Search in sources :

Example 81 with Engine

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

the class ComplexImport method fill.

private void fill(Element element, Cell cell, Attribute attribute, ImportRule rule) {
    Engine engine = rowSet.getEngine();
    String type = attribute.getAttributeType().toString();
    if (cell == null) {
        try {
            engine.setAttribute(element, attribute, sheetName);
        } catch (Exception e) {
        }
    } else {
        try {
            EObject object = null;
            if (cell.getCellType() == Cell.CELL_TYPE_STRING)
                object = new EObject(cell.getStringCellValue());
            else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
                object = new EObject(cell.getNumericCellValue());
            else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
                object = new EObject(cell.getDateCellValue());
            else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
                object = new EObject(cell.getDateCellValue());
            if (object == null)
                try {
                    object = new EObject(cell.getStringCellValue());
                } catch (Exception e) {
                }
            if (object == null)
                try {
                    object = new EObject(cell.getNumericCellValue());
                } catch (Exception e) {
                }
            if (object == null)
                try {
                    object = new EObject(cell.getDateCellValue());
                } catch (Exception e) {
                }
            if (object == null)
                return;
            if (("".equals(object.getValue())) && (engine.getAttribute(element, attribute) != null)) {
                setAttribute(engine, element, attribute, null, rule);
                return;
            }
            if ((object.getValue() == null) && (engine.getAttribute(element, attribute) != null)) {
                setAttribute(engine, element, attribute, null, rule);
                return;
            }
            if (("Core.Double".equals(type)) || ("Core.Currency".equals(type))) {
                setAttribute(engine, element, attribute, object.doubleValue(), rule);
            } else if (("Core.Text".equals(type)) || ("Core.Variant".equals(type))) {
                setAttribute(engine, element, attribute, object.stringValue(), rule);
            } else if ("Core.Date".equals(type)) {
                setAttribute(engine, element, attribute, object.dateValue(), rule);
            } else if ("Core.Long".equals(type)) {
                setAttribute(engine, element, attribute, object.longValue(), rule);
            } else if ("Core.OtherElement".equals(type)) {
                long qId = getOtherElemetQualifierId(attribute);
                String s = object.stringValue();
                if ((s != null) && (s.length() > 0)) {
                    Element element2 = engine.getElement(s.trim(), qId);
                    if (element2 == null) {
                        Qualifier qualifier = engine.getQualifier(qId);
                        Attribute name = engine.getAttribute(qualifier.getAttributeForName());
                        if (name == null)
                            return;
                        element2 = engine.createElement(qId);
                        setAttribute(engine, element2, name, s, rule);
                    }
                    setAttribute(engine, element, attribute, element2.getId(), rule);
                }
            } else {
                setAttribute(engine, element, attribute, object.getValue(), rule);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) EObject(com.ramussoft.eval.EObject) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Engine(com.ramussoft.common.Engine)

Example 82 with Engine

use of com.ramussoft.common.Engine 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 83 with Engine

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

the class FunctionOptionsDialog method apptype.

private void apptype() {
    Engine e = dataPlugin.getEngine();
    if (e instanceof Journaled)
        ((Journaled) e).startUserTransaction();
    function.setFont(getJFontChooser().getSelFont());
    function.setBackground(getJColorChooser().getColor());
    function.setForeground(getJColorChooser1().getColor());
    final JList jList = selectOwner.getJList();
    if (jList.getSelectedIndex() == 0)
        function.setOwner(null);
    else {
        function.setOwner((Row) jList.getSelectedValue());
    }
    function.setType(functionType.getType());
    AccessRules rules = dataPlugin.getAccessRules();
    Element element = ((NFunction) function).getElement();
    for (int index = attributes.size() - 1; index >= 0; index--) {
        Attribute attribute = attributes.get(index);
        if (rules.canUpdateElement(element.getId(), attribute.getId())) {
            Object value = attributeEditors.get(index).getValue();
            if (!equals(value, values.get(index)))
                e.setAttribute(element, attribute, value);
        }
    }
    if (e instanceof Journaled)
        ((Journaled) e).commitUserTransaction();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) AccessRules(com.ramussoft.common.AccessRules) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Engine(com.ramussoft.common.Engine) JList(javax.swing.JList)

Example 84 with Engine

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

the class FunctionOptionsDialog method load.

private void load() {
    Engine e = dataPlugin.getEngine();
    Qualifier qualifier = function.getQualifier();
    attributes = new ArrayList<Attribute>(qualifier.getAttributes());
    for (int i = attributes.size() - 1; i >= 0; i--) {
        Attribute attribute = attributes.get(i);
        AttributePlugin plugin = framework.findAttributePlugin(attribute.getAttributeType());
        Element element = ((NFunction) function).getElement();
        AttributeEditor editor = plugin.getAttributeEditor(e, dataPlugin.getAccessRules(), element, attribute, "function", null);
        if (editor == null)
            continue;
        attributeEditors.add(0, editor);
        JComponent component = editor.getComponent();
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(component, BorderLayout.CENTER);
        Action[] actions = editor.getActions();
        if (actions.length > 0) {
            JToolBar bar = new JToolBar();
            for (Action a : actions) {
                JButton b = bar.add(a);
                b.setFocusable(false);
                bar.add(b);
            }
            panel.add(bar, BorderLayout.NORTH);
        }
        getJTabbedPane().insertTab(attribute.getName(), null, panel, null, 0);
        Object value = e.getAttribute(element, attribute);
        editor.setValue(value);
        values.add(0, value);
    }
    getJColorChooser().setColor(function.getBackground());
    getJColorChooser1().setColor(function.getForeground());
    getJFontChooser().setSelFont(function.getFont());
    functionType.setFunction(function);
    selectOwner.setFunction(function);
}
Also used : JPanel(javax.swing.JPanel) Action(javax.swing.Action) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) BorderLayout(java.awt.BorderLayout) AttributeEditor(com.ramussoft.gui.common.AttributeEditor) Qualifier(com.ramussoft.common.Qualifier) IDEF0Object(com.ramussoft.pb.idef.visual.IDEF0Object) Engine(com.ramussoft.common.Engine)

Example 85 with Engine

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

the class DiagramOptionsDialog method onOk.

@Override
protected void onOk() {
    Engine engine = framework.getEngine();
    ((Journaled) engine).startUserTransaction();
    function.setStatus(statusPanel.getStatus());
    if (!function.getCreateDate().equals(createDate.getDate()))
        function.setCreateDate(createDate.getDate());
    if (!function.getRevDate().equals(revDate.getDate()))
        function.setRevDate(revDate.getDate());
    if (!function.getAuthor().equals(author.getText()))
        function.setAuthor(author.getText());
    String newSize = String.valueOf(sizesBox.getSelectedItem());
    if (horizontalPageCountBox.getSelectedIndex() != 0)
        newSize += "x" + horizontalPageCountBox.getSelectedItem();
    if (!newSize.equals(function.getPageSize())) {
        function.setPageSize(newSize);
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                framework.propertyChanged(IDEF0TabView.UPDATE_SIZES);
            }
        });
    }
    ((Journaled) engine).commitUserTransaction();
    super.onOk();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Engine(com.ramussoft.common.Engine)

Aggregations

Engine (com.ramussoft.common.Engine)85 Attribute (com.ramussoft.common.Attribute)32 ArrayList (java.util.ArrayList)30 Element (com.ramussoft.common.Element)27 Qualifier (com.ramussoft.common.Qualifier)22 AccessRules (com.ramussoft.common.AccessRules)21 List (java.util.List)19 IEngine (com.ramussoft.common.IEngine)15 Row (com.ramussoft.database.common.Row)13 IOException (java.io.IOException)11 SQLException (java.sql.SQLException)11 PluginFactory (com.ramussoft.common.PluginFactory)8 PluginProvider (com.ramussoft.common.PluginProvider)8 Journaled (com.ramussoft.common.journal.Journaled)8 CachedEngine (com.ramussoft.common.cached.CachedEngine)7 Hashtable (java.util.Hashtable)7 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)6 JournaledEngine (com.ramussoft.common.journal.JournaledEngine)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)5 MemoryDatabase (com.ramussoft.database.MemoryDatabase)5