Search in sources :

Example 1 with Arrays2

use of org.eclipse.n4js.utils.collections.Arrays2 in project n4js by eclipse.

the class WorkingSetManualAssociationWizard method addPages.

@Override
public void addPages() {
    addPage(new WizardPage("") {

        private Text nameText;

        private final Collection<IProject> workspaceProjects = newTreeSet(PROJECT_NAME_COMPARATOR);

        private final Collection<IProject> workingSetProjects = newTreeSet(PROJECT_NAME_COMPARATOR);

        @Override
        public void createControl(Composite parent) {
            final Composite composite = new Composite(parent, NONE);
            composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).create());
            composite.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            new Label(composite, NONE).setText("Working set name:");
            nameText = new Text(composite, BORDER);
            nameText.setLayoutData(fillDefaults().align(FILL, CENTER).grab(true, false).create());
            Composite tableComposite = new Composite(composite, NONE);
            tableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).create());
            tableComposite.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).span(2, 1).create());
            Group workspaceGroup = new Group(tableComposite, SHADOW_IN);
            workspaceGroup.setText("Available workspace projects");
            workspaceGroup.setLayout(GridLayoutFactory.fillDefaults().create());
            workspaceGroup.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            final TableViewer allProjectsViewer = new TableViewerBuilder(singletonList("")).setHasBorder(true).setHeaderVisible(false).setLinesVisible(false).setMultipleSelection(true).setColumnWidthsInPixel(Ints.asList(350)).setLabelProvider(labelProvider).build(workspaceGroup);
            Composite buttonComposite = new Composite(tableComposite, NONE);
            buttonComposite.setLayout(GridLayoutFactory.fillDefaults().create());
            // buttonComposite.setLayoutData(fillDefaults().align(CENTER, CENTER).grab(false, false).create());
            final Button addButton = new Button(buttonComposite, PUSH);
            addButton.setImage(ImageRef.RIGHT_ARROW.asImage().orNull());
            addButton.setToolTipText("Add all selected workspace projects");
            addButton.setEnabled(false);
            final Button removeButton = new Button(buttonComposite, PUSH);
            removeButton.setImage(ImageRef.LEFT_ARROW.asImage().orNull());
            removeButton.setToolTipText("Remove all selected working set element projects");
            removeButton.setEnabled(false);
            Group workingSetGroup = new Group(tableComposite, SHADOW_IN);
            workingSetGroup.setText("Associated working set projects");
            workingSetGroup.setLayout(GridLayoutFactory.fillDefaults().create());
            workingSetGroup.setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).create());
            final TableViewer associatedProjectsViewer = new TableViewerBuilder(singletonList("")).setHasBorder(true).setHeaderVisible(false).setLinesVisible(false).setMultipleSelection(true).setColumnWidthsInPixel(Ints.asList(350)).setLabelProvider(labelProvider).build(workingSetGroup);
            addButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStructuredSelection selection = allProjectsViewer.getStructuredSelection();
                    if (selection != null && !selection.isEmpty()) {
                        final IProject[] projects = Arrays2.filter(selection.toArray(), IProject.class);
                        allProjectsViewer.remove(projects);
                        associatedProjectsViewer.add(projects);
                        workspaceProjects.removeAll(Arrays.asList(projects));
                        workingSetProjects.addAll(Arrays.asList(projects));
                        setPageComplete(validatePage());
                    }
                }
            });
            removeButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStructuredSelection selection = associatedProjectsViewer.getStructuredSelection();
                    if (selection != null && !selection.isEmpty()) {
                        final IProject[] projects = Arrays2.filter(selection.toArray(), IProject.class);
                        associatedProjectsViewer.remove(projects);
                        allProjectsViewer.add(projects);
                        workingSetProjects.removeAll(Arrays.asList(projects));
                        workspaceProjects.addAll(Arrays.asList(projects));
                        setPageComplete(validatePage());
                    }
                }
            });
            associatedProjectsViewer.addSelectionChangedListener(event -> {
                final IStructuredSelection selection = associatedProjectsViewer.getStructuredSelection();
                removeButton.setEnabled(null != selection && !selection.isEmpty());
            });
            allProjectsViewer.addSelectionChangedListener(event -> {
                final IStructuredSelection selection = allProjectsViewer.getStructuredSelection();
                addButton.setEnabled(null != selection && !selection.isEmpty());
            });
            setPageComplete(false);
            setControl(composite);
            final Optional<WorkingSet> editedWorkingSet = getEditedWorkingSet();
            workspaceProjects.addAll(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()));
            if (editedWorkingSet.isPresent()) {
                final ManualAssociationWorkingSet workingSet = (ManualAssociationWorkingSet) editedWorkingSet.get();
                workingSetRef.set(workingSet);
                nameText.setText(workingSet.getName());
                nameText.selectAll();
                workingSetProjects.addAll(workingSet.getAssociatedProjects());
                workspaceProjects.removeAll(workingSetProjects);
                originalName.set(workingSet.getName());
            }
            composite.getDisplay().asyncExec(() -> {
                setTitle(TITLE);
                setDescription(DESCRIPTION);
                allProjectsViewer.setInput(workspaceProjects);
                associatedProjectsViewer.setInput(workingSetProjects);
            });
            nameText.addModifyListener(e -> setPageComplete(validatePage()));
        }

        @Override
        public void setVisible(boolean visible) {
            if (visible) {
                Rectangle location = UIUtils.getConstrainedShellBounds(getShell(), SHELL_SIZE);
                getShell().setBounds(location);
            }
            super.setVisible(visible);
        }

        @SuppressWarnings("null")
        private boolean validatePage() {
            String errorMessage = null;
            final String name = nameText.getText();
            final WorkingSetManager manager = getManager();
            if (manager == null) {
                errorMessage = "No active working set manager is available.";
            }
            if (errorMessage == null) {
                if (name == null || name.trim().length() == 0) {
                    errorMessage = "Working set name should be specified.";
                }
            }
            if (errorMessage == null) {
                if (!name.equals(originalName.get()) && // This case ID and name are equal. Intentionally name.
                getAllWorkingSets().stream().anyMatch(ws -> ws.getName().equals(name))) {
                    errorMessage = "A working set already exists with name '" + name + "'.";
                }
            }
            if (errorMessage != null) {
                workingSetRef.set(null);
            } else {
                final Iterable<String> projectNames = from(workingSetProjects).transform(p -> p.getName());
                workingSetRef.set(new ManualAssociationWorkingSet(projectNames, name, manager));
            }
            setMessage(errorMessage, ERROR);
            return errorMessage == null;
        }
    });
}
Also used : Arrays(java.util.Arrays) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) TableViewer(org.eclipse.jface.viewers.TableViewer) Inject(com.google.inject.Inject) Rectangle(org.eclipse.swt.graphics.Rectangle) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) AtomicReference(java.util.concurrent.atomic.AtomicReference) Point(org.eclipse.swt.graphics.Point) Collections.singletonList(java.util.Collections.singletonList) Sets.newTreeSet(com.google.common.collect.Sets.newTreeSet) IProject(org.eclipse.core.resources.IProject) Composite(org.eclipse.swt.widgets.Composite) Optional(com.google.common.base.Optional) FluentIterable.from(com.google.common.collect.FluentIterable.from) WizardPage(org.eclipse.jface.wizard.WizardPage) N4JSProjectExplorerLabelProvider(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerLabelProvider) BORDER(org.eclipse.swt.SWT.BORDER) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) PUSH(org.eclipse.swt.SWT.PUSH) Button(org.eclipse.swt.widgets.Button) UIUtils(org.eclipse.n4js.ui.utils.UIUtils) TableViewerBuilder(org.eclipse.n4js.ui.viewer.TableViewerBuilder) Collection(java.util.Collection) Group(org.eclipse.swt.widgets.Group) Ints(com.google.common.primitives.Ints) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) CENTER(org.eclipse.swt.SWT.CENTER) FILL(org.eclipse.swt.SWT.FILL) GridDataFactory.fillDefaults(org.eclipse.jface.layout.GridDataFactory.fillDefaults) SHADOW_IN(org.eclipse.swt.SWT.SHADOW_IN) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Comparator(java.util.Comparator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ImageRef(org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef) Label(org.eclipse.swt.widgets.Label) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Optional(com.google.common.base.Optional) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) Button(org.eclipse.swt.widgets.Button) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) WizardPage(org.eclipse.jface.wizard.WizardPage) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerBuilder(org.eclipse.n4js.ui.viewer.TableViewerBuilder)

Example 2 with Arrays2

use of org.eclipse.n4js.utils.collections.Arrays2 in project n4js by eclipse.

the class N4JSProjectExplorerHelper method getVirtualNodesForProject.

/**
 * Returns with an array of virtual {@link Node node} instances for the project that should be revealed in the
 * project explorer.
 *
 * @param project
 *            the workspace project.
 * @return an array of virtual nodes.
 */
public Node[] getVirtualNodesForProject(IProject project) {
    checkArgument(!(project instanceof ExternalProject), "Expected Eclipse workspace project. Got: " + project);
    if (null == project || !project.exists() || !project.isAccessible()) {
        return Node.EMPTY_NODES;
    }
    IN4JSProject n4Project = getProject(project);
    if (null == n4Project || !n4Project.exists() || n4Project.isExternal()) {
        return Node.EMPTY_NODES;
    }
    final Image image = ImageRef.LIB_PATH.asImage().get();
    final NamedNode rootNode = new NamedNode(project, "External Dependencies", image);
    Iterable<IN4JSProject> directDependencies = from(n4Project.getAllDirectDependencies()).filter(IN4JSProject.class);
    Iterable<IN4JSProject> runtimeLibraries = getExternalDependenciesOfType(directDependencies, RUNTIME_LIBRARY);
    if (!from(runtimeLibraries).isEmpty()) {
        Map<String, IN4JSProject> builtInRuntimeEnvironments = getBuiltInRuntimeEnvironments();
        Map<String, IN4JSProject> builtInRuntimeLibraries = getBuiltInRuntimeLibraries();
        Collection<IN4JSProject> libs = newHashSet();
        Collection<IN4JSProject> envs = newHashSet();
        for (IN4JSProject p : runtimeLibraries) {
            IN4JSProject dependency = builtInRuntimeLibraries.get(p.getProjectId());
            if (null != dependency) {
                libs.add(dependency);
            }
        }
        if (!libs.isEmpty()) {
            OUTER: for (IN4JSProject p : builtInRuntimeEnvironments.values()) {
                for (IN4JSProject providedLib : from(p.getProvidedRuntimeLibraries()).filter(IN4JSProject.class)) {
                    if (libs.contains(providedLib)) {
                        envs.add(p);
                        String extndedRuntimeEnvName = p.getExtendedRuntimeEnvironmentId().orNull();
                        if (null != extndedRuntimeEnvName) {
                            final IN4JSProject extension = builtInRuntimeEnvironments.get(extndedRuntimeEnvName);
                            if (null != extension) {
                                envs.add(extension);
                            }
                        }
                        continue OUTER;
                    }
                }
            }
        }
        NamedNode runtimeNode = new NamedNode(rootNode, "N4JS Runtime", image);
        if (!envs.isEmpty()) {
            NamedNode envsNode = new NamedNode(runtimeNode, "Runtime Environments", image);
            envsNode.addChild(from(envs).transform(p -> new BuiltInProjectNode(envsNode, p)));
            runtimeNode.addChild(envsNode);
        }
        if (!libs.isEmpty()) {
            NamedNode libsNode = new NamedNode(runtimeNode, "Runtime Libraries", image);
            libsNode.addChild(from(libs).transform(p -> new BuiltInProjectNode(libsNode, p)));
            runtimeNode.addChild(libsNode);
        }
        if (!Arrays2.isEmpty(runtimeNode.getChildren())) {
            rootNode.addChild(runtimeNode);
        }
    }
    Map<String, IN4JSProject> langProjects = getAvailableLangProjects();
    Map<String, IN4JSProject> mangelhaftProjects = getAvailableMangelhaftProjects();
    Map<String, IN4JSProject> npmProjects = getAvailableNpmProjects();
    Collection<IN4JSProject> requiredLangLibs = newHashSet();
    Collection<IN4JSProject> requiredMangelhaftLibs = newHashSet();
    Collection<IN4JSProject> requiredNpmLibs = newHashSet();
    for (IN4JSProject directDependecy : directDependencies) {
        if (directDependecy.exists() && directDependecy.isExternal()) {
            IN4JSProject externalDepenency = mangelhaftProjects.get(directDependecy.getProjectId());
            if (null != externalDepenency) {
                requiredMangelhaftLibs.add(externalDepenency);
            } else {
                externalDepenency = npmProjects.get(directDependecy.getProjectId());
                if (null != externalDepenency) {
                    requiredNpmLibs.add(externalDepenency);
                } else {
                    externalDepenency = langProjects.get(directDependecy.getProjectId());
                    if (null != externalDepenency) {
                        requiredLangLibs.add(externalDepenency);
                    }
                }
            }
        }
    }
    if (!requiredLangLibs.isEmpty()) {
        NamedNode langNode = new NamedNode(rootNode, EXTERNAL_LIBRARY_NAMES.get(LANG_CATEGORY), image);
        langNode.addChild(from(requiredLangLibs).transform(p -> new BuiltInProjectNode(langNode, p)));
        rootNode.addChild(langNode);
    }
    if (!requiredMangelhaftLibs.isEmpty()) {
        NamedNode mangNode = new NamedNode(rootNode, EXTERNAL_LIBRARY_NAMES.get(MANGELHAFT_CATEGORY), image);
        mangNode.addChild(from(requiredMangelhaftLibs).transform(p -> new BuiltInProjectNode(mangNode, p)));
        rootNode.addChild(mangNode);
    }
    if (!requiredNpmLibs.isEmpty()) {
        NamedNode npmNode = new NamedNode(rootNode, EXTERNAL_LIBRARY_NAMES.get(NPM_CATEGORY), image);
        npmNode.addChild(from(requiredNpmLibs).transform(p -> new BuiltInProjectNode(npmNode, p)));
        rootNode.addChild(npmNode);
    }
    return Arrays2.isEmpty(rootNode.getChildren()) ? new Node[0] : new Node[] { rootNode };
}
Also used : IFolder(org.eclipse.core.resources.IFolder) ExternalLibraryWorkspace(org.eclipse.n4js.external.ExternalLibraryWorkspace) LANG_CATEGORY(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.LANG_CATEGORY) Inject(com.google.inject.Inject) Image(org.eclipse.swt.graphics.Image) Maps.uniqueIndex(com.google.common.collect.Maps.uniqueIndex) MANGELHAFT_CATEGORY(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.MANGELHAFT_CATEGORY) IN4JSCore(org.eclipse.n4js.projectModel.IN4JSCore) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) Strings(com.google.common.base.Strings) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) RUNTIME_ENVIRONMENT(org.eclipse.n4js.n4mf.ProjectType.RUNTIME_ENVIRONMENT) IProject(org.eclipse.core.resources.IProject) FluentIterable.from(com.google.common.collect.FluentIterable.from) Map(java.util.Map) EXTERNAL_LIBRARIES_SUPPLIER(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.EXTERNAL_LIBRARIES_SUPPLIER) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) IExternalResource(org.eclipse.n4js.utils.resources.IExternalResource) URI(java.net.URI) EnumSet(java.util.EnumSet) Collection(java.util.Collection) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) RUNTIME_CATEGORY(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.RUNTIME_CATEGORY) EXTERNAL_LIBRARY_NAMES(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.EXTERNAL_LIBRARY_NAMES) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) URI.createFileURI(org.eclipse.emf.common.util.URI.createFileURI) ProjectType(org.eclipse.n4js.n4mf.ProjectType) URI.createPlatformResourceURI(org.eclipse.emf.common.util.URI.createPlatformResourceURI) Collections(java.util.Collections) ImageRef(org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef) NPM_CATEGORY(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator.NPM_CATEGORY) RUNTIME_LIBRARY(org.eclipse.n4js.n4mf.ProjectType.RUNTIME_LIBRARY) Singleton(com.google.inject.Singleton) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Image(org.eclipse.swt.graphics.Image)

Example 3 with Arrays2

use of org.eclipse.n4js.utils.collections.Arrays2 in project n4js by eclipse.

the class RebuildWorkspaceProjectsScheduler method scheduleBuildIfNecessary.

/**
 * Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
 * iterable of projects is empty.
 *
 * @param toUpdate
 *            an iterable of projects to build.
 */
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
    if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
        final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
        final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder())).filter(config -> Iterables.contains(toUpdate, config.getProject())).toArray(IBuildConfiguration.class);
        if (!Arrays2.isEmpty(projectsToReBuild)) {
            new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
        }
    }
}
Also used : Workspace(org.eclipse.core.internal.resources.Workspace) Iterables(com.google.common.collect.Iterables) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) IProject(org.eclipse.core.resources.IProject) Arrays.asList(java.util.Arrays.asList) FluentIterable.from(com.google.common.collect.FluentIterable.from) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration) Platform(org.eclipse.core.runtime.Platform) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) Workspace(org.eclipse.core.internal.resources.Workspace) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 4 with Arrays2

use of org.eclipse.n4js.utils.collections.Arrays2 in project n4js by eclipse.

the class GHOLD_101_WorkingSetsTest_PluginUITest method tearDown.

@Override
public void tearDown() throws Exception {
    super.tearDown();
    broker.resetState();
    waitForIdleState();
    final TreeItem[] treeItems = commonViewer.getTree().getItems();
    assertTrue("Expected empty Project Explorer. Input was: " + Arrays.toString(treeItems), Arrays2.isEmpty(treeItems));
    assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel());
    assertNull("Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution());
    IContributionItem showHiddenWorkingSetsItem = from(Arrays.asList(projectExplorer.getViewSite().getActionBars().getToolBarManager().getItems())).firstMatch(i -> ShowHiddenWorkingSetsDropDownAction.class.getName().equals(i.getId())).orNull();
    assertNull("Show hidden working set drop down contribution was visible when projects are configured as top level elements.", showHiddenWorkingSetsItem);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Arrays(java.util.Arrays) Diff(org.eclipse.n4js.utils.Diff) N4JSProjectExplorerProblemsDecorator(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Inject(com.google.inject.Inject) IAction(org.eclipse.jface.action.IAction) CoreException(org.eclipse.core.runtime.CoreException) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) WorkingSetManagerBrokerImpl(org.eclipse.n4js.ui.workingsets.WorkingSetManagerBrokerImpl) JavaProjectSetupUtil(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil) HashMultimap(com.google.common.collect.HashMultimap) HideWorkingSetAction(org.eclipse.n4js.ui.workingsets.internal.HideWorkingSetAction) Arrays.asList(java.util.Arrays.asList) FluentIterable.from(com.google.common.collect.FluentIterable.from) ProjectTypeAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager) ProjectNameFilterAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) CommonViewer(org.eclipse.ui.navigator.CommonViewer) PlatformUI(org.eclipse.ui.PlatformUI) Collection(java.util.Collection) WARNING(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator.WARNING) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) SWT(org.eclipse.swt.SWT) Entry(java.util.Map.Entry) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) Pattern(java.util.regex.Pattern) Iterables.toArray(com.google.common.collect.Iterables.toArray) WorkingSetDiffBuilder(org.eclipse.n4js.ui.workingsets.WorkingSetDiffBuilder) Iterables(com.google.common.collect.Iterables) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) BeforeClass(org.junit.BeforeClass) ManualAssociationAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager) ProjectExplorer(org.eclipse.ui.navigator.resources.ProjectExplorer) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) Multimap(com.google.common.collect.Multimap) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectWorkingSetDropDownAction(org.eclipse.n4js.ui.navigator.internal.SelectWorkingSetDropDownAction) NO_ADORNMENT(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator.NO_ADORNMENT) RUNTIME_ENVIRONMENT(org.eclipse.n4js.n4mf.ProjectType.RUNTIME_ENVIRONMENT) IProject(org.eclipse.core.resources.IProject) N4JSProjectInWorkingSetDropAdapterAssistant(org.eclipse.n4js.ui.workingsets.internal.N4JSProjectInWorkingSetDropAdapterAssistant) ShowHiddenWorkingSetsDropDownAction(org.eclipse.n4js.ui.navigator.internal.ShowHiddenWorkingSetsDropDownAction) ERROR(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator.ERROR) CommonDropAdapter(org.eclipse.ui.navigator.CommonDropAdapter) IFile(org.eclipse.core.resources.IFile) Before(org.junit.Before) TEST(org.eclipse.n4js.n4mf.ProjectType.TEST) Pattern.compile(java.util.regex.Pattern.compile) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) LIBRARY(org.eclipse.n4js.n4mf.ProjectType.LIBRARY) IOException(java.io.IOException) Test(org.junit.Test) OTHERS_WORKING_SET_ID(org.eclipse.n4js.ui.workingsets.WorkingSet.OTHERS_WORKING_SET_ID) CommonDropAdapterAssistant(org.eclipse.ui.navigator.CommonDropAdapterAssistant) ProjectNameFilterWorkingSet(org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager.ProjectNameFilterWorkingSet) TreeItem(org.eclipse.swt.widgets.TreeItem) ProjectType(org.eclipse.n4js.n4mf.ProjectType) ProjectTypeWorkingSet(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager.ProjectTypeWorkingSet) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) INavigatorDnDService(org.eclipse.ui.navigator.INavigatorDnDService) IResource(org.eclipse.core.resources.IResource) IContributionItem(org.eclipse.jface.action.IContributionItem) IWorkbench(org.eclipse.ui.IWorkbench) Menu(org.eclipse.swt.widgets.Menu) RUNTIME_LIBRARY(org.eclipse.n4js.n4mf.ProjectType.RUNTIME_LIBRARY) InputStream(java.io.InputStream) TreeItem(org.eclipse.swt.widgets.TreeItem) IContributionItem(org.eclipse.jface.action.IContributionItem) ShowHiddenWorkingSetsDropDownAction(org.eclipse.n4js.ui.navigator.internal.ShowHiddenWorkingSetsDropDownAction)

Example 5 with Arrays2

use of org.eclipse.n4js.utils.collections.Arrays2 in project n4js by eclipse.

the class SelectAllProjectExplorer_PluginUITest method tearDown.

@Override
public void tearDown() throws Exception {
    super.tearDown();
    broker.resetState();
    waitForIdleState();
    final TreeItem[] treeItems = commonViewer.getTree().getItems();
    assertTrue("Expected empty Project Explorer. Input was: " + Arrays.toString(treeItems), Arrays2.isEmpty(treeItems));
    assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel());
    assertNull("Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution());
    IContributionItem showHiddenWorkingSetsItem = from(Arrays.asList(projectExplorer.getViewSite().getActionBars().getToolBarManager().getItems())).firstMatch(i -> ShowHiddenWorkingSetsDropDownAction.class.getName().equals(i.getId())).orNull();
    assertNull("Show hidden working set drop down contribution was visible when projects are configured as top level elements.", showHiddenWorkingSetsItem);
}
Also used : Arrays(java.util.Arrays) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IN4JSEclipseCore(org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore) Inject(com.google.inject.Inject) IAction(org.eclipse.jface.action.IAction) IWorkbenchCommandConstants(org.eclipse.ui.IWorkbenchCommandConstants) CoreException(org.eclipse.core.runtime.CoreException) WorkingSetManagerBrokerImpl(org.eclipse.n4js.ui.workingsets.WorkingSetManagerBrokerImpl) HashMultimap(com.google.common.collect.HashMultimap) Arrays.asList(java.util.Arrays.asList) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) FluentIterable.from(com.google.common.collect.FluentIterable.from) Map(java.util.Map) ProjectTypeAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager) CommonViewer(org.eclipse.ui.navigator.CommonViewer) PlatformUI(org.eclipse.ui.PlatformUI) Collection(java.util.Collection) MenuManager(org.eclipse.jface.action.MenuManager) Collectors(java.util.stream.Collectors) List(java.util.List) LegacyActionTools(org.eclipse.jface.action.LegacyActionTools) Entry(java.util.Map.Entry) Optional(java.util.Optional) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Iterables(com.google.common.collect.Iterables) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) URI(org.eclipse.emf.common.util.URI) BeforeClass(org.junit.BeforeClass) ProjectExplorer(org.eclipse.ui.navigator.resources.ProjectExplorer) HashMap(java.util.HashMap) Arrays2(org.eclipse.n4js.utils.collections.Arrays2) Multimap(com.google.common.collect.Multimap) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectWorkingSetDropDownAction(org.eclipse.n4js.ui.navigator.internal.SelectWorkingSetDropDownAction) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) ShowHiddenWorkingSetsDropDownAction(org.eclipse.n4js.ui.navigator.internal.ShowHiddenWorkingSetsDropDownAction) Before(org.junit.Before) CommandManager(org.eclipse.core.commands.CommandManager) TEST(org.eclipse.n4js.n4mf.ProjectType.TEST) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager) UIUtils(org.eclipse.n4js.ui.utils.UIUtils) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) LIBRARY(org.eclipse.n4js.n4mf.ProjectType.LIBRARY) Test(org.junit.Test) ExecutionException(org.eclipse.core.commands.ExecutionException) IActionBars(org.eclipse.ui.IActionBars) TreeItem(org.eclipse.swt.widgets.TreeItem) ProjectType(org.eclipse.n4js.n4mf.ProjectType) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) Command(org.eclipse.core.commands.Command) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMenuManager(org.eclipse.jface.action.IMenuManager) IResource(org.eclipse.core.resources.IResource) IContributionItem(org.eclipse.jface.action.IContributionItem) IWorkbench(org.eclipse.ui.IWorkbench) TreeItem(org.eclipse.swt.widgets.TreeItem) IContributionItem(org.eclipse.jface.action.IContributionItem) ShowHiddenWorkingSetsDropDownAction(org.eclipse.n4js.ui.navigator.internal.ShowHiddenWorkingSetsDropDownAction)

Aggregations

FluentIterable.from (com.google.common.collect.FluentIterable.from)5 IProject (org.eclipse.core.resources.IProject)5 Arrays2 (org.eclipse.n4js.utils.collections.Arrays2)5 Inject (com.google.inject.Inject)4 Collection (java.util.Collection)4 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)4 Iterables (com.google.common.collect.Iterables)3 Arrays (java.util.Arrays)3 Arrays.asList (java.util.Arrays.asList)3 ProjectType (org.eclipse.n4js.n4mf.ProjectType)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 IAction (org.eclipse.jface.action.IAction)2