Search in sources :

Example 21 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsPanel method openDiagram.

private void openDiagram(TreePath path) {
    Object object = path.getLastPathComponent();
    if (object instanceof ModelsNode) {
        Qualifier qualifier = ((ModelsNode) object).getQualifier();
        OpenDiagram open = new OpenDiagram(qualifier, -1l);
        framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
    } else {
        Row row = (Row) object;
        if (row.getChildCount() == 0)
            row = row.getParent();
        if (row instanceof ModelsNode) {
            Qualifier qualifier = ((ModelsNode) row).getQualifier();
            OpenDiagram open = new OpenDiagram(qualifier, -1l);
            framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
        } else {
            if ((row != null) && (row.getElement() != null)) {
                Qualifier qualifier = engine.getQualifier(row.getElement().getQualifierId());
                OpenDiagram open = new OpenDiagram(qualifier, row.getElementId());
                framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
            }
        }
    }
}
Also used : OpenDiagram(com.ramussoft.idef0.OpenDiagram) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

Example 22 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelsPanel method getRecIDEF0Kod.

private static String getRecIDEF0Kod(final Row function) {
    final Row f = function.getParent();
    if (f == null || f.getParent() == null || (f.getParent().getParent() == null))
        return "";
    String id = Integer.toString(function.getId());
    if (id.length() > 1)
        id = "." + id + ".";
    return getRecIDEF0Kod(f) + id;
}
Also used : Row(com.ramussoft.database.common.Row)

Example 23 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class IDEF0Plugin method checkModelTree.

private void checkModelTree(Qualifier modelTree) {
    List<Qualifier> models = new ArrayList<Qualifier>();
    List<Qualifier> qList = engine.getQualifiers();
    for (Qualifier qualifier : qList) {
        if (IDEF0Plugin.isFunction(qualifier)) {
            models.add(qualifier);
        }
    }
    Collections.sort(models, new Comparator<Qualifier>() {

        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return StringCollator.compare(o1.getName(), o2.getName());
        }
    });
    Attribute attribute = StandardAttributesPlugin.getAttributeQualifierId(engine);
    RowSet rowSet = new RowSet(engine, modelTree, new Attribute[] { attribute }, null, true);
    for (Row row : rowSet.getAllRows()) {
        for (int i = models.size() - 1; i >= 0; --i) {
            Qualifier model = models.get(i);
            Long id = (Long) row.getAttribute(attribute);
            if (id != null && model.getId() == id.longValue()) {
                models.remove(i);
                break;
            }
        }
    }
    for (Qualifier model : models) {
        Row row = rowSet.createRow(null);
        row.setName(model.getName());
        row.setAttribute(attribute, model.getId());
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

Example 24 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ComplexImport method importDromSheet.

public void importDromSheet(Sheet sheet, String sheetName, int startFrom, ImportRule[] rules) {
    this.sheetName = sheetName;
    Attribute name = rowSet.getEngine().getAttribute(rowSet.getQualifier().getAttributeForName());
    Row current = null;
    int row = startFrom;
    while (true) {
        org.apache.poi.ss.usermodel.Row row2 = sheet.getRow(row);
        if (row2 == null)
            break;
        for (ImportRule rule : rules) {
            if (rule.getAttribute().equals(name)) {
                String s = null;
                if (rule.getColumn() >= 0) {
                    Cell cell = row2.getCell(rule.getColumn());
                    if (cell != null) {
                        s = cell.getStringCellValue();
                    }
                } else
                    s = sheetName;
                if ((s != null) && (!"".equals(s))) {
                    Element element = null;
                    if (uniqueName)
                        element = rowSet.getEngine().getElement(s, rowSet.getQualifier().getId());
                    if (element != null)
                        current = null;
                    else {
                        current = rowSet.createRow(null);
                    }
                    for (ImportRule rule2 : rules) rule2.setObject(null);
                }
            }
        }
        Hashtable<Attribute, Element> tableElements = new Hashtable<Attribute, Element>(1);
        if (current != null)
            for (ImportRule rule : rules) {
                if (rule.getColumn() == -1) {
                    if (rule.getTableAttribute() == null) {
                        fill(current.getElement(), null, rule.getAttribute(), rule);
                    } else {
                        Element tableElement = tableElements.get(rule.getAttribute());
                        if (tableElement == null) {
                            tableElement = StandardAttributesPlugin.createTableElement(rowSet.getEngine(), rule.getAttribute(), current.getElement());
                            tableElements.put(rule.getAttribute(), tableElement);
                        }
                        fill(tableElement, null, rule.getTableAttribute(), rule);
                    }
                } else {
                    Cell cell = row2.getCell(rule.getColumn());
                    if (cell != null) {
                        if (rule.getTableAttribute() == null) {
                            fill(current.getElement(), cell, rule.getAttribute(), rule);
                        } else {
                            if (!isNull(cell)) {
                                Element tableElement = tableElements.get(rule.getAttribute());
                                if (tableElement == null) {
                                    tableElement = StandardAttributesPlugin.createTableElement(rowSet.getEngine(), rule.getAttribute(), current.getElement());
                                    tableElements.put(rule.getAttribute(), tableElement);
                                }
                                fill(tableElement, cell, rule.getTableAttribute(), rule);
                            }
                        }
                    }
                }
            }
        row++;
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Element(com.ramussoft.common.Element) Row(com.ramussoft.database.common.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 25 with Row

use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.

the class ModelPropertiesDialog method updateAttributesInOrder.

@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
    List<Row> list = view.getSelectedRows();
    List<Attribute> attributes = new ArrayList<Attribute>(list.size());
    for (Row pr : list) {
        Attribute attribute = StandardAttributesPlugin.getAttribute(engine, pr.getElement());
        attributes.add(attribute);
        if (qAttributes.indexOf(attribute) < 0)
            qAttributes.add(attribute);
    }
    List<Attribute> rem = new ArrayList<Attribute>();
    for (Attribute a : qAttributes) if (attributes.indexOf(a) < 0)
        rem.add(a);
    for (Attribute r : rem) qAttributes.remove(r);
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

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