use of com.ramussoft.gui.qualifier.table.MetadataGetter in project ramus by Vitaliy-Yakovchuk.
the class LineStyleAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
for (Stroke stroke : LineStyleChooser.getStrokes()) {
box.addItem(stroke);
}
return new DefaultCellEditor(box) {
private Pin pin;
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Stroke) {
((Journaled) engine).startUserTransaction();
apply((BasicStroke) box.getSelectedItem(), pin);
return super.stopCellEditing();
}
return false;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
pin = (Pin) ((MetadataGetter) table).getMetadata();
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
};
}
use of com.ramussoft.gui.qualifier.table.MetadataGetter in project ramus by Vitaliy-Yakovchuk.
the class SectorColorAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
box.addItem(Color.white);
box.addItem(Color.green);
box.addItem(Color.blue);
box.addItem(Color.red);
box.addItem(Color.yellow);
box.addItem(Color.cyan);
box.addItem(Color.magenta);
box.addItem(Color.orange);
box.addItem(Color.pink);
box.addItem(Color.lightGray);
box.addItem(Color.gray);
box.addItem(Color.darkGray);
box.addItem(Color.black);
return new DefaultCellEditor(box) {
private Pin pin;
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Color) {
((Journaled) engine).startUserTransaction();
apply((Color) box.getSelectedItem(), pin);
return super.stopCellEditing();
}
return false;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
pin = (Pin) ((MetadataGetter) table).getMetadata();
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
};
}
Aggregations