public void actionPerformed(ActionEvent e) {
   Operator selectedOperator = this.actions.getSelectedOperator();
   if (selectedOperator != null) {
     NewBuildingBlockDialog dialog = new NewBuildingBlockDialog();
     dialog.setVisible(true);
     if (dialog.isOk()) {
       try {
         BuildingBlock buildingBlock = dialog.getSelectedBuildingBlock();
         if (buildingBlock != null) {
           String xmlDescription = buildingBlock.getXML();
           try {
             InputSource source = new InputSource(new StringReader(xmlDescription));
             Document document =
                 DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(source);
             Element element = document.getDocumentElement();
             Operator operator =
                 Operator.createFromXML(
                     element,
                     actions.getProcess(),
                     new LinkedList<UnknownParameterInformation>(),
                     null,
                     XMLImporter.CURRENT_VERSION);
             operator.setUserDescription(buildingBlock.getDescription());
             actions.insert(Collections.singletonList(operator));
           } catch (Exception ex) {
             SwingTools.showSimpleErrorMessage(
                 "cannot_instantiate_building_block", ex, buildingBlock.getName());
           }
         }
       } catch (Exception ex) {
         SwingTools.showSimpleErrorMessage("cannot_instantiate_building_block", ex);
       }
     }
   }
 }
 @Override
 public void actionPerformed(ActionEvent e) {
   String loc =
       RepositoryLocationChooser.selectLocation(
           lastLocation, "", RapidMinerGUI.getMainFrame(), true, false, true, true, true);
   if (loc != null) {
     RepositoryLocation location;
     try {
       location = new RepositoryLocation(loc);
     } catch (Exception ex) {
       SwingTools.showSimpleErrorMessage("malformed_rep_location", ex, loc);
       return;
     }
     try {
       if (location.locateEntry() != null) {
         // overwrite?
         if (SwingTools.showConfirmDialog("overwrite", ConfirmDialog.YES_NO_OPTION, location)
             != ConfirmDialog.YES_OPTION) {
           return;
         }
       }
       RepositoryManager.getInstance(null).store(object, location, null);
       lastLocation = location;
     } catch (RepositoryException ex) {
       SwingTools.showSimpleErrorMessage("cannot_store_obj_at_location", ex, loc);
     }
   }
 }
 @Override
 public void valueForPathChanged(TreePath path, Object newValue) {
   try {
     ((Entry) path.getLastPathComponent()).rename(newValue.toString());
   } catch (Exception e) {
     SwingTools.showSimpleErrorMessage("error_rename", e, e.toString());
   }
 }
 @Override
 public void save(BlobEntry entry) {
   try {
     save(entry.openOutputStream(LIBRARY_MIME_TYPE));
   } catch (RepositoryException e) {
     SwingTools.showSimpleErrorMessage("cannot_access_repository", e);
   }
 }
 @Override
 protected void ok() {
   try {
     chooser.getRepositoryLocation();
     super.ok();
   } catch (MalformedRepositoryLocationException e) {
     SwingTools.showSimpleErrorMessage("malformed_repository_location", e, e.getMessage());
   }
 }
 @Override
 public void createConfigurationWizard(ParameterType type, ConfigurationListener listener) {
   ExcelExampleSource sourceOperator = (ExcelExampleSource) listener;
   try {
     new ExcelImportWizard(sourceOperator, listener, null).setVisible(true);
   } catch (OperatorException e) {
     SwingTools.showSimpleErrorMessage("importwizard.error_creating_wizard", e);
   }
 }
예제 #7
0
 @Override
 public void performAction(OperatorDescription description) {
   try {
     Operator operator = OperatorService.createOperator(description);
     RapidMinerGUI.getMainFrame().getActions().insert(Collections.singletonList(operator));
   } catch (Exception e) {
     SwingTools.showSimpleErrorMessage("cannot_instantiate", e, description.getName());
   }
 }
 private void save() {
   File file = SwingTools.chooseFile(null, null, true, "wgt", "attribute weight file");
   try {
     attributeTableModel
         .getAttributeWeights()
         .writeAttributeWeights(file, Tools.getDefaultEncoding());
   } catch (IOException e) {
     SwingTools.showSimpleErrorMessage("cannot_write_attr_weights_to_file", e, file.getName());
   }
 }
 private void load() {
   File file = SwingTools.chooseFile(null, null, true, "wgt", "attribute weight file");
   try {
     AttributeWeights fileWeights = AttributeWeights.load(file);
     attributeTableModel.mergeWeights(fileWeights);
   } catch (IOException e) {
     SwingTools.showSimpleErrorMessage("cannot_load_attr_weights_from_file", e, file.getName());
   }
   update();
 }
 @Override
 public void actionPerformed(ActionEvent e) {
   File file =
       SwingTools.chooseFile(
           RapidMinerGUI.getMainFrame(),
           "export_process",
           null,
           false,
           false,
           new String[] {RapidMiner.PROCESS_FILE_EXTENSION, "xml"},
           new String[] {"Process File", "Process File"});
   if (file == null) {
     return;
   }
   try {
     new FileProcessLocation(file).store(RapidMinerGUI.getMainFrame().getProcess(), null);
   } catch (IOException e1) {
     SwingTools.showSimpleErrorMessage(
         "cannot_save_process",
         e1,
         RapidMinerGUI.getMainFrame().getProcess().getProcessLocation(),
         e1.getMessage());
   }
 }
예제 #11
0
  private void storeInFolder(final Folder folder) {
    // get current process name (if present)
    String currentName = null;
    if (RapidMinerGUI.getMainFrame().getProcess().getProcessLocation() != null) {
      currentName = RapidMinerGUI.getMainFrame().getProcess().getProcessLocation().getShortName();
    }

    final String name = SwingTools.showRepositoryEntryInputDialog("store_process", currentName);
    if (name != null) {
      if (name.isEmpty()) {
        SwingTools.showVerySimpleErrorMessage("please_enter_non_empty_name");
        return;
      }
      try {
        // check if folder already contains entry with said name
        RepositoryLocation entryLocation = new RepositoryLocation(folder.getLocation(), name);
        if (folder.containsEntry(name)) {
          Entry existingEntry = entryLocation.locateEntry();
          if (!(existingEntry instanceof ProcessEntry)) {
            // existing entry is not a ProcessEntry, cannot overwrite
            SwingTools.showVerySimpleErrorMessage("repository_entry_already_exists", name);
            return;
          } else {
            // existing entry is ProcessEntry,let #overwriteProcess() handle it
            overwriteProcess((ProcessEntry) existingEntry);
            return;
          }
        }
      } catch (RepositoryException e1) {
        SwingTools.showSimpleErrorMessage("cannot_store_process_in_repository", e1, name);
        return;
      } catch (MalformedRepositoryLocationException e1) {
        SwingTools.showSimpleErrorMessage("cannot_store_process_in_repository", e1, name);
        return;
      }

      ProgressThread storeProgressThread =
          new ProgressThread("store_process") {

            public void run() {
              getProgressListener().setTotal(100);
              Process process = RapidMinerGUI.getMainFrame().getProcess();
              RepositoryProcessLocation processLocation = null;
              try {
                processLocation =
                    new RepositoryProcessLocation(
                        new RepositoryLocation(folder.getLocation(), name));
                getProgressListener().setCompleted(10);
                Process.checkIfSavable(process);
                folder.createProcessEntry(name, process.getRootOperator().getXML(false));
                process.setProcessLocation(processLocation);
                tree.expandPath(tree.getSelectionPath());
                RapidMinerGUI.addToRecentFiles(process.getProcessLocation());
                RapidMinerGUI.getMainFrame().processHasBeenSaved();
              } catch (Exception e) {
                SwingTools.showSimpleErrorMessage(
                    "cannot_save_process", e, processLocation, e.getMessage());
                RapidMinerGUI.getMainFrame().getProcess().setProcessLocation(null);
              } finally {
                getProgressListener().setCompleted(10);
                getProgressListener().complete();
              }
            }
          };
      storeProgressThread.start();
    }
  }
  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);
  }