本文整理汇总了Java中org.eclipse.core.runtime.jobs.MultiRule.combine方法的典型用法代码示例。如果您正苦于以下问题:Java MultiRule.combine方法的具体用法?Java MultiRule.combine怎么用?Java MultiRule.combine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.jobs.MultiRule
的用法示例。
在下文中一共展示了MultiRule.combine方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchedulingRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的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.runtime.jobs.MultiRule; //导入方法依赖的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.runtime.jobs.MultiRule; //导入方法依赖的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.runtime.jobs.MultiRule; //导入方法依赖的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: checkout
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
/**
* Checkout projects from the SVN repository
*
* @param projects
* the projects to be loaded from the repository
* @param infoMap
* a mapping of project to project load information
* @param monitor
* the progress monitor (not <code>null</code>)
*/
private IProject[] checkout(IProject[] projects, Map<IProject, LoadInfo> infoMap,
IProgressMonitor monitor) throws TeamException, MalformedURLException {
if(projects==null || projects.length==0) {
return new IProject[0];
}
ISchedulingRule[] ruleArray = new ISchedulingRule[projects.length];
for (int i = 0; i < projects.length; i++) {
ruleArray[i] = projects[i].getWorkspace().getRuleFactory().modifyRule(projects[i]);
}
ISchedulingRule rule= MultiRule.combine(ruleArray);
Job.getJobManager().beginRule(rule, monitor);
monitor.beginTask("", 1000 * projects.length); //$NON-NLS-1$
List<IProject> result = new ArrayList<IProject>();
try {
for (IProject project : projects) {
if (monitor.isCanceled()) {
break;
}
LoadInfo info = infoMap.get(project);
if (info != null
&& info.checkout(new SubProgressMonitor(monitor, 1000))) {
result.add(project);
}
}
} finally {
Job.getJobManager().endRule(rule);
monitor.done();
}
return result.toArray(new IProject[result.size()]);
}
示例6: getSchedulingRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的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()]));
}
示例7: getSchedulingRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的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()]));
}
示例8: moveRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
/** Obtains the scheduling rule from the appropriate factories for a move operation. */
public ISchedulingRule moveRule(IResource source, IResource destination) {
if (source.getType() == IResource.ROOT || destination.getType() == IResource.ROOT) return root;
// treat a move across projects as a create on the destination and a delete on the source
if (!source.getFullPath().segment(0).equals(destination.getFullPath().segment(0)))
return MultiRule.combine(
modifyRule(source.getProject()), modifyRule(destination.getProject()));
return factoryFor(source).moveRule(source, destination);
}
示例9: run
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的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);
}
示例10: getSchedulingRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
/**
* This rule ensures the operation will run exclusively with the undo contexts it uses.
*
* @param operation
* @return
*/
protected final static ISchedulingRule getSchedulingRule(IUndoableOperation operation) {
IUndoContext[] contexts = operation.getContexts();
ISchedulingRule[] rules = new ISchedulingRule[contexts.length];
for (int i = 0 ; i < contexts.length ; i++) {
IUndoContext context = contexts[i];
rules[i] = new UndoContextRule(context);
}
ISchedulingRule rule = MultiRule.combine(rules);
return rule;
}
示例11: inJobEnforceRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
/**
* Undo/redo this operation, while enforcing its scheduling rule.
* This method is required to be executed in a Job.
*
* @param info
* @param monitor
* @param operation
* @param undo true if undo, false if redo
* @return
*/
private IStatus inJobEnforceRule(IAdaptable info, IProgressMonitor monitor, IUndoableOperation operation, boolean undo) {
IJobManager jobManager = Job.getJobManager();
ISchedulingRule currentRule = jobManager.currentRule();
ISchedulingRule operationRule = OperationJob.getSchedulingRule(operation);
ISchedulingRule rule = MultiRule.combine(currentRule, operationRule);
try {
jobManager.beginRule(rule, monitor);
return inJobInRule(info, monitor, operation, undo);
} finally {
jobManager.endRule(rule);
}
}
示例12: run
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
public void run(final IProgressMonitor monitor) throws SVNException {
final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
try {
List<IProject> projectList = new ArrayList<IProject>();
for (IResource currentResource : resources) {
IProject project = currentResource.getProject();
if (!projectList.contains(project)) {
projectList.add(project);
}
}
if (conflictResolver != null) {
svnClient.addConflictResolutionCallback(conflictResolver);
}
IProject[] projects = new IProject[projectList.size()];
projectList.toArray(projects);
ISchedulingRule rule = MultiRule.combine(projects);
SVNProviderPlugin.run(new ISVNRunnable() {
public void run(final IProgressMonitor pm) throws SVNException {
try {
monitor.beginTask(null, 100 * resources.length);
svnClient.addNotifyListener(operationResourceCollector);
if (resources.length == 1)
{
monitor.subTask(resources[0].getName());
svnClient.update(resources[0].getLocation().toFile(),revision, depth, setDepth, ignoreExternals, force);
updatedResources.add(resources[0]);
monitor.worked(100);
}
else
{
File[] files = new File[resources.length];
for (int i = 0; i < resources.length; i++) {
files[i] = resources[i].getLocation().toFile();
updatedResources.add(resources[i]);
}
svnClient.update(files, revision, depth, setDepth, ignoreExternals, force);
monitor.worked(100);
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
monitor.done();
if (svnClient != null) {
if (conflictResolver != null) {
svnClient.addConflictResolutionCallback(null);
}
svnClient.removeNotifyListener(operationResourceCollector);
root.getRepository().returnSVNClient(svnClient);
}
}
}
}, rule, Policy.monitorFor(monitor));
} finally {
OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
}
}
示例13: moveRule
import org.eclipse.core.runtime.jobs.MultiRule; //导入方法依赖的package包/类
/**
* Default implementation of <code>IResourceRuleFactory#moveRule</code>. This default
* implementation returns a rule that combines the parent of the source resource and the parent of
* the destination resource.
*
* <p>Subclasses may override this method. The rule provided by an overriding method must at least
* contain the rule from this default implementation.
*
* @see
* org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
* @see org.eclipse.core.resources.IResourceRuleFactory#moveRule(IResource, IResource)
*/
public ISchedulingRule moveRule(IResource source, IResource destination) {
// move needs the parent of both source and destination
return MultiRule.combine(parent(source), parent(destination));
}