Example usage for org.eclipse.jface.dialogs IMessageProvider WARNING

List of usage examples for org.eclipse.jface.dialogs IMessageProvider WARNING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IMessageProvider WARNING.

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs IMessageProvider WARNING.

Click Source Link

Document

Constant for a warning message (value 2).

Usage

From source file:org.eclipse.oomph.setup.ui.wizards.ConfirmationPage.java

License:Open Source License

private void validate() {
    setErrorMessage(null);//from  w  w  w  .  ja  v a2s.  c o m
    setPageComplete(false);

    if (switchWorkspaceButton != null && switchWorkspaceButton.isVisible()
            && switchWorkspaceButton.getSelection()) {
        setMessage("The IDE will be restarted with the new workspace " + getPerformer().getWorkspaceLocation()
                + ".", IMessageProvider.WARNING);
    } else {
        setMessage(null);
    }

    if (!someTaskChecked) {
        if (getWizard().getPerformer().getNeededTasks().size() == 0) {
            setMessage("No tasks need to perform.", IMessageProvider.WARNING);
        } else {
            setErrorMessage("Please check one or more tasks to continue with the installation process.");
        }

        return;
    }

    if (configurationLocationExists && !overwriteButton.getSelection()) {
        setErrorMessage("The folder " + lastConfigurationLocation
                + " exists.\n Please check the Overwrite button to rename it and continue with the installation process.");
        return;
    } else if (newWorkspaceLocation != null
            && !ObjectUtil.equals(newWorkspaceLocation, currentWorkspaceLocation)
            && !switchWorkspaceButton.getSelection()) {
        setErrorMessage("The workspace location is changed to " + getPerformer().getWorkspaceLocation()
                + ".  Please check the 'Switch workspace' button to restarted the IDE, switch to the new workspace, and continue the installation process.");
        return;
    }

    setPageComplete(true);
    setButtonState(IDialogConstants.NEXT_ID, false);
}

From source file:org.eclipse.oomph.setup.ui.wizards.ProgressPage.java

License:Open Source License

private void run(final String jobName, final ProgressLogRunnable runnable) {
    try {//from   w  w w . ja  va2s .com
        // Remember and use the progressPageLog that is valid at this point in time.
        final ProgressPageLog progressLog = progressPageLog;

        Runnable jobRunnable = new Runnable() {
            public void run() {
                final SetupWizard wizard = getWizard();
                final Shell shell = wizard.getShell();

                setButtonState(IDialogConstants.CANCEL_ID, false);
                setButtonState(IDialogConstants.BACK_ID, false);

                final Job job = new Job(jobName) {
                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        progressLog.setProgressMonitor(monitor);

                        final Trigger trigger = getTrigger();
                        long start = System.currentTimeMillis();
                        boolean success = false;
                        Set<String> restartReasons = null;

                        UIUtil.syncExec(new Runnable() {
                            public void run() {
                                shell.setData(PROGRESS_STATUS, null);
                                if (trigger != Trigger.BOOTSTRAP) {
                                    if (trigger == Trigger.STARTUP
                                            || !SetupPropertyTester.isShowProgressInWizard()) {
                                        shell.setVisible(false);
                                    }

                                    SetupPropertyTester.setPerformingShell(shell);
                                }
                            }
                        });

                        try {
                            restartReasons = runnable.run(progressLog);

                            SetupTaskPerformer performer = getPerformer();
                            saveLocalFiles(performer);

                            if (launchAutomatically && trigger == Trigger.BOOTSTRAP) {
                                hasLaunched = launchProduct(performer);
                            }

                            success = true;
                        } catch (OperationCanceledException ex) {
                            // Do nothing
                        } catch (Throwable ex) {
                            final IStatus status = SetupUIPlugin.INSTANCE.getStatus(ex);
                            SetupUIPlugin.INSTANCE.log(new IStatus() {
                                public IStatus[] getChildren() {
                                    return status.getChildren();
                                }

                                public int getCode() {
                                    return status.getCode();
                                }

                                public Throwable getException() {
                                    return status.getException();
                                }

                                public String getMessage() {
                                    return status.getMessage();
                                }

                                public String getPlugin() {
                                    return status.getPlugin();
                                }

                                public int getSeverity() {
                                    return IStatus.WARNING;
                                }

                                public boolean isMultiStatus() {
                                    return status.isMultiStatus();
                                }

                                public boolean isOK() {
                                    return false;
                                }

                                public boolean matches(int severityMask) {
                                    return (severityMask & IStatus.WARNING) != 0;
                                }

                                @Override
                                public String toString() {
                                    StringBuilder result = new StringBuilder();
                                    result.append("Status WARNING");
                                    result.append(": ");
                                    result.append(getPlugin());
                                    result.append(" code=");
                                    result.append(getCode());
                                    result.append(' ');
                                    result.append(getMessage());
                                    result.append(' ');
                                    result.append(getException());
                                    result.append(" children=[");
                                    result.append(status);
                                    result.append("]");
                                    return result.toString();
                                }
                            });
                            progressLog.log(ex);
                        } finally {
                            long seconds = (System.currentTimeMillis() - start) / 1000;
                            progressLog.setTerminating();
                            progressLog.message("Took " + seconds + " seconds.");

                            getWizard().sendStats(success);

                            final AtomicBoolean disableCancelButton = new AtomicBoolean(true);

                            final boolean restart = restartReasons != null && !restartReasons.isEmpty()
                                    && trigger != Trigger.BOOTSTRAP;
                            if (restart) {
                                progressLog.message("A restart is needed for the following reasons:", false,
                                        Severity.INFO);
                                for (String reason : restartReasons) {
                                    progressLog.message("  - " + reason);
                                }

                                wizard.setFinishAction(new Runnable() {
                                    public void run() {
                                        progressLog.done();

                                        UIUtil.asyncExec(new Runnable() {
                                            public void run() {
                                                // Also include any triggered task whose implementation is currently unavailable.
                                                // Such tasks will not be needed by are likely needed after the restart when their implementations have been installed.
                                                SetupTaskPerformer performer = getPerformer();
                                                EList<SetupTask> remainingTasks = new BasicEList<SetupTask>(
                                                        performer.getNeededTasks());
                                                for (SetupTask setupTask : performer.getTriggeredSetupTasks()) {
                                                    if (setupTask instanceof DynamicSetupTaskImpl) {
                                                        remainingTasks.add(setupTask);
                                                    }
                                                }

                                                SetupUIPlugin.restart(trigger, remainingTasks);
                                            }
                                        });
                                    }
                                });

                                if (success && launchAutomatically) {
                                    wizard.performFinish();
                                    return Status.OK_STATUS;
                                }

                                progressLog.message("Press Finish to restart now or Cancel to restart later.",
                                        Severity.INFO);
                                disableCancelButton.set(false);
                            } else {
                                if (success && dismissAutomatically) {
                                    wizard.setFinishAction(new Runnable() {
                                        public void run() {
                                            IWizardContainer container = getContainer();
                                            if (container instanceof WizardDialog) {
                                                WizardDialog dialog = (WizardDialog) container;
                                                progressLog.done();
                                                dialog.close();
                                            }
                                        }
                                    });

                                    wizard.performFinish();
                                    return Status.OK_STATUS;
                                }

                                if (success) {
                                    progressLog.message("Press Finish to close the dialog.", Severity.INFO);

                                    if (launchButton != null && !hasLaunched && trigger == Trigger.BOOTSTRAP) {
                                        wizard.setFinishAction(new Runnable() {
                                            public void run() {
                                                if (launchAutomatically) {
                                                    try {
                                                        hasLaunched = launchProduct(getPerformer());
                                                    } catch (Exception ex) {
                                                        SetupUIPlugin.INSTANCE.log(ex);
                                                    }
                                                }
                                            }
                                        });
                                    }
                                } else {
                                    if (progressLog.isCanceled()) {
                                        progressLog.message("Task execution was canceled.", Severity.WARNING);
                                    } else {
                                        progressLog.message("There are failed tasks.", Severity.ERROR);
                                    }

                                    progressLog.message(
                                            "Press Back to choose different settings or Cancel to abort.",
                                            Severity.INFO);
                                }
                            }

                            IOUtil.close(getPerformer().getLogStream());

                            final boolean finalSuccess = success;
                            UIUtil.syncExec(new Runnable() {
                                public void run() {
                                    progressLog.done();
                                    setPageComplete(finalSuccess);
                                    setButtonState(IDialogConstants.BACK_ID, true);

                                    if (finalSuccess) {
                                        if (restart) {
                                            setMessage(
                                                    "Task execution has successfully completed but requires a restart.  Press Finish to restart now or Cancel to restart later.",
                                                    IMessageProvider.WARNING);
                                            setButtonState(IDialogConstants.CANCEL_ID, true);

                                            shell.setData(PROGRESS_STATUS, new Status(IStatus.WARNING,
                                                    SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                    "Task execution has successfully completed but requires a restart"));
                                        } else {
                                            setMessage(
                                                    "Task execution has successfully completed.  Press Back to choose different settings or Finish to exit.");
                                            if (disableCancelButton.get()) {
                                                setButtonState(IDialogConstants.CANCEL_ID, false);
                                            }

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.OK,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution has successfully completed"));
                                        }
                                    } else {
                                        setButtonState(IDialogConstants.CANCEL_ID, true);
                                        if (progressLog.isCanceled()) {
                                            setErrorMessage(
                                                    "Task execution was canceled.  Press Back to choose different settings or Cancel to abort.");

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.CANCEL,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution was canceled."));
                                        } else {
                                            setErrorMessage(
                                                    "There are failed tasks.  Press Back to choose different settings or Cancel to abort.");

                                            shell.setData(PROGRESS_STATUS,
                                                    new Status(IStatus.ERROR,
                                                            SetupEditPlugin.INSTANCE.getSymbolicName(),
                                                            "Task execution was failed."));
                                        }
                                    }
                                }
                            });
                        }

                        return Status.OK_STATUS;
                    }

                    @Override
                    public boolean belongsTo(Object family) {
                        return family == PROGRESS_FAMILY;
                    }
                };

                job.schedule();

            }
        };

        UIUtil.asyncExec(jobRunnable);
    } catch (

    Throwable ex)

    {
        SetupUIPlugin.INSTANCE.log(ex);
        ErrorDialog.open(ex);
    }

}

From source file:org.eclipse.osee.ats.editor.widget.ReviewInfoXWidget.java

License:Open Source License

private void createReviewHyperlink(Composite comp, IManagedForm managedForm, XFormToolkit toolkit,
        final AbstractReviewArtifact revArt, IStateToken forState) throws OseeCoreException {

    Composite workComp = toolkit.createContainer(comp, 1);
    workComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
    workComp.setLayout(ALayout.getZeroMarginLayout(3, false));

    Label strLabel = new Label(workComp, SWT.NONE);
    labelWidgets.add(strLabel);/*from  w w  w . j av a  2  s  .c  o  m*/
    if (revArt.isBlocking() && !revArt.isCompletedOrCancelled()) {
        strLabel.setText("State Blocking [" + revArt.getArtifactTypeName() + "] must be completed: ");
        IMessageManager messageManager = managedForm.getMessageManager();
        if (messageManager != null) {
            messageManager.addMessage(
                    "validation.error", "\"" + forState.getName() + "\" State has a blocking ["
                            + revArt.getArtifactTypeName() + "] that must be completed.",
                    null, IMessageProvider.ERROR, strLabel);
        }
    } else if (!revArt.isCompletedOrCancelled()) {
        strLabel.setText("Open [" + revArt.getArtifactTypeName() + "] exists: ");
        IMessageManager messageManager = managedForm.getMessageManager();
        if (messageManager != null) {
            messageManager.addMessage("validation.error",
                    "\"" + forState.getName() + "\" State has an open [" + revArt.getArtifactTypeName() + "].",
                    null, IMessageProvider.WARNING, strLabel);
        }
    } else {
        strLabel.setText(revArt.getStateMgr().getCurrentStateName() + " [" + revArt.getArtifactTypeName()
                + "] exists: ");
    }

    String str = "[" + revArt.getName() + "]";
    Hyperlink hyperLabel = toolkit.createHyperlink(workComp,
            (str.length() > 300 ? Strings.truncate(str, 300) + "..." : str), SWT.NONE);
    hyperLabel.setToolTipText("Select to open review");
    hyperLabel.addListener(SWT.MouseUp, new Listener() {
        @Override
        public void handleEvent(Event event) {
            SMAEditor.editArtifact(revArt);
        }
    });
}

From source file:org.eclipse.osee.framework.ui.skynet.artifact.editor.parts.MessageSummaryNote.java

License:Open Source License

private void configureFormText(final Form form, FormText text) {
    text.addHyperlinkListener(new HyperlinkAdapter() {
        @Override//from   w  w  w .ja  v a  2s .c  o m
        public void linkActivated(HyperlinkEvent e) {
            String is = (String) e.getHref();
            try {
                int index = Integer.parseInt(is);
                IMessage[] messages = form.getChildrenMessages();
                IMessage message = messages[index];
                Control c = message.getControl();
                ((FormText) e.widget).getShell().dispose();
                if (c != null) {
                    c.setFocus();
                }
            } catch (NumberFormatException ex) {
                OseeLog.log(Activator.class, OseeLevel.SEVERE, ex);
            }
        }
    });
    text.setImage("error", getImage(IMessageProvider.ERROR));
    text.setImage("warning", getImage(IMessageProvider.WARNING));
    text.setImage("info", getImage(IMessageProvider.INFORMATION));
}

From source file:org.eclipse.osee.framework.ui.skynet.artifact.editor.parts.MessageSummaryNote.java

License:Open Source License

private Image getImage(int type) {
    Image image = null;/*from  w w  w .  j ava  2  s  .  c o  m*/
    switch (type) {
    case IMessageProvider.ERROR:
        image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
        break;
    case IMessageProvider.WARNING:
        image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
        break;
    case IMessageProvider.INFORMATION:
        image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
        break;
    default:
        break;
    }
    return image;
}

From source file:org.eclipse.osee.framework.ui.skynet.artifact.editor.parts.MessageSummaryNote.java

License:Open Source License

private String getMessageSummary(IMessage[] messages) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("<form>");
    for (int i = 0; i < messages.length; i++) {
        IMessage message = messages[i];//www . jav  a2  s .  co  m
        pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\"");
        switch (message.getMessageType()) {
        case IMessageProvider.ERROR:
            pw.print("error");
            break;
        case IMessageProvider.WARNING:
            pw.print("warning");
            break;
        case IMessageProvider.INFORMATION:
            pw.print("info");
            break;
        }
        pw.print("\"> <a href=\"");
        pw.print(i + "");
        pw.print("\">");
        if (message.getPrefix() != null) {
            pw.print(message.getPrefix());
        }
        pw.print(message.getMessage());
        pw.println("</a></li>");
    }
    pw.println("</form>");
    pw.flush();
    return sw.toString();
}

From source file:org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportPage.java

License:Open Source License

protected boolean executeOperation(final IOperation operation) {
    final IStatus[] status = new IStatus[1];
    try {// w w  w.  j  av  a 2 s  .  c  o m
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    status[0] = Operations.executeWorkAndCheckStatus(operation, monitor);
                } catch (OseeCoreException ex) {
                    if (monitor.isCanceled()) {
                        throw new InterruptedException();
                    } else {
                        throw new InvocationTargetException(ex);
                    }
                }
            }
        });
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        displayErrorDialog(e.getTargetException());
        return false;
    }

    //grab the error here and
    if (operationReportMessages.length() != 0) {
        setMessage(operationReportMessages.toString(), IMessageProvider.WARNING);
    } else {
        setMessage("", IMessageProvider.NONE);
    }

    if (status[0].isOK()) {
        setErrorMessage(null);
    } else {
        setErrorMessage(status[0].getMessage());
    }
    return true;
}

From source file:org.eclipse.osee.framework.ui.skynet.widgets.XWidgetValidateUtility.java

License:Open Source License

public static int toMessageProviderLevel(int level) {
    int toReturn = IMessageProvider.NONE;
    if (level == IStatus.INFO) {
        toReturn = IMessageProvider.INFORMATION;
    } else if (level == IStatus.WARNING) {
        toReturn = IMessageProvider.WARNING;
    } else if (level == IStatus.ERROR) {
        toReturn = IMessageProvider.ERROR;
    }//from  ww w . ja v  a2s . com
    return toReturn;
}

From source file:org.eclipse.papyrus.core.adaptor.gmf.ModelManagerEditor.java

License:Open Source License

/**
 * @generated//w w  w  .  j a  va2  s.  c  om
 */
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
        // editor has been programmatically closed while the dialog was open
        return;
    }
    if (provider.isDeleted(input) && original != null) {
        String message = NLS.bind(Messages.ModelManagerEditor_SavingDeletedFile, original.getName());
        dialog.setErrorMessage(null);
        dialog.setMessage(message, IMessageProvider.WARNING);
    }
    if (dialog.open() == Window.CANCEL) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IPath filePath = dialog.getResult();
    if (filePath == null) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.ModelManagerEditor_SaveAsErrorTitle,
                    Messages.ModelManagerEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        // getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
        // getDocumentProvider().getDocument(getEditorInput()), true);
        getDocumentProvider().saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.ModelManagerEditor_SaveErrorTitle,
                    Messages.ModelManagerEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:org.eclipse.papyrus.uml.diagram.wizards.pages.SelectDiagramCategoryPage.java

License:Open Source License

/**
 * Validate file extension.//from   w  w  w  .  j a  v  a2  s . c  om
 *
 * @param categories the categories
 * @return true, if successful
 */
protected boolean validateFileExtension(String... categories) {
    IStatus status = ((CreateModelWizard) getWizard()).diagramCategoryChanged(categories);
    switch (status.getSeverity()) {
    case Status.ERROR:
        setErrorMessage(status.getMessage());
        return false;
    case Status.WARNING:
        setMessage(status.getMessage(), IMessageProvider.WARNING);
        break;
    case Status.INFO:
        setMessage(status.getMessage(), IMessageProvider.INFORMATION);
        break;
    }
    return true;
}