Java Code Examples for org.eclipse.jface.dialogs.ErrorDialog

The following examples show how to use org.eclipse.jface.dialogs.ErrorDialog. These examples are extracted from open source projects. 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 Project: MergeProcessor   Source File: MergeTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Executes the merge in a separate minimal working copy.
 * 
 * @throws InterruptedException
 * @throws InvocationTargetException
 * @throws SvnClientException
 */
private void mergeInMinimalWorkingCopy() throws InvocationTargetException, InterruptedException {
	LogUtil.entering();
	final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shellProvider.getShell());
	Dashboard.setShellProgressMonitorDialog(pmd);
	pmd.run(true, true, monitor -> {
		try {
			boolean cancelled = MergeProcessorUtil.merge(pmd, monitor, configuration, mergeUnit);
			if (cancelled) {
				mergeUnit.setStatus(MergeUnitStatus.CANCELLED);
				MergeProcessorUtil.canceled(mergeUnit);
			} else {
				mergeUnit.setStatus(MergeUnitStatus.DONE);
			}
		} catch (Throwable e) {
			pmd.getShell().getDisplay().syncExec(() -> {
				MultiStatus status = createMultiStatus(e);
				ErrorDialog.openError(pmd.getShell(), "Error dusrching merge process",
						"An Exception occured during the merge process. The merge didn't run successfully.",
						status);
			});
		}

	});
	LogUtil.exiting();
}
 
Example 2
/**
 * See {@link ILaunchShortcut2#getLaunchConfigurations(ISelection)} for contract.
 * @param file
 * @return
 */
private ILaunchConfiguration[] getLaunchConfigurations(File file) {
	if (file == null || !canLaunch(file)) {
		return null;
	}
	try {
		ILaunchConfiguration[] existing = Arrays.stream(launchManager.getLaunchConfigurations(configType))
				.filter(launchConfig -> match(launchConfig, file)).toArray(ILaunchConfiguration[]::new);
		if (existing.length != 0) {
			return existing;
		}
		return new ILaunchConfiguration[0];
	} catch (CoreException e) {
		ErrorDialog.openError(Display.getDefault().getActiveShell(), "error", e.getMessage(), e.getStatus()); //$NON-NLS-1$
		Activator.getDefault().getLog().log(e.getStatus());
	}
	return new ILaunchConfiguration[0];
}
 
Example 3
@Override
protected void handleOpen(OpenEvent event) {
    Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
    if (getDisplayedMatchCount(firstElement) == 0) {
        try {
            if (firstElement instanceof IAdaptable) {
                IAdaptable iAdaptable = (IAdaptable) firstElement;
                IFile file = iAdaptable.getAdapter(IFile.class);
                if (file != null) {

                    open(getSite().getPage(), file, false);
                }
            }
        } catch (PartInitException e) {
            ErrorDialog.openError(getSite().getShell(),
                    "Open File",
                    "Opening the file failed.", e.getStatus());
        }
        return;
    }
    super.handleOpen(event);
}
 
Example 4
public void launchWithParameters(ILaunchConfiguration configuration, String mode, ILaunch launch,
		IProgressMonitor monitor, Map<String, Object> param, File debugAdapter) throws CoreException {
	try {
		List<String> debugCmdArgs = Collections.singletonList(debugAdapter.getAbsolutePath());

		DSPLaunchDelegateLaunchBuilder builder = new DSPLaunchDelegateLaunchBuilder(configuration, mode, launch,
				monitor);
		builder.setLaunchDebugAdapter(InitializeLaunchConfigurations.getNodeJsLocation(), debugCmdArgs);
		builder.setMonitorDebugAdapter(configuration.getAttribute(DSPPlugin.ATTR_DSP_MONITOR_DEBUG_ADAPTER, false));
		builder.setDspParameters(param);

		super.launch(builder);
	} catch (Exception e) {
		IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
		Activator.getDefault().getLog().log(errorStatus);
		Display.getDefault().asyncExec(new Runnable() {
		@Override
		public void run() {
				ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus); //$NON-NLS-1$
		}
		});

	}
}
 
Example 5
Source Project: n4js   Source File: N4JSStackTraceHyperlink.java    License: 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 6
/**
 * Shows JFace ErrorDialog but improved by constructing full stack trace in detail area.
 *
 * @return true if OK was pressed
 */
public static boolean showErrorDialogWithStackTrace(String msg, Throwable throwable) {

	// Temporary holder of child statuses
	List<Status> childStatuses = new ArrayList<>();

	for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
		childStatuses.add(new Status(IStatus.ERROR, "N4js-plugin-id", stackTraceElement.toString()));
	}

	MultiStatus ms = new MultiStatus("N4js-plugin-id", IStatus.ERROR,
			childStatuses.toArray(new Status[] {}), // convert to array of statuses
			throwable.getLocalizedMessage(), throwable);

	final AtomicBoolean result = new AtomicBoolean(true);
	Display.getDefault()
			.syncExec(
					() -> result.set(
							ErrorDialog.openError(null, "Error occurred while organizing ", msg, ms) == Window.OK));

	return result.get();
}
 
Example 7
Source Project: n4js   Source File: N4JSGracefulActivator.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Opens a message dialog showing the status with given title. If you do not have a title, just call
 * {@link #statusDialog(IStatus)}.
 */
public static void statusDialog(String title, IStatus status) {
	Shell shell = getActiveWorkbenchShell();
	if (shell != null) {
		switch (status.getSeverity()) {
		case IStatus.ERROR:
			ErrorDialog.openError(shell, title, null, status);
			break;
		case IStatus.WARNING:
			MessageDialog.openWarning(shell, title, status.getMessage());
			break;
		case IStatus.INFO:
			MessageDialog.openInformation(shell, title, status.getMessage());
			break;
		}
	}
}
 
Example 8
Source Project: neoscada   Source File: Activator.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Notify error using message box (thread safe).
 * @param message The message to display
 * @param error The error that occurred
 */
public void notifyError ( final String message, final Throwable error )
{
    final Display display = getWorkbench ().getDisplay ();

    if ( !display.isDisposed () )
    {
        display.asyncExec ( new Runnable () {

            @Override
            public void run ()
            {
                final Shell shell = getWorkbench ().getActiveWorkbenchWindow ().getShell ();
                logger.debug ( "Shell disposed: {}", shell.isDisposed () );
                if ( !shell.isDisposed () )
                {
                    final IStatus status = new OperationStatus ( IStatus.ERROR, PLUGIN_ID, 0, message + ":" + error.getMessage (), error );
                    ErrorDialog.openError ( shell, null, message, status );
                }
            }
        } );
    }
}
 
Example 9
Source Project: neoscada   Source File: PreviewPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void setVisible ( final boolean visible )
{
    super.setVisible ( visible );
    if ( visible )
    {
        try
        {
            getContainer ().run ( false, false, new IRunnableWithProgress () {

                @Override
                public void run ( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
                {
                    setMergeResult ( PreviewPage.this.mergeController.merge ( wrap ( monitor ) ) );
                }
            } );
        }
        catch ( final Exception e )
        {
            final Status status = new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.PreviewPage_StatusErrorFailedToMerge, e );
            StatusManager.getManager ().handle ( status );
            ErrorDialog.openError ( getShell (), Messages.PreviewPage_TitleErrorFailedToMerge, Messages.PreviewPage_MessageErrorFailedToMerge, status );
        }
    }
}
 
Example 10
Source Project: neoscada   Source File: PreferencePage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void handleRemove ()
{
    final MultiStatus ms = new MultiStatus ( Activator.PLUGIN_ID, 0, "Removing key providers", null );

    for ( final KeyProvider provider : this.selectedProviders )
    {
        try
        {
            this.factory.remove ( provider );
        }
        catch ( final Exception e )
        {
            ms.add ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
        }
    }
    if ( !ms.isOK () )
    {
        ErrorDialog.openError ( getShell (), "Error", null, ms );
    }
}
 
Example 11
/**
 * Opens an error dialog if necessary. Takes care of complex rules necessary
 * for making the error dialog look nice.
 */
private void openError(IStatus status) {
	if (status == null) {
		return;
	}

	String genericTitle = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_title;
	int codes = IStatus.ERROR | IStatus.WARNING;

	// simple case: one error, not a multistatus
	if (!status.isMultiStatus()) {
		ErrorDialog
				.openError(getShell(), genericTitle, null, status, codes);
		return;
	}

	// one error, single child of multistatus
	IStatus[] children = status.getChildren();
	if (children.length == 1) {
		ErrorDialog.openError(getShell(), status.getMessage(), null,
				children[0], codes);
		return;
	}
	// several problems
	ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
}
 
Example 12
@Override
public void run() {

    final IBreakpoint breakpoint = getBreakpoint();
    if (breakpoint != null) {
        new Job("Enabling / Disabling Breakpoint") { //$NON-NLS-1$
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    breakpoint.setEnabled(!breakpoint.isEnabled());
                    return Status.OK_STATUS;
                } catch (final CoreException e) {
                    Display.getDefault().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            ErrorDialog.openError(getTextEditor().getEditorSite().getShell(),
                                    "Enabling/disabling breakpoints",
                                    "Exceptions occurred enabling disabling the breakpoint", e.getStatus());
                        }
                    });
                }
                return Status.CANCEL_STATUS;
            }
        }.schedule();
    }
}
 
Example 13
/**
 * Opens an error dialog if necessary. Takes care of complex rules necessary
 * for making the error dialog look nice.
 */
private void openError(IStatus status) {
    if (status == null) {
        return;
    }

    String genericTitle = WorkbenchNavigatorMessages.DropAdapter_title;
    int codes = IStatus.ERROR | IStatus.WARNING;

    // simple case: one error, not a multistatus
    if (!status.isMultiStatus()) {
        ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
        return;
    }

    // one error, single child of multistatus
    IStatus[] children = status.getChildren();
    if (children.length == 1) {
        ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes);
        return;
    }
    // several problems
    ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
}
 
Example 14
Source Project: developer-studio   Source File: WSO2PluginProjectWizard.java    License: 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 15
private void showMatch(final Match match, final boolean activateEditor) {
    ISafeRunnable runnable = new ISafeRunnable() {
        public void handleException(Throwable exception) {
            if (exception instanceof PartInitException) {
                PartInitException pie = (PartInitException) exception;
                ErrorDialog.openError(getSite().getShell(), "Show match", "Could not find an editor for the current match", pie.getStatus());
            }
        }

        public void run() throws Exception {
            IRegion location= getCurrentMatchLocation(match);
            showMatch(match, location.getOffset(), location.getLength(), activateEditor);
        }
    };
    SafeRunner.run(runnable);
}
 
Example 16
Source Project: typescript.java   Source File: TypeScriptSearchResultPage.java    License: MIT License 6 votes vote down vote up
protected void handleOpen(OpenEvent event) {
	if (showLineMatches()) {
		Object firstElement= ((IStructuredSelection)event.getSelection()).getFirstElement();
		if (firstElement instanceof IFile) {
			if (getDisplayedMatchCount(firstElement) == 0) {
				try {
					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 17
Source Project: tracecompass   Source File: TargetNodeComponent.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Handles the connected event.
 */
private void handleConnected() {
    try {
        createControlService();
        getConfigurationFromNode();
        // Set connected only after the control service has been created and the jobs for creating the
        // sub-nodes are completed.
    } catch (final ExecutionException e) {
        // Disconnect only if no control service, otherwise stay connected.
        if (getControlService() == NULL_CONTROL_SERVICE) {
            fState = TargetNodeState.CONNECTED;
            disconnect();
        }

        // Notify user
        Display.getDefault().asyncExec(() -> {
            ErrorDialog er = new ErrorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.TraceControl_ErrorTitle, Messages.TraceControl_RetrieveNodeConfigurationFailure,
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e),
                    IStatus.ERROR);
            er.open();
        });
        Activator.getDefault().logError(Messages.TraceControl_RetrieveNodeConfigurationFailure + " (" + getName() + "). \n", e); //$NON-NLS-1$ //$NON-NLS-2$
    }
}
 
Example 18
@Override
protected void okPressed() {
    // Validate input data
    String sessionPath = fFileNameCombo.getText();

    if (!"".equals(sessionPath)) { //$NON-NLS-1$

        ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
        try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(sessionPath, "r")) { //$NON-NLS-1$
            String line = rafile.getNextLine();
            while (line != null) {
                builder.add(line);
                line = rafile.getNextLine();
            }
        } catch (IOException e) {
            ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e));
            return;
        }
        saveWidgetValues();
        fCommands = builder.build();
        super.okPressed();
    }
}
 
Example 19
Source Project: Pydev   Source File: PyUnitView.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void restoreFromClipboard() {
    try {
        String clipboardContents = ClipboardHandler.getClipboardContents();
        PyUnitTestRun testRunRestored = PyUnitTestRun.fromXML(clipboardContents);
        DummyPyUnitServer pyUnitServer = new DummyPyUnitServer(testRunRestored.getPyUnitLaunch());

        final PyUnitViewServerListener serverListener = new PyUnitViewServerListener(pyUnitServer, testRunRestored);
        PyUnitViewTestsHolder.addServerListener(serverListener);

        this.setCurrentRun(testRunRestored);
    } catch (Exception e) {
        Log.log(e);
        Status status = SharedCorePlugin.makeStatus(IStatus.ERROR, e.getMessage(), e);
        ErrorDialog.openError(EditorUtils.getShell(), "Error restoring tests from clipboard",
                "Error restoring tests from clipboard", status);
    }
}
 
Example 20
/**
 * Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.
 */
private void openError(final IStatus status) {
	if (status == null) { return; }

	final String genericTitle = WorkbenchNavigatorMessages.DropAdapter_title;
	final int codes = IStatus.ERROR | IStatus.WARNING;

	// simple case: one error, not a multistatus
	if (!status.isMultiStatus()) {
		ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
		return;
	}

	// one error, single child of multistatus
	final IStatus[] children = status.getChildren();
	if (children.length == 1) {
		ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes);
		return;
	}
	// several problems
	ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
}
 
Example 21
protected void perform(CoreException e, Shell shell, String title, String message)
{
	/*
	 * if (!Activator.getDefault().getPreferenceStore().getBoolean(
	 * PreferenceConstants.RESOURCE_SHOW_ERROR_INVALID_RESOURCE_NAME) && isInvalidResouceName(e)) { return; }
	 */
	IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG);
	IStatus status = e.getStatus();
	if (status != null)
	{
		ErrorDialog.openError(shell, title, message, status);
	}
	else
	{
		displayMessageDialog(e, e.getMessage(), shell, title, message);
	}
}
 
Example 22
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 23
Source Project: slr-toolkit   Source File: SplitTermHandler.java    License: 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 24
Source Project: slr-toolkit   Source File: MergeTermsHandler.java    License: 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) {
		List<Term> termsToMerge = new ArrayList<>(currentSelection.size());
		currentSelection.toList().stream().filter(s -> s instanceof Term).forEach(s -> termsToMerge.add((Term) s));
		if (selectionValid(termsToMerge)) {
			MergeTermsDialog dialog = new MergeTermsDialog(null, termsToMerge);
			dialog.setBlockOnOpen(true);
			if (dialog.open() == MessageDialog.OK && dialog.getReturnCode() == MessageDialog.OK) {
				TermMerger.merge(termsToMerge, dialog.getTargetTerm());
			}
		} else {
			ErrorDialog.openError(null, "Error", null, new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid selection. The selected terms must not share their paths.", null));
		}
		
	}
	return null;
}
 
Example 25
/**
 * Opens an error dialog if necessary. Takes care of complex rules necessary
 * for making the error dialog look nice.
 */
private void openError(IStatus status) {
	if (status == null) {
		return;
	}

	String genericTitle = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_title;
	int codes = IStatus.ERROR | IStatus.WARNING;

	// simple case: one error, not a multistatus
	if (!status.isMultiStatus()) {
		ErrorDialog
				.openError(getShell(), genericTitle, null, status, codes);
		return;
	}

	// one error, single child of multistatus
	IStatus[] children = status.getChildren();
	if (children.length == 1) {
		ErrorDialog.openError(getShell(), status.getMessage(), null,
				children[0], codes);
		return;
	}
	// several problems
	ErrorDialog.openError(getShell(), genericTitle, null, status, codes);
}
 
Example 26
/**
 * 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 27
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 28
Source Project: sarl   Source File: IssueInformationPage.java    License: Apache License 2.0 6 votes vote down vote up
/** Invoked when the wizard is closed with the "Finish" button.
 *
 * @return {@code true} for closing the wizard; {@code false} for keeping it open.
 */
public boolean performFinish() {
	final IEclipsePreferences prefs = SARLEclipsePlugin.getDefault().getPreferences();
	final String login = this.trackerLogin.getText();
	if (Strings.isEmpty(login)) {
		prefs.remove(PREFERENCE_LOGIN);
	} else {
		prefs.put(PREFERENCE_LOGIN, login);
	}
	try {
		prefs.sync();
		return true;
	} catch (BackingStoreException e) {
		ErrorDialog.openError(getShell(), e.getLocalizedMessage(), e.getLocalizedMessage(),
				SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, e));
		return false;
	}
}
 
Example 29
Source Project: sarl   Source File: BuildSettingWizardPage.java    License: Apache License 2.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() {
	final IStatus status = changeToNewProject();
	if (status != null) {
		updateStatus(status);
		if (!status.isOK()) {
			ErrorDialog.openError(
					getShell(),
					NewWizardMessages.NewJavaProjectWizardPageTwo_error_title,
					null,
					status);
		}
	}
	return this.currProject;
}
 
Example 30
static File findDebugAdapter() {
	URL fileURL;
	try {
		fileURL = FileLocator.toFileURL(
				ChromeRunDAPDebugDelegate.class.getResource("/node_modules/debugger-for-chrome/out/src/chromeDebug.js"));
		return new File(fileURL.toURI());
	} catch (IOException | URISyntaxException e) {
		IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
		Activator.getDefault().getLog().log(errorStatus);
		Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus)); //$NON-NLS-1$
	}
	return null;
}