use of org.eclipse.n4js.ui.workingsets.WorkingSet in project n4js by eclipse.
the class ShowHiddenWorkingSetsDropDownAction method createMenuItems.
@Override
protected void createMenuItems(final Menu parent) {
final WorkingSetManager manager = workingSetManagerBroker.getActiveManager();
final WorkingSet[] allWorkingSets = manager.getAllWorkingSets();
final WorkingSet[] workingSets = manager.getWorkingSets();
for (final WorkingSet workingSet : allWorkingSets) {
if (!Arrays.contains(workingSets, workingSet)) {
final MenuItem item = new MenuItem(parent, PUSH);
item.setText(workingSet.getName());
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
showWorkingSet(manager, workingSet);
}
});
}
}
createSeparator(parent);
final MenuItem item = new MenuItem(parent, CHECK);
item.setText(SHOW_ALL_HIDDEN_WORKING_SETS);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final Iterable<WorkingSet> difference = difference(newHashSet(allWorkingSets), newHashSet(workingSets));
final WorkingSet[] toShow = Iterables.toArray(difference, WorkingSet.class);
showWorkingSet(manager, toShow);
}
});
}
use of org.eclipse.n4js.ui.workingsets.WorkingSet in project n4js by eclipse.
the class N4JSNavigatorActionProvider method setContext.
@Override
public void setContext(final ActionContext context) {
super.setContext(context);
projectGroup.setContext(context);
// context is null if disposal of the provider is triggered
if (null != context) {
StructuredSelection selection = (StructuredSelection) context.getSelection();
List<Object> selectedElements = Arrays.asList(selection.toArray());
selectionContainsWorkingSet = selectedElements.stream().anyMatch(element -> element instanceof WorkingSet);
// try to minimize number of context updates for working set action provider
if (selectionContainsWorkingSet) {
workingSetActionProvider.setContext(context);
}
assignWorkingSetsAction.selectionChanged(selection);
}
}
use of org.eclipse.n4js.ui.workingsets.WorkingSet in project n4js by eclipse.
the class N4JSProjectExplorerProblemsDecorator method computeAdornmentFlags.
/**
* Increased visibility for testing purposes.
*
* <p>
* {@inheritDoc}
*/
@Override
@VisibleForTesting
public int computeAdornmentFlags(final Object obj) {
if (!(obj instanceof WorkingSet)) {
return super.computeAdornmentFlags(obj);
}
final WorkingSet workingSet = (WorkingSet) obj;
final IAdaptable[] elements = workingSet.getElements();
int result = 0;
for (int i = 0; i < elements.length; i++) {
final IAdaptable element = elements[i];
final int flags = super.computeAdornmentFlags(element);
if ((flags & BUILDPATH_ERROR) != 0) {
return BUILDPATH_ERROR;
}
result |= flags;
}
if ((result & ERROR) != 0) {
return ERROR;
} else if ((result & WARNING) != 0) {
return WARNING;
} else {
return NO_ADORNMENT;
}
}
use of org.eclipse.n4js.ui.workingsets.WorkingSet in project n4js by eclipse.
the class GHOLD_101_WorkingSetsTest_PluginUITest method testWorkingSetIsTheSingleRootInNavaigator.
/**
*/
@Test
public void testWorkingSetIsTheSingleRootInNavaigator() {
activateWorkingSetManager(ManualAssociationAwareWorkingSetManager.class);
final TreeItem[] treeItems = commonViewer.getTree().getItems();
assertTrue("Expected exactly one item in the Project Explorer. Input was: " + Arrays.toString(treeItems), treeItems.length == 1);
final Object data = treeItems[0].getData();
assertTrue("Expected " + WorkingSet.class + " input in navigator. Was " + data, data instanceof WorkingSet);
final WorkingSet workingSet = (WorkingSet) treeItems[0].getData();
assertTrue("Expected working set with ID: " + OTHERS_WORKING_SET_ID + ". Was " + workingSet.getId(), OTHERS_WORKING_SET_ID.equals(workingSet.getId()));
}
use of org.eclipse.n4js.ui.workingsets.WorkingSet in project n4js by eclipse.
the class GHOLD_101_WorkingSetsTest_PluginUITest method testMarkerSupportForWorkingSets.
/**
*/
@Test
public void testMarkerSupportForWorkingSets() throws CoreException, IOException {
final IProject project = createN4JSProject("P1", LIBRARY);
createTestFile(project.getFolder("src"), "A", "class a { }");
final IFile moduleFile = project.getFolder("src").getFile("A.n4js");
assertTrue("File is not accessible under src/A.n4js", moduleFile.isAccessible());
// line 1: Class names should start with upper case letter.
assertMarkers("Expected exactly one validation issue.", project, 1);
activateWorkingSetManager(ManualAssociationAwareWorkingSetManager.class);
final TreeItem[] treeItems = commonViewer.getTree().getItems();
assertTrue("Expected exactly one item in the Project Explorer. Input was: " + Arrays.toString(treeItems), treeItems.length == 1);
final Object data = treeItems[0].getData();
assertTrue("Expected " + WorkingSet.class + " input in navigator. Was " + data, data instanceof WorkingSet);
final WorkingSet workingSet = (WorkingSet) treeItems[0].getData();
assertTrue("Expected working set with ID: " + OTHERS_WORKING_SET_ID + ". Was " + workingSet.getId(), OTHERS_WORKING_SET_ID.equals(workingSet.getId()));
final N4JSProjectExplorerProblemsDecorator decorator = new N4JSProjectExplorerProblemsDecorator();
int adornmentFlag = decorator.computeAdornmentFlags(workingSet);
assertEquals("Adornment mismatch.", WARNING, adornmentFlag);
try (final InputStream is = new StringInputStream("someBrokenContent")) {
moduleFile.setContents(is, IResource.FORCE, null);
}
waitForAutoBuild();
// line 1: Couldn't resolve reference to IdentifiableElement 'someBrokenContent'
assertMarkers("Expected exactly one validation issue.", project, 1);
adornmentFlag = decorator.computeAdornmentFlags(workingSet);
assertEquals("Adornment mismatch.", ERROR, adornmentFlag);
try (final InputStream is = new StringInputStream("class A { }")) {
moduleFile.setContents(is, IResource.FORCE, null);
}
waitForAutoBuild();
assertMarkers("Expected exactly zero validation issues.", project, 0);
adornmentFlag = decorator.computeAdornmentFlags(workingSet);
assertEquals("Adornment mismatch.", NO_ADORNMENT, adornmentFlag);
}
Aggregations