Search in sources :

Example 1 with ClasspathPagePresenter

use of org.eclipse.che.ide.ext.java.client.project.classpath.valueproviders.pages.ClasspathPagePresenter in project che by eclipse.

the class ProjectClasspathPresenter method show.

/** Show dialog. */
public void show() {
    final Resource[] resources = appContext.getResources();
    Preconditions.checkState(resources != null && resources.length == 1);
    final Optional<Project> project = resources[0].getRelatedProject();
    Preconditions.checkState(isJavaProject(project.get()));
    classpathContainer.getClasspathEntries(project.get().getLocation().toString()).then(new Operation<List<ClasspathEntryDto>>() {

        @Override
        public void apply(List<ClasspathEntryDto> arg) throws OperationException {
            classpathResolver.resolveClasspathEntries(arg);
            if (propertiesMap == null) {
                propertiesMap = new HashMap<>();
                for (ClasspathPagePresenter page : classpathPages) {
                    Set<ClasspathPagePresenter> pages = propertiesMap.get(page.getCategory());
                    if (pages == null) {
                        pages = new HashSet<>();
                        propertiesMap.put(page.getCategory(), pages);
                    }
                    pages.add(page);
                }
                view.setPages(propertiesMap);
            }
            view.show();
            view.selectPage(propertiesMap.entrySet().iterator().next().getValue().iterator().next());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify("Problems with getting classpath", arg.getMessage(), FAIL, EMERGE_MODE);
        }
    });
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) JavaUtil.isJavaProject(org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject) PromiseError(org.eclipse.che.api.promises.client.PromiseError) List(java.util.List) ClasspathPagePresenter(org.eclipse.che.ide.ext.java.client.project.classpath.valueproviders.pages.ClasspathPagePresenter) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

List (java.util.List)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ClasspathPagePresenter (org.eclipse.che.ide.ext.java.client.project.classpath.valueproviders.pages.ClasspathPagePresenter)1 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)1 ClasspathEntryDto (org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto)1