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 };
}
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;
}
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);
}
}
}
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 };
}
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 };
}
Aggregations