Search in sources :

Example 11 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project egit by eclipse.

the class RuleUtil method getRuleForContainers.

/**
 * Calculates a {@link ISchedulingRule} for all containers of the paths that
 * are in the workspace.
 *
 * @param paths
 * @return scheduling rule
 */
public static ISchedulingRule getRuleForContainers(Collection<IPath> paths) {
    List<ISchedulingRule> rules = new ArrayList<ISchedulingRule>();
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (IPath path : paths) {
        IResource resource = ResourceUtil.getResourceForLocation(path, false);
        if (resource != null) {
            IContainer container = resource.getParent();
            ISchedulingRule rule = ruleFactory.modifyRule(container);
            if (rule != null)
                rules.add(rule);
        }
    }
    if (rules.size() == 0)
        return null;
    else
        return new MultiRule(rules.toArray(new ISchedulingRule[rules.size()]));
}
Also used : IPath(org.eclipse.core.runtime.IPath) MultiRule(org.eclipse.core.runtime.jobs.MultiRule) ArrayList(java.util.ArrayList) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 12 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project whole by wholeplatform.

the class WorkspaceDecorationManager method addDecoration.

public void addDecoration(DecorationKind kind, final IEntity entity, final String message, final String location) {
    final int severity = getSeverity(kind);
    if (resource != null && severity != -1) {
        try {
            IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
            ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

                public void run(IProgressMonitor monitor) throws CoreException {
                    MarkerUtils.addMarker(resource, severity, message, entity, location);
                }
            }, ruleFactory.markerRule(resource), 0, monitor);
        } catch (CoreException e) {
        }
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory)

Example 13 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project titan.EclipsePlug-ins by eclipse.

the class MergeLog method refreshOutputFilesAsync.

private void refreshOutputFilesAsync(final IFile[] outputFiles) {
    final WorkspaceJob mergeJob = new WorkspaceJob("Refreshing output file information") {

        @Override
        public IStatus runInWorkspace(final IProgressMonitor monitor) {
            if (outputFiles != null) {
                ResourceUtils.refreshResources(Arrays.asList(outputFiles));
                for (IFile file : outputFiles) {
                    ResourceUtils.setPersistentProperty(file, MERGED_FILE_PROPERTY.getQualifier(), MERGED_FILE_PROPERTY.getLocalName(), true);
                }
            }
            return Status.OK_STATUS;
        }
    };
    final IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule combinedRule = null;
    for (final IFile file : outputFiles) {
        combinedRule = MultiRule.combine(ruleFactory.createRule(file), combinedRule);
    }
    mergeJob.setRule(combinedRule);
    mergeJob.setPriority(Job.LONG);
    mergeJob.setUser(true);
    mergeJob.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
    mergeJob.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 14 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project titan.EclipsePlug-ins by eclipse.

the class MergeLog method createSchedulingRule.

private ISchedulingRule createSchedulingRule(final List<IFile> files) {
    final IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule combinedRule = null;
    for (final IFile file : files) {
        combinedRule = MultiRule.combine(ruleFactory.createRule(file), combinedRule);
    }
    return combinedRule;
}
Also used : IFile(org.eclipse.core.resources.IFile) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 15 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project titan.EclipsePlug-ins by eclipse.

the class ConfigurationManagerControl method changeActualConfiguration.

/**
 * Changes the actually used configuration to the one being selected in
 * the configuration selector. Also loads all of the settings of the new
 * configuration into the project.
 */
public void changeActualConfiguration() {
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule rule = ruleFactory.createRule(project);
    try {
        Job.getJobManager().beginRule(rule, new NullProgressMonitor());
        actualConfiguration = configurations.getText();
        final HashSet<IResource> changedResources = new HashSet<IResource>();
        final Document document = ProjectDocumentHandlingUtility.getDocument(project);
        Node configurationNode = ProjectFileHandler.findConfigurationNode(document.getDocumentElement(), actualConfiguration);
        if (actualConfiguration == null) {
            ErrorReporter.logError("The configuration `" + actualConfiguration + "' for project `" + project.getName() + "' does not exist.");
        } else {
            ProjectFileHandler fileHandler = new ProjectFileHandler(project);
            fileHandler.loadProjectInfoFromNode(configurationNode, changedResources);
        }
    } finally {
        Job.getJobManager().endRule(rule);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectFileHandler(org.eclipse.titan.designer.properties.data.ProjectFileHandler) Node(org.w3c.dom.Node) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) Document(org.w3c.dom.Document) IResource(org.eclipse.core.resources.IResource) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) HashSet(java.util.HashSet)

Aggregations

IResourceRuleFactory (org.eclipse.core.resources.IResourceRuleFactory)17 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)13 ArrayList (java.util.ArrayList)5 IFile (org.eclipse.core.resources.IFile)5 IResource (org.eclipse.core.resources.IResource)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 IPath (org.eclipse.core.runtime.IPath)4 File (java.io.File)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 Job (org.eclipse.core.runtime.jobs.Job)3 BufferedReader (java.io.BufferedReader)2 BufferedWriter (java.io.BufferedWriter)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2