本文整理汇总了Java中org.eclipse.core.resources.IResourceRuleFactory类的典型用法代码示例。如果您正苦于以下问题:Java IResourceRuleFactory类的具体用法?Java IResourceRuleFactory怎么用?Java IResourceRuleFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IResourceRuleFactory类属于org.eclipse.core.resources包,在下文中一共展示了IResourceRuleFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchedulingRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* 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()]));
}
示例2: getModifyRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* 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;
}
示例3: getDeleteRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* 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;
}
示例4: getCreateRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* 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;
}
示例5: getSchedulingRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
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()]));
}
示例6: getSchedulingRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
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()]));
}
示例7: getMarkerRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
private ISchedulingRule getMarkerRule(IResource resource) {
ISchedulingRule rule = null;
if (resource != null) {
IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
rule = ruleFactory.markerRule(resource);
}
return rule;
}
示例8: factoryFor
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/** Returns the scheduling rule factory for the given resource */
private IResourceRuleFactory factoryFor(IResource destination) {
IResourceRuleFactory fac = projectsToRules.get(destination.getFullPath().segment(0));
if (fac == null) {
// use the default factory if the project is not yet accessible
if (!destination.getProject().isAccessible()) return defaultFactory;
// ask the team hook to supply one
fac = teamHook.getRuleFactory(destination.getProject());
projectsToRules.put(destination.getFullPath().segment(0), fac);
}
return fac;
}
示例9: getRuleFactory
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
@Override
public IResourceRuleFactory getRuleFactory() {
// note that the rule factory is created lazily because it
// requires loading the teamHook extension
if (ruleFactory == null) {
ruleFactory = new Rules(this);
}
return ruleFactory;
}
示例10: run
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* 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);
}
示例11: getSchedulingRule
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
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();
}
示例12: getRuleFactory
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
public IResourceRuleFactory getRuleFactory() {
return RESOURCE_RULE_FACTORY;
}
示例13: setRuleFactory
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
void setRuleFactory(IProject project, IResourceRuleFactory factory) {
if (factory == null) projectsToRules.remove(project.getName());
else projectsToRules.put(project.getName(), factory);
}
示例14: setRuleFactory
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
protected void setRuleFactory(IProject project, IResourceRuleFactory factory) {
Workspace workspace = ((Workspace) project.getWorkspace());
((Rules) workspace.getRuleFactory()).setRuleFactory(project, factory);
}
示例15: addTestJob
import org.eclipse.core.resources.IResourceRuleFactory; //导入依赖的package包/类
/**
* Add a new test generation job to the job queue
*
* @param target
*/
protected void addTestJob(final IResource target) {
IJavaElement element = JavaCore.create(target);
if (element == null) {
return;
}
IJavaElement packageElement = element.getParent();
String packageName = packageElement.getElementName();
final String targetClass = (!packageName.isEmpty() ? packageName + "." : "")
+ target.getName().replace(".java", "").replace(File.separator, ".");
System.out.println("* Scheduling new automated job for " + targetClass);
final String targetClassWithoutPackage = target.getName().replace(".java", "");
final String suiteClassName = targetClass + Properties.JUNIT_SUFFIX;
final String suiteFileName = target.getProject().getLocation() + "/evosuite-tests/" +
suiteClassName.replace('.', File.separatorChar) + ".java";
System.out.println("Checking for " + suiteFileName);
File suiteFile = new File(suiteFileName);
Job job = null;
if (suiteFile.exists()) {
MessageDialog dialog = new MessageDialog(
shell,
"Existing test suite found",
null, // image
"A test suite for class \""
+ targetClass
+ "\" already exists. EvoSuite will overwrite this test suite. Do you really want to proceed?",
MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Overwrite", "Extend",
"Rename Original", "Cancel" }, 0);
int returnCode = dialog.open();
// 0 == overwrite
// 1 == extend
if(returnCode == 1) {
IWorkspaceRoot wroot = target.getWorkspace().getRoot();
IResource suiteResource = wroot.getFileForLocation(new Path(suiteFileName));
job = new TestExtensionJob(shell, suiteResource, targetClass, suiteClassName);
}
else if (returnCode == 2) {
// 2 == Rename
renameSuite(target, packageName, targetClassWithoutPackage + Properties.JUNIT_SUFFIX + ".java");
} else if (returnCode > 2) {
// Cancel
return;
}
}
if(job == null)
job = new TestGenerationJob(shell, target, targetClass, suiteClassName);
job.setPriority(Job.SHORT);
IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
ISchedulingRule rule = ruleFactory.createRule(target.getProject());
//IFolder folder = proj.getFolder(ResourceUtil.EVOSUITE_FILES);
job.setRule(rule);
job.setUser(true);
job.schedule(); // start as soon as possible
}