use of com.intellij.flex.model.bc.ValueSource 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.flex.model.bc.ValueSource in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createValueRenderer.
private TableCellRenderer createValueRenderer() {
return new TableCellRenderer() {
private final JLabel myLabel = new JLabel();
private final JCheckBox myCheckBox = new JCheckBox();
private final ComponentWithBrowseButton<JLabel> myLabelWithBrowse = new ComponentWithBrowseButton<>(new JLabel(), null);
public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
if (!(value instanceof CompilerOptionInfo)) {
// invisible root node or group node
myLabel.setText("");
return myLabel;
}
final CompilerOptionInfo info = (CompilerOptionInfo) value;
final Pair<String, ValueSource> valueAndSource = getValueAndSource(info);
switch(info.TYPE) {
case Boolean:
myCheckBox.setBackground(table.getBackground());
//myCheckBox.setForeground(UIUtil.getTableForeground());
//myCheckBox.setEnabled(moduleDefault || fromConfigFile || custom);
myCheckBox.setSelected("true".equalsIgnoreCase(valueAndSource.first));
return myCheckBox;
case String:
case Int:
case List:
case IncludeClasses:
case IncludeFiles:
myLabel.setBackground(table.getBackground());
myLabel.setText(getPresentableSummary(valueAndSource.first, info));
renderAccordingToSource(myLabel, valueAndSource.second, false);
return myLabel;
case File:
final JLabel label = myLabelWithBrowse.getChildComponent();
myLabelWithBrowse.setBackground(table.getBackground());
label.setText(FileUtil.toSystemDependentName(valueAndSource.first));
renderAccordingToSource(label, valueAndSource.second, false);
return myLabelWithBrowse;
case Group:
default:
assert false;
return null;
}
}
};
}
use of com.intellij.flex.model.bc.ValueSource in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createTreeCellRenderer.
private TreeCellRenderer createTreeCellRenderer() {
return new TreeCellRenderer() {
private final JLabel myLabel = new JLabel();
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
if (!(userObject instanceof CompilerOptionInfo)) {
// invisible root node
return myLabel;
}
final CompilerOptionInfo info = (CompilerOptionInfo) userObject;
myLabel.setText(info.DISPLAY_NAME);
final ValueSource valueSource = getValueAndSource(info).second;
renderAccordingToSource(myLabel, valueSource, selected);
myLabel.setForeground(selected ? UIUtil.getTableSelectionForeground() : UIUtil.getTableForeground());
return myLabel;
}
};
}
Aggregations