Search in sources :

Example 1 with MetadataGetter

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);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 2 with MetadataGetter

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);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) Color(java.awt.Color) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

Journaled (com.ramussoft.common.journal.Journaled)2 MetadataGetter (com.ramussoft.gui.qualifier.table.MetadataGetter)2 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)2 DefaultCellEditor (javax.swing.DefaultCellEditor)2 JComboBox (javax.swing.JComboBox)2 JTable (javax.swing.JTable)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Stroke (java.awt.Stroke)1