Java Code Examples for org.eclipse.jface.dialogs.ErrorDialog#openError()

The following examples show how to use org.eclipse.jface.dialogs.ErrorDialog#openError() . 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
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term termToSplit = (Term) currentSelection.getFirstElement();
		if (selectionValid(termToSplit)) {
			SplitTermDialog dialog = new SplitTermDialog(null, termToSplit.getName());
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermSplitter.split(termToSplit, dialog.getDefaultTermName(), dialog.getFurtherTermNames());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected term must not have children.", null));
		}
	}
	return null;
}
 
Example 2
/**
 * @see org.eclipse.debug.ui.console.IConsoleHyperlink#linkActivated()
 */
@Override
public void linkActivated() {
	JSStackTraceLocationText locationText;
	try {
		String linkText = getLinkText();
		locationText = new JSStackTraceLocationText(linkText);
	} catch (CoreException e1) {
		ErrorDialog.openError(
				N4JSGracefulActivator.getActiveWorkbenchShell(),
				ConsoleMessages.msgHyperlinkError(),
				ConsoleMessages.msgHyperlinkError(),
				e1.getStatus());
		return;
	}

	startSourceSearch(locationText);
}
 
Example 3
protected boolean performFinishForZipExport() {
    ExportBosArchiveOperation operation = createExportBOSOperation();
    try {
        getContainer().run(false, true, operation::run);
    } catch (InterruptedException | InvocationTargetException e) {
        BonitaStudioLog.error(e);
        MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.exportFailed, e.getCause().getMessage());
        return false;
    }

    if (!operation.getStatus().isOK()) {
        ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.exportFailed, null, operation.getStatus());
        return false;
    }
    return true;
}
 
Example 4
Source Project: elexis-3-core   File: RnDialogs.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void okPressed(){
	
	// Number num=df.parse(amount.getText());
	Money ret = MoneyInput.getFromTextField(amount);
	if (ret != null) {
		ret = ret.multiply(-1.0);
		rn.addZahlung(ret, bemerkung.getText(), new TimeTool(dp.getDate().getTime()));
		super.okPressed();
	} else {
		ErrorDialog.openError(getShell(), Messages.RnDialogs_amountInvalid,
			Messages.RnDialogs_invalidFormat, //$NON-NLS-1$ //$NON-NLS-2$
			new Status(1, "ch.elexis", 1, "CurrencyFormat", null)); //$NON-NLS-1$ //$NON-NLS-2$
	}
	
}
 
Example 5
Source Project: Pydev   File: FileSearchPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleOpen(OpenEvent event) {
    if (showLineMatches()) {
        Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
        if (firstElement instanceof IFile) {
            if (getDisplayedMatchCount(firstElement) == 0) {
                try {
                    fEditorOpener.open(getSite().getPage(), (IFile) firstElement, false);
                } catch (PartInitException e) {
                    ErrorDialog.openError(getSite().getShell(),
                            SearchMessages.FileSearchPage_open_file_dialog_title,
                            SearchMessages.FileSearchPage_open_file_failed, e.getStatus());
                }
                return;
            }
        }
    }
    super.handleOpen(event);
}
 
Example 6
private WSO2PluginSampleExt generateWSO2PluginSampleExt(String fileName, String pluginSamlpeId) {
	Gson gson = new Gson();
	WSO2PluginSampleExt wso2PluginSampleExt = null;
	String fileToRead = fileName + pluginSamlpeId + File.separator + WSO2PluginConstants.SAMPLE_DESCRIPTION_FILE;
	try {
		BufferedReader br = new BufferedReader(new FileReader(fileToRead));
		wso2PluginSampleExt = gson.fromJson(br, WSO2PluginSampleExt.class);
		wso2PluginSampleExt.setIsUpdatedFromGit("true");
		wso2PluginSampleExt.setPluginArchive(
				fileName + pluginSamlpeId + File.separator + wso2PluginSampleExt.getPluginArchive());
	} catch (JsonIOException | JsonSyntaxException | FileNotFoundException e) {
		log.error("Could not load the plugin sample from the archive, error in the sample format " + e);
		MultiStatus status = MessageDialogUtils.createMultiStatus(e.getLocalizedMessage(), e,
				WSO2PluginConstants.PACKAGE_ID);
		// show error dialog
		ErrorDialog.openError(this.getShell(), WSO2PluginConstants.ERROR_DIALOG_TITLE,
				"Could not load the plugin sample from the archive, error in the sample format ", status);
	}

	return wso2PluginSampleExt;

}
 
Example 7
public void saveToProjectSettings(IScopedPreferences iScopedPreferences, IProject[] projects) {
    Map<String, Object> saveData = getFieldEditorsSaveData();
    if (saveData.size() > 0) {
        try {
            String message = iScopedPreferences.saveToProjectSettings(saveData, projects);
            DialogHelpers.openInfo("Contents saved", message);
        } catch (Exception e) {
            Log.log(e);
            ErrorDialog.openError(EditorUtils.getShell(),
                    "Error: unable to save requested settings to user settings",
                    e.getMessage(),
                    SharedUiPlugin.makeErrorStatus(e, false));
        }
    } else {
        // This shouldn't happen
        DialogHelpers.openCritical("Error: No preferences to save",
                "Error: No preferences to save (please report this as an error).");
    }

}
 
Example 8
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        URL url = getURL();

        IWebBrowser browser;
        browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.AS_EDITOR,
                BonitaPreferenceConstants.APPLICATION_BROWSER_ID, "Bonita Application", "");
        browser.openURL(url);

    } catch (Exception e) {
        BonitaStudioLog.error(e);
        ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "error",
                "error starting server",
                Status.OK_STATUS);
    }

    return null;
}
 
Example 9
private void findReferences(IResource resource, int offset, int length) {
	TypeScriptSearchQuery query = new TypeScriptSearchQuery(resource, offset);
	if (query.canRunInBackground()) {
		/*
		 * This indirection with Object as parameter is needed to prevent
		 * the loading of the Search plug-in: the VM verifies the method
		 * call and hence loads the types used in the method signature,
		 * eventually triggering the loading of a plug-in (in this case
		 * ISearchQuery results in Search plug-in being loaded).
		 */
		SearchUtil.runQueryInBackground(query);
	} else {
		IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
		/*
		 * This indirection with Object as parameter is needed to prevent
		 * the loading of the Search plug-in: the VM verifies the method
		 * call and hence loads the types used in the method signature,
		 * eventually triggering the loading of a plug-in (in this case it
		 * would be ISearchQuery).
		 */
		IStatus status = SearchUtil.runQueryInForeground(progressService, query);
		if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
			ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title,
					SearchMessages.Search_Error_search_message, status);
		}
	}
}
 
Example 10
@Override
public void run(ITextSelection selection) {
	try {
		IJavaElement element= SelectionConverter.getElementAtOffset(fEditor);
		if (element != null)
			run(element);
	} catch (JavaModelException e) {
		JavaPlugin.log(e);
		String message= ActionMessages.ShowInPackageViewAction_error_message;
		ErrorDialog.openError(getShell(), getDialogTitle(), message, e.getStatus());
	}
}
 
Example 11
Source Project: neoscada   File: GeneratorView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void createPages ()
{
    try
    {
        for ( final GeneratorPageInformation info : getPageInformation () )
        {
            this.pages.add ( info );
        }
    }
    catch ( final CoreException e )
    {
        ErrorDialog.openError ( getSite ().getShell (), Messages.getString ( "GeneratorView.createPages.error" ), Messages.getString ( "GeneratorView.createPages.errorMessage" ), e.getStatus () );
    }
}
 
Example 12
Source Project: goclipse   File: GoSearchPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performAction() {
  try {
    NewSearchUI.runQueryInBackground(newQuery());
  } catch (CoreException e) {
    ErrorDialog.openError(getShell(), "Search",
        "Problems occurred while searching. The affected files will be skipped.", e.getStatus());
    return false;
  }
  return true;
}
 
Example 13
Source Project: sarl   File: SARLExamplePlugin.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Display an error dialog and log the error.
 *
 * @param shell the parent container.
 * @param title the title of the dialog box.
 * @param message the message to display into the dialog box.
 * @param exception the exception to be logged.
 * @since 0.6
 * @see #log(Throwable)
 */
public void openError(Shell shell, String title, String message, Throwable exception) {
	final Throwable ex = (exception != null) ? Throwables.getRootCause(exception) : null;
	if (ex != null) {
		log(ex);
		final IStatus status = createStatus(IStatus.ERROR, 0, message, ex);
		ErrorDialog.openError(shell, title, message, status);
	} else {
		MessageDialog.openError(shell, title, message);
	}
}
 
Example 14
Source Project: ermaster-b   File: Activator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * �w�肳�ꂽ��O�̗�O�_�C�A���O��\�����܂��B
 *
 * @param e
 *            ��O
 */
public static void showExceptionDialog(Throwable e) {
	IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, e
			.toString(), e);

	Activator.log(e);

	ErrorDialog.openError(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), ResourceString
			.getResourceString("dialog.title.error"), ResourceString
			.getResourceString("error.plugin.error.message"), status);
}
 
Example 15
/**
 * Creates the provisional project on which the wizard is working on. The provisional project is typically
 * created when the page is entered the first time. The early project creation is required to configure linked folders.
 *
 * @return the provisional project
 */
protected IProject createProvisonalProject() {
	IStatus status= changeToNewProject();
	if (status != null && !status.isOK()) {
		ErrorDialog.openError(getShell(), NewWizardMessages.NewJavaProjectWizardPageTwo_error_title, null, status);
	}
	return fCurrProject;
}
 
Example 16
void createPage0() {
	try {
		editor = new StructuredTextEditor();
		int index = addPage(editor, getEditorInput());
		setPageText(index, editor.getTitle());
	}
	catch (PartInitException e) {
		ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
	}
}
 
Example 17
Source Project: neoscada   File: NewTestWizard.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean performFinish ()
{
    try
    {
        handleFinish ();
        return true;
    }
    catch ( final Exception e )
    {
        logger.info ( "Failed to start server", e );
        ErrorDialog.openError ( getShell (), null, null, StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
        return false;
    }
}
 
Example 18
protected void performNewSearch(String label, Iterable<? extends IJavaElement> elements) throws JavaModelException, InterruptedException {
	CompositeSearchQuery compositeSearchQuery = createCompositeQuery(label, elements);
	if (compositeSearchQuery.canRunInBackground()) {
		SearchUtil.runQueryInBackground(compositeSearchQuery);
	} else {
		IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
		IStatus status= SearchUtil.runQueryInForeground(progressService, compositeSearchQuery);
		if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
			ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status);
		}
	}
}
 
Example 19
@Override
public void launch(ISelection selection, String launchMode) {
  try {
    IModule[] modules = launcher.asModules(selection);
    launcher.launch(modules, launchMode);
  } catch (CoreException ex) {
    ErrorDialog.openError(null, Messages.getString("UNABLE_TO_LAUNCH"), ex.getLocalizedMessage(), //$NON-NLS-1$
        ex.getStatus());
  }
}
 
Example 20
public static IProposableFix createAddUnimplementedMethodsFix(final CompilationUnit root, IProblemLocation problem) {
	ASTNode typeNode= getSelectedTypeNode(root, problem);
	if (typeNode == null)
		return null;

	if (isTypeBindingNull(typeNode))
		return null;

	AddUnimplementedMethodsOperation operation= new AddUnimplementedMethodsOperation(typeNode);
	if (operation.getMethodsToImplement().length > 0) {
		return new UnimplementedCodeFix(CorrectionMessages.UnimplementedMethodsCorrectionProposal_description, root, new CompilationUnitRewriteOperation[] { operation });
	} else {
		return new IProposableFix() {
			public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
				CompilationUnitChange change= new CompilationUnitChange(CorrectionMessages.UnimplementedMethodsCorrectionProposal_description, (ICompilationUnit) root.getJavaElement()) {
					@Override
					public Change perform(IProgressMonitor pm) throws CoreException {
						Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
						String dialogTitle= CorrectionMessages.UnimplementedMethodsCorrectionProposal_description;
						IStatus status= getStatus();
						ErrorDialog.openError(shell, dialogTitle, CorrectionMessages.UnimplementedCodeFix_DependenciesErrorMessage, status);

						return new NullChange();
					}
				};
				change.setEdit(new MultiTextEdit());
				return change;
			}

			public String getAdditionalProposalInfo() {
				return new String();
			}

			public String getDisplayString() {
				return CorrectionMessages.UnimplementedMethodsCorrectionProposal_description;
			}

			public IStatus getStatus() {
				return new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, CorrectionMessages.UnimplementedCodeFix_DependenciesStatusMessage);
			}
		};
	}
}