use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class AutoConversionTypesEditor method doStore.
@Override
protected void doStore() {
if (!enableBtn.getSelection()) {
return;
}
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit(//$NON-NLS-1$
Messages.getString("AutoConversionTypesEditor.doStore.title")) {
@Override
public void run() throws PersistenceException {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
applyChange();
}
};
// unlockObject();
// alreadyEditedByUser = true; // to avoid 2 calls of unlock
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 e1) {
MessageBoxExceptionHandler.process(e1.getCause());
}
}
};
repositoryWorkUnit.setAvoidSvnUpdate(true);
repositoryWorkUnit.setAvoidUnloadResources(true);
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class CustomComponentSettingPage method finish.
private void finish(IProgressMonitor... monitorWrap) {
IProgressMonitor monitor = null;
if (monitorWrap != null && monitorWrap.length == 1) {
monitor = monitorWrap[0];
}
final IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
if (PluginChecker.isSVNProviderPluginLoaded() && (!sharedAdded.isEmpty() || !backAdded.isEmpty())) {
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit("Update custom components") {
@Override
public void run() throws PersistenceException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor subMonitor) throws CoreException {
ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
String targetRoot = eclipseProject.getLocation().toString() + "/" + ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
File componentFolder = new File(targetRoot);
URL url = null;
try {
if (!componentFolder.exists()) {
FilesUtils.createFoldersIfNotExists(targetRoot, false);
}
Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
String sourceRoot = url.getFile();
// delete share
for (IComponent component : backAdded.keySet()) {
String componentFullPath = targetRoot + File.separator + component.getName();
if (service.isSVNProject(pro)) {
service.svnEclipseHandlerDelete(eclipseProject, pro, componentFullPath);
if (subMonitor != null) {
subMonitor.worked(10);
}
} else {
File file = new File(componentFullPath);
if (file != null && file.exists()) {
org.talend.utils.io.FilesUtils.deleteFolder(file, true);
}
}
}
if (!backAdded.isEmpty()) {
getCustomComponentSettings().removeAll(backAdded.values());
}
FileFilter ff = new FileFilter() {
@Override
public boolean accept(File pathname) {
if (FilesUtils.isSVNFolder(pathname)) {
return false;
}
return true;
}
};
// share
for (IComponent component : sharedAdded.keySet()) {
String sourcePath = sourceRoot + component.getPathSource() + File.separator + component.getName();
File sourceFile = new File(sourcePath);
String targetPath = targetRoot + File.separatorChar + component.getName();
File targetFile = new File(targetPath);
FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
if (subMonitor != null) {
subMonitor.worked(10);
}
}
} catch (Exception e) {
resetCustomComponentSetting();
ExceptionHandler.process(e);
}
try {
prf.saveProject(pro);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
try {
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
};
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, new NullProgressMonitor());
} catch (CoreException e) {
throw new PersistenceException(e.getCause());
}
}
};
repositoryWorkUnit.setRefreshRepository(false);
repositoryWorkUnit.setForceTransaction(true);
prf.executeRepositoryWorkUnit(repositoryWorkUnit);
try {
repositoryWorkUnit.throwPersistenceExceptionIfAny();
} catch (PersistenceException e) {
e.printStackTrace();
}
}
if (monitor != null) {
monitor.done();
}
// refresh again after the gui closed .
try {
String projectLabel = pro.getTechnicalLabel();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e1) {
ExceptionHandler.process(e1);
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method updateItemsVersion.
private void updateItemsVersion() {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", getModifiedVersionItems().size() * 100);
Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>();
for (RepositoryObject object : getModifiedVersionItems()) {
// IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
if (object != null && object.getProperty() != null) {
if (object.getStatusCode().equals(object.getProperty().getStatusCode())) {
final Item item = object.getProperty().getItem();
item.getProperty().setOldStatusCode(object.getStatusCode());
// types.add(object.getRepositoryNode().getObjectType());
try {
// }
if (object != null) {
// obj.setVersion(object.getNewVersion());
FACTORY.save(project, object.getProperty());
} else {
// FACTORY.save(project, item.getProperty());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
monitor.worked(100);
}
// RepositoryManager.refresh(types);
monitor.done();
}
};
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class ExtractDocumentationAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
final Item item = node.getObject().getProperty().getItem();
if (item == null) {
return;
}
String initialFileName = null;
String initialExtension = null;
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
initialFileName = documentationItem.getName();
if (documentationItem.getExtension() != null) {
initialExtension = documentationItem.getExtension();
}
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
if (!LinkUtils.validateLink(linkDocItem.getLink())) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString(//$NON-NLS-1$
"ExtractDocumentationAction.fileErrorTitle"), //$NON-NLS-1$
Messages.getString("ExtractDocumentationAction.fileErrorMessages"));
return;
}
initialFileName = linkDocItem.getName();
if (linkDocItem.getExtension() != null) {
initialExtension = linkDocItem.getExtension();
}
}
if (initialFileName != null) {
FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
if (initialExtension != null) {
//$NON-NLS-1$
initialFileName = initialFileName + LinkUtils.DOT + initialExtension;
//$NON-NLS-1$ //$NON-NLS-2$
fileDlg.setFilterExtensions(new String[] { "*." + initialExtension, "*.*" });
}
fileDlg.setFileName(initialFileName);
String filename = fileDlg.open();
if (filename != null) {
final File file = new File(filename);
ProgressDialog progressDialog = new ProgressDialog(Display.getCurrent().getActiveShell()) {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (item instanceof DocumentationItem) {
DocumentationItem documentationItem = (DocumentationItem) item;
documentationItem.getContent().setInnerContentToFile(file);
} else if (item instanceof LinkDocumentationItem) {
// link documenation
LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
if (byteArray != null) {
byteArray.setInnerContentToFile(file);
}
}
} catch (IOException ioe) {
MessageBoxExceptionHandler.process(ioe);
}
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
// Nothing to do
}
}
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class MemoryRuntimeComposite method disconnectJVM.
private void disconnectJVM() {
final Job disconnectJVM = new //$NON-NLS-1$
Job(//$NON-NLS-1$
"disconnect JVM") {
@Override
protected IStatus run(IProgressMonitor monitor) {
if (isRemoteMonitoring) {
if (currentJvm != null && currentJvm.isConnected()) {
currentJvm.disconnect();
}
}
return Status.OK_STATUS;
}
};
disconnectJVM.schedule();
}
Aggregations