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.wst.wsdl.ui.internal.contentgenerator.ui.SoapBindingOptionsPage.java

License:Open Source License

public String getMessage() {
    String message = null;//w  w  w.j a v a  2s.c  o m
    if (rpcEncoded != null && rpcEncoded.getSelection()) {
        if (wizardPage instanceof WSDLNewFileOptionsPage) {
            IProject project = ((WSDLNewFileOptionsPage) wizardPage).getProject();
            IServicePolicy policy = ((WSDLNewFileOptionsPage) wizardPage).getServicePolicy();
            int messageType = ServicePolicyHelper.getMessageSeverity(project, policy);
            if (messageType == IMessageProvider.ERROR) {
                message = Messages._ERROR_WSI_COMPLIANCE_RPC_ENCODING;
            } else if (messageType == IMessageProvider.WARNING) {
                message = Messages._WARN_WSI_COMPLIANCE_RPC_ENCODING;
            }
        }
    }
    if (message == null)
        message = ""; //$NON-NLS-1$ 
    return message;
}

From source file:org.eclipse.wst.wsdl.ui.internal.util.ServicePolicyHelper.java

License:Open Source License

/**
 * Get the severity to be used when there are problems with the current policy
 * /*from ww w.  j av  a 2 s. c o m*/
 * @param project
 * @param policy
 * @return int (IMessageProvider.NONE, IMessageProvider.ERROR,
 *         IMessageProvider.WARNING)
 */
public static int getMessageSeverity(IProject project, IServicePolicy policy) {
    int messageSeverity = IMessageProvider.NONE;

    if (policy != null) {
        IPolicyStateEnum policyStateEnum = policy.getPolicyStateEnum(project);
        String enumId = policyStateEnum.getCurrentItem().getId();

        if (WSIServicePoliciesConstants.stateEnumRequire.equals(enumId))
            messageSeverity = IMessageProvider.ERROR;
        else if (WSIServicePoliciesConstants.stateEnumSuggest.equals(enumId))
            messageSeverity = IMessageProvider.WARNING;
    }

    return messageSeverity;
}

From source file:org.eclipse.wst.wsdl.ui.internal.wizards.WSDLNewFileOptionsPage.java

License:Open Source License

/**
 * Validates protocol by checking if there is an active wsi policy requires or
 * suggests a default protocol and that protocol is not the same as the
 * currently selected protocol//  w  ww  .j a  v  a2  s.  c o  m
 * 
 * @param protocol
 * @return
 */
private boolean validateProtocol(String protocol) {
    ContentGeneratorUIExtensionRegistry registry = WSDLEditorPlugin.getInstance()
            .getContentGeneratorUIExtensionRegistry();
    ContentGeneratorUIExtension extension = registry.getExtensionForLabel(protocol);
    if (extension != null) {
        String namespace = extension.getNamespace();
        if (namespace != null) {
            IProject project = getProject();
            if (activeServicePolicy != null) {
                // get default binding and compare if same or not
                String defaultBinding = ServicePolicyHelper.getDefaultBinding(project, activeServicePolicy);
                if (!defaultBinding.equals(namespace)) {
                    int messageType = ServicePolicyHelper.getMessageSeverity(project, activeServicePolicy);
                    if (messageType == IMessageProvider.ERROR) {
                        // if not same, set error message
                        // put up an error message
                        ContentGeneratorUIExtension ext = registry.getExtensionForNamespace(defaultBinding);
                        if (ext != null) {
                            String n = ext.getLabel();
                            setMessage(NLS.bind(Messages._ERROR_WSI_COMPLIANCE_PROTOCOL, new String[] { n }),
                                    IMessageProvider.ERROR);
                        }
                        return false;
                    } else if (messageType == IMessageProvider.WARNING) {
                        // put up a warning message
                        ContentGeneratorUIExtension ext = registry.getExtensionForNamespace(defaultBinding);
                        if (ext != null) {
                            String n = ext.getLabel();
                            setMessage(NLS.bind(Messages._WARN_WSI_COMPLIANCE_PROTOCOL, new String[] { n }),
                                    IMessageProvider.WARNING);
                        }
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

From source file:org.eclipse.xtext.ui.preferences.PropertyAndPreferencePage.java

License:Open Source License

private static void applyToStatusLine(DialogPage page, IStatus status) {
    String message = status.getMessage();
    if (message != null && message.length() == 0) {
        message = null;/*from  w ww.  ja  va2  s. c om*/
    }
    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:org.eclipse.xtext.ui.wizard.template.NewFileWizardPrimaryPage.java

License:Open Source License

@Override
public void setStatus(IStatus status) {
    if (status == null || status.getSeverity() == IStatus.OK) {
        setErrorMessage(null);/*from   ww  w .  j  av a 2s .c  o  m*/
        setMessage(null);
        setPageComplete(true);
    } else if (status.getSeverity() == IStatus.ERROR) {
        setErrorMessage(status.getMessage());
        setPageComplete(false);
    } else if (status.getSeverity() == IStatus.WARNING) {
        setErrorMessage(null);
        setMessage(status.getMessage(), IMessageProvider.WARNING);
        setPageComplete(true);
    } else {
        setErrorMessage(null);
        setMessage(status.getMessage(), IMessageProvider.INFORMATION);
        setPageComplete(true);
    }
}

From source file:org.eclipse.xtext.xtext.ui.wizard.project.AdvancedNewProjectPage.java

License:Open Source License

public Procedure0 checkWidgets(final SelectionEvent e) {
    Procedure0 _xblockexpression = null;
    {/*  w ww  . j av  a2s .  c  om*/
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.MAVEN)
                && (!this.isBundleResolved("org.eclipse.m2e.maven.runtime")))) {
            this.<Control>reportIssue(IMessageProvider.WARNING, Messages.AdvancedNewProjectPage_noM2e);
        }
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.GRADLE)
                && (!this.isBundleResolved("org.eclipse.buildship.core")))) {
            this.<Control>reportIssue(IMessageProvider.WARNING, Messages.AdvancedNewProjectPage_noBuildship);
        }
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.GRADLE)
                && this.createUiProject.getSelection())) {
            this.<Control>reportIssue(IMessageProvider.WARNING,
                    Messages.AdvancedNewProjectPage_eclipseAndGradleWarn);
        }
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.MAVEN)
                && this.createIdeaProject.getSelection())) {
            this.<Control>reportIssue(IMessageProvider.WARNING,
                    Messages.AdvancedNewProjectPage_ideaAndMavenWarn);
        }
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.NONE)
                && this.createIdeaProject.getSelection())) {
            this.<Control>reportIssue(IMessageProvider.INFORMATION,
                    Messages.AdvancedNewProjectPage_ideaReqGradleInfo);
        }
        if (((this.createUiProject.getSelection() && this.createP2Project.getSelection())
                && (!this.createSDKProject.getSelection()))) {
            this.<Control>addIssue(IMessageProvider.INFORMATION, Messages.AdvancedNewProjectPage_p2AndSdkInfo);
        }
        Object _source = null;
        if (e != null) {
            _source = e.getSource();
        }
        final Object source = _source;
        if ((this.createUiProject.getSelection()
                && (!this.isSelected(this.sourceLayout, SourceLayout.PLAIN)))) {
            if ((this.createUiProject == source)) {
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("\'");
                String _text = this.createUiProject.getText();
                _builder.append(_text);
                _builder.append("\' requires ");
                _builder.append(SourceLayout.PLAIN);
                _builder.append(" source layout.");
                _builder.newLineIfNotEmpty();
                _builder.append("Please <a>select \'");
                _builder.append(SourceLayout.PLAIN);
                _builder.append("\'</a> source layout.");
                final Procedure0 _function = () -> {
                    this.select(this.sourceLayout, SourceLayout.PLAIN);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder.toString(), _function);
            } else {
                StringConcatenation _builder_1 = new StringConcatenation();
                _builder_1.append(SourceLayout.MAVEN);
                _builder_1.append(" source layout is not supported by the \'");
                String _text_1 = this.createUiProject.getText();
                _builder_1.append(_text_1);
                _builder_1.append("\' project.");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("Please <a>deselect \'");
                String _text_2 = this.createUiProject.getText();
                _builder_1.append(_text_2);
                _builder_1.append("\'</a>.");
                final Procedure0 _function_1 = () -> {
                    this.createUiProject.setSelection(false);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder_1.toString(), _function_1);
            }
        }
        if ((this.isSelected(this.preferredBuildSystem, BuildSystem.NONE)
                && this.isSelected(this.sourceLayout, SourceLayout.MAVEN))) {
            if ((this.preferredBuildSystem == source)) {
                StringConcatenation _builder_2 = new StringConcatenation();
                _builder_2.append("Maven/Gradle source layout is not supported without a build system.");
                _builder_2.newLine();
                _builder_2.append("Please <a>select \'");
                _builder_2.append(SourceLayout.PLAIN);
                _builder_2.append("\'</a> source layout.");
                final Procedure0 _function_2 = () -> {
                    this.select(this.sourceLayout, SourceLayout.PLAIN);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder_2.toString(), _function_2);
            } else {
                StringConcatenation _builder_3 = new StringConcatenation();
                _builder_3.append(
                        "Maven/Gradle source layout is only supported when using Maven or Gradle build system.");
                _builder_3.newLine();
                _builder_3.append("You need to choose Maven or Gradle build system.");
                _builder_3.newLine();
                _builder_3.append("Select <a>Gradle</a> build.");
                final Procedure0 _function_3 = () -> {
                    this.select(this.preferredBuildSystem, BuildSystem.GRADLE);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder_3.toString(), _function_3);
            }
        }
        if ((this.createWebProject.getSelection()
                && this.isSelected(this.preferredBuildSystem, BuildSystem.NONE))) {
            if ((this.preferredBuildSystem == source)) {
                StringConcatenation _builder_4 = new StringConcatenation();
                _builder_4.append("The \'");
                String _text_3 = this.createWebProject.getText();
                _builder_4.append(_text_3);
                _builder_4.append("\' project can not be build without a build system.");
                _builder_4.newLineIfNotEmpty();
                _builder_4.append("Please <a>deselect \'");
                String _text_4 = this.createWebProject.getText();
                _builder_4.append(_text_4);
                _builder_4.append("\'</a>.");
                final Procedure0 _function_4 = () -> {
                    this.createWebProject.setSelection(false);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder_4.toString(), _function_4);
            } else {
                StringConcatenation _builder_5 = new StringConcatenation();
                _builder_5.append("To build the \'");
                String _text_5 = this.createWebProject.getText();
                _builder_5.append(_text_5);
                _builder_5.append("\' project, you need to choose Maven or Gradle build system.");
                _builder_5.newLineIfNotEmpty();
                _builder_5.append("Select <a>Gradle</a> build.");
                final Procedure0 _function_5 = () -> {
                    this.select(this.preferredBuildSystem, BuildSystem.GRADLE);
                };
                this.<Control>reportIssue(IMessageProvider.ERROR, _builder_5.toString(), _function_5);
            }
        }
        if (this.autoSelectIdeProject) {
            this.autoSelectIdeProject = false;
            StringConcatenation _builder_6 = new StringConcatenation();
            _builder_6.append("\'");
            String _text_6 = this.createIdeProject.getText();
            _builder_6.append(_text_6);
            _builder_6.append("\' project was automatically selected as option \'");
            String _text_7 = ((Button) source).getText();
            _builder_6.append(_text_7);
            _builder_6.append("\' requires it.");
            this.<Control>reportIssue(IMessageProvider.INFORMATION, _builder_6.toString());
        }
        Procedure0 _xifexpression = null;
        if (this.autoSelectSDKProject) {
            Procedure0 _xblockexpression_1 = null;
            {
                this.autoSelectSDKProject = false;
                StringConcatenation _builder_7 = new StringConcatenation();
                _builder_7.append("\'");
                String _text_8 = this.createSDKProject.getText();
                _builder_7.append(_text_8);
                _builder_7.append("\' was automatically selected as option \'");
                String _text_9 = ((Button) source).getText();
                _builder_7.append(_text_9);
                _builder_7.append("\' requires it.");
                _xblockexpression_1 = this.<Control>reportIssue(IMessageProvider.INFORMATION,
                        _builder_7.toString());
            }
            _xifexpression = _xblockexpression_1;
        }
        _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
}

From source file:org.eclipse.xtext.xtext.ui.wizard.project.StatusWidget.java

License:Open Source License

private Image imageFor(final int type) {
    Image _switchResult = null;//from  www . ja  v a2  s. c  om
    switch (type) {
    case IMessageProvider.NONE:
        _switchResult = null;
        break;
    case IMessageProvider.INFORMATION:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case IMessageProvider.WARNING:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case IMessageProvider.ERROR:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    }
    return _switchResult;
}

From source file:org.ect.reo.diagram.part.ReoDiagramEditor.java

License:Open Source License

/**
 * @generated/* ww w  .j ava2s.c o  m*/
 */
@Override
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.ReoDiagramEditor_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.ReoDiagramEditor_SaveAsErrorTitle,
                    Messages.ReoDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).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.ReoDiagramEditor_SaveErrorTitle,
                    Messages.ReoDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:org.emftext.language.secprop.diagram.part.SecpropDiagramEditor.java

License:Open Source License

/**
 * @generated//  ww w .ja  va2  s. co  m
 */
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.SecpropDiagramEditor_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.SecpropDiagramEditor_SaveAsErrorTitle,
                    Messages.SecpropDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).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.SecpropDiagramEditor_SaveErrorTitle,
                    Messages.SecpropDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:org.emftext.language.valueflow.diagram.part.ValueflowDiagramEditor.java

License:Open Source License

/**
 * @generated//from  w  ww .  j  ava 2 s .  co  m
 */
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.ValueflowDiagramEditor_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.ValueflowDiagramEditor_SaveAsErrorTitle,
                    Messages.ValueflowDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).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.ValueflowDiagramEditor_SaveErrorTitle,
                    Messages.ValueflowDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}