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();
}
}
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();
}
}
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();
}
}
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();
}
}
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;
}
Aggregations