Search in sources :

Example 11 with WorkingSet

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

the class ShowHiddenWorkingSetsDropDownAction method showWorkingSet.

private void showWorkingSet(final WorkingSetManager manager, final WorkingSet... workingSets) {
    final WorkingSetDiffBuilder builder = new WorkingSetDiffBuilder(manager);
    final Collection<WorkingSet> visibleItems = newArrayList(manager.getWorkingSets());
    visibleItems.addAll(newArrayList(workingSets));
    final WorkingSet[] newAllItems = manager.getAllWorkingSets();
    final Iterable<WorkingSet> newItems = newArrayList(manager.getAllWorkingSets());
    for (final Iterator<WorkingSet> itr = newItems.iterator(); itr.hasNext(); ) /**/
    {
        final WorkingSet next = itr.next();
        if (!visibleItems.contains(next)) {
            itr.remove();
        }
    }
    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) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet)

Example 12 with WorkingSet

use of org.eclipse.n4js.ui.workingsets.WorkingSet 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 13 with WorkingSet

use of org.eclipse.n4js.ui.workingsets.WorkingSet 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 14 with WorkingSet

use of org.eclipse.n4js.ui.workingsets.WorkingSet 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)

Example 15 with WorkingSet

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

the class HideWorkingSetAction method updateSelection.

@Override
@VisibleForTesting
public boolean updateSelection(IStructuredSelection selection) {
    if (selection == null || selection.isEmpty()) {
        return false;
    }
    final Object[] selectionElements = selection.toArray();
    final WorkingSet[] selectedWorkingSets = Arrays2.filter(selectionElements, WorkingSet.class);
    if (selectionElements.length != selectedWorkingSets.length) {
        return false;
    }
    final WorkingSetManager manager = selectedWorkingSets[0].getWorkingSetManager();
    // Cannot hide all working sets.
    return manager.getWorkingSets().length > selectedWorkingSets.length;
}
Also used : WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) WorkingSetManager(org.eclipse.n4js.ui.workingsets.WorkingSetManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

WorkingSet (org.eclipse.n4js.ui.workingsets.WorkingSet)19 WorkingSetManager (org.eclipse.n4js.ui.workingsets.WorkingSetManager)13 ManualAssociationWorkingSet (org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet)9 WorkingSetDiffBuilder (org.eclipse.n4js.ui.workingsets.WorkingSetDiffBuilder)8 ManualAssociationAwareWorkingSetManager (org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager)7 IProject (org.eclipse.core.resources.IProject)6 ProjectNameFilterWorkingSet (org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager.ProjectNameFilterWorkingSet)5 ProjectTypeWorkingSet (org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager.ProjectTypeWorkingSet)5 TreeItem (org.eclipse.swt.widgets.TreeItem)5 Test (org.junit.Test)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Inject (com.google.inject.Inject)3 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 List (java.util.List)3 IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 ProjectNameFilterAwareWorkingSetManager (org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager)3 ProjectTypeAwareWorkingSetManager (org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager)3