Package org.openbp.core.model.item.process

Examples of org.openbp.core.model.item.process.ProcessItem


      return;

    String processName = entryName.substring(0, index);
    entryName = entryName.substring(index + 1);

    ProcessItem process;
    try
    {
      process = (ProcessItem) model.resolveItemRef(processName, ItemTypes.PROCESS);
    }
    catch (ModelException e)
    {
      String msg = e.getMessage();
      msgs.addMsg(null, "Cannot resolve the process name of an entry. Maybe the process has been deleted.\n" + msg);
      return;
    }

    Node node = process.getNodeByName(entryName);
    if (node instanceof InitialNode)
    {
      initialNode = (InitialNode) node;
    }
    else
    {
      String msg = MsgFormat.format("Cannot resolve the entry $0 in process $1. Maybe the entry has been deleted.", entryName, process.getQualifier());
      msgs.addMsg(null, msg);
    }
  }
View Full Code Here


    double factor = 1d;
    int additionalSockets = 0;

    if (item instanceof ProcessItem)
    {
      ProcessItem process = (ProcessItem) item;
      int size = ModelerGraphics.DEFAULT_NODE_SIZE;

      String processType = process.getProcessType();
      if (ProcessTypes.USECASE.equals(processType) || ProcessTypes.TOPLEVEL.equals(processType))
      {
        // Make use cases and top level processes appear larger
        factor = 2d;
      }

      // Count the number of sockets (i. e. entry and final nodes)
      for (Iterator it = process.getNodes(); it.hasNext();)
      {
        Node node = (Node) it.next();

        if (node instanceof InitialNode || node instanceof FinalNode)
          ++additionalSockets;
      }

      // Normal are one entry and one final node, so subtract two sockets
      additionalSockets -= 2;

      // Adjust the size of the node according to the number of sockets
      if (additionalSockets > 0)
      {
        size += ModelerGraphics.DEFAULT_NODE_SIZE * additionalSockets / 2;
      }
      process.setNodeGeometry("size:" + size);
    }
    else if (item instanceof ActivityItem)
    {
      // Adjust the size of the node according to the number of sockets
      ActivityItem action = (ActivityItem) item;
View Full Code Here

      // We create a dummy process which we put into the clipboard.
      // In order to force all object references to be absolute, we choose the System model
      // as parent model of the dummy process (this is also fine for objects which belong
      // to the System model itself since these object will always be referenced using their
      // local name)
      ProcessItem process = new ProcessItemImpl();
      process.setName("ProcessDummy");
      process.setModel(ModelConnector.getInstance().getModelByQualifier(CoreConstants.SYSTEM_MODEL_QUALIFIER));

      // When copying a node, we perform the following steps:
      // 1. Encode the geometry
      // 2. Clone the object
      // 3. Add the cloned object to the dummy process
      // 4. Generate reference names from the actual object references (e. g. for actions, sub processes, data types etc.)

      // Node that contains the selected sockets
      ActivityNodeImpl socketHolder = null;

      // List of source nodes that have been copied
      ArrayList copiedSourceNodes = new ArrayList();

      // Socket that contains the selected parameters
      NodeSocket paramHolder = null;

      for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
      {
        Figure next = fe.nextFigure();

        if (next instanceof NodeFigure)
        {
          NodeFigure nodeFigure = (NodeFigure) next;
          nodeFigure.encodeGeometry();

          Node node = nodeFigure.getNode();

          // Remember that we have copied this one
          copiedSourceNodes.add(node);

          // Clone the node and add it to the process
          node = (Node) node.clone();
          process.addNode(node);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof TextElementFigure)
        {
          TextElementFigure textElementFigure = (TextElementFigure) next;
          textElementFigure.encodeGeometry();

          TextElement textElement = textElementFigure.getTextElement();

          // Clone the element and add it to the process
          textElement = (TextElement) textElement.clone();
          process.addTextElement(textElement);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof SocketFigure)
        {
          SocketFigure socketFigure = (SocketFigure) next;
          socketFigure.encodeGeometry();

          NodeSocket socket = socketFigure.getNodeSocket();

          if (socketHolder == null)
          {
            socketHolder = new ActivityNodeImpl();
            socketHolder.setName("NodeDummy");
            process.addNode(socketHolder);
          }

          // Clone the socketand add it to the dummy node
          socket = (NodeSocket) socket.clone();
          socketHolder.addSocket(socket);

          copyFlavor = ClientFlavors.NODE_SOCKETS;
        }

        else if (next instanceof ParamFigure)
        {
          ParamFigure paramFigure = (ParamFigure) next;

          NodeParam param = paramFigure.getNodeParam();

          if (paramHolder == null)
          {
            if (socketHolder == null)
            {
              socketHolder = new ActivityNodeImpl();
              socketHolder.setName("NodeDummy");
              process.addNode(socketHolder);
            }

            paramHolder = new NodeSocketImpl();
            paramHolder.setName("SocketDummy");
            socketHolder.addSocket(paramHolder);
          }

          // Clone the socket and add it to the dummy node
          param = (NodeParam) param.clone();
          paramHolder.addParam(param, - 1);

          copyFlavor = ClientFlavors.NODE_PARAMS;
        }
      }

      // When copying a link, we perform the following steps:
      // 1. Encode the geometry
      // 2. Generate reference names from the actual object references
      //    (e. g. node names for control links, parameter names for data links etc.)
      // 3. Clone the object
      // 4. Add the cloned object to the dummy process
      // 5. Re-establish the object references (now based on the elements of the dummy process)
      //    If this fails, the object will be removed from the dummy process again.

      StandardMsgContainer msgContainer = ModelConnector.getInstance().getMsgContainer();
      msgContainer.clearMsgs();

      for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
      {
        Figure next = fe.nextFigure();

        if (next instanceof FlowConnection)
        {
          FlowConnection flowConnection = (FlowConnection) next;

          ControlLink link = flowConnection.getControlLink();

          if (! copiedSourceNodes.contains(link.getSourceSocket().getNode())
            || ! copiedSourceNodes.contains(link.getTargetSocket().getNode()))
          {
            // Link source or target has not been copied
            continue;
          }

          flowConnection.encodeGeometry();

          link = (ControlLink) link.clone();
          process.addControlLink(link);

          if (! msgContainer.isEmpty())
          {
            // One of the end points of the link is not present in the copied set,
            // so remove the link from the dummy process again.
            process.removeControlLink(link);
            msgContainer.clearMsgs();
          }
        }

        else if (next instanceof ParamConnection)
        {
          ParamConnection paramConnection = (ParamConnection) next;

          DataLink link = paramConnection.getDataLink();

          Param sourceParam = link.getSourceParam();
          Param targetParam = link.getTargetParam();

          if (sourceParam instanceof NodeParam)
          {
            if (! copiedSourceNodes.contains(((NodeParam) sourceParam).getSocket().getNode()))
            {
              // Link source or target has not been copied
              continue;
            }
          }
          else
          {
            // Don't copy process variable links
            continue;
          }

          if (targetParam instanceof NodeParam)
          {
            if (! copiedSourceNodes.contains(((NodeParam) targetParam).getSocket().getNode()))
            {
              // Link source or target has not been copied
              continue;
            }
          }
          else
          {
            // Don't copy process variable links
            continue;
          }

          paramConnection.encodeGeometry();

          link = (DataLink) link.clone();
          process.addDataLink(link);

          if (! msgContainer.isEmpty())
          {
            // One of the end points of the link is not present in the copied set,
            // so remove the link from the dummy process again.
            process.removeDataLink(link);
            msgContainer.clearMsgs();
          }
        }
      }

      // Re-establish inter-object links and links to other items
      // and remove links to figures to make the gc work
      // TODO Fix 4 This seems to produce some maintainReferences error: "Cannot resolve ... in Model /System"
      process.maintainReferences(ModelObject.RESOLVE_GLOBAL_REFS | ModelObject.RESOLVE_LOCAL_REFS | ModelObject.UNLINK_FROM_REPRESENTATION);

      if (copyFlavor != null && (process.getNodes().hasNext() || process.getTextElements().hasNext()))
      {
        Transferable ret = new SimpleTransferable(process, copyFlavor);

        if (copiedSourceNodes.size() == 1)
        {
View Full Code Here

    {
      initializeModelDirectorySetup((Model) item);
    }
    else if (item instanceof ProcessItem)
    {
      ProcessItem process = (ProcessItem) item;

      // Initialize some process properties from the default skin settings
      SkinMgr.getInstance().getDefaultSkin().initalizeNewProcess(process);

      // Supply the process type
      process.setProcessType(processType);
    }

    // Reinitialize the item's standard configuration now that we have fixed the process type
    ItemCreationUtil.setupStandardConfiguration(item);
View Full Code Here

  {
    Object o = je.getObject();

    if (o instanceof Modeler)
    {
      ProcessItem currentProcess = ((Modeler) o).getProcess();
      itemBrowser.currentProcessQualifier = currentProcess.getQualifier();

      return EVENT_HANDLED;
    }

    return EVENT_IGNORED;
View Full Code Here

      ModelQualifier qualifier = mo.getQualifier();

      if (qualifier.getItemType().equals(ItemTypes.PROCESS))
      {
        // Open the process of select the node/socket/parameter
        ProcessItem process = getProcess(mo);
        OpenEvent oEvent = new OpenEvent(this, "open.modeler", process);
        fireEvent(oEvent);

        // The event must be fired twice, because the first only deselect the current selection.
        // The second select the component.
View Full Code Here

   */
  public static void ensureProcessType(Item item)
  {
    if (item instanceof ProcessItem)
    {
      ProcessItem process = (ProcessItem) item;
      if (process.getProcessType() == null)
      {
        process.setProcessType(ProcessTypes.USERINTERFACE);
      }
    }
  }
View Full Code Here

   * @param context Generator context
   */
  private void initializeProcess(GeneratorContext context)
  {
    // Initialize the process according to the process type
    ProcessItem process = (ProcessItem) context.getItem();

    String processType = (String) context.getProperty(PROCESS_TYPE);
    process.setProcessType(processType);

    String skinName = (String) context.getProperty(SKIN_NAME);
    if (skinName != null)
    {
      process.setSkinName(skinName);
    }

    if (context.isEmptyItem() && context.isNewItem())
    {
      // Modify new processes
View Full Code Here

   *
   * @param context Generator context
   */
  public void updateItemName(GeneratorContext context)
  {
    ProcessItem process = (ProcessItem) context.getItem();

    // For new items, assign a default name/display name/description
    // based on the process type specified in the generator xml descriptor if they don't have a valid name already

    if (process.getName() != null)
    {
      ModelQualifier itemQualifier = process.getQualifier();
      if (ModelConnector.getInstance().getItemByQualifier(itemQualifier, false) == null)
      {
        // Name not present yet, continue
        return;
      }
    }

    // Generate a name for the item if a name format has been specified in the generator properties
    String processType = process.getProcessType();
    if (processType != null)
    {
      String name = processType;

      String nameSuffix = determineUniqueSuffix(process, name);
      if (nameSuffix != null)
      {
        name += nameSuffix;
      }
      process.setName(name);
    }
  }
View Full Code Here

  {
    if (! (item instanceof ProcessItem))
      // We check process items only
      return;

    ProcessItem process = (ProcessItem) item;
    if (! process.isDefaultProcess())
      // We need to take action for processes that are about to become the new default process only
      return;

    ProcessItem currentDefaultProcess = process.getModel().getDefaultProcess();
    if (currentDefaultProcess == null || currentDefaultProcess.getName().equals(process.getName()))
      // No default process yet or process to be updated is already the default process
      return;

    // Clear the default flag of the old default process and update the old default process first
    currentDefaultProcess.setDefaultProcess(false);

    // First, perform the operation at the server
    modelMgr.updateItem(currentDefaultProcess);

    fireEvent(new ModelConnectorEvent(ModelConnectorEvent.ITEM_UPDATED, currentDefaultProcess.getQualifier()));
  }
View Full Code Here

TOP

Related Classes of org.openbp.core.model.item.process.ProcessItem

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.