use of com.intellij.flex.model.bc.CompilerOptionInfo in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method updateChildNodes.
private void updateChildNodes(final DefaultMutableTreeNode rootNode, final CompilerOptionInfo[] optionInfos, final boolean showAll) {
int currentNodeNumber = 0;
for (final CompilerOptionInfo info : optionInfos) {
final boolean show = // empty group will be hidden later
info.isGroup() || ((myMode != Mode.BC || info.isApplicable(getSdkVersion(), myNature)) && (showAll || !info.ADVANCED || hasCustomValue(info)));
DefaultMutableTreeNode node = findChildNodeWithInfo(rootNode, info);
if (show) {
if (node == null) {
node = new DefaultMutableTreeNode(info, info.isGroup());
rootNode.insert(node, currentNodeNumber);
}
currentNodeNumber++;
if (info.isGroup()) {
updateChildNodes(node, info.getChildOptionInfos(), showAll);
if (node.getChildCount() == 0) {
node.removeFromParent();
currentNodeNumber--;
}
}
} else {
if (node != null) {
node.removeFromParent();
}
}
}
}
use of com.intellij.flex.model.bc.CompilerOptionInfo in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createValueEditor.
private TableCellEditor createValueEditor() {
return new AbstractTableCellEditor() {
//private CellEditorComponentWithBrowseButton<JTextField> myTextWithBrowse;
//private LocalPathCellEditor myLocalPathCellEditor;
private final JTextField myTextField = new JTextField();
private final TextFieldWithBrowseButton myTextWithBrowse = new TextFieldWithBrowseButton();
private final RepeatableValueEditor myRepeatableValueEditor = new RepeatableValueEditor(myProject);
private final ExtensionAwareFileChooserDescriptor myFileChooserDescriptor = new ExtensionAwareFileChooserDescriptor();
private final JCheckBox myCheckBox = new JCheckBox();
{
myTextWithBrowse.addBrowseFolderListener(null, null, myProject, myFileChooserDescriptor);
myCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// apply new check box state immediately
TableUtil.stopEditing(myTreeTable);
}
});
}
private Component myCurrentEditor;
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
assert value instanceof CompilerOptionInfo;
final CompilerOptionInfo info = (CompilerOptionInfo) value;
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null || sdk.getSdkType() == FlexmojosSdkType.getInstance() ? null : sdk.getHomePath();
final String optionValue = sdkHome == null ? getValueAndSource(info).first : getValueAndSource(info).first.replace(CompilerOptionInfo.FLEX_SDK_MACRO, sdkHome);
switch(info.TYPE) {
case Boolean:
myCheckBox.setBackground(table.getBackground());
myCheckBox.setSelected("true".equalsIgnoreCase(optionValue));
myCurrentEditor = myCheckBox;
break;
case List:
myRepeatableValueEditor.setInfoAndValue(info, optionValue);
myCurrentEditor = myRepeatableValueEditor;
break;
case String:
case Int:
case IncludeClasses:
case IncludeFiles:
myTextField.setText(optionValue);
myCurrentEditor = myTextField;
break;
case File:
myFileChooserDescriptor.setAllowedExtensions(info.FILE_EXTENSION);
myTextWithBrowse.setText(FileUtil.toSystemDependentName(optionValue));
myCurrentEditor = myTextWithBrowse;
break;
case Group:
default:
assert false;
}
return myCurrentEditor;
}
public Object getCellEditorValue() {
if (myCurrentEditor == myCheckBox) {
return String.valueOf(myCheckBox.isSelected());
}
if (myCurrentEditor == myTextField) {
return myTextField.getText().trim();
}
if (myCurrentEditor == myTextWithBrowse) {
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null || sdk.getSdkType() == FlexmojosSdkType.getInstance() ? null : sdk.getHomePath();
final String path = FileUtil.toSystemIndependentName(myTextWithBrowse.getText().trim());
return sdkHome == null ? path : path.replace(sdkHome, CompilerOptionInfo.FLEX_SDK_MACRO);
}
if (myCurrentEditor == myRepeatableValueEditor) {
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null ? null : sdk.getHomePath();
final String value = myRepeatableValueEditor.getValue();
return sdkHome == null ? value : value.replace(sdkHome, CompilerOptionInfo.FLEX_SDK_MACRO);
}
assert false;
return null;
}
};
}
use of com.intellij.flex.model.bc.CompilerOptionInfo 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.CompilerOptionInfo 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.CompilerOptionInfo in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createTreeTable.
private TreeTable createTreeTable() {
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
final TreeTableModel model = new ListTreeTableModel(rootNode, createColumns());
final TreeTable treeTable = new TreeTable(model);
treeTable.getColumnModel().getColumn(1).setCellRenderer(createValueRenderer());
treeTable.getColumnModel().getColumn(1).setCellEditor(createValueEditor());
final TreeTableTree tree = treeTable.getTree();
tree.setRootVisible(false);
tree.setLineStyleAngled();
tree.setShowsRootHandles(true);
tree.setCellRenderer(createTreeCellRenderer());
treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
treeTable.setRowHeight(new JTextField("Fake").getPreferredSize().height + 3);
//treeTable.setTableHeader(null);
final DefaultActionGroup group = new DefaultActionGroup();
group.add(new RestoreDefaultValueAction(tree));
PopupHandler.installPopupHandler(treeTable, group, ActionPlaces.UNKNOWN, ActionManager.getInstance());
new TreeTableSpeedSearch(treeTable, o -> {
final Object userObject = ((DefaultMutableTreeNode) o.getLastPathComponent()).getUserObject();
return userObject instanceof CompilerOptionInfo ? ((CompilerOptionInfo) userObject).DISPLAY_NAME : "";
}).setComparator(new SpeedSearchComparator(false));
return treeTable;
}
Aggregations