use of com.ramussoft.gui.qualifier.table.RowTreeTable in project ramus by Vitaliy-Yakovchuk.
the class QualifierPreferencesPanel method refreshActions.
protected void refreshActions() {
RowTreeTable table = attributeEditor.getRowTreeTableComponent().getTable();
createAttributeAction.setEnabled(rules.canCreateAttribute());
if (table.getTreeSelectionModel().getSelectionPath() == null) {
deleteAttributeAction.setEnabled(false);
} else {
boolean e = true;
TreePath[] paths = table.getTreeSelectionModel().getSelectionPaths();
for (TreePath path : paths) {
Row row = ((TreeTableNode) path.getLastPathComponent()).getRow();
if (row == null) {
e = false;
break;
}
if (row.getChildCount() > 0) {
e = false;
break;
}
Long long1 = (Long) row.getAttribute(attributeId);
if (long1 == null)
break;
long attrId = long1;
if (!rules.canDeleteAttribute(attrId)) {
e = false;
break;
}
}
deleteAttributeAction.setEnabled(e);
}
}
use of com.ramussoft.gui.qualifier.table.RowTreeTable in project ramus by Vitaliy-Yakovchuk.
the class QualifierHistoryPlugin method getHistoryAction.
private Action getHistoryAction(final TableTabView tableView) {
Action res = (Action) tableView.getTag().get("HistoryAction");
if (res == null) {
final Action action = new AbstractAction() {
/**
*/
private static final long serialVersionUID = 6587512715104944731L;
{
putValue(ACTION_COMMAND_KEY, "Action.ShowHistory");
putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/com/ramussoft/gui/table/history.png")));
setEnabled(false);
}
@Override
public void actionPerformed(ActionEvent e) {
RowTreeTable table = tableView.getComponent().getTable();
Row row;
if ((table.getSelectedColumn() >= 0) && (table.getSelectedNode() != null) && ((row = table.getSelectedNode().getRow()) != null)) {
int c = table.convertColumnIndexToModel(table.getSelectedColumn());
Attribute attribute = table.getRowSet().getAttributes()[c];
showHistory(tableView, row.getElement(), attribute);
}
}
};
res = action;
tableView.getTag().put("HistoryAction", res);
tableView.getComponent().getTable().addSelectionListener(new SelectionListener() {
@Override
public void changeSelection(SelectionEvent event) {
RowTreeTable table = tableView.getComponent().getTable();
Row row;
if ((table.getSelectedColumn() >= 0) && (table.getSelectedNode() != null) && ((row = table.getSelectedNode().getRow()) != null)) {
int c = table.convertColumnIndexToModel(table.getSelectedColumn());
Attribute attribute = table.getRowSet().getAttributes()[c];
action.setEnabled(StandardAttributesPlugin.hasHistory(tableView.getFramework().getEngine(), row.getElement(), attribute));
} else {
action.setEnabled(false);
}
}
});
}
return res;
}
use of com.ramussoft.gui.qualifier.table.RowTreeTable in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method canOpen.
public boolean canOpen() {
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);
}
}
}
}
}
}
return models.size() > 0;
}
use of com.ramussoft.gui.qualifier.table.RowTreeTable in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method init.
private void init() {
tree = new RowTreeTableComponent(engine, IDEF0Plugin.getModelTree(engine), framework.getAccessRules(), new ModelRowCreator(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework) {
@Override
protected RowTreeTableModel createRowTreeTableModel(final Engine engine, Qualifier qualifier, AccessRules accessRules, RootCreater rootCreater, Attribute[] attributes, GUIFramework framework) {
RowTreeTableModel rowTreeTableModel = new RowTreeTableModel(engine, qualifier, attributes, accessRules, rootCreater, framework) {
@Override
protected RowNode newRowNode(Row row) {
Long id = (Long) row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine));
if (id != null) {
Qualifier qualifier = engine.getQualifier(id);
if (qualifier != null) {
ModelsNode node = newModelsNode(row, qualifier);
node.getTreeTableModel().setTable(tree.getTable());
node.getTreeTableModel().setModelSupport(tree.getModel().getModelSupport());
return node;
}
}
return super.newRowNode(row);
}
@Override
public boolean isCellEditable(Object node, int column) {
if (super.isCellEditable(node, column)) {
if (node instanceof ModelsNode)
return true;
}
return false;
}
};
return rowTreeTableModel;
}
@Override
protected RowTreeTable createTable(AccessRules accessRules, GUIFramework framework, AttributePlugin[] plugins) {
return new RowTreeTable(accessRules, model.getRowSet(), plugins, framework, model) {
long treeModelsId = IDEF0Plugin.getModelTree(engine).getId();
@Override
public Transferable createTransferable() {
final int[] is = getSelectedRows();
final ArrayList<Integer> al = new ArrayList<Integer>();
long id = IDEF0Plugin.getModelTree(engine).getId();
Rows rows = new Rows();
for (final int i : is) {
al.add(i);
TreeTableNode node = (TreeTableNode) getPathForRow(i).getLastPathComponent();
if ((node != null) && (node.getRow() != null)) {
Row row = node.getRow();
rows.add(row);
if (row.getElement().getQualifierId() != id)
return null;
}
}
exporting = true;
return new ArrayTransferable(al, rows);
}
@Override
public boolean importData(Transferable t, boolean on, int aIndex) {
int index = aIndex;
long id = IDEF0Plugin.getModelTree(engine).getId();
if (index >= getRowCount())
index--;
if (index < 0)
return false;
TreeTableNode node = (TreeTableNode) getPathForRow(index).getLastPathComponent();
if (node.getRow() != null)
if (node.getRow().getElement().getQualifierId() != id)
return false;
return super.importData(t, on, aIndex);
}
@Override
protected Icon getDefaultIcon(Row row) {
if (row.getElement().getQualifierId() != treeModelsId) {
if (row.getChildCount() == 0)
return note;
else
return function;
}
if (row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine)) == null)
return null;
return ModelsPanel.this.model;
}
};
}
};
fixTable((TreeTableNode) tree.getModel().getRoot());
tree.getTable().addMouseListener(new MouseAdapter() {
private int[] lastSelectedRows;
private long lastClickTime;
@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 < QualifierView.EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, tree.getTable().getSelectedRows()))) {
if (!tree.getTable().isEditing()) {
editTableField();
}
} else {
lastClickTime = System.currentTimeMillis();
lastSelectedRows = tree.getTable().getSelectedRows();
}
}
}
}
});
tree.getTable().setEditIfNullEvent(false);
tree.getTable().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
tree.getTable().getActionMap().put("EditCell", new AbstractAction() {
/**
*/
private static final long serialVersionUID = 3229634866196074563L;
@Override
public void actionPerformed(ActionEvent e) {
if ((tree.getTable().getSelectedRow() >= 0) && (tree.getTable().getSelectedColumn() >= 0))
editTableField();
}
});
JScrollPane pane = new JScrollPane();
pane.setViewportView(tree);
this.add(pane, BorderLayout.CENTER);
}
use of com.ramussoft.gui.qualifier.table.RowTreeTable in project ramus by Vitaliy-Yakovchuk.
the class ModelPropertiesDialog method refreshActions.
protected void refreshActions() {
RowTreeTable table = component.getTable();
createAttributeAction.setEnabled(rules.canCreateAttribute());
if (table.getTreeSelectionModel().getSelectionPath() == null) {
deleteAttributeAction.setEnabled(false);
attributePreferencesAction.setEnabled(false);
} else {
attributePreferencesAction.setEnabled(true);
boolean e = true;
TreePath[] paths = table.getTreeSelectionModel().getSelectionPaths();
for (TreePath path : paths) {
Row row = ((TreeTableNode) path.getLastPathComponent()).getRow();
if (row == null) {
e = false;
break;
}
if (row.getChildCount() > 0) {
e = false;
break;
}
Long long1 = (Long) row.getAttribute(attributeId);
if (long1 == null)
break;
long attrId = long1;
if (!rules.canDeleteAttribute(attrId)) {
e = false;
break;
}
}
deleteAttributeAction.setEnabled(e);
}
}
Aggregations