org.eclipse.jdt.internal.ui.util.ExceptionHandler Java Examples

The following examples show how to use org.eclipse.jdt.internal.ui.util.ExceptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProblemSeveritiesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doBrowseTypes(StringButtonDialogField dialogField) {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText());
		dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title);
		dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			dialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message);
	}
}
 
Example #2
Source File: GotoTypeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Shell shell= JavaPlugin.getActiveWorkbenchShell();
	SelectionDialog dialog= null;
	try {
		dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
			SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
	} catch (JavaModelException e) {
		String title= getDialogTitle();
		String message= PackagesMessages.GotoType_error_message;
		ExceptionHandler.handle(e, title, message);
		return;
	}

	dialog.setTitle(getDialogTitle());
	dialog.setMessage(PackagesMessages.GotoType_dialog_message);
	if (dialog.open() == IDialogConstants.CANCEL_ID) {
		return;
	}

	Object[] types= dialog.getResult();
	if (types != null && types.length > 0) {
		gotoType((IType) types[0]);
	}
}
 
Example #3
Source File: AddJavaDocStubAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	IMember[] members= getSelectedMembers(selection);
	if (members == null || members.length == 0) {
		return;
	}

	try {
		ICompilationUnit cu= members[0].getCompilationUnit();
		if (!ActionUtil.isEditable(getShell(), cu)) {
			return;
		}

		// open the editor, forces the creation of a working copy
		IEditorPart editor= JavaUI.openInEditor(cu);

		if (ElementValidator.check(members, getShell(), getDialogTitle(), false))
			run(members);
		JavaModelUtil.reconcile(cu);
		EditorUtility.revealInEditor(editor, members[0]);

	} catch (CoreException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.AddJavaDocStubsAction_error_actionFailed);
	}
}
 
Example #4
Source File: AddJavaDocStubAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	try {
		IJavaElement element= SelectionConverter.getElementAtOffset(fEditor);
		if (!ActionUtil.isEditable(fEditor, getShell(), element))
			return;
		int type= element != null ? element.getElementType() : -1;
		if (type != IJavaElement.METHOD && type != IJavaElement.TYPE && type != IJavaElement.FIELD) {
	 		element= SelectionConverter.getTypeAtOffset(fEditor);
	 		if (element == null) {
				MessageDialog.openInformation(getShell(), getDialogTitle(),
					ActionMessages.AddJavaDocStubsAction_not_applicable);
				return;
	 		}
		}
		IMember[] members= new IMember[] { (IMember)element };
		if (ElementValidator.checkValidateEdit(members, getShell(), getDialogTitle()))
			run(members);
	} catch (CoreException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.AddJavaDocStubsAction_error_actionFailed);
	}
}
 
Example #5
Source File: MoveStaticMembersAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	try {
		IMember member= getSelectedMemberFromEditor();
		if (!ActionUtil.isEditable(fEditor, getShell(), member))
			return;
		IMember[] array= new IMember[]{member};
		if (member != null && RefactoringAvailabilityTester.isMoveStaticMembersAvailable(array)){
			RefactoringExecutionStarter.startMoveStaticMembersRefactoring(array, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.MoveMembersAction_unavailable);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #6
Source File: UseSupertypeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	try {
		if (!ActionUtil.isProcessable(fEditor))
			return;
		IType type= RefactoringActions.getEnclosingOrPrimaryType(fEditor);
		if (RefactoringAvailabilityTester.isUseSuperTypeAvailable(type)) {
			if (!ActionUtil.isEditable(getShell(), type))
				return;
			RefactoringExecutionStarter.startUseSupertypeRefactoring(type, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.UseSupertypeAction_to_activate);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #7
Source File: CallHierarchyUI.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static CallHierarchyViewPart openView(IMember[] input, IWorkbenchWindow window) {
  	if (input.length == 0) {
	MessageDialog.openInformation(window.getShell(), CallHierarchyMessages.CallHierarchyUI_selectionDialog_title,
			CallHierarchyMessages.CallHierarchyUI_open_operation_unavialable);
	return null;
}
      IWorkbenchPage page= window.getActivePage();
try {
	CallHierarchyViewPart viewPart= getDefault().findLRUCallHierarchyViewPart(page); //find the first view which is not pinned
	String secondaryId= null;
	if (viewPart == null) {
		if (page.findViewReference(CallHierarchyViewPart.ID_CALL_HIERARCHY) != null) //all the current views are pinned, open a new instance
			secondaryId= String.valueOf(++getDefault().fViewCount);
	} else
		secondaryId= viewPart.getViewSite().getSecondaryId();
	viewPart= (CallHierarchyViewPart)page.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
	viewPart.setInputElements(input);
	return viewPart;
      } catch (CoreException e) {
          ExceptionHandler.handle(e, window.getShell(),
              CallHierarchyMessages.CallHierarchyUI_error_open_view, e.getMessage());
      }
      return null;
  }
 
Example #8
Source File: CodeAssistFavoritesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doBrowseTypes() {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
		dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
		dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			fNameDialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
	}
}
 
Example #9
Source File: AddUnimplementedConstructorsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	Shell shell= getShell();
	try {
		IType type= getSelectedType(selection);
		if (type == null) {
			MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.AddUnimplementedConstructorsAction_not_applicable);
			return;
		}
		if (type.isAnnotation()) {
			MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.AddUnimplementedConstructorsAction_annotation_not_applicable);
			return;
		} else if (type.isInterface()) {
			MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.AddUnimplementedConstructorsAction_interface_not_applicable);
			return;
		} else if (type.isEnum()) {
			MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.AddUnimplementedConstructorsAction_enum_not_applicable);
			return;
		}
		run(shell, type, false);
	} catch (CoreException e) {
		ExceptionHandler.handle(e, shell, getDialogTitle(), null);
	}
}
 
Example #10
Source File: JarPackageWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Exports the JAR package.
 *
 * @param op the op
 * @return a boolean indicating success or failure
 */
protected boolean executeExportOperation(IJarExportRunnable op) {
	try {
		getContainer().run(true, true, op);
	} catch (InterruptedException e) {
		return false;
	} catch (InvocationTargetException ex) {
		if (ex.getTargetException() != null) {
			ExceptionHandler.handle(ex, getShell(), JarPackagerMessages.JarPackageWizard_jarExportError_title, JarPackagerMessages.JarPackageWizard_jarExportError_message);
			return false;
		}
	}
	IStatus status= op.getStatus();
	if (!status.isOK()) {
		ErrorDialog.openError(getShell(), JarPackagerMessages.JarPackageWizard_jarExport_title, null, status);
		return !(status.matches(IStatus.ERROR));
	}
	return true;
}
 
Example #11
Source File: OverrideIndicatorManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Opens and reveals the defining method.
 */
public void open() {
	CompilationUnit ast= SharedASTProvider.getAST(fJavaElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
	if (ast != null) {
		ASTNode node= ast.findDeclaringNode(fAstNodeKey);
		if (node instanceof MethodDeclaration) {
			try {
				IMethodBinding methodBinding= ((MethodDeclaration)node).resolveBinding();
				IMethodBinding definingMethodBinding= Bindings.findOverriddenMethod(methodBinding, true);
				if (definingMethodBinding != null) {
					IJavaElement definingMethod= definingMethodBinding.getJavaElement();
					if (definingMethod != null) {
						JavaUI.openInEditor(definingMethod, true, true);
						return;
					}
				}
			} catch (CoreException e) {
				ExceptionHandler.handle(e, JavaEditorMessages.OverrideIndicatorManager_open_error_title, JavaEditorMessages.OverrideIndicatorManager_open_error_messageHasLogEntry);
				return;
			}
		}
	}
	String title= JavaEditorMessages.OverrideIndicatorManager_open_error_title;
	String message= JavaEditorMessages.OverrideIndicatorManager_open_error_message;
	MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message);
}
 
Example #12
Source File: ReorgMoveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	if (ReorgUtils.containsOnlyProjects(selection.toList())) {
		createWorkbenchAction(selection).run();
		return;
	}
	try {
		List<?> elements= selection.toList();
		IResource[] resources= ReorgUtils.getResources(elements);
		IJavaElement[] javaElements= ReorgUtils.getJavaElements(elements);
		if (RefactoringAvailabilityTester.isMoveAvailable(resources, javaElements))
			RefactoringExecutionStarter.startMoveRefactoring(resources, javaElements, getShell());
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #13
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Object[] createFileListInput() {
	try {

		IPackageFragment fPkgFragment= fResourceBundlePackage.getSelected();
		if (fPkgFragment == null)
			return new Object[0];
		List<Object> result= new ArrayList<Object>(1);
		Object[] nonjava= fPkgFragment.getNonJavaResources();
		for (int i= 0; i < nonjava.length; i++) {
			if (isPropertyFile(nonjava[i]))
				result.add(nonjava[i]);
		}
		return result.toArray();

	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, NLSUIMessages.NLSAccessorConfigurationDialog_externalizing, NLSUIMessages .NLSAccessorConfigurationDialog_exception);
		return new Object[0];
	}
}
 
Example #14
Source File: ExternalizeWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static void open(final ICompilationUnit unit, final Shell shell) {
	if (unit == null || !unit.exists()) {
		return;
	}
	Display display= shell != null ? shell.getDisplay() : Display.getCurrent();
	BusyIndicator.showWhile(display, new Runnable() {
		public void run() {
			NLSRefactoring refactoring= null;
			try {
				refactoring= NLSRefactoring.create(unit);
			} catch (IllegalArgumentException e) {
				// Loading a properties file can throw an IAE due to malformed Unicode escape sequence, see Properties#load for details.
				IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), e.getLocalizedMessage());
				ExceptionHandler.handle(status,
						NLSUIMessages.ExternalizeWizard_name,
						NLSUIMessages.ExternalizeWizard_error_message);
			}
			if (refactoring != null)
				new RefactoringStarter().activate(new ExternalizeWizard(refactoring), shell, ActionMessages.ExternalizeStringsAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING);
		}
	});
}
 
Example #15
Source File: PullUpMethodPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void initializeTreeViewer(final IProgressMonitor pm) {
	try {
		pm.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 2);
		final IMember[] matchingMethods= fProcessor.getMatchingElements(new SubProgressMonitor(pm, 1), false);
		final ITypeHierarchy hierarchy= fProcessor.getDestinationTypeHierarchy(new SubProgressMonitor(pm, 1));
		removeAllTreeViewFilters();
		fTreeViewer.addFilter(new PullUpFilter(hierarchy, matchingMethods));
		fTreeViewer.setContentProvider(new PullUpHierarchyContentProvider(fProcessor.getDeclaringType(), matchingMethods));
		fTreeViewer.setInput(hierarchy);
		precheckElements(fTreeViewer);
		fTreeViewer.expandAll();
		updateSelectionLabel();
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.PullUpInputPage_pull_up1, RefactoringMessages.PullUpInputPage_exception);
		fTreeViewer.setInput(null);
	} finally {
		pm.done();
	}
}
 
Example #16
Source File: DeleteAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	if (ReorgUtils.containsOnlyProjects(selection.toList())) {
		createWorkbenchAction(selection).run();
		return;
	}
	if (ReorgUtils.containsOnlyWorkingSets(selection.toList())){
		deleteWorkingSets(selection);
		return;
	}
	try {
		RefactoringExecutionStarter.startDeleteRefactoring(selection.toArray(), getShell());
	} catch (CoreException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #17
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleOpen(OpenEvent event) {
	Object firstElement= ((IStructuredSelection)event.getSelection()).getFirstElement();
	if (firstElement instanceof ICompilationUnit ||
			firstElement instanceof IClassFile ||
			firstElement instanceof IMember) {
		if (getDisplayedMatchCount(firstElement) == 0) {
			try {
				fEditorOpener.openElement(firstElement);
			} catch (CoreException e) {
				ExceptionHandler.handle(e, getSite().getShell(), SearchMessages.JavaSearchResultPage_open_editor_error_title, SearchMessages.JavaSearchResultPage_open_editor_error_message);
			}
			return;
		}
	}
	super.handleOpen(event);
}
 
Example #18
Source File: PullUpAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void run(ITextSelection selection) {
	try {
		if (!ActionUtil.isEditable(fEditor))
			return;
		IMember member= getSelectedMemberFromEditor();
		IMember[] array= new IMember[] { member};
		if (member != null && RefactoringAvailabilityTester.isPullUpAvailable(array)) {
			RefactoringExecutionStarter.startPullUpRefactoring(array, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.PullUpAction_unavailable);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #19
Source File: ConvertNestedToTopAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	try {
		if (!ActionUtil.isEditable(fEditor))
			return;
		IType type= RefactoringAvailabilityTester.getDeclaringType(SelectionConverter.resolveEnclosingElement(fEditor, selection));
		if (type != null && RefactoringAvailabilityTester.isMoveInnerAvailable(type)) {
			RefactoringExecutionStarter.startMoveInnerRefactoring(type, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.ConvertNestedToTopAction_To_activate);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e,
			RefactoringMessages.OpenRefactoringWizardAction_refactoring,
			RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #20
Source File: InferTypeArgumentsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	IJavaElement[] elements= getSelectedElements(selection);
	try {
		if (! ActionUtil.areProcessable(getShell(), elements))
			return;

		if (RefactoringAvailabilityTester.isInferTypeArgumentsAvailable(elements)) {
			RefactoringExecutionStarter.startInferTypeArgumentsRefactoring(elements, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.InferTypeArgumentsAction_unavailable);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #21
Source File: InferTypeArgumentsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	if (!ActionUtil.isEditable(fEditor))
		return;
	IJavaElement element= SelectionConverter.getInput(fEditor);
	IJavaElement[] array= new IJavaElement[] {element};
	try {
		if (element != null && RefactoringAvailabilityTester.isInferTypeArgumentsAvailable(array)){
			RefactoringExecutionStarter.startInferTypeArgumentsRefactoring(array, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.InferTypeArgumentsAction_unavailable);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #22
Source File: AbstractOpenWizardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Shell shell= getShell();
	if (!doCreateProjectFirstOnEmptyWorkspace(shell)) {
		return;
	}
	try {
		INewWizard wizard= createWizard();
		wizard.init(PlatformUI.getWorkbench(), getSelection());

		WizardDialog dialog= new WizardDialog(shell, wizard);
		PixelConverter converter= new PixelConverter(JFaceResources.getDialogFont());
		dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
		dialog.create();
		int res= dialog.open();
		if (res == Window.OK && wizard instanceof NewElementWizard) {
			fCreatedElement= ((NewElementWizard)wizard).getCreatedElement();
		}

		notifyResult(res == Window.OK);
	} catch (CoreException e) {
		String title= NewWizardMessages.AbstractOpenWizardAction_createerror_title;
		String message= NewWizardMessages.AbstractOpenWizardAction_createerror_message;
		ExceptionHandler.handle(e, shell, title, message);
	}
}
 
Example #23
Source File: ImportOrganizeInputDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doBrowseTypes() {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
		dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title);
		dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_description);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			fNameDialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message);
	}
}
 
Example #24
Source File: MoveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(ITextSelection selection) {
	try {
		if (!ActionUtil.isEditable(fEditor))
			return;
		if (fMoveStaticMembersAction.isEnabled() && tryMoveStaticMembers(selection))
			return;

		if (fMoveInstanceMethodAction.isEnabled() && tryMoveInstanceMethod(selection))
			return;

		if (tryReorgMove())
			return;

		MessageDialog.openInformation(getShell(), RefactoringMessages.MoveAction_Move, RefactoringMessages.MoveAction_select);
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #25
Source File: ClassFileEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	fParent= new Composite(parent, SWT.NONE);
	fStackLayout= new StackLayout();
	fParent.setLayout(fStackLayout);

	fViewerComposite= new Composite(fParent, SWT.NONE);
	fViewerComposite.setLayout(new FillLayout());

	super.createPartControl(fViewerComposite);

	fStackLayout.topControl= fViewerComposite;
	fParent.layout();

	try {
		verifyInput(getEditorInput());
	} catch (CoreException e) {
		String title= JavaEditorMessages.ClassFileEditor_error_title;
		String message= JavaEditorMessages.ClassFileEditor_error_message;
		ExceptionHandler.handle(e, fParent.getShell(), title, message);
	}
}
 
Example #26
Source File: OpenJavaBrowsingPerspectiveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed);
	}
}
 
Example #27
Source File: ExtractSuperClassAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void run(final ITextSelection selection) {
	try {
		if (! ActionUtil.isEditable(fEditor))
			return;
		final IMember member= getSelectedMemberFromEditor();
		final IMember[] array= new IMember[] { member};
		if (member != null && RefactoringAvailabilityTester.isExtractSupertypeAvailable(array)) {
			RefactoringExecutionStarter.startExtractSupertypeRefactoring(array, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.ExtractSuperTypeAction_unavailable);
		}
	} catch (JavaModelException exception) {
		ExceptionHandler.handle(exception, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}
 
Example #28
Source File: MoveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	try {
		if (fMoveInstanceMethodAction.isEnabled() && tryMoveInstanceMethod(selection))
			return;

		if (fMoveStaticMembersAction.isEnabled() && tryMoveStaticMembers(selection))
			return;

		if (fReorgMoveAction.isEnabled())
			fReorgMoveAction.run(selection);

	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}

}
 
Example #29
Source File: OverrideMethodsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run(IStructuredSelection selection) {
	try {
		final IType type= getSelectedType(selection);
		if (type == null) {
			MessageDialog.openInformation(getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_not_applicable);
			notifyResult(false);
			return;
		}
		if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isEditable(getShell(), type)) {
			notifyResult(false);
			return;
		}
		run(getShell(), type);
	} catch (CoreException exception) {
		ExceptionHandler.handle(exception, getShell(), getDialogTitle(), ActionMessages.OverrideMethodsAction_error_actionfailed);
	}
}
 
Example #30
Source File: PushDownAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void run(ITextSelection selection) {
	try {
		if (!ActionUtil.isEditable(fEditor))
			return;
		IMember member= getSelectedMemberFromEditor();
		IMember[] array= new IMember[] { member};
		if (member != null && RefactoringAvailabilityTester.isPushDownAvailable(array)) {
			RefactoringExecutionStarter.startPushDownRefactoring(array, getShell());
		} else {
			MessageDialog.openInformation(getShell(), RefactoringMessages.OpenRefactoringWizardAction_unavailable, RefactoringMessages.PushDownAction_To_activate);
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception);
	}
}