Java Code Examples for org.eclipse.jface.dialogs.ErrorDialog#open()
The following examples show how to use
org.eclipse.jface.dialogs.ErrorDialog#open() .
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: ResourceTransferDragAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void handleFinishedDropMove(DragSourceEvent event) { MultiStatus status= new MultiStatus( JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_resource, null); List<IResource> resources= convertSelection(); for (Iterator<IResource> iter= resources.iterator(); iter.hasNext();) { IResource resource= iter.next(); try { resource.delete(true, null); } catch (CoreException e) { status.add(e.getStatus()); } } int childrenCount= status.getChildren().length; if (childrenCount > 0) { Shell parent= SWTUtil.getShell(event.widget); ErrorDialog error= new ErrorDialog(parent, JavaUIMessages.ResourceTransferDragAdapter_moving_resource, childrenCount == 1 ? JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_singular : Messages.format( JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_plural, String.valueOf(childrenCount)), status, IStatus.ERROR); error.open(); } }
Example 2
Source File: CompilationUnitEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Opens a warning dialog informing about a failure during handling of save listeners. * * @param title the dialog title * @param message the message to display * @param exception the exception to handle * @since 3.4 */ private void openSaveListenerWarningDialog(String title, String message, CoreException exception) { final String linkText; final IJavaProject javaProject= getInputJavaElement().getJavaProject(); IProject project= javaProject != null ? javaProject.getProject() : null; final boolean hasProjectSettings= project != null && CleanUpPreferenceUtil.hasSettingsInScope(new ProjectScope(project)); if (exception.getStatus().getCode() == IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION) { message= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_message; if (hasProjectSettings) linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_property_link; else linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_link; } else { message= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_message; if (hasProjectSettings) linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_property_link; else linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_link; } IStatus status= exception.getStatus(); int mask= IStatus.WARNING | IStatus.ERROR; ErrorDialog dialog= new ErrorDialog(getSite().getShell(), title, message, status, mask) { @Override protected Control createMessageArea(Composite parent) { Control result= super.createMessageArea(parent); // Panic code: use 'parent' instead of 'result' in case super implementation changes in the future new Label(parent, SWT.NONE); // filler as parent has 2 columns (icon and label) Link link= new Link(parent, SWT.NONE); link.setText(linkText); link.setFont(parent.getFont()); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (hasProjectSettings) PreferencesUtil.createPropertyDialogOn(getShell(), javaProject, SaveParticipantPreferencePage.PROPERTY_PAGE_ID, null, null).open(); else PreferencesUtil.createPreferenceDialogOn(getShell(), SaveParticipantPreferencePage.PREFERENCE_PAGE_ID, null, null).open(); } }); GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); link.setLayoutData(gridData); return result; } @Override protected Image getImage() { return getWarningImage(); } }; dialog.open(); }