Search in sources :

Example 6 with NFunction

use of com.ramussoft.pb.data.negine.NFunction 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 7 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method loadFromParalel.

public void loadFromParalel(Function base, boolean importAll, List<Qualifier> selected) {
    this.base = base;
    List<Attribute> tAttrs = toEngine.getAttributes();
    List<Attribute> fAttrs = fromEngine.getAttributes();
    for (Attribute f : fAttrs) for (Attribute t : tAttrs) if ((f.getName().equals(t.getName())) && (f.getAttributeType().equals(t.getAttributeType())))
        attrHash.put(f.getId(), t);
    List<Qualifier> fList = fromEngine.getQualifiers();
    List<Qualifier> tList = toEngine.getQualifiers();
    for (Qualifier f : fList) if (!IDEF0Plugin.isFunction(f))
        for (Qualifier t : tList) if (!IDEF0Plugin.isFunction(t))
            if (f.getName().equals(t.getName()))
                qHash.put(f.getId(), t);
    Vector<Row> fRows = fromDataPlugin.getRecChilds(null, false);
    Vector<Row> tRows = toDataPlugin.getRecChilds(null, false);
    for (Row f : fRows) {
        for (Row t : tRows) {
            if (f.getName().equals(t.getName())) {
                rowHash.put(f.getElement().getId(), t);
                Vector<Row> fCRows = fromDataPlugin.getRecChilds(f, true);
                Vector<Row> tCRows = toDataPlugin.getRecChilds(t, true);
                for (Row fc : fCRows) for (Row tc : tCRows) if (fc.getName().equals(tc.getName()))
                    rowHash.put(fc.getElement().getId(), tc);
            }
        }
    }
    if (importAll)
        createAllRows();
    for (Qualifier qualifier : selected) {
        fromDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, fromEngine, fromDataPlugin.getAccessRules());
        List<Attribute> list = getAttributes(qualifier.getAttributes());
        Qualifier baseFunction = toEngine.getQualifier(base.getElement().getQualifierId());
        for (Attribute a : list) if (baseFunction.getAttributes().indexOf(a) < 0)
            baseFunction.getAttributes().add(a);
        toEngine.updateQualifier(baseFunction);
        int r;
        if ((r = fromDataPlugin.getBaseFunction().getChildCount()) > 0)
            for (int i = 0; i < r; i++) {
                function = (Function) fromDataPlugin.getBaseFunction().getChildAt(i);
                Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
                childs.add(0, function);
                for (Row row : childs) {
                    NFunction dest = (NFunction) getRow(row);
                    showMessageAnimation(dest.toString());
                }
                NFunction func = (NFunction) getRow(function);
                createSectorsOnUpperLevel(func);
            }
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 8 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method copyRow.

private void copyRow(Row source, Row destination) {
    if (source.isElement()) {
        Qualifier qualifier = fromEngine.getQualifier(source.getElement().getQualifierId());
        Qualifier to = toEngine.getQualifier(destination.getElement().getQualifierId());
        checkAttributes(qualifier, to);
        copyAttributes(qualifier.getAttributes(), source.getElement(), destination.getElement());
        copyAttributes(qualifier.getSystemAttributes(), source.getElement(), destination.getElement());
        if (source instanceof NFunction)
            copyFunction((NFunction) source, (NFunction) destination);
    } else {
        Qualifier s = StandardAttributesPlugin.getQualifier(fromEngine, source.getElement());
        Qualifier d = StandardAttributesPlugin.getQualifier(toEngine, destination.getElement());
        copyQualifier(s, d);
    }
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier)

Example 9 with NFunction

use of com.ramussoft.pb.data.negine.NFunction 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)

Example 10 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class IDEF0Object method onProcessEndBoundsChange.

public void onProcessEndBoundsChange(List<PaintSector> notToMove) {
    final FRectangle oldRec = function.getBounds();
    super.onProcessEndBoundsChange();
    function.setBounds(new FRectangle(myBounds));
    final SectorRefactor refactor = movingArea.getRefactor();
    MemoryData memoryData = new MemoryData();
    List<PaintSector> list = new ArrayList<PaintSector>();
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        PaintSector sector = refactor.getSector(i);
        boolean con = false;
        if (notToMove != null)
            for (PaintSector ps : notToMove) {
                if (ps.getSector().equals(sector.getSector())) {
                    con = true;
                    break;
                }
            }
        if (con)
            continue;
        setAddedSectorPos(oldRec, sector, list);
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NFunction(com.ramussoft.pb.data.negine.NFunction) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint)

Aggregations

NFunction (com.ramussoft.pb.data.negine.NFunction)24 Function (com.ramussoft.pb.Function)10 Row (com.ramussoft.pb.Row)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 FRectangle (com.dsoft.pb.types.FRectangle)7 Attribute (com.ramussoft.common.Attribute)7 Qualifier (com.ramussoft.common.Qualifier)7 Point (com.ramussoft.pb.idef.elements.Point)7 Crosspoint (com.ramussoft.pb.Crosspoint)6 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)6 NSector (com.ramussoft.pb.data.negine.NSector)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Element (com.ramussoft.common.Element)4 Sector (com.ramussoft.pb.Sector)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Engine (com.ramussoft.common.Engine)3 DataPlugin (com.ramussoft.pb.DataPlugin)3 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)3