public void setLevel(Level level) {
   LogService.getRoot().setLevel(level);
   handler.setLevel(level);
   ParameterService.setParameterValue(
       MainFrame.PROPERTY_RAPIDMINER_GUI_LOG_LEVEL, level.getName());
   ParameterService.saveParameters();
 }
 static {
   String colorStr =
       ParameterService.getParameterValue(
           MainFrame.PROPERTY_RAPIDMINER_GUI_MESSAGEVIEWER_HIGHLIGHT_LOGSERVICE);
   if (colorStr != null) {
     COLOR_DEFAULT = ParameterTypeColor.string2Color(colorStr);
   } else {
     COLOR_DEFAULT = Color.BLACK;
   }
   colorStr =
       ParameterService.getParameterValue(
           MainFrame.PROPERTY_RAPIDMINER_GUI_MESSAGEVIEWER_HIGHLIGHT_NOTES);
   if (colorStr != null) {
     COLOR_INFO = ParameterTypeColor.string2Color(colorStr);
   } else {
     COLOR_INFO = Color.BLACK;
   }
   colorStr =
       ParameterService.getParameterValue(
           MainFrame.PROPERTY_RAPIDMINER_GUI_MESSAGEVIEWER_HIGHLIGHT_WARNINGS);
   if (colorStr != null) {
     COLOR_WARNING = ParameterTypeColor.string2Color(colorStr);
   } else {
     COLOR_WARNING = Color.BLACK;
   }
   colorStr =
       ParameterService.getParameterValue(
           MainFrame.PROPERTY_RAPIDMINER_GUI_MESSAGEVIEWER_HIGHLIGHT_ERRORS);
   if (colorStr != null) {
     COLOR_ERROR = ParameterTypeColor.string2Color(colorStr);
   } else {
     COLOR_ERROR = Color.BLACK;
   }
 }
  public static String selectLocation(
      RepositoryLocation resolveRelativeTo,
      String initialValue,
      Component c,
      final boolean selectEntries,
      final boolean selectFolder,
      final boolean forceDisableRelativeResolve,
      final boolean enforceValidRepositoryEntryName,
      final boolean onlyWriteableRepositories) {
    final RepositoryLocationChooserDialog dialog =
        new RepositoryLocationChooserDialog(
            resolveRelativeTo,
            initialValue,
            selectEntries,
            selectFolder,
            onlyWriteableRepositories);
    if (forceDisableRelativeResolve) {
      dialog.chooser.setResolveRelative(false);
      if (dialog.chooser.resolveBox != null) {
        dialog.chooser.resolveBox.setVisible(false);
      }
    }
    dialog.chooser.setEnforceValidRepositoryEntryName(enforceValidRepositoryEntryName);
    if (enforceValidRepositoryEntryName) {
      dialog.chooser.locationFieldRepositoryEntry.addObserver(dialog, true);
    }
    dialog.setVisible(true);

    // if user has used double click to submit
    if (dialog.userSelection != null) {
      return dialog.userSelection;
    }
    if (dialog.wasConfirmed()) {
      if (resolveRelativeTo != null && !forceDisableRelativeResolve) {
        ParameterService.setParameterValue(
            RapidMinerGUI.PROPERTY_RESOLVE_RELATIVE_REPOSITORY_LOCATIONS,
            dialog.chooser.resolveRelative() ? "true" : "false");
        ParameterService.saveParameters();
      }
      String text;
      try {
        text = dialog.chooser.getRepositoryLocation();
      } catch (MalformedRepositoryLocationException e) {
        // this should not happen since the dialog would not have disposed without an error message.
        throw new RuntimeException(e);
      }
      if (text.length() > 0) {
        return text;
      } else {
        return null;
      }
    } else {
      return null;
    }
  }
  /** Trains a model using an ExampleSet from the input. Uses the method learn(ExampleSet). */
  @Override
  public void doWork() throws OperatorException {
    ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

    // some checks
    if (exampleSet.getAttributes().getLabel() == null) {
      throw new UserError(this, 105, new Object[0]);
    }
    if (exampleSet.getAttributes().size() == 0) {
      throw new UserError(this, 106, new Object[0]);
    }

    // check capabilities and produce errors if they are not fulfilled
    CapabilityCheck check =
        new CapabilityCheck(
            this,
            Tools.booleanValue(
                ParameterService.getParameterValue(
                    CapabilityProvider.PROPERTY_RAPIDMINER_GENERAL_CAPABILITIES_WARN),
                true));
    check.checkLearnerCapabilities(this, exampleSet);

    Model model = learn(exampleSet);

    modelOutput.deliver(model);
    exampleSetOutput.deliver(exampleSet);
  }
  public String getErrorName() {
    String deflt = "Unnamed plotter error.";
    if (Boolean.valueOf(
        ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEBUGMODE))) {
      deflt += " (" + errorId + ")";
    }

    return getResourceString(errorId, NAME_KEY, deflt);
  }
示例#6
0
  public SettingsTabs(String initialSelectedTab) {
    Collection<String> definedParameterKeys = ParameterService.getDefinedParameterKeys();
    SortedMap<String, List<ParameterType>> groups = new TreeMap<String, List<ParameterType>>();

    for (String key : definedParameterKeys) {
      String group = ParameterService.getGroupKey(key);

      List<ParameterType> groupTypeList = groups.get(group);
      if (groupTypeList == null) {
        groupTypeList = new LinkedList<ParameterType>();
        groups.put(group, groupTypeList);
      }
      groupTypeList.add(ParameterService.getParameterType(key));
    }

    for (Entry<String, List<ParameterType>> entry : groups.entrySet()) {
      List<ParameterType> lists = entry.getValue();
      Collections.sort(
          lists,
          new Comparator<ParameterType>() {
            @Override
            public int compare(ParameterType o1, ParameterType o2) {
              return o1.getKey().compareTo(o2.getKey());
            }
          });
      SettingsPropertyPanel table = new SettingsPropertyPanel(lists);
      parameterPanels.add(table);

      ExtendedJScrollPane scrollPane = new ExtendedJScrollPane(table);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
      scrollPane.setPreferredSize(new Dimension(600, 300));

      String group = entry.getKey();
      String name =
          new String(new char[] {group.charAt(0)}).toUpperCase()
              + group.substring(1, group.length());
      addTab(name, scrollPane);
    }
  }
 private static Level getSpecifiedLogLevelIndex() {
   String value = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_LOG_LEVEL);
   if (value == null) {
     return Level.CONFIG;
   } else {
     for (int i = 0; i < SELECTABLE_LEVEL_NAMES.length; i++) {
       if (SELECTABLE_LEVEL_NAMES[i].equals(value)) {
         return SELECTABLE_LEVELS[i];
       }
     }
     return Level.CONFIG;
   }
 }
  @Override
  public void windowClosed(WindowEvent e) {
    boolean betaActiveNow =
        Boolean.parseBoolean(
            ParameterService.getParameterValue(
                RapidMiner.PROPERTY_RAPIDMINER_UPDATE_BETA_FEATURES));
    if (!betaActiveBefore && betaActiveNow) {
      JTextArea textArea = new JTextArea();
      textArea.setColumns(60);
      textArea.setRows(15);
      textArea.setLineWrap(true);
      textArea.setWrapStyleWord(true);
      textArea.setEditable(false);
      textArea.setText(loadBetaEULA());
      textArea.setBorder(null);
      textArea.setCaretPosition(0);

      JScrollPane scrollPane = new ExtendedJScrollPane(textArea);
      scrollPane.setBorder(BorderFactory.createLineBorder(Colors.TEXTFIELD_BORDER));

      ButtonDialog dialog =
          new ButtonDialogBuilder("beta_features_eula")
              .setOwner(ApplicationFrame.getApplicationFrame())
              .setButtons(DefaultButtons.OK_BUTTON, DefaultButtons.CANCEL_BUTTON)
              .setModalityType(ModalityType.APPLICATION_MODAL)
              .setContent(scrollPane, ButtonDialog.DEFAULT_SIZE)
              .build();
      dialog.setVisible(true);
      if (!dialog.wasConfirmed()) {
        ParameterService.setParameterValue(
            RapidMiner.PROPERTY_RAPIDMINER_UPDATE_BETA_FEATURES, String.valueOf(false));
        ActionStatisticsCollector.INSTANCE.log(
            ActionStatisticsCollector.TYPE_BETA_FEATURES,
            ActionStatisticsCollector.VALUE_BETA_FEATURES_ACTIVATION,
            "cancelled");
      }
    }
  }
 public static void main(String[] args) {
   RapidMiner.class.getName();
   ParameterService.init();
   try {
     new RapidAnalyticsCLTool(args).run();
   } catch (IllegalArgumentException e) {
     System.err.println(e.getMessage());
     System.exit(1);
   } catch (MalformedURLException e) {
     System.err.println(e.getMessage());
     System.exit(1);
   } catch (RepositoryException e) {
     System.err.println(e.getMessage());
     System.exit(1);
   }
 }
 {
   String encoding = RapidMiner.SYSTEM_ENCODING_NAME;
   String encodingProperty =
       ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEFAULT_ENCODING);
   if (encodingProperty != null) {
     encoding = encodingProperty;
   }
   encodingComboBox.setSelectedItem(encoding);
   encodingComboBox.setPreferredSize(new Dimension(encodingComboBox.getPreferredSize().width, 25));
   encodingComboBox.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           settingsChanged();
         }
       });
 }
  private LoggingViewer(JTextPane textArea) {
    super(new BorderLayout());
    final Level level = getSpecifiedLogLevelIndex();
    handler.setLevel(level);
    LogService.getRoot().setLevel(level);
    maxRows = 1000;
    try {
      String maxRowsString =
          ParameterService.getParameterValue(
              MainFrame.PROPERTY_RAPIDMINER_GUI_MESSAGEVIEWER_ROWLIMIT);
      if (maxRowsString != null) maxRows = Integer.parseInt(maxRowsString);
    } catch (NumberFormatException e) {
      // LogService.getGlobal().log("Bad integer format for property '', using default number of
      // maximum rows for logging (1000).", LogService.WARNING);
      LogService.getRoot()
          .log(
              Level.WARNING,
              "com.rapidminer.gui.tools.LoggingViewer.bad_integer_format_for_property");
    }

    this.textArea = textArea;
    this.textArea.setToolTipText(
        "Displays logging messages according to the current log verbosity (parameter of root operator).");
    this.textArea.setEditable(false);
    this.textArea.addMouseListener(this);
    this.textArea.setFont(this.textArea.getFont().deriveFont(Font.PLAIN));
    LogService.getRoot().addHandler(handler);

    JToolBar toolBar = new ExtendedJToolBar();
    toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
    toolBar.add(SAVE_LOGFILE_ACTION);
    toolBar.add(CLEAR_MESSAGE_VIEWER_ACTION);
    toolBar.add(SEARCH_ACTION);
    add(toolBar, BorderLayout.NORTH);
    JScrollPane scrollPane = new ExtendedJScrollPane(textArea);
    scrollPane.setBorder(null);
    add(scrollPane, BorderLayout.CENTER);
  }
 protected PerformanceVector getPerformance(boolean cloneInput) {
   try {
     inputExtender.passDataThrough();
     executeSubprocess();
     if (isPerformanceRequired()) {
       return getPerformanceInnerSink().getData(PerformanceVector.class);
     } else {
       return getPerformanceInnerSink().getDataOrNull(PerformanceVector.class);
     }
   } catch (OperatorException e) {
     StringBuilder builder = new StringBuilder();
     builder.append(this.getName());
     builder.append(
         ": Cannot evaluate performance for current parameter combination because of an error in one of the inner operators: ");
     builder.append(e.getMessage());
     getLogger().severe(builder.toString());
     //            getLogger().severe("Cannot evaluate performance for current parameter
     // combination: " + e.getMessage());
     if (Boolean.parseBoolean(
         ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEBUGMODE)))
       e.printStackTrace();
     return null;
   }
 }
  public RepositoryLocationChooser(
      Dialog owner,
      RepositoryLocation resolveRelativeTo,
      String initialValue,
      final boolean allowEntries,
      final boolean allowFolders,
      boolean enforceValidRepositoryEntryName,
      final boolean onlyWriteableRepositories) {
    if (initialValue != null) {
      try {
        RepositoryLocation repositoryLocation;
        if (resolveRelativeTo != null) {
          repositoryLocation = new RepositoryLocation(resolveRelativeTo, initialValue);
        } else {
          repositoryLocation = new RepositoryLocation(initialValue);
        }
        locationField.setText(repositoryLocation.getName());
        locationFieldRepositoryEntry.setText(repositoryLocation.getName());
        resultLabel.setText(repositoryLocation.toString());
      } catch (Exception e) {
      }
    }
    this.resolveRelativeTo = resolveRelativeTo;
    this.enforceValidRepositoryEntryName = enforceValidRepositoryEntryName;
    tree = new RepositoryTree(owner, !allowEntries, onlyWriteableRepositories);

    if (initialValue != null) {
      if (tree.expandIfExists(resolveRelativeTo, initialValue)) {
        locationField.setText("");
        locationFieldRepositoryEntry.setText("");
      }
    }
    tree.getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {

              @Override
              public void valueChanged(TreeSelectionEvent e) {
                if (e.getPath() != null) {
                  currentEntry = (Entry) e.getPath().getLastPathComponent();
                  if (currentEntry instanceof Folder) { //  && allowFolders)) {
                    //						locationField.setText("");
                  } else if ((!(currentEntry instanceof Folder)) && allowEntries) {
                    //					if (true) {
                    //							//!(currentEntry instanceof Folder)) {
                    locationField.setText(currentEntry.getLocation().getName());
                    locationFieldRepositoryEntry.setText(currentEntry.getLocation().getName());
                  }
                  updateResult();
                }
              }
            });
    KeyListener keyListener =
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            updateResult();
          }

          @Override
          public void keyTyped(KeyEvent e) {
            TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
              Entry selectedEntry = (Entry) selectionPath.getLastPathComponent();
              if (!(selectedEntry instanceof Folder)) {
                tree.setSelectionPath(selectionPath.getParentPath());
              }
            }
          }
        };
    locationField.addKeyListener(keyListener);
    locationFieldRepositoryEntry.addKeyListener(keyListener);
    locationFieldRepositoryEntry.addObserver(this, true);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(0, 0, 0, 0);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridwidth = GridBagConstraints.REMAINDER;

    JScrollPane treePane = new ExtendedJScrollPane(tree);
    treePane.setBorder(ButtonDialog.createBorder());
    add(treePane, c);

    c.insets = new Insets(ButtonDialog.GAP, 0, 0, ButtonDialog.GAP);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 0;
    locationLabel = new ResourceLabel("repository_chooser.entry_name");
    locationLabel.setLabelFor(locationField);
    add(locationLabel, c);

    c.weightx = 1;
    c.insets = new Insets(ButtonDialog.GAP, 0, 0, 0);
    c.weightx = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(locationField, c);
    add(locationFieldRepositoryEntry, c);
    if (enforceValidRepositoryEntryName) {
      locationField.setVisible(false);
    } else {
      locationFieldRepositoryEntry.setVisible(false);
    }

    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 0;
    c.insets = new Insets(ButtonDialog.GAP, 0, 0, ButtonDialog.GAP);
    add(new ResourceLabel("repository_chooser.location"), c);
    c.weightx = 1;
    c.insets = new Insets(ButtonDialog.GAP, 0, 0, 0);
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(resultLabel, c);

    if (resolveRelativeTo != null) {
      resolveBox =
          new JCheckBox(
              new ResourceActionAdapter(
                  "repository_chooser.resolve", resolveRelativeTo.getAbsoluteLocation()));
      resolveBox.setSelected(
          ParameterService.getParameterValue(
                  RapidMinerGUI.PROPERTY_RESOLVE_RELATIVE_REPOSITORY_LOCATIONS)
              .equals("true"));
      add(resolveBox, c);
      resolveBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              updateResult();
            }
          });
    }
  }
  public ManageTemplatesDialog(MainFrame mainFrame) {
    super(mainFrame, "Manage Templates", true);

    JPanel rootPanel = new JPanel(new BorderLayout());
    rootPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    GridBagLayout layout = new GridBagLayout();
    JPanel mainPanel = new JPanel(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0d;
    c.weighty = 0.0d;

    JPanel textPanel =
        SwingTools.createTextPanel(
            "Manage Templates...",
            "Please select templates to delete them. Only "
                + "user defined templates can be removed.");
    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(textPanel, c);
    mainPanel.add(textPanel);

    Component sep = Box.createVerticalStrut(10);
    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(sep, c);
    mainPanel.add(sep);

    // add components to main panel
    File[] templateFiles =
        ParameterService.getUserRapidMinerDir()
            .listFiles(
                new FileFilter() {

                  public boolean accept(File file) {
                    return file.getName().endsWith(".template");
                  }
                });
    for (int i = 0; i < templateFiles.length; i++) {
      try {
        Template template = new Template(templateFiles[i]);
        templateMap.put(template.getName(), template);
      } catch (InstantiationException e) {
        SwingTools.showSimpleErrorMessage(
            "Cannot load template file '" + templateFiles[i] + "'", e);
      }
    }

    JScrollPane listPane = new ExtendedJScrollPane(templateList);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 1.0d;
    layout.setConstraints(listPane, c);
    mainPanel.add(listPane);
    c.weighty = 0.0d;

    // buttons
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton deleteButton = new JButton("Delete");
    deleteButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });
    buttonPanel.add(deleteButton);
    JButton okButton = new JButton("Ok");
    okButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            ok();
          }
        });
    buttonPanel.add(okButton);

    rootPanel.add(mainPanel, BorderLayout.CENTER);
    rootPanel.add(buttonPanel, BorderLayout.SOUTH);
    getContentPane().add(rootPanel);

    update();
    pack();
    setSize(250, 400);
    setLocationRelativeTo(mainFrame);
  }
示例#15
0
 /** This method will save the parameters defined in this tab */
 public void save() throws IOException {
   applyProperties();
   ParameterService.saveParameters();
 }
 /** Constructs a listener for beta features activation. */
 BetaFeaturesListener() {
   betaActiveBefore =
       Boolean.parseBoolean(
           ParameterService.getParameterValue(
               RapidMiner.PROPERTY_RAPIDMINER_UPDATE_BETA_FEATURES));
 }