// MyDefect : Refactored private void displayErrorMessage(ResourceRefactorCommand rrcCommand) { // if there are problems, use the common error dialog to report them if (rrcCommand.getPostExecuteMessages() != null && rrcCommand.getPostExecuteMessages().size() > 0) { RefactorCommandProcessorDialog rcpdDialog = new RefactorCommandProcessorDialog( UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(), rrcCommand); rcpdDialog.open(); } }
@Override public void run(IAction action) { /* * 0. instantiate a move command * 1. instantiate the FileFolderMoveDialog * 2. 'init' it with: * - the selection * - the rename command * - a ModelContainerSelectionValidator * * 3. if dlg is ok, * a) set the destination (from the dialog) on the command * a) execute the move command * b) add the command to the UndoManager */ // create the move command, set the resource on it ResourceMoveCommand rmcCommand = new ResourceMoveCommand(); rmcCommand.setResource(resSelectedResource); rmcCommand.setImportHandler(new OrganizeImportHandlerDialog()); // cleanup modified files before starting this operation boolean bContinue = doResourceCleanup(); if (!bContinue) { return; } // check if anything wrong with dependents if (!checkDependentStatus(rmcCommand, resSelectedResource)) { return; } // create the dialog FileFolderMoveDialog ffmdDialog = new FileFolderMoveDialog( UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(), rmcCommand, resSelectedResource, new ModelExplorerContentProvider()); // launch the dialog ffmdDialog.open(); // if result is ok, finish the command and execute it if (ffmdDialog.getReturnCode() == Window.OK) { Object[] oSelectedObjects = ffmdDialog.getResult(); // add the user's selected destination to the command this.dest = (IContainer) oSelectedObjects[0]; rmcCommand.setDestination(this.dest); // Let's cache the auto-build and reset after. We don't want auto-building before the // refactoring is complete boolean autoBuildOn = ModelerCore.getWorkspace().isAutoBuilding(); if (autoBuildOn) { JobUtils.setAutoBuild(false); } // run it executeCommand(rmcCommand); if (autoBuildOn) { JobUtils.setAutoBuild(true); } // add the command to the Undo Manager (the manager will deal with whether // the command can be undone or not) if (getStatus() != null && getStatus().getSeverity() < IStatus.ERROR) { getRefactorUndoManager().addCommand(rmcCommand); } // if there are problems, use the common error dialog to report them if (rmcCommand.getPostExecuteMessages() != null && rmcCommand.getPostExecuteMessages().size() > 0) { // System.out.println( "[MoveRefactorAction.run] command has messages: " + // rmcCommand.getPostExecuteMessages().size() ); //$NON-NLS-1$ RefactorCommandProcessorDialog rcpdDialog = new RefactorCommandProcessorDialog( UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(), rmcCommand); rcpdDialog.open(); } else { // System.out.println( "[MoveRefactorAction.run] command has NO messages" ); // //$NON-NLS-1$ } } }