Exemplo n.º 1
0
  private void enableActionsNow() {
    boolean[] currentStates = new boolean[ConditionalAction.NUMBER_OF_CONDITIONS];
    Operator op = getFirstSelectedOperator();
    if (op != null) {
      currentStates[ConditionalAction.OPERATOR_SELECTED] = true;
      if (op instanceof OperatorChain) {
        currentStates[ConditionalAction.OPERATOR_CHAIN_SELECTED] = true;
      }
      if (op.getParent() == null) {
        currentStates[ConditionalAction.ROOT_SELECTED] = true;
      } else {
        currentStates[ConditionalAction.PARENT_ENABLED] = op.getParent().isEnabled();
        if (op.getExecutionUnit().getNumberOfOperators() > 1) {
          currentStates[ConditionalAction.SIBLINGS_EXIST] = true;
        }
      }
    }

    int processState = process.getProcessState();
    currentStates[ConditionalAction.PROCESS_STOPPED] =
        processState == Process.PROCESS_STATE_STOPPED;
    currentStates[ConditionalAction.PROCESS_PAUSED] = processState == Process.PROCESS_STATE_PAUSED;
    currentStates[ConditionalAction.PROCESS_RUNNING] =
        processState == Process.PROCESS_STATE_RUNNING;
    currentStates[ConditionalAction.EDIT_IN_PROGRESS] = EditBlockingProgressThread.isEditing();
    currentStates[ConditionalAction.PROCESS_SAVED] = process.hasSaveDestination();
    currentStates[ConditionalAction.PROCESS_RENDERER_IS_VISIBLE] =
        mainFrame.getProcessPanel().getProcessRenderer().isShowing();
    currentStates[ConditionalAction.PROCESS_RENDERER_HAS_UNDO_STEPS] = mainFrame.hasUndoSteps();
    currentStates[ConditionalAction.PROCESS_RENDERER_HAS_REDO_STEPS] = mainFrame.hasRedoSteps();
    ConditionalAction.updateAll(currentStates);
    updateCheckboxStates();
  }
Exemplo n.º 2
0
 /** The currently selected operator will be deleted. */
 public void delete() {
   Operator parent = null;
   for (Operator selectedOperator : new LinkedList<Operator>(getSelectedOperators())) {
     if (parent == null) {
       parent = selectedOperator.getParent();
     }
     if (selectedOperator instanceof ProcessRootOperator) {
       return;
     }
     selectedOperator.remove();
   }
   mainFrame.selectOperator(parent);
 }
Exemplo n.º 3
0
  /** Creates a new popup menu for the selected operator. */
  public void addToOperatorPopupMenu(
      JPopupMenu menu, Action renameAction, Action... furtherActions) {
    final Operator op = getFirstSelectedOperator();
    final boolean singleSelection = getSelectedOperators().size() == 1;

    if (op != null && !singleSelection) {
      if (!(op instanceof ProcessRootOperator) && op.getParent() != null) {
        // enable / disable operator
        menu.add(TOGGLE_ACTIVATION_ITEM.createMultipleActivationItem());
      }
    }

    if (op != null && singleSelection) {
      if (mainFrame.getProcessPanel().getProcessRenderer().getModel().getDisplayedChain() != op) {
        menu.add(INFO_OPERATOR_ACTION);
        menu.add(TOGGLE_ACTIVATION_ITEM.createMenuItem());
        if (renameAction != null) {
          menu.add(renameAction);
        } else {
          menu.add(RENAME_OPERATOR_ACTION);
        }
        menu.addSeparator();
        if (op instanceof OperatorChain && ((OperatorChain) op).getAllInnerOperators().size() > 0) {
          menu.add(OperatorMenu.REPLACE_OPERATORCHAIN_MENU);
        } else {
          menu.add(OperatorMenu.REPLACE_OPERATOR_MENU);
        }
      }
    }

    // add new operator and building block menu
    if (mainFrame.getProcessPanel().getProcessRenderer().getModel().getDisplayedChain() == op) {
      menu.add(OperatorMenu.NEW_OPERATOR_MENU);
    }

    // populate menu with registered operator actions (if any)
    synchronized (factories) {
      for (OperatorActionFactory factory : factories) {
        List<ResourceEntry> entries = factory.create(context);
        if (!entries.isEmpty()) {
          menu.addSeparator();
        }
        for (ResourceEntry entry : entries) {
          if (entry.isMenu()) {
            menu.add(entry.getMenu());
          } else {
            menu.add(entry.getAction());
          }
        }
      }
    }

    menu.addSeparator();
    boolean enableCutCopy =
        mainFrame.getProcessPanel().getProcessRenderer().getModel().getDisplayedChain() != op;
    OperatorTransferHandler.installMenuItems(menu, enableCutCopy);

    // add further actions here
    if (furtherActions.length > 0) {
      menu.addSeparator();
      for (Action a : furtherActions) {
        if (a == null) {
          continue;
        }

        if (a instanceof ToggleAction) {
          menu.add(((ToggleAction) a).createMenuItem());
        } else {
          menu.add(a);
        }
      }
    }

    if (op != null && !(op instanceof ProcessRootOperator) && singleSelection) {
      menu.addSeparator();
      for (int i = 0; i < TOGGLE_BREAKPOINT.length; i++) {
        JMenuItem item = TOGGLE_BREAKPOINT[i].createMenuItem();
        menu.add(item);
      }
    }
  }