Search in sources :

Example 1 with DFDSFunction

use of com.ramussoft.pb.dfds.visual.DFDSFunction in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method addIDEF0Object.

private IDEF0Object addIDEF0Object(final Function function) {
    IDEF0Object movingFunction;
    if (function.getType() < Function.TYPE_EXTERNAL_REFERENCE) {
        if (DIAGRAM_TYPE_DFD == activeFunction.getDecompositionType())
            movingFunction = new DFDFunction(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this, silent);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null);
                }
            };
        else if (DIAGRAM_TYPE_DFDS == activeFunction.getDecompositionType())
            movingFunction = new DFDSFunction(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this, silent);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null);
                }
            };
        else
            movingFunction = new MovingFunction(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this, silent);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null, false);
                }
            };
    } else {
        if (function.getType() == Function.TYPE_EXTERNAL_REFERENCE) {
            movingFunction = new External(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null);
                }
            };
        } else if (function.getType() == Function.TYPE_DFDS_ROLE) {
            movingFunction = new DFDSRole(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this, silent);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null, false);
                }
            };
        } else {
            // DATA STORE
            movingFunction = new DataStore(this, function) {

                /**
                 * @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
                 */
                @Override
                public void focusGained(boolean silent) {
                    super.focusGained(silent);
                    setActiveObject(this);
                }

                @Override
                public void focusLost() {
                    super.focusLost();
                    if (getActiveObject() == this)
                        setActiveObject(null);
                }
            };
        }
    }
    movingFunctions.put(function, movingFunction);
    return movingFunction;
}
Also used : DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) DataStore(com.ramussoft.pb.dfd.visual.DataStore) External(com.ramussoft.pb.dfd.visual.External) DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction)

Example 2 with DFDSFunction

use of com.ramussoft.pb.dfds.visual.DFDSFunction in project ramus by Vitaliy-Yakovchuk.

the class MovingArea method setActiveFunction.

/**
 * Задає значення активного на блоку (того який являється базовим для
 * решти).
 *
 * @param activeFunction Значення активної функції.
 */
public void setActiveFunction(final Function activeFunction) {
    synchronized (backgroundPaintlock) {
        bImage = null;
    }
    String size = activeFunction.getPageSize();
    initSize(size);
    if (panel != null) {
        cancelAdding();
        panel.setMovingAreaSize(zoom);
    }
    if (activeFunction.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
        return;
    textPaintCache.clear();
    if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS) {
        DropTarget dropTarget = new DropTarget();
        this.setDropTarget(dropTarget);
        try {
            dropTarget.addDropTargetListener(new DropTargetAdapter() {

                @Override
                public void drop(DropTargetDropEvent event) {
                    if (event.getTransferable().isDataFlavorSupported(RowTreeTable.rowsListFlavor)) {
                        try {
                            event.acceptDrop(event.getSourceActions());
                            Rows rows = (Rows) event.getTransferable().getTransferData(RowTreeTable.rowsListFlavor);
                            FloatPoint point = toPoint(event.getLocation().x, event.getLocation().y);
                            Function owner = null;
                            for (MovingPanel panel : panels) if (panel instanceof DFDSFunction && panel.contain(point)) {
                                owner = ((DFDSFunction) panel).getFunction();
                            }
                            startUserTransaction();
                            Function function = createFunctionalObject(getDoubleOrdinate(event.getLocation().getX()), getDoubleOrdinate(event.getLocation().getY()), Function.TYPE_DFDS_ROLE, activeFunction);
                            RectangleVisualOptions ops = IDEF0Plugin.getDefaultRectangleVisualOptions(dataPlugin.getEngine(), rows.get(0).getElement());
                            if (ops != null) {
                                FRectangle rect = function.getBounds();
                                rect.setHeight(ops.bounds.getHeight());
                                rect.setWidth(ops.bounds.getWidth());
                                function.setBounds(rect);
                                function.setFont(ops.font);
                                function.setBackground(ops.background);
                                function.setForeground(ops.foreground);
                            }
                            Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                            Row[] rows2 = new Row[rows.size()];
                            for (int i = 0; i < rows2.length; i++) rows2[i] = dataPlugin.findRowByGlobalId(rows.get(i).getElementId());
                            stream.setRows(rows2);
                            function.setLink(stream.getElement().getId());
                            if (owner != null) {
                                function.setOwner(owner);
                                DFDSFunction function2 = findDFDSFunction(owner);
                                List<Function> roles = getRoles(function2);
                                if (!roles.contains(function))
                                    roles.add(function);
                                if (function2 != null)
                                    function2.justifyRoles(roles);
                            }
                            commitUserTransaction();
                            panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
                        } catch (UnsupportedFlavorException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } else
                        event.rejectDrop();
                }
            });
        } catch (TooManyListenersException e) {
            e.printStackTrace();
        }
    } else
        this.setDropTarget(null);
    if (rec)
        return;
    rec = true;
    if (panel != null) {
        boolean locked;
        if (activeFunction.equals(lockedFunction))
            locked = true;
        else
            locked = activeFunction.lock();
        refactor.loadFromFunction(activeFunction, false);
        if (!activeFunction.equals(lockedFunction)) {
            if (lockedFunction != null)
                lockedFunction.unlock();
            if (locked)
                lockedFunction = activeFunction;
            else
                lockedFunction = null;
        }
        panel.setMovingActiveFunction(activeFunction);
        if (getState() == END_POINT_ADDING)
            setState(START_POINT_ADDING);
        if ((getState() == END_POINT_CHANGING) || (getState() == START_POINT_CHANGING) || (getState() == FUNCTION_ADDING_STATE) || (getState() == TEXT_ADDING_STATE))
            cancelAdding();
    } else
        refactor.loadFromFunction(activeFunction, false);
    boolean updateListeneres = this.activeFunction != activeFunction;
    this.activeFunction = activeFunction;
    if (panel != null) {
        panel.getFrame().propertyChange(MChangeListener.REFRESH_FUNCTION_IN_TREE, activeFunction);
    }
    setPanels();
    if (panel != null) {
        setActiveObject(null);
        final java.awt.Point mp = getMousePosition();
        if (mp != null)
            moveMoveListener.mouseMoved(new MouseEvent(this, 0, 0, 0, mp.x, mp.y, 0, false));
    }
    functionIndex = dataPlugin.indexOfFunction(activeFunction);
    if (functionIndex < 0)
        functionIndex = 0;
    rec = false;
    if (updateListeneres) {
        ActiveFunctionEvent event = new ActiveFunctionEvent(activeFunction);
        for (ActiveFunctionListener l : getActiveFunctionListeners()) l.activeFunctionChanged(event);
    }
    if (panel != null) {
        panel.getFrame().refreshActions(panel);
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActiveFunctionListener(com.ramussoft.pb.idef.visual.event.ActiveFunctionListener) IOException(java.io.IOException) ActiveFunctionEvent(com.ramussoft.pb.idef.visual.event.ActiveFunctionEvent) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) DropTargetAdapter(java.awt.dnd.DropTargetAdapter) 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) TooManyListenersException(java.util.TooManyListenersException) FloatPoint(com.dsoft.pb.types.FloatPoint) FRectangle(com.dsoft.pb.types.FRectangle) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent) DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Rows(com.ramussoft.gui.qualifier.table.Rows)

Aggregations

DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)2 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)2 FRectangle (com.dsoft.pb.types.FRectangle)1 FloatPoint (com.dsoft.pb.types.FloatPoint)1 Rows (com.ramussoft.gui.qualifier.table.Rows)1 RectangleVisualOptions (com.ramussoft.idef0.attribute.RectangleVisualOptions)1 Function (com.ramussoft.pb.Function)1 Stream (com.ramussoft.pb.Stream)1 NFunction (com.ramussoft.pb.data.negine.NFunction)1 DataStore (com.ramussoft.pb.dfd.visual.DataStore)1 External (com.ramussoft.pb.dfd.visual.External)1 DFDSRole (com.ramussoft.pb.dfds.visual.DFDSRole)1 ActiveFunctionEvent (com.ramussoft.pb.idef.visual.event.ActiveFunctionEvent)1 ActiveFunctionListener (com.ramussoft.pb.idef.visual.event.ActiveFunctionListener)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 DropTarget (java.awt.dnd.DropTarget)1 DropTargetAdapter (java.awt.dnd.DropTargetAdapter)1 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1