Search in sources :

Example 6 with WorkingSetManager

use of org.eclipse.n4js.ui.workingsets.WorkingSetManager in project n4js by eclipse.

the class GHOLD_101_WorkingSetsTest_PluginUITest method activateWorkingSetManager.

private void activateWorkingSetManager(final Class<? extends WorkingSetManager> clazz) {
    final WorkingSetManager manager = from(broker.getWorkingSetManagers()).firstMatch(m -> m.getId().equals(clazz.getName())).orNull();
    checkNotNull(manager, "Working set manager does not exist with ID: " + clazz);
    broker.setActiveManager(manager);
    broker.setWorkingSetTopLevel(true);
    waitForIdleState();
    final IContributionItem dropDownContribution = getWorkingSetDropDownContribution();
    assertNotNull("Select working set drop down contribution was null when working sets are configured as top level elements.", dropDownContribution);
}
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) IContributionItem(org.eclipse.jface.action.IContributionItem) ProjectTypeAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager) ProjectNameFilterAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager) ManualAssociationAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager)

Example 7 with WorkingSetManager

use of org.eclipse.n4js.ui.workingsets.WorkingSetManager in project n4js by eclipse.

the class SelectAllProjectExplorer_PluginUITest method activateWorkingSetManager.

private void activateWorkingSetManager(final Class<? extends WorkingSetManager> clazz) {
    final WorkingSetManager manager = from(broker.getWorkingSetManagers()).firstMatch(m -> m.getId().equals(clazz.getName())).orNull();
    checkNotNull(manager, "Working set manager does not exist with ID: " + clazz);
    broker.setActiveManager(manager);
    broker.setWorkingSetTopLevel(true);
    waitForIdleState();
    final IContributionItem dropDownContribution = getWorkingSetDropDownContribution();
    assertNotNull("Select working set drop down contribution was null when working sets are configured as top level elements.", dropDownContribution);
}
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) IContributionItem(org.eclipse.jface.action.IContributionItem) ProjectTypeAwareWorkingSetManager(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager)

Example 8 with WorkingSetManager

use of org.eclipse.n4js.ui.workingsets.WorkingSetManager in project n4js by eclipse.

the class N4JSActionBarContributionProvider method workingSetManagerStateChanged.

@Override
public void workingSetManagerStateChanged(final WorkingSetManagerChangeEvent event) {
    final Diff<WorkingSet> diff = event.getDiff();
    final WorkingSetManager activeManager = workingSetManagerBroker.getActiveManager();
    final String changedId = event.getId();
    if (actionBars != null && activeManager != null && !diff.isEmpty() && workingSetManagerBroker.isWorkingSetTopLevel() && activeManager.getId().equals(changedId)) {
        final WorkingSet[] allItems = diff.getNewAllItems();
        final WorkingSet[] items = diff.getNewItems();
        updateShowHiddenAction(allItems, items);
        actionBars.updateActionBars();
    }
}
Also used : WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager)

Example 9 with WorkingSetManager

use of org.eclipse.n4js.ui.workingsets.WorkingSetManager in project n4js by eclipse.

the class N4JSActionBarContributionProvider method topLevelElementChanged.

@Override
public void topLevelElementChanged(final boolean workingSetTopLevel) {
    if (actionBars != null) {
        final IToolBarManager toolBarManager = actionBars.getToolBarManager();
        toolBarManager.remove(selectWorkingSetDelegate);
        toolBarManager.remove(showHiddenWorkingSetsDelegate);
        if (workingSetManagerBroker.isWorkingSetTopLevel()) {
            toolBarManager.add(selectWorkingSetDelegate);
            final WorkingSetManager manager = workingSetManagerBroker.getActiveManager();
            if (manager != null) {
                WorkingSet[] allItems = manager.getAllWorkingSets();
                WorkingSet[] items = manager.getWorkingSets();
                updateShowHiddenAction(allItems, items);
            }
        }
        selectTopLevelElementAction.fillActionBars(actionBars);
        actionBars.updateActionBars();
    }
}
Also used : IToolBarManager(org.eclipse.jface.action.IToolBarManager) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager)

Example 10 with WorkingSetManager

use of org.eclipse.n4js.ui.workingsets.WorkingSetManager in project n4js by eclipse.

the class HideWorkingSetAction method run.

@Override
public void run() {
    final IStructuredSelection selection = getStructuredSelection();
    final Object[] selectionElements = selection.toArray();
    final WorkingSet[] selectedWorkingSets = Arrays2.filter(selectionElements, WorkingSet.class);
    final WorkingSetManager manager = selectedWorkingSets[0].getWorkingSetManager();
    final WorkingSetDiffBuilder builder = new WorkingSetDiffBuilder(manager);
    final WorkingSet[] newAllItems = manager.getAllWorkingSets();
    final List<WorkingSet> newItems = newArrayList(manager.getWorkingSets());
    for (final WorkingSet toHide : selectedWorkingSets) {
        newItems.remove(toHide);
    }
    final Diff<WorkingSet> diff = builder.build(Iterables.toArray(newItems, WorkingSet.class), newAllItems);
    if (!diff.isEmpty()) {
        manager.updateState(diff);
        manager.saveState(new NullProgressMonitor());
        manager.getWorkingSetManagerBroker().refreshNavigator();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WorkingSetDiffBuilder(org.eclipse.n4js.ui.workingsets.WorkingSetDiffBuilder) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager)

Aggregations

WorkingSetManager (org.eclipse.n4js.ui.workingsets.WorkingSetManager)14 WorkingSet (org.eclipse.n4js.ui.workingsets.WorkingSet)13 ManualAssociationAwareWorkingSetManager (org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager)6 ManualAssociationWorkingSet (org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet)6 WorkingSetDiffBuilder (org.eclipse.n4js.ui.workingsets.WorkingSetDiffBuilder)6 IProject (org.eclipse.core.resources.IProject)4 ProjectTypeAwareWorkingSetManager (org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 Collection (java.util.Collection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 FluentIterable.from (com.google.common.collect.FluentIterable.from)2 HashMultimap (com.google.common.collect.HashMultimap)2 Iterables (com.google.common.collect.Iterables)2 Multimap (com.google.common.collect.Multimap)2 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2