use of javax.swing.event.CellEditorListener in project JMRI by JMRI.
the class ValueEditor method fireEditingCanceled.
protected void fireEditingCanceled() {
if (log.isDebugEnabled()) {
log.debug("fireEditingCancelled, but we are not setting back the old value");
}
Vector<CellEditorListener> local;
synchronized (listeners) {
local = new Vector<CellEditorListener>(listeners);
}
ChangeEvent ce = new ChangeEvent(this);
for (int i = local.size() - 1; i >= 0; i--) {
local.elementAt(i).editingCanceled(ce);
}
}
use of javax.swing.event.CellEditorListener in project adempiere by adempiere.
the class Find method initFindAdvanced.
// addSelectionColumn
/**
* Init Find GridController
*/
private void initFindAdvanced() {
log.config("");
advancedTable.setModel(new DefaultTableModel(0, 7));
advancedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
advancedTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
advancedTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
TableCellRenderer renderer = new ProxyRenderer(advancedTable.getDefaultRenderer(Object.class));
advancedTable.setDefaultRenderer(Object.class, renderer);
InputMap im = advancedTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
final Action tabAction = advancedTable.getActionMap().get(im.get(tab));
Action tabActionWrapper = new AbstractAction() {
private static final long serialVersionUID = -6868476640719619801L;
public void actionPerformed(ActionEvent e) {
tabAction.actionPerformed(e);
JTable table = (JTable) e.getSource();
table.requestFocusInWindow();
}
};
advancedTable.getActionMap().put(im.get(tab), tabActionWrapper);
KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
final Action shiftTabAction = advancedTable.getActionMap().get(im.get(shiftTab));
Action shiftTabActionWrapper = new AbstractAction() {
private static final long serialVersionUID = 5493691483070046620L;
public void actionPerformed(ActionEvent e) {
shiftTabAction.actionPerformed(e);
JTable table = (JTable) e.getSource();
table.requestFocusInWindow();
}
};
advancedTable.getActionMap().put(im.get(shiftTab), shiftTabActionWrapper);
// 0 = Columns
ArrayList<ValueNamePair> items = new ArrayList<ValueNamePair>();
for (int c = 0; c < m_findFields.length; c++) {
GridField field = m_findFields[c];
String columnName = field.getColumnName();
String header = field.getHeader();
if (header == null || header.length() == 0) {
header = Msg.translate(Env.getCtx(), columnName);
if (header == null || header.length() == 0)
continue;
}
if (field.isKey())
header += (" (ID)");
ValueNamePair pp = new ValueNamePair(columnName, header);
// System.out.println(pp + " = " + field);
items.add(pp);
}
columnValueNamePairs = new ValueNamePair[items.size()];
items.toArray(columnValueNamePairs);
// sort alpha
Arrays.sort(columnValueNamePairs);
columns = new CComboBox(columnValueNamePairs);
columns.addActionListener(this);
TableColumn tc = advancedTable.getColumnModel().getColumn(INDEX_COLUMNNAME);
tc.setPreferredWidth(120);
FindCellEditor dce = new FindCellEditor(columns);
dce.addCellEditorListener(new CellEditorListener() {
public void editingCanceled(ChangeEvent ce) {
}
public void editingStopped(ChangeEvent ce) {
int col = advancedTable.getSelectedColumn();
int row = advancedTable.getSelectedRow();
if (col == INDEX_COLUMNNAME && row >= 0) {
advancedTable.setValueAt(null, row, INDEX_VALUE);
advancedTable.setValueAt(null, row, INDEX_VALUE2);
}
}
});
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.translate(Env.getCtx(), "AD_Column_ID"));
// 0 = And/Or
andOr = new CComboBox(new String[] { "", Msg.getMsg(Env.getCtx(), "AND"), Msg.getMsg(Env.getCtx(), "OR") });
tc = advancedTable.getColumnModel().getColumn(INDEX_ANDOR);
tc.setPreferredWidth(45);
dce = new FindCellEditor(andOr);
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "And/Or"));
// 1 = Left Bracket
leftBrackets = new CComboBox(new String[] { "", "(", "((", "(((" });
tc = advancedTable.getColumnModel().getColumn(INDEX_LEFTBRACKET);
tc.setPreferredWidth(25);
dce = new FindCellEditor(leftBrackets);
tc.setCellEditor(dce);
tc.setHeaderValue("(");
// 3 = Operators
operators = new CComboBox(MQuery.OPERATORS);
tc = advancedTable.getColumnModel().getColumn(INDEX_OPERATOR);
tc.setPreferredWidth(55);
dce = new FindCellEditor(operators);
tc.setCellEditor(dce);
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "Operator"));
// 4 = QueryValue
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE);
FindValueEditor fve = new FindValueEditor(this, false);
tc.setCellEditor(fve);
tc.setPreferredWidth(120);
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue"));
// 5 = QueryValue2
tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE2);
tc.setPreferredWidth(120);
fve = new FindValueEditor(this, true);
tc.setCellEditor(fve);
tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false)));
tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue2"));
// 6 = Right Bracket
rightBrackets = new CComboBox(new String[] { "", ")", "))", ")))" });
tc = advancedTable.getColumnModel().getColumn(INDEX_RIGHTBRACKET);
tc.setPreferredWidth(25);
dce = new FindCellEditor(rightBrackets);
tc.setCellEditor(dce);
tc.setHeaderValue(")");
// phib: disabled auto-completion as it causes date fields to have to be entered twice
//AutoCompletion.enable(columns);
//AutoCompletion.enable(operators);
//user query
refreshUserQueries();
}
Aggregations