Java 类com.intellij.util.ui.ColumnInfo 实例源码

项目:intellij-ce-playground    文件:DetectedRootsChooser.java   
public void setElements(List<? extends DetectedRootData> roots) {
  Set<String> rootTypes = new HashSet<String>();
  for (DetectedRootData root : roots) {
    for (DetectedProjectRoot projectRoot : root.getAllRoots()) {
      rootTypes.add(projectRoot.getRootTypeName());
    }
  }
  myModel.setColumnInfos(new ColumnInfo[]{myIncludedColumn, ROOT_COLUMN, ROOT_TYPE_COLUMN});
  int max = 0;
  for (String rootType : rootTypes) {
    max = Math.max(max, myTable.getFontMetrics(myTable.getFont()).stringWidth(rootType));
  }
  final TableColumn column = myTable.getColumnModel().getColumn(2);
  int width = max + 20;//add space for combobox button
  column.setPreferredWidth(width);
  column.setMaxWidth(width);
  myTable.updateColumnSizes();
  List<DetectedRootData> sortedRoots = new ArrayList<DetectedRootData>(roots);
  Collections.sort(sortedRoots, new Comparator<DetectedRootData>() {
    @Override
    public int compare(DetectedRootData o1, DetectedRootData o2) {
      return o1.getDirectory().compareTo(o2.getDirectory());
    }
  });
  myModel.setItems(sortedRoots);
}
项目:intellij-ce-playground    文件:DualView.java   
private ColumnInfo[] createTreeColumns(DualViewColumnInfo[] columns) {
  Collection<ColumnInfo> result = new ArrayList<ColumnInfo>();

  final ColumnInfo firstColumn = columns[0];
  ColumnInfo firstTreeColumn = new ColumnInfo(firstColumn.getName()) {
    public Object valueOf(Object object) {
      return firstColumn.valueOf(object);
    }

    public Class getColumnClass() {
      return TreeTableModel.class;
    }

    public boolean isCellEditable(Object o) {
      return true;
    }
  };
  result.add(firstTreeColumn);
  for (int i = 1; i < columns.length; i++) {
    DualViewColumnInfo column = columns[i];
    if (column.shouldBeShownIsTheTree()) result.add(column);
  }

  return result.toArray(new ColumnInfo[result.size()]);
}
项目:intellij-ce-playground    文件:TableModelEditor.java   
@Override
public void setValueAt(Object newValue, int rowIndex, int columnIndex) {
  if (rowIndex < getRowCount()) {
    @SuppressWarnings("unchecked")
    ColumnInfo<T, Object> column = (ColumnInfo<T, Object>)getColumnInfos()[columnIndex];
    T item = getItem(rowIndex);
    Object oldValue = column.valueOf(item);
    if (column.getColumnClass() == String.class
        ? !Comparing.strEqual(((String)oldValue), ((String)newValue))
        : !Comparing.equal(oldValue, newValue)) {

      column.setValue(helper.getMutable(item, rowIndex), newValue);
      if (dataChangedListener != null) {
        dataChangedListener.dataChanged(column, rowIndex);
      }
    }
  }
}
项目:intellij-ce-playground    文件:PlatformComponentsPanel.java   
private void createUIComponents() {
  UpdaterTreeNode.Renderer renderer = new SummaryTreeNode.Renderer();

  myPlatformLoadingIcon = new AsyncProcessIcon("Loading...");
  myPlatformSummaryRootNode = new RootNode();
  myPlatformDetailsRootNode = new RootNode();
  ColumnInfo[] platformSummaryColumns =
    new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new ApiLevelColumnInfo(), new RevisionColumnInfo(),
      new StatusColumnInfo()};
  myPlatformSummaryTable = new TreeTableView(new ListTreeTableModelOnColumns(myPlatformSummaryRootNode, platformSummaryColumns));
  SdkUpdaterConfigPanel.setTreeTableProperties(myPlatformSummaryTable, renderer);
  MouseListener modificationListener = new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      refreshModified();
    }
  };
  myPlatformSummaryTable.addMouseListener(modificationListener);

  ColumnInfo[] platformDetailColumns =
    new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new ApiLevelColumnInfo(), new RevisionColumnInfo(),
      new StatusColumnInfo()};
  myPlatformDetailTable = new TreeTableView(new ListTreeTableModelOnColumns(myPlatformDetailsRootNode, platformDetailColumns));
  SdkUpdaterConfigPanel.setTreeTableProperties(myPlatformDetailTable, renderer);
  myPlatformDetailTable.addMouseListener(modificationListener);
}
项目:intellij-ce-playground    文件:UIPropertyBinding.java   
public void loadValues(AbstractProperty.AbstractPropertyContainer container) {
  if (myColumnWidthProperty != null) {
    BaseTableView.restoreWidth(myColumnWidthProperty.get(container), getComponent().getColumnModel());
  }
  myModel.setItems(myProperty.getModifiableList(container));
  if (myModel.isSortable()) {
    final ColumnInfo[] columnInfos = myModel.getColumnInfos();
    int sortByColumn = -1;
    for (int idx = 0; idx < columnInfos.length; idx++) {
      ColumnInfo columnInfo = columnInfos[idx];
      if (columnInfo.isSortable()) {
        sortByColumn = idx;
        break;
      }
    }
  }
  TableUtil.ensureSelectionExists(getComponent());
}
项目:Dynatrace-AppMon-IntelliJ-IDEA-Integration-Plugin    文件:TestRunResultsView.java   
public TestRunResultsView(Project project) {
    this.model = new ListTreeTableModelOnColumns(null, COLUMNS.toArray(new ColumnInfo[COLUMNS.size()]));
    this.tree = new TreeTable(this.model);

    this.tree.getColumnModel().getColumn(0).setMinWidth(TestMeasureColumnInfo.MeasureProperty.GROUP.width * 2);
    for (TestMeasureColumnInfo.MeasureProperty prop : TestMeasureColumnInfo.MeasureProperty.values()) {
        //first column is name column which is not included in MeasureProperties, that's why we add 1.
        this.tree.getColumnModel().getColumn(prop.ordinal() + 1).setMinWidth(prop.width);
    }

    this.panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(this.tree));
    //set text when no tests were fetched yet
    this.setEmptyText(Messages.getMessage("execution.result.ui.loading"));

    //add rightclick dialog
    DefaultActionGroup dag = new DefaultActionGroup();
    dag.add(new OpenInEditorAction(() -> {
        TestResultNode node = this.getSelectedNode();
        if (node != null) {
            return node.getResult();
        }
        return null;
    }, project));
    PopupHandler.installUnknownPopupHandler(this.tree, dag, ActionManager.getInstance());
}
项目:tools-idea    文件:DetectedRootsChooser.java   
public void setElements(List<? extends DetectedRootData> roots) {
  Set<String> rootTypes = new HashSet<String>();
  for (DetectedRootData root : roots) {
    for (DetectedProjectRoot projectRoot : root.getAllRoots()) {
      rootTypes.add(projectRoot.getRootTypeName());
    }
  }
  myModel.setColumnInfos(new ColumnInfo[]{myIncludedColumn, ROOT_COLUMN, ROOT_TYPE_COLUMN});
  int max = 0;
  for (String rootType : rootTypes) {
    max = Math.max(max, myTable.getFontMetrics(myTable.getFont()).stringWidth(rootType));
  }
  final TableColumn column = myTable.getColumnModel().getColumn(2);
  int width = max + 20;//add space for combobox button
  column.setPreferredWidth(width);
  column.setMaxWidth(width);
  myTable.updateColumnSizes();
  List<DetectedRootData> sortedRoots = new ArrayList<DetectedRootData>(roots);
  Collections.sort(sortedRoots, new Comparator<DetectedRootData>() {
    @Override
    public int compare(DetectedRootData o1, DetectedRootData o2) {
      return o1.getDirectory().compareTo(o2.getDirectory());
    }
  });
  myModel.setItems(sortedRoots);
}
项目:tools-idea    文件:DualView.java   
private ColumnInfo[] createTreeColumns(DualViewColumnInfo[] columns) {
  Collection<ColumnInfo> result = new ArrayList<ColumnInfo>();

  final ColumnInfo firstColumn = columns[0];
  ColumnInfo firstTreeColumn = new ColumnInfo(firstColumn.getName()) {
    public Object valueOf(Object object) {
      return firstColumn.valueOf(object);
    }

    public Class getColumnClass() {
      return TreeTableModel.class;
    }

    public boolean isCellEditable(Object o) {
      return true;
    }
  };
  result.add(firstTreeColumn);
  for (int i = 1; i < columns.length; i++) {
    DualViewColumnInfo column = columns[i];
    if (column.shouldBeShownIsTheTree()) result.add(column);
  }

  return result.toArray(new ColumnInfo[result.size()]);
}
项目:tools-idea    文件:PluginTable.java   
public PluginTable(final PluginTableModel model) {
  super(model);
  getColumnModel().setColumnMargin(0);
  for (int i = 0; i < model.getColumnCount(); i++) {
    TableColumn column = getColumnModel().getColumn(i);
    final ColumnInfo columnInfo = model.getColumnInfos()[i];
    column.setCellEditor(columnInfo.getEditor(null));
    if (columnInfo.getColumnClass() == Boolean.class) {
      final int width = new JCheckBox().getPreferredSize().width;
      column.setWidth(width);
      column.setPreferredWidth(width);
      column.setMaxWidth(width);
      column.setMinWidth(width);
    }
  }

  setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  setShowGrid(false);
  setStriped(true);
}
项目:tools-idea    文件:UIPropertyBinding.java   
public void loadValues(AbstractProperty.AbstractPropertyContainer container) {
  if (myColumnWidthProperty != null) {
    BaseTableView.restoreWidth(myColumnWidthProperty.get(container), getComponent().getColumnModel());
  }
  myModel.setItems(myProperty.getModifiableList(container));
  if (myModel.isSortable()) {
    final ColumnInfo[] columnInfos = myModel.getColumnInfos();
    int sortByColumn = -1;
    for (int idx = 0; idx < columnInfos.length; idx++) {
      ColumnInfo columnInfo = columnInfos[idx];
      if (columnInfo.isSortable()) {
        sortByColumn = idx;
        break;
      }
    }
  }
  TableUtil.ensureSelectionExists(getComponent());
}
项目:tools-idea    文件:GitLogUI.java   
private void initAuthor() {
  AUTHOR = new ColumnInfo<Object, String>("Author") {
    @Override
    public String valueOf(Object o) {
      if (o instanceof GitHeavyCommit) {
        return ((GitHeavyCommit)o).getAuthor();
      }
      return "";
    }

    @Override
    public TableCellRenderer getRenderer(Object o) {
      return myAuthorRenderer;
    }
  };
}
项目:tools-idea    文件:GitLogPerformanceTest.java   
private void impl(RootsHolder rootsHolder, GitLogFilters filters) {
  final GitCommitsSequentialIndex commitsSequentially = new GitCommitsSequentialIndex();
  final MediatorImpl mediator = new MediatorImpl(myProject, commitsSequentially);
  final LoadController controller = new LoadController(myProject, mediator, null, commitsSequentially);

  mediator.setLoader(controller);
  final BigTableTableModel tableModel = new BigTableTableModel(Collections.<ColumnInfo>emptyList(), EmptyRunnable.getInstance());
  mediator.setTableModel(tableModel);
  tableModel.setRootsHolder(rootsHolder);
  final Semaphore semaphore = new Semaphore();
  final MyUIRefresh refresh = new MyUIRefresh(semaphore);
  mediator.setUIRefresh(refresh);

  final long start = System.currentTimeMillis();
  semaphore.down();
  mediator.reload(rootsHolder, Collections.<String>emptyList(), Collections.<String>emptyList(), filters, true);
  semaphore.waitFor(300000);
  refresh.assertMe();
  final long end = System.currentTimeMillis();
  System.out.println("Time: " + (end - start));
}
项目:nosql4idea    文件:JsonTreeTableView.java   
public JsonTreeTableView(TreeNode rootNode, ColumnInfo[] columnInfos) {
    super(new ListTreeTableModelOnColumns(rootNode, columnInfos));
    this.columns = columnInfos;

    final TreeTableTree tree = getTree();

    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    UIUtil.setLineStyleAngled(tree);
    setTreeCellRenderer(new KeyCellRenderer());

    TreeUtil.expand(tree, 2);

    new TreeTableSpeedSearch(this, new Convertor<TreePath, String>() {
        @Override
        public String convert(final TreePath path) {
            final NoSqlTreeNode node = (NoSqlTreeNode) path.getLastPathComponent();
            NodeDescriptor descriptor = node.getDescriptor();
            return descriptor.getFormattedKey();
        }
    });
}
项目:consulo-apache-ant    文件:UIPropertyBinding.java   
public void loadValues(AbstractProperty.AbstractPropertyContainer container) {
  if (myColumnWidthProperty != null) {
    BaseTableView.restoreWidth(myColumnWidthProperty.get(container), getComponent().getColumnModel());
  }
  myModel.setItems(myProperty.getModifiableList(container));
  if (myModel.isSortable()) {
    final ColumnInfo[] columnInfos = myModel.getColumnInfos();
    int sortByColumn = -1;
    for (int idx = 0; idx < columnInfos.length; idx++) {
      ColumnInfo columnInfo = columnInfos[idx];
      if (columnInfo.isSortable()) {
        sortByColumn = idx;
        break;
      }
    }
  }
  TableUtil.ensureSelectionExists(getComponent());
}
项目:consulo    文件:DualView.java   
private ColumnInfo[] createTreeColumns(DualViewColumnInfo[] columns) {
  Collection<ColumnInfo> result = new ArrayList<ColumnInfo>();

  final ColumnInfo firstColumn = columns[0];
  ColumnInfo firstTreeColumn = new ColumnInfo(firstColumn.getName()) {
    public Object valueOf(Object object) {
      return firstColumn.valueOf(object);
    }

    public Class getColumnClass() {
      return TreeTableModel.class;
    }

    public boolean isCellEditable(Object o) {
      return true;
    }
  };
  result.add(firstTreeColumn);
  for (int i = 1; i < columns.length; i++) {
    DualViewColumnInfo column = columns[i];
    if (column.shouldBeShownIsTheTree()) result.add(column);
  }

  return result.toArray(new ColumnInfo[result.size()]);
}
项目:consulo    文件:TableModelEditor.java   
@Override
public void setValueAt(Object newValue, int rowIndex, int columnIndex) {
  if (rowIndex < getRowCount()) {
    @SuppressWarnings("unchecked")
    ColumnInfo<T, Object> column = (ColumnInfo<T, Object>)getColumnInfos()[columnIndex];
    T item = getItem(rowIndex);
    Object oldValue = column.valueOf(item);
    if (column.getColumnClass() == String.class
        ? !Comparing.strEqual(((String)oldValue), ((String)newValue))
        : !Comparing.equal(oldValue, newValue)) {

      column.setValue(helper.getMutable(item, rowIndex), newValue);
      if (dataChangedListener != null) {
        dataChangedListener.dataChanged(column, rowIndex);
      }
    }
  }
}
项目:consulo    文件:FileHistoryPanelImpl.java   
@Nonnull
private DualViewColumnInfo[] createColumnList(@Nonnull Project project,
                                              @Nonnull VcsHistoryProvider provider,
                                              @Nullable ColumnInfo[] additionalColumns) {
  ArrayList<DualViewColumnInfo> columns = new ArrayList<>();
  columns.add(new RevisionColumnInfo(myRevisionsInOrderComparator));
  if (!provider.isDateOmittable()) columns.add(new DateColumnInfo());
  columns.add(new AuthorColumnInfo());
  ArrayList<DualViewColumnInfo> additionalColumnInfo = new ArrayList<>();
  if (additionalColumns != null) {
    for (ColumnInfo additionalColumn : additionalColumns) {
      additionalColumnInfo.add(new FileHistoryColumnWrapper(additionalColumn) {
        @Override
        protected DualView getDualView() {
          return myDualView;
        }
      });
    }
  }
  columns.addAll(additionalColumnInfo);
  columns.add(new MessageColumnInfo(project));
  return columns.toArray(new DualViewColumnInfo[columns.size()]);
}
项目:intellij-ce-playground    文件:ListTreeTableModelOnColumns.java   
/**
 * @param columns
 * @return true if changed
 */
public boolean setColumns(ColumnInfo[] columns) {
  if (myColumns != null && Arrays.equals(myColumns, columns)) {
    return false;
  }
  myColumns = columns;
  return true;
}
项目:intellij-ce-playground    文件:TableView.java   
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
  final ColumnInfo<Item, ?> columnInfo = getListTableModel().getColumnInfos()[convertColumnIndexToModel(column)];
  final Item item = getRow(row);
  final TableCellRenderer renderer = columnInfo.getCustomizedRenderer(item, columnInfo.getRenderer(item));
  if (renderer == null) {
    return super.getCellRenderer(row, column);
  }
  else {
    return renderer;
  }
}
项目:intellij-ce-playground    文件:CheckboxTreeTable.java   
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) {
  super(new ListTreeTableModelOnColumns(root, columns));
  final TreeTableTree tree = getTree();
  myEventDispatcher = EventDispatcher.create(CheckboxTreeListener.class);
  CheckboxTreeHelper helper = new CheckboxTreeHelper(CheckboxTreeHelper.DEFAULT_POLICY, myEventDispatcher);
  helper.initTree(tree, this, renderer);
  tree.setSelectionRow(0);
}
项目:intellij-ce-playground    文件:TableModelEditor.java   
/**
 * source will be copied, passed list will not be used directly
 *
 * Implement {@link DialogItemEditor} instead of {@link CollectionItemEditor} if you want provide dialog to edit.
 */
public TableModelEditor(@NotNull List<T> items, @NotNull ColumnInfo[] columns, @NotNull CollectionItemEditor<T> itemEditor, @NotNull String emptyText) {
  super(itemEditor);

  model = new MyListTableModel(columns, new ArrayList<T>(items));
  table = new TableView<T>(model);
  table.setDefaultEditor(Enum.class, ComboBoxTableCellEditor.INSTANCE);
  table.setStriped(true);
  table.setEnableAntialiasing(true);
  preferredScrollableViewportHeightInRows(JBTable.PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS);
  new TableSpeedSearch(table);
  ColumnInfo firstColumn = columns[0];
  if ((firstColumn.getColumnClass() == boolean.class || firstColumn.getColumnClass() == Boolean.class) && firstColumn.getName().isEmpty()) {
    TableUtil.setupCheckboxColumn(table.getColumnModel().getColumn(0));
  }

 boolean needTableHeader = false;
  for (ColumnInfo column : columns) {
    if (!StringUtil.isEmpty(column.getName())) {
      needTableHeader = true;
      break;
    }
  }

  if (!needTableHeader) {
    table.setTableHeader(null);
  }

  table.getEmptyText().setText(emptyText);
  MyRemoveAction removeAction = new MyRemoveAction();
  toolbarDecorator = ToolbarDecorator.createDecorator(table, this).setRemoveAction(removeAction).setRemoveActionUpdater(removeAction);

  if (itemEditor instanceof DialogItemEditor) {
    addDialogActions();
  }
}
项目:intellij-ce-playground    文件:TableModelEditor.java   
@NotNull
public List<T> apply() {
  if (helper.hasModifiedItems()) {
    @SuppressWarnings("unchecked")
    final ColumnInfo<T, Object>[] columns = model.getColumnInfos();
    helper.process(new TObjectObjectProcedure<T, T>() {
      @Override
      public boolean execute(T newItem, @NotNull T oldItem) {
        for (ColumnInfo<T, Object> column : columns) {
          if (column.isCellEditable(newItem)) {
            column.setValue(oldItem, column.valueOf(newItem));
          }
        }

        if (itemEditor instanceof DialogItemEditor) {
          ((DialogItemEditor<T>)itemEditor).applyEdited(oldItem, newItem);
        }

        model.items.set(ContainerUtil.indexOfIdentity(model.items, newItem), oldItem);
        return true;
      }
    });
  }

  helper.reset(model.items);
  return model.items;
}
项目:intellij-ce-playground    文件:CompareWithSelectedRevisionAction.java   
private static void showTreePopup(final List<TreeItem<VcsFileRevision>> roots, final VirtualFile file, final Project project, final DiffProvider diffProvider) {
  final TreeTableView treeTable = new TreeTableView(new ListTreeTableModelOnColumns(new TreeNodeAdapter(null, null, roots),
                                                                                    new ColumnInfo[]{BRANCH_COLUMN, REVISION_COLUMN,
                                                                                    DATE_COLUMN, AUTHOR_COLUMN}));
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      int index = treeTable.getSelectionModel().getMinSelectionIndex();
      if (index == -1) {
        return;
      }
      VcsFileRevision revision = getRevisionAt(treeTable, index);
      if (revision != null) {
        DiffActionExecutor.showDiff(diffProvider, revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH);
      }
    }
  };

  treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  new PopupChooserBuilder(treeTable).
    setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).
    setItemChoosenCallback(runnable).
    setSouthComponent(createCommentsPanel(treeTable)).
    setResizable(true).
    setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").
    createPopup().
    showCenteredInCurrentWindow(project);

  final int lastRow = treeTable.getRowCount() - 1;
  if (lastRow < 0) return;
  treeTable.getSelectionModel().addSelectionInterval(lastRow, lastRow);
  treeTable.scrollRectToVisible(treeTable.getCellRect(lastRow, 0, true));
}
项目:intellij-ce-playground    文件:CommittedChangesTableModel.java   
private static ColumnInfo[] buildColumnInfos(final ChangeListColumn[] columns) {
  ColumnInfo[] result = new ColumnInfo[columns.length];
  for(int i=0; i<columns.length; i++) {
    result [i] = new ColumnInfoAdapter(columns [i]);
  }
  return result;
}
项目:intellij-ce-playground    文件:IssueNavigationConfigurationPanel.java   
public void reset() {
  IssueNavigationConfiguration configuration = IssueNavigationConfiguration.getInstance(myProject);
  myLinks = new ArrayList<IssueNavigationLink>();
  for(IssueNavigationLink link: configuration.getLinks()) {
    myLinks.add(new IssueNavigationLink(link.getIssueRegexp(), link.getLinkRegexp()));
  }
  myModel = new ListTableModel<IssueNavigationLink>(
    new ColumnInfo[] { ISSUE_COLUMN, LINK_COLUMN },
    myLinks,
    0);
  myLinkTable.setModel(myModel);
}
项目:intellij-ce-playground    文件:VcsHistoryDialog.java   
private static ColumnInfo[] createColumns(ColumnInfo[] additionalColumns) {
  if (additionalColumns == null) {
    return COLUMNS;
  }

  ColumnInfo[] result = new ColumnInfo[additionalColumns.length + COLUMNS.length];

  System.arraycopy(COLUMNS, 0, result, 0, COLUMNS.length);
  System.arraycopy(additionalColumns, 0, result, COLUMNS.length, additionalColumns.length);

  return result;
}
项目:intellij-ce-playground    文件:ParameterTableModelBase.java   
public ParameterTableModelBase(PsiElement typeContext,
                               PsiElement defaultValueContext,
                               ColumnInfo... columnInfos) {
  super(columnInfos);
  myTypeContext = typeContext;
  myDefaultValueContext = defaultValueContext;
}
项目:intellij-ce-playground    文件:DomCollectionControl.java   
public DomCollectionControl(@NotNull DomElement parentElement,
                            @NotNull DomCollectionChildDescription description,
                            final boolean editable,
                            ColumnInfo<T, ?>... columnInfos) {
  myChildDescription = description;
  myParentDomElement = parentElement;
  myColumnInfos = columnInfos;
  myEditable = editable;
}
项目:intellij-ce-playground    文件:DomUIFactory.java   
public ColumnInfo createColumnInfo(final DomCollectionChildDescription description,
                                   final DomElement element) {
  final String presentableName = description.getCommonPresentableName(element);
  final Class aClass = DomUtil.extractParameterClassFromGenericType(description.getType());
  if (aClass != null) {
    if (Boolean.class.equals(aClass) || boolean.class.equals(aClass)) {
      return new BooleanColumnInfo(presentableName);
    }

    return new GenericValueColumnInfo(presentableName, aClass, createCellEditor(element, aClass));
  }

  return new StringColumnInfo(presentableName);
}
项目:intellij-ce-playground    文件:AbstractTableView.java   
protected void adjustColumnWidths() {
  final ColumnInfo[] columnInfos = myTableModel.getColumnInfos();
  for (int i = 0; i < columnInfos.length; i++) {
    final int width = getColumnPreferredWidth(i);
    if (width > 0) {
      myTable.getColumnModel().getColumn(i).setPreferredWidth(width);
    }
  }
}
项目:intellij-ce-playground    文件:AbstractTableView.java   
protected int getColumnPreferredWidth(final int i) {
  final ColumnInfo columnInfo = myTableModel.getColumnInfos()[i];
  final java.util.List items = myTableModel.getItems();
  int width = -1;
  for (int j = 0; j < items.size(); j++) {
    final TableCellRenderer renderer = myTable.getCellRenderer(j, i);
    final Component component = renderer.getTableCellRendererComponent(myTable, columnInfo.valueOf(items.get(j)), false, false, j, i);
    width = Math.max(width, component.getPreferredSize().width);
  }
  return width;
}
项目:intellij-ce-playground    文件:AbstractTableView.java   
public final void reset(ColumnInfo[] columnInfos, List<? extends T> data) {
  final boolean columnsChanged = myTableModel.setColumnInfos(columnInfos);
  final boolean dataChanged = !data.equals(myTableModel.getItems());
  final int oldRowCount = myTableModel.getRowCount();
  if ((dataChanged || columnsChanged) && myTable.isEditing()) {
    myTable.getCellEditor().cancelCellEditing();
  }

  if (dataChanged) {
    final int selectedRow = myTable.getSelectedRow();
    myTableModel.setItems(new ArrayList<T>(data));
    if (selectedRow >= 0 && selectedRow < myTableModel.getRowCount()) {
      myTable.getSelectionModel().setSelectionInterval(selectedRow, selectedRow);
    }
  }

  myTableModel.cacheValues();
  final int rowCount = myTableModel.getRowCount();
  final int columnCount = myTableModel.getColumnCount();
  myCachedRenderers = new TableCellRenderer[rowCount][columnCount];
  for (int row = 0; row < rowCount; row++) {
    for (int column = 0; column < columnCount; column++) {
      final TableCellRenderer superRenderer = myTable.getSuperCellRenderer(row, column);
      myCachedRenderers[row][column] = getTableCellRenderer(row, column, superRenderer, myTableModel.getItems().get(row));
    }
  }
  if (columnsChanged || oldRowCount == 0 && rowCount != 0) {
    adjustColumnWidths();
  }

  myTable.revalidate();
  myTable.repaint();
}
项目:intellij-ce-playground    文件:ToolComponentsPanel.java   
private void createUIComponents() {
  myToolsLoadingIcon = new AsyncProcessIcon("Loading...");

  myToolsSummaryRootNode = new RootNode();
  myToolsDetailsRootNode = new RootNode();

  UpdaterTreeNode.Renderer renderer = new SummaryTreeNode.Renderer();

  ColumnInfo[] toolsSummaryColumns =
    new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new VersionColumnInfo(), new StatusColumnInfo()};
  myToolsSummaryTable = new TreeTableView(new ListTreeTableModelOnColumns(myToolsSummaryRootNode, toolsSummaryColumns));

  SdkUpdaterConfigPanel.setTreeTableProperties(myToolsSummaryTable, renderer);

  ColumnInfo[] toolsDetailColumns =
    new ColumnInfo[]{new DownloadStatusColumnInfo(), new TreeColumnInfo("Name"), new VersionColumnInfo(), new StatusColumnInfo()};
  myToolsDetailTable = new TreeTableView(new ListTreeTableModelOnColumns(myToolsDetailsRootNode, toolsDetailColumns));
  SdkUpdaterConfigPanel.setTreeTableProperties(myToolsDetailTable, renderer);

  MouseListener modificationListener = new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      refreshModified();
    }
  };
  myToolsDetailTable.addMouseListener(modificationListener);
  myToolsSummaryTable.addMouseListener(modificationListener);
}
项目:intellij-ce-playground    文件:TestTableRenderer.java   
public TestTableRenderer(final ColumnInfo[] columns) {
  myRenderers = new TableCellRenderer[columns.length];
  for (int i = 0; i < columns.length; i++) {
    final ColumnInfo column = columns[i];
    myRenderers[i] = column.getRenderer(null);
  }
}
项目:intellij-ce-playground    文件:BuildFilePropertiesPanel.java   
public PropertiesTab() {
  myPropertiesTable = new JBTable();
  UIPropertyBinding.TableListBinding<BuildFileProperty> tableListBinding = getBinding().bindList(myPropertiesTable, PROPERTY_COLUMNS,
                                                                                                 AntBuildFileImpl.ANT_PROPERTIES);
  tableListBinding.setColumnWidths(GlobalAntConfiguration.PROPERTIES_TABLE_LAYOUT);

  myWholePanel = ToolbarDecorator.createDecorator(myPropertiesTable)
    .setAddAction(new AnActionButtonRunnable() {


      @Override
      public void run(AnActionButton button) {
        if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
          return;
        }
        BuildFileProperty item = new BuildFileProperty();
        ListTableModel<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)myPropertiesTable.getModel();
        ArrayList<BuildFileProperty> items = new ArrayList<BuildFileProperty>(model.getItems());
        items.add(item);
        model.setItems(items);
        int newIndex = model.indexOf(item);
        ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
        selectionModel.clearSelection();
        selectionModel.setSelectionInterval(newIndex, newIndex);
        ColumnInfo[] columns = model.getColumnInfos();
        for (int i = 0; i < columns.length; i++) {
          ColumnInfo column = columns[i];
          if (column.isCellEditable(item)) {
            myPropertiesTable.requestFocusInWindow();
            myPropertiesTable.editCellAt(newIndex, i);
            break;
          }
        }
      }
    }).disableUpDownActions().createPanel();
  myWholePanel.setBorder(null);
}
项目:intellij-ce-playground    文件:UIPropertyBinding.java   
public void addAddFacility(JButton addButton, final Factory<T> factory) {
  myComponents.add(addButton);
  addButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      JTable table = getComponent();
      if (table.isEditing() && !table.getCellEditor().stopCellEditing()) {
        return;
      }
      T item = factory.create();
      if (item == null) {
        return;
      }
      ArrayList<T> items = new ArrayList<T>(myModel.getItems());
      items.add(item);
      myModel.setItems(items);
      int newIndex = myModel.indexOf(item);
      ListSelectionModel selectionModel = table.getSelectionModel();
      selectionModel.clearSelection();
      selectionModel.setSelectionInterval(newIndex, newIndex);
      ColumnInfo[] columns = myModel.getColumnInfos();
      for (int i = 0; i < columns.length; i++) {
        ColumnInfo column = columns[i];
        if (column.isCellEditable(item)) {
          table.requestFocusInWindow();
          table.editCellAt(newIndex, i);
          break;
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:JavaCoverageViewExtension.java   
@Override
public ColumnInfo[] createColumnInfos() {
  return new ColumnInfo[]{
    new ElementColumnInfo(), 
    new PercentageCoverageColumnInfo(1, "Class, %", mySuitesBundle, myStateBean), 
    new PercentageCoverageColumnInfo(2, "Method, %", mySuitesBundle, myStateBean),
    new PercentageCoverageColumnInfo(3, "Line, %", mySuitesBundle, myStateBean)
  };
}
项目:vso-intellij    文件:WorkspaceMappingsTableEditor.java   
public void setMappings(final List<Workspace.Mapping> mappings) {
    if (mappings != null) {
        final List<Row> rows = new ArrayList<Row>(mappings.size());
        for (final Workspace.Mapping mapping : mappings) {
            rows.add(new Row(mapping.getServerPath(), mapping.getLocalPath(),
                    mapping.isCloaked() ? MappingType.CLOAKED : MappingType.MAPPED));
        }
        setModel(new ColumnInfo[]{new MappingTypeColumn(), new ServerPathColumn(project, serverContext), new LocalPathColumn(project)}, rows);
    }
}
项目:vso-intellij    文件:CustomTreeTable.java   
private static <T> TreeTableModel createModel(final Collection<? extends TreeTableColumn<T>> columns,
                                              final ContentProvider<T> contentProvider) {
    final Collection<ColumnInfo> columnsInfos = new ArrayList<ColumnInfo>(columns.size());
    boolean first = true;
    for (final TreeTableColumn<T> column : columns) {
        if (first) {
            columnsInfos.add(new TreeColumnInfo(column.getCaption()));
        } else {
            columnsInfos.add(new ColumnInfo(column.getCaption()) {
                public Object valueOf(final Object o) {
                    return o;
                }

                public Class getColumnClass() {
                    return TableColumnMarker.class;
                }
            });
        }
        first = false;
    }

    final DefaultMutableTreeNode root;
    final Collection<? extends T> rootObjects = contentProvider.getRoots();
    if (!rootObjects.isEmpty()) {
        if (rootObjects.size() == 1) {
            root = new DefaultMutableTreeNode(rootObjects.iterator().next());
            addChildren(root, contentProvider);
        } else {
            root = new DefaultMutableTreeNode(HIDDEN_ROOT);
            for (final T rootObject : rootObjects) {
                final DefaultMutableTreeNode subRoot = new DefaultMutableTreeNode(rootObject);
                addChildren(subRoot, contentProvider);
                root.add(subRoot);
            }
        }
    } else {
        root = null;
    }
    return new ListTreeTableModelOnColumns(root, columnsInfos.toArray(new ColumnInfo[columnsInfos.size()]));
}
项目:vso-intellij    文件:WorkItemsTableModel.java   
public WorkItemsTableModel(@NotNull WorkItemsCheckinParameters content) {
  super(null, new ColumnInfo[]{new CheckBoxColumn(content), TYPE, ID, TITLE, STATE, new CheckInActionColumn(content)});

  myContent = content;

  myRoot = new DefaultMutableTreeNode();
  setRoot(myRoot);
}