private void run(ICompilationUnit cu) { if (!ActionUtil.isEditable(fEditor, getShell(), cu)) return; ICleanUp[] cleanUps= getCleanUps(new ICompilationUnit[] { cu }); if (cleanUps == null) return; if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null)) return; try { performRefactoring(new ICompilationUnit[] { cu }, cleanUps); } catch (InvocationTargetException e) { JavaPlugin.log(e); if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException)e.getCause()); } }
private void run(ICompilationUnit cu) { if (!ActionUtil.isEditable(fEditor, getShell(), cu)) return; ICleanUp[] cleanUps= getCleanUps(new ICompilationUnit[] { cu }); if (cleanUps == null) return; if (!ElementValidator.check(cu, getShell(), getActionName(), fEditor != null)) return; try { performRefactoring(new ICompilationUnit[] { cu }, cleanUps); } catch (InvocationTargetException e) { JavaPlugin.log(e); if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException)e.getCause()); } }
private void runOnMultiple(final ICompilationUnit[] cus) { ICleanUp[] cleanUps= getCleanUps(cus); if (cleanUps == null) return; MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null); for (int i= 0; i < cus.length; i++) { ICompilationUnit cu= cus[i]; if (!ActionUtil.isOnBuildPath(cu)) { String cuLocation= BasicElementLabels.getPathLabel(cu.getPath(), false); String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); } } if (!status.isOK()) { ErrorDialog.openError(getShell(), getActionName(), null, status); return; } try { performRefactoring(cus, cleanUps); } catch (InvocationTargetException e) { JavaPlugin.log(e); if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException)e.getCause()); } }
private void runOnMultiple(final ICompilationUnit[] cus) { ICleanUp[] cleanUps= getCleanUps(cus); if (cleanUps == null) return; MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null); for (int i= 0; i < cus.length; i++) { ICompilationUnit cu= cus[i]; if (!ActionUtil.isOnBuildPath(cu)) { String cuLocation= BasicElementLabels.getPathLabel(cu.getPath(), false); String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); } } if (!status.isOK()) { ErrorDialog.openError(getShell(), getActionName(), null, status); return; } try { performRefactoring(cus, cleanUps); } catch (InvocationTargetException e) { JavaPlugin.log(e); if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException)e.getCause()); } }