use of javax.swing.DefaultCellEditor in project knetbuilder by Rothamsted.
the class InteractiveGenomicFilter method insertRow.
/**
* Inserts a default row at the end of table.
*/
private void insertRow() {
DefaultTableModel model = (DefaultTableModel) searchTable.getModel();
Object[] row = new Object[5];
row[0] = Boolean.valueOf(true);
row[1] = chromosomeBox.getItemAt(0);
row[2] = Integer.valueOf(1);
row[3] = Integer.valueOf(100000);
JComboBox qtlJBox = chromosome2qtl.get(((IntegerStringWrapper) chromosomeBox.getItemAt(0)).getValue());
DefaultCellEditor qtlEditor = new DefaultCellEditor(qtlJBox);
rm.addEditorForRow(model.getRowCount(), qtlEditor);
row[4] = qtlJBox.getItemAt(0);
model.insertRow(model.getRowCount(), row);
}
use of javax.swing.DefaultCellEditor in project Mapillary by JOSM.
the class MapillaryExpertFilterDialog method build.
/**
* Builds the GUI.
*/
private void build() {
userTable = new UserTable(filterModel);
userTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
userTable.setSelectionModel(filterModel.getSelectionModel());
TableHelper.adjustColumnWidth(userTable, 0, false);
TableHelper.adjustColumnWidth(userTable, 1, false);
TableHelper.adjustColumnWidth(userTable, 3, false);
TableHelper.adjustColumnWidth(userTable, 4, false);
userTable.setDefaultRenderer(Boolean.class, new BooleanRenderer());
userTable.setDefaultRenderer(String.class, new StringRenderer());
userTable.setDefaultEditor(String.class, new DefaultCellEditor(new DisableShortcutsOnFocusGainedTextField()));
// Toggle filter "enabled" on Enter
InputMapUtils.addEnterAction(userTable, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectedRow();
if (index >= 0) {
Filter filter = filterModel.getValue(index);
filterModel.setValueAt(!filter.enable, index, MapillaryFilterTableModel.COL_ENABLED);
}
}
});
// Toggle filter "hiding" on Spacebar
InputMapUtils.addSpacebarAction(userTable, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int index = userTable.getSelectedRow();
if (index >= 0) {
Filter filter = filterModel.getValue(index);
filterModel.setValueAt(!filter.hiding, index, MapillaryFilterTableModel.COL_HIDING);
}
}
});
List<FilterAction> actions = Arrays.asList(addAction, editAction, deleteAction, moveUpAction, moveDownAction, sortAction, reverseAction);
for (FilterAction action : actions) {
TableHelper.adaptTo(action, filterModel);
TableHelper.adaptTo(action, filterModel.getSelectionModel());
action.updateEnabledState();
}
createLayout(userTable, true, actions.stream().map(a -> new SideButton(a, false)).collect(Collectors.toList()));
}
use of javax.swing.DefaultCellEditor in project knime-base by knime.
the class ShapeManagerNodeDialogPane method columnChanged.
private void columnChanged(final String column) {
final LinkedHashMap<DataCell, Shape> domMap = m_map.get(column);
TableModel tableModel = new DefaultTableModel() {
private final DataCell[] m_valueNames = new DataCell[domMap.size()];
{
int row = 0;
for (DataCell cell : domMap.keySet()) {
m_valueNames[row] = cell;
row++;
}
}
@Override
public String getColumnName(final int columnIdx) {
if (columnIdx == 1) {
return "Shapes";
} else {
return "Values of " + column;
}
}
@Override
public boolean isCellEditable(final int row, final int columnIdx) {
return (columnIdx == 1);
}
@Override
public int getRowCount() {
return domMap.size();
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public Class<?> getColumnClass(final int columnIndex) {
if (columnIndex == 1) {
return Shape.class;
} else {
return DataCell.class;
}
}
@Override
public Object getValueAt(final int row, final int columnIndex) {
if (columnIndex == 1) {
return domMap.get(m_valueNames[row]);
} else {
return m_valueNames[row];
}
}
@Override
public void setValueAt(final Object aValue, final int row, final int columnIdx) {
assert aValue instanceof Shape;
assert columnIdx == 1;
domMap.put(m_valueNames[row], (Shape) aValue);
}
};
m_valueTable.setModel(tableModel);
m_valueTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(new ShapeSelectionComboBox()));
m_valueTable.getColumnModel().getColumn(1).setCellRenderer(new ShapeSelectionComboBoxRenderer());
}
use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.
the class AlertMessageModel method createColumns.
/**
* Create the columns in the model
*/
@Override
protected ArrayList<ProxyColumn<AlertMessage>> createColumns() {
ArrayList<ProxyColumn<AlertMessage>> cols = new ArrayList<ProxyColumn<AlertMessage>>(2);
cols.add(new ProxyColumn<AlertMessage>("alert.period", 100) {
public Object getValueAt(AlertMessage am) {
return AlertPeriod.fromOrdinal(am.getAlertPeriod());
}
public boolean isEditable(AlertMessage am) {
return canWrite(am);
}
public void setValueAt(AlertMessage am, Object value) {
if (value instanceof AlertPeriod) {
AlertPeriod ap = (AlertPeriod) value;
am.setAlertPeriod(ap.ordinal());
}
}
protected TableCellEditor createCellEditor() {
return new DefaultCellEditor(new JComboBox<AlertPeriod>(AlertPeriod.VALUES));
}
});
cols.add(new ProxyColumn<AlertMessage>("alert.quick.message", 120) {
public Object getValueAt(AlertMessage am) {
return am.getQuickMessage();
}
public boolean isEditable(AlertMessage am) {
return canWrite(am);
}
public void setValueAt(AlertMessage am, Object value) {
am.setQuickMessage(lookupQuickMessage(value));
}
});
return cols;
}
use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.
the class EncoderStreamModel method createColumns.
/**
* Create the columns in the model
*/
@Override
protected ArrayList<ProxyColumn<EncoderStream>> createColumns() {
ArrayList<ProxyColumn<EncoderStream>> cols = new ArrayList<ProxyColumn<EncoderStream>>(8);
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.view.num", 80, Integer.class) {
public Object getValueAt(EncoderStream es) {
return es.getViewNum();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "viewNum");
}
public void setValueAt(EncoderStream es, Object value) {
Integer view = (value instanceof Integer) ? (Integer) value : null;
es.setViewNum(view);
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.flow", 90, Boolean.class) {
public Object getValueAt(EncoderStream es) {
return es.getFlowStream();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "flowStream");
}
public void setValueAt(EncoderStream es, Object value) {
if (value instanceof Boolean)
es.setFlowStream((Boolean) value);
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.encoding", 90) {
public Object getValueAt(EncoderStream es) {
return Encoding.fromOrdinal(es.getEncoding());
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "encoding");
}
public void setValueAt(EncoderStream es, Object value) {
if (value instanceof Encoding) {
Encoding e = (Encoding) value;
es.setEncoding(e.ordinal());
}
}
protected TableCellEditor createCellEditor() {
return new DefaultCellEditor(new JComboBox<Encoding>(Encoding.values()));
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.quality", 80) {
public Object getValueAt(EncoderStream es) {
return EncodingQuality.fromOrdinal(es.getQuality());
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "quality");
}
public void setValueAt(EncoderStream es, Object value) {
if (value instanceof EncodingQuality) {
EncodingQuality q = (EncodingQuality) value;
es.setQuality(q.ordinal());
}
}
protected TableCellEditor createCellEditor() {
return new DefaultCellEditor(new JComboBox<EncodingQuality>(EncodingQuality.values()));
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.uri.scheme", 100) {
public Object getValueAt(EncoderStream es) {
return es.getUriScheme();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "uriScheme");
}
public void setValueAt(EncoderStream es, Object value) {
String s = value.toString().trim();
es.setUriScheme((s.length() > 0) ? s : null);
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.uri.path", 240) {
public Object getValueAt(EncoderStream es) {
return es.getUriPath();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "uriPath");
}
public void setValueAt(EncoderStream es, Object value) {
String p = value.toString().trim();
es.setUriPath((p.length() > 0) ? p : null);
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.mcast.port", 100, Integer.class) {
public Object getValueAt(EncoderStream es) {
return es.getMcastPort();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "mcastPort");
}
public void setValueAt(EncoderStream es, Object value) {
Integer port = (value instanceof Integer) ? (Integer) value : null;
es.setMcastPort(port);
}
});
cols.add(new ProxyColumn<EncoderStream>("encoder.stream.latency", 100, Integer.class) {
public Object getValueAt(EncoderStream es) {
return es.getLatency();
}
public boolean isEditable(EncoderStream es) {
return canWrite(es, "latency");
}
public void setValueAt(EncoderStream es, Object value) {
if (value instanceof Integer)
es.setLatency((Integer) value);
}
});
return cols;
}
Aggregations