Search in sources :

Example 16 with TreeTableNode

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

the class ReportsView method openReport.

protected void openReport() {
    table.setEditable(false);
    TreeTableNode node = table.getSelectedNode();
    if (node != null) {
        Row row = node.getRow();
        if (row != null) {
            openReport(row);
        }
    }
    table.setEditable(true);
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row)

Example 17 with TreeTableNode

use of com.ramussoft.gui.qualifier.table.TreeTableNode 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)

Example 18 with TreeTableNode

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

the class ChartSetsView method deleteDiagram.

public void deleteDiagram() {
    List<Row> rows = new ArrayList<Row>();
    int[] sels = table.getSelectedRows();
    for (int i : sels) {
        TreePath path = table.getPathForRow(i);
        if (path != null) {
            TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
            if (node != null) {
                Row row = node.getRow();
                if (row != null)
                    rows.add(row);
            }
        }
    }
    if (rows.size() > 0) {
        if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
        Engine engine = framework.getEngine();
        ((Journaled) engine).startUserTransaction();
        for (Row row : rows) engine.deleteElement(row.getElementId());
        ((Journaled) engine).commitUserTransaction();
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row) Engine(com.ramussoft.common.Engine)

Example 19 with TreeTableNode

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

the class ChartSetsView method deleteChartSet.

public void deleteChartSet() {
    List<Row> rows = new ArrayList<Row>();
    int[] sels = table.getSelectedRows();
    for (int i : sels) {
        TreePath path = table.getPathForRow(i);
        if (path != null) {
            TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
            if (node != null) {
                Row row = node.getRow();
                if (row != null)
                    rows.add(row);
            }
        }
    }
    if (rows.size() > 0) {
        if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
        Engine engine = framework.getEngine();
        ((Journaled) engine).startUserTransaction();
        for (Row row : rows) ChartPlugin.deleteChartSet(engine, row.getElement());
        ((Journaled) engine).commitUserTransaction();
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row) Engine(com.ramussoft.common.Engine)

Example 20 with TreeTableNode

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

the class ElistTabView method createComponent.

@Override
public JComponent createComponent() {
    final Engine engine = framework.getEngine();
    AccessRules rules = framework.getAccessRules();
    ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, elementList);
    boolean addListener = q1 == null;
    q1 = engine.getQualifier(p.getQualifier1());
    q2 = engine.getQualifier(p.getQualifier2());
    readOnly = !((rules.canUpdateAttribute(q1.getId(), elementList.getId())) && (rules.canUpdateAttribute(q2.getId(), elementList.getId())));
    if (addListener) {
        engine.addElementAttributeListener(q1, leftAttributeListener);
        engine.addElementAttributeListener(q2, rightAttributeListener);
    }
    left = new ElistPanel(framework, engine, rules, q1, elementList) {

        @Override
        public String getPropertiesPrefix() {
            return "left" + elementList.getId();
        }

        @Override
        public void changeSelection(SelectionEvent event) {
            ElistTabView.this.changeSelection(this, event);
        }

        @Override
        public JComponent createComponent() {
            unique = null;
            if (getComponent() != null) {
                left.clearSelection();
                left.setSelectType(SelectType.RADIO);
                right.clearSelection();
                right.setSelectType(SelectType.RADIO);
            }
            JComponent component2 = super.createComponent();
            getComponent().getPane().getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

                @Override
                public void adjustmentValueChanged(AdjustmentEvent e) {
                    comp.repaint();
                }
            });
            getComponent().getTable().getModel().addTableModelListener(modelListener);
            getComponent().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                @SuppressWarnings("unchecked")
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    TreeTableNode node = left.getComponent().getTable().getSelectedNode();
                    if ((node != null) && (node.getRow() != null)) {
                        leftElement = node.getRow().getElement();
                        leftValue = (List<ElementListPersistent>) engine.getAttribute(leftElement, elementList);
                        if (unique == null)
                            rightValue = null;
                    } else
                        leftValue = null;
                    comp.repaint();
                }
            });
            return component2;
        }

        @Override
        public void setSelectType(SelectType selectType) {
            if ((!readOnly) || (selectType.equals(SelectType.NONE)))
                super.setSelectType(selectType);
        }
    };
    right = new ElistPanel(framework, engine, rules, q2, elementList) {

        @Override
        public String getPropertiesPrefix() {
            return "right" + elementList.getId();
        }

        @Override
        public void changeSelection(SelectionEvent event) {
            ElistTabView.this.changeSelection(this, event);
        }

        @Override
        public JComponent createComponent() {
            unique = null;
            if (getComponent() != null) {
                left.clearSelection();
                left.setSelectType(SelectType.RADIO);
                right.clearSelection();
                right.setSelectType(SelectType.RADIO);
            }
            JComponent component2 = super.createComponent();
            getComponent().getPane().getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

                @Override
                public void adjustmentValueChanged(AdjustmentEvent e) {
                    comp.repaint();
                }
            });
            getComponent().getTable().getModel().addTableModelListener(modelListener);
            getComponent().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                @SuppressWarnings("unchecked")
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    TreeTableNode node = right.getComponent().getTable().getSelectedNode();
                    if ((node != null) && (node.getRow() != null)) {
                        rightElement = node.getRow().getElement();
                        rightValue = (List<ElementListPersistent>) engine.getAttribute(rightElement, elementList);
                        if (unique == null)
                            leftValue = null;
                    } else
                        rightValue = null;
                    comp.repaint();
                }
            });
            return component2;
        }

        @Override
        public void setSelectType(SelectType selectType) {
            if ((!readOnly) || (selectType.equals(SelectType.NONE)))
                super.setSelectType(selectType);
        }
    };
    JSplitPane pane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    pane1.setRightComponent(rightContainer);
    comp.setBackground(Color.white);
    pane1.setLeftComponent(comp);
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    pane.setLeftComponent(leftContainer);
    Properties properties = engine.getProperties(getProperiesName());
    revert = Options.getBoolean("REVERT", false, properties);
    revertAction.putValue(Action.SELECTED_KEY, revert);
    addPanels();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(pane1, BorderLayout.CENTER);
    pane.setRightComponent(panel);
    component = new JPanel(new BorderLayout());
    component.add(pane, BorderLayout.CENTER);
    Options.loadOptions(component, properties);
    if (readOnly) {
        left.setSelectType(SelectType.NONE);
        right.setSelectType(SelectType.NONE);
    }
    return component;
}
Also used : JPanel(javax.swing.JPanel) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) AdjustmentEvent(java.awt.event.AdjustmentEvent) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) JComponent(javax.swing.JComponent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) SelectType(com.ramussoft.gui.qualifier.table.SelectType) Properties(java.util.Properties) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) AdjustmentListener(java.awt.event.AdjustmentListener) AccessRules(com.ramussoft.common.AccessRules) JSplitPane(javax.swing.JSplitPane) Engine(com.ramussoft.common.Engine)

Aggregations

TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)22 Row (com.ramussoft.database.common.Row)20 TreePath (javax.swing.tree.TreePath)10 Engine (com.ramussoft.common.Engine)7 Attribute (com.ramussoft.common.Attribute)6 ArrayList (java.util.ArrayList)6 RootRow (com.ramussoft.database.common.RowSet.RootRow)5 RowTreeTable (com.ramussoft.gui.qualifier.table.RowTreeTable)5 AccessRules (com.ramussoft.common.AccessRules)4 Qualifier (com.ramussoft.common.Qualifier)3 Journaled (com.ramussoft.common.journal.Journaled)3 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)3 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)3 SelectionEvent (com.ramussoft.gui.qualifier.table.event.SelectionEvent)3 ActionEvent (java.awt.event.ActionEvent)3 MouseAdapter (java.awt.event.MouseAdapter)3 MouseEvent (java.awt.event.MouseEvent)3 AbstractAction (javax.swing.AbstractAction)3 RowNode (com.ramussoft.gui.qualifier.table.RowNode)2 RowTreeTableModel (com.ramussoft.gui.qualifier.table.RowTreeTableModel)2