Search in sources :

Example 86 with Function

use of com.ramussoft.pb.Function 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 87 with Function

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

the class AbstractTemplate method createChilds.

private synchronized void createChilds(final Rectangle rectangle) {
    // final IdGenerator g = GlobalId.getGenerator();
    // GlobalId.setGenerator(generator);
    dataPlugin = NDataPluginFactory.getTemplateDataPlugin();
    Function f = dataPlugin.getBaseFunction();
    final ProjectOptions po = f.getProjectOptions();
    po.setChangeDate(po.getDateChangeDate());
    po.setProjectAutor(po.getProjectAutor());
    po.setProjectName(po.getProjectName());
    po.setUsedAt(po.getUsedAt());
    f.setProjectOptions(po);
    final Attribute attribute = dataPlugin.getEngine().createAttribute(new com.ramussoft.common.AttributeType("Core", "Text", true));
    Qualifier q = dataPlugin.getBaseFunctionQualifier();
    q.getAttributes().add(attribute);
    q.setAttributeForName(attribute.getId());
    dataPlugin.getEngine().updateQualifier(q);
    f = (Function) dataPlugin.createRow(f, true);
    diagram = f;
    f.setDecompositionType(decompositionType);
    final FRectangle rect = f.getBounds();
    rect.setX(rectangle.getWidth() / 2 - rect.getWidth() / 2);
    rect.setY(rectangle.getHeight() / 2 - rect.getHeight() / 2);
    f.setBounds(rect);
    createChilds(f, dataPlugin);
    base = f;
// GlobalId.setGenerator(g);
}
Also used : Function(com.ramussoft.pb.Function) Attribute(com.ramussoft.common.Attribute) FRectangle(com.dsoft.pb.types.FRectangle) Qualifier(com.ramussoft.common.Qualifier) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 88 with Function

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

the class IDEFPanel method loadPosiotion.

public void loadPosiotion() {
    final InputStream stream = dataPlugin.getNamedData("system/idef0.pos");
    closeTabs();
    movingArea.clear();
    if (stream == null) {
        movingArea.setActiveFunction(dataPlugin.getBaseFunction());
    } else {
        try {
            DataLoader.readInteger(stream);
            final int l = DataLoader.readInteger(stream);
            if (l < 0)
                return;
            final Tab[] tabs = new Tab[l];
            for (int i = 0; i < l; i++) {
                final GlobalId id = new GlobalId(stream);
                tabs[i] = simpleCreateTab((Function) dataPlugin.findRowByGlobalId(id));
            }
            if (l > 0) {
                final int s = DataLoader.readInteger(stream);
                tabs[s].getPanel().add(getJScrollPane1(), BorderLayout.CENTER);
                tabs[s].select();
                movingArea.setActiveFunction(tabs[s].getFunction());
            } else {
                final GlobalId id = new GlobalId(stream);
                Function active = (Function) dataPlugin.findRowByGlobalId(id);
                if (active == null)
                    active = dataPlugin.getBaseFunction();
                movingArea.setActiveFunction(active);
            }
            stream.close();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
    repaint();
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) InputStream(java.io.InputStream) IOException(java.io.IOException) Crosspoint(com.ramussoft.pb.Crosspoint) GlobalId(com.ramussoft.pb.types.GlobalId)

Example 89 with Function

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

the class IDEFPanel method setFunctionMenu.

public void setFunctionMenu(final Function function) {
    getJMenu1().removeAll();
    final Row[] rows = function.getOwners();
    class OwnerSetter implements ActionListener {

        private final Function function;

        private final Row owner;

        public OwnerSetter(final Function function, final Row owner) {
            super();
            this.function = function;
            this.owner = owner;
        }

        public void actionPerformed(final ActionEvent e) {
            movingArea.startUserTransaction();
            function.setOwner(owner);
            movingArea.commitUserTransaction();
        }
    }
    boolean parentOuner = false;
    Row ouner = function.getOwner();
    Row pOuner = null;
    if (function.getParent() != null)
        pOuner = ((Function) function.getParentRow()).getOwner();
    parentOuner = ((ouner != null) && (ouner.equals(pOuner)));
    JRadioButtonMenuItem item;
    if (pOuner != null) {
        item = new JRadioButtonMenuItem("<html><body><i><b>" + pOuner.getName() + "</b></i></body></html>");
    } else
        item = new JRadioButtonMenuItem("<html><body><i><b>" + ResourceLoader.getString("owner_not_selected") + "</b></i></body></html>");
    item.addActionListener(new OwnerSetter(function, null));
    if (ouner == null || parentOuner)
        item.setSelected(true);
    jMenu1.add(item);
    if (rows.length > 0)
        jMenu1.addSeparator();
    for (final Row element : rows) if (!element.equals(pOuner)) {
        item = new JRadioButtonMenuItem(element.getName());
        item.addActionListener(new OwnerSetter(function, element));
        if (ouner != null && ouner.equals(element))
            item.setSelected(true);
        jMenu1.add(item);
    }
    jMenu1.addSeparator();
    final JMenuItem mi = new JMenuItem(ResourceLoader.getString("Owners.Clasificators"));
    mi.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            getOwnerClasificatorsDialog().showModal();
        }
    });
    jMenu1.add(mi);
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Row(com.ramussoft.pb.Row) JMenuItem(javax.swing.JMenuItem)

Example 90 with Function

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

the class IDEF0Object method getIDEF0Kod.

/**
 * Метод визначає код функціонального блоку у відповідності до стандарту
 * IDEF0
 *
 * @param function Функціональний блок, для якого буде визначений його код.
 * @return Код функціонального блока у відповідності до стандарту IDEF0.
 */
public static String getIDEF0Kod(Row function) {
    Engine engine = function.getEngine();
    Integer integer = (Integer) function.getAttribute(IDEF0Plugin.getDecompositionTypeAttribute(engine));
    if (integer != null && integer.intValue() == MovingArea.DIAGRAM_TYPE_DFDS)
        return function.getNativeCode();
    Qualifier qualifier = engine.getQualifier(function.getElement().getQualifierId());
    DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(qualifier, engine, null);
    com.ramussoft.pb.Row f1 = dataPlugin.findRowByGlobalId(function.getElementId());
    if (f1 != null)
        function = (Row) f1;
    final com.ramussoft.database.common.Row f = function.getParent();
    if (function instanceof Function) {
        ProjectOptions po = ((Function) function).getProjectOptions();
        String letter = po.getDeligate().getModelLetter();
        if (letter != null && letter.length() > 0) {
            if (f == null)
                return letter + "-0";
            if (f.getParent() == null)
                return letter + "0";
            return letter + getRecIDEF0Kod(function);
        }
    }
    if (f == null)
        return "A-0";
    if (f.getParent() == null)
        return "A0";
    return "A" + getRecIDEF0Kod(function);
}
Also used : Row(com.ramussoft.database.common.Row) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row) NRow(com.ramussoft.pb.data.negine.NRow) DataPlugin(com.ramussoft.pb.DataPlugin) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) Engine(com.ramussoft.common.Engine)

Aggregations

Function (com.ramussoft.pb.Function)96 NFunction (com.ramussoft.pb.data.negine.NFunction)50 Row (com.ramussoft.pb.Row)36 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)27 Crosspoint (com.ramussoft.pb.Crosspoint)25 Sector (com.ramussoft.pb.Sector)25 Stream (com.ramussoft.pb.Stream)21 FloatPoint (com.dsoft.pb.types.FloatPoint)19 NSector (com.ramussoft.pb.data.negine.NSector)18 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)17 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)17 Vector (java.util.Vector)17 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)15 IOException (java.io.IOException)13 FRectangle (com.dsoft.pb.types.FRectangle)11 Point (com.ramussoft.pb.idef.elements.Point)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 ArrayList (java.util.ArrayList)10 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)8