org.eclipse.core.resources.IResourceRuleFactory Java Examples

The following examples show how to use org.eclipse.core.resources.IResourceRuleFactory. 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: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for modifying the resources
 * @param resources set of resources
 * @return a combined rule
 */
public static ISchedulingRule getModifyRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        // if one of the resources does not exist
        // something is screwed up
        if (resources[i] == null || !resources[i].exists())
        {
            return null;
        }
        ISchedulingRule rule = ruleFactory.modifyRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #2
Source File: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for deleting resource
 * @param resource
 * @return
 */
public static ISchedulingRule getDeleteRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        ISchedulingRule rule = ruleFactory.deleteRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #3
Source File: ResourceHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Retrieves a combined rule for creating resource
 * @param resource
 * @return
 */
public static ISchedulingRule getCreateRule(IResource[] resources)
{
    if (resources == null)
    {
        return null;
    }
    ISchedulingRule combinedRule = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (int i = 0; i < resources.length; i++)
    {
        ISchedulingRule rule = ruleFactory.createRule(resources[i]);
        combinedRule = MultiRule.combine(rule, combinedRule);
    }
    return combinedRule;
}
 
Example #4
Source File: RepositoryProviderOperation.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Retgurn the scheduling rule to be obtained before work
 * begins on the given provider. By default, it is the provider's project.
 * This can be changed by subclasses.
 * @param provider
 * @return
 */
protected ISchedulingRule getSchedulingRule(SVNTeamProvider provider) {
	IResourceRuleFactory ruleFactory = provider.getRuleFactory();
	HashSet rules = new HashSet();
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i = 0; i < resources.length; i++) {			
		IResource[] pathResources = SVNWorkspaceRoot.getResourcesFor(new Path(resources[i].getLocation().toOSString()), false);
		for (IResource pathResource : pathResources) {
			IProject resourceProject = pathResource.getProject();				
			rules.add(ruleFactory.modifyRule(resourceProject));
			if (resourceProject.getLocation() != null) {
				// Add nested projects
				for (IProject project : projects) {
					if (project.getLocation() != null) {
						if (!project.getLocation().equals(resourceProject.getLocation()) && resourceProject.getLocation().isPrefixOf(project.getLocation())) {
							rules.add(ruleFactory.modifyRule(project));
						}
					}
				}	
			}
		}
	}
	return MultiRule.combine((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
}
 
Example #5
Source File: BaseDocumentLifeCycleHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private ISchedulingRule getRule(Set<ICompilationUnit> units) {
	ISchedulingRule result = null;
	IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
	for (ICompilationUnit unit : units) {
		if (unit.getResource() != null) {
			ISchedulingRule rule = ruleFactory.createRule(unit.getResource());
			result = MultiRule.combine(rule, result);
		}
	}
	return result;
}
 
Example #6
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static ISchedulingRule createRule(Collection<? extends IResource> resources) {
      ISchedulingRule combinedRule = null;
      IResourceRuleFactory ruleFactory = 
            ResourcesPlugin.getWorkspace().getRuleFactory();
      
      for (IResource r : resources) {
      	ISchedulingRule rule = ruleFactory.createRule(r);
          combinedRule = MultiRule.combine(rule, combinedRule);
}
      
      return combinedRule;
   }
 
Example #7
Source File: ResourceHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Retrieves a rule for modifying a resource
 * @param resource
 * @return
 */
public static ISchedulingRule getModifyRule(IResource resource)
{
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule rule = ruleFactory.modifyRule(resource);
    return rule;
}
 
Example #8
Source File: CloseResourceAction.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The implementation of this <code>WorkspaceAction</code> method method saves and closes the resource's dirty
 * editors before closing it.
 */
@Override
public void run() {
	// Get the items to close.
	final List<? extends IResource> projects = getSelectedResources();
	if (projects == null || projects.isEmpty()) {
		// no action needs to be taken since no projects are selected
		return;
	}

	final IResource[] projectArray = projects.toArray(new IResource[projects.size()]);

	if (!IDE.saveAllEditors(projectArray, true)) { return; }
	if (!validateClose()) { return; }

	closeMatchingEditors(projects, false);

	// be conservative and include all projects in the selection - projects
	// can change state between now and when the job starts
	ISchedulingRule rule = null;
	final IResourceRuleFactory factory = ResourcesPlugin.getWorkspace().getRuleFactory();
	for (final IResource element : projectArray) {
		final IProject project = (IProject) element;
		rule = MultiRule.combine(rule, factory.modifyRule(project));
	}
	runInBackground(rule);
}
 
Example #9
Source File: CheckoutAsProjectOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ISchedulingRule getSchedulingRule(SVNTeamProvider provider) {
	IResourceRuleFactory ruleFactory = provider.getRuleFactory();
	HashSet rules = new HashSet();
	for (int i = 0; i < localFolders.length; i++) {
		rules.add(ruleFactory.modifyRule(localFolders[i].getProject()));
	}
	return MultiRule.combine((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
}
 
Example #10
Source File: BranchTagOperation.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ISchedulingRule getSchedulingRule(SVNTeamProvider provider) {
	IResource[] resources = getResources();
	if (resources == null) return super.getSchedulingRule(provider);
	IResourceRuleFactory ruleFactory = provider.getRuleFactory();
	HashSet<ISchedulingRule> rules = new HashSet<ISchedulingRule>();
	for (int i = 0; i < resources.length; i++) {
		rules.add(ruleFactory.modifyRule(resources[i].getProject()));
	}
	return MultiRule.combine((ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]));
}
 
Example #11
Source File: SetClasspathOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected ISchedulingRule getSchedulingRule() {
	if (this.canChangeResources) {
		IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
		return new MultiRule(new ISchedulingRule[] {
			// use project modification rule as this is needed to create the .classpath file if it doesn't exist yet, or to update project references
			ruleFactory.modifyRule(this.project.getProject()),
			
			// and external project modification rule in case the external folders are modified
			ruleFactory.modifyRule(JavaModelManager.getExternalManager().getExternalFoldersProject())
		});
	}
	return super.getSchedulingRule();
}
 
Example #12
Source File: ResourceHelper.java    From tlaplus with MIT License 4 votes vote down vote up
public static ISchedulingRule getCreateRule(IResource resource)
{
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    return ruleFactory.createRule(resource);
}
 
Example #13
Source File: SVNTeamProvider.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public IResourceRuleFactory getRuleFactory() {
	return RESOURCE_RULE_FACTORY;
}