本文整理汇总了Java中org.eclipse.ui.IWorkingSet.getElements方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkingSet.getElements方法的具体用法?Java IWorkingSet.getElements怎么用?Java IWorkingSet.getElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IWorkingSet
的用法示例。
在下文中一共展示了IWorkingSet.getElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GpsProject
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private GpsProject(IProject project) throws GpsFileException {
name = project.getName();
for (IWorkingSet ws: PlatformUI.getWorkbench().getWorkingSetManager().getAllWorkingSets()) {
if (ws.getId() != null && ws.getId().equals("org.eclipse.jdt.ui.JavaWorkingSetPage")) { //$NON-NLS-1$
for (IAdaptable element: ws.getElements()) {
if (project.equals(element.getAdapter(IProject.class))) {
workingSets.add(ws.getName());
break;
}
}
}
}
try {
repositoryHandler = GpsRepositoryFactory.createHandler(project, this);
} catch (Throwable t) {
throw new GpsFileException("Cannot serialize project {0}", t, project.getName());
}
}
示例2: computeAdornmentFlags
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
@Override
protected int computeAdornmentFlags(Object obj) {
if (!(obj instanceof IWorkingSet))
return super.computeAdornmentFlags(obj);
IWorkingSet workingSet= (IWorkingSet)obj;
IAdaptable[] elements= workingSet.getElements();
int result= 0;
for (int i= 0; i < elements.length; i++) {
IAdaptable element= elements[i];
int flags= super.computeAdornmentFlags(element);
if ((flags & JavaElementImageDescriptor.BUILDPATH_ERROR) != 0)
return JavaElementImageDescriptor.BUILDPATH_ERROR;
result|= flags;
}
if ((result & JavaElementImageDescriptor.ERROR) != 0)
return JavaElementImageDescriptor.ERROR;
else if ((result & JavaElementImageDescriptor.WARNING) != 0)
return JavaElementImageDescriptor.WARNING;
return 0;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:PackageExplorerProblemsDecorator.java
示例3: isSupportedAsTopLevelElement
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
/**
* Tells whether the given working set is supported as top-level element
*
* @param workingSet the working set to test
* @return <code>true</code> if the given working set is supported as top-level element
* @since 3.6
*/
public static boolean isSupportedAsTopLevelElement(IWorkingSet workingSet) {
Object id= workingSet.getId();
if (IWorkingSetIDs.OTHERS.equals(id) || IWorkingSetIDs.JAVA.equals(id) || IWorkingSetIDs.RESOURCE.equals(id))
return true;
if (!workingSet.isSelfUpdating() || workingSet.isAggregateWorkingSet())
return false;
IAdaptable[] elements= workingSet.getElements();
for (int i= 0; i < elements.length; i++) {
IAdaptable element= elements[i];
IProject p= (IProject)element.getAdapter(IProject.class);
if (p != null && p.exists())
return true;
}
return false;
}
示例4: getResources
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
/**
* @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<WorkItem>();
boolean aggregateWorkingSet = wset.isAggregateWorkingSet();
//TODO: Understand whats happening...
// 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;
}
示例5: refresh
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
public IAdaptable[] refresh(IWorkingSet ws) {
IAdaptable[] oldElements= fWorkingSetToElement.get(ws);
if (oldElements == null)
return null;
IAdaptable[] newElements= ws.getElements();
List<IAdaptable> toRemove= new ArrayList<IAdaptable>(Arrays.asList(oldElements));
List<IAdaptable> toAdd= new ArrayList<IAdaptable>(Arrays.asList(newElements));
computeDelta(toRemove, toAdd, oldElements, newElements);
for (Iterator<IAdaptable> iter= toAdd.iterator(); iter.hasNext();) {
addElement(iter.next(), ws);
}
for (Iterator<IAdaptable> iter= toRemove.iterator(); iter.hasNext();) {
removeElement(iter.next(), ws);
}
if (toRemove.size() > 0 || toAdd.size() > 0)
fWorkingSetToElement.put(ws, newElements);
return oldElements;
}
示例6: getResources
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private Set<IResource> getResources(Object parent) {
Set<IResource> resources = new HashSet<IResource>();
if (parent instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) parent;
IAdaptable[] elements = workingSet.getElements();
// elements may contain NON-resource elements, which we have to
// convert to
// resources
for (IAdaptable adaptable : elements) {
IResource resource = (IResource) adaptable.getAdapter(IResource.class);
// TODO get only java projects or children of them
if (resource != null) {
resources.add(resource);
}
}
} else if (parent instanceof IWorkspaceRoot) {
IWorkspaceRoot workspaceRoot = (IWorkspaceRoot) parent;
// TODO get only java projects
IProject[] projects = workspaceRoot.getProjects();
for (IProject project : projects) {
resources.add(project);
}
}
return resources;
}
示例7: addJavaElements
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private void addJavaElements(Set<IJavaElement> javaElements, IWorkingSet workingSet) {
if (workingSet == null) return;
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
try {
IJavaProject[] projects =
JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
javaElements.addAll(Arrays.asList(projects));
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return;
}
IAdaptable[] elements = workingSet.getElements();
for (int i = 0; i < elements.length; i++) {
IJavaElement javaElement = (IJavaElement) elements[i].getAdapter(IJavaElement.class);
if (javaElement != null) {
addJavaElements(javaElements, javaElement);
continue;
}
IResource resource = (IResource) elements[i].getAdapter(IResource.class);
if (resource != null) {
addJavaElements(javaElements, resource);
}
// else we don't know what to do with it, ignore.
}
}
示例8: contains
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private static boolean contains(IWorkingSet set, IAdaptable adaptedElement) {
IAdaptable[] elements= set.getElements();
for (int i= 0; i < elements.length; i++) {
if (elements[i].equals(adaptedElement))
return true;
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ConfigureWorkingSetAssignementAction.java
示例9: getWorkingSetElements
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private IAdaptable[] getWorkingSetElements(IWorkingSet workingSet) {
IAdaptable[] children = workingSet.getElements();
for (int i = 0; i < children.length; i++) {
Object resource = children[i].getAdapter(IResource.class);
if (resource instanceof IProject)
children[i] = (IProject) resource;
}
return children;
}
示例10: getWorkingSet
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
/**
* Get the correct working set, if working sets are present in environment
* The Eclipse UI's default 'Other Projects' entry is not represented in the manager
* so, if a file from there is selected a Workspace search will result.
*
* @param editor
* @return current IWorkingSet or null
*/
private IWorkingSet getWorkingSet(ITextEditor editor) {
IWorkingSet result = null;
IWorkbenchPage page = getWorkbenchPage();
if (page != null) {
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
IWorkingSet[] workingSets = manager.getRecentWorkingSets();
if (workingSets != null && workingSets.length > 0) {
// return most recent working set
result = workingSets[0];
} else {
// For some lame reason, recent working sets is often not set in the manager
// so paw through them manually
workingSets = manager.getAllWorkingSets();
if (workingSets != null && workingSets.length > 0) {
IProject proj = this.getCurrentProject(editor);
for(IWorkingSet set : workingSets) {
for (IAdaptable ele : set.getElements()) {
Object adapt = ele.getAdapter(IProject.class);
if (adapt != null && adapt.equals(proj)){
return set;
}
}
}
}
}
}
return result;
}
示例11: addJavaElements
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private void addJavaElements(Set<IJavaElement> javaElements, IWorkingSet workingSet) {
if (workingSet == null)
return;
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
try {
IJavaProject[] projects= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
javaElements.addAll(Arrays.asList(projects));
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return;
}
IAdaptable[] elements= workingSet.getElements();
for (int i= 0; i < elements.length; i++) {
IJavaElement javaElement=(IJavaElement) elements[i].getAdapter(IJavaElement.class);
if (javaElement != null) {
addJavaElements(javaElements, javaElement);
continue;
}
IResource resource= (IResource)elements[i].getAdapter(IResource.class);
if (resource != null) {
addJavaElements(javaElements, resource);
}
// else we don't know what to do with it, ignore.
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:30,代码来源:JavaSearchScopeFactory.java
示例12: add
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private static void add(IWorkingSet workingSet, IAdaptable adaptedElement) {
IAdaptable[] elements= workingSet.getElements();
IAdaptable[] newElements= new IAdaptable[elements.length + 1];
System.arraycopy(elements, 0, newElements, 0, elements.length);
newElements[elements.length]= adaptedElement;
workingSet.setElements(newElements);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:8,代码来源:ConfigureWorkingSetAssignementAction.java
示例13: put
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private void put(IWorkingSet ws) {
if (fWorkingSetToElement.containsKey(ws))
return;
IAdaptable[] elements= ws.getElements();
fWorkingSetToElement.put(ws, elements);
for (int i= 0; i < elements.length; i++) {
IAdaptable element= elements[i];
addElement(element, ws);
if (!(element instanceof IProject) && !(element instanceof IJavaProject)) {
fNonProjectTopLevelElements.add(element);
}
}
}
示例14: collectIAdaptable
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
private void collectIAdaptable(IWorkingSet workingSet, Set<IFile> collected) {
IAdaptable[] adaptables = workingSet.getElements();
for (IAdaptable adaptable : adaptables) {
collectRelevantFiles(adaptable, collected);
}
}
示例15: resolveWorkingSetsForProjects
import org.eclipse.ui.IWorkingSet; //导入方法依赖的package包/类
/**
* Resolve working sets for given projects
*
* @param projects
* projects to scan for
* @param manager
* working set manager
* @return list of working set data - never <code>null</code>
*/
List<WorkingSetData> resolveWorkingSetsForProjects(Collection<IProject> projects, IWorkingSetManager manager) {
List<WorkingSetData> list = new ArrayList<>();
if (manager == null) {
return list;
}
IWorkingSet[] workingSets = manager.getAllWorkingSets();
if (workingSets == null || workingSets.length == 0) {
return list;
}
for (IWorkingSet workingSet : workingSets) {
if (workingSet == null) {
continue;
}
try {
IAdaptable[] elements = workingSet.getElements();
if (elements == null || elements.length == 0) {
continue;
}
WorkingSetData data = new WorkingSetData();
data.workingSet = workingSet;
list.add(data);
for (IAdaptable adaptable : elements) {
IProject project = adaptable.getAdapter(IProject.class);
if (project == null) {
continue;
}
data.projectNamesContainedBefore.add(project.getName());
}
} catch (IllegalStateException e) {
/* ignore this working set */
}
}
return list;
}