use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.
the class ExportProjectsAsAction method run.
@Override
public void run() {
// Refresh Navigator view before export operation, see bug 4595
Job job = new //$NON-NLS-1$
Job(//$NON-NLS-1$
Messages.getString("ExportCommandAction.refreshWorkspace")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(ExportProjectsAsAction.this.getToolTipText(), IProgressMonitor.UNKNOWN);
try {
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
e.printStackTrace();
}
monitor.done();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setPriority(Job.BUILD);
job.schedule();
initializeExternalLibraries();
Shell activeShell = Display.getCurrent().getActiveShell();
TalendZipFileExportWizard docWizard = new TalendZipFileExportWizard();
WizardDialog dialog = new WizardDialog(activeShell, docWizard);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (brandingService.isPoweredbyTalend()) {
//$NON-NLS-1$
docWizard.setWindowTitle(Messages.getString("ExportProjectsAsAction.actionTitle"));
} else {
docWizard.setWindowTitle(Messages.getString("ExportProjectsAsAction.actionTitleForOthers", //$NON-NLS-1$
brandingService.getShortProductName()));
}
dialog.create();
dialog.open();
clearExternalLibraries();
}
use of org.eclipse.core.runtime.jobs.Job in project bndtools by bndtools.
the class ImportBndWorkspaceWizard method performFinish.
@Override
public boolean performFinish() {
final ImportSettings importSettings = new ImportSettings(mainPage.getSelectedFolder(), mainPage.isDeleteSettings(), mainPage.isInferExecutionEnvironment());
// create the new project operation
final WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException {
try {
importProjects(importSettings, monitor);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, "Error during import of Bnd workspace!", e));
}
}
};
Job importJob = new Job("Import Bnd Workspace") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
op.run(monitor);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof CoreException && ((CoreException) t).getStatus().getException() != null) {
// unwrap the cause of the CoreException
t = ((CoreException) t).getStatus().getException();
}
return new Status(Status.ERROR, Plugin.PLUGIN_ID, "Could not finish import job for Bnd Workspace!", t);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
importJob.schedule();
try {
// Prompt to switch to the BndTools perspective
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
if (!"bndtools.perspective".equals(currentPerspective.getId())) {
if (MessageDialog.openQuestion(getShell(), "Bndtools Perspective", "Switch to the Bndtools perspective?")) {
this.workbench.showPerspective("bndtools.perspective", window);
}
}
} catch (WorkbenchException e) {
error("Unable to switch to BndTools perspective", e);
}
return true;
}
Aggregations