Search in sources :

Example 56 with Element

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

the class RowSet method attributeChanged.

protected void attributeChanged(AttributeEvent event) {
    synchronized (STATIC_LOCK) {
        if (currentThread == Thread.currentThread())
            return;
    }
    if (event.getAttribute().equals(getHAttribute())) {
        HierarchicalPersistent old = (HierarchicalPersistent) event.getOldValue();
        HierarchicalPersistent p = (HierarchicalPersistent) event.getNewValue();
        Element e = event.getElement();
        Row row = findRow(e.getId());
        if (row != null) {
            if (old != null) {
                Row parent = row.getParent();
                if (parent != null) {
                    int index = parent.getChildren().indexOf(row);
                    parent.getChildren().remove(row);
                    removedFromChildren(parent, row, index);
                }
            }
            if (p == null)
                return;
            Row parent = findRow(p.getParentElementId());
            if (parent == null)
                parent = root;
            List<Row> children = parent.getChildren();
            children.remove(row);
            row.setNativeParent(parent);
            int index = 0;
            int size = children.size();
            for (int i = 0; i < size; i++) {
                Row row2 = children.get(i);
                if (row2.getElementId() == p.getPreviousElementId()) {
                    index = i + 1;
                    break;
                }
            }
            if (!filter(row.getElement())) {
                children.add(index, row);
                added(parent, row, index);
            }
        } else {
            System.err.println("Warning! Unregister with current rowset row where changed. Element id: " + e.getId() + ", Name: " + e.getName());
            return;
        }
    }
    for (int i = 0; i < attributesWithH.length; i++) {
        if (attributesWithH[i].equals(event.getAttribute())) {
            Row row = findRow(event.getElement().getId());
            if (row == null)
                return;
            row.updateObject(i, event.getNewValue());
            attributeChanged(row, event.getAttribute(), event.getNewValue(), event.getOldValue(), event.isJournaled());
        }
    }
    if (event.getAttribute().getId() == qualifier.getAttributeForName()) {
        Row row = findRow(event.getElement().getId());
        row.updateElement();
    }
}
Also used : HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Element(com.ramussoft.common.Element)

Example 57 with Element

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

the class SectorFontAttributePlugin 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 PaintSector.Pin pin;

        private JFontChooser component;

        private Font font;

        {
            component = new JFontChooser();
            ResourceLoader.setJComponentsText(component);
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            font = pin.getSector().getFont();
            component.setSelFont(font);
            return value;
        }

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

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

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            PaintSector sector = pin.getSector();
            sector.setFont(component.getSelFont());
            sector.copyVisual(Sector.VISUAL_COPY_ADDED);
            pin.getSector().getMovingArea().getRefactor().setUndoPoint();
        }

        @Override
        public boolean isSaveAnyway() {
            return !font.equals(component.getSelFont());
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) JFontChooser(com.ramussoft.pb.frames.components.JFontChooser) Element(com.ramussoft.common.Element) Font(java.awt.Font) Engine(com.ramussoft.common.Engine)

Example 58 with Element

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

the class ModelsPanel method createElement.

public void createElement(Qualifier qualifier) {
    Element element = engine.createElement(IDEF0Plugin.getModelTree(engine).getId());
    engine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(engine), qualifier.getId());
    Row row = tree.getRowSet().createRow(null, element);
    row.setName(qualifier.getName());
}
Also used : Element(com.ramussoft.common.Element) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 59 with Element

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

the class NDataPluginFactory method createDataPlugin.

private DataPlugin createDataPlugin() {
    DataPlugin plugin = (DataPlugin) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { DataPlugin.class }, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            try {
                String name = method.getName();
                if ("getBaseFunction".equals(name)) {
                    if (rowBaseFunction == null) {
                        rowBaseFunction = getBaseFunction(dataPlugin, baseFunction);
                    }
                    return rowBaseFunction;
                }
                if ("getBaseFunctionQualifier".equals(name))
                    return baseFunction;
                if ("isReadOnly".equals(name))
                    return !dataPlugin.getAccessRules().canUpdateQualifier(baseFunction.getId());
                if ("createRow".equals(name)) {
                    com.ramussoft.pb.Row parent = (com.ramussoft.pb.Row) args[0];
                    RowSet set = dataPlugin.getRowSet(baseFunction.getId());
                    if (parent instanceof Function) {
                        Row row = set.createRow((Row) parent);
                        ((NFunction) row).setDefaultValues();
                        ((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
                        return row;
                    }
                } else if ("createFunction".equals(name)) {
                    com.ramussoft.pb.Function parent = (com.ramussoft.pb.Function) args[0];
                    final Integer type = (Integer) args[1];
                    RowSet set = dataPlugin.getRowSet(baseFunction.getId());
                    if (parent instanceof Function) {
                        Row row = set.createRow((Row) parent, new ElementCreationCallback() {

                            @Override
                            public void created(Element element) {
                                Engine engine = dataPlugin.getEngine();
                                Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
                                engine.setAttribute(element, attribute, type);
                            }
                        });
                        ((NFunction) row).setDefaultValues();
                        ((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
                        return row;
                    }
                } else if ((("getChilds".equals(name)) || ("getRecChilds".equals(name))) && (args[0] == null) && (((Boolean) args[1]) == false)) {
                    Vector v = (Vector) method.invoke(dataPlugin, args);
                    v.add(0, dataPlugin.getBaseStream());
                    v.add(0, getBaseFunction(dataPlugin, baseFunction));
                    return v;
                }
                if ("getProjectOptions".equals(name))
                    return getProjectOptions();
                if ("setProjectOptions".equals(name))
                    return setProjectOptions((ProjectOptions) args[0]);
                if ("refresh".equals(name)) {
                    fullRefrash((GUIFramework) args[0]);
                    return null;
                }
                return method.invoke(dataPlugin, args);
            } catch (InvocationTargetException e) {
                throw e.getTargetException();
            }
        }

        private Row getBaseFunction(final NDataPlugin dataPlugin, final Qualifier baseFunction) {
            return dataPlugin.getNBaseFunction(baseFunction.getId());
        }

        protected Object setProjectOptions(ProjectOptions projectOptions) {
            getBaseFunction(dataPlugin, baseFunction).setAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()), projectOptions);
            return null;
        }

        protected Object getProjectOptions() {
            return getBaseFunction(dataPlugin, baseFunction).getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
        }
    });
    plugin.getBaseFunction();
    return plugin;
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) ElementCreationCallback(com.ramussoft.database.common.ElementCreationCallback) Qualifier(com.ramussoft.common.Qualifier) Vector(java.util.Vector) Engine(com.ramussoft.common.Engine) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException) Row(com.ramussoft.database.common.Row) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 60 with Element

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

the class ModelParaleler method createParalel.

public void createParalel(final Function function, final boolean createAllRows) {
    ModelParaleler.this.function = function;
    if (createAllRows)
        createAllRows();
    Qualifier qualifier = toEngine.createQualifier();
    copyQualifier(function.getQualifier(), qualifier);
    IDEF0Plugin.installFunctionAttributes(qualifier, toEngine);
    Qualifier q = IDEF0Plugin.getModelTree(toEngine);
    Element element = toEngine.createElement(q.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(toEngine), qualifier.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(toEngine), function.getName());
    toDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, toEngine, toDataPlugin.getAccessRules());
    ModelParaleler.this.base = toDataPlugin.getBaseFunction();
    Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
    ProjectOptions projectOptions = toDataPlugin.getBaseFunction().getProjectOptions();
    projectOptions.getDeligate().setDiagramSize(function.getProjectOptions().getDeligate().getDiagramSize());
    toDataPlugin.getBaseFunction().setProjectOptions(projectOptions);
    for (Row row : childs) {
        NFunction dest = (NFunction) getRow(row);
        showMessageAnimation(dest.toString());
    }
    NFunction func = null;
    Vector<Row> v = toDataPlugin.getChilds(base, true);
    if (v.size() > 0)
        func = (NFunction) v.get(0);
    createSectorsOnUpperLevel(func);
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6