Search in sources :

Example 6 with RowTreeTable

use of com.ramussoft.gui.qualifier.table.RowTreeTable 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)6 RowTreeTable (com.ramussoft.gui.qualifier.table.RowTreeTable)6 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)5 TreePath (javax.swing.tree.TreePath)4 Qualifier (com.ramussoft.common.Qualifier)3 RootRow (com.ramussoft.database.common.RowSet.RootRow)3 ArrayList (java.util.ArrayList)3 Attribute (com.ramussoft.common.Attribute)2 ActionEvent (java.awt.event.ActionEvent)2 AbstractAction (javax.swing.AbstractAction)2 ImageIcon (javax.swing.ImageIcon)2 AccessRules (com.ramussoft.common.AccessRules)1 Engine (com.ramussoft.common.Engine)1 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)1 GUIFramework (com.ramussoft.gui.common.GUIFramework)1 RootCreater (com.ramussoft.gui.qualifier.table.RootCreater)1 RowNode (com.ramussoft.gui.qualifier.table.RowNode)1 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)1 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)1 RowTreeTableModel (com.ramussoft.gui.qualifier.table.RowTreeTableModel)1