use of org.eclipse.core.resources.IWorkspaceRunnable in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
if (mainPage.isCreateNewVersionJob()) {
try {
ProxyRepositoryFactory.getInstance().updateLockStatus();
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
ERepositoryStatus repositoryStatus = ProxyRepositoryFactory.getInstance().getStatus(processObject);
if ((repositoryStatus.equals(ERepositoryStatus.READ_ONLY)) || repositoryStatus == ERepositoryStatus.LOCK_BY_OTHER || repositoryStatus.equals(ERepositoryStatus.LOCK_BY_USER)) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openWarning(getShell(), "Warning", Messages.getString("OpenExistVersionProcessWizard.labelContent"));
}
});
return false;
} else {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
if (!alreadyEditedByUser) {
refreshNewJob();
RelationshipItemBuilder.getInstance().addOrUpdateItem(processObject.getProperty().getItem());
try {
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
try {
Item newCreated = null;
if (processObject.getProperty() != null && processObject.getProperty().getItem() != null) {
newCreated = processObject.getProperty().getItem();
}
if (!(newCreated instanceof BusinessProcessItem)) {
ProxyRepositoryFactory.getInstance().lock(processObject);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (LoginException e) {
ExceptionHandler.process(e);
}
boolean locked = processObject.getRepositoryStatus().equals(ERepositoryStatus.LOCK_BY_USER);
openAnotherVersion((RepositoryNode) processObject.getRepositoryNode(), !locked);
try {
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
};
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);
}
}
} else {
StructuredSelection selection = (StructuredSelection) mainPage.getSelection();
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
boolean lastVersion = node.getObject().getVersion().equals(processObject.getVersion());
// processObject.getProperty().setVersion(originalVersion);
if (lastVersion) {
lockObject(processObject);
}
ERepositoryStatus status = node.getObject().getRepositoryStatus();
boolean isLocked = false;
if (status == ERepositoryStatus.LOCK_BY_USER) {
isLocked = true;
}
// Only latest version can be editted
openAnotherVersion(node, !lastVersion || !isLocked);
}
return true;
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project tdi-studio-se by Talend.
the class SaveAsProcessWizard method update.
private void update(final ProcessType processType) {
RepositoryWorkUnit<Object> rwu = new RepositoryWorkUnit<Object>("Save job") {
@Override
protected void run() throws LoginException, PersistenceException {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
try {
oldProcessItem.setProcess(processType);
assginValues(oldProperty, property);
RelationshipItemBuilder.getInstance().addOrUpdateItem(oldProcessItem);
repositoryFactory.save(oldProcessItem);
// assign value
processItem = oldProcessItem;
} 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());
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.setAvoidSvnUpdate(true);
repositoryFactory.executeRepositoryWorkUnit(rwu);
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project tdi-studio-se by Talend.
the class GenericConnWizard method createOrUpdateConnectionItem.
private void createOrUpdateConnectionItem() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
Form form = wizPage.getForm();
if (form.isCallAfterFormFinish()) {
if (creation) {
factory.create(connectionItem, pathToSave);
}
compService.afterFormFinish(form.getName(), form.getProperties());
}
updateConnectionItem(factory);
} catch (Throwable e) {
throw new CoreException(new Status(IStatus.ERROR, IGenericConstants.REPOSITORY_PLUGIN_ID, "Error when saving the connection", e));
}
}
};
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(operation, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
// Move it from WorkspaceRunnable to avoid the conflicting rules with other jobs.
if (!creation) {
GenericUpdateManager.updateGenericConnection(connectionItem, oldMetadataTable);
}
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project tesb-studio-se by Talend.
the class PublishMetadataRunnable method run.
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(Messages.PublishMetadataAction_Importing, 3);
final Collection<XmlFileConnectionItem> xmlObjs;
try {
xmlObjs = initFileConnection();
} catch (Exception e) {
String message = (null != e.getMessage()) ? e.getMessage() : e.getClass().getName();
throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Can't retrieve schemas from metadata: " + message, e));
}
Collection<XmlFileConnectionItem> selectTables;
if (xmlObjs.size() > 0) {
RewriteSchemaDialogRunnable runnable = new RewriteSchemaDialogRunnable(shell, xmlObjs);
Display.getDefault().syncExec(runnable);
selectTables = runnable.getSelectTables();
if (null == selectTables) {
return;
}
} else {
selectTables = Collections.emptyList();
}
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
boolean validateWsdl = Activator.getDefault().getPreferenceStore().getBoolean(EsbSoapServicePreferencePage.ENABLE_WSDL_VALIDATION);
if (validateWsdl) {
WSDLUtils.validateWsdl(wsdlDefinition.getDocumentBaseURI());
}
monitor.worked(1);
if (monitor.isCanceled()) {
return;
}
try {
process(wsdlDefinition, selectTables);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error during schema processing", e));
}
monitor.done();
}
};
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(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method refreshJobAndSave.
private void refreshJobAndSave(final IProxyRepositoryFactory repFactory) throws PersistenceException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
repFactory.save(item);
} catch (PersistenceException e) {
throw new CoreException(new Status(IStatus.ERROR, DesignerPlugin.ID, "Save Routine failed!", e));
}
}
;
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
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(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException e) {
throw new PersistenceException(e);
} catch (InterruptedException e) {
throw new PersistenceException(e);
}
setTitleImage(getTitleImage());
}
Aggregations