Package org.openbp.jaspira.action

Examples of org.openbp.jaspira.action.JaspiraAction$PriorityComparator


    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();
              }
            });
          }
        }

        if (flavor [i].equals(ModelerFlavors.PARAM_CONNECTION_FIGURE))
        {
          final ParamConnection connection = (ParamConnection) ie.getSafeTransferData(flavor [i]);

          // 'Lock/unlock orientation' popup
          JaspiraAction lockAction = new JaspiraAction(modeler, "modeler.edit.lockorientation")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Lock Orientation");

              connection.toggleOrientationLock();

              modeler.endUndo();
            }
          };
          lockAction.setSelected(connection.isOrientationLocked());
          group.addMenuChild(lockAction);

          // 'Flip orientation' popup
          group.addMenuChild(new JaspiraAction(modeler, "modeler.edit.fliporientation")
          {
            public void actionPerformed(ActionEvent e)
            {
              modeler.startUndo("Flip Orientation");

              connection.flipOrientation();

              modeler.endUndo();
            }
          });
        }
      }

      ie.add(group);

      boolean copyEnabled = modeler.canCopy();
      boolean cutEnabled = modeler.canCut();
      boolean deleteEnabled = modeler.canDelete();
      boolean pasteEnabled = modeler.canPaste(ClipboardMgr.getInstance().getCurrentEntry());
      if (copyEnabled || deleteEnabled || cutEnabled || pasteEnabled)
      {
        JaspiraAction copyPasteGroup = new JaspiraAction("copypaste", null, null, null, null, 2, JaspiraAction.TYPE_GROUP);

        JaspiraAction ja;

        ja = new JaspiraAction(modeler, "modeler.edit.copy")
        {
          public void actionPerformed(ActionEvent e)
          {
            // Forward to the clipboard plugin
            modeler.fireEvent(new JaspiraActionEvent(modeler, "global.clipboard.copy", Plugin.LEVEL_APPLICATION));
          }
        };
        ja.setEnabled(copyEnabled);
        copyPasteGroup.addMenuChild(ja);

        ja = new JaspiraAction(modeler, "modeler.edit.cut")
        {
          public void actionPerformed(ActionEvent e)
          {
            // Forward to the clipboard plugin
            modeler.fireEvent(new JaspiraActionEvent(modeler, "global.clipboard.cut", Plugin.LEVEL_APPLICATION));
          }
        };
        ja.setEnabled(cutEnabled);
        copyPasteGroup.addMenuChild(ja);

        ja = new JaspiraAction(modeler, "modeler.edit.paste")
        {
          public void actionPerformed(ActionEvent e)
          {
            // Forward to the clipboard plugin
            modeler.fireEvent(new JaspiraActionEvent(modeler, "global.clipboard.paste", Plugin.LEVEL_APPLICATION));
          }
        };
        ja.setEnabled(pasteEnabled);
        copyPasteGroup.addMenuChild(ja);

        ie.add(copyPasteGroup);

        ja = new JaspiraAction(modeler, "modeler.edit.delete")
        {
          public void actionPerformed(ActionEvent e)
          {
            // Forward to the clipboard plugin
            modeler.fireEvent(new JaspiraActionEvent(modeler, "global.clipboard.delete", Plugin.LEVEL_APPLICATION));
          }
        };
        ja.setEnabled(deleteEnabled);
        ie.add(ja);
      }
    }

    return EVENT_HANDLED;
View Full Code Here


   *
   * @param skin Skin or null
   */
  protected void updateSkinSelectionBox(Skin skin)
  {
    JaspiraAction action = getAction("plugin.skin.selectskin");
    if (action != null)
    {
      String text = skin != null ? skin.getDisplayText() : null;
      action.putValue(JaspiraToolbarCombo.PROPERTY_TEXT, text);
      action.setEnabled(text != null);
    }
  }
View Full Code Here

  /**
   * Fills the skin selection box with the available skins.
   */
  protected void fillSkinSelectionBox()
  {
    JaspiraAction action = getAction("plugin.skin.selectskin");
    if (action != null)
    {
      action.clearValues();

      List skins = SkinMgr.getInstance().getSkinList();
      int n = skins.size();
      for (int i = 0; i < n; ++i)
      {
        Skin skin = (Skin) skins.get(i);
        String text = skin.getDisplayText();

        // Save the skin display name and the skin itself as selection text/selection value
        // in the property map of the action.
        // The toolbar combo will initialize itself from this.
        action.putValue(JaspiraToolbarCombo.PROPERTY_SELECTION_VALUE + i, skin);
        action.putValue(JaspiraToolbarCombo.PROPERTY_SELECTION_TEXT + i, text);
      }

      action.putValue(JaspiraToolbarCombo.PROPERTY_TEXT, null);
      action.setEnabled(false);
    }
  }
View Full Code Here

     * @param je Event
     * @return The event status code
     */
    public JaspiraEventHandlerCode displayskin(JaspiraEvent je)
    {
      JaspiraAction action = getAction("plugin.skin.selectskin");
      if (action != null)
      {
        Skin skin = (Skin) je.getObject();
        String text = skin != null ? skin.getDisplayText() : null;
        action.putValue(JaspiraToolbarCombo.PROPERTY_TEXT, text);
        action.setEnabled(text != null);
      }

      return EVENT_CONSUMED;
    }
View Full Code Here

              flipableSelected = true;
            }
          }
        }

        JaspiraAction action = ActionMgr.getInstance().getAction("modeler.edit.fliporientation");
        if (action != null)
        {
          action.setEnabled(flipableSelected);
        }
      }

      return EVENT_HANDLED;
    }
View Full Code Here

    String pageName = activePage != null ? activePage.getName() : null;

    // Create and add the menu bar
    JMenuBar mb = new JMenuBar();

    JaspiraAction root = ActionMgr.getInstance().getAction(JaspiraAction.MENU_ROOT);
    if (root.getMenuchildren() != null)
    {
      for (Iterator it = root.getMenuchildren().iterator(); it.hasNext();)
      {
        JaspiraAction action = (JaspiraAction) it.next();

        if (action.matchesPageName(pageName))
        {
          JMenuItem menuItem = action.toMenuItem(pageName);
          if (menuItem != null)
          {
            mb.add(menuItem);
          }
        }
      }
    }

    setJMenuBar(mb);

    // Clear and populate the toolbar
    toolbar.removeAll();

    root = ActionMgr.getInstance().getAction(JaspiraAction.TOOLBAR_ROOT);
    if (root.getToolbarchildren() != null)
    {
      for (Iterator it = root.getToolbarchildren().iterator(); it.hasNext();)
      {
        JaspiraAction action = (JaspiraAction) it.next();

        if (action.matchesPageName(pageName))
        {
          JComponent toolbarComponent = action.toToolBarComponent(pageName);
          if (toolbarComponent != null)
          {
            toolbar.add(toolbarComponent);
            toolbar.addSeparator();
          }
View Full Code Here

          else
          {
            menu.addSeparator();
          }

          menu.add(new JaspiraAction(toolbox, "toolbox.remove")
          {
            public void actionPerformed(ActionEvent ae)
            {
              toolbox.removeToolBoxItem(ToolBoxItem.this);
              toolbox.refreshContent();
View Full Code Here

   */
  public Undoable startUndoForAction(String eventName)
  {
    String displayName = null;

    JaspiraAction action = ActionMgr.getInstance().getAction(eventName);
    if (action != null)
    {
      displayName = action.getDisplayName();
    }

    return startUndo(displayName);
  }
View Full Code Here

    add(contentPane, BorderLayout.CENTER);

    if (plugin.hasCloseButton())
    {
      JaspiraAction closeAction = new JaspiraAction(commonResourceCollection, "plugin.close")
      {
        public void actionPerformed(ActionEvent e)
        {
          plugin.requestClose();
        }
View Full Code Here

        {
          toolbarPopup.removeAll();
        }
        toolbarPopup.add(cachedToolBar);

        JaspiraAction toolbarPopupTrigger = new JaspiraAction(commonResourceCollection, "plugin.toolbarmenu")
        {
          public void actionPerformed(ActionEvent e)
          {
            Dimension d = getToolkit().getScreenSize();
            Component c = (Component) e.getSource();
View Full Code Here

TOP

Related Classes of org.openbp.jaspira.action.JaspiraAction$PriorityComparator

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.