当前位置: 首页>>代码示例>>Java>>正文


Java ISchedulingRule类代码示例

本文整理汇总了Java中org.eclipse.core.runtime.jobs.ISchedulingRule的典型用法代码示例。如果您正苦于以下问题:Java ISchedulingRule类的具体用法?Java ISchedulingRule怎么用?Java ISchedulingRule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ISchedulingRule类属于org.eclipse.core.runtime.jobs包,在下文中一共展示了ISchedulingRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runInUI

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
@Override
public void runInUI(IRunnableContext context,
        IRunnableWithProgress runnable, ISchedulingRule rule)
        throws InvocationTargetException, InterruptedException {
	final RunnableWithStatus runnableWithStatus = new RunnableWithStatus(
			context,
			runnable, rule);
	uiSynchronize.syncExec(new Runnable() {
		@Override
		public void run() {
			BusyIndicator.showWhile(getDisplay(), runnableWithStatus);
		}

	});

	IStatus status = runnableWithStatus.getStatus();
	if (!status.isOK()) {
		Throwable exception = status.getException();
		if (exception instanceof InvocationTargetException)
			throw (InvocationTargetException) exception;
		else if (exception instanceof InterruptedException)
			throw (InterruptedException) exception;
		else // should be OperationCanceledException
			throw new InterruptedException(exception.getMessage());
	}
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:27,代码来源:ProgressServiceImpl.java

示例2: execute

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
public void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
	Map table = getProviderMapping(getResources());
	Set keySet = table.keySet();
	monitor.beginTask(null, keySet.size() * 1000);
	Iterator iterator = keySet.iterator();
	while (iterator.hasNext()) {
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
		SVNTeamProvider provider = (SVNTeamProvider)iterator.next();
		List list = (List)table.get(provider);
		IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
		ISchedulingRule rule = getSchedulingRule(provider);
		try {
			Job.getJobManager().beginRule(rule, monitor);
			monitor.setTaskName(getTaskName(provider));
			execute(provider, providerResources, subMonitor);
		} finally {
			Job.getJobManager().endRule(rule);
		}
	}
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:21,代码来源:RepositoryProviderOperation.java

示例3: getSchedulingRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的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()]));
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:31,代码来源:RepositoryProviderOperation.java

示例4: getModifyRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的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;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:27,代码来源:ResourceHelper.java

示例5: getDeleteRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的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;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:21,代码来源:ResourceHelper.java

示例6: getCreateRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的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;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:21,代码来源:ResourceHelper.java

示例7: getResetRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getResetRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(ResourcesPlugin.getWorkspace().getRuleFactory()
						.modifyRule(file));
			}
		}
		return new MultiRule(
				(ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
						.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:23,代码来源:StatemachineDocumentProvider.java

示例8: getSaveRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
/**
 * @generated
 */
protected ISchedulingRule getSaveRule(Object element) {
	ResourceSetInfo info = getResourceSetInfo(element);
	if (info != null) {
		LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>();
		for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it
				.hasNext();) {
			Resource nextResource = it.next();
			IFile file = WorkspaceSynchronizer.getFile(nextResource);
			if (file != null) {
				rules.add(computeSchedulingRule(file));
			}
		}
		return new MultiRule(
				(ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules
						.size()]));
	}
	return null;
}
 
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:22,代码来源:StatemachineDocumentProvider.java

示例9: checkIn

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
/** An operation calls this method and it only returns when the operation is free to run. */
public void checkIn(ISchedulingRule rule, IProgressMonitor monitor) throws CoreException {
  boolean success = false;
  try {
    if (workspace.isTreeLocked()) {
      String msg = Messages.resources_cannotModify;
      throw new ResourceException(IResourceStatus.WORKSPACE_LOCKED, null, msg, null);
    }
    jobManager.beginRule(rule, monitor);
    lock.acquire();
    incrementPreparedOperations();
    success = true;
  } finally {
    // remember if we failed to check in, so we can avoid check out
    if (!success) checkInFailed.set(Boolean.TRUE);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:WorkManager.java

示例10: validateEditRule

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
/** Combines rules for each parameter to validateEdit from the corresponding rule factories. */
public ISchedulingRule validateEditRule(IResource[] resources) {
  if (resources.length == 0) return null;
  // optimize rule for single file
  if (resources.length == 1) {
    if (resources[0].getType() == IResource.ROOT) return root;
    return factoryFor(resources[0]).validateEditRule(resources);
  }
  // gather rules for each resource from appropriate factory
  HashSet<ISchedulingRule> rules = new HashSet<ISchedulingRule>();
  IResource[] oneResource = new IResource[1];
  for (int i = 0; i < resources.length; i++) {
    if (resources[i].getType() == IResource.ROOT) return root;
    oneResource[0] = resources[i];
    ISchedulingRule rule = factoryFor(resources[i]).validateEditRule(oneResource);
    if (rule != null) rules.add(rule);
  }
  if (rules.isEmpty()) return null;
  if (rules.size() == 1) return rules.iterator().next();
  ISchedulingRule[] ruleArray = rules.toArray(new ISchedulingRule[rules.size()]);
  return new MultiRule(ruleArray);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:Rules.java

示例11: isConflicting

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
@Override
public boolean isConflicting(ISchedulingRule rule) {
  if (this == rule) return true;
  // must not schedule at same time as notification
  if (rule.getClass().equals(WorkManager.NotifyRule.class)) return true;
  if (rule instanceof MultiRule) {
    MultiRule multi = (MultiRule) rule;
    ISchedulingRule[] children = multi.getChildren();
    for (int i = 0; i < children.length; i++) if (isConflicting(children[i])) return true;
    return false;
  }
  if (!(rule instanceof IResource)) return false;
  IResource resource = (IResource) rule;
  if (!workspace.equals(resource.getWorkspace())) return false;
  IPath otherPath = resource.getFullPath();
  return path.isPrefixOf(otherPath) || otherPath.isPrefixOf(path);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:Resource.java

示例12: isConflicting

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
@Override
public boolean isConflicting(ISchedulingRule rule) {
    if(this == rule){
        return true;
    }
    if(rule instanceof ExclusiveRule) {
        ExclusiveRule rule2 = (ExclusiveRule) rule;
        IJavaElement element = root.getJavaElement();
        IJavaElement element2 = rule2.root.getJavaElement();
        if(element.equals(element2)){
            return true;
        }
        if(MULTICORE) {
            return tooManyJobsThere();
        }
        return true;
    }
    return false;
}
 
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:20,代码来源:ExclusiveRule.java

示例13: threadChange

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
public void threadChange(Thread thread) {
  // we must make sure we aren't transferring control away from a thread that
  // already owns a scheduling rule because this is deadlock prone (bug 105491)
  if (rule == null) {
    return;
  }
  Job currentJob = Job.getJobManager().currentJob();
  if (currentJob == null) {
    return;
  }
  ISchedulingRule currentRule = currentJob.getRule();
  if (currentRule == null) {
    return;
  }
  throw new IllegalStateException(
      "Cannot fork a thread from a thread owning a rule"); // $NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:WorkspaceModifyOperation.java

示例14: assertXtextIndexIsValid

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
/**
 * Performs some general validity checks on the Xtext index. Only intended to be used in tests (e.g. no support for
 * cancellation).
 */
protected void assertXtextIndexIsValid() {
	// ensure no build is running while we examine the Xtext index
	final ISchedulingRule rule = externalLibraryBuilderHelper.getRule();
	try {
		Job.getJobManager().beginRule(rule, null);
		assertXtextIndexIsValidInternal();
	} finally {
		Job.getJobManager().endRule(rule);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:AbstractBuilderTest.java

示例15: storeUpdated

import org.eclipse.core.runtime.jobs.ISchedulingRule; //导入依赖的package包/类
@Override
public void storeUpdated(final ExternalLibraryPreferenceStore store, final IProgressMonitor monitor) {
	final ISchedulingRule rule = builderHelper.getRule();
	try {
		Job.getJobManager().beginRule(rule, monitor);
		storeUpdatedInternal(store, monitor);
	} finally {
		Job.getJobManager().endRule(rule);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:EclipseExternalLibraryWorkspace.java


注:本文中的org.eclipse.core.runtime.jobs.ISchedulingRule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。