Search in sources :

Example 1 with ValueSource

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 };
}
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 2 with ValueSource

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;
            }
        }
    };
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) ValueSource(com.intellij.flex.model.bc.ValueSource) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton)

Example 3 with ValueSource

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;
        }
    };
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CompilerOptionInfo(com.intellij.flex.model.bc.CompilerOptionInfo) ValueSource(com.intellij.flex.model.bc.ValueSource)

Aggregations

CompilerOptionInfo (com.intellij.flex.model.bc.CompilerOptionInfo)3 ValueSource (com.intellij.flex.model.bc.ValueSource)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 ComponentWithBrowseButton (com.intellij.openapi.ui.ComponentWithBrowseButton)1 ListTreeTableModel (com.intellij.ui.treeStructure.treetable.ListTreeTableModel)1 TreeTableModel (com.intellij.ui.treeStructure.treetable.TreeTableModel)1 ColumnInfo (com.intellij.util.ui.ColumnInfo)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1 TreeCellRenderer (javax.swing.tree.TreeCellRenderer)1