Search in sources :

Example 46 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsPanel method showSelection.

@Override
public void showSelection(final OpenDiagram diagram) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            TreePath sel = null;
            int selRow = -1;
            for (int row = 0; row < getTree().getTable().getRowCount(); row++) {
                TreePath path = getTree().getTable().getPathForRow(row);
                Object object = path.getLastPathComponent();
                if (diagram.getFunctionId() == -1l) {
                    if (object instanceof ModelsNode) {
                        if (((ModelsNode) object).getQualifier().equals(diagram.getQualifier())) {
                            sel = path;
                            break;
                        }
                    }
                } else if (object instanceof RowNode) {
                    Row row2 = ((RowNode) object).getRow();
                    if ((row2.getElement() != null) && (row2.getElementId() == diagram.getFunctionId())) {
                        sel = path;
                        selRow = row;
                    }
                }
            }
            if (sel != null) {
                if (!getTree().getTable().isExpanded(sel))
                    getTree().getTable().expandPath(sel);
                getTree().getTable().getSelectionModel().clearSelection();
                getTree().getTable().getSelectionModel().addSelectionInterval(selRow, selRow);
            }
        }
    });
}
Also used : TreePath(javax.swing.tree.TreePath) RowNode(com.ramussoft.gui.qualifier.table.RowNode) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 47 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsNode method createR2Children.

public static Vector<TreeTableNode> createR2Children(Row root) {
    Vector<TreeTableNode> res = new Vector<TreeTableNode>();
    for (Row row : root.getChildren()) {
        RowNode node = new FunctionNode(createR2Children(row), row);
        node.setParent();
        res.add(node);
    }
    return res;
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) RowNode(com.ramussoft.gui.qualifier.table.RowNode) Row(com.ramussoft.database.common.Row) Vector(java.util.Vector)

Example 48 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsView method createModelsPanel.

protected void createModelsPanel() {
    if (this.modelsPanel != null)
        this.modelsPanel.close();
    Qualifier modelTree = IDEF0Plugin.getModelTree(engine);
    modelTree = engine.getQualifier(modelTree.getId());
    if (modelTree == null) {
        final com.ramussoft.idef0.idef0.oldmodelsview.ModelsPanel modelsPanel = new com.ramussoft.idef0.idef0.oldmodelsview.ModelsPanel(engine, framework) {

            @Override
            public boolean isDisabeUpdate() {
                return disableUpdated;
            }
        };
        modelsPanel.getTree().getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                openDiagram.setEnabled(modelsPanel.getTree().getSelectionPath() != null);
            }
        });
        modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
        modelsPanel.getTree().addTreeSelectionListener(new TreeSelectionListener() {

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                ch1();
                modelNode = getActiveNode1();
                while ((modelNode != null) && (!(modelNode instanceof ModelsNode)) && (modelNode instanceof Row)) modelNode = ((Row) modelNode).getParent();
                modelProperties.setEnabled((modelNode instanceof ModelsNode) && (rules.canUpdateQualifier(((ModelsNode) modelNode).getQualifier().getId())));
            }
        });
        modelsPanel.getTreeModel().addTreeModelListener(new TreeModelListener() {

            @Override
            public void treeNodesChanged(TreeModelEvent e) {
                ch1();
            }

            @Override
            public void treeNodesInserted(TreeModelEvent e) {
                ch1();
            }

            @Override
            public void treeNodesRemoved(TreeModelEvent e) {
                ch1();
            }

            @Override
            public void treeStructureChanged(TreeModelEvent e) {
                ch1();
            }
        });
        contentPanel.add(modelsPanel, BorderLayout.CENTER);
        modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
        this.modelsPanel = modelsPanel;
    } else {
        final ModelsPanel modelsPanel = new ModelsPanel(engine, framework) {

            @Override
            public boolean isDisabeUpdate() {
                return disableUpdated;
            }
        };
        modelsPanel.getTree().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                openDiagram.setEnabled(modelsPanel.canOpen());
            }
        });
        modelsPanel.getTree().setComponentPopupMenu(createPopupMenu());
        modelsPanel.getTree().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                ch();
                modelNode = getActiveNode();
                while ((modelNode != null) && (!(modelNode instanceof ModelsNode)) && (modelNode instanceof RowNode)) modelNode = ((RowNode) modelNode).getParent();
                modelProperties.setEnabled((modelNode instanceof ModelsNode) && (rules.canUpdateQualifier(((ModelsNode) modelNode).getQualifier().getId())));
            }
        });
        contentPanel.add(modelsPanel, BorderLayout.CENTER);
        modelsPanel.getTree().getTable().setComponentPopupMenu(createPopupMenu());
        this.modelsPanel = modelsPanel;
    }
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) RowNode(com.ramussoft.gui.qualifier.table.RowNode) TreeModelListener(javax.swing.event.TreeModelListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) TreeSelectionListener(javax.swing.event.TreeSelectionListener) ListSelectionListener(javax.swing.event.ListSelectionListener) Qualifier(com.ramussoft.common.Qualifier) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) Row(com.ramussoft.database.common.Row)

Example 49 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsPanel method deleteElement.

public void deleteElement(Qualifier qualifier) {
    for (Row row : tree.getRowSet().getAllRows()) {
        Long id = (Long) (row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine)));
        if (id != null && id.longValue() == qualifier.getId()) {
            tree.getRowSet().deleteRow(row);
            break;
        }
    }
    for (int i = modelsNodes.size() - 1; i >= 0; --i) {
        ModelsNode node = modelsNodes.get(i);
        if (node.getTreeTableModel().getRowSet().getQualifier().equals(qualifier)) {
            modelsNodes.remove(i);
            node.close();
        }
    }
}
Also used : Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 50 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsPanel method openDiagram.

public void openDiagram() {
    RowTreeTable table = tree.getTable();
    final List<OpenDiagram> models = new ArrayList<OpenDiagram>();
    Qualifier modelTree = IDEF0Plugin.getModelTree(engine);
    for (int i : table.getSelectedRows()) {
        if (i >= 0) {
            TreePath path = table.getPathForRow(i);
            if (path != null) {
                TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
                if (node != null) {
                    Row row = node.getRow();
                    if (row != null) {
                        if (row.getElement().getQualifierId() == modelTree.getId()) {
                            Long id = (Long) row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine));
                            if (id != null) {
                                Qualifier model = engine.getQualifier(id);
                                if (model != null) {
                                    OpenDiagram openDiagram = new OpenDiagram(model, -1l);
                                    models.add(openDiagram);
                                }
                            }
                        } else {
                            if (row.getChildCount() <= 0)
                                row = row.getParent();
                            OpenDiagram openDiagram = new OpenDiagram(row.getRowSet().getQualifier(), row.getElementId());
                            models.add(openDiagram);
                        }
                    }
                }
            }
        }
    }
    if (models.size() > 0) {
        if (engine.getPluginProperty("IDEF0", "DataPlugin") == null) {
            framework.showAnimation(GlobalResourcesManager.getString("Wait.DataLoading"));
            Thread thread = new Thread() {

                @Override
                public void run() {
                    NDataPluginFactory.getDataPlugin(null, engine, framework.getAccessRules());
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            openDiagrams(models);
                            framework.hideAnimation();
                        }
                    });
                }
            };
            thread.start();
        } else
            openDiagrams(models);
    }
}
Also used : TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) ArrayList(java.util.ArrayList) TreePath(javax.swing.tree.TreePath) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow) RowTreeTable(com.ramussoft.gui.qualifier.table.RowTreeTable)

Aggregations

Row (com.ramussoft.database.common.Row)81 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)20 Attribute (com.ramussoft.common.Attribute)19 ArrayList (java.util.ArrayList)18 Qualifier (com.ramussoft.common.Qualifier)17 TreePath (javax.swing.tree.TreePath)15 Engine (com.ramussoft.common.Engine)13 Element (com.ramussoft.common.Element)12 RootRow (com.ramussoft.database.common.RowSet.RootRow)12 RowSet (com.ramussoft.database.common.RowSet)9 ActionEvent (java.awt.event.ActionEvent)8 AbstractAction (javax.swing.AbstractAction)8 RowTreeTable (com.ramussoft.gui.qualifier.table.RowTreeTable)6 MouseAdapter (java.awt.event.MouseAdapter)6 MouseEvent (java.awt.event.MouseEvent)6 JComponent (javax.swing.JComponent)6 JScrollPane (javax.swing.JScrollPane)6 AccessRules (com.ramussoft.common.AccessRules)5 Journaled (com.ramussoft.common.journal.Journaled)5 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)5