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

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

Introduction

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

Prototype

int INFORMATION

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

Click Source Link

Document

Constant for an info message (value 1).

Usage

From source file:org.rssowl.ui.internal.dialogs.SearchNewsDialog.java

License:Open Source License

private void restoreInfoMessage(boolean clearError) {
    if (clearError)
        setErrorMessage(null);//ww w .j  ava  2s .  com
    setMessage(Messages.SearchNewsDialog_SEARCH_HELP, IMessageProvider.INFORMATION);
}

From source file:org.rssowl.ui.internal.dialogs.SynchronizationStatusDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    /* Composite to hold all components */
    Composite composite = new Composite((Composite) super.createDialogArea(parent), SWT.NONE);
    composite.setLayout(LayoutUtils.createGridLayout(1, 5, 10));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    /* Title *//*from   w w w  .  ja  v a 2s  . co m*/
    setTitle(Messages.SynchronizationStatusDialog_SYNC_STATUS);

    /* Title Image */
    setTitleImage(OwlUI.getImage(fResources, "/icons/wizban/reader_wiz.png")); //$NON-NLS-1$

    /* Title Message */
    if (fStatus == null)
        setMessage(Messages.SynchronizationStatusDialog_NO_STATUS_AVAILABLE, IMessageProvider.INFORMATION);
    else if (fStatus.isOK())
        setMessage(Messages.SynchronizationStatusDialog_LAST_SYNC_OK, IMessageProvider.INFORMATION);
    else
        setMessage(Messages.SynchronizationStatusDialog_LAST_SYNC_ERROR, IMessageProvider.ERROR);

    /* Dialog Message Link */
    Link dialogMessageLink = new Link(composite, SWT.WRAP);
    dialogMessageLink.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    boolean isToday = fStatus != null
            ? DateUtils.isAfterIncludingToday(new Date(fStatus.getTime()),
                    DateUtils.getToday().getTimeInMillis())
            : false;
    DateFormat format = isToday ? fTimeFormat : fDateFormat;

    /* a) Never Synchronized */
    if (fStatus == null) {
        dialogMessageLink.setText(Messages.SynchronizationStatusDialog_NO_STATUS_MSG);
        dialogMessageLink.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                close();
                ImportAction action = new ImportAction();
                action.openWizardDefault(getParentShell());
            }
        });
    }

    /* b) Synchronized OK */
    else if (fStatus.isOK()) {
        if (fStatus.getItemCount() == 1)
            dialogMessageLink.setText(NLS.bind(Messages.SynchronizationStatusDialog_LAST_SYNC_OK_MSG,
                    format.format(fStatus.getTime()), fStatus.getTotalItemCount()));
        else
            dialogMessageLink.setText(NLS.bind(Messages.SynchronizationStatusDialog_LAST_SYNC_OK_MSG_N,
                    new Object[] { fStatus.getItemCount(), format.format(fStatus.getTime()),
                            fStatus.getTotalItemCount() }));
    }

    /* c) Synchronization ERROR */
    else {
        final String userUrl = (fStatus.getException() instanceof SyncConnectionException)
                ? ((SyncConnectionException) fStatus.getException()).getUserUrl()
                : null;

        /* Google provided link to solve the issue */
        if (StringUtils.isSet(userUrl)) {
            dialogMessageLink.setText(NLS.bind(Messages.SynchronizationStatusDialog_LAST_SYNC_ERROR_MSG_LINK,
                    format.format(fStatus.getTime()), fStatus.getException().getMessage()));
            dialogMessageLink.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    BrowserUtils.openLinkExternal(userUrl);
                }
            });
        }

        /* Other general connection issue */
        else {
            dialogMessageLink.setText(NLS.bind(Messages.SynchronizationStatusDialog_LAST_SYNC_ERROR_MSG,
                    format.format(fStatus.getTime()), CoreUtils.toMessage(fStatus.getException())));
        }
    }

    /* Spacer */
    new Label(composite, SWT.NONE);

    /* Holder for the separator to the OK and Cancel buttons */
    Composite sepHolder = new Composite(parent, SWT.NONE);
    sepHolder.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    sepHolder.setLayout(LayoutUtils.createGridLayout(1, 0, 0));

    /* Separator */
    Label separator = new Label(sepHolder, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    applyDialogFont(composite);

    return composite;
}

From source file:org.sonar.ide.eclipse.internal.ui.wizards.ServerLocationWizardPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
 *///  ww  w.  j av  a  2s.com
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText(Messages.ServerLocationWizardPage_label_host);
    serverUrlText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    serverUrlText.setLayoutData(gd);
    serverUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    // Sonar Server Username
    Label labelUsername = new Label(container, SWT.NULL);
    labelUsername.setText(Messages.ServerLocationWizardPage_label_username);
    serverUsernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    serverUsernameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Sonar Server password
    Label labelPassword = new Label(container, SWT.NULL);
    labelPassword.setText(Messages.ServerLocationWizardPage_label_password);
    serverPasswordText = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
    serverPasswordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Sonar test connection button
    testConnectionButton = new Button(container, SWT.PUSH);
    testConnectionButton.setText(Messages.ServerLocationWizardPage_action_test);
    testConnectionButton.setToolTipText(Messages.ServerLocationWizardPage_action_test_tooltip);
    testConnectionButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    testConnectionButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // We need those variables - in other case we would get an IllegalAccessException
            final String serverUrl = getServerUrl();
            final String username = getUsername();
            final String password = getPassword();
            try {
                getWizard().getContainer().run(true, true, new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Testing", IProgressMonitor.UNKNOWN);
                        try {
                            if (SonarCorePlugin.getServersManager().testSonar(serverUrl, username, password)) {
                                status = new Status(Status.OK, ISonarConstants.PLUGIN_ID,
                                        Messages.ServerLocationWizardPage_msg_connected);
                            } else {
                                status = new Status(Status.ERROR, ISonarConstants.PLUGIN_ID,
                                        Messages.ServerLocationWizardPage_msg_error);
                            }
                        } catch (CoreException e) {
                            status = e.getStatus();
                        } catch (OperationCanceledException e) {
                            status = Status.CANCEL_STATUS;
                            throw new InterruptedException();
                        } catch (Exception e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InvocationTargetException e1) {
                LoggerFactory.getLogger(getClass()).error(e1.getMessage(), e1);
            } catch (InterruptedException e1) { // NOSONAR - canceled
            }
            getWizard().getContainer().updateButtons();

            String message = status.getMessage();
            switch (status.getSeverity()) {
            case IStatus.OK:
                setMessage(message, IMessageProvider.INFORMATION);
                break;
            default:
                setMessage(message, IMessageProvider.ERROR);
                break;
            }
        }
    });

    initialize();
    dialogChanged();
    setControl(container);
}

From source file:org.sonar.ide.eclipse.ui.internal.wizards.associate.SonarSearchEngineProvider.java

License:Open Source License

public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> list = new ArrayList<IContentProposal>();
    for (ISonarServer sonarServer : sonarServers) {
        List<ISonarRemoteModule> remoteModules = WSClientFactory.getSonarClient(sonarServer)
                .searchRemoteModules(contents);
        for (ISonarRemoteModule resource : remoteModules) {
            RemoteSonarProject prj = new RemoteSonarProject(sonarServer.getUrl(), resource.getKey(),
                    resource.getName());
            list.add(new ContentProposal(prj.asString(), resource.getName(), prj.getDescription()));
        }// w w w. j a  v  a  2s.co  m
    }
    if (!list.isEmpty()) {
        parentPage.setMessage("", IMessageProvider.NONE);
        return list.toArray(new IContentProposal[list.size()]);
    } else {
        parentPage.setMessage("No result", IMessageProvider.INFORMATION);
        return new IContentProposal[0];
    }
}

From source file:org.sonar.ide.eclipse.ui.internal.wizards.ServerLocationWizardPage.java

License:Open Source License

private void createTestConnectionButton(Composite container) {
    Button testConnectionButton = new Button(container, SWT.PUSH);
    testConnectionButton.setText(Messages.ServerLocationWizardPage_action_test);
    testConnectionButton.setToolTipText(Messages.ServerLocationWizardPage_action_test_tooltip);
    testConnectionButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    testConnectionButton.addSelectionListener(new SelectionAdapter() {

        @Override//ww  w  . j a  v a 2 s  .c o  m
        public void widgetSelected(SelectionEvent e) {
            // We need those variables - in other case we would get an IllegalAccessException
            final String serverUrl = getServerUrl();
            final String username = getUsername();
            final String password = getPassword();
            try {
                ServerConnectionTestJob testJob = new ServerConnectionTestJob(username, password, serverUrl);
                getWizard().getContainer().run(true, true, testJob);
                status = testJob.getStatus();
            } catch (InvocationTargetException e1) {
                LoggerFactory.getLogger(getClass()).error(e1.getMessage(), e1);
                status = new Status(IStatus.ERROR, SonarUiPlugin.PLUGIN_ID,
                        Messages.ServerLocationWizardPage_msg_error);
            } catch (InterruptedException e1) {
                LoggerFactory.getLogger(getClass()).error(e1.getMessage(), e1);
                status = new Status(IStatus.ERROR, SonarUiPlugin.PLUGIN_ID,
                        Messages.ServerLocationWizardPage_msg_error);
            } catch (OperationCanceledException e1) {
                status = Status.CANCEL_STATUS;
            }
            getWizard().getContainer().updateButtons();

            String message = status.getMessage();
            switch (status.getSeverity()) {
            case IStatus.OK:
                setMessage(message, IMessageProvider.INFORMATION);
                break;
            default:
                setMessage(message, IMessageProvider.ERROR);
                break;
            }
        }
    });
}

From source file:org.sonarlint.eclipse.ui.internal.bind.SearchEngineProvider.java

License:Open Source License

@Override
public IContentProposal[] getProposals(String contents, int position) {
    if (!server.isUpdated()) {
        parentPage.setMessage("Please update server first", IMessageProvider.INFORMATION);
        return new IContentProposal[0];
    }//from w  w w .jav  a2 s .co m
    List<IContentProposal> list = new ArrayList<>();
    try {
        List<RemoteModule> modules = getModuleIndex().search(contents);
        for (RemoteModule m : modules) {
            RemoteSonarProject prj = new RemoteSonarProject(server.getId(), m.getKey(), m.getName());
            list.add(new ContentProposal(prj.asString(), m.getName(), prj.getDescription()));
        }
    } catch (Exception e) {
        SonarLintCorePlugin.getDefault().debug("Unable to search modules from server " + server.getId(), e);
    }
    if (!list.isEmpty()) {
        parentPage.setMessage("", IMessageProvider.NONE);
        return list.toArray(new IContentProposal[list.size()]);
    } else {
        parentPage.setMessage("No results", IMessageProvider.INFORMATION);
        return new IContentProposal[0];
    }
}

From source file:org.sonarlint.eclipse.ui.internal.server.wizard.OrganizationProvider.java

License:Open Source License

@Override
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> list = new ArrayList<>();
    TextSearchIndex<RemoteOrganization> organizationsIndex = model.getOrganizationsIndex();
    Map<RemoteOrganization, Double> filtered = organizationsIndex != null ? organizationsIndex.search(contents)
            : Collections.emptyMap();
    if (filtered.isEmpty()) {
        parentPage.setMessage("No results", IMessageProvider.INFORMATION);
    } else {//  w ww.  jav  a  2s. c  om
        parentPage.setMessage("", IMessageProvider.NONE);
    }
    List<Map.Entry<RemoteOrganization, Double>> entries = new ArrayList<>(filtered.entrySet());
    entries.sort(Comparator.comparing(Map.Entry<RemoteOrganization, Double>::getValue).reversed()
            .thenComparing(Comparator.comparing(e -> e.getKey().getName(), String.CASE_INSENSITIVE_ORDER)));
    for (Map.Entry<RemoteOrganization, Double> e : entries) {
        list.add(new ContentProposal(e.getKey().getKey(), e.getKey().getName(), toDescription(e.getKey())));
    }
    return list.toArray(new IContentProposal[list.size()]);
}

From source file:org.sonarlint.eclipse.ui.internal.server.wizard.ServerLocationWizardPage.java

License:Open Source License

private void createTestConnectionButton(Composite container) {
    Button testConnectionButton = new Button(container, SWT.PUSH);
    testConnectionButton.setText(Messages.ServerLocationWizardPage_action_test);
    testConnectionButton.setToolTipText(Messages.ServerLocationWizardPage_action_test_tooltip);
    testConnectionButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    testConnectionButton.addSelectionListener(new SelectionAdapter() {

        @Override/*from  w  w w  . ja  v a 2  s .  c o  m*/
        public void widgetSelected(SelectionEvent e) {
            try {
                ServerConnectionTestJob testJob = new ServerConnectionTestJob(transcientServer(), getUsername(),
                        getPassword());
                getWizard().getContainer().run(true, true, testJob);
                status = testJob.getStatus();
            } catch (OperationCanceledException e1) {
                status = Status.CANCEL_STATUS;
            } catch (Exception e1) {
                status = new Status(IStatus.ERROR, SonarLintUiPlugin.PLUGIN_ID,
                        Messages.ServerLocationWizardPage_msg_error + " " + e1.getMessage(), e1);
            }
            getWizard().getContainer().updateButtons();

            String message = status.getMessage();
            if (status.getSeverity() == IStatus.OK) {
                setMessage(message, IMessageProvider.INFORMATION);
            } else {
                setMessage(message, IMessageProvider.ERROR);
            }
        }
    });
}

From source file:org.springframework.extensions.surf.alfresco.model.editor.page.ModelXMLAbstractPage.java

License:Apache License

/**
 * @param type/*w ww. ja  va 2s .c o m*/
 * @return
 */
protected Image getImage(int type) {
    switch (type) {
    case IMessageProvider.ERROR:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
    case IMessageProvider.WARNING:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
    case IMessageProvider.INFORMATION:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
    }
    return null;
}

From source file:org.springframework.extensions.surf.alfresco.model.editor.page.ModelXMLAbstractPage.java

License:Apache License

/**
 * @param form//  w  w  w  .  ja v  a2s  . c o m
 * @param text
 */
protected void configureFormText(final Form form, FormText text) {
    text.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.setFocus();
            } catch (NumberFormatException ex) {
            }
        }
    });
    text.setImage("error", getImage(IMessageProvider.ERROR));
    text.setImage("warning", getImage(IMessageProvider.WARNING));
    text.setImage("info", getImage(IMessageProvider.INFORMATION));
}