當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。