Search in sources :

Example 86 with Row

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

the class NewProjectDialog method showModal.

public void showModal(final Engine engine, final AccessRules accessRules, final GUIFramework framework) {
    ((Journaled) engine).setNoUndoPoint();
    final Properties name_author = new DefaultProperties(new Property[] { new DefaultProperty(AUTOR, Property.TEXT_FIELD), new DefaultProperty(PROJECT_NAME, Property.TEXT_FIELD), new DefaultProperty(MODEL_NAME, Property.TEXT_FIELD) }, Factory.getString("name_author.Describe"));
    final Properties used_at = new DefaultProperties(new Property[] { new DefaultProperty(USED_AT, Property.TEXT_FIELD) }, Factory.getString("used_at.Describe"));
    final Properties def = new DefaultProperties(new Property[] { new DefaultProperty(DEFINITION, Property.TEXT) }, Factory.getString("describe.Describe"));
    final Properties clasificators = new DefaultProperties(new Property[] { new DefaultProperty(CLASIFICATOR1, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR2, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR3, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR4, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR5, Property.TEXT_FIELD) }, Factory.getString("Clasificators.Describe"));
    masterModel = new DefaultMasterModel(new Properties[] { name_author, used_at, def, clasificators });
    mainPanel = new MainPanel(new PanelCreator(masterModel)) {

        @Override
        public boolean cancel() {
            if (super.cancel()) {
                NewProjectDialog.this.setVisible(false);
                finish();
                return true;
            }
            return false;
        }

        @Override
        protected void finish() {
            super.finish();
            ((Journaled) engine).startUserTransaction();
            final Qualifier baseFunction = engine.createQualifier();
            String modelName = getValue(MODEL_NAME);
            if ((modelName == null) || (modelName.length() == 0))
                baseFunction.setName(ResourceLoader.getString("base_function"));
            else
                baseFunction.setName(modelName);
            Attribute name = engine.createAttribute(new AttributeType("Core", "Text", true));
            name.setName(ResourceLoader.getString("name"));
            engine.updateAttribute(name);
            java.util.Properties ps = engine.getProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES);
            ps.setProperty(AutochangePlugin.AUTO_ADD_ATTRIBUTE_IDS, Long.toString(name.getId()));
            ps.setProperty(AutochangePlugin.ATTRIBUTE_FOR_NAME, Long.toString(name.getId()));
            engine.setProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES, ps);
            baseFunction.getAttributes().add(name);
            baseFunction.setAttributeForName(name.getId());
            IDEF0Plugin.installFunctionAttributes(baseFunction, engine);
            Element element = engine.createElement(IDEF0Plugin.getModelTree(engine).getId());
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(engine), baseFunction.getId());
            HierarchicalPersistent hp = new HierarchicalPersistent();
            hp.setParentElementId(-1l);
            hp.setPreviousElementId(-1l);
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(engine), baseFunction.getName());
            engine.setAttribute(element, StandardAttributesPlugin.getHierarchicalAttribute(engine), hp);
            DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(baseFunction, engine, accessRules);
            if (dfd.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFD);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            ProjectOptions projectOptions = new ProjectOptions();
            projectOptions.setProjectAutor(getValue(AUTOR));
            projectOptions.setProjectName(getValue(PROJECT_NAME));
            projectOptions.setDefinition(getValue(DEFINITION));
            projectOptions.setUsedAt(getValue(USED_AT));
            NewProjectDialog.this.setVisible(false);
            final String[] cls = getClasifiactors();
            final StringBuffer ounersIds = new StringBuffer();
            for (final String c : cls) {
                Row row = dataPlugin.createRow(null, false);
                Qualifier qualifier = engine.getQualifier(StandardAttributesPlugin.getQualifierId(engine, row.getElement().getId()));
                qualifier.setName(c);
                engine.updateQualifier(qualifier);
                if (ouners.indexOf(c) >= 0) {
                    ounersIds.append(qualifier.getId());
                    ounersIds.append(' ');
                }
            }
            dataPlugin.setProperty(DataPlugin.PROPERTY_OUNERS, ounersIds.toString());
            dataPlugin.getBaseFunction().setProjectOptions(projectOptions);
            ((Journaled) engine).commitUserTransaction();
            ((Journaled) engine).setNoUndoPoint();
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    framework.propertyChanged("ShowWorkspace", "Workspace.IDEF0");
                    OpenDiagram open = new OpenDiagram(baseFunction, -1l);
                    framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
                }
            });
        }
    };
    setContentPane(mainPanel);
    pack();
    Dimension size = this.getSize();
    setMinimumSize(new Dimension(size.width, size.height + 30));
    setLocationRelativeTo(null);
    setVisible(true);
    frame.repaint();
}
Also used : DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Dimension(java.awt.Dimension) DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Properties(com.ramussoft.pb.master.model.Properties) DefaultProperty(com.ramussoft.pb.master.model.DefaultProperty) Journaled(com.ramussoft.common.journal.Journaled) MainPanel(com.ramussoft.pb.master.gui.MainPanel) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) AttributeType(com.ramussoft.common.AttributeType) DefaultPanelCreator(com.ramussoft.pb.master.gui.DefaultPanelCreator) OpenDiagram(com.ramussoft.idef0.OpenDiagram) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) DefaultMasterModel(com.ramussoft.pb.master.model.DefaultMasterModel) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 87 with Row

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

the class HTMLHelper method getDiagram.

/*
     *
	 * private static final int IMAGE_WIDTH = 850; private static final int
	 * IMAGE_HEIGHT = 738;
	 */
public String getDiagram(final String sId, final String functionController, final String clasificatorController) {
    if (sId == null)
        return null;
    final Row r = dataPlugin.findRowByGlobalId(GlobalId.convert(sId));
    if (r instanceof Function) {
        final Function function = (Function) r;
        final int imageWidth = IMAGE_WIDTH;
        final int imageHeight = IMAGE_HEIGHT;
        final DiagramHolder htmlStream = new DiagramHolder();
        htmlStream.println("<img border=0 width=" + imageWidth + " height=" + imageHeight + " src=\"" + functionController + "idef0/" + function.getGlobalId().toString() + "\" useMap=#M" + function.getGlobalId().toString() + ">");
        htmlStream.println("<map name=M" + function.getGlobalId().toString() + ">");
        final Vector childs = dataPlugin.getChilds(function, true);
        final MovingArea area = PIDEF0painter.createMovingArea(new Dimension(imageWidth, imageHeight), dataPlugin);
        final SectorRefactor refactor = area.getRefactor();
        for (int i = 0; i < childs.size(); i++) {
            final Function fun = (Function) childs.get(i);
            String where;
            if (fun.isLeaf())
                where = clasificatorController;
            else
                where = functionController + "index/";
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + where + fun.getGlobalId().toString() + "\"");
            htmlStream.println(">");
        }
        refactor.loadFromFunction(function, false);
        final int sc = refactor.getSectorsCount();
        for (int i = 0; i < sc; i++) {
            final PaintSector sector = refactor.getSector(i);
            final Stream stream = sector.getStream();
            final MovingLabel text = refactor.getSector(i).getText();
            if (text != null && stream != null) {
                htmlStream.print("<area shape=RECT coords=" + getAreaCoords(text.getBounds(), area) + " href=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
                htmlStream.println(">");
            }
            final int l = sector.getPinCount();
            for (int j = 0; j < l; j++) if (stream != null) {
                final Pin pin = sector.getPin(j);
                htmlStream.print("<area shape=RECT coords=" + getPinCoords(pin, area) + " href=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
                htmlStream.println(">");
            }
        }
        htmlStream.println("<map>");
        return htmlStream.toString();
    }
    return null;
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Dimension(java.awt.Dimension) Function(com.ramussoft.pb.Function) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 88 with Row

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

the class UserTemplate method createChilds.

public void createChilds(final Function function, final DataPlugin dataPlugin) {
    Hashtable<Long, Long> trans = new Hashtable<Long, Long>();
    final MovingArea ma = new MovingArea(dataPlugin);
    ma.setDataPlugin(dataPlugin);
    ma.setActiveFunction(function);
    final SectorRefactor refactor = ma.getRefactor();
    try {
        final ByteArrayInputStream streamr = new ByteArrayInputStream(data);
        final ObjectInputStream stream = new ObjectInputStream(streamr);
        final MemoryData data = new MemoryData();
        int l = DataLoader.readInteger(stream);
        for (int i = 0; i < l; i++) {
            final Function c = (Function) dataPlugin.createRow(function, true);
            c.setName(functionNames.get(i));
            if (i < functionTypes.size())
                c.setType(functionTypes.get(i));
            if (i < functionLinks.size()) {
                Row r = dataPlugin.findRowByGlobalId(functionLinks.get(i));
                if (r != null) {
                    if (r instanceof Stream) {
                        Stream st = (Stream) r;
                        Stream s = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                        s.setAttachedStatus(st.getAttachedStatus());
                        s.setEmptyName(st.isEmptyName());
                        s.setRows(st.getAdded());
                        c.setLink(s.getElement().getId());
                    }
                }
            }
            final long id = DataLoader.readLong(stream);
            trans.put(id, c.getElement().getId());
            c.setBounds(DataLoader.readFRectangle(stream));
            c.setFont(DataLoader.readFont(stream, data));
            c.setBackground(DataLoader.readColor(stream, data));
            c.setForeground(DataLoader.readColor(stream, data));
        }
        // Read version of
        final int ver = DataLoader.readInteger(stream);
        // Paint
        // Sector format
        l = DataLoader.readInteger(stream);
        HashMap<Sector, List<SectorPointPersistent>> pointsCache = new HashMap<Sector, List<SectorPointPersistent>>();
        HashMap<Long, Long> pointIds = new HashMap<Long, Long>();
        for (int i = 0; i < l; i++) {
            final Sector s = dataPlugin.createSector();
            s.setFunction(function);
            final long id = DataLoader.readLong(stream);
            trans.put(id, ((NSector) s).getElementId());
            final byte[] va = DataLoader.readBytes(stream);
            s.setVisualAttributes(va);
            List<SectorPointPersistent> points = (List) stream.readObject();
            pointsCache.put(s, points);
            normalize(points, dataPlugin.getEngine(), pointIds);
            s.setSectorPointPersistents(points);
            s.setSectorProperties((SectorPropertiesPersistent) stream.readObject());
            // final byte bs[] = DataLoader.readBytes(stream);
            // final ByteArrayInputStream ba = new ByteArrayInputStream(bs);
            final PaintSector ps = PaintSector.loadFromSector(ver, ma, data, dataPlugin, s);
            refactor.addSector(ps);
            Crosspoint c;
            if (DataLoader.readBoolean(stream)) {
                c = getCrosspoint(dataPlugin, trans, stream);
                s.getStart().setCrosspointA(c);
            }
            loadBorder(s.getStart(), stream, trans, dataPlugin, refactor, ps, true);
            s.getStart().commit();
            if (DataLoader.readBoolean(stream)) {
                c = getCrosspoint(dataPlugin, trans, stream);
                s.getEnd().setCrosspointA(c);
            }
            loadBorder(s.getEnd(), stream, trans, dataPlugin, refactor, ps, false);
            s.getEnd().commit();
            if (DataLoader.readBoolean(stream)) {
                int count = DataLoader.readInteger(stream);
                List<Row> rows = new ArrayList<Row>();
                for (int j = 0; j < count; j++) {
                    Row row = loadRow(stream, dataPlugin);
                    if (row != null)
                        rows.add(row);
                }
                if (rows.size() > 0) {
                    Stream stream2 = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                    stream2.setRows(rows.toArray(new Row[rows.size()]));
                    ((NSector) s).setThisStream(stream2);
                }
            }
        }
        setPoints(pointsCache);
        refactor.saveToFunction();
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSector(com.ramussoft.pb.data.negine.NSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Hashtable(java.util.Hashtable) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) IOException(java.io.IOException) ByteArrayInputStream(java.io.ByteArrayInputStream) MemoryData(com.dsoft.utils.DataLoader.MemoryData) SectorPointPersistent(com.ramussoft.idef0.attribute.SectorPointPersistent) Row(com.ramussoft.pb.Row) ObjectInputStream(java.io.ObjectInputStream)

Example 89 with Row

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

the class DFDSRoleOptionsDialog method onOk.

@Override
protected void onOk() {
    if (!isCanOk()) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
        return;
    }
    if (!isOkStreamName()) {
        if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
            return;
        }
    }
    DFDSRole role = (DFDSRole) object;
    Journaled journaled = (Journaled) dataPlugin.getEngine();
    journaled.startUserTransaction();
    Function function = object.getFunction();
    function.setFont(fontChooser.getSelFont());
    function.setBackground(backgroundColorChooser.getColor());
    function.setForeground(foregroundColorChooser.getColor());
    role.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);
    }
    stream.setRows(sectorRowsEditor.getRows());
    role.setStream(stream, ReplaceStreamType.SIMPLE);
    // sector.setStreamAddedByRefactor(false);
    final Row[] rs = sectorRowsEditor.getRows();
    role.setRows(rs);
    if (rs != null) {
        RectangleVisualOptions ops = new RectangleVisualOptions();
        ops.bounds = function.getBounds();
        ops.background = function.getBackground();
        ops.font = function.getFont();
        ops.foreground = function.getForeground();
        for (Row row : rs) if (row != null) {
            IDEF0Plugin.setDefaultRectangleVisualOptions(dataPlugin.getEngine(), row.getElement(), ops);
        }
    }
    journaled.commitUserTransaction();
    setVisible(false);
}
Also used : DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) Journaled(com.ramussoft.common.journal.Journaled) Function(com.ramussoft.pb.Function) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 90 with Row

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

the class DFDSMovingLabel method getText.

@Override
public String getText() {
    if (labelText == null) {
        String s = sector.getAlternativeText();
        if ("".equals(s)) {
            final Stream stream = sector.getStream();
            if (stream != null) {
                if (stream.isEmptyName()) {
                    Row[] rows = stream.getAdded();
                    StringBuilder sb = null;
                    for (Row row : rows) if (row != null) {
                        if (sb == null)
                            sb = new StringBuilder(row.getName());
                        else {
                            sb.append(";\n");
                            sb.append(row.getName());
                        }
                        String status = row.getAttachedStatus();
                        if (status != null) {
                            int i = status.indexOf('|');
                            if (i >= 0) {
                                status = status.substring(i + 1);
                                if (status.trim().length() == 0)
                                    status = null;
                            }
                        }
                        if (status != null) {
                            sb.append(" (");
                            sb.append(status);
                            sb.append(')');
                        }
                    }
                    if (sb != null)
                        s = sb.toString();
                } else
                    s = stream.getName();
            }
        }
        labelText = s;
    }
    return labelText;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

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