use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
the class Marker method delete.
/**
* @see IMarker#delete()
*/
public void delete() throws CoreException {
final ISchedulingRule rule = getWorkspace().getRuleFactory().markerRule(resource);
try {
getWorkspace().prepareOperation(rule, null);
getWorkspace().beginOperation(true);
getWorkspace().getMarkerManager().removeMarker(getResource(), getId());
} finally {
getWorkspace().endOperation(rule, false, null);
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project tdq-studio-se by Talend.
the class DataProviderWriter method save.
/**
* Save connection item and update the dependencies(optional). <B>To update dependencies of the connection the
* #careDependency must be set as TRUE.</B>
*
* @see org.talend.dq.writer.AElementPersistance#save(org.talend.core.model.properties.Item, boolean[])
*/
@Override
public ReturnCode save(Item item, boolean careDependency) {
final ConnectionItem connItem = (ConnectionItem) item;
final boolean isCare = careDependency;
// MOD qiongli TDQ-6287 avoid all notification of changes before the end of the modifications.
final ReturnCode returnCode = new ReturnCode();
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>(// $NON-NLS-1$
"Save connection item: " + item.getProperty().getDisplayName()) {
@Override
protected void run() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
try {
if (isCare) {
saveWithDependencies(connItem, connItem.getConnection());
} else {
saveWithoutDependencies(connItem, connItem.getConnection());
}
} catch (PersistenceException e) {
log.error(e, e);
returnCode.setOk(Boolean.FALSE);
returnCode.setMessage(e.getMessage());
}
}
};
ISchedulingRule schedulingRule = workspace.getRoot();
try {
workspace.run(operation, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
} catch (CoreException e) {
log.error(e, e);
returnCode.setOk(false);
}
}
};
workUnit.setAvoidUnloadResources(true);
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
// MOD yyi 2012-02-07 TDQ-4621:Update dependencies(connection) when careDependency is true.
return returnCode;
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.runtime by eclipse.
the class MultiRuleTest method testCombine.
public void testCombine() {
ISchedulingRule child1 = new PathRule("/a");
ISchedulingRule child2 = new PathRule("/b/c");
ISchedulingRule childOfChild1 = new PathRule("/a/b");
ISchedulingRule nonChild = new PathRule("/z/d");
MultiRule multi1 = new MultiRule(new ISchedulingRule[] { child1, child2 });
// add multi to its own children
assertEquals("1.0", multi1, MultiRule.combine(new ISchedulingRule[] { multi1 }));
assertEquals("1.1", multi1, MultiRule.combine(new ISchedulingRule[] { multi1, child1, child2, childOfChild1 }));
assertEquals("1.2", multi1, MultiRule.combine(multi1, child2));
assertEquals("1.3", multi1, MultiRule.combine(childOfChild1, multi1));
// null
assertEquals("1.4", null, MultiRule.combine(null, null));
assertEquals("1.5", multi1, MultiRule.combine(null, multi1));
assertEquals("1.6", child1, MultiRule.combine(child1, null));
MultiRule result = (MultiRule) MultiRule.combine(multi1, nonChild);
assertTrue("2.0" + result, result.contains(multi1));
assertTrue("2.1", result.contains(nonChild));
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.runtime by eclipse.
the class MultiRuleTest method testIsConflicting.
public void testIsConflicting() {
ISchedulingRule child1 = new PathRule("/a");
ISchedulingRule child2 = new PathRule("/b/c");
ISchedulingRule childOfChild1 = new PathRule("/a/b");
ISchedulingRule nonChild = new PathRule("/z/d");
MultiRule multi1 = new MultiRule(new ISchedulingRule[] { child1, child2 });
MultiRule multi2 = new MultiRule(new ISchedulingRule[] { childOfChild1, nonChild });
assertTrue("1.0", multi1.isConflicting(child1));
assertTrue("1.1", multi1.isConflicting(child2));
assertTrue("1.2", !multi1.isConflicting(nonChild));
assertTrue("1.3", multi1.isConflicting(childOfChild1));
assertTrue("1.4", multi1.isConflicting(multi2));
assertTrue("1.5", multi2.isConflicting(multi1));
assertTrue("1.6", multi1.isConflicting(multi1));
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.runtime by eclipse.
the class Bug_129551 method testBug.
public void testBug() {
ISchedulingRule rule = new IdentityRule();
BugJob job = new BugJob();
job.setRule(rule);
TestJob other = new TestJob("bug_129551_other", 1, 1);
other.setRule(rule);
job.schedule();
other.schedule();
// wait until the first job is about to run
barrier.waitForStatus(TestBarrier.STATUS_RUNNING);
// wait to ensure the other job is blocked
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
fail("4.99", e);
}
// let the first job go
barrier.setStatus(TestBarrier.STATUS_START);
barrier.waitForStatus(TestBarrier.STATUS_DONE);
// check for failure
if (failure[0] != null)
fail(failure[0].getMessage());
// tell the job not to sleep this time around
shouldSleep[0] = false;
job.wakeUp();
waitForCompletion(job);
waitForCompletion(other);
}
Aggregations