@Override public void run(ITextSelection selection) { if (!ActionUtil.isEditable(fEditor)) return; RefactoringExecutionStarter.startChangeTypeRefactoring( SelectionConverter.getInputAsCompilationUnit(fEditor), getShell(), selection.getOffset(), selection.getLength()); }
@Override public void run(ITextSelection selection) { if (!ActionUtil.isEditable(fEditor)) return; ConvertGroovyLocalToFieldRefactoring refactoring = new ConvertGroovyLocalToFieldRefactoring( fEditor.getGroovyCompilationUnit(), selection.getOffset(), selection.getLength()); new RefactoringStarter() .activate( new PromoteTempWizard(refactoring), getShell(), RefactoringMessages.ConvertLocalToField_title, RefactoringSaveHelper.SAVE_NOTHING); }
@Override public void run(IStructuredSelection selection) { try { IMember member = getMember(selection); if (member == null || !ActionUtil.isEditable(getShell(), member)) return; ISourceRange range = member.getNameRange(); RefactoringExecutionStarter.startChangeTypeRefactoring( member.getCompilationUnit(), getShell(), range.getOffset(), range.getLength()); } catch (CoreException e) { ExceptionHandler.handle( e, RefactoringMessages.ChangeTypeAction_dialog_title, RefactoringMessages.ChangeTypeAction_exception); } }
/** * Try to execute the correction command. * * @return <code>true</code> iff the correction could be started * @since 3.6 */ public boolean doExecute() { ISelection selection = fEditor.getSelectionProvider().getSelection(); ICompilationUnit cu = JavaUI.getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput()); IAnnotationModel model = JavaUI.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput()); if (selection instanceof ITextSelection && cu != null && model != null) { if (!ActionUtil.isEditable(fEditor)) { return false; } ICompletionProposal proposal = findCorrection(fId, fIsAssist, (ITextSelection) selection, cu, model); if (proposal != null) { invokeProposal(proposal, ((ITextSelection) selection).getOffset()); return true; } } return false; }