コード例 #1
0
 public int open() {
   try {
     ensureConsistency();
   } catch (InvocationTargetException e) {
     ExceptionHandler.handle(
         e,
         JavaUIMessages.TypeSelectionDialog_error3Title,
         JavaUIMessages.TypeSelectionDialog_error3Message);
     return CANCEL;
   } catch (InterruptedException e) {
     // cancelled by user
     return CANCEL;
   }
   if (fInitialFilter == null) {
     IWorkbenchWindow window = JavaScriptPlugin.getActiveWorkbenchWindow();
     if (window != null) {
       ISelection selection = window.getSelectionService().getSelection();
       if (selection instanceof ITextSelection) {
         String text = ((ITextSelection) selection).getText();
         if (text != null) {
           text = text.trim();
           if (text.length() > 0
               && JavaScriptConventions.validateJavaScriptTypeName(
                       text, JavaScriptCore.VERSION_1_3, JavaScriptCore.VERSION_1_3)
                   .isOK()) {
             fInitialFilter = text;
             fSelectionMode = FULL_SELECTION;
           }
         }
       }
     }
   }
   return super.open();
 }
 /*
  * @see ICompletionProposal#apply(IDocument)
  */
 public void apply(IDocument document) {
   try {
     performChange(JavaScriptPlugin.getActivePage().getActiveEditor(), document);
   } catch (CoreException e) {
     ExceptionHandler.handle(
         e,
         CorrectionMessages.ChangeCorrectionProposal_error_title,
         CorrectionMessages.ChangeCorrectionProposal_error_message);
   }
 }
 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.getJavaScriptUnit(), getShell(), range.getOffset(), range.getLength());
   } catch (CoreException e) {
     ExceptionHandler.handle(
         e,
         RefactoringMessages.ChangeTypeAction_dialog_title,
         RefactoringMessages.ChangeTypeAction_exception);
   }
 }
 /*
  * (non-Javadoc) Method declared on SelectionDispatchAction
  */
 public void run(ITextSelection selection) {
   if (!ActionUtil.isEditable(fEditor)) return;
   try {
     RefactoringExecutionStarter.startChangeTypeRefactoring(
         SelectionConverter.getInputAsCompilationUnit(fEditor),
         getShell(),
         selection.getOffset(),
         selection.getLength());
   } catch (CoreException e) {
     ExceptionHandler.handle(
         e,
         RefactoringMessages.ChangeTypeAction_dialog_title,
         RefactoringMessages.ChangeTypeAction_exception);
   }
 }
 protected void handleFinishException(Shell shell, InvocationTargetException e) {
   String title = NewWizardMessages.JavaProjectWizard_op_error_title;
   String message = NewWizardMessages.JavaProjectWizard_op_error_create_message;
   ExceptionHandler.handle(e, getShell(), title, message);
 }