public void apply(Process process, Map<String, String> nameTranslation) {
   String opName = null;
   if (nameTranslation != null) {
     opName = nameTranslation.get(this.operator);
   }
   if (opName == null) {
     opName = this.operator;
   }
   process
       .getLogger()
       .fine(
           "Setting parameter '"
               + parameterKey
               + "' of operator '"
               + opName
               + "' to '"
               + parameterValue
               + "'.");
   Operator operator = process.getOperator(opName);
   if (operator == null) {
     process.getLogger().warning("No such operator: '" + opName + "'.");
   } else {
     operator.getParameters().setParameter(parameterKey, parameterValue);
   }
 }
Exemplo n.º 2
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();
  }
 private void registerOperator(Operator operator, boolean registerWithProcess) {
   operator.setEnclosingProcess(this);
   Process process = getEnclosingOperator().getProcess();
   if ((process != null) && registerWithProcess) {
     operator.registerOperator(process);
   }
   fireUpdate(this);
   operator.addObserver(delegatingOperatorObserver, false);
   operator.clear(Port.CLEAR_ALL);
   if (process != null) {
     process.fireOperatorAdded(operator);
   }
 }
  private JComboBox createParameterCombo(String operatorName, PropertyTable propertyTable) {
    JComboBox combo = new JComboBox();

    Operator operator = process.getOperator((String) operatorCombo.getSelectedItem());
    if (operator != null) {
      Iterator<ParameterType> i = operator.getParameters().getParameterTypes().iterator();
      while (i.hasNext()) {
        combo.addItem(i.next().getKey());
      }
    }

    if (combo.getItemCount() == 0) combo.addItem("no parameters");

    combo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            fireParameterChangedEvent();
            fireEditingStopped();
          }
        });

    combo.setSelectedIndex(0);

    return combo;
  }
  @Override
  public void receive(IOObject object) {
    setData(object);

    Process process = getPorts().getOwner().getOperator().getProcess();
    if ((process != null)
        && (process.getDebugMode() == DebugMode.COLLECT_METADATA_AFTER_EXECUTION)) {
      if (object == null) {
        setRealMetaData(null);
      } else {
        MetaData forIOObject = MetaData.forIOObject(object);
        setRealMetaData(forIOObject);
      }
    } else {
      setRealMetaData(null);
    }
  }
 /**
  * Removes the given operator. Don't call this method directly but call {@link Operator#remove()}.
  */
 protected void removeOperator(Operator operator) {
   if (!operators.contains(operator)) {
     throw new NoSuchElementException(
         "Operator " + operator.getName() + " not contained in " + getName() + "!");
   }
   int oldIndex = operators.indexOf(operator);
   int oldIndexAmongEnabled = getEnabledOperators().indexOf(operator);
   operators.remove(operator);
   unregister(operator);
   // operator.disconnectPorts();
   // transformMDNeighbourhood();
   Process process = getEnclosingOperator().getProcess();
   if (process != null) {
     process.fireOperatorRemoved(operator, oldIndex, oldIndexAmongEnabled);
   }
   operator.setEnclosingProcess(null);
   fireUpdate(this);
 }
 private void updateErrors() {
   if ((currentOperator != null) && onlyCurrent.isSelected()) {
     fill(currentOperator);
   } else {
     if (currentProcess != null) {
       fill(currentProcess.getRootOperator());
     }
   }
 }
 /**
  * Moves an operator to the given index. (If the old index is smaller than the new one, the new
  * one will automatically be reduced by one.)
  */
 public void moveToIndex(Operator op, int newIndex) {
   int oldIndex = operators.indexOf(op);
   Process process = getEnclosingOperator().getProcess();
   if (oldIndex != -1) {
     operators.remove(op);
     if (process != null) {
       int oldIndexAmongEnabled = getEnabledOperators().indexOf(op);
       process.fireOperatorRemoved(op, oldIndex, oldIndexAmongEnabled);
     }
     if (oldIndex < newIndex) {
       newIndex--;
     }
     operators.add(newIndex, op);
     if (process != null) {
       process.fireOperatorAdded(op);
     }
     fireUpdate();
     updateExecutionOrder();
   }
 }
Exemplo n.º 9
0
  public static void createBugReport(
      File reportFile,
      Throwable exception,
      String userMessage,
      Process process,
      String logMessage,
      File[] attachments)
      throws IOException {
    ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(reportFile));
    zipOut.setComment("RapidMiner bug report - generated " + new Date());
    write("message.txt", "User message", userMessage, zipOut);
    write("_process.xml", "Process as in memory.", process.getRootOperator().getXML(false), zipOut);
    if (process.getProcessLocation() != null) {
      try {
        String contents = process.getProcessLocation().getRawXML();
        write(
            process.getProcessLocation().getShortName(),
            "Raw process file in repository.",
            contents,
            zipOut);
      } catch (Throwable t) {
        write(
            process.getProcessLocation().getShortName(),
            "Raw process file in repository.",
            "could not read: " + t,
            zipOut);
      }
    }
    write("_log.txt", "Log message", logMessage, zipOut);
    write(
        "_properties.txt",
        "System properties, information about java version and operating system",
        getProperties(),
        zipOut);
    write("_exception.txt", "Exception stack trace", getStackTrace(exception), zipOut);

    for (File attachment : attachments) {
      writeFile(attachment, zipOut);
    }
    zipOut.close();
  }
  /**
   * Sets the process and the editable parameters.
   *
   * @param parameters A list of String[2] where the first String is the name of the operator and
   *     the second is the name of the parameter.
   */
  public boolean setProcess(Process process, Collection<OperatorParameterPair> parameters) {
    if (process == null) {
      parameters = new LinkedList<OperatorParameterPair>(); // enforce arraylengths = 0
    }
    updateTableData(parameters.size());

    operators = new Operator[parameters.size()];
    parameterTypes = new ParameterType[parameters.size()];

    Iterator<OperatorParameterPair> i = parameters.iterator();
    int j = 0;
    while (i.hasNext()) {
      OperatorParameterPair parameter = i.next();
      Operator operator = process.getOperator(parameter.getOperator());
      operators[j] = operator;
      ParameterType parameterType = getParameterType(operator, parameter.getParameter());
      if (operator == null || parameterType == null) {
        updateTableData(0); // enforce size of 0
        return false;
      }
      parameterTypes[j] = parameterType;
      getModel().setValueAt(operator.getName() + "." + parameterTypes[j].getKey(), j, 0);
      Object value = parameterTypes[j].getDefaultValue();
      try {
        value = operator.getParameters().getParameter(parameterTypes[j].getKey());
      } catch (UndefinedParameterError e) {
        // tries non default value. Fail --> default
      }
      getModel().setValueAt(value, j, 1);
      j++;
    }
    updateEditorsAndRenderers();

    getModel()
        .addTableModelListener(
            new TableModelListener() {
              public void tableChanged(TableModelEvent e) {
                setValue(e.getFirstRow(), getModel().getValueAt(e.getFirstRow(), 1));
              }
            });
    return true;
  }
Exemplo n.º 11
0
 public Operator getRootOperator() {
   if (process != null) {
     return process.getRootOperator();
   }
   return null;
 }
Exemplo n.º 12
0
 @Override
 public void processEnded(Process process) {
   enableActions();
   mainFrame.RUN_ACTION.setState(process.getProcessState());
 }
  /**
   * Displays a warning bubble that alerts the user that he failed to connect any of the process
   * result ports.
   *
   * <p>The bubble is located at the first result port of the outermost process and the process view
   * will change to said port. The {@link ResultWarningPreventionRegistry} contains a list with
   * Operators which can suppress this warning.
   *
   * @param process the process in question
   * @return the {@link PortInfoBubble} instance, never {@code null}
   */
  public static PortInfoBubble displayPrecheckNoResultPortInformation(final Process process) {
    if (process == null) {
      throw new IllegalArgumentException("port must not be null!");
    }

    Port firstResultPort =
        process.getRootOperator().getSubprocess(0).getInnerSinks().getPortByIndex(0);
    JButton ackButton =
        new JButton(I18N.getGUIMessage("gui.bubble.process_unconnected_result_port.button.label"));
    ackButton.setToolTipText(
        I18N.getGUIMessage("gui.bubble.process_unconnected_result_port.button.tip"));

    final BubbleDelegator bubbleDelegator = new BubbleDelegator();
    ResourceAction runAnywayAction =
        new ResourceAction("process_unconnected_result_port.button_run_anyway", "F11") {

          private static final long serialVersionUID = 1L;

          @Override
          public void actionPerformed(final ActionEvent e) {
            BubbleWindow bubble = bubbleDelegator.getBubble();
            if (bubble != null) {
              bubble.killBubble(true);
            }

            // run process without checking for problems
            RapidMinerGUI.getMainFrame().runProcess(false);
          }
        };
    LinkButton runAnywayButton = new LinkButton(runAnywayAction);
    runAnywayButton.setToolTipText(
        I18N.getGUIMessage("gui.bubble.process_unconnected_result_port.button_run_anyway.tip"));
    runAnywayButton.registerKeyboardAction(
        runAnywayAction,
        KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0),
        JComponent.WHEN_IN_FOCUSED_WINDOW);

    PortBubbleBuilder builder =
        new PortBubbleBuilder(
            RapidMinerGUI.getMainFrame(), firstResultPort, "process_unconnected_result_port");
    final PortInfoBubble noResultConnectionBubble =
        builder
            .setHideOnConnection(true)
            .setAlignment(AlignedSide.LEFT)
            .setStyle(BubbleStyle.WARNING)
            .setHideOnProcessRun(false)
            .setEnsureVisible(true)
            .hideCloseButton()
            .setAdditionalComponents(new JComponent[] {ackButton, runAnywayButton})
            .build();
    ackButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            noResultConnectionBubble.killBubble(true);
          }
        });
    bubbleDelegator.setBubbleWindow(noResultConnectionBubble);

    noResultConnectionBubble.setVisible(true);
    return noResultConnectionBubble;
  }