Java Code Examples for org.eclipse.core.resources.IResource#getWorkspace()

The following examples show how to use org.eclipse.core.resources.IResource#getWorkspace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PythonBaseModelProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param newWorkingSet
 */
private IWorkspace[] getWorkspaces(IWorkingSet newWorkingSet) {
    IAdaptable[] elements = newWorkingSet.getElements();
    HashSet<IWorkspace> set = new HashSet<IWorkspace>();

    for (IAdaptable adaptable : elements) {
        IResource adapter = adaptable.getAdapter(IResource.class);
        if (adapter != null) {
            IWorkspace workspace = adapter.getWorkspace();
            set.add(workspace);
        } else {
            Log.log("Was not expecting that IWorkingSet adaptable didn't return anything...");
        }
    }
    return set.toArray(new IWorkspace[0]);
}
 
Example 2
Source File: CommitWorkingCopyOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected ISchedulingRule getSchedulingRule() {
	IResource resource = getElementToProcess().getResource();
	if (resource == null) return null;
	IWorkspace workspace = resource.getWorkspace();
	if (resource.exists()) {
		return workspace.getRuleFactory().modifyRule(resource);
	} else {
		return workspace.getRuleFactory().createRule(resource);
	}
}
 
Example 3
Source File: CreateElementInCUOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected ISchedulingRule getSchedulingRule() {
	IResource resource = getCompilationUnit().getResource();
	IWorkspace workspace = resource.getWorkspace();
	return workspace.getRuleFactory().modifyRule(resource);
}