public WorkbenchRConsole(RGui rgui) { super("> "); super.setSubmitInterface(new ConsoleSubmitInterface()); this.rgui = rgui; initConsoleActions(); initCommandSearch(); initCommandCompletion(); search.setVisible(false); centerPanel.add(search, BorderLayout.SOUTH); rgui.addConsole(CONSOLE_ID, this); }
public void actionPerformed(ActionEvent event) { final Vector<FileNode> toInstall = panel.getSelectedNodes(); final InstallPackageDialog packageDialog = new InstallPackageDialog(panel); packageDialog.setLibrary(rgui.getUser().getUserLibFolder()); if (toInstall.size() > 0) { new Thread( new Runnable() { public void run() { for (FileNode node : toInstall) { packageDialog.addPackage(node.getName()); } packageDialog.setVisible(true); if (packageDialog.getResult() == InstallPackageDialog.CANCEL) return; Operation installPackageOp = rgui.getOpManager().createOperation("Installing packages.."); int cnt = 0; int tot = toInstall.size(); String cmd0 = "R CMD INSTALL --library=" + packageDialog.getLibrary() + " " + packageDialog.getOptions() + " "; if (rgui.isRAvailable()) { installPackageOp.startOperation(); try { for (FileNode node : toInstall) { try { installPackageOp.startOperation("..."); try { installPackageOp.setProgress( 100 * cnt++ / tot, "installing " + node.getName()); } catch (OperationCancelledException oce) { break; } String cmd1 = cmd0 + " '" + node.getPath() + "'"; log.info("InstallPackageAction-cmd1=" + cmd1); rgui.obtainR().exec(cmd1); } catch (Exception ex) { // JOptionPaneExt.showExceptionDialog(panel.getParent(), ex); log.error("Problem during installation of " + node.getName(), ex); break; } finally { rgui.getRLock().unlock(); } } } finally { installPackageOp.completeOperation(); } } } }) .start(); } }
@Override public boolean isEnabled() { return (rgui.isRAvailable() && panel.getOutline().getSelectedRows().length > 0); }