Search in sources :

Example 81 with Element

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

the class LineStyleAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private LineStyleChooser component;

        private Stroke stroke;

        {
            component = new LineStyleChooser();
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            stroke = pin.getSector().getStroke();
            component.setStroke(stroke);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            LineStyleAttributePlugin.this.apply(component.getStroke(), pin);
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public boolean isSaveAnyway() {
            return !stroke.equals(component.getStroke());
        }
    };
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) LineStyleChooser(com.ramussoft.pb.frames.components.LineStyleChooser) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Engine(com.ramussoft.common.Engine)

Example 82 with Element

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

the class QualifierImporterImpl method importQualifiers.

public void importQualifiers(int elementImportType, boolean importTableAttributes) {
    int i = 0;
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = createQualifier(sourceQualifier, sourceRows[i]);
        qualifiers.put(sourceQualifier, qualifier);
        i++;
    }
    if (importTableAttributes)
        createTableAttributes();
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = getDestination(sourceQualifier);
        Attribute attributeForDestName = null;
        for (Attribute sourceAttribute : sourceQualifier.getAttributes()) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute == null) {
                AttributePlugin plugin = framework.findAttributePlugin(sourceAttribute.getAttributeType());
                if (plugin != null) {
                    destAttribute = plugin.createSyncAttribute(engine, this, sourceAttribute);
                    if (destAttribute != null) {
                        attributes.put(sourceAttribute, destAttribute);
                    }
                }
            }
            if (destAttribute != null) {
                if (qualifier.getAttributes().indexOf(destAttribute) < 0) {
                    qualifier.getAttributes().add(destAttribute);
                }
                if (sourceQualifier.getAttributeForName() == sourceAttribute.getId())
                    attributeForDestName = destAttribute;
            }
        }
        if (attributeForDestName != null)
            qualifier.setAttributeForName(attributeForDestName.getId());
        engine.updateQualifier(qualifier);
    }
    for (Qualifier sourceQualifier : sourceQualifiers) {
        for (Attribute sourceAttribute : sourceQualifier.getAttributes()) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute != null) {
                AttributePlugin plugin = framework.findAttributePlugin(sourceAttribute.getAttributeType());
                if (plugin != null) {
                    plugin.syncAttribute(engine, this, sourceAttribute);
                }
            }
        }
    }
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = getDestination(sourceQualifier);
        List<Element> sourceElements = source.getElements(sourceQualifier.getId());
        List<Element> destElements = engine.getElements(qualifier.getId());
        for (Element sourceElement : sourceElements) {
            Element dest = createElement(sourceElement, destElements, qualifier.getId());
            elements.put(sourceElement, dest);
        }
    }
    if (importTableAttributes)
        setupTableElements();
    Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(source);
    for (Qualifier sourceQualifier : sourceQualifiers) {
        List<Element> sourceElements = source.getElements(sourceQualifier.getId());
        boolean h = sourceQualifier.getSystemAttributes().indexOf(hAttribute) >= 0;
        for (Element sourceElement : sourceElements) {
            Element dest = getDestination(sourceElement);
            if (h && (createdElemets.get(sourceElement) != null)) {
                HierarchicalPersistent hp = (HierarchicalPersistent) getSourceValue(sourceElement, hAttribute);
                Element prev = source.getElement(hp.getPreviousElementId());
                Element parent = source.getElement(hp.getParentElementId());
                HierarchicalPersistent set = new HierarchicalPersistent();
                if (prev == null)
                    set.setPreviousElementId(-1l);
                else
                    set.setPreviousElementId(getDestination(prev).getId());
                if (parent == null) {
                    set.setParentElementId(-1l);
                } else {
                    Element destination = getDestination(parent);
                    if (destination != null)
                        set.setParentElementId(destination.getId());
                    else
                        set.setParentElementId(-1l);
                }
                engine.setAttribute(dest, StandardAttributesPlugin.getHierarchicalAttribute(engine), set);
            }
        }
        Attribute[] attributes = sourceQualifier.getAttributes().toArray(new Attribute[sourceQualifier.getAttributes().size()]);
        Arrays.sort(attributes, new Comparator<Attribute>() {

            @Override
            public int compare(Attribute o1, Attribute o2) {
                AttributePlugin plugin1 = framework.findAttributePlugin(o1.getAttributeType());
                AttributePlugin plugin2 = framework.findAttributePlugin(o1.getAttributeType());
                if (plugin1 == null) {
                    if (plugin2 == null)
                        return 0;
                    else
                        return -1;
                }
                if (plugin2 == null)
                    return 1;
                if (plugin1.getSyncPriority() > plugin2.getSyncPriority())
                    return 1;
                if (plugin1.getSyncPriority() < plugin2.getSyncPriority())
                    return -1;
                return 0;
            }
        });
        for (Attribute sourceAttribute : attributes) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute != null) {
                AttributePlugin plugin = framework.findAttributePlugin(destAttribute.getAttributeType());
                for (Element sourceElement : sourceElements) {
                    if ((createdElemets.get(sourceElement) != null) || (elementImportType == ELEMENT_IMPORT_TYPE_UPDATE)) {
                        if (plugin != null)
                            plugin.syncElement(engine, this, sourceElement, sourceAttribute);
                    }
                }
            }
        }
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 83 with Element

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

the class QualifierImporterImpl method setupTableElements.

private void setupTableElements() {
    List<Attribute> attributes = new ArrayList<Attribute>(1);
    attributes.add(StandardAttributesPlugin.getTableElementIdAttribute(source));
    Attribute toSet = StandardAttributesPlugin.getTableElementIdAttribute(engine);
    for (Qualifier q : tableSourceQualifiers) {
        Hashtable<Element, Object[]> table = source.getElements(q, attributes);
        for (Entry<Element, Object[]> entry : table.entrySet()) {
            Long l = (Long) entry.getValue()[0];
            if (l != null) {
                Element s = source.getElement(l);
                Element d = getDestination(s);
                if (d != null) {
                    Element dest = getDestination(entry.getKey());
                    engine.setAttribute(dest, toSet, d.getId());
                }
            }
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier)

Example 84 with Element

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

the class HTTPParser method printReportsQ.

private void printReportsQ() throws IOException {
    final String sNum = params.get("num");
    if (sNum == null)
        printError(RES.getString("reportEror"));
    final long num = Long.parseLong(sNum);
    Element report = null;
    if ((report = dataPlugin.getEngine().getElement(num)) == null) {
        printError(RES.getString("reportEror"));
        return;
    }
    htmlTitle = RES.getString("reportQuaryFor") + ": " + report.getName();
    printStartD();
    Qualifier qualifier = ((ReportQuery) dataPlugin.getEngine()).getHTMLReportQuery(report);
    if (qualifier == null) {
        printReport(report, null);
    } else
        printReportQuary(qualifier, Long.toString(report.getId()));
    printEndD();
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 85 with Element

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

the class HTTPParser method printFunctionArrows.

private void printFunctionArrows(final Vector left, final String string) throws IOException {
    final Vector<Row> v = new Vector<Row>();
    for (int i = 0; i < left.size(); i++) {
        final Stream stream = (Stream) left.get(i);
        final Row[] rs = stream.getAdded();
        for (final Row row : rs) {
            if (v.indexOf(row) < 0)
                v.add(row);
        }
    }
    final Row[] rows = new Row[v.size()];
    for (int i = 0; i < rows.length; i++) rows[i] = v.get(i);
    if (rows.length == 0)
        return;
    RowFactory.sortByName(rows);
    htmlStream.println("<p>");
    htmlStream.println("<table border=1 width=100%>");
    printMainTableTitle(string, 3);
    htmlStream.print("<tr>");
    htmlStream.print("<td><b>");
    htmlStream.print(RES.getString("kod"));
    htmlStream.print("</b></td>");
    htmlStream.print("<td><b>");
    htmlStream.print(RES.getString("element"));
    htmlStream.print("</b></td>");
    htmlStream.print("<td><b>");
    htmlStream.print(RES.getString("clasificator"));
    htmlStream.print("</b></td>");
    htmlStream.println("</tr>");
    for (final Row row : rows) {
        htmlStream.print("<tr>");
        htmlStream.print("<td>");
        printStartATeg("rows/index.html?id=" + row.getGlobalId().toString());
        htmlStream.print(row.getKod());
        printEndATeg();
        htmlStream.print("</td>");
        htmlStream.print("<td width=100%>");
        printStartATeg("rows/index.html?id=" + row.getGlobalId().toString());
        htmlStream.print(row.getName());
        printEndATeg();
        htmlStream.print("</td>");
        Qualifier q = dataPlugin.getEngine().getQualifier(row.getElement().getQualifierId());
        Element element = StandardAttributesPlugin.getElement(dataPlugin.getEngine(), q.getId());
        htmlStream.print("<td>");
        String name = q.getName();
        if (element != null) {
            printStartATeg("rows/index.html?id=" + element.getId());
        } else {
            if (name.equals(StandardAttributesPlugin.QUALIFIERS_QUALIFIER))
                name = RES.getString("clasificator");
        }
        htmlStream.print(name);
        if (element != null) {
            printEndATeg();
        }
        htmlStream.print("</td>");
        htmlStream.println("</tr>");
    }
    htmlStream.println("</table>");
    htmlStream.println("</p>");
}
Also used : Element(com.ramussoft.common.Element) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) Vector(java.util.Vector)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6