Java Code Examples for org.eclipse.jface.operation.IRunnableWithProgress

The following are top voted examples for showing how to use org.eclipse.jface.operation.IRunnableWithProgress. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: neoscada   File: PreviewPage.java   View source code 6 votes vote down vote up
@Override
public void setVisible ( final boolean visible )
{
    super.setVisible ( visible );
    if ( visible )
    {
        try
        {
            getContainer ().run ( false, false, new IRunnableWithProgress () {

                @Override
                public void run ( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
                {
                    setMergeResult ( PreviewPage.this.mergeController.merge ( wrap ( monitor ) ) );
                }
            } );
        }
        catch ( final Exception e )
        {
            final Status status = new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.PreviewPage_StatusErrorFailedToMerge, e );
            StatusManager.getManager ().handle ( status );
            ErrorDialog.openError ( getShell (), Messages.PreviewPage_TitleErrorFailedToMerge, Messages.PreviewPage_MessageErrorFailedToMerge, status );
        }
    }
}
 
Example 2
Project: neoscada   File: ExportEventsWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish ()
{
    try
    {
        getContainer ().run ( true, true, new IRunnableWithProgress () {

            public void run ( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
            {
                doExport ( monitor );
            }
        } );
        return true;
    }
    catch ( final Exception e )
    {
        StatusManager.getManager ().handle ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.ExportWizard_ErrorMessage, e ) );
        return false;
    }
}
 
Example 3
Project: gw4e.project   File: RunAsManualWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish() {
	try {
		getContainer().run(true, true, new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) {
				monitor.beginTask("Generating ", 1);
				persist();
				monitor.worked(1);
				monitor.done();
			}
		});
	} catch (Exception e) {
		ResourceManager.logException(e);
	}
	return true;
}
 
Example 4
Project: gw4e.project   File: GeneratorToFileCreationWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish() {
	if (resourcePage.isJavaApiBasedCheckbox()) {
		boolean autoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
		try {
			ResourceManager.setAutoBuilding(false);
			String modelFileName = resourcePage.getFilename().split(Pattern.quote("."))[0] + "Reduced." + Constant.GRAPH_JSON_FILE;
			File outputModelFile = elementsPage.getModelOutputFile(modelFileName);
			File outputjavafile = resourcePage.getOutputFile();
			String executionName = executionContextPage.getClassName();
			IRunnableWithProgress generator = new JavaApiBasedConverter(
					outputModelFile,
					outputjavafile, 
					resourcePage.getModelFile(), 
					executionName,
					elementsPage.getElements());
			getContainer().run(true, true, generator);
		} catch (Exception e) {
			DialogManager.displayErrorMessage(MessageUtil.getString("error"), MessageUtil.getString("an_error_has_occured_while_generating_test"), e);
			ResourceManager.logException(e);
		} finally {
			ResourceManager.setAutoBuilding(autoBuilding);
		}
	}
	return true;
}
 
Example 5
Project: termsuite-ui   File: ProgressServiceImpl.java   View source code 6 votes vote down vote up
@Override
public void runInUI(IRunnableContext context,
        IRunnableWithProgress runnable, ISchedulingRule rule)
        throws InvocationTargetException, InterruptedException {
	final RunnableWithStatus runnableWithStatus = new RunnableWithStatus(
			context,
			runnable, rule);
	uiSynchronize.syncExec(new Runnable() {
		@Override
		public void run() {
			BusyIndicator.showWhile(getDisplay(), runnableWithStatus);
		}

	});

	IStatus status = runnableWithStatus.getStatus();
	if (!status.isOK()) {
		Throwable exception = status.getException();
		if (exception instanceof InvocationTargetException)
			throw (InvocationTargetException) exception;
		else if (exception instanceof InterruptedException)
			throw (InterruptedException) exception;
		else // should be OperationCanceledException
			throw new InterruptedException(exception.getMessage());
	}
}
 
Example 6
Project: subclipse   File: RemoteResourceViewGraphAction.java   View source code 6 votes vote down vote up
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
	run(new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) {
			ISVNRemoteResource[] resources = getSelectedRemoteResources();
			if (resources.length == 0)
				resources = getSelectedRemoteFolders();
			try {
				if (resources.length > 0) {
					getTargetPage().openEditor(
							new RevisionGraphEditorInput(resources[0]),
							"org.tigris.subversion.subclipse.graph.editors.revisionGraphEditor");
				}
			} catch (Exception e) {
				Activator.handleError(e);
				Activator.showErrorDialog(getErrorTitle(), e);
			}				
		}
	}, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
 
Example 7
Project: subclipse   File: RepositoriesView.java   View source code 6 votes vote down vote up
/**
  * this is called whenever a new repository location is added for example
  * or when user wants to refresh
  */
 protected void refreshViewer(Object object, boolean refreshRepositoriesFolders) {
     if (treeViewer == null) return;
     if (refreshRepositoriesFolders) {
     	IRunnableWithProgress runnable = new IRunnableWithProgress() {
	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
             	SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor);
	}
     	};
         try {
	new ProgressMonitorDialog(getShell()).run(true, false, runnable);
} catch (Exception e) {
          SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
     }
     if (object == null) treeViewer.refresh();
     else {
     	if (object instanceof ISVNRemoteFolder) {
     		ISVNRemoteFolder parent = ((ISVNRemoteFolder)object).getParent();
     		if (parent == null) {
     			treeViewer.refresh();
     			return;
     		}
     	}
     	treeViewer.refresh(object); 
     }
 }
 
Example 8
Project: subclipse   File: ShowResourceInHistoryAction.java   View source code 6 votes vote down vote up
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
       if (action != null && !action.isEnabled()) { 
       	action.setEnabled(true);
       } 
       else {
		run(new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) {
				IResource[] resources = getSelectedResources();
				if (resources.length != 1) return;
				IHistoryView view = (IHistoryView) showView(ISVNUIConstants.HISTORY_VIEW_ID);
				if (view != null) {
					view.showHistoryFor(resources[0]);
				}
			}
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
       }
}
 
Example 9
Project: subclipse   File: DeleteRemoteResourceAction.java   View source code 6 votes vote down vote up
protected void execute(IAction action)
	throws InvocationTargetException, InterruptedException {
       RepositoryManager manager = SVNUIPlugin.getPlugin().getRepositoryManager();
       final String message = manager.promptForComment(getShell(), new IResource[]{});
       
       if (message == null)
           return; // cancel
       
       run(new IRunnableWithProgress() {
           public void run(IProgressMonitor monitor) throws InvocationTargetException {
               try {
                   SVNProviderPlugin.getPlugin().getRepositoryResourcesManager().
                       deleteRemoteResources(        
                           getSelectedRemoteResources(),message,monitor);
               } catch (TeamException e) {
                   throw new InvocationTargetException(e);
               }
           }
       }, true /* cancelable */, PROGRESS_BUSYCURSOR); //$NON-NLS-1$        

}
 
Example 10
Project: subclipse   File: SVNPropertyModifyAction.java   View source code 6 votes vote down vote up
protected void execute(IAction action)
	throws InvocationTargetException, InterruptedException {
		run(new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
				ISVNProperty svnProperty = getSelectedSvnProperties()[0];
				ISVNLocalResource svnResource = getSVNLocalResource(svnProperty);
				SvnWizardSetPropertyPage setPropertyPage = new SvnWizardSetPropertyPage(svnResource, svnProperty);
				SvnWizard wizard = new SvnWizard(setPropertyPage);
			    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
			    wizard.setParentDialog(dialog); 					
				if (dialog.open() != SvnWizardDialog.OK) return;
		
				try {
					if (setPropertyPage.getPropertyValue() != null) {
						svnResource.setSvnProperty(setPropertyPage.getPropertyName(), setPropertyPage.getPropertyValue(),setPropertyPage.getRecurse());
					} else {
						svnResource.setSvnProperty(setPropertyPage.getPropertyName(), setPropertyPage.getPropertyFile(),setPropertyPage.getRecurse());
					}
					SvnPropertiesView.refreshView();
				} catch (SVNException e) {
					throw new InvocationTargetException(e);
				}
			} 
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
 
Example 11
Project: google-cloud-eclipse   File: PipelineArgumentsTabTest.java   View source code 6 votes vote down vote up
@Test
public void testInitializeForm_noExceptionForNonAccessibleProject()
    throws CoreException, InvocationTargetException, InterruptedException {
  IWorkspaceRoot workspaceRoot = mock(IWorkspaceRoot.class);
  when(workspaceRoot.getProject(anyString())).thenReturn(mock(IProject.class));

  ILaunchConfigurationDialog dialog = mock(ILaunchConfigurationDialog.class);
  doAnswer(new SynchronousIRunnableContextExecutor())
      .when(dialog).run(anyBoolean(), anyBoolean(), any(IRunnableWithProgress.class));

  ILaunchConfiguration configuration = mock(ILaunchConfiguration.class);
  when(configuration.getAttribute(
      eq(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME), anyString()))
      .thenReturn("my-project");
  when(configuration.getAttribute(
      eq(PipelineConfigurationAttr.RUNNER_ARGUMENT.toString()), anyString()))
      .thenReturn("DirectPipelineRunner");

  PipelineArgumentsTab tab = new PipelineArgumentsTab(workspaceRoot);
  tab.setLaunchConfigurationDialog(dialog);
  tab.createControl(shellResource.getShell());
  tab.initializeFrom(configuration);  // Should not throw NPE.

  ProjectUtils.waitForProjects();  // Suppress some non-terminated-job error logs
}
 
Example 12
Project: hybris-commerce-eclipse-plugin   File: NewExtensionWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish() {
	getWizardPageConfig();
	IRunnableWithProgress runnable = new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				generateExtension(monitor, extension.getName(), saveLocation);
			} catch (CoreException ce) {
				throw new InvocationTargetException(ce);
			} finally {
				monitor.done();
			}
		}
	};
	try {
		getContainer().run(true, false, runnable);
	} catch (InterruptedException ie) {
		return false;
	} catch (InvocationTargetException ite) {
		Throwable realException = ite.getTargetException();
		MessageDialog.openError(getShell(), "Error", realException.getMessage());
		return false;
	}
	return true;
}
 
Example 13
Project: hybris-commerce-eclipse-plugin   File: ProjectSourceUtil.java   View source code 6 votes vote down vote up
/**
 * Return an attachment or detachment runner.
 * 
 * @param sourceArchive
 * @param isAttach
 * @return runner
 */
private static IRunnableWithProgress getRunnerInternal( final File sourceArchive, final boolean isAttach )
{
	IRunnableWithProgress runner = new IRunnableWithProgress()
	{
		@Override
		public void run( IProgressMonitor monitor ) throws InvocationTargetException
		{
			List<IProject> projects = Arrays.asList( ResourcesPlugin.getWorkspace().getRoot().getProjects() );
			int progress = 0;
			for( IProject project: projects )
			{
				if( FixProjectsUtils.isAHybrisExtension( project ) )
				{
					processProject( monitor, isAttach, project, sourceArchive );
				}
				progress++;
				monitor.worked( progress );
			}
		}
	};
	
	return runner;
}
 
Example 14
Project: hybris-commerce-eclipse-plugin   File: DetachSourcesHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException 
{

	Shell activeShell = HandlerUtil.getActiveShell(event);
	IRunnableWithProgress runner = ProjectSourceUtil.getRunner();

	try
	{
		new ProgressMonitorDialog( activeShell ).run( true, false, runner );

	}
	catch( InvocationTargetException | InterruptedException e )
	{
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError( activeShell, "Error detaching sources", t.toString() );
	}

	return null;
}
 
Example 15
Project: hybris-commerce-eclipse-plugin   File: ImportPlatformWizard.java   View source code 6 votes vote down vote up
/**
 * Attaches the sources.
 */
private void attachSources()
{
	final File sourceArchive = page2.getSourceFile();	
	
	if (sourceArchive == null) 
	{
		return; //nothing to do
	}
	
	IRunnableWithProgress runner = ProjectSourceUtil.getRunner(sourceArchive);

	try
	{
		new ProgressMonitorDialog( getContainer().getShell() ).run( true, false, runner );

	}
	catch( InvocationTargetException | InterruptedException e )
	{
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError( getShell(), "Error attaching sources", t.toString() );
	}
	
}
 
Example 16
Project: TranskribusSwtGui   File: ProgramUpdaterDialog.java   View source code 6 votes vote down vote up
private static boolean downloadUpdate(Shell parent, final ProgramPackageFile f, final boolean downloadAll) throws InterruptedException, Throwable {
	final File downloadFile = new File(UPDATE_ZIP_FN);
	logger.info("downloading update to: "+downloadFile.getAbsolutePath());
	final ProgressBarDialog pbd = new ProgressBarDialog(parent);
		pbd.open(new IRunnableWithProgress() {
			@Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				try {
					PROGRAM_UPDATER.downloadUpdate(downloadFile, f, monitor, downloadAll);
				} catch (Exception e) {
					throw new InvocationTargetException(e);
				}
			}
		}, "", true);
		logger.debug("was canceled: "+pbd.isCanceled());
		return pbd.isCanceled();
}
 
Example 17
Project: TranskribusSwtGui   File: ProgressBarDialog.java   View source code 6 votes vote down vote up
public void open(final IRunnableWithProgress runnable, String title, boolean mayCancel) throws InterruptedException, Throwable {
//		this.runnable = runnable;
		this.done = false;
		executorService = Executors.newSingleThreadScheduledExecutor();
		initInternalRunnable(runnable);
		
		this.setMayCancel(mayCancel);
		Assert.assertNotNull(runnable);

		createContents(); // create window

		shell.setText(title);
		shell.open();
		shell.layout();
				
		Future<?> fut = executorService.submit(internalRunnable);
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				checkIfFutIsDone(fut);
				
				display.sleep();	
			}
		}
		// return result;
	}
 
Example 18
Project: tlaplus   File: TranslatorJob.java   View source code 6 votes vote down vote up
/**
 * Return as runnable instead of the job
 * @param fileToBuild
 * @return
 */
public static IRunnableWithProgress getAsRunnableWithProgress(final IResource fileToBuild)
{
    final TranslatorJob job = new TranslatorJob(fileToBuild);
    return new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
        {
            try
            {
                job.setRule(ResourceHelper.getModifyRule(fileToBuild));
                job.runInWorkspace(monitor);
            } catch (CoreException e)
            {
                throw new InvocationTargetException(e);
            }
        }
    };
}
 
Example 19
Project: bts   File: LinkedEditingUndoSupport.java   View source code 6 votes vote down vote up
public void undoDocumentChanges() {
	final ISourceViewer viewer = editor.getInternalSourceViewer();
	try {
		editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				if (viewer instanceof ITextViewerExtension6) {
					IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
					if (undoManager instanceof IUndoManagerExtension) {
						IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
						IUndoContext undoContext = undoManagerExtension.getUndoContext();
						IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
						while (undoManager.undoable()) {
							if (startingUndoOperation != null
									&& startingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
								return;
							undoManager.undo();
						}
					}
				}
			}
		});
		syncUtil.waitForReconciler(editor);
	} catch (Exception e) {
		LOG.error(e.getMessage(), e);
	}
}
 
Example 20
Project: xtext-gef   File: ValidateAction.java   View source code 6 votes vote down vote up
/**
 * @generated
 */
public void run() {
	IWorkbenchPart workbenchPart = page.getActivePart();
	if (workbenchPart instanceof IDiagramWorkbenchPart) {
		final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart;
		try {
			new WorkspaceModifyDelegatingOperation(
					new IRunnableWithProgress() {

						public void run(IProgressMonitor monitor)
								throws InterruptedException,
								InvocationTargetException {
							runValidation(part.getDiagramEditPart(),
									part.getDiagram());
						}
					}).run(new NullProgressMonitor());
		} catch (Exception e) {
			StatemachineDiagramEditorPlugin.getInstance().logError(
					"Validation action failed", e); //$NON-NLS-1$
		}
	}
}
 
Example 21
Project: statecharts   File: SelectExamplePage.java   View source code 6 votes vote down vote up
private void initAsync() {
	try {
		getWizard().getContainer().run(true, false, new IRunnableWithProgress() {
			@Override
			public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				init(monitor);
			}
		});

		if (revealExamplesAutomatically()) {
			Display.getCurrent().asyncExec(new Runnable() {
				@Override
				public void run() {
					messageArea.button.setEnabled(false);
					revealExamples();
				}
			});
		}
	} catch (InvocationTargetException | InterruptedException e) {
		e.printStackTrace();
	}
}
 
Example 22
Project: statecharts   File: SelectExamplePage.java   View source code 6 votes vote down vote up
protected void revealExamples() {
	try {
		getWizard().getContainer().run(true, true, new IRunnableWithProgress() {
			@Override
			public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				final IStatus status = exampleService.fetchAllExamples(monitor);
				Display.getDefault().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (status.isOK()) {
							SelectExamplePage.this.setInput(monitor);
						} else {
							messageArea.showError();
						}
					}
				});
			}
		});

	} catch (InvocationTargetException | InterruptedException e1) {
		e1.printStackTrace();
	}
}
 
Example 23
Project: statecharts   File: ExampleWizard.java   View source code 6 votes vote down vote up
public boolean performFinish() {
	final ExampleData selection = page.getSelection();
	if (selection != null) {
		try {
			getContainer().run(true, true, new IRunnableWithProgress() {
				@Override
				public void run(IProgressMonitor monitor) throws InvocationTargetException {
					if (overrideIfExists(selection)) {
						exampleService.importExample(selection, monitor);
					}
				}
			});
		} catch (InvocationTargetException | InterruptedException e) {
			e.printStackTrace();
		}
	}
	return true;
}
 
Example 24
Project: statecharts   File: SGenNewFileWizard.java   View source code 6 votes vote down vote up
@Override
public boolean performFinish() {
	IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
		@Override
		protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException {
			ensureSCTNature(getProject(modelFilePage.getContainerFullPath()));
			Resource resource = createDefaultModel(modelFilePage.getURI());
			openModel(resource);
		}
	};
	try {
		getContainer().run(false, true, op);
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
	return true;
}
 
Example 25
Project: modelling-postgresql   File: MDACConfigurator.java   View source code 6 votes vote down vote up
public void actionPerformed(final List<MObject> selectedElements, final IModule module) {
	ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
	try {
		progress.run(true, false, new IRunnableWithProgress() {

			@Override
			public void run(IProgressMonitor arg0)
					throws InvocationTargetException, InterruptedException {					
				arg0.beginTask("Running...", IProgressMonitor.UNKNOWN);
				runScript(selectedElements, module);
				arg0.done();
			}
		});
	} catch (InvocationTargetException | InterruptedException e) {
		e.printStackTrace();
	}
}
 
Example 26
Project: vTM-eclipse   File: SWTUtil.java   View source code 6 votes vote down vote up
/**
 * Run a progress operation in the background.
 * @param op The operation to run.
 * @param wait Should the method block whilst the job is run?
 * @throws InvocationTargetException If the operation failed and threw an
 * exception.
 */
public static void progressBackground( IRunnableWithProgress op, boolean wait ) throws InvocationTargetException
{
   if( !ZXTMPlugin.isEclipseLoaded() ) 
   {
      System.err.println( "Cannot run operation, workspace not ready" );
      Thread.dumpStack();
      return;
   }
   
   BackgroundJob job = new BackgroundJob( op );
   job.schedule();
   
   if( wait ) {
     if( Job.getJobManager().currentJob() != null ) {
        ZDebug.dumpStackTrace( "Background job is trying to be run from another job and blocking" );
     } else {
        try { job.join(); } catch (Exception e) {}
     }
   }
}
 
Example 27
Project: APICloud-Studio   File: ShowResourceInHistoryAction.java   View source code 6 votes vote down vote up
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
       if (action != null && !action.isEnabled()) { 
       	action.setEnabled(true);
       } 
       else {
		run(new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) {
				IResource[] resources = getSelectedResources();
				if (resources.length != 1) return;
				IHistoryView view = (IHistoryView) showView(ISVNUIConstants.HISTORY_VIEW_ID);
				if (view != null) {
					view.showHistoryFor(resources[0]);
				}
			}
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
       }
}
 
Example 28
Project: APICloud-Studio   File: DeleteRemoteResourceAction.java   View source code 6 votes vote down vote up
protected void execute(IAction action)
	throws InvocationTargetException, InterruptedException {
       RepositoryManager manager = SVNUIPlugin.getPlugin().getRepositoryManager();
       final String message = manager.promptForComment(getShell(), new IResource[]{});
       
       if (message == null)
           return; // cancel
       
       run(new IRunnableWithProgress() {
           public void run(IProgressMonitor monitor) throws InvocationTargetException {
               try {
                   SVNProviderPlugin.getPlugin().getRepositoryResourcesManager().
                       deleteRemoteResources(        
                           getSelectedRemoteResources(),message,monitor);
               } catch (TeamException e) {
                   throw new InvocationTargetException(e);
               }
           }
       }, true /* cancelable */, PROGRESS_BUSYCURSOR); //$NON-NLS-1$        

}
 
Example 29
Project: APICloud-Studio   File: SVNPropertyModifyAction.java   View source code 6 votes vote down vote up
protected void execute(IAction action)
	throws InvocationTargetException, InterruptedException {
		run(new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
				ISVNProperty svnProperty = getSelectedSvnProperties()[0];
				ISVNLocalResource svnResource = getSVNLocalResource(svnProperty);
				SvnWizardSetPropertyPage setPropertyPage = new SvnWizardSetPropertyPage(svnResource, svnProperty);
				SvnWizard wizard = new SvnWizard(setPropertyPage);
			    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
			    wizard.setParentDialog(dialog); 					
				if (dialog.open() != SvnWizardDialog.OK) return;
		
				try {
					if (setPropertyPage.getPropertyValue() != null) {
						svnResource.setSvnProperty(setPropertyPage.getPropertyName(), setPropertyPage.getPropertyValue(),setPropertyPage.getRecurse());
					} else {
						svnResource.setSvnProperty(setPropertyPage.getPropertyName(), setPropertyPage.getPropertyFile(),setPropertyPage.getRecurse());
					}
					SvnPropertiesView.refreshView();
				} catch (SVNException e) {
					throw new InvocationTargetException(e);
				}
			} 
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
 
Example 30
Project: OpenSPIFe   File: TransferableExportWizard.java   View source code 6 votes vote down vote up
@Override
protected void savePlan(final EPlan plan, final File file) throws Exception {
	final boolean isExportSelected = isExportSelected();
	IRunnableWithProgress op = new IRunnableWithProgress() {
		@Override
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				exportPlan(plan, file, isExportSelected, monitor);
			} catch (ThreadDeath td) {
				throw td;
			} catch (Throwable t) {
				throw new InvocationTargetException(t);
			}
		}
	};
	getContainer().run(true, true, op);
}
 
Example 31
Project: OpenSPIFe   File: SpifeResourceUtils.java   View source code 6 votes vote down vote up
public static IEditorPart openPlanEditorFromWizard(final IFile planFile, final IWorkbench workbench, IWizardContainer container) {
	final IEditorPart[] result = new IEditorPart[1];
	try {
		container.run(false, false, new IRunnableWithProgress() {
			@Override
			public void run(IProgressMonitor monitor) {
				try {
					monitor.beginTask("Opening " + planFile.getName() + " in editor", IProgressMonitor.UNKNOWN);
					result[0] = openEditorOnPlanFile(planFile, workbench);
				} finally {
					monitor.done();
				}
			}
		});
	} catch (Exception e) {
		LogUtil.error(e);
	}
	return result[0];
}
 
Example 32
Project: Eclipse-Postfix-Code-Completion   File: JavadocConfigurationPropertyPage.java   View source code 6 votes vote down vote up
private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final URL javadocLocation, final IClasspathEntry entry, final IPath containerPath) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				IJavaProject project= elem.getJavaProject();
				if (elem instanceof IPackageFragmentRoot) {
					CPListElement cpElem= CPListElement.createFromExisting(entry, project);
					String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null;
					cpElem.setAttribute(CPListElement.JAVADOC, loc);
					IClasspathEntry newEntry= cpElem.getClasspathEntry();
					String[] changedAttributes= { CPListElement.JAVADOC };
					BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor);
				} else {
					JavaUI.setProjectJavadocLocation(project, javadocLocation);
				}
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
}
 
Example 33
Project: Eclipse-Postfix-Code-Completion   File: NativeLibrariesPropertyPage.java   View source code 6 votes vote down vote up
private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final String nativeLibraryPath, final IClasspathEntry entry, final IPath containerPath, final boolean isReferencedEntry) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				IJavaProject project= elem.getJavaProject();
				if (elem instanceof IPackageFragmentRoot) {
					CPListElement cpElem= CPListElement.createFromExisting(entry, project);
					cpElem.setAttribute(CPListElement.NATIVE_LIB_PATH, nativeLibraryPath);
					IClasspathEntry newEntry= cpElem.getClasspathEntry();
					String[] changedAttributes= { CPListElement.NATIVE_LIB_PATH };
					BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, isReferencedEntry,  monitor);
				}
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
}
 
Example 34
Project: Eclipse-Postfix-Code-Completion   File: MainMethodSearchEngine.java   View source code 6 votes vote down vote up
/**
 * Searches for all main methods in the given scope.
 * Valid styles are IJavaElementSearchConstants.CONSIDER_BINARIES and
 * IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS
 * @param context runnable context
 * @param scope the search scope
 * @param style style search style constants (see {@link IJavaElementSearchConstants})
 * @return the types found
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
public IType[] searchMainMethods(IRunnableContext context, final IJavaSearchScope scope, final int style) throws InvocationTargetException, InterruptedException  {
	int allFlags=  IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS | IJavaElementSearchConstants.CONSIDER_BINARIES;
	Assert.isTrue((style | allFlags) == allFlags);

	final IType[][] res= new IType[1][];

	IRunnableWithProgress runnable= new IRunnableWithProgress() {
		public void run(IProgressMonitor pm) throws InvocationTargetException {
			try {
				res[0]= searchMainMethods(pm, scope, style);
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
	context.run(true, true, runnable);

	return res[0];
}
 
Example 35
Project: tesb-studio-se   File: StopRuntimeAction.java   View source code 6 votes vote down vote up
@Override
public void run() {

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(false, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                new StopRuntimeProgress().run(monitor);
            }
        });
    } catch (Throwable e) {
        ExceptionHandler.process(e);
        IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e);
        if (e.getCause() != null) {
            status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause());
        }
        RuntimeErrorDialog.openError(shell,
                RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog6"),
                RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog6"), status);
    }
}
 
Example 36
Project: tesb-studio-se   File: StartRuntimeAction.java   View source code 6 votes vote down vote up
@Override
public void run() {

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(false, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                new StartRuntimeProgress(true).run(monitor);
            }
        });
    } catch (Throwable e) {
        ExceptionHandler.process(e);
        IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e);
        if (e.getCause() != null) {
            status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause());
        }
        RuntimeErrorDialog.openError(shell,
                RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog3"),
                RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog3"), status);
    }
}
 
Example 37
Project: XPagesExtensionLibrary   File: AbstractBluemixWizard.java   View source code 6 votes vote down vote up
protected boolean runJob(IRunnableWithProgress runnable) {
    // Clear any errors
    ((WizardPage)getContainer().getCurrentPage()).setErrorMessage(null);
    _jobException = null;

    // Start the job
    try {
        getContainer().run(true, true, runnable);
    } catch (Exception e) {
        _jobException = e;
    } 

    // Check for errors
    if (_jobException != null) {
        String msg = StringUtil.format("{0} : {1}", _jobException.getMessage(), BluemixUtil.getErrorText(_jobException));
        ((WizardPage)getContainer().getCurrentPage()).setErrorMessage(msg);
        if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
            BluemixLogger.BLUEMIX_LOGGER.errorp(this, "runJob", BluemixUtil.getRootCause(_jobException), "Error running job"); // $NON-NLS-1$ $NLE-AbstractBluemixWizard.Errorrunningjob-2$
        }            
        return false;
    }

    return true;
}
 
Example 38
Project: idecore   File: ActionController.java   View source code 6 votes vote down vote up
protected void syncCheckWork() throws InvocationTargetException, InterruptedException {
    IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.run(true, true, new IRunnableWithProgress() {
        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask("Synchronize check against server", 2);
            try {
                monitorWork(monitor);
                boolean tmpInSync = false;
                for (IResource resource : getSelectedResources()) {
                    ProjectService projectService = ContainerDelegate.getInstance().getServiceLocator().getProjectService();
                    tmpInSync = projectService.isResourceInSync(
                    		resource,
                            new SubProgressMonitor(monitor, 4));
                    if (!tmpInSync) {
                        isInSync = false;
                    }
                }
            } catch (Exception e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    });
}
 
Example 39
Project: idecore   File: ProjectContentPropertyPage.java   View source code 6 votes vote down vote up
private static void refreshProject(final IWorkbench workbench, final IStructuredSelection selection) throws InvocationTargetException,
        InterruptedException {
    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
    service.run(false, false, new IRunnableWithProgress() {
        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException {
            monitor.beginTask("Refreshing project...", IProgressMonitor.UNKNOWN);
            try {
                RefreshResourceHandler.execute(workbench, selection);
            } catch (Throwable e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    });
}
 
Example 40
Project: idecore   File: DeploymentResultsPage.java   View source code 6 votes vote down vote up
private void deploy() throws InvocationTargetException {
    IProgressService service = PlatformUI.getWorkbench().getProgressService();
    try {
        service.run(true, true, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Deploying components...", 1);
                try {
                    deploymentWizard.getDeploymentController().finish(new SubProgressMonitor(monitor, 3));
                    monitor.worked(1);
                } finally {
                    monitor.subTask("Done");
                }
            }
        });
    } catch (InterruptedException e) {
        logger.warn("Operation cancelled: " + e.getMessage());
    }
}