Search in sources :

Example 81 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.

the class TableCellEditorFactory method createFontTypeEditor.

private TableCellEditor createFontTypeEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    box.addItem(BOLD);
    box.addItem(ITALIC);
    box.addItem(BOLD_ITALIC);
    return new DefaultCellEditor(box);
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 82 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.

the class TableCellEditorFactory method createBaseQualifierEditor.

private TableCellEditor createBaseQualifierEditor() {
    List<Qualifier> qualifiers = engine.getQualifiers();
    Collections.sort(qualifiers, new Comparator<Qualifier>() {

        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });
    JComboBox box = new JComboBox();
    box.addItem(null);
    for (Qualifier qualifier : qualifiers) box.addItem(qualifier);
    return new DefaultCellEditor(box);
}
Also used : JComboBox(javax.swing.JComboBox) Qualifier(com.ramussoft.common.Qualifier) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 83 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.

the class TableCellEditorFactory method createTextAligmentEditor.

private TableCellEditor createTextAligmentEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    box.addItem(LEFT);
    box.addItem(CENTER);
    box.addItem(RIGHT);
    box.addItem(JUSTIFY);
    return new DefaultCellEditor(box);
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 84 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.

the class TableCellEditorFactory method createFontEditor.

private TableCellEditor createFontEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    for (String name : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) box.addItem(name);
    return new DefaultCellEditor(box);
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 85 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project felix-dev by apache.

the class SliderEditor method setData.

public void setData(UPnPAction action) {
    table.deleteMyCellEditors();
    String[] names = action.getInputArgumentNames();
    size = 0;
    this.names = names;
    if (names != null) {
        values = new String[names.length];
        related = new String[names.length];
        types = new String[names.length];
        for (int i = 0; i < names.length; i++) {
            values[i] = "";
            UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
            related[i] = currentStateVar.getName();
            String javaType = currentStateVar.getJavaDataType().toString();
            javaType = javaType.substring(javaType.lastIndexOf('.') + 1);
            String upnpType = currentStateVar.getUPnPDataType();
            types[i] = javaType + " \\ " + upnpType;
            // handle allowed value list
            if (currentStateVar.getAllowedValues() != null) {
                String[] av = currentStateVar.getAllowedValues();
                JComboBox comboBox = new JComboBox();
                for (int j = 0; j < av.length; j++) {
                    comboBox.addItem(av[j]);
                }
                // preset the first value from list
                values[i] = av[0];
                table.setMyCellEditor(new DefaultCellEditor(comboBox), i);
            }
            // handle default value
            if (currentStateVar.getDefaultValue() != null) {
                String val = currentStateVar.getDefaultValue().toString();
                if (val.length() > 0)
                    values[i] = val;
            }
            // handle range values
            if ((currentStateVar.getMaximum() != null) && (currentStateVar.getMinimum() != null)) {
                int max = currentStateVar.getMaximum().intValue();
                int min = currentStateVar.getMinimum().intValue();
                int value = min;
                try {
                    value = Integer.parseInt(values[i]);
                } catch (NumberFormatException ignored) {
                }
                table.setMyCellEditor(new SliderEditor(min, max, value), i);
            }
        }
        size = names.length;
    }
    this.fireTableChanged(new TableModelEvent(this));
    this.fireTableStructureChanged();
}
Also used : JComboBox(javax.swing.JComboBox) TableModelEvent(javax.swing.event.TableModelEvent) UPnPStateVariable(org.osgi.service.upnp.UPnPStateVariable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)186 JComboBox (javax.swing.JComboBox)116 TableColumn (javax.swing.table.TableColumn)61 JTable (javax.swing.JTable)59 ArrayList (java.util.ArrayList)47 TableCellEditor (javax.swing.table.TableCellEditor)35 JScrollPane (javax.swing.JScrollPane)33 JPanel (javax.swing.JPanel)26 ActionEvent (java.awt.event.ActionEvent)25 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)23 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)23 JLabel (javax.swing.JLabel)22 JTextField (javax.swing.JTextField)22 Component (java.awt.Component)21 DefaultTableModel (javax.swing.table.DefaultTableModel)21 Dimension (java.awt.Dimension)17 ActionListener (java.awt.event.ActionListener)16 JButton (javax.swing.JButton)16 JCheckBox (javax.swing.JCheckBox)16 TableCellRenderer (javax.swing.table.TableCellRenderer)15