use of com.ramussoft.database.common.Row 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.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class QualifierView method moveElements.
private void moveElements(Row row, long parentElementId, long prevParentId, Qualifier dest) {
long qualifierId = StandardAttributesPlugin.getQualifierId(engine, row.getElement());
framework.propertyChanged("CloseQualifier", qualifierId);
Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(engine);
List<Element> elements = engine.getElements(qualifierId);
for (Element element : elements) {
engine.setElementQualifier(element.getId(), dest.getId());
element.setQualifierId(dest.getId());
HierarchicalPersistent hp = (HierarchicalPersistent) engine.getAttribute(element, hAttribute);
if ((hp != null) && (hp.getParentElementId() == -1l)) {
hp.setParentElementId(row.getElementId());
engine.setAttribute(element, hAttribute, hp);
}
}
long prevId = -1l;
for (Row row2 : toArray(row.getChildren())) {
moveElements(row2, row.getElementId(), prevId, dest);
prevId = row2.getId();
}
String name = row.getName();
engine.setElementQualifier(row.getElementId(), dest.getId());
HierarchicalPersistent hp = new HierarchicalPersistent();
hp.setPreviousElementId(prevParentId);
hp.setParentElementId(parentElementId);
engine.setAttribute(row.getElement(), hAttribute, hp);
Attribute nameAttribute = engine.getAttribute(dest.getAttributeForName());
if (nameAttribute != null)
engine.setAttribute(row.getElement(), nameAttribute, name);
}
use of com.ramussoft.database.common.Row 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.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class AbstractTableView method refreshActions.
protected void refreshActions() {
boolean canCreateElement = accessRules.canCreateElement(qualifier.getId());
createElementAction.setEnabled(canCreateElement);
sortByName.setEnabled(accessRules.canUpdateQualifier(qualifier.getId()));
if (table.getTreeSelectionModel().getSelectionPath() == null) {
deleteElementAction.setEnabled(false);
createChildElementAction.setEnabled(false);
joinElements.setEnabled(false);
setElementIconAction.setEnabled(false);
} else {
boolean e = true;
boolean i = true;
TreePath[] paths = table.getTreeSelectionModel().getSelectionPaths();
long[] ids = new long[paths.length];
boolean first = true;
for (int j = 0; j < ids.length; j++) {
Row row = ((TreeTableNode) paths[j].getLastPathComponent()).getRow();
if (row == null) {
e = false;
i = false;
break;
}
if (row.getChildCount() > 0) {
e = false;
break;
}
ids[j] = row.getElementId();
if (first) {
first = false;
if (!accessRules.canUpdateAttribute(row.getElement().getQualifierId(), row.getRowSet().getHAttribute().getId())) {
i = false;
}
}
}
if (e) {
if (!accessRules.canDeleteElements(ids)) {
e = false;
}
}
deleteElementAction.setEnabled(e);
setElementQualifierAction.setEnabled(e);
joinElements.setEnabled(e);
createChildElementAction.setEnabled(canCreateElement);
setElementIconAction.setEnabled(i);
}
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class RowRootCreater method createRowChildren.
public static Vector<TreeTableNode> createRowChildren(Row root) {
Vector<TreeTableNode> res = new Vector<TreeTableNode>();
for (Row row : root.getChildren()) {
RowNode node = new RowNode(createRowChildren(row), row);
node.setParent();
res.add(node);
}
return res;
}
Aggregations