Example usage for org.eclipse.jface.dialogs MessageDialog ERROR

List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog ERROR.

Prototype

int ERROR

To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:eu.cloudwave.wp5.feedback.eclipse.base.ui.dialogs.AbstractMessageDialog.java

License:Apache License

/**
 * Displays the current {@link MessageDialog}.
 * /*from   w w  w.j a  v  a2s.c  o  m*/
 * @param title
 *          the title of the {@link MessageDialog}
 * @param message
 *          the message of the {@link MessageDialog}
 * @param dialogImageType
 *          one of the following values:
 *          <ul>
 *          <li>MessageDialog.NONE for a dialog with no image</li>
 *          <li>MessageDialog.ERROR for a dialog with an error image</li>
 *          <li>MessageDialog.INFORMATION for a dialog with an information image</li>
 *          <li>MessageDialog.QUESTION for a dialog with a question image</li>
 *          <li>MessageDialog.WARNING for a dialog with a warning image</li>
 *          </ul>
 * @param buttonText
 *          the text of the button
 */
public final void display(final String title, final String message, final int dialogImageType,
        final String buttonText) {
    new AbstractUiTask() {
        @Override
        public void doWork() {
            final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            final String[] buttons = new String[] { "Cancel", buttonText };
            final MessageDialog messageDialog = new MessageDialog(shell, title, null, message,
                    MessageDialog.ERROR, buttons, 0);
            final int action = messageDialog.open();
            if (action == 1) {
                action(shell);
            }
        }
    }.run();
}

From source file:eu.hydrologis.jgrass.libs.utils.dialogs.ProblemDialogs.java

License:Open Source License

/**
 * @param errorMessage//from   w w w.j  ava 2 s . c  om
 * @param shell
 */
private static void error(final String errorMessage, Shell shell) {
    Shell sh = shell != null ? shell : PlatformUI.getWorkbench().getDisplay().getActiveShell();
    MessageDialog dialog = new MessageDialog(sh, Messages.getString("ProblemDialogs.error"), null, errorMessage, //$NON-NLS-1$
            MessageDialog.ERROR, new String[] { Messages.getString("ProblemDialogs.ok") }, 0); //$NON-NLS-1$
    dialog.setBlockOnOpen(true);
    dialog.open();
}

From source file:eu.modelwriter.marker.ui.Activator.java

License:Open Source License

public static MessageDialog errorDialogOK(String title, String message) {
    return new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, 0, "Yes", "No");
}

From source file:eu.modelwriter.marker.ui.Activator.java

License:Open Source License

public static MessageDialog errorDialogYESNO(String title, String message) {
    return new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, 0, "Yes", "No");
}

From source file:eu.numberfour.n4js.ui.dialog.ModuleSpecifierSelectionDialog.java

License:Open Source License

/**
 * Processes the initial string selection.
 *
 * For existing resources it just sets the initial selection to the specified file system resource.
 *
 * In the case that the initial module specifier points to a non-existing location, a dialog is displayed which
 * allows the user to automatically create not yet existing folders.
 *
 * @param initialModuleSpecifier//from  w w  w .  j a v  a  2  s .c  om
 *            The module specifier
 * @return A {@link IWorkbenchAdapter} adaptable object or null on failure
 */
private Object processInitialSelection(String initialModuleSpecifier) {

    IPath sourceFolderPath = sourceFolder.getFullPath();
    IPath initialModulePath = new Path(initialModuleSpecifier);

    // Use the root element source folder for an empty initial selection
    if (initialModuleSpecifier.isEmpty()) {
        return this.sourceFolder;
    }

    // Use the root element source folder for invalid module specifiers
    if (!WorkspaceWizardValidatorUtils.isValidFolderPath(initialModulePath)) {
        return this.sourceFolder;
    }

    // The project relative path of a module specifier
    IPath fullPath = sourceFolderPath.append(new Path(initialModuleSpecifier));

    // If the module specifier refers to an existing n4js resource
    if (!fullPath.hasTrailingSeparator()) {
        IFile n4jsModuleFile = workspaceRoot
                .getFile(fullPath.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION));
        IFile n4jsdModuleFile = workspaceRoot
                .getFile(fullPath.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION));

        // Just use it as initial selection
        if (n4jsModuleFile.exists()) {
            return n4jsModuleFile;
        }
        if (n4jsdModuleFile.exists()) {
            return n4jsdModuleFile;
        }

    }

    //// Otherwise use the existing part of the path as initial selection:

    // If the module specifier specifies the module name, extract it and remove its segment.
    if (isModuleFileSpecifier(initialModulePath)) {
        initialModuleName = initialModulePath.lastSegment();
        initialModulePath = initialModulePath.removeLastSegments(1);
    }

    IResource selection = this.sourceFolder;

    // Accumulate path segments to search for the longest existing path
    IPath accumulatedPath = sourceFolderPath;

    // Collect the paths of all non-existing segments
    // These are relative to the last existing segment of the path
    List<IPath> nonExistingSegmentPaths = new ArrayList<>();

    for (Iterator<String> segmentIterator = Arrays.asList(initialModulePath.segments())
            .iterator(); segmentIterator.hasNext(); /**/) {

        accumulatedPath = accumulatedPath.append(segmentIterator.next());

        // Results in null if non-existing
        IResource nextSegmentResource = workspaceRoot.findMember(accumulatedPath);

        // If the current segment is an existing file and not the last specifier segment
        // show a file overlap error message
        if (null != nextSegmentResource && !(nextSegmentResource instanceof IContainer)
                && segmentIterator.hasNext()) {

            MessageDialog.open(MessageDialog.ERROR, getShell(), SPECIFIER_OVERLAPS_WITH_FILE_TITLE, String
                    .format(SPECIFIER_OVERLAPS_WITH_FILE_MESSAGE, initialModuleSpecifier, accumulatedPath),
                    SWT.NONE);

            return selection;
        }

        // If the segment exist go ahead with the next one
        if (null != nextSegmentResource && nextSegmentResource.exists()) {
            selection = nextSegmentResource;
        } else { // If not add it to the list of non existing segments.
            nonExistingSegmentPaths.add(accumulatedPath.makeRelativeTo(selection.getFullPath()));
        }
    }

    // If any non-existing folders need to be created
    if (nonExistingSegmentPaths.size() > 0) {
        // Ask the user if he wants to create the missing folders
        boolean create = MessageDialog.open(MessageDialog.QUESTION, getShell(),
                NON_EXISTING_MODULE_LOCATION_TITLE, NON_EXISTING_MODULE_LOCATION_MESSAGE, SWT.NONE);

        // Create the missing folders
        if (create) {
            ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell());
            progressMonitorDialog.open();
            IProgressMonitor progressMonitor = progressMonitorDialog.getProgressMonitor();

            IPath deepestPath = nonExistingSegmentPaths.get(nonExistingSegmentPaths.size() - 1);
            selection = createFolderPath(deepestPath, (IContainer) selection, progressMonitor);

            progressMonitor.done();
            progressMonitorDialog.close();
        }

    }
    return selection;
}

From source file:eu.numberfour.n4js.ui.dialog.ModuleSpecifierSelectionDialog.java

License:Open Source License

/**
 * Creates all non-existing segments of the given path.
 *
 * @param path/*w w w  . j  a  v a  2  s.c  om*/
 *            The path to create
 * @param parent
 *            The container in which the path should be created in
 * @param monitor
 *            A progress monitor. May be {@code null}
 *
 * @return The folder specified by the path
 */
private IContainer createFolderPath(IPath path, IContainer parent, IProgressMonitor monitor) {
    IContainer activeContainer = parent;

    if (null != monitor) {
        monitor.beginTask("Creating folders", path.segmentCount());
    }

    for (String segment : path.segments()) {
        IFolder folderToCreate = activeContainer.getFolder(new Path(segment));
        try {
            if (!folderToCreate.exists()) {
                createFolder(segment, activeContainer, monitor);
            }
            if (null != monitor) {
                monitor.worked(1);
            }
            activeContainer = folderToCreate;
        } catch (CoreException e) {
            LOGGER.error("Failed to create module folders.", e);
            MessageDialog.open(MessageDialog.ERROR, getShell(), FAILED_TO_CREATE_FOLDER_TITLE,
                    String.format(FAILED_TO_CREATE_FOLDER_MESSAGE, folderToCreate.getFullPath().toString(),
                            e.getMessage()),
                    SWT.NONE);
            break;
        }
    }
    return activeContainer;
}

From source file:eu.numberfour.n4js.ui.export.AbstractExportToSingleFileWizardPage.java

License:Open Source License

/**
 * Display an error dialog with the specified message.
 *//*from   w w w  .  j  a  v a 2 s.  c o  m*/
private void displayErrorDialog(String message) {
    MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), getErrorDialogTitle(), message,
            SWT.SHEET);
}

From source file:eu.numberfour.n4js.ui.handler.CreateNewN4JSElementInModuleHandler.java

License:Open Source License

/**
 * Opens the wizard with the given id and passes it the selection.
 *
 * @param wizardId//ww w.  java  2  s  .  c  o m
 *            The wizard id of the eclipse newWizard registry
 * @param selection
 *            The selection
 */
private void openWizardForModule(String wizardId, IStructuredSelection selection, boolean nested) {

    // Retrieve wizard from registry
    IWizardDescriptor wizardDescriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(wizardId);

    if (wizardDescriptor == null) {
        return;
    }

    try {
        IWorkbenchWizard wizard = wizardDescriptor.createWizard();

        // Inject wizard members
        injector.injectMembers(wizard);

        // Create and open a new wizard dialog
        WizardDialog wizardDialog = new WizardDialog(UIUtils.getShell(), wizard);

        // If the wizard supports it, enable in module option
        if (wizard instanceof N4JSNewClassifierWizard<?>) {
            ((N4JSNewClassifierWizard<?>) wizard).init(PlatformUI.getWorkbench(), selection, nested);
        } else {
            // Otherwise just pass it the initial selection
            wizard.init(PlatformUI.getWorkbench(), selection);
        }

        // wizardDialog.setTitle(wizard.getWindowTitle());
        wizardDialog.open();

    } catch (CoreException e) {
        /** Failed to create the wizard */
        Shell workbenchShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        MessageDialog.open(MessageDialog.ERROR, workbenchShell, "Failed to launch wizard",
                String.format("Failed to launch wizard %s", wizardId), SWT.SHEET);
        return;
    }

}

From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.RetrieveSEEHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {//from  w  w  w .  j av a 2 s . c  o  m
        if (SkillproService.getSkillproProvider().getSEERepo().isEmpty()) {
            getAllSEE();
        } else {
            getNewSEE();
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "Protocol exception",
                e.getMessage(), SWT.SHEET);
    } catch (IOException e) {
        e.printStackTrace();
        MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "IOException exception",
                e.getMessage(), SWT.SHEET);
    }
    return null;
}

From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.UpdateRegisteredSEEsHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {//w w  w .  j a  v a2  s . c  om
        List<SEE> registeredSEEs = new ArrayList<>();
        for (SEE see : SkillproService.getSkillproProvider().getSEERepo()) {
            if (see.getMESNodeID() != null || !see.getMESNodeID().isEmpty()) {
                registeredSEEs.add(see);
            }
        }
        //can actually be done in the first for-loop, but let's just leave it like this for now
        for (SEE see : registeredSEEs) {
            updateSEE(see);
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
        MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "Protocol exception",
                e.getMessage(), SWT.SHEET);
    } catch (IOException e) {
        e.printStackTrace();
        MessageDialog.open(MessageDialog.ERROR, HandlerUtil.getActiveShell(event), "IOException exception",
                e.getMessage(), SWT.SHEET);
    }
    return null;
}