List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress
IRunnableWithProgress
From source file:com.genuitec.eclipse.gerrit.tools.internal.fbranches.BranchingUtils.java
License:Open Source License
public static boolean deleteBranches(Shell shell, final Repository repository, final List<Ref> toDelete) { final List<Ref> unmerged = new ArrayList<Ref>(); try {//from w ww. java2 s. c om new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { unmerged.addAll(deleteBranches(repository, toDelete, false, monitor)); } }); } catch (InvocationTargetException e1) { RepositoryUtils.handleException(e1); return false; } catch (InterruptedException e1) { // ignore return false; } if (!unmerged.isEmpty()) { MessageDialog messageDialog = new UnmergedBranchDialog<Ref>(shell, unmerged); if (messageDialog.open() != Window.OK) return false; try { new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { deleteBranches(repository, toDelete, true, monitor); } }); } catch (InvocationTargetException e1) { RepositoryUtils.handleException(e1); return false; } catch (InterruptedException e1) { // ignore return false; } } return true; }
From source file:com.genuitec.eclipse.gerrit.tools.utils.RepositoryUtils.java
License:Open Source License
public static void fetchOrigin(Shell shell, final Repository repository) { //perform branch operation try {//w ww.jav a 2 s . c o m ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); progressDialog.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.beginTask("Fetching updates from origin", 100); FetchOperationUI fetchOp = new FetchOperationUI(repository, new RemoteConfig(repository.getConfig(), "origin"), 3000, false); //$NON-NLS-1$ fetchOp.setCredentialsProvider(new EGitCredentialsProvider()); fetchOp.execute(new SubProgressMonitor(monitor, 100)); } catch (Exception e) { throw new InvocationTargetException(e); } } }); } catch (InterruptedException e) { //ignore } catch (Exception e) { RepositoryUtils.handleException(e); } }
From source file:com.github.funthomas424242.gedcoml.generator.popupMenus.AcceleoGenerateGEDCOMLGeneratorAction.java
License:Open Source License
/**{@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) * @generated//from w ww .ja va 2s. com */ public void run(IAction action) { if (files != null) { IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { Iterator<IFile> filesIt = files.iterator(); while (filesIt.hasNext()) { IFile model = (IFile) filesIt.next(); URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); try { IContainer target = model.getProject().getFolder("target/generated-sources"); GenerateAll generator = new GenerateAll(modelURI, target, getArguments()); generator.doGenerate(monitor); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } finally { model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); } } } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }; try { PlatformUI.getWorkbench().getProgressService().run(true, true, operation); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }
From source file:com.github.funthomas424242.rezeptsammler.rezept.generator.popupMenus.AcceleoGenerateRezept2MavenProjectAction.java
License:Open Source License
/**{@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) * @generated/* w w w .j ava 2 s .co m*/ */ public void run(IAction action) { if (files != null) { IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { Iterator<IFile> filesIt = files.iterator(); while (filesIt.hasNext()) { IFile model = (IFile) filesIt.next(); URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); try { IContainer target = model.getProject().getFolder("src-gen"); GenerateAll generator = new GenerateAll(modelURI, target, getArguments()); generator.doGenerate(monitor); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } finally { model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); } } } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }; try { PlatformUI.getWorkbench().getProgressService().run(true, true, operation); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }
From source file:com.github.lbroudoux.dsl.eip.gen.camel.ui.popupMenus.AcceleoGenerateEIPtoCamelJavaAction.java
License:Apache License
/**{@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) * @generated/*from w w w. j a v a2s . c o m*/ */ public void run(IAction action) { if (files != null) { IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { Iterator<IFile> filesIt = files.iterator(); while (filesIt.hasNext()) { IFile model = (IFile) filesIt.next(); URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); try { IContainer target = model.getProject().getFolder("src-gen"); GenerateJava generator = new GenerateJava(modelURI, target, getArguments()); generator.doGenerate(monitor); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } finally { model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); } } } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }; try { PlatformUI.getWorkbench().getProgressService().run(true, true, operation); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }
From source file:com.github.lbroudoux.dsl.eip.gen.camel.ui.popupMenus.AcceleoGenerateEIPtoCamelXmlAction.java
License:Apache License
/**{@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) * @generated/*from w ww . j a v a 2 s . c o m*/ */ public void run(IAction action) { if (files != null) { IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { Iterator<IFile> filesIt = files.iterator(); while (filesIt.hasNext()) { IFile model = (IFile) filesIt.next(); URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); try { IContainer target = model.getProject().getFolder("src-gen"); GenerateXml generator = new GenerateXml(modelURI, target, getArguments()); generator.doGenerate(monitor); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } finally { model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); } } } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }; try { PlatformUI.getWorkbench().getProgressService().run(true, true, operation); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }
From source file:com.github.lbroudoux.dsl.eip.gen.switchyard.ui.popupMenus.AcceleoGenerateSwitchyardAction.java
License:Apache License
/**{@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) * @generated NOT//from w w w . j av a 2s . c om */ public void run(IAction action) { if (files != null) { Iterator<IFile> filesIt = files.iterator(); while (filesIt.hasNext()) { final IFile model = (IFile) filesIt.next(); // Run dialog asynchronously into UI Thread. PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); DirectoryDialog dialog = new DirectoryDialog(activeShell); dialog.setText("Switchyard generation target"); dialog.setMessage("Select a target directory for project generation on " + model.getName()); final String directory = dialog.open(); if (directory == null) { return; } // Create a new runnable for this. IRunnableWithProgress operation = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) { URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); IContainer target = model.getProject().getWorkspace().getRoot() .getContainerForLocation(new Path(directory)); try { try { GenerateAll generator = new GenerateAll(modelURI, target, getArguments()); generator.doGenerate(monitor); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } finally { model.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); } } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }; // Execute runnable operation with progression. try { PlatformUI.getWorkbench().getProgressService().run(true, true, operation); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } catch (InterruptedException e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } }); } } }
From source file:com.github.librecut.internal.cutter.wizards.CutWizard.java
License:Open Source License
@Override public boolean performFinish() { final ICutter cutter = getSelectedCutter(); ILayout layout = getCurrentLayout(); if (layout == null) { return false; }/*from www . ja va2s . co m*/ final Map<String, Object> parameterMap = cuttingParameterPage.getParameterMap(); final IPattern pattern = createPattern(layout, cutter.getDescriptor()); if (!validatePattern(pattern, layout, cutter.getDescriptor())) { // TODO improve error reporting (show details of validation error) IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, STATUS_CODE_PATTERN_VALIDATION_FAILED, Messages.CutWizard_PatternValidationError, null); StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK); return false; } try { getContainer().run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SubMonitor subMonitor = SubMonitor.convert(monitor, "Cutting", 100); try { cutter.cut(pattern, parameterMap, subMonitor.newChild(100)); } finally { monitor.done(); } } }); return true; } catch (InvocationTargetException e) { return false; } catch (InterruptedException e) { return false; } }
From source file:com.github.sdbg.debug.ui.internal.view.RemoveAllBreakpointsAction.java
License:Open Source License
@Override public void run() { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); try {// www. j a va2 s . co m PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { deleteBreakpoints(shell, monitor); } }); } catch (InvocationTargetException e) { DartUtil.logError(e); } catch (InterruptedException e) { DartUtil.logError(e); } }
From source file:com.google.cloud.tools.eclipse.appengine.login.ui.LoginServiceUi.java
License:Apache License
private String showProgressDialogAndWaitForCode(final String message, final LocalServerReceiver codeReceiver, final String redirectUrl) throws IOException { try {/*from w w w .j a v a2 s . c o m*/ final Semaphore wait = new Semaphore(0 /* initially zero permit */); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shellProvider.getShell()) { @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.LOGIN_PROGRESS_DIALOG_TITLE); } @Override protected void cancelPressed() { wait.release(); // Allow termination of the attached task. stopCodeWaitingJob(redirectUrl); AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_CANCELED, null, null, getParentShell()); } }; final String[] codeHolder = new String[1]; final IOException[] exceptionHolder = new IOException[1]; dialog.run(true /* fork */, true /* cancelable */, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.LOGIN_START, null, null, dialog.getShell()); monitor.beginTask(message != null ? message : Messages.LOGIN_PROGRESS_DIALOG_MESSAGE, IProgressMonitor.UNKNOWN); // Fork another sub-job to circumvent the limitation of LocalServerReceiver. // (See the comments of scheduleCodeWaitingJob().) scheduleCodeWaitingJob(new LocalServerReceiverWrapper(codeReceiver), wait, codeHolder, exceptionHolder); wait.acquireUninterruptibly(); // Block until signaled. } }); if (exceptionHolder[0] != null) { throw exceptionHolder[0]; } return codeHolder[0]; } catch (InvocationTargetException | InterruptedException ex) { // Never thrown from the attached task. return null; } }