Search in sources :

Example 11 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-plugins by JetBrains.

the class CompilerOptionsConfigurable method createColumns.

private ColumnInfo[] createColumns() {
    final ColumnInfo optionColumn = new ColumnInfo("Option") {

        public Object valueOf(final Object o) {
            final Object userObject = ((DefaultMutableTreeNode) o).getUserObject();
            return userObject instanceof CompilerOptionInfo ? userObject : o;
        }

        public Class getColumnClass() {
            return TreeTableModel.class;
        }
    };
    final ColumnInfo valueColumn = new ColumnInfo("Value") {

        public Object valueOf(Object o) {
            final Object userObject = ((DefaultMutableTreeNode) o).getUserObject();
            return userObject instanceof CompilerOptionInfo && !((CompilerOptionInfo) userObject).isGroup() ? userObject : null;
        }

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

        //public TableCellRenderer getRenderer(Object o) {
        //  return myValueRenderer;
        //}
        //public TableCellEditor getEditor(Object item) {
        //  return myEditor;
        //}
        public boolean isCellEditable(Object o) {
            final Object userObject = ((DefaultMutableTreeNode) o).getUserObject();
            return userObject instanceof CompilerOptionInfo && !((CompilerOptionInfo) userObject).isGroup();
        }

        public void setValue(Object node, Object value) {
            final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
            final CompilerOptionInfo info = (CompilerOptionInfo) treeNode.getUserObject();
            final Pair<String, ValueSource> valueAndSource = getValueAndSource(info);
            // don't apply if user just clicked through the table without typing anything
            if (!value.equals(valueAndSource.first)) {
                myMapModified = true;
                myCurrentOptions.put(info.ID, (String) value);
                reloadNodeOrGroup(myTreeTable.getTree(), treeNode);
            }
        }
    };
    return new ColumnInfo[] { optionColumn, valueColumn };
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) ValueSource(com.intellij.flex.model.bc.ValueSource) ColumnInfo(com.intellij.util.ui.ColumnInfo) ListTreeTableModel(com.intellij.ui.treeStructure.treetable.ListTreeTableModel) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel)

Example 12 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-plugins by JetBrains.

the class EditableTreeTable method getCellEditor.

// copied from TableView
@Override
public TableCellEditor getCellEditor(int row, int column) {
    ListTreeTableModelOnColumns model = (ListTreeTableModelOnColumns) getTableModel();
    final ColumnInfo columnInfo = model.getColumnInfos()[convertColumnIndexToModel(column)];
    T item = (T) getValueAt(convertRowIndexToModel(row), 0);
    final TableCellEditor editor = columnInfo.getEditor(item);
    return editor == null ? super.getCellEditor(row, column) : editor;
}
Also used : ColumnInfo(com.intellij.util.ui.ColumnInfo) TableCellEditor(javax.swing.table.TableCellEditor)

Example 13 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-plugins by JetBrains.

the class EditableTreeTable method updateColumnSizes.

// copied from TableView
public void updateColumnSizes() {
    final JTableHeader header = getTableHeader();
    final TableCellRenderer defaultRenderer = header == null ? null : header.getDefaultRenderer();
    ColumnInfo[] columns = ((ListTreeTableModelOnColumns) getTableModel()).getColumnInfos();
    for (int i = 0; i < columns.length; i++) {
        final ColumnInfo columnInfo = columns[i];
        final TableColumn column = getColumnModel().getColumn(i);
        final Component headerComponent = defaultRenderer == null ? null : defaultRenderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
        final Dimension headerSize = headerComponent == null ? JBUI.emptySize() : headerComponent.getPreferredSize();
        final String maxStringValue;
        final String preferredValue;
        if (columnInfo.getWidth(this) > 0) {
            int width = columnInfo.getWidth(this);
            column.setMaxWidth(width);
            column.setPreferredWidth(width);
            column.setMinWidth(width);
        } else if ((maxStringValue = columnInfo.getMaxStringValue()) != null) {
            int width = getFontMetrics(getFont()).stringWidth(maxStringValue) + columnInfo.getAdditionalWidth();
            width = Math.max(width, headerSize.width);
            column.setPreferredWidth(width);
            column.setMaxWidth(width);
        } else if ((preferredValue = columnInfo.getPreferredStringValue()) != null) {
            int width = getFontMetrics(getFont()).stringWidth(preferredValue) + columnInfo.getAdditionalWidth();
            width = Math.max(width, headerSize.width);
            column.setPreferredWidth(width);
        }
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JTableHeader(javax.swing.table.JTableHeader) ColumnInfo(com.intellij.util.ui.ColumnInfo) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) TableColumn(javax.swing.table.TableColumn)

Example 14 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-plugins by JetBrains.

the class CallTreeTable method getHotSpotsColumns.

private static ColumnInfo[] getHotSpotsColumns() {
    final ColumnInfo methodsColumn = new ColumnInfo("Methods") {

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

        @Override
        public Object valueOf(final Object o) {
            return o;
        }

        @Override
        public Comparator getComparator() {
            return new FrameNameComparator();
        }
    };
    final ColumnInfo countColumn = new AbstractCallColumnInfo("Cumulative time, ms") {

        @Override
        public Comparator<DefaultMutableTreeNode> getComparator() {
            return new CumulativeTimeComparator();
        }

        @Override
        protected long extractValueFromCallInfo(CallInfo value) {
            return value.getCumulativeTime();
        }
    };
    final ColumnInfo selfColumn = new AbstractCallColumnInfo("Self time, ms") {

        @Override
        public Comparator<DefaultMutableTreeNode> getComparator() {
            return new SelfTimeComparator();
        }

        @Override
        protected long extractValueFromCallInfo(CallInfo value) {
            return value.getSelfTime();
        }
    };
    return new ColumnInfo[] { methodsColumn, countColumn, selfColumn };
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CallInfo(com.jetbrains.actionscript.profiler.vo.CallInfo) ColumnInfo(com.intellij.util.ui.ColumnInfo) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel)

Example 15 with ColumnInfo

use of com.intellij.util.ui.ColumnInfo in project intellij-plugins by JetBrains.

the class LiveObjectsTreeTable method getColumns.

private static ColumnInfo[] getColumns() {
    final ColumnInfo qnameColumn = new ColumnInfo("Class") {

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

        @Override
        public Object valueOf(final Object o) {
            return o;
        }

        @Override
        public Comparator<DefaultMutableTreeNode> getComparator() {
            return new AbstractSizeNodeComparator() {

                @Override
                protected int compareInfo(SizeInfoNode si1, SizeInfoNode si2) {
                    if (si1.isMethod() && si2.isMethod()) {
                        return si1.getFrameInfo().compareTo(si2.getFrameInfo());
                    }
                    int result = si1.getClassName().compareTo(si2.getClassName());
                    if (result != 0 || si1.getPackageName() == null || si2.getPackageName() == null) {
                        return result;
                    }
                    return si1.getPackageName().compareTo(si2.getPackageName());
                }
            };
        }
    };
    final ColumnInfo countColumn = new AbstractSizeColumnInfo("Count") {

        @Override
        protected String extractValueFromSizeInfoNode(SizeInfoNode value) {
            return Integer.toString(value.getCount());
        }

        @Override
        public Comparator<DefaultMutableTreeNode> getComparator() {
            return new AbstractSizeNodeComparator() {

                @Override
                protected int compareInfo(SizeInfoNode si1, SizeInfoNode si2) {
                    return (int) Math.signum(si2.getCount() - si1.getCount());
                }
            };
        }
    };
    final ColumnInfo sizeColumn = new AbstractSizeColumnInfo("Size, bytes") {

        @Override
        protected String extractValueFromSizeInfoNode(SizeInfoNode value) {
            return NumberFormat.getInstance().format(value.getSize());
        }

        @Override
        public Comparator<DefaultMutableTreeNode> getComparator() {
            return new AbstractSizeNodeComparator() {

                @Override
                protected int compareInfo(SizeInfoNode si1, SizeInfoNode si2) {
                    return (int) Math.signum(si2.getSize() - si1.getSize());
                }
            };
        }
    };
    return new ColumnInfo[] { qnameColumn, countColumn, sizeColumn };
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ColumnInfo(com.intellij.util.ui.ColumnInfo) TreeTableModel(com.intellij.ui.treeStructure.treetable.TreeTableModel)

Aggregations

ColumnInfo (com.intellij.util.ui.ColumnInfo)27 TableCellRenderer (javax.swing.table.TableCellRenderer)7 TreeTableView (com.intellij.ui.dualView.TreeTableView)4 TreeTableModel (com.intellij.ui.treeStructure.treetable.TreeTableModel)4 ListTableModel (com.intellij.util.ui.ListTableModel)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 NotNull (org.jetbrains.annotations.NotNull)4 TableView (com.intellij.ui.table.TableView)3 ListTreeTableModelOnColumns (com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns)3 List (java.util.List)3 TableColumn (javax.swing.table.TableColumn)3 Project (com.intellij.openapi.project.Project)2 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)2 TreeColumnInfo (com.intellij.ui.treeStructure.treetable.TreeColumnInfo)2 AsyncProcessIcon (com.intellij.util.ui.AsyncProcessIcon)2 ArrayList (java.util.ArrayList)2 TableCellEditor (javax.swing.table.TableCellEditor)2 Nullable (org.jetbrains.annotations.Nullable)2 DependencyCellRenderer (com.android.tools.idea.gradle.structure.configurables.ui.dependencies.AbstractDeclaredDependenciesTableModel.DependencyCellRenderer)1 PsArtifactDependencySpec (com.android.tools.idea.gradle.structure.model.PsArtifactDependencySpec)1