Package org.openbp.cockpit.modeler.drawing

Examples of org.openbp.cockpit.modeler.drawing.WorkspaceDrawingView$CursorAction


    if (!modeler.getPluginComponent().isShowing())
    {
      return EVENT_IGNORED;
    }

    final WorkspaceDrawingView workspaceView = modeler.getDrawingView();

    if (ie.getSourcePlugin() == modeler)
    {
      DataFlavor [] flavor = ie.getTransferDataFlavors();

      JaspiraAction group = new JaspiraAction("popup", null, null, null, null, 100, JaspiraAction.TYPE_GROUP);

      for (int i = 0; i < flavor.length; i++)
      {
        if (flavor [i].equals(ClientFlavors.MODEL_OBJECT))
        {
          ModelObject mo = (ModelObject) ie.getSafeTransferData(flavor [i]);
          configuratorSupport.addConfiguratorMenuOptions(mo, group);
        }

        if (flavor [i].equals(ModelerFlavors.FIGURE))
        {
          Figure figure = (Figure) ie.getSafeTransferData(flavor [i]);
          workspaceView.singleSelect(figure);
        }

        if (flavor [i].equals(ModelerFlavors.PARAM_FIGURE))
        {
          final ParamFigure paramFigure = (ParamFigure) ie.getSafeTransferData(flavor [i]);
          final NodeParam nodeParam = paramFigure.getNodeParam();
          SocketFigure socketFigure = (SocketFigure) paramFigure.getParent();

          // Add the 'Parameter visibility' sub menu for all parameters of the socket if appropriate
          ParamVisibilityHelper.addParamMenu(ie, modeler, socketFigure);

          // 'Parameter Value Wizard' popup
          final NodeFigure nodeFigure = (NodeFigure) socketFigure.getParent();
          if (ParamValueWizard.isParameterValueWizardApplyable(modeler, nodeFigure, nodeParam.getSocket().getName()))
          {
            JaspiraAction wizardGroup = new JaspiraAction("popupwizard", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);

            wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.paramvaluewizard")
            {
              public void actionPerformed(ActionEvent e)
              {
                // Display parameter value wizard if appropriate
                ParamValueWizard.displayParameterValueWizard(modeler, nodeFigure, nodeParam.getSocket().getName(), nodeParam.getName());
              }
            });

            ie.add(wizardGroup);
          }

          // 'Create identical process variable' popup
          String paramName = nodeParam.getName();
          if (nodeParam.getProcess().getProcessVariableByName(paramName) == null)
          {
            JaspiraAction wizardGroup = new JaspiraAction("processvargroup", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);

            wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createprocessvarfromparam")
            {
              public void actionPerformed(ActionEvent e)
              {
                // Forward to the process variables plugin
                modeler.fireEvent("variables.createprocessvarfromparam", nodeParam);
              }
            });

            ie.add(wizardGroup);
          }
        }

        if (flavor [i].equals(ModelerFlavors.SOCKET_FIGURE))
        {
          final SocketFigure socketFigure = (SocketFigure) ie.getSafeTransferData(flavor [i]);
          final NodeSocket socket = socketFigure.getNodeSocket();

          // Add the 'Parameter visibility' sub menu if appropriate
          ParamVisibilityHelper.addParamMenu(ie, modeler, socketFigure);

          // 'Parameter Value Wizard' popup
          final NodeFigure nodeFigure = (NodeFigure) socketFigure.getParent();
          if (ParamValueWizard.isParameterValueWizardApplyable(modeler, nodeFigure, socket.getName()))
          {
            JaspiraAction wizardGroup = new JaspiraAction("popupwizard", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);

            wizardGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.paramvaluewizard")
            {
              public void actionPerformed(ActionEvent e)
              {
                // Display parameter value wizard if appropriate
                ParamValueWizard.displayParameterValueWizard(modeler, nodeFigure, socket.getName(), null);
              }
            });

            ie.add(wizardGroup);
          }

          /* Currently unused, rathr leads to confusion
          JaspiraAction socketToNodeGroup = new JaspiraAction("popupsockettonode", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);

          // 'Create initial node' popup
          socketToNodeGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createentryfromsocket")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Create Initial Node");

              if (drawing.getProcess().getNodeByName(socket.getName()) != null)
              {
                // A node with this name already exists; issue a warning.
                // The createFinalNodeFromSocket method will ensure that the new node
                // has a unique name.
                String msg = modeler.getPluginResourceCollection().getRequiredString("messages.nodealreadyexists");
                JMsgBox.show(null, msg, JMsgBox.ICON_INFO);
              }

              // Create a node from the socket and add it to the process
              NodeFigure nodeFigure = ModelerUtil.createInitialNodeFromSocket(socketFigure);

              modeler.endUndo();
            }
          });

          if (socket.isExitSocket())
          {
            // 'Create final node' popup
            socketToNodeGroup.addMenuChild(new JaspiraAction(modeler, "modeler.edit.createexitfromsocket")
            {
              public void actionPerformed(ActionEvent e)
              {
                modeler.startUndo("Create Final Node");

                if (drawing.getProcess().getNodeByName(socket.getName()) != null)
                {
                  // A node with this name already exists; issue a warning.
                  // The createFinalNodeFromSocket method will ensure that the new node
                  // has a unique name.
                  String msg = modeler.getPluginResourceCollection().getRequiredString("messages.nodealreadyexists");
                  JMsgBox.show(null, msg, JMsgBox.ICON_INFO);
                }

                // Create a node from the socket and add it to the process
                NodeFigure nodeFigure = ModelerUtil.createFinalNodeFromSocket(socketFigure);

                modeler.endUndo();
              }
            });
          }

          ie.add(socketToNodeGroup);
           */
        }

        if (flavor [i].equals(ModelerFlavors.NODE_FIGURE))
        {
          final NodeFigure nodeFigure = (NodeFigure) ie.getSafeTransferData(flavor [i]);

          group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.mirrororientation")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Flip Orientation");

              nodeFigure.flipOrientation();
              workspaceView.checkDamage();

              modeler.endUndo();
            }
          });

          group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.rotateorientationcw")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Rotate Orientation");

              nodeFigure.changeOrientation(NodeFigure.ROTATE_CW);
              workspaceView.checkDamage();

              modeler.endUndo();
            }
          });

          group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.rotateorientationccw")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Rotate Orientation");

              nodeFigure.changeOrientation(NodeFigure.ROTATE_CCW);
              workspaceView.checkDamage();

              modeler.endUndo();
            }
          });
        }

        if (flavor [i].equals(ModelerFlavors.COLORIZABLE))
        {
          final Colorizable col = (Colorizable) ie.getSafeTransferData(flavor [i]);

          // 'Reset color' popup
          if (col.getFillColor() != null && !col.getFillColor().equals(col.getDefaultFillColor()))
          {
            group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.resetcolor")
            {
              public void actionPerformed(ActionEvent e)
              {
                modeler.startUndo("Reset Color");

                // TODO Feature 6: Reset subordinate element color, too
                col.setFillColor(col.getDefaultFillColor());
                workspaceView.checkDamage();

                modeler.endUndo();
              }
            });
          }
View Full Code Here


    super(toolSupport);
  }

  public void mouseMove(MouseEvent e, int x, int y)
  {
    WorkspaceDrawingView view = (WorkspaceDrawingView) getView();
    Point lastPoint = getLastPoint();

    // ALT key pressed. Move the drawing accordingly using heuristic values.
    int xDiff = CommonUtil.rnd((e.getX() - lastPoint.x) / 1.5);
    int yDiff = CommonUtil.rnd((e.getY() - lastPoint.y) / 1.5);

    // Convert to document coordinates
    xDiff = view.applyScale(xDiff, true);
    yDiff = view.applyScale(yDiff, true);

    if (xDiff != 0 || yDiff != 0)
    {
      ((Trackable) getEditor()).moveTrackerBy(xDiff, yDiff);
    }
View Full Code Here

        // The skin is the selection item of the combo box
        Skin skin = (Skin) combo.getSelectedItem();

        if (currentModeler != null)
        {
          WorkspaceDrawingView view = currentModeler.getDrawingView();

          // We must clear the selection because all drawing objects will be cleared.
          view.clearSelection();

          ProcessDrawing drawing = (ProcessDrawing) view.drawing();

          // Save any geometry changes
          drawing.encodeGeometry();

          currentModeler.startUndo("Change Presentation Skin");

          // Completely reinitialize the drawing by re-setting the process
          ProcessItem process = drawing.getProcess();
          process.setSkinName(skin.getName());
          drawing.setProcess(process);

          currentModeler.endUndo();

          view.redraw();

          if (currentModeler.getPluginComponent().isShowing())
          {
            currentModeler.focusPlugin();
          }
View Full Code Here

  /**
   * Initializes the modeler after the process/drawing to edit has been set.
   */
  private void initializeModeler()
  {
    workspaceView = new WorkspaceDrawingView(this);
    workspaceView.setDrawing(drawing);

    toolSupport = new ModelerToolSupport(this);
    StandardToolSupportSetup.setupToolSupport(toolSupport, true);

View Full Code Here

  protected void restoreSelection(List selectionQualifiers)
  {
    if (selectionQualifiers == null)
      return;

    WorkspaceDrawingView view = modeler.getDrawingView();
    Rectangle rect = null;

    // Restore the selected objects by looking up the figures by theirmodel qualifier
    int n = selectionQualifiers.size();
    for (int i = 0; i < n; ++i)
    {
      ModelQualifier qualifier = (ModelQualifier) selectionQualifiers.get(i);

      ProcessElementContainer pec = modeler.getDrawing().getFigureByQualifier(qualifier);
      if (pec != null)
      {
        view.addToSelection(pec);

        Rectangle db = pec.displayBox();
        if (rect == null)
          rect = new Rectangle(db);
        else
          rect = rect.union(db);
      }
    }

    if (rect != null)
    {
      // Try to position the selection into view again
      rect.grow(50, 50);
      view.scrollRectToVisible(rect);
    }
  }
View Full Code Here

    super(toolSupport);
  }

  public void mouseMove(MouseEvent e, int x, int y)
  {
    WorkspaceDrawingView view = (WorkspaceDrawingView) getView();
    Point lastPoint = getLastPoint();

    // ALT+CTRL key pressed. Scale the drawing accordingly using heuristic values
    int diff = (e.getX() - lastPoint.x) / 2;

    if (diff != 0)
    {
      ((ProcessDrawing) getDrawing()).invalidate();

      // Scale according to mouse movement
      double scaleFactor = view.getScaleFactor();
      scaleFactor *= (100d + diff) / 100;
      view.setScaleFactor(scaleFactor);

      // ((Trackable) editor).centerTrackerAt (center);
      view.redraw();
    }
  }
View Full Code Here

    super.dragEnded(transferable);
  }

  public List getDropRegions(List flavors, Transferable data, MouseEvent mouseEvent)
  {
    WorkspaceDrawingView view = getDrawing().getView();

    if (flavors.contains(ModelerFlavors.COLOR))
    {
      // Use the whole section as target
      Rectangle r = presentationFigure.displayBox();
      r = view.applyScale(r, false);
      return Collections.singletonList(new ViewDropRegion(REGION_COLOR, this, r, view));
    }

    String regionId = null;
    if (flavors.contains(ClientFlavors.TYPE_ITEM))
    {
      regionId = REGION_PARAM_BY_TYPE;
    }
    else if (flavors.contains(ClientFlavors.PROCESS_VARIABLE))
    {
      regionId = REGION_PARAM_BY_VARIABLE;
    }

    if (regionId != null)
    {
      if (mouseEvent == null || ! mouseEvent.isControlDown())
      {
        // Accept type items only if the CTRL button is not pressed to prevent overlaying the region
        // exposed by the ParamFigure in this case.
        Rectangle[] bounds = getParamRegions();

        if (bounds.length > 1)
        {
          List result = new ArrayList();
          for (int i = 0; i < bounds.length; i++)
          {
            // Add a green drop region with a small black border around each parameter
            Rectangle r = view.applyScale(bounds[i], false);

            ViewDropRegion region = new ViewDropRegion(regionId + ":" + i, this, r, view);
            region.setPaint(ModelerColors.DROP_REGION);
            region.setFrameColor(Color.BLACK);

            result.add(region);
          }
          return result;
        }

        // Params are not shown, so we need only a single region.
        // Use the whole section as target
        Rectangle r = presentationFigure.displayBox();
        r = view.applyScale(r, false);
        ViewDropRegion region = new ViewDropRegion(regionId, this, r, view);
        region.setPaint(ModelerColors.DROP_REGION);
        return Collections.singletonList(region);
      }
    }
View Full Code Here

    return true;
  }

  public List getImportersAt(Point p)
  {
    WorkspaceDrawingView view = getDrawing().getView();

    Point docPoint = SwingUtil.convertFromGlassCoords(p, view);
    if (presentationFigure.containsPoint(docPoint.x, docPoint.y))
      return Collections.singletonList(new Importer(socket.getQualifier(), this, new DataFlavor[]
      {
View Full Code Here

    // Signalize figure change
    socketFigure.changed();

    if (socketFigure.getDrawing() != null)
    {
      WorkspaceDrawingView view = socketFigure.getDrawing().getView();
      if (view != null)
      {
        view.checkDamage();
      }
    }
  }
View Full Code Here

    return false;
  }

  public List getImportersAt(Point p)
  {
    WorkspaceDrawingView view = getDrawing().getView();

    Point docPoint = SwingUtil.convertFromGlassCoords(p, view);
    if (presentationFigure.containsPoint(docPoint.x, docPoint.y))
      return Collections.singletonList(new Importer(node.getQualifier(), this, new DataFlavor[]
      {
View Full Code Here

TOP

Related Classes of org.openbp.cockpit.modeler.drawing.WorkspaceDrawingView$CursorAction

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.