Search in sources :

Example 61 with Row

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

the class ModelParaleler method loadFromParalel.

public void loadFromParalel(boolean importAll, List<Qualifier> selected) {
    List<Attribute> tAttrs = toEngine.getAttributes();
    List<Attribute> fAttrs = fromEngine.getAttributes();
    for (Attribute f : fAttrs) for (Attribute t : tAttrs) if ((f.getName().equals(t.getName())) && (f.getAttributeType().equals(t.getAttributeType())))
        attrHash.put(f.getId(), t);
    List<Qualifier> fList = fromEngine.getQualifiers();
    List<Qualifier> tList = toEngine.getQualifiers();
    for (Qualifier f : fList) if (!IDEF0Plugin.isFunction(f))
        for (Qualifier t : tList) if (!IDEF0Plugin.isFunction(t))
            if (f.getName().equals(t.getName()))
                qHash.put(f.getId(), t);
    Vector<Row> fRows = fromDataPlugin.getRecChilds(null, false);
    Vector<Row> tRows = toDataPlugin.getRecChilds(null, false);
    for (Row f : fRows) for (Row t : tRows) if (f.getName().equals(t.getName())) {
        rowHash.put(f.getElement().getId(), t);
        Vector<Row> fCRows = fromDataPlugin.getRecChilds(f, true);
        Vector<Row> tCRows = toDataPlugin.getRecChilds(t, true);
        for (Row fc : fCRows) for (Row tc : tCRows) if (fc.getName().equals(tc.getName()))
            rowHash.put(fc.getElement().getId(), tc);
    }
    if (importAll) {
        createAllRows();
    }
    for (Qualifier qualifier : selected) {
        fromDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, fromEngine, fromDataPlugin.getAccessRules());
        Qualifier baseFunction = toEngine.createQualifier();
        baseFunction.setName(qualifier.getName());
        IDEF0Plugin.installFunctionAttributes(baseFunction, toEngine);
        toDataPlugin = NDataPluginFactory.getDataPlugin(baseFunction, toEngine, toDataPlugin.getAccessRules());
        base = toDataPlugin.getBaseFunction();
        List<Attribute> list = getAttributes(qualifier.getAttributes());
        for (Attribute a : list) if (baseFunction.getAttributes().indexOf(a) < 0)
            baseFunction.getAttributes().add(a);
        Attribute forName = fromEngine.getAttribute(qualifier.getAttributeForName());
        if (forName != null)
            baseFunction.setAttributeForName(getAttribute(forName).getId());
        toEngine.updateQualifier(baseFunction);
        if (fromDataPlugin.getBaseFunction().getChildCount() > 0) {
            function = (Function) fromDataPlugin.getBaseFunction().getChildAt(0);
            Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
            childs.add(0, function);
            for (Row row : childs) {
                NFunction dest = (NFunction) getRow(row);
                showMessageAnimation(dest.toString());
            }
            NFunction func = (NFunction) getRow(function);
            createSectorsOnUpperLevel(func);
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 62 with Row

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

the class StreamAttributePlugin 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 SectorRowsEditor sectorRowsEditor;

        private SectorNameEditor sectorNameEditor;

        private PaintSector.Pin pin;

        private DataPlugin dataPlugin;

        private PaintSector sector;

        private JTabbedPane component;

        {
            dataPlugin = NDataPluginFactory.getDataPlugin(null, engine, rules);
            Sector sector = dataPlugin.findSectorByGlobalId(GlobalId.create(element.getId()));
            if (sector != null) {
                dataPlugin = NDataPluginFactory.getDataPlugin(engine.getQualifier(sector.getFunction().getElement().getQualifierId()), engine, rules);
                component = new JTabbedPane();
                sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, rules);
                sectorNameEditor = new SectorNameEditor(dataPlugin, framework, rules) {

                    @Override
                    public Stream getStream() {
                        return sectorRowsEditor.getStream();
                    }
                };
                sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
                component.addTab(ResourceLoader.getString("stream"), null, sectorRowsEditor, null);
                component.addTab(ResourceLoader.getString("name"), null, sectorNameEditor, null);
                ResourceLoader.setJComponentsText(sectorRowsEditor);
                ResourceLoader.setJComponentsText(sectorNameEditor);
            }
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            sector = pin.getSector();
            sectorNameEditor.setSector(sector.getSector());
            sectorRowsEditor.setSector(sector.getSector());
            return value;
        }

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

        @Override
        public JComponent getComponent() {
            if (component == null)
                return new JPanel();
            return component;
        }

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

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            sector.setShowText(sectorNameEditor.getBox().isSelected());
            sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
            Stream stream = sectorRowsEditor.getStream();
            if (stream == null) {
                stream = sectorNameEditor.findStreamByName();
                if (stream == null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            final String t = sectorNameEditor.getArrowName();
            if (!t.equals("")) {
                if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            if (t.equals("")) {
                if (!stream.isEmptyName()) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                    stream.setEmptyName(true);
                }
            } else
                stream.setName(t);
            final Row[] added = stream.getAdded();
            stream.setRows(sectorRowsEditor.getRows());
            sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
            stream = sector.getStream();
            stream.setRows(added);
            // sector.setStreamAddedByRefactor(false);
            final Row[] rs = sectorRowsEditor.getRows();
            sector.setRows(rs);
            sector.createTexts();
            PaintSector.save(sector, new DataLoader.MemoryData(), engine);
            sector.getMovingArea().getRefactor().setUndoPoint();
            sectorNameEditor.setChanged(false);
        }

        @Override
        public boolean canApply() {
            final boolean b = isSave();
            if (b) {
                if (!isOkStreamName()) {
                    if (JOptionPane.showConfirmDialog(component, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
                        return false;
                }
            } else {
                JOptionPane.showMessageDialog(component, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
                return false;
            }
            return b;
        }

        private boolean isSave() {
            final Row[] rs = sectorRowsEditor.getRows();
            final boolean b = rs.length > 0 || !sectorNameEditor.getArrowName().equals("");
            return b;
        }

        private boolean isOkStreamName() {
            final Stream stream = sectorNameEditor.findStreamByName();
            if (stream != null)
                return stream.equals(sectorNameEditor.getNullStream());
            return true;
        }

        @Override
        public boolean isSaveAnyway() {
            return sectorRowsEditor.isChanged() || sectorNameEditor.isChanged();
        }

        @Override
        public void close() {
            super.close();
            sectorRowsEditor.dispose();
        }
    };
}
Also used : JPanel(javax.swing.JPanel) Attribute(com.ramussoft.common.Attribute) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) JTabbedPane(javax.swing.JTabbedPane) Element(com.ramussoft.common.Element) SectorNameEditor(com.ramussoft.pb.idef.frames.SectorNameEditor) DataLoader(com.dsoft.utils.DataLoader) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) SectorRowsEditor(com.ramussoft.pb.idef.frames.SectorRowsEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Engine(com.ramussoft.common.Engine)

Example 63 with Row

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

the class DFDSNamePanel method compile.

private void compile(DFDSName name) {
    Row row = dataPlugin.findRowByGlobalId(element.getId());
    if (row instanceof Function) {
        Function function = (NFunction) row;
        dataPlugin.compileDFDSName(name, function);
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Row(com.ramussoft.pb.Row)

Example 64 with Row

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

the class HTTPParser method getSelRows.

private Row[] getSelRows(Qualifier clasificator) {
    final Enumeration e = params.keys();
    Vector v = new Vector();
    final String base = params.get("base");
    if (base == null) {
        while (e.hasMoreElements()) {
            final Object key = e.nextElement();
            final GlobalId id = GlobalId.convert(key.toString());
            if (id != null) {
                if (!params.get(key).equals("")) {
                    final Row r = dataPlugin.findRowByGlobalId(id);
                    if (r != null)
                        v.add(r);
                }
            }
        }
        final Vector rec = dataPlugin.getRecChildren(clasificator);
        final Vector res = new Vector();
        Object tmp;
        for (int i = 0; i < rec.size(); i++) if (v.indexOf(tmp = rec.get(i)) >= 0)
            res.add(tmp);
        v = res;
    } else {
        try {
            final Row row = dataPlugin.findRowByGlobalId(GlobalId.convert(base));
            v = dataPlugin.getRecChilds(row, true);
            v.insertElementAt(row, 0);
        } catch (final Exception ex) {
        }
    }
    final Row[] rows = new Row[v.size()];
    for (int i = 0; i < rows.length; i++) rows[i] = (Row) v.get(i);
    return rows;
}
Also used : Enumeration(java.util.Enumeration) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) Vector(java.util.Vector) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) GlobalId(com.ramussoft.pb.types.GlobalId)

Example 65 with Row

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

the class HTTPParser method printElements.

private void printElements(final String elementsName, final Object[] rows, final String startLink, final String moreParams, final String tableTag) throws IOException {
    if (rows.length == 0)
        return;
    htmlStream.println(tableTag);
    printMainTableTitle(elementsName);
    for (int i = 0; i < rows.length; i++) {
        final Row row = (Row) rows[i];
        final boolean gray = i % 2 == 0;
        String sGray = "";
        if (gray)
            sGray = " bgcolor=" + GRAY;
        String href;
        if (startLink == null)
            href = null;
        else
            href = startLink + "/index.html?id=" + row.getGlobalId().toString() + moreParams;
        htmlStream.print("<tr>");
        htmlStream.print("<td" + sGray + ">");
        printStartATeg(href);
        printRowKod(row, false);
        if (startLink != null)
            printEndATeg();
        htmlStream.print("</td>");
        htmlStream.print("<td" + sGray + ">");
        printStartATeg(href);
        printRowName(row, false);
        if (startLink != null)
            printEndATeg();
        htmlStream.print("</td>");
        htmlStream.println("</tr>");
    }
    htmlStream.println("</table>");
}
Also used : Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow)

Aggregations

Row (com.ramussoft.pb.Row)93 Function (com.ramussoft.pb.Function)35 Stream (com.ramussoft.pb.Stream)30 Vector (java.util.Vector)28 NFunction (com.ramussoft.pb.data.negine.NFunction)19 Sector (com.ramussoft.pb.Sector)15 NRow (com.ramussoft.pb.data.negine.NRow)14 Qualifier (com.ramussoft.common.Qualifier)13 Crosspoint (com.ramussoft.pb.Crosspoint)13 NSector (com.ramussoft.pb.data.negine.NSector)13 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ArrayList (java.util.ArrayList)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 Attribute (com.ramussoft.common.Attribute)9 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)9 IOException (java.io.IOException)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 Point (com.ramussoft.pb.idef.elements.Point)8 Element (com.ramussoft.common.Element)7