Search in sources :

Example 61 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project beast2 by CompEvol.

the class AlignmentListInputEditor method setUpComboBoxes.

// createListBox
void setUpComboBoxes() {
    // set up comboboxes
    @SuppressWarnings("unchecked") Set<String>[] partitionNames = new HashSet[3];
    for (int i = 0; i < 3; i++) {
        partitionNames[i] = new HashSet<>();
    }
    for (int i = 0; i < partitionCount; i++) {
        partitionNames[0].add(((BEASTInterface) likelihoods[i].siteModelInput.get()).getID());
        partitionNames[1].add(likelihoods[i].branchRateModelInput.get().getID());
        partitionNames[2].add(likelihoods[i].treeInput.get().getID());
    }
    String[][] partitionNameStrings = new String[3][];
    for (int i = 0; i < 3; i++) {
        partitionNameStrings[i] = partitionNames[i].toArray(new String[0]);
    }
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < partitionNameStrings[j].length; i++) {
            partitionNameStrings[j][i] = BeautiDoc.parsePartition(partitionNameStrings[j][i]);
        }
    }
    TableColumn col = table.getColumnModel().getColumn(SITEMODEL_COLUMN);
    JComboBox<String> siteModelComboBox = new JComboBox<>(partitionNameStrings[0]);
    siteModelComboBox.setEditable(true);
    siteModelComboBox.addActionListener(new ComboActionListener(SITEMODEL_COLUMN));
    col.setCellEditor(new DefaultCellEditor(siteModelComboBox));
    // If the cell should appear like a combobox in its
    // non-editing state, also set the combobox renderer
    col.setCellRenderer(new MyComboBoxRenderer(partitionNameStrings[0]));
    col = table.getColumnModel().getColumn(CLOCKMODEL_COLUMN);
    JComboBox<String> clockModelComboBox = new JComboBox<>(partitionNameStrings[1]);
    clockModelComboBox.setEditable(true);
    clockModelComboBox.addActionListener(new ComboActionListener(CLOCKMODEL_COLUMN));
    col.setCellEditor(new DefaultCellEditor(clockModelComboBox));
    col.setCellRenderer(new MyComboBoxRenderer(partitionNameStrings[1]));
    col = table.getColumnModel().getColumn(TREE_COLUMN);
    JComboBox<String> treeComboBox = new JComboBox<>(partitionNameStrings[2]);
    treeComboBox.setEditable(true);
    treeComboBox.addActionListener(new ComboActionListener(TREE_COLUMN));
    col.setCellEditor(new DefaultCellEditor(treeComboBox));
    col.setCellRenderer(new MyComboBoxRenderer(partitionNameStrings[2]));
    col = table.getColumnModel().getColumn(TAXA_COLUMN);
    col.setPreferredWidth(30);
    col = table.getColumnModel().getColumn(SITES_COLUMN);
    col.setPreferredWidth(30);
    col = table.getColumnModel().getColumn(USE_AMBIGUITIES_COLUMN);
    JCheckBox checkBox = new JCheckBox();
    checkBox.addActionListener(e -> {
        if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) {
            Log.warning.println(" " + table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()));
        }
        try {
            int row = table.getSelectedRow();
            if (hasUseAmbiguitiesInput(row)) {
                likelihoods[row].setInputValue("useAmbiguities", checkBox.isSelected());
                tableData[row][USE_AMBIGUITIES_COLUMN] = checkBox.isSelected();
            } else {
                if (checkBox.isSelected()) {
                    checkBox.setSelected(false);
                }
            }
        } catch (Exception ex) {
        // TODO: handle exception
        }
    });
    col.setCellEditor(new DefaultCellEditor(checkBox));
    col.setCellRenderer(new MyCheckBoxRenderer());
    col.setPreferredWidth(20);
    col.setMaxWidth(20);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) JComboBox(javax.swing.JComboBox) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor) JCheckBox(javax.swing.JCheckBox) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 62 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project netbeans-rcp-lite by outersky.

the class SheetTable method prepareCustomEditor.

private void prepareCustomEditor(Object customEditorObj) {
    JComboBox comboBox = null;
    if (customEditorObj instanceof DefaultCellEditor) {
        if (((DefaultCellEditor) customEditorObj).getComponent() instanceof JComboBox) {
            comboBox = (JComboBox) ((DefaultCellEditor) customEditorObj).getComponent();
        }
    } else if (customEditorObj instanceof JComboBox) {
        comboBox = (JComboBox) customEditorObj;
    }
    if (null != comboBox) {
        if (!(comboBox.getUI() instanceof CleanComboUI)) {
            comboBox.setUI(new CleanComboUI(true));
            ComboBoxAutoCompleteSupport.install(comboBox);
        }
    }
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 63 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project OpenTCS-4 by touchmii.

the class ContinuousLoadPanel method buildTableModels.

private void buildTableModels(TransportOrderData transportOrder) {
    requireNonNull(transportOrder, "transportOrder");
    // Drive orders
    locationsComboBox.removeAllItems();
    operationTypesComboBox.removeAllItems();
    SortedSet<Location> sortedLocationSet = new TreeSet<>(Comparators.objectsByName());
    sortedLocationSet.addAll(objectService.fetchObjects(Location.class));
    for (Location i : sortedLocationSet) {
        locationsComboBox.addItem(i.getReference());
    }
    locationsComboBox.addItemListener((ItemEvent e) -> locationsComboBoxItemStateChanged(e));
    doTable.setModel(new DriveOrderTableModel(transportOrder.getDriveOrders()));
    doTable.setDefaultEditor(TCSObjectReference.class, new DefaultCellEditor(locationsComboBox));
    doTable.setDefaultEditor(String.class, new DefaultCellEditor(operationTypesComboBox));
    // Properties
    propertyTable.setModel(new PropertyTableModel(transportOrder.getProperties()));
}
Also used : ItemEvent(java.awt.event.ItemEvent) TreeSet(java.util.TreeSet) Location(org.opentcs.data.model.Location) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 64 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project gate-core by GateNLP.

the class LuceneDataStoreSearchGUI method updateAnnotationSetsList.

protected void updateAnnotationSetsList() {
    String corpusName = (corpusToSearchIn.getSelectedItem().equals(Constants.ENTIRE_DATASTORE)) ? null : (String) corpusIds.get(corpusToSearchIn.getSelectedIndex() - 1);
    TreeSet<String> ts = new TreeSet<String>(stringCollator);
    ts.addAll(getAnnotationSetNames(corpusName));
    DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()]));
    dcbm.insertElementAt(Constants.ALL_SETS, 0);
    annotationSetsToSearchIn.setModel(dcbm);
    annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS);
    // used in the ConfigureStackViewFrame as Annotation type column
    // cell editor
    TreeSet<String> types = new TreeSet<String>(stringCollator);
    types.addAll(getTypesAndFeatures(null, null).keySet());
    // put all annotation types from the datastore
    // combobox used as cell editor
    JComboBox<String> annotTypesBox = new JComboBox<String>();
    annotTypesBox.setMaximumRowCount(10);
    annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()])));
    DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox);
    cellEditor.setClickCountToStart(0);
    configureStackViewFrame.getTable().getColumnModel().getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor);
}
Also used : JComboBox(javax.swing.JComboBox) TreeSet(java.util.TreeSet) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 65 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project micro-manager by micro-manager.

the class ButtonTable method setupActionColumn.

/**
 * setup a combobox with Button actions enum as 2nd column's cell editor
 * @param deviceColumn column that will get the new custom editor
 */
private void setupActionColumn(TableColumn deviceColumn) {
    JComboBox<ButtonActions.ActionItems> comboBox = new JComboBox<>();
    for (ButtonActions.ActionItems ai : ButtonActions.ActionItems.values()) {
        comboBox.addItem(ai);
    }
    deviceColumn.setCellEditor(new DefaultCellEditor(comboBox));
    // Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Assign actions to buttons");
    deviceColumn.setCellRenderer(renderer);
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)180 JComboBox (javax.swing.JComboBox)116 TableColumn (javax.swing.table.TableColumn)57 JTable (javax.swing.JTable)56 ArrayList (java.util.ArrayList)44 TableCellEditor (javax.swing.table.TableCellEditor)35 JScrollPane (javax.swing.JScrollPane)33 JPanel (javax.swing.JPanel)25 ActionEvent (java.awt.event.ActionEvent)24 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)23 JTextField (javax.swing.JTextField)22 JLabel (javax.swing.JLabel)20 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)20 Component (java.awt.Component)18 DefaultTableModel (javax.swing.table.DefaultTableModel)17 Dimension (java.awt.Dimension)16 JButton (javax.swing.JButton)16 ActionListener (java.awt.event.ActionListener)15 JCheckBox (javax.swing.JCheckBox)13 TableColumnModel (javax.swing.table.TableColumnModel)13