Search in sources :

Example 1 with RowRootCreater

use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.

the class TableChartAttributePlugin method getAttributePreferenciesEditor.

@Override
public AttributePreferenciesEditor getAttributePreferenciesEditor() {
    return new AttributePreferenciesEditor() {

        private RowTreeTableComponent component;

        @Override
        public JComponent createComponent(Attribute attribute, Engine engine, AccessRules accessRules) {
            component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
            component.setSelectType(SelectType.RADIO);
            return component;
        }

        @Override
        public boolean canApply() {
            return component.getModel().getSelectedRows().size() > 0;
        }

        @Override
        public void apply(Attribute attribute, Engine engine, AccessRules accessRules) {
            Row row = component.getModel().getSelectedRows().get(0);
            TableChartPersistent tcp = new TableChartPersistent();
            tcp.setOtherElementId(row.getElementId());
            engine.setAttribute(null, attribute, tcp);
        }
    };
}
Also used : Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) AccessRules(com.ramussoft.common.AccessRules) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) TableChartPersistent(com.ramussoft.chart.core.TableChartPersistent) Row(com.ramussoft.database.common.Row) AttributePreferenciesEditor(com.ramussoft.gui.common.AttributePreferenciesEditor) Engine(com.ramussoft.common.Engine)

Example 2 with RowRootCreater

use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.

the class ChartsView method createComponent.

@Override
public JComponent createComponent() {
    Engine engine = framework.getEngine();
    AccessRules accessRules = framework.getAccessRules();
    component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
    component.getTable().addSelectionListener(new SelectionListener() {

        @Override
        public void changeSelection(SelectionEvent event) {
            TreeTableNode selectedNode = component.getTable().getSelectedNode();
            if (selectedNode == null)
                chartPrefernecesAction.setEnabled(false);
            else {
                Row row = selectedNode.getRow();
                chartPrefernecesAction.setEnabled(row != null);
            }
            openChartAction.setEnabled(chartPrefernecesAction.isEnabled());
            deleteChartAction.setEnabled(chartPrefernecesAction.isEnabled());
        }
    });
    table = component.getTable();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    openDiagram();
                } else {
                    if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
                        if (!table.isEditing()) {
                            editTableField();
                        }
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        lastSelectedRows = table.getSelectedRows();
                    }
                }
            }
        }
    });
    table.setEditIfNullEvent(false);
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
    table.getActionMap().put("EditCell", new AbstractAction() {

        /**
         */
        private static final long serialVersionUID = 3229634866196074563L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
                editTableField();
        }
    });
    table.setExportRows(true);
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) AccessRules(com.ramussoft.common.AccessRules) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) Row(com.ramussoft.database.common.Row) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 3 with RowRootCreater

use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.

the class AttributePullView method createComponent.

@Override
public JComponent createComponent() {
    component = new RowTreeTableComponent(engine, attributeQualifier, rules, new RowRootCreater(), new Attribute[] { attributeName, attributeTypeName }, framework);
    table = component.getTable();
    component.getModel().setEditable(1, false);
    ((AbstractTableModel) table.getModel()).fireTableStructureChanged();
    Attribute type = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_TYPE_NAME);
    final Hashtable<String, String> names = new Hashtable<String, String>();
    for (AttributeType type2 : engine.getAttributeTypes()) {
        AttributePlugin plugin = framework.findAttributePlugin(type2);
        try {
            String key = "AttributeType." + type2.toString();
            names.put(key, plugin.getString(key));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    String key = "AttributeType.Core.ElementList";
    names.put(key, GlobalResourcesManager.getString(key));
    component.getModel().setAttributeLocalizer(new RowTreeTableModel.Localizer() {

        @Override
        public Object getValue(Object key) {
            if (key == null)
                return "Anknown attribute type";
            return names.get("AttributeType." + key.toString());
        }
    }, type);
    table.getTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            refreshActions();
        }
    });
    rowSet = component.getRowSet();
    table.setEditIfNullEvent(false);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    setupAttribute();
                }
            }
        }
    });
    refreshActions();
    table.setComponentPopupMenu(createJPopupMenu());
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) Hashtable(java.util.Hashtable) MouseAdapter(java.awt.event.MouseAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) RowTreeTableModel(com.ramussoft.gui.qualifier.table.RowTreeTableModel) AttributeType(com.ramussoft.common.AttributeType) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) AbstractTableModel(javax.swing.table.AbstractTableModel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 4 with RowRootCreater

use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.

the class ChartSetsView method createComponent.

@Override
public JComponent createComponent() {
    Engine engine = framework.getEngine();
    AccessRules accessRules = framework.getAccessRules();
    component = new RowTreeTableComponent(engine, ChartPlugin.getChartSets(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
    table = component.getTable();
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
                    openChartSet();
                } else {
                    if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
                        if (!table.isEditing()) {
                            editTableField();
                        }
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        lastSelectedRows = table.getSelectedRows();
                    }
                }
            }
        }
    });
    table.addSelectionListener(new SelectionListener() {

        @Override
        public void changeSelection(SelectionEvent event) {
            TreeTableNode selectedNode = component.getTable().getSelectedNode();
            if (selectedNode == null)
                openChartSetAction.setEnabled(false);
            else {
                Row row = selectedNode.getRow();
                openChartSetAction.setEnabled(row != null);
            }
            deleteChartSetAction.setEnabled(openChartSetAction.isEnabled());
        }
    });
    table.setEditIfNullEvent(false);
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
    table.getActionMap().put("EditCell", new AbstractAction() {

        /**
         */
        private static final long serialVersionUID = 3229634866196074563L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
                editTableField();
        }
    });
    return component;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Attribute(com.ramussoft.common.Attribute) RowTreeTableComponent(com.ramussoft.gui.qualifier.table.RowTreeTableComponent) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) AccessRules(com.ramussoft.common.AccessRules) RowRootCreater(com.ramussoft.gui.qualifier.table.RowRootCreater) Row(com.ramussoft.database.common.Row) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Aggregations

Attribute (com.ramussoft.common.Attribute)4 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)4 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)4 AccessRules (com.ramussoft.common.AccessRules)3 Engine (com.ramussoft.common.Engine)3 Row (com.ramussoft.database.common.Row)3 MouseAdapter (java.awt.event.MouseAdapter)3 MouseEvent (java.awt.event.MouseEvent)3 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)2 SelectionEvent (com.ramussoft.gui.qualifier.table.event.SelectionEvent)2 SelectionListener (com.ramussoft.gui.qualifier.table.event.SelectionListener)2 ActionEvent (java.awt.event.ActionEvent)2 AbstractAction (javax.swing.AbstractAction)2 TableChartPersistent (com.ramussoft.chart.core.TableChartPersistent)1 AttributeType (com.ramussoft.common.AttributeType)1 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)1 AttributePreferenciesEditor (com.ramussoft.gui.common.AttributePreferenciesEditor)1 RowTreeTableModel (com.ramussoft.gui.qualifier.table.RowTreeTableModel)1 Hashtable (java.util.Hashtable)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1