Search in sources :

Example 1 with DataPlugin

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

the class External method paint.

@Override
public void paint(Graphics2D g) {
    DataPlugin dp = ((NFunction) function).getDataPlugin();
    Row row = dp.findRowByGlobalId(function.getLink());
    final class PolygonD extends Polygon {

        /**
         */
        private static final long serialVersionUID = 113232131232134523L;

        public void addPoint(final double x, final double y) {
            super.addPoint((int) x, (int) y);
        }
    }
    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    g.fill(rect);
    g.setFont(function.getFont());
    paintText(g);
    if (row != null) {
        String string = row.getKod();
        movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 3, myBounds.getY() + 3, myBounds.getWidth() - 3, myBounds.getHeight() - 3), Line.LEFT_ALIGN, 0, true);
    }
    paintBorder(g);
    final Stroke tmp = g.getStroke();
    g.draw(rect);
    double zm = movingArea.getIDoubleOrdinate(2);
    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + zm, rect.getY() + rect.getHeight()));
    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect.getX() + rect.getWidth(), rect.getY() + zm));
    if (paintTriangle >= 0) {
        final PolygonD p = new PolygonD();
        p.addPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
        int standoff2 = -1;
        switch(paintTriangle) {
            case Point.TOP:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                }
                break;
            case Point.LEFT:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
            case Point.RIGHT:
                {
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
            case Point.BOTTOM:
                {
                    p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                    p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                }
                break;
        }
        if (p.npoints > 1)
            g.fillPolygon(p);
    }
    g.setStroke(tmp);
}
Also used : Stroke(java.awt.Stroke) NFunction(com.ramussoft.pb.data.negine.NFunction) Rectangle2D(java.awt.geom.Rectangle2D) Line2D(java.awt.geom.Line2D) Point(com.ramussoft.pb.idef.elements.Point) FRectangle(com.dsoft.pb.types.FRectangle) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Polygon(java.awt.Polygon)

Example 2 with DataPlugin

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

the class AbstractDataPlugin method loadFromParalel.

public void loadFromParalel(final DataPlugin dataPlugin, final Function base, final File file, final GUIFramework framework) throws IOException {
    Thread t = new Thread("Paralel-DataLoader") {

        @Override
        public void run() {
            try {
                framework.showAnimation(ResourceLoader.getString("Wait.Message"));
                MemoryDatabase md = new MemoryDatabase() {

                    protected String getJournalDirectoryName(String tmp) {
                        return null;
                    }

                    @Override
                    protected File getFile() {
                        return file;
                    }
                };
                LoadFromParalelDialog dialog = new LoadFromParalelDialog(framework.getMainFrame(), md.getEngine("idef0"));
                if (dialog.showModal()) {
                    ((Journaled) getEngine()).startUserTransaction();
                    try {
                        framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, false);
                        framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, true);
                        DataPlugin fdp = NDataPluginFactory.getDataPlugin(null, md.getEngine("idef0"), md.getAccessRules("idef0"));
                        ModelParaleler paraleler = new ModelParaleler(fdp, dataPlugin, framework);
                        paraleler.loadFromParalel(base, dialog.isImportAll(), dialog.getSelected());
                    } finally {
                        framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, false);
                        ((Journaled) getEngine()).commitUserTransaction();
                        framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, true);
                        framework.propertyChanged(ModelsView.REFRESH_ALL_MODELS);
                    }
                }
                FileIEngineImpl impl = (FileIEngineImpl) md.getEngine("idef0").getDeligate();
                impl.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                framework.hideAnimation();
            }
        }
    };
    t.start();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ModelParaleler(com.ramussoft.idef0.ModelParaleler) LoadFromParalelDialog(com.ramussoft.pb.idef.frames.LoadFromParalelDialog) MemoryDatabase(com.ramussoft.database.MemoryDatabase) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) IOException(java.io.IOException)

Example 3 with DataPlugin

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

the class DataStore method paint.

@Override
public void paint(Graphics2D g) {
    final Stroke tmp = g.getStroke();
    try {
        DataPlugin dp = ((NFunction) function).getDataPlugin();
        Row row = dp.findRowByGlobalId(function.getLink());
        final class PolygonD extends Polygon {

            /**
             */
            private static final long serialVersionUID = 1L;

            public void addPoint(final double x, final double y) {
                super.addPoint((int) x, (int) y);
            }
        }
        ;
        g.setColor(function.getBackground());
        final Rectangle2D rect = movingArea.getBounds(getBounds());
        Rectangle2D r2d = null;
        if (row != null) {
            String string = row.getKod();
            r2d = function.getFont().getStringBounds(string, g.getFontRenderContext());
            left = movingArea.getIDoubleOrdinate(r2d.getWidth()) + 1;
        } else {
            left = EMPTY_LEFT;
        }
        g.fill(rect);
        g.setFont(function.getFont());
        paintText(g);
        if (row != null) {
            String string = row.getKod();
            movingArea.paintText(g, string, new FRectangle(myBounds.getX() + 0.5, myBounds.getY(), left - 0.5, myBounds.getHeight()), Line.LEFT_ALIGN, 1, true);
        }
        g.draw(new Line2D.Double(rect.getX() + left, rect.getMaxY(), rect.getX() + left, rect.getY()));
        paintBorder(g);
        g.draw(new Line2D.Double(rect.getX(), rect.getY(), rect.getMaxX(), rect.getY()));
        g.draw(new Line2D.Double(rect.getX(), rect.getMaxY(), rect.getX(), rect.getY()));
        g.draw(new Line2D.Double(rect.getMaxX(), rect.getMaxY(), rect.getX(), rect.getMaxY()));
        g.setStroke(new BasicStroke(2));
        /*
             * g.draw(new Line2D.Double(rect.getX() + rect.getWidth() - 1,
			 * rect.getY() + 1, rect.getX() + rect.getWidth() - 1, rect.getY() +
			 * rect.getHeight() - 1)); g.draw(new Line2D.Double(rect.getX() + 1,
			 * rect.getY() + rect.getHeight() - 1, rect.getX() + rect.getWidth()
			 * - 1, rect .getY() + rect.getHeight() - 1));
			 */
        final String string = getIDEF0Kod();
        g.setFont(function.getFont());
        double h = MovingArea.getWidth(0) + MovingArea.getWidth((int) function.getFont().getStringBounds(string, g.getFontRenderContext()).getHeight());
        h = h * 0.7;
        if (paintTriangle >= 0) {
            final PolygonD p = new PolygonD();
            p.addPoint(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
            int standoff2 = -1;
            switch(paintTriangle) {
                case Point.TOP:
                    {
                        p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                        p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                    }
                    break;
                case Point.LEFT:
                    {
                        p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                        p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                    }
                    break;
                case Point.RIGHT:
                    {
                        p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + standoff2);
                        p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                    }
                    break;
                case Point.BOTTOM:
                    {
                        p.addPoint(rect.getX() + standoff2, rect.getY() + rect.getHeight() - standoff2);
                        p.addPoint(rect.getX() + rect.getWidth() - standoff2, rect.getY() + rect.getHeight() - standoff2);
                    }
                    break;
            }
            if (p.npoints > 1)
                g.fillPolygon(p);
        }
    } catch (NullPointerException e) {
    }
    g.setStroke(tmp);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NFunction(com.ramussoft.pb.data.negine.NFunction) Rectangle2D(java.awt.geom.Rectangle2D) Line2D(java.awt.geom.Line2D) Point(com.ramussoft.pb.idef.elements.Point) FRectangle(com.dsoft.pb.types.FRectangle) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Polygon(java.awt.Polygon)

Example 4 with DataPlugin

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

the class HTTPParser method printArrowFunctionss.

private void printArrowFunctionss(final Row row) throws IOException {
    final Vector funcs = new Vector<Row>();
    List<Qualifier> list = dataPlugin.getEngine().getQualifiers();
    for (Qualifier q : list) {
        if (IDEF0Plugin.isFunction(q)) {
            DataPlugin dp = NDataPluginFactory.getDataPlugin(q, dataPlugin.getEngine(), dataPlugin.getAccessRules());
            funcs.addAll(dp.getRecChilds(dp.getBaseFunction(), true));
        }
    }
    final Vector<UF> res = new Vector<UF>();
    for (int i = 0; i < funcs.size(); i++) {
        addFunction(row, (Function) funcs.get(i), res);
    }
    if (res.size() > 0) {
        htmlStream.println("<p><table width=100% border=1>");
        printMainTableTitle(RES.getString("UseInFunctions"), 3);
        htmlStream.print("<tr>");
        htmlStream.print("<td><b>");
        htmlStream.print(RES.getString("kod"));
        htmlStream.print("</b></td>");
        htmlStream.print("<td width=100%><b>");
        htmlStream.print(RES.getString("FunctionName"));
        htmlStream.print("</b></td>");
        htmlStream.print("<td><b>");
        htmlStream.print(RES.getString("Type"));
        htmlStream.print("</b></td>");
        htmlStream.println("</tr>");
        for (int i = 0; i < res.size(); i++) {
            final UF uf = res.get(i);
            htmlStream.println("<tr>");
            htmlStream.print("<td>");
            printStartATeg("rows/index.html?id=" + uf.function.getGlobalId().toString());
            htmlStream.print(MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) uf.function));
            htmlStream.print("</td>");
            htmlStream.print("<td width=100%>");
            printStartATeg("rows/index.html?id=" + uf.function.getGlobalId().toString());
            htmlStream.print(uf.function.getName());
            htmlStream.print("</td>");
            htmlStream.print("<td>");
            switch(uf.type) {
                case MovingPanel.RIGHT:
                    htmlStream.print(RES.getString("RightElements"));
                    break;
                case MovingPanel.LEFT:
                    htmlStream.print(RES.getString("LeftElements"));
                    break;
                case MovingPanel.TOP:
                    htmlStream.print(RES.getString("TopElements"));
                    break;
                case MovingPanel.BOTTOM:
                    htmlStream.print(RES.getString("BottomElements"));
                    break;
            }
            htmlStream.print("</td>");
            htmlStream.println("</tr>");
        }
        htmlStream.println("</table></p>");
    }
}
Also used : Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) DataPlugin(com.ramussoft.pb.DataPlugin) AbstractDataPlugin(com.ramussoft.pb.data.AbstractDataPlugin) Vector(java.util.Vector)

Example 5 with DataPlugin

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

the class FunctionOwnerAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private SelectOwner component = new SelectOwner();

        @Override
        public Object setValue(Object value) {
            DataPlugin plugin = NDataPluginFactory.getDataPlugin(engine.getQualifier(element.getQualifierId()), engine, rules);
            component.setFunction((Function) plugin.findRowByGlobalId(element.getId()));
            return value;
        }

        @Override
        public Object getValue() {
            Row row = component.getOwner();
            if (row != null)
                return row.getElement().getId();
            return null;
        }

        @Override
        public JComponent getComponent() {
            return component;
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) SelectOwner(com.ramussoft.pb.idef.frames.SelectOwner) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin)

Aggregations

DataPlugin (com.ramussoft.pb.DataPlugin)17 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)9 Qualifier (com.ramussoft.common.Qualifier)8 Row (com.ramussoft.pb.Row)7 Journaled (com.ramussoft.common.journal.Journaled)5 IOException (java.io.IOException)5 Attribute (com.ramussoft.common.Attribute)4 NFunction (com.ramussoft.pb.data.negine.NFunction)4 ProjectOptions (com.dsoft.pb.idef.elements.ProjectOptions)3 Element (com.ramussoft.common.Element)3 Engine (com.ramussoft.common.Engine)3 Function (com.ramussoft.pb.Function)3 FRectangle (com.dsoft.pb.types.FRectangle)2 AttributeType (com.ramussoft.common.AttributeType)2 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)2 MemoryDatabase (com.ramussoft.database.MemoryDatabase)2 Row (com.ramussoft.database.common.Row)2 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)2 ModelParaleler (com.ramussoft.idef0.ModelParaleler)2 NRow (com.ramussoft.pb.data.negine.NRow)2