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.versant.core.jdo.tools.eclipse.VOAConfigComposite.java

License:Open Source License

private void validateProject() {
    String projectPath = pc.getProjectFilePath();
    if (projectPath == null || projectPath.length() == 0) {
        setMessage("Please select a VOA Project file.", IMessageProvider.ERROR);
        return;//from w  w  w.j  a va2 s.  c o  m
    }
    File file = new File(projectPath);
    String cPath = projectPath;
    try {
        cPath = file.getCanonicalPath();
    } catch (IOException e1) {
        cPath = file.getAbsolutePath();
    }
    if (!file.getAbsolutePath().equals(projectPath)) {
        file = new java.io.File(project.getLocation().toFile(), projectPath);
    }
    try {
        cPath = file.getCanonicalPath();
    } catch (IOException e1) {
        cPath = file.getAbsolutePath();
    }
    projectPath = cPath;
    pc.setProjectFilePath(projectPath);
    if (file != null && file.isDirectory()) {
        setMessage(projectPath + " is not a valid file.", IMessageProvider.ERROR);
        return;
    }
    if (file != null && file.exists() && !file.canWrite()) {
        setMessage("Project must be writable", IMessageProvider.ERROR);
        return;
    }
    boolean createFile = file == null || !file.exists();
    if (createFile) {
        File source = null;
        try {
            source = Utils.getSrcFile(project);
        } catch (JavaModelException e) {
            source = project.getLocation().toFile();
        }
        String jdoPathStr = source.getName() + "/" + project.getName() + ".jdo";
        setMessage("Create Project file: " + file + "\nand .jdo file: " + jdoPathStr, IMessageProvider.WARNING);
    } else {
        setMessage("Project file found", IMessageProvider.INFORMATION);
        Properties props = new Properties();
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            props.load(in);
        } catch (Exception e) {
            e.printStackTrace();
            try {
                in.close();
            } catch (Exception x) {
            }
        }
        if (!props.containsKey("javax.jdo.option.ConnectionURL")) {
            setMessage("Project file(" + file.getName()
                    + ") is not valid.\nIt does not contain the property:javax.jdo.option.ConnectionURL",
                    IMessageProvider.ERROR);
            return;
        }
    }
}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.TcServer20WizardFragment.java

License:Open Source License

protected void validate() {
    if (wc == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        return;/*  w w w . j ava 2  s  .  c  o m*/
    }

    IStatus status = doValidate();
    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();
}

From source file:com.vmware.vfabric.ide.eclipse.tcserver.internal.ui.TcServer21WizardFragment.java

License:Open Source License

protected void validate() {
    if (!newInstanceButton.getSelection() && serverNameCombo.getText().length() == 0) {
        wizard.setMessage(SPECIFY_TC_SERVER_INSTANCE_MESSAGE, IMessageProvider.NONE);
        setComplete(false);//  w w w . java 2s . c o m
        return;
    }

    if (wc == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        setComplete(false);
        return;
    }

    IStatus status = doValidate();
    if (status == null || status.isOK()) {
        wizard.setMessage(null, IMessageProvider.NONE);
        setComplete(true);
    } else if (status.getSeverity() == IStatus.INFO) {
        wizard.setMessage(status.getMessage(), IMessageProvider.NONE);
        setComplete(false);
    } else if (status.getSeverity() == IStatus.WARNING) {
        wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
        setComplete(true);
    } else {
        wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
        setComplete(false);
    }
    updateDescription(status);
    wizard.update();
}

From source file:crosswalk.diagram.part.CrosswalkDiagramEditor.java

License:Apache License

/**
 * @generated//w  w w . jav  a 2  s . c o 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.CrosswalkDiagramEditor_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.CrosswalkDiagramEditor_SaveAsErrorTitle,
                    Messages.CrosswalkDiagramEditor_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.CrosswalkDiagramEditor_SaveErrorTitle,
                    Messages.CrosswalkDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:de.gulden.modeling.wave.diagram.part.WaveDiagramEditor.java

License:Open Source License

/**
 * @generated//from  w w  w.j a  v a 2s.  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.WaveDiagramEditor_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.WaveDiagramEditor_SaveAsErrorTitle,
                    Messages.WaveDiagramEditor_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.WaveDiagramEditor_SaveErrorTitle,
                    Messages.WaveDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:de.hentschel.visualdbc.dbcmodel.diagram.part.DbCDiagramEditor.java

License:Open Source License

/**
 * @generated//  ww w  . j  a  v a 2 s .  c  o  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.DbCDiagramEditor_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.DbCDiagramEditor_SaveAsErrorTitle,
                    Messages.DbCDiagramEditor_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.DbCDiagramEditor_SaveErrorTitle,
                    Messages.DbCDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:de.innot.avreclipse.ui.dialogs.ChangeMCUDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    String title = MessageFormat.format("Change MCU for file {0}", fFileName);
    setTitle(title);/*  www .  j  a v  a  2s.  c  om*/

    // create the top level composite for the dialog area
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(parent.getFont());

    // Build a separator line. This is just eye candy.
    Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
    titleBarSeparator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));

    // The real content
    Composite body = new Composite(composite, SWT.NONE);
    body.setLayout(new GridLayout(2, false));

    Label label = new Label(body, SWT.NONE);
    label.setText("Select new MCU:");

    Set<String> allmcusset = getMCUList();
    final String[] allmcuids = allmcusset.toArray(new String[allmcusset.size()]);
    Arrays.sort(allmcuids);

    final String[] allmcunames = new String[allmcuids.length];

    int oldmcuindex = -1;
    for (int i = 0; i < allmcuids.length; i++) {
        allmcunames[i] = AVRMCUidConverter.id2name(allmcuids[i]);
        if (fSourceValues.getMCUId().equals(allmcuids[i])) {
            oldmcuindex = i;
        }
    }

    fMCUCombo = new Combo(body, SWT.READ_ONLY);
    fMCUCombo.setItems(allmcunames);
    fMCUCombo.setVisibleItemCount(Math.min(allmcunames.length, 25));
    fMCUCombo.select(oldmcuindex);
    fMCUCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fNewMCU = allmcuids[fMCUCombo.getSelectionIndex()];
            boolean isCompatible = fSourceValues.isCompatibleWith(fNewMCU);
            fOKButton.setText(isCompatible ? TEXT_OK : TEXT_CONVERT);
            if (!isCompatible) {
                setMessage("Selected MCU is not compatible with current MCU.", IMessageProvider.WARNING);
            } else {
                setMessage(null);
            }
        }
    });

    return composite;
}

From source file:de.lmu.ifi.dbs.medmon.base.ui.validation.FormValidationAdapter.java

License:Open Source License

/**
 * Configures the <code>FormText</code> to display the errors.
 * /*from   w w w  .j  a va 2  s  . com*/
 * @param form
 *            The parent <code>Form</code>
 * @param formText
 *            The <code>FormText</code> to be configured
 */
private void configureFormText(final Form form, FormText formText) {
    formText.addHyperlinkListener(new HyperlinkAdapter() {
        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.isDisposed())
                    c.setFocus();
            } catch (NumberFormatException ex) {
            }
        }
    });
    formText.setImage("error", getImage(IMessageProvider.ERROR)); //$NON-NLS-1$
    formText.setImage("warning", getImage(IMessageProvider.WARNING)); //$NON-NLS-1$
    formText.setImage("info", getImage(IMessageProvider.INFORMATION)); //$NON-NLS-1$
}

From source file:de.lmu.ifi.dbs.medmon.base.ui.validation.FormValidationAdapter.java

License:Open Source License

/**
 * Creates the content for the error shell.
 * // w  w w  .  j  a v  a 2 s  .  com
 * @param messages
 *            The messages to be displayed
 * @return the messages as <code>String</code>
 */
private String createErrorShellContent(IMessage[] messages) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("<form>"); //$NON-NLS-1$
    for (int i = 0; i < messages.length; i++) {
        IMessage message = messages[i];
        pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\""); //$NON-NLS-1$
        switch (message.getMessageType()) {
        case IMessageProvider.ERROR:
            pw.print("error"); //$NON-NLS-1$
            break;
        case IMessageProvider.WARNING:
            pw.print("warning"); //$NON-NLS-1$
            break;
        case IMessageProvider.INFORMATION:
            pw.print("info"); //$NON-NLS-1$
            break;
        }
        pw.print("\"> <a href=\""); //$NON-NLS-1$
        pw.print(i + ""); //$NON-NLS-1$
        pw.print("\">"); //$NON-NLS-1$
        if (message.getPrefix() != null)
            pw.print(message.getPrefix());
        pw.print(message.getMessage());
        pw.println("</a></li>"); //$NON-NLS-1$
    }
    pw.println("</form>"); //$NON-NLS-1$
    pw.flush();
    return sw.toString();
}

From source file:de.lmu.ifi.dbs.medmon.base.ui.validation.FormValidationAdapter.java

License:Open Source License

/**
 * Returns the <code>Image</code> for the given message type.
 * /*from  ww w. j av a 2s  .  com*/
 * @param type
 *            The given message typ
 * @return the <code>Image</code>
 */
private Image getImage(int type) {
    switch (type) {
    case IMessageProvider.ERROR:
        return null; //$NON-NLS-1$
    case IMessageProvider.WARNING:
        return null; //$NON-NLS-1$
    case IMessageProvider.INFORMATION:
        return null; //$NON-NLS-1$
    }
    return null;
}