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);
}
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);
}
}
}
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()));
}
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);
}
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);
}
Aggregations