public IStatus handle( final String id, final IToolRunnableControllerAdapter tools, final Map<String, Object> data, final IProgressMonitor monitor) { final String message; { String s = ToolEventHandlerUtil.getCheckedData(data, LOGIN_MESSAGE_DATA_KEY, String.class, false); if (s == null) { final IProgressInfo progressInfo = tools.getController().getProgressInfo(); s = NLS.bind("Select file (in {0}):", progressInfo.getLabel()); } message = s; } final Boolean newFile = ToolEventHandlerUtil.getCheckedData( data, "newResource", Boolean.class, true); // $NON-NLS-1$ final ToolProcess tool = tools.getController().getProcess(); final AtomicReference<IFileStore> file = new AtomicReference<IFileStore>(); final Runnable runnable = new Runnable() { public void run() { final SelectFileDialog dialog = new SelectFileDialog( UIAccess.getActiveWorkbenchShell(true), tool, message, newFile.booleanValue()); dialog.setBlockOnOpen(true); if (dialog.open() == Dialog.OK) { file.set(dialog.getResource()); } } }; UIAccess.getDisplay().syncExec(runnable); if (file.get() == null) { return Status.CANCEL_STATUS; } data.put("filename", file.get().toURI().toString()); // $NON-NLS-1$ return Status.OK_STATUS; }
@Override public IStatus handle( final String id, final IConsoleService tools, final Map<String, Object> data, final IProgressMonitor monitor) { if (id.equals(LOAD_HISTORY_ID)) { return loadHistory(tools, data, monitor); } if (id.equals(SAVE_HISTORY_ID)) { return saveHistory(tools, data, monitor); } if (id.equals(ADDTO_HISTORY_ID)) { final String item = ToolEventHandlerUtil.getCheckedData(data, "text", String.class, true); // $NON-NLS-1$ tools.getTool().getHistory().addCommand(item, tools.getController().getCurrentSubmitType()); return Status.OK_STATUS; } throw new UnsupportedOperationException(); }
protected IStatus saveHistory( final IConsoleService tools, final Map<String, Object> data, final IProgressMonitor monitor) { try { CoreException fileException = null; IFileStore fileStore = null; final IStatus status; final String filename = ToolEventHandlerUtil.getCheckedData(data, "filename", String.class, true); // $NON-NLS-1$ final ToolWorkspace workspaceData = tools.getWorkspaceData(); try { fileStore = workspaceData.toFileStore(filename); } catch (final CoreException e) { fileException = e; } if (fileStore == null) { status = new Status( IStatus.ERROR, NicoCore.PLUGIN_ID, -1, NLS.bind( Messages.ToolController_FileOperation_error_CannotResolve_message, filename), fileException); } else { status = tools .getTool() .getHistory() .save(fileStore, EFS.NONE, workspaceData.getEncoding(), false, monitor); } tools.handleStatus(status, monitor); return status; } catch (final OperationCanceledException e) { return Status.CANCEL_STATUS; } }