Package org.woped.core.model

Examples of org.woped.core.model.ModelElementContainer


        false));

    setName("Subprocess " + model.getNameValue());

    // Switch editor to use the model element container of the subprocess
    ModelElementContainer container = model.getSimpleTransContainer();

    getModelProcessor().setElementContainer(container);
    model.getCreationMap().setSubElementContainer(container);

    // Get list of input nodes, presume that there is exactly one source and one sink,
    // which is a valid assumption for sub processes and should have been verified before
    // this constructor is called
    Set<AbstractPetriNetElementModel> sources = NetAlgorithms
        .getDirectlyConnectedNodes(model,
            NetAlgorithms.connectionTypeINBOUND);
    Iterator<AbstractPetriNetElementModel> sourceKeyIterator = sources.iterator();
    AbstractPetriNetElementModel sourceModel = sourceKeyIterator.next();
    setSubprocessInput(sourceModel);

    // Check whether the source element already exists
    if (container.getElementById(sourceModel.getId()) == null) {
      CreationMap sourceCreationMap = sourceModel.getCreationMap();
      if (((EditorVC) parentEditor).isCopyFlag() == false) {     
      container.getArcMap().clear();
      container.getIdMap().clear();
      }
      sourceCreationMap.setPosition(10, 160);
      sourceCreationMap.setReadOnly(true);
      sourceCreationMap.setNamePosition(30, 200);
      sourceCreationMap.setEditOnCreation(false);
      sourceCreationMap.setUpperElement(sourceModel);
      createElement(sourceCreationMap, true, true);
    } else {
      container.getElementById(sourceModel.getId()).setNameValue(
          getSubprocessInput().getNameValue());
      container.getElementById(sourceModel.getId()).setReadOnly(true);
    }

    // Get list of output nodes
    Set<AbstractPetriNetElementModel> targets = NetAlgorithms
        .getDirectlyConnectedNodes(model,
            NetAlgorithms.connectionTypeOUTBOUND);
    Iterator<AbstractPetriNetElementModel> targetKeyIterator = targets.iterator();
    AbstractPetriNetElementModel targetModel = targetKeyIterator.next();
    setSubprocessOutput(targetModel);
    // Check whether the target element already exists
    if (container.getElementById(targetModel.getId()) == null) {
      CreationMap targetCreationMap = targetModel.getCreationMap();
      targetCreationMap.setPosition(520, 160);
      targetCreationMap.setReadOnly(true);
      targetCreationMap.setNamePosition(540, 200);
      targetCreationMap.setEditOnCreation(false);
      targetCreationMap.setUpperElement(targetModel);
      createElement(targetCreationMap, true, true);

    } else {
      container.getElementById(targetModel.getId()).setNameValue(
          getSubprocessOutput().getNameValue());
      container.getElementById(targetModel.getId()).setReadOnly(true);
    }

    // We must create a JGraph model
    // representation of the new model element container
    // Disable undo while doing so just as we do for loading a PNML file
    if (getGraph().getUndoManager() != null) {
      ((WoPeDUndoManager) getGraph().getUndoManager()).setEnabled(false);
    }
    getGraph().drawNet(getModelProcessor());
    if (getGraph().getUndoManager() != null) {
      ((WoPeDUndoManager) getGraph().getUndoManager()).setEnabled(true);
    }
    updateNet();
    // Clear selection, we do not want newly created elements to be selected
    getGraph().clearSelection();

    // Keep the tree model of the parent editor up to date
    if ((parentEditor != null) && (getEditorPanel().GetTreeModel() != null)
        && (parentEditor instanceof EditorVC)) {
      getEditorPanel().GetTreeModel().addTreeModelListener(((EditorVC) parentEditor)
          .getEditorPanel().GetTreeModel());
    }

    // Try to retrieve saved layout information from the Model Element
    // container
    // and set it for this editor window
    EditorLayoutInfo layoutInfo = container.getEditorLayoutInfo();
    if (layoutInfo != null) {
      getEditorPanel().setSavedLayoutInfo(layoutInfo);
    }
    // Copy resources from parentEditor to subprocessEditor
    Vector<ResourceModel> res = ((PetriNetModelProcessor) (parentEditor
        .getModelProcessor())).getResources();
    ((PetriNetModelProcessor) (getModelProcessor())).setResources(res);

    HashMap<String, Vector<String>> mapping = ((PetriNetModelProcessor) (parentEditor
        .getModelProcessor())).getResourceMapping();
    ((PetriNetModelProcessor) (getModelProcessor()))
        .setResourceMapping(mapping);

    Vector<ResourceClassModel> units = ((PetriNetModelProcessor) (parentEditor
        .getModelProcessor())).getOrganizationUnits();
    ((PetriNetModelProcessor) (getModelProcessor()))
        .setOrganizationUnits(units);

    Vector<ResourceClassModel> roles = ((PetriNetModelProcessor) (parentEditor
        .getModelProcessor())).getRoles();
    ((PetriNetModelProcessor) (getModelProcessor())).setRoles(roles);

    Map<String, AbstractPetriNetElementModel> transitions;
    TransitionModel trans;
    if (!(transitions = container.getElementsByType(2)).isEmpty()) {
      Iterator<AbstractPetriNetElementModel> iterTrans = transitions.values().iterator();
      while (iterTrans.hasNext()) {
        trans = (TransitionModel) iterTrans.next();
        if (trans.isIncommingTarget())
          createArc(this.m_subprocessInput.getId(), trans.getId());
View Full Code Here


          AbstractPetriNetElementModel trans = iterTransition.next();
          AbstractPetriNetElementModel opTrans = null;
          tm = (TransitionModel) trans;
            successors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeOUTBOUND);
            predecessors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeINBOUND);
            ModelElementContainer mec;
            AbstractPetriNetElementModel elem = null;
            Iterator<ModelElementContainer> ownerIterator = trans.getOwningContainersIterator();
            while (ownerIterator.hasNext()) {
              mec = ownerIterator.next();
              elem = mec.getOwningElement();
              if (elem != null && elem.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
                opTrans = (TransitionModel)elem;
                break;
              }
            }
View Full Code Here

    /*
     * net info
     */
   
    ModelElementContainer mec = editor.getModelProcessor().getElementContainer();

    JPanel infoPanel = new JPanel();
    ClickLabel clickLabel = null;
    JLabel count = null;
    infoPanel.setBackground(Color.WHITE);
View Full Code Here

    // ! Translate a string identifier as returned by the WOFLAN
    // ! analyser DLL into an object within the net that is currently
    // ! opened in the editor
    private AbstractPetriNetElementModel translateToNetObject(String name) {
        ModelElementContainer elements = m_currentEditor.getModelProcessor().getElementContainer();
        String objectID = null;
        int nOperator = name.lastIndexOf(OperatorTransitionModel.OPERATOR_SEPERATOR_TRANSITION);
        if (nOperator != -1) {
            // Cut any operator numbers at the end (operator
            // numbers are used for complex transitions such as
            // xor split / xor join
            objectID = name.substring(0, nOperator);
            int nRealIDIndex = objectID.lastIndexOf(OperatorTransitionModel.INNERID_SEPERATOR);
            if (nRealIDIndex != -1) {
                objectID = objectID.substring(nRealIDIndex + 1);
            }
        } else {
            // This is an ordinary element, just take its ID
            int nRealIDIndex = name.lastIndexOf(OperatorTransitionModel.INNERID_SEPERATOR);
            if (nRealIDIndex != -1) {
                objectID = name.substring(nRealIDIndex + 1);
            }
        }

        // Cut any hash sign that might exist
        if ((objectID != null) && (objectID.charAt(0) == '#')) {
            objectID = objectID.substring(1);
        }

        AbstractPetriNetElementModel current = ((objectID != null) ? elements.getElementById(objectID) : null);
        return current;
    }
View Full Code Here

            ((PlaceModel) container.getElementById(placeIter.next())).resetVirtualTokens();
        }
        Iterator<String> subpIter = container.getElementsByType(AbstractPetriNetElementModel.SUBP_TYPE).keySet().iterator();
        while (subpIter.hasNext()) {
            // Now we call ourselves recursively for all sub-processes
            ModelElementContainer innerContainer = ((SubProcessModel) container.getElementById(subpIter.next()))
                    .getSimpleTransContainer();
            resetVirtualTokensInElementContainer(innerContainer);
        }
    }
View Full Code Here

        if (element != null) {
            // An object can have multiple owning containers
            // Iterate through all of them to get all connections
            Iterator<ModelElementContainer> ownerIterator = element.getOwningContainersIterator();
            while (ownerIterator.hasNext()) {
                ModelElementContainer currentContainer = ownerIterator.next();
                if ((connectionType & connectionTypeINBOUND) > 0) {
                    // Detect inbound connections
                    // Return only those that do not connect any operators
                    Map<String, AbstractPetriNetElementModel> sourceElements = currentContainer.getSourceElements(element
                            .getId());
                    appendNonOperators(result, sourceElements.values().iterator());
                }
                if ((connectionType & connectionTypeOUTBOUND) > 0) {
                    // Detect outbound connections
                    // Return only those that do not connect any operators
                    Map<String, AbstractPetriNetElementModel> targetElements = currentContainer.getTargetElements(element
                            .getId());
                    appendNonOperators(result, targetElements.values().iterator());
                }
            }
        }
View Full Code Here

  @Override
  public void registerIncomingConnection(
        PetriNetModelProcessor processor,
      AbstractPetriNetElementModel sourceModel)
  {
    ModelElementContainer outerContainer = processor.getElementContainer();
    /*
     * If operator have only one Source AND container does only
     * have one simple trans
     */
    if (outerContainer.getSourceElements(
        getId()).size() == 1
        && getSimpleTransContainer()
        .getElementsByType(
            AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
            .size() == 1)
    {
      // get simple trans
      TransitionModel simpleTrans = (TransitionModel) getSimpleTransContainer().getElementsByType(
          AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
          .values().iterator().next();
      // dann f�ge nur die Reference hinzu
      addReference(getNextFreeArcID(processor),
          (DefaultPort) sourceModel.getChildAt(0),
          (DefaultPort) simpleTrans.getChildAt(0));
    } else
    {
      // create new SimpleTrans
      // add simpletrans to SimpleTransContainer
      TransitionModel simpleTrans = addNewSimpleTrans();
     
      // add new arc from new source to cew simpleTrans in
      // SimpleTransConatainer
      addReference(getNextFreeArcID(processor),
          (DefaultPort) sourceModel.getChildAt(0),
          (DefaultPort) simpleTrans.getChildAt(0));
     
      // create a new arc from EACH SimpleTrans to EACH Target
      // of the Operator
      Iterator<String> targetIter = outerContainer.getTargetElements(getId())
      .keySet().iterator();
      while (targetIter.hasNext())
      {
        addReference(getNextFreeArcID(processor),
            (DefaultPort) simpleTrans.getChildAt(0),
            (DefaultPort) outerContainer
            .getElementById(targetIter.next())
            .getChildAt(0));
      }
    }
  }
View Full Code Here

    setSize(WIDTH, HEIGHT);
    getToolSpecific().setSubprocess(true);

    // there is already a container -> make a copy
    if (map.getSubElementContainer() != null) {
      ModelElementContainer newContainer = copySubElementContainer(map
          .getSubElementContainer());

      newContainer.setOwningElement(this);
      subElementContainer = newContainer;
    } else {
      // The sub element container
      // is owned by the subprocess
      subElementContainer = new ModelElementContainer();
      subElementContainer.setOwningElement(this);
      // System.err.println(this.getToolTipText());
    }

  }
View Full Code Here

  private ModelElementContainer copySubElementContainer(
      ModelElementContainer container) {

    LoggerManager.info(Constants.CORE_LOGGER, "copySubElementContainer");
    ModelElementContainer newContainer = new ModelElementContainer();

    newContainer.setOwningElement(container.getOwningElement());

    PetriNetModelProcessor processor = new PetriNetModelProcessor();
    processor.setElementContainer(newContainer);

    // HashMap<String, String> idMapper = new HashMap<String, String>();

    // copy elements

    Map<?, ?> idMap = container.getIdMap();
    Iterator<?> keyIterator = idMap.keySet().iterator();
    CreationMap currentArcMapSub;
    AbstractPetriNetElementModel newElementSub = null;
    while (keyIterator.hasNext()) {

      AbstractPetriNetElementModel currentElementSub = (AbstractPetriNetElementModel) container
          .getElementById(keyIterator.next());

      if (!currentElementSub.isReadOnly()) {
        CreationMap newMapSub = (CreationMap) currentElementSub
            .getCreationMap().clone();
        // newMap.setId("copyof_" + newMap.getId());
        String[] splitName = newMapSub.getId().split(
            SUBELEMENT_SEPERATOR);
        if (splitName.length > 1)
          newMapSub.setId(super.getId() + SUBELEMENT_SEPERATOR
              + splitName[splitName.length - 1]);
        newMapSub.setName(newMapSub.getId());
        newElementSub = ModelElementFactory
            .createModelElement(newMapSub);
       
        if (currentElementSub instanceof TransitionModel) {
          TransitionModel newTransitionSub = (TransitionModel) newElementSub;
          newTransitionSub
              .setToolSpecific(((TransitionModel) currentElementSub)
                  .getToolSpecific());

          newContainer.addElement(newTransitionSub);

        } else

          newContainer.addElement(newElementSub);
      }
    }
    /* insert arc source/target */
    Iterator<?> arcIterSub = container.getArcMap().keySet().iterator();
    CreationMap cMapSub = CreationMap.createMap();
    String originalElementId;
    String[] splitedSourceId, splitedTargetId;
    while (arcIterSub.hasNext()) {
      currentArcMapSub = container.getArcMap().get((arcIterSub.next()))
          .getCreationMap();
      originalElementId = currentArcMapSub.getName();
      splitedSourceId = currentArcMapSub.getArcSourceId().split(
          SUBELEMENT_SEPERATOR);
      splitedTargetId = currentArcMapSub.getArcTargetId().split(
          SUBELEMENT_SEPERATOR);

      String newSourceName ;
      String newTargetName ;
     
      if ((splitedSourceId.length > 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
        cMapSub.setArcSourceId(newSourceName);
        cMapSub.setArcTargetId(newTargetName);
        processor.createArc(newSourceName,
            newTargetName);
      }
      else if ((splitedSourceId.length <= 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        cMapSub.setArcTargetId(newTargetName);
        ((TransitionModel) newContainer.getElementById(newTargetName)).setIncommingTarget(true);
        processor.createArc(originalElementId,
            cMapSub.getArcTargetId());
      }
      else if ((splitedSourceId.length > 1) && (splitedTargetId.length <= 1)) {
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
        cMapSub.setArcSourceId(newSourceName);
        ((TransitionModel) newContainer.getElementById(newSourceName)).setOutgoingSource(true);
      }
    }
    /* insert arcs */
    return newContainer;
  }
View Full Code Here

            return;
        }
        m_bBasicNetInfoAvailable = true;

        // Get the element container containing all our elements
        ModelElementContainer elements = m_currentEditor.getModelProcessor().getElementContainer();
        // Iterate through all elements and
        // take notes
        m_nNumArcs = 0;
        Iterator<AbstractPetriNetElementModel> i = elements.getRootElements().iterator();
        updateStatistics(i);
        // Just ask the arc map for its size...
        m_nNumArcs += elements.getArcMap().size();
    }
View Full Code Here

TOP

Related Classes of org.woped.core.model.ModelElementContainer

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.