下面列出了怎么用org.eclipse.ui.IAggregateWorkingSet的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @param wset
* non null working set
* @return non null set with work items, which may be empty
*/
public static Set<WorkItem> getResources(IWorkingSet wset) {
Set<WorkItem> set = new HashSet<>();
boolean aggregateWorkingSet = wset.isAggregateWorkingSet();
// IAggregateWorkingSet was introduced in Eclipse 3.5
if (aggregateWorkingSet && wset instanceof IAggregateWorkingSet) {
IAggregateWorkingSet aggr = (IAggregateWorkingSet) wset;
IWorkingSet[] sets = aggr.getComponents();
for (IWorkingSet iWorkingSet : sets) {
set.addAll(getResources(iWorkingSet));
}
} else {
IAdaptable[] elements = wset.getElements();
for (IAdaptable iAdaptable : elements) {
WorkItem item = getWorkItem(iAdaptable);
if (item != null) {
set.add(item);
}
}
}
return set;
}
/**
* The superclass does not deal with the content description, handle it
* here.
*
* @noreference
*/
public void updateTitle() {
super.updateTitle();
Object input = getCommonViewer().getInput();
if (input == null || input instanceof IAggregateWorkingSet) {
setContentDescription(""); //$NON-NLS-1$
return;
}
if (!(input instanceof IResource)) {
if (input instanceof IAdaptable) {
IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
.getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
setContentDescription(wbadapter.getLabel(input));
return;
}
}
setContentDescription(input.toString());
return;
}
IResource res = (IResource) input;
setContentDescription(res.getName());
}
/**
* The superclass does not deal with the content description, handle it
* here.
*
* @noreference
*/
public void updateTitle() {
super.updateTitle();
Object input = getCommonViewer().getInput();
if (input == null || input instanceof IAggregateWorkingSet) {
setContentDescription(""); //$NON-NLS-1$
return;
}
if (!(input instanceof IResource)) {
if (input instanceof IAdaptable) {
IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
.getAdapter(IWorkbenchAdapter.class);
if (wbadapter != null) {
setContentDescription(wbadapter.getLabel(input));
return;
}
}
setContentDescription(input.toString());
return;
}
IResource res = (IResource) input;
setContentDescription(res.getName());
}
public void propertyChange(PropertyChangeEvent event) {
if (ignoreFilterChangeEvents)
return;
IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();
setWorkingSet(newWorkingSet);
if (newWorkingSet != null) {
if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
contentService.getActivationService().activateExtensions(
new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
contentService.getActivationService().persistExtensionActivations();
}
if (newWorkingSet.isAggregateWorkingSet()) {
IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
IWorkingSet[] comps = agWs.getComponents();
if (comps.length > 1) {
viewer.getCommonNavigator().setWorkingSetLabel(
WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
} else if (comps.length > 0) {
viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
} else {
viewer.getCommonNavigator().setWorkingSetLabel(null);
}
} else
viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
} else {
viewer.getCommonNavigator().setWorkingSetLabel(null);
}
viewer.getFrameList().reset();
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) parentElement;
if (workingSet.isAggregateWorkingSet() && projectExplorer != null) {
switch (projectExplorer.getRootMode()) {
case ProjectExplorer.WORKING_SETS :
return ((IAggregateWorkingSet) workingSet).getComponents();
case ProjectExplorer.PROJECTS :
return getWorkingSetElements(workingSet);
}
}
return getWorkingSetElements(workingSet);
}
return NO_CHILDREN;
}
public void propertyChange(PropertyChangeEvent event) {
if (ignoreFilterChangeEvents)
return;
IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();
setWorkingSet(newWorkingSet);
if (newWorkingSet != null) {
if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
contentService.getActivationService().activateExtensions(
new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
contentService.getActivationService().persistExtensionActivations();
}
if (newWorkingSet.isAggregateWorkingSet()) {
IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
IWorkingSet[] comps = agWs.getComponents();
if (comps.length > 1) {
viewer.getCommonNavigator().setWorkingSetLabel(
WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
} else if (comps.length > 0) {
viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
} else {
viewer.getCommonNavigator().setWorkingSetLabel(null);
}
} else
viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
} else {
viewer.getCommonNavigator().setWorkingSetLabel(null);
}
viewer.getFrameList().reset();
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) parentElement;
if (workingSet.isAggregateWorkingSet() && projectExplorer != null) {
switch (projectExplorer.getRootMode()) {
case ProjectExplorer.WORKING_SETS :
return ((IAggregateWorkingSet) workingSet).getComponents();
case ProjectExplorer.PROJECTS :
return getWorkingSetElements(workingSet);
}
}
return getWorkingSetElements(workingSet);
}
return NO_CHILDREN;
}