Search in sources :

Example 21 with NFunction

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

the class MovingArea method setActiveObject.

public void setActiveObject(final Object activeObject, boolean silent) {
    this.prevActiveObject = this.getActiveObject();
    if (activeObject instanceof MovingText)
        this.activeMovingTextIndex = refactor.getTexts().indexOf(activeObject);
    else
        this.activeMovingTextIndex = -1;
    if (activeObject instanceof MovingFunction) {
        NFunction function = (NFunction) ((MovingFunction) activeObject).getFunction();
        if (!silent) {
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, function.getElement());
            long id = dataPlugin.getBaseFunctionQualifier().getAttributeForName();
            for (Attribute attr : dataPlugin.getBaseFunctionQualifier().getAttributes()) if (attr.getId() == id) {
                panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(function.getElement(), attr));
            }
        }
        Enumeration e = ((MovingFunction) activeObject).getFunction().children();
        while (e.hasMoreElements()) ((Function) e.nextElement()).getSectors();
    }
    final Object o = this.activeObject;
    if ((activeObject == null) && (!silent)) {
        panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, null);
    }
    this.activeObject = activeObject;
    if (o != activeObject)
        panel.getFrame().refreshActions(panel);
    if (activeObject instanceof PaintSector.Pin) {
        final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
        panel.getFrame().getJCheckBoxMenuItemShowTilda().setSelected(pin.getSector().isShowTilda());
        panel.getFrame().getJCheckBoxMenuItemTransparentText().setSelected(pin.getSector().isTransparent());
        if (!silent) {
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, ((NSector) pin.getSector().getSector()).getElement(), pin);
            panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(((NSector) pin.getSector().getSector()).getElement(), IDEF0Plugin.getStreamAttribute(dataPlugin.getEngine())), pin);
        }
    }
    repaintAsync();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) Enumeration(java.util.Enumeration) NFunction(com.ramussoft.pb.data.negine.NFunction) Attribute(com.ramussoft.common.Attribute) NSector(com.ramussoft.pb.data.negine.NSector) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) AttributeEditorView(com.ramussoft.gui.attribute.AttributeEditorView) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) DFDObject(com.ramussoft.pb.dfd.visual.DFDObject)

Example 22 with NFunction

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

the class MovingArea method checkRemoveLevelFunction.

/**
 * Метод перевіряє, чи правильно розташовані сектори, щоб функціональний
 * блок міг бути видалений.
 *
 * @param context Функціональний блок, який має бути видалений.
 * @return <code>true</code>, якщо функціональний блок може бути видалений,
 * <code>false</code>, якщо функціональний блок не може бути
 * видалений.
 */
private boolean checkRemoveLevelFunction(final Function context) {
    final Function f = (Function) context.getParentRow();
    ((NFunction) f).clearSectorsBuffer();
    final Vector<Sector> sectors = f.getSectors();
    for (int i = 0; i < sectors.size(); i++) {
        final Sector sector = sectors.get(i);
        if (context.equals(sector.getStart().getFunction())) {
            if (sector.getEnd().getBorderType() != sector.getStart().getFunctionType())
                return false;
        } else if (context.equals(sector.getEnd().getFunction())) {
            if (sector.getStart().getBorderType() != sector.getEnd().getFunctionType())
                return false;
        } else
            return false;
    }
    return true;
}
Also used : DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Function(com.ramussoft.pb.Function) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Example 23 with NFunction

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

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

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