Search in sources :

Example 86 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project omero-insight by ome.

the class OMETreeTable method setDefaultEditors.

/**
 * Sets the default editors for the cells in the table. This includes
 * editors for cells containing: int, long, string, booleans,
 * floats, longs, doubles.
 */
protected void setDefaultEditors() {
    Iterator<Class<?>> classIterator = DEFAULT_EDITORS.keySet().iterator();
    Class<?> classType;
    DefaultCellEditor editorType;
    while (classIterator.hasNext()) {
        classType = classIterator.next();
        editorType = DEFAULT_EDITORS.get(classType);
        this.setDefaultEditor(classType, editorType);
    }
}
Also used : DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 87 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.

the class HttpPanelParamTableView method initAddins.

private void initAddins() {
    // Get all addins
    addins = new LinkedList<>();
    addins.add(new ParamAddinMagic());
    addins.add(new ParamAddinUrlencode());
    comboBoxAddIns = new JComboBox<>();
    comboBoxAddIns.addItem(ADD_INS);
    for (ParamAddinInterface addin : addins) {
        comboBoxAddIns.addItem(addin);
    }
    comboBoxAddIns.addActionListener(new ComboBoxAddinsActionListener());
    table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(getComboBoxTypes()));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    if (table.getColumnCount() != 4) {
        return;
    }
    table.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(comboBoxAddIns));
    table.getColumnModel().getColumn(3).setCellRenderer(new ComboBoxCellRenderer(comboBoxAddIns));
}
Also used : ParamAddinInterface(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinInterface) ParamAddinMagic(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinMagic) ParamAddinUrlencode(org.zaproxy.zap.extension.httppanel.view.paramtable.addins.ParamAddinUrlencode) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 88 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.

the class HttpPanelParamTableView method setEditable.

@Override
public void setEditable(boolean editable) {
    if (isEditable != editable) {
        if (isEditable) {
            table.getColumnModel().removeColumn(table.getColumnModel().getColumn(3));
        } else {
            TableColumn column = new TableColumn(3, 150, new ComboBoxCellRenderer(comboBoxAddIns), new DefaultCellEditor(comboBoxAddIns));
            column.setPreferredWidth(150);
            column.setMaxWidth(150);
            table.addColumn(column);
        }
        isEditable = editable;
        httpPanelTabularModel.setEditable(editable);
    }
}
Also used : TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 89 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project vcell by virtualcell.

the class StructureMappingTableModel method updateSubdomainComboBox.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void updateSubdomainComboBox() {
    GeometryClass[] geometryClasses = getGeometryContext().getGeometry().getGeometryClasses();
    DefaultComboBoxModel aModel = new DefaultComboBoxModel();
    for (GeometryClass gc : geometryClasses) {
        aModel.addElement(gc);
    }
    JComboBox subdomainComboBoxCellEditor = new JComboBox();
    subdomainComboBoxCellEditor.setRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setHorizontalTextPosition(SwingConstants.LEFT);
            if (value instanceof GeometryClass) {
                GeometryClass gc = (GeometryClass) value;
                setText(gc.getName());
                if (value instanceof SubVolume) {
                    SubVolume subVolume = (SubVolume) value;
                    java.awt.Color handleColor = new java.awt.Color(colormap[subVolume.getHandle()]);
                    // small square icon with subdomain color
                    Icon icon = new ColorIcon(10, 10, handleColor, true);
                    setHorizontalTextPosition(SwingConstants.RIGHT);
                    setIcon(icon);
                } else if (value instanceof SurfaceClass) {
                    SurfaceClass sc = (SurfaceClass) value;
                    Set<SubVolume> sv = sc.getAdjacentSubvolumes();
                    Iterator<SubVolume> iterator = sv.iterator();
                    SubVolume sv1 = iterator.next();
                    SubVolume sv2 = iterator.next();
                    java.awt.Color c1 = new java.awt.Color(colormap[sv2.getHandle()]);
                    java.awt.Color c2 = new java.awt.Color(colormap[sv1.getHandle()]);
                    Icon icon = new ColorIconEx(10, 10, c1, c2);
                    setIcon(icon);
                    setHorizontalTextPosition(SwingConstants.RIGHT);
                }
            }
            return this;
        }
    });
    subdomainComboBoxCellEditor.setModel(aModel);
    ownerTable.getColumnModel().getColumn(SPATIAL_COLUMN_SUBDOMAIN).setCellEditor(new DefaultCellEditor(subdomainComboBoxCellEditor));
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) ColorIcon(org.vcell.util.gui.ColorIcon) JComboBox(javax.swing.JComboBox) SurfaceClass(cbit.vcell.geometry.SurfaceClass) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultCellEditor(javax.swing.DefaultCellEditor) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) SubVolume(cbit.vcell.geometry.SubVolume) ColorIcon(org.vcell.util.gui.ColorIcon) Icon(javax.swing.Icon) Component(java.awt.Component) ColorIconEx(org.vcell.util.gui.ColorIconEx) JList(javax.swing.JList)

Example 90 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project knime-core by knime.

the class OutFieldsTable method createFieldTypeCellEditor.

// CELL EDITORS
/**
 * Create cell editor for for the input columns / flow variables.
 * @return an editor for the type field
 */
protected TableCellEditor createFieldTypeCellEditor() {
    JComboBox<FieldType> comboBox = new JComboBox<FieldType>();
    comboBox.addItem(FieldType.Column);
    comboBox.addItem(FieldType.FlowVariable);
    DefaultCellEditor editor = new DefaultCellEditor(comboBox);
    editor.setClickCountToStart(2);
    return editor;
}
Also used : JComboBox(javax.swing.JComboBox) FieldType(org.knime.core.node.util.dialog.OutFieldsTableModel.FieldType) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)192 JComboBox (javax.swing.JComboBox)120 JTable (javax.swing.JTable)61 TableColumn (javax.swing.table.TableColumn)61 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 JTextField (javax.swing.JTextField)23 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)23 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)23 JLabel (javax.swing.JLabel)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