@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); } } }
public void locateExpandedEntries() { for (String absoluteLocation : expandedNodes) { try { RepositoryLocation repositoryLocation = new RepositoryLocation(absoluteLocation); repositoryLocation.locateEntry(); } catch (MalformedRepositoryLocationException e) { LogService.getRoot().warning("Unable to expand the location:" + absoluteLocation); e.printStackTrace(); } catch (RepositoryException e) { LogService.getRoot().warning("Unable to expand the location:" + absoluteLocation); e.printStackTrace(); } } }
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(); } }