use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class HeapDumpEditor method parseDumpFile.
/**
* Parses the dump file.
*
* @param filePath The file path
*/
private void parseDumpFile(final String filePath) {
Job job = new Job(Messages.parseHeapDumpFileJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
HeapDumpParser parser = new HeapDumpParser(new File(filePath), heapListElements, monitor);
try {
parser.parse();
} catch (ParserConfigurationException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
} catch (SAXException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
} catch (IOException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
}
setProfileInfo(parser.getProfileInfo());
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (heapHistogramPage != null) {
heapHistogramPage.refresh();
}
}
});
return Status.OK_STATUS;
}
};
job.schedule();
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class GenericConnWizardPage method setVisible.
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
dynamicComposite.resetParameters();
dynamicComposite.refresh();
dynamicComposite.setMinHeight(dynamicComposite.getMinHeight());
updateContextFields();
if (getNameParameter() != null) {
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
"") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
listExistingObjects = loadRepositoryViewObjectList();
} catch (PersistenceException e) {
return new org.eclipse.core.runtime.Status(IStatus.ERROR, "org.talend.metadata.management.ui", 1, "", //$NON-NLS-1$ //$NON-NLS-2$
e);
}
retrieveNameFinished = true;
// force the refresh of the text field, no matter successfull retrieve of not.
Display d = DisplayUtils.getDisplay();
if (d != null) {
d.syncExec(new Runnable() {
@Override
public void run() {
evaluateTextField();
}
});
}
return Status.OK_STATUS;
}
};
job.setUser(false);
job.setPriority(Job.BUILD);
// start as soon as possible
job.schedule();
}
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class ImportItemWizardPage method updateItemsList.
public void updateItemsList(final String path, boolean isneedUpdate) {
if (!isneedUpdate) {
if (path.equals(lastPath)) {
return;
}
}
lastPath = path;
if (path == null || path.length() == 0) {
selectedItems = new ArrayList<ItemRecord>();
checkTreeViewer.refresh(true);
// get the top item to check if tree is empty, if not then uncheck everything
TreeItem topItem = checkTreeViewer.getTree().getTopItem();
if (topItem != null) {
checkTreeViewer.setSubtreeChecked(topItem.getData(), false);
}
// else not root element, tree is already empty
checkValidItems();
return;
}
final boolean dirSelected = this.itemFromDirectoryRadio.getSelection();
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
// monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
//$NON-NLS-1$
monitor.beginTask(Messages.getString("DataTransferMessages.WizardProjectsImportPage_SearchingMessage"), 100);
File directory = new File(path);
monitor.worked(10);
if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) {
sourceTarFile = getSpecifiedTarSourceFile(path);
if (sourceTarFile == null) {
return;
}
TarLeveledStructureProvider provider = new TarLeveledStructureProvider(sourceTarFile);
manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
if (!manager.collectPath2Object(provider.getRoot())) {
return;
}
} else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) {
sourceFile = getSpecifiedZipSourceFile(path);
if (sourceFile == null) {
return;
}
ZipLeveledStructureProvider provider = new ZipLeveledStructureProvider(sourceFile);
manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
if (!manager.collectPath2Object(provider.getRoot())) {
return;
}
} else if (dirSelected && directory.isDirectory()) {
manager = ResourcesManagerFactory.getInstance().createResourcesManager();
if (!manager.collectPath2Object(directory)) {
return;
}
} else {
monitor.worked(60);
}
monitor.done();
}
});
} catch (InvocationTargetException e) {
IDEWorkbenchPlugin.log(e.getMessage(), e);
} catch (InterruptedException e) {
// Nothing to do if the user interrupts.
}
populateItems();
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class ImportItemWizardPage method performFinish.
public boolean performFinish() {
final List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
final List<ItemRecord> checkedItemRecords = getCheckedElements();
itemRecords.addAll(checkedItemRecords);
itemRecords.addAll(getHadoopSubrecords(itemRecords));
for (ItemRecord itemRecord : itemRecords) {
Item item = itemRecord.getProperty().getItem();
if (item instanceof JobletProcessItem) {
needToRefreshPalette = true;
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (item.getState().isLocked()) {
try {
factory.unlock(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (LoginException e) {
ExceptionHandler.process(e);
}
}
ERepositoryStatus status = factory.getStatus(item);
if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
try {
factory.unlock(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (LoginException e) {
ExceptionHandler.process(e);
}
}
}
try {
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IPath destinationPath = null;
String contentType = "";
if (rNode != null && rNode.getType().equals(ENodeType.SIMPLE_FOLDER)) {
destinationPath = RepositoryNodeUtilities.getPath(rNode);
contentType = rNode.getContentType().name();
}
repositoryUtil.setErrors(false);
repositoryUtil.clear();
repositoryUtil.importItemRecords(manager, itemRecords, monitor, overwrite, destinationPath, contentType);
if (repositoryUtil.hasErrors()) {
throw new InvocationTargetException(new CoreException(new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), //$NON-NLS-1$
"Import errors")));
}
}
};
new ProgressMonitorDialog(getShell()).run(true, true, iRunnableWithProgress);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if (repositoryUtil.getRoutineExtModulesMap().isEmpty()) {
if (targetException instanceof CoreException) {
//$NON-NLS-1$
MessageDialog.openWarning(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("ImportItemWizardPage.ImportSelectedItems"), //$NON-NLS-1$
Messages.getString("ImportItemWizardPage.ErrorsOccured"));
}
}
} catch (InterruptedException e) {
//
}
ResourcesManager curManager = this.manager;
if (curManager instanceof ProviderManager) {
curManager.closeResource();
}
selectedItems = null;
itemRecords.clear();
return true;
}
use of org.eclipse.core.runtime.IProgressMonitor in project tdi-studio-se by Talend.
the class PaletteSettingPage method okPressed.
protected void okPressed() {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayUtils.getDefaultShell());
IRunnableWithProgress rwp = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
try {
prf.saveProject(project);
ShowStandardAction.getInstance().doRun();
if (needCodeGen) {
Job refreshTemplates = CorePlugin.getDefault().getCodeGeneratorService().refreshTemplates();
refreshTemplates.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
}
});
}
// ComponentUtilities.updatePalette();
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
};
try {
pmd.run(true, false, rwp);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
Aggregations