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);
}
}
});
}
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;
}
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;
}
}
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();
}
}
}
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);
}
}
Aggregations