Package org.enhydra.shark.xpdl

Examples of org.enhydra.shark.xpdl.XMLElement


    @Override
    public int remove(XMLElement el) {
        // remove editable variable for all existing activities when a variable is removed
        DataField df = (DataField)el;
        XMLElement parent = getParent();
        if (parent instanceof WorkflowProcess) {
            parent.setNotifyListeners(false);
            parent.setNotifyMainListeners(false);
            WorkflowProcess wp = (WorkflowProcess)parent;
            Activities acts = wp.getActivities();
            for (int i=0; i<acts.size(); i++) {
                Activity act = (Activity)acts.get(i);
                if (act.getActivityType() == XPDLConstants.ACTIVITY_TYPE_NO) {
                    ExtendedAttributes attributes = act.getExtendedAttributes();
                    int position = -1;
                    for (int j=0; j<attributes.size(); j++) {
                        ExtendedAttribute attribute = (ExtendedAttribute)attributes.get(j);
                        String attrName = attribute.getName();
                        if (("VariableToProcess_UPDATE".equals(attrName) || ("VariableToProcess_VIEW".equals(attrName))) && df.getId().equals(attribute.getVValue())) {
                            position = j;
                            break;
                        }
                    }
                    if (position >= 0) {
                        attributes.remove(position);
                    }
                }
            }
            parent.setNotifyListeners(true);
            parent.setNotifyMainListeners(true);
        }
        int result = super.remove(el);
        return result;
    }
View Full Code Here


     * This method is called by EditAction class, as well as by
     * pressing F2 or clicking a mouse on a cell.
     */
    protected boolean startEditing(Object cell, MouseEvent event) {
        if (cell instanceof WorkflowElement) {
            XMLElement el = ((WorkflowElement) cell).getPropertyObject();
            if (el instanceof Activity) {
                Activity act = (Activity) el;
                if (act.getActivityType() == XPDLConstants.ACTIVITY_TYPE_SUBFLOW) {
                    //CUSTOM
                    JaWEManager.getInstance().getJaWEController().getJaWEActions().getAction(JaWEActions.EDIT_PROPERTIES_ACTION).actionPerformed(null);
View Full Code Here

            throw new RuntimeException("Can't perform makeAs!");
        }

        DataTypes other = (DataTypes) el;

        XMLElement oldChoosen = choosen;
        XMLElement newChoosen = null;
        boolean notify = false;
        if (choices == null && other.choices != null) {
            isInitialized = true;
            fillChoices();
        } else if (choices != null && other.choices == null) {
            oldChoosen = choosen;
            clear();
            notify = true;
            Thread.dumpStack();
        }

        if (choices != null && other.choices != null) {
            XMLElement othchsn = other.getChoosen();
            int chind = other.choices.indexOf(othchsn);
            newChoosen = (XMLElement) this.choices.get(chind);

            if (!othchsn.equals(oldChoosen)) {
                newChoosen.makeAs(othchsn);
                choosen = newChoosen;
                if (oldChoosen != choosen) {
                    notify = true;
                }
View Full Code Here

        }
        if (!(arg instanceof XPDLElementChangeInfo)) {
            return;
        }
        XPDLElementChangeInfo info = (XPDLElementChangeInfo) arg;
        XMLElement changedElement = info.getChangedElement();
        int action = info.getAction();
        if (info.getSource() == this || (changedElement == null && action != XPDLElementChangeInfo.SELECTED)) {
            return;
        }
        if (!(action == XMLElementChangeInfo.UPDATED ||
                action == XMLElementChangeInfo.INSERTED ||
                action == XMLElementChangeInfo.REMOVED ||
                action == XMLElementChangeInfo.REPOSITIONED ||
                action == XPDLElementChangeInfo.SELECTED ||
                action == XPDLElementChangeInfo.ADJUST_UNDOABLE_ACTION ||
                action == XPDLElementChangeInfo.UNDO ||
                action == XPDLElementChangeInfo.REDO ||
                action == XPDLElementChangeInfo.COPY ||
                action == XPDLElementChangeInfo.CUT)) {
            return;
        }

        long start = System.currentTimeMillis();
        JaWEManager.getInstance().getLoggingManager().info(
                "GraphController -> update for event " + info + " started ...");

        updateInProgress = true;
        try {
            if (action == XPDLElementChangeInfo.COPY || action == XPDLElementChangeInfo.CUT) {
                copyOrCutInfo = null;
                if (selectedGraph != null) {
                    GraphManager gm = selectedGraph.getGraphManager();

                    Map actRectangles = new HashMap();
                    Iterator it = info.getChangedSubElements().iterator();
                    while (it.hasNext()) {
                        XMLElement toCopyOrCut = (XMLElement) it.next();
                        if (!(toCopyOrCut instanceof Activity)) {
                            continue;
                        }
                        Activity a = (Activity) toCopyOrCut;
                        GraphActivityInterface ga = gm.getGraphActivity(a);
View Full Code Here

        List selectedElements = new ArrayList();
        if (selectedCells != null) {
            for (int i = 0; i < selectedCells.length; i++) {
                if (selectedCells[i] instanceof WorkflowElement) {
                    WorkflowElement we = (WorkflowElement) selectedCells[i];
                    XMLElement el = we.getPropertyObject();
                    if (el != null) {
                        if (el instanceof Participant) {
                            par = (Participant) el;
                        }
                        selectedElements.add(el);
View Full Code Here

    public GraphSettings getGraphSettings() {
        return settings;
    }

    public void update(XPDLElementChangeInfo info) {
        XMLElement changedElement = info.getChangedElement();
        List changedElements = info.getChangedSubElements();
        int action = info.getAction();

        // ********************************* START OF SELECTION EVENT
        if (action == XPDLElementChangeInfo.SELECTED) {
            // clean old selection
            if (selectedGraph != null) {
                if (overview != null) {
                    if (overview.getGraph() != null) {
                        overview.getGraph().clearSelection();
                    }
                }

                selectedGraph.clearSelection();
            }

            if (changedElement != null) {
                // ***************************** find graph
                Graph g = null;
                XMLElement lastSel = changedElement;
                if (changedElements.size() > 0) {
                    lastSel = (XMLElement) changedElements.get(changedElements.size() - 1);
                }

                if (graphMap.containsKey(lastSel)) {
                    g = getGraph((XMLCollectionElement) lastSel);
                }

                if (g == null && selectedGraph != null) {
                    if (lastSel instanceof Participant && selectedGraph.getGraphManager().getGraphParticipant((Participant) lastSel) != null) {
                        g = selectedGraph;
                    } else if (lastSel instanceof ExtendedAttribute && selectedGraph.getGraphManager().getBubble((ExtendedAttribute) lastSel) != null) {
                        g = selectedGraph;
                    } else if (lastSel instanceof Activity && selectedGraph.getGraphManager().getGraphActivity((Activity) lastSel) != null) {
                        g = selectedGraph;
                        GraphUtilities.reloadGraph(g);
                    } else if (lastSel instanceof Transition && selectedGraph.getGraphManager().getGraphTransition((Transition) lastSel) != null) {
                        g = selectedGraph;
                    }
                }

                if (g == null) {
                    XMLElement parent = lastSel;
                    do {
                        parent = parent.getParent();
                    } while (parent != null && !(parent instanceof ActivitySet || parent instanceof WorkflowProcess));
                    if (parent != null) {
                        g = getGraph((XMLCollectionElement) parent);
                    } else {
                        if (selectedGraph != null) {
                            if (XMLUtil.getPackage(lastSel) == XMLUtil.getPackage(selectedGraph.getXPDLObject())) {
                                g = selectedGraph;
                            }
                        }
                    }
                }

                if (g == null) {
                    Package sp = XMLUtil.getPackage(lastSel);
                    if (sp != null) {
                        List wps = sp.getWorkflowProcesses().toElements();
                        if (wps.size() != 0) {
                            g = getGraph((XMLCollectionElement) wps.get(0));
                        }
                    }
                }

                if (g != selectedGraph) {
                    setSelectedGraph(g);
                }

                if (selectedGraph != null) {
                    selectedGraph.clearSelection();
                }
                // ***************************** end of find graph

                // **************************** select elements
                WorkflowElement selectedElement = null;
                WorkflowElement lastSelected = null;
                if (selectedGraph != null) {
                    List selectedElements = new ArrayList();
                    List overviewElements = new ArrayList();
                    List toCheck = new ArrayList();
                    if (changedElements == null || changedElements.size() == 0) {
                        toCheck.add(changedElement);
                    } else {
                        toCheck.addAll(changedElements);
                    }
                    for (Iterator it = toCheck.iterator(); it.hasNext();) {
                        XMLElement el = (XMLElement) it.next();

                        selectedElement = selectedGraph.getGraphInterface(el);
                        if (overview != null && selectedElement != null && !(selectedElement instanceof GraphTransitionInterface)) {
                            overviewElements.add(selectedElement);
                        }
View Full Code Here

    public void add(XMLElement el) {
        super.add(el);
        // add editable variable for all existing activities when a variable is added
        XPDLObjectFactory xpdlObjectFactory = JaWEManager.getInstance().getXPDLObjectFactory();
        FormalParameter fp = (FormalParameter)el;
        XMLElement parent = getParent();
        if (parent instanceof WorkflowProcess) {
            parent.setNotifyListeners(false);
            parent.setNotifyMainListeners(false);
            WorkflowProcess wp = (WorkflowProcess)parent;
            Activities acts = wp.getActivities();
            for (int i=0; i<acts.size(); i++) {
                Activity act = (Activity)acts.get(i);
                if (act.getActivityType() == XPDLConstants.ACTIVITY_TYPE_NO) {
                    ExtendedAttribute attribute = xpdlObjectFactory.createXPDLObject(act.getExtendedAttributes(), null, true);
                    attribute.setName("VariableToProcess_UPDATE");
                    attribute.setVValue(fp.getId());
                }
            }
            parent.setNotifyListeners(true);
            parent.setNotifyMainListeners(true);
        }
    }
View Full Code Here

    @Override
    public int remove(XMLElement el) {
        if (el instanceof DataField) {
            // remove editable variable for all existing activities when a variable is removed
            DataField df = (DataField)el;
            XMLElement parent = getParent();
            if (parent instanceof WorkflowProcess) {
                parent.setNotifyListeners(false);
                parent.setNotifyMainListeners(false);
                WorkflowProcess wp = (WorkflowProcess)parent;
                Activities acts = wp.getActivities();
                for (int i=0; i<acts.size(); i++) {
                    Activity act = (Activity)acts.get(i);
                    if (act.getActivityType() == XPDLConstants.ACTIVITY_TYPE_NO) {
                        ExtendedAttributes attributes = act.getExtendedAttributes();
                        int position = -1;
                        for (int j=0; j<attributes.size(); j++) {
                            ExtendedAttribute attribute = (ExtendedAttribute)attributes.get(j);
                            String attrName = attribute.getName();
                            if (("VariableToProcess_UPDATE".equals(attrName) || ("VariableToProcess_VIEW".equals(attrName))) && df.getId().equals(attribute.getVValue())) {
                                position = j;
                                break;
                            }
                        }
                        if (position >= 0) {
                            attributes.remove(position);
                        }
                    }
                }
                parent.setNotifyListeners(true);
                parent.setNotifyMainListeners(true);
            }
        }
        int result = super.remove(el);
        return result;
    }
View Full Code Here

        return new Point(xClick, yClick);
    }

    public void handleXPDLChangeEvent(XPDLElementChangeInfo info) {
        int action = info.getAction();
        XMLElement el = info.getChangedElement();
        List l = info.getChangedSubElements();

        tree.removeTreeSelectionListener(controller);

        if (action == XPDLElementChangeInfo.SELECTED) {
            tree.clearSelection();
        }

        if (el instanceof Activity || el instanceof Package || el instanceof WorkflowProcesses || el instanceof WorkflowProcess || el instanceof ActivitySets || el instanceof ActivitySet || el instanceof Activities || (el instanceof Transitions && action == XPDLElementChangeInfo.SELECTED)) {
            if (action == XMLElementChangeInfo.INSERTED) {
                if (l != null && l.size() > 0) {
                    Iterator it1 = l.iterator();
                    while (it1.hasNext()) {
                        treeModel.insertNode((XMLElement) it1.next());
                    }
                } else {
                    if (el instanceof Package) {
                        treeModel.insertNode(el);
                    }
                }
                if (el instanceof Package) {
                    controller.getSettings().adjustActions();
                }
            } else if (action == XMLElementChangeInfo.REMOVED) {
                if (l != null && l.size() > 0) {
                    Iterator it1 = l.iterator();
                    while (it1.hasNext()) {
                        treeModel.removeNode((XMLElement) it1.next());
                    }
                } else {
                    treeModel.removeNode(el);
                }
                if (treeModel.getRootNode().getChildCount() == 0) {
                    reinitialize();
                    return;
                }
            } else if (action == XPDLElementChangeInfo.SELECTED) {
                if (el != null) {
                    List toSelect = new ArrayList();
                    if (l != null) {
                        toSelect.addAll(l);
                    }
                    if (toSelect.size() == 0) {
                        toSelect.add(el);
                    }
                    for (int i = 0; i < toSelect.size(); i++) {
                        XMLElement toSel = (XMLElement) toSelect.get(i);
                        if (toSelect instanceof Transitions || toSelect instanceof Transition) {
                            continue;
                        }
                        XPDLTreeNode n = treeModel.findNode(toSel);
                        TreePath tp = null;
                        if (n != null) {
                            tp = new TreePath(n.getPath());
                            tree.addSelectionPath(tp);
                        }
                        if (tp != null) {
                            tree.scrollPathToVisible(tp);
                        }
                    }
                }
            } else if (action == XMLElementChangeInfo.REPOSITIONED) {
                List elsToReposition = new ArrayList();
                List newPositions = new ArrayList();
                if (el instanceof XMLCollection) {
                    if (l != null) {
                        elsToReposition.addAll(l);
                        newPositions.addAll((List) info.getNewValue());
                    }
                    for (int j = 0; j < elsToReposition.size(); j++) {
                        XMLElement eltr = (XMLElement) elsToReposition.get(j);
                        treeModel.repositionNode(eltr, ((Integer) newPositions.get(j)).intValue());
                    }
                }
            }
        }
View Full Code Here

    // before doing this, listener has to be removed
    public void setCurrentSelection() {
        List toSelect = JaWEManager.getInstance().getJaWEController().getSelectionManager().getSelectedElements();
        for (int i = 0; i < toSelect.size(); i++) {
            XMLElement toSel = (XMLElement) toSelect.get(i);
            if (toSel instanceof Package || toSel instanceof WorkflowProcess || toSel instanceof ActivitySet || toSel instanceof Activity) {
                XPDLTreeNode n = treeModel.findNode(toSel);
                TreePath tp = null;
                if (n != null) {
                    tp = new TreePath(n.getPath());
View Full Code Here

TOP

Related Classes of org.enhydra.shark.xpdl.XMLElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.