Search in sources :

Example 1 with IMessageManager

use of org.eclipse.ui.forms.IMessageManager in project bndtools by bndtools.

the class RepositorySelectionPart method reloadRepos.

private void reloadRepos() {
    final IMessageManager messages = getManagedForm().getMessageManager();
    messages.removeMessage(MESSAGE_KEY, runReposViewer.getControl());
    final List<Repository> allRepos = new ArrayList<>();
    try {
        allRepos.addAll(repositories.getOrdered());
        runReposViewer.setInput(allRepos);
    } catch (Exception e) {
        messages.addMessage(MESSAGE_KEY, "Repository List: Unable to load OSGi Repositories. " + e.getMessage(), e, IMessageProvider.ERROR, runReposViewer.getControl());
        // Load the repos and clear the error message if the Workspace is initialised later.
        Central.onWorkspaceInit(new Success<Workspace, Void>() {

            @Override
            public Promise<Void> call(final Promise<Workspace> resolved) throws Exception {
                final Deferred<Void> completion = new Deferred<>();
                SWTConcurrencyUtil.execForControl(runReposViewer.getControl(), true, new Runnable() {

                    @Override
                    public void run() {
                        try {
                            allRepos.clear();
                            allRepos.addAll(resolved.getValue().getPlugins(Repository.class));
                            runReposViewer.setInput(allRepos);
                            messages.removeMessage(MESSAGE_KEY, runReposViewer.getControl());
                            completion.resolve(null);
                        } catch (Exception e) {
                            completion.fail(e);
                        }
                    }
                });
                return completion.getPromise();
            }
        });
    }
    updateButtons();
}
Also used : Promise(org.osgi.util.promise.Promise) Repository(org.osgi.service.repository.Repository) WorkspaceR5Repository(bndtools.central.WorkspaceR5Repository) Deferred(org.osgi.util.promise.Deferred) ArrayList(java.util.ArrayList) IMessageManager(org.eclipse.ui.forms.IMessageManager) InvocationTargetException(java.lang.reflect.InvocationTargetException) Success(org.osgi.util.promise.Success)

Example 2 with IMessageManager

use of org.eclipse.ui.forms.IMessageManager in project bndtools by bndtools.

the class ImportPatternsListPart method validate.

@Override
public void validate() {
    IMessageManager msgs = getManagedForm().getMessageManager();
    msgs.setDecorationPosition(SWT.TOP | SWT.RIGHT);
    String noStarWarning = null;
    String actionMessage = null;
    List<ImportPattern> patterns = getClauses();
    if (!patterns.isEmpty()) {
        for (Iterator<ImportPattern> iter = patterns.iterator(); iter.hasNext(); ) {
            ImportPattern pattern = iter.next();
            if (pattern.getName().equals("*") && iter.hasNext()) {
                noStarWarning = "The catch-all pattern \"*\" should be in the last position.";
                actionMessage = "Move \"*\" pattern to the last position.";
                break;
            }
        }
        if (noStarWarning == null) {
            ImportPattern last = patterns.get(patterns.size() - 1);
            if (!last.getName().equals("*")) {
                noStarWarning = "The catch-all pattern \"*\" should be present and in the last position.";
                actionMessage = "Add missing \"*\" pattern.";
            }
        }
    }
    if (noStarWarning != null) {
        msgs.addMessage("_warning_no_star", noStarWarning, new FixMissingStarsAction(actionMessage), IMessageProvider.WARNING);
    } else {
        msgs.removeMessage("_warning_no_star");
    }
}
Also used : ImportPattern(aQute.bnd.build.model.clauses.ImportPattern) IMessageManager(org.eclipse.ui.forms.IMessageManager)

Example 3 with IMessageManager

use of org.eclipse.ui.forms.IMessageManager in project bndtools by bndtools.

the class ProjectBuildPage method reportProblemsInHeader.

void reportProblemsInHeader() {
    IManagedForm mform = getManagedForm();
    if (mform == null)
        return;
    if (mform.getForm().isDisposed())
        // We were called asynchronously after dialog was closed
        return;
    IMessageManager manager = mform.getMessageManager();
    manager.removeMessages();
    for (Entry<String, Integer> entry : messageSeverityMap.entrySet()) {
        // severities in IMessageProvider are 1 higher than in IMarker
        int mappedSeverity = entry.getValue() + 1;
        // may be null
        IAction[] fixes = messageFixesMap.get(entry.getKey());
        manager.addMessage(entry.getKey(), entry.getKey(), fixes, mappedSeverity);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) IManagedForm(org.eclipse.ui.forms.IManagedForm) IMessageManager(org.eclipse.ui.forms.IMessageManager)

Aggregations

IMessageManager (org.eclipse.ui.forms.IMessageManager)3 ImportPattern (aQute.bnd.build.model.clauses.ImportPattern)1 WorkspaceR5Repository (bndtools.central.WorkspaceR5Repository)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IAction (org.eclipse.jface.action.IAction)1 IManagedForm (org.eclipse.ui.forms.IManagedForm)1 Repository (org.osgi.service.repository.Repository)1 Deferred (org.osgi.util.promise.Deferred)1 Promise (org.osgi.util.promise.Promise)1 Success (org.osgi.util.promise.Success)1