use of org.eclipse.core.runtime.jobs.ISchedulingRule in project tdi-studio-se by Talend.
the class SaveAsBusinessModelWizard method update.
private void update() {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
assginVlaues(oldProperty, property);
repositoryFactory.save(oldBusinessProcessItem);
// assign value
businessProcessItem = oldBusinessProcessItem;
} catch (PersistenceException pe) {
throw new CoreException(new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "persistance error", //$NON-NLS-1$
pe));
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e.getCause());
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.text by eclipse.
the class LastSaveReferenceProvider method readDocument.
/**
* Reads in the saved document into <code>fReference</code>.
*
* @param monitor a progress monitor, or <code>null</code>
* @param force <code>true</code> if the reference document should also
* be read if the current document is <code>null</code>,<code>false</code>
* if it should only be updated if it already existed.
*/
private void readDocument(IProgressMonitor monitor, boolean force) {
// protect against concurrent disposal
IDocumentProvider prov = fDocumentProvider;
IEditorInput inp = fEditorInput;
IDocument doc = fReference;
ITextEditor editor = fEditor;
if (prov instanceof IStorageDocumentProvider && inp instanceof IStorageEditorInput) {
IStorageEditorInput input = (IStorageEditorInput) inp;
IStorageDocumentProvider provider = (IStorageDocumentProvider) prov;
if (doc == null)
if (force || fDocumentRead)
doc = new Document();
else
return;
IJobManager jobMgr = Job.getJobManager();
try {
IStorage storage = input.getStorage();
// check for null for backward compatibility (we used to check before...)
if (storage == null)
return;
fProgressMonitor = monitor;
ISchedulingRule rule = getSchedulingRule(storage);
// delay for any other job requiring the lock on file
try {
lockDocument(monitor, jobMgr, rule);
String encoding;
if (storage instanceof IEncodedStorage)
encoding = ((IEncodedStorage) storage).getCharset();
else
encoding = null;
boolean skipUTF8BOM = isUTF8BOM(encoding, storage);
setDocumentContent(doc, storage, encoding, monitor, skipUTF8BOM);
} finally {
unlockDocument(jobMgr, rule);
fProgressMonitor = null;
}
} catch (CoreException e) {
return;
}
if (monitor != null && monitor.isCanceled())
return;
// update state
synchronized (fLock) {
if (fDocumentProvider == provider && fEditorInput == input) {
// only update state if our provider / input pair has not
// been updated in between (dispose or setActiveEditor)
fReference = doc;
fDocumentRead = true;
addElementStateListener(editor, prov);
}
}
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.text by eclipse.
the class GenericFileBufferOperationRunner method computeCommitRule.
protected ISchedulingRule computeCommitRule(IFileBuffer[] fileBuffers) {
ArrayList<ISchedulingRule> list = new ArrayList<>();
for (IFileBuffer fileBuffer : fileBuffers) {
ISchedulingRule rule = fileBuffer.computeCommitRule();
if (rule != null)
list.add(rule);
}
ISchedulingRule[] rules = new ISchedulingRule[list.size()];
list.toArray(rules);
return new MultiRule(rules);
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.text by eclipse.
the class GenericFileBufferOperationRunner method performOperation.
private void performOperation(IFileBuffer fileBuffer, IFileBufferOperation operation, IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException {
SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 100);
ISchedulingRule rule = fileBuffer.computeCommitRule();
IJobManager manager = Job.getJobManager();
manager.beginRule(rule, subMonitor.split(1));
String name = fileBuffer.getLocation().lastSegment();
subMonitor.setTaskName(name);
operation.run(fileBuffer, subMonitor.split(99));
manager.endRule(rule);
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project eclipse.platform.text by eclipse.
the class GenericFileBufferOperationRunner method commit.
protected void commit(final IFileBuffer[] fileBuffers, final IProgressMonitor progressMonitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 2);
ISchedulingRule rule = computeCommitRule(fileBuffers);
Job.getJobManager().beginRule(rule, subMonitor.split(1));
try {
doCommit(fileBuffers, subMonitor.split(1));
} finally {
Job.getJobManager().endRule(rule);
}
}
Aggregations