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
Source File: SplitTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@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
Source File: OpenApplicationCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 3
Source File: ScopedFieldEditorPreferencePage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
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 4
Source File: WSO2PluginProjectWizard.java    From developer-studio with Apache License 2.0 6 votes vote down vote up
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 5
Source File: FileSearchPage.java    From Pydev with 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
Source File: RnDialogs.java    From elexis-3-core with 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 7
Source File: ExportRepositoryWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: N4JSStackTraceHyperlink.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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 9
Source File: GeneratorView.java    From neoscada with 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 10
Source File: GoSearchPage.java    From goclipse with 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 11
Source File: SARLExamplePlugin.java    From sarl with 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 12
Source File: Activator.java    From ermaster-b with 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 13
Source File: NewJavaProjectWizardPageTwo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 14
Source File: TSVEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
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 15
Source File: ShowInPackageViewAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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 16
Source File: NewTestWizard.java    From neoscada with 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 17
Source File: JdtReferenceFinder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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 18
Source File: FindReferencesInProjectAction.java    From typescript.java with MIT License 5 votes vote down vote up
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 19
Source File: LocalAppEngineStandardLaunchShortcut.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@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
Source File: UnimplementedCodeFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
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);
			}
		};
	}
}