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:com.buildml.eclipse.utils.AlertDialog.java

License:Open Source License

/**
 * Display an warning dialog box in the context of the current shell. Both
 * a general message and an explanatory reason will be display. Given that there's
 * only an "OK" button, there's no return code needed.
 * @param title The general informational message to be displayed.
 * @param message The detailed reason for the event.
 *//* www. ja v  a  2s.com*/
public static void displayWarningDialog(String title, String message) {
    openDialog(title, message, IMessageProvider.WARNING, false);
}

From source file:com.byterefinery.rmbench.export.ModelCompareEditor.java

License:Open Source License

/**
 * ask the user for the workspace path of a file resource and save the document there.
 * <p><em>//from  w w  w  . ja  va 2  s. c o m
 * copied from {@link org.eclipse.ui.editors.text.TextEditor}. Sorry for that</em>
 * 
 * @param progressMonitor the progress monitor to be used
 */
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();

    if (documentProvider == null) {
        // editor has programmatically been  closed while the dialog was open
        return;
    }

    if (documentProvider.isDeleted(input) && original != null) {
        String message = MessageFormat.format(Messages.MCEditor_warning_save_delete,
                new Object[] { 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;
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFile file = workspace.getRoot().getFile(filePath);
    final IEditorInput newInput = new NonPersistableFileEditorInput(file);

    boolean success = false;
    try {

        documentProvider.aboutToChange(newInput);
        documentProvider.saveDocument(progressMonitor, newInput, documentProvider.getDocument(input), true);
        success = true;

    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            String title = Messages.MCEditor_error_save_title;
            String msg = MessageFormat.format(Messages.MCEditor_error_save_message,
                    new Object[] { x.getMessage() });

            if (status != null) {
                switch (status.getSeverity()) {
                case IStatus.INFO:
                    MessageDialog.openInformation(shell, title, msg);
                    break;
                case IStatus.WARNING:
                    MessageDialog.openWarning(shell, title, msg);
                    break;
                default:
                    MessageDialog.openError(shell, title, msg);
                }
            } else {
                MessageDialog.openError(shell, title, msg);
            }
        }
    } finally {
        documentProvider.changed(newInput);
        if (success)
            setInput(newInput);
    }

    if (progressMonitor != null)
        progressMonitor.setCanceled(!success);
}

From source file:com.centurylink.mdw.plugin.server.ServiceMixRuntimeWizardFragment.java

License:Apache License

protected boolean validate(IWizardHandle wizard) {
    if (runtime == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        return false;
    }/*from w w  w. ja  v  a2  s .c om*/

    IStatus status = runtime.validate();
    if (status == null || status.isOK())
        wizard.setMessage(null, IMessageProvider.NONE);
    else if (status.getSeverity() == IStatus.WARNING)
        wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
    else
        wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
    wizard.update();

    return status == null || status.isOK();
}

From source file:com.centurylink.mdw.plugin.server.ServiceMixServerWizardFragment.java

License:Apache License

protected boolean validate(IWizardHandle wizard) {
    if (server == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        return false;
    }//from  w w w .j a  v a2s .  c  o  m

    IStatus status = server.validate();
    if (status == null || status.isOK())
        wizard.setMessage(null, IMessageProvider.NONE);
    else if (status.getSeverity() == IStatus.WARNING)
        wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
    else
        wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
    wizard.update();

    return status == null || status.isOK();
}

From source file:com.cisco.yangide.editor.dialogs.StatusUtil.java

License:Open Source License

/**
 * Applies the status to the status line of a dialog page.
 */// w  w w  .j  a  va 2  s  .  co  m
public static void applyToStatusLine(DialogPage page, IStatus status) {
    String message = status.getMessage();
    if (message != null && message.length() == 0) {
        message = null;
    }
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(message, IMessageProvider.NONE);
        page.setErrorMessage(null);
        break;
    case IStatus.WARNING:
        page.setMessage(message, IMessageProvider.WARNING);
        page.setErrorMessage(null);
        break;
    case IStatus.INFO:
        page.setMessage(message, IMessageProvider.INFORMATION);
        page.setErrorMessage(null);
        break;
    default:
        page.setMessage(null);
        page.setErrorMessage(message);
        break;
    }
}

From source file:com.cloudbees.eclipse.dev.ui.views.forge.ForgeSyncConfirmation.java

License:Open Source License

private void checkForgeSyncEnablers() {
    List<String> plugins = getEnabledSCMPlugins();

    if (plugins.isEmpty()) {
        setMessage("Did not find any SCM plugins.", IMessageProvider.WARNING);
    } else {/* www  .  j  av  a  2 s .co m*/
        StringBuilder info = new StringBuilder("Found following SCM plugins: ");

        for (String name : plugins) {
            info.append(name).append(", ");
        }

        info.delete(info.length() - 2, info.length());

        setMessage(info.toString(), IMessageProvider.INFORMATION);
    }
}

From source file:com.dubture.pdt.ui.wizards.classes.ClassCreationWizardPage.java

License:Open Source License

protected void dialogChanged() {

    final String container = getContainerName();
    final String fileName = getFileName();

    if (abstractCheckbox.getSelection() && finalCheckbox.getSelection()) {
        updateStatus("A class cannot be abstract and final at the same time");
        return;//from  w  w w .j  a v a 2s .c o  m
    }
    if (container.length() == 0) {
        updateStatus(PHPUIMessages.PHPFileCreationWizardPage_10); //$NON-NLS-1$
        return;
    }

    if (fileName != null && !fileName.equals("") && getScriptFolder().getSourceModule(fileName).exists()) { //$NON-NLS-1$
        updateStatus("The specified class already exists"); //$NON-NLS-1$
        return;
    }

    int dotIndex = fileName.lastIndexOf('.');
    if (fileName.length() == 0 || dotIndex == 0) {
        updateStatus(PHPUIMessages.PHPFileCreationWizardPage_15); //$NON-NLS-1$
        return;
    }

    if (dotIndex != -1) {
        String fileNameWithoutExtention = fileName.substring(0, dotIndex);
        for (int i = 0; i < fileNameWithoutExtention.length(); i++) {
            char ch = fileNameWithoutExtention.charAt(i);
            if (!(Character.isJavaIdentifierPart(ch) || ch == '.' || ch == '-')) {
                updateStatus(PHPUIMessages.PHPFileCreationWizardPage_16); //$NON-NLS-1$
                return;
            }
        }
    }

    String text = fileText.getText();

    if (text.length() > 0 && Character.isLowerCase(fileText.getText().charAt(0))) {
        setMessage("Classes starting with lowercase letters are discouraged", IMessageProvider.WARNING);
    } else {
        setMessage("");
    }

    updateStatus(new IStatus[] { new StatusInfo() });
}

From source file:com.ebmwebsourcing.petals.common.internal.formeditor.JbiFormEditor.java

License:Open Source License

/**
 * Refreshes the markers/*from   w w  w  .j  a va2s .  c o  m*/
 * @param markerDeltas
 */
private void refreshMarkers() {

    if (this.editedFile == null || !this.editedFile.exists())
        return;

    try {
        // Prepare the messages
        final Set<String> warningMessages = new HashSet<String>();
        final Set<String> errorMessages = new HashSet<String>();
        IMarker[] markers = this.editedFile.findMarkers(PetalsConstants.MARKER_ID_JBI_XML, true,
                IResource.DEPTH_ZERO);
        if (markers != null) {
            for (IMarker marker : markers) {
                int severity = marker.getAttribute(IMarker.SEVERITY, -1);
                if (severity == IMarker.SEVERITY_ERROR)
                    errorMessages.add(marker.getAttribute(IMarker.MESSAGE, ""));
                else if (severity == IMarker.SEVERITY_WARNING)
                    warningMessages.add(marker.getAttribute(IMarker.MESSAGE, ""));
            }
        }

        // Update the message manager
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {

                if (JbiFormEditor.this.mainForm.isDisposed())
                    return;

                JbiFormEditor.this.mainForm.getMessageManager().removeAllMessages();
                int i = 0;
                for (String msg : errorMessages)
                    JbiFormEditor.this.mainForm.getMessageManager().addMessage("error" + i++, msg, null,
                            IMessageProvider.ERROR);

                for (String msg : warningMessages)
                    JbiFormEditor.this.mainForm.getMessageManager().addMessage("warning" + i++, msg, null,
                            IMessageProvider.WARNING);
            }
        });

    } catch (CoreException e) {
        PetalsCommonPlugin.log(e, IStatus.ERROR);
    }
}

From source file:com.ebmwebsourcing.petals.common.internal.provisional.utils.MarkerUtils.java

License:Open Source License

/**
 * Gets the {@link IMessageProvider} constant from an {@link IMarker} severity constant.
 * @param markerSeverity/*from   w  w w.  j ava2  s .co m*/
 * @return
 */
public static int getMessageSeverityFromMarkerSeverity(int markerSeverity) {

    int type;
    switch (markerSeverity) {
    case IMarker.SEVERITY_ERROR:
        type = IMessageProvider.ERROR;
        break;
    case IMarker.SEVERITY_WARNING:
        type = IMessageProvider.WARNING;
        break;
    case IMarker.SEVERITY_INFO:
        type = IMessageProvider.INFORMATION;
        break;
    default:
        type = IMessageProvider.NONE;
    }

    return type;
}

From source file:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java

License:Open Source License

/**
 * Updates the page status.//from ww  w  .  j av  a2s.c  o  m
 * @param message the message to show, or null to show nothing
 * @param status a {@link IMessageProvider} constant
 */
private void updateStatus(String message, int status) {

    setMessage(null, IMessageProvider.ERROR);
    setMessage(null, IMessageProvider.INFORMATION);
    setMessage(null, IMessageProvider.WARNING);
    setMessage(null, IMessageProvider.NONE);

    setMessage(message, status);
    setPageComplete(status != IMessageProvider.ERROR || message == null);
}