Search in sources :

Example 6 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class NFunction method getProjectOptions.

@Override
public ProjectOptions getProjectOptions() {
    NFunction f = this;
    while (f.getParent() != null) {
        f = (NFunction) f.getParentRow();
    }
    ProjectOptions options = (ProjectOptions) f.getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
    if (options == null)
        options = new ProjectOptions();
    return options;
}
Also used : ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 7 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions 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 8 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions 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 9 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions 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)

Example 10 with ProjectOptions

use of com.dsoft.pb.idef.elements.ProjectOptions in project ramus by Vitaliy-Yakovchuk.

the class IDEF0Object method getDFDSKod.

public static String getDFDSKod(Row function, DataPlugin dataPlugin) {
    if (function instanceof Function) {
        ProjectOptions po = ((Function) function).getProjectOptions();
        String letter = po.getDeligate().getModelLetter();
        if (letter != null && letter.length() > 0) {
            if (function.equals(dataPlugin.getBaseFunction()))
                return letter + "-0";
            return letter + getRecDFDSKod(function, true);
        }
    }
    if (function.equals(dataPlugin.getBaseFunction()))
        return "A-0";
    return "A-" + getRecDFDSKod(function, true);
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Aggregations

ProjectOptions (com.dsoft.pb.idef.elements.ProjectOptions)10 Function (com.ramussoft.pb.Function)6 Qualifier (com.ramussoft.common.Qualifier)5 NFunction (com.ramussoft.pb.data.negine.NFunction)5 Attribute (com.ramussoft.common.Attribute)3 Element (com.ramussoft.common.Element)3 DataPlugin (com.ramussoft.pb.DataPlugin)3 Row (com.ramussoft.pb.Row)3 Readed (com.dsoft.pb.idef.elements.Readed)2 FRectangle (com.dsoft.pb.types.FRectangle)2 Engine (com.ramussoft.common.Engine)2 Row (com.ramussoft.database.common.Row)2 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)2 Vector (java.util.Vector)2 FloatPoint (com.dsoft.pb.types.FloatPoint)1 AttributeType (com.ramussoft.common.AttributeType)1 IEngine (com.ramussoft.common.IEngine)1 AbstractAttributeConverter (com.ramussoft.common.attribute.AbstractAttributeConverter)1 Journaled (com.ramussoft.common.journal.Journaled)1 Persistent (com.ramussoft.common.persistent.Persistent)1