Search in sources :

Example 1 with Row

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);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeTableNode(com.ramussoft.gui.qualifier.table.TreeTableNode) Row(com.ramussoft.database.common.Row) RowTreeTable(com.ramussoft.gui.qualifier.table.RowTreeTable)

Example 2 with Row

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);
}
Also used : Attribute(com.ramussoft.common.Attribute) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Element(com.ramussoft.common.Element) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 3 with Row

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) Attribute(com.ramussoft.common.Attribute) ActionEvent(java.awt.event.ActionEvent) SelectionEvent(com.ramussoft.gui.qualifier.table.event.SelectionEvent) Row(com.ramussoft.database.common.Row) RowTreeTable(com.ramussoft.gui.qualifier.table.RowTreeTable) AbstractAction(javax.swing.AbstractAction) SelectionListener(com.ramussoft.gui.qualifier.table.event.SelectionListener)

Example 4 with Row

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);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) Row(com.ramussoft.database.common.Row)

Example 5 with Row

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;
}
Also used : Row(com.ramussoft.database.common.Row) Vector(java.util.Vector)

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