org.eclipse.jface.operation.IRunnableWithProgress Java Examples

The following examples show how to use org.eclipse.jface.operation.IRunnableWithProgress. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TmxEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private void doFilter(final TmxEditorFilterBean filter) {
	TeActiveCellEditor.commit();
	final String srcSearchStr = getSearchText(srcSearchText);
	final String tgtSearchStr = getSearchText(tgtSearchText);
	IRunnableWithProgress progress = new IRunnableWithProgress() {
		@Override
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
			tmxDataAccess.loadDisplayTuIdentifierByFilter(monitor, filter, srcLangCode, tgtLangCode, srcSearchStr,
					tgtSearchStr);
		}
	};
	try {
		new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, progress);
	} catch (Exception e) {
		e.printStackTrace();
	}
	tmxEditorImpWithNattable.setSrcSearchStr(srcSearchStr);
	tmxEditorImpWithNattable.setTgtSearchStr(tgtSearchStr);
	tmxEditorImpWithNattable.getTable().setFocus();
	tmxEditorImpWithNattable.refrush();
	tmxEditorImpWithNattable.selectCell(getTgtColumnIndex(), 0);
}
 
Example #2
Source File: ValidateAction.java    From scava with Eclipse Public License 2.0 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) {
			CrossflowDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
		}
	}
}
 
Example #3
Source File: ExportEventsWizard.java    From neoscada with Eclipse Public License 1.0 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 #4
Source File: PreviewPage.java    From neoscada with Eclipse Public License 1.0 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 #5
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 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) {
			ProcessDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
		}
	}
}
 
Example #6
Source File: ExportWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean performFinish() {
	try {
		getContainer().run(true, false, new IRunnableWithProgress() {
			
			@Override
			public void run(IProgressMonitor monitor) throws InvocationTargetException,
					InterruptedException {
				monitor.beginTask(Messages.exporting, IProgressMonitor.UNKNOWN) ;
				Display.getDefault().asyncExec(new Runnable() {
					
					@Override
					public void run() {
						IAction action = page.getAction() ;
						action.run() ;	
					}
				}) ;
			}
		});
	} catch (Exception e){
		BonitaStudioLog.error(e) ;
	}
	
	
	return true;
}
 
Example #7
Source File: ConfigurationWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void setProcess(final AbstractProcess process) {
    this.process = process;
    final Configuration configuration = getConfigurationFromProcess(process, configurationName);
    if (configuration != null) {
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        try {
            service.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    new ConfigurationSynchronizer(process, configuration).synchronize(monitor);
                }
            });
        } catch (final InvocationTargetException | InterruptedException e) {
            BonitaStudioLog.error(e);
        }
        configurationWorkingCopy = emfModelUpdater.from(configuration).getWorkingCopy();
    }
}
 
Example #8
Source File: ProjectSourceUtil.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 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 #9
Source File: ContractInputControllerTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_open_an_error_dialog_if_remove_operation_failed() throws Exception {
    final IProgressService mockProgressService = mock(IProgressService.class);
    contractInputController = spy(new ContractInputController(mockProgressService));
    doReturn(new TransactionalEditingDomainImpl(new ProcessItemProviderAdapterFactory())).when(contractInputController).editingDomain(any(Contract.class));

    final Contract contract = aContract().havingInput(aContractInput()).in(aTask()).build();
    observableValue.setValue(contract);
    when(viewer.getSelection()).thenReturn(new StructuredSelection(contract.getInputs()));
    final InvocationTargetException error = new InvocationTargetException(new Throwable());
    doThrow(error).when(mockProgressService).run(anyBoolean(), anyBoolean(), any(IRunnableWithProgress.class));

    contractInputController.remove(viewer);

    verify(contractInputController).openErrorDialog(error);
}
 
Example #10
Source File: ExampleWizard.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public boolean performFinish() {
	final List<ExampleData> selection = page.getSelection();
	if (selection != null) {
		try {
			getContainer().run(true, true, new IRunnableWithProgress() {
				@Override
				public void run(IProgressMonitor monitor) throws InvocationTargetException {
					for (ExampleData exampleData : selection) {
						if (overrideIfExists(exampleData)) {
							IProject project = importer.importExample(exampleData, monitor);
							opener.openModelFiles(project);
						}
					}
				}
			});
		} catch (InvocationTargetException | InterruptedException e) {
			e.printStackTrace();
		}
	}
	return true;
}
 
Example #11
Source File: CheckoutAction.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void doCheckout(Commit commit) throws Exception {
	ProgressMonitorDialog dialog = new ProgressMonitorDialog(UI.shell());
	dialog.run(true, false, new IRunnableWithProgress() {

		@Override
		public void run(IProgressMonitor m) throws InvocationTargetException, InterruptedException {
			try {
				FetchNotifierMonitor monitor = new FetchNotifierMonitor(m, M.CheckingOutCommit);
				RepositoryClient client = Database.getRepositoryClient();
				client.checkout(commit.id, monitor);
			} catch (WebRequestException e) {
				throw new InvocationTargetException(e, e.getMessage());
			}
		}
	});
}
 
Example #12
Source File: RefreshAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
final protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
	return new WorkspaceModifyOperation() {
		@Override
		public void execute(final IProgressMonitor monitor) {
			final Iterator<? extends IResource> resourcesEnum = resources.iterator();
			try {
				while (resourcesEnum.hasNext()) {
					try {
						final IResource resource = resourcesEnum.next();
						refreshResource(resource, null);
					} catch (final CoreException e) {}
					if (monitor.isCanceled()) { throw new OperationCanceledException(); }
				}
			} finally {
				monitor.done();
			}
		}
	};
}
 
Example #13
Source File: DeleteRemoteResourceAction.java    From APICloud-Studio with GNU General Public License v3.0 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 #14
Source File: ContractInputGenerationWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected IRunnableWithProgress buildContractOperationFromData(BusinessObjectData data,
        RootContractInputGenerator contractInputGenerator) {
    return monitor -> {
        try {
            if (contractContainer instanceof Pool) {
                contractInputGenerator.buildForInstanciation(data, monitor);
            } else {
                contractInputGenerator.build(data, generationOptions.getEditMode(), monitor);
            }
            monitor.beginTask("Generating contract constraints...", IProgressMonitor.UNKNOWN);
            List<ContractConstraint> constraints = contractConstraintBuilder.buildConstraints(
                    contractInputGenerator.getRootContractInput(), ModelHelper.getParentPool(contractContainer));
            editingDomain.getCommandStack().execute(createCommand(contractInputGenerator, data, constraints));
        } catch (final OperationCreationException e) {
            throw new InvocationTargetException(e);
        }
    };
}
 
Example #15
Source File: ShowResourceInHistoryAction.java    From APICloud-Studio with GNU General Public License v3.0 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 #16
Source File: TmxValidatorDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void okPressed() {
	styledText.setText("");
	final String tmxFilePath = txtTmxFilePath.getText();
	try {
		run(isFork(), canCancel(), new IRunnableWithProgress() {
			@Override
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				TmxValidator validator = new TmxValidator(monitor);
				validator.setReport(true);
				validator.setNormalize(true);
				validator.setDebug(true);
				validator.setStyledText(styledText);
				validator.validate(tmxFilePath);
			}
		});
	} catch (Exception e) {
		LOGGER.error("", e);
		OpenMessageUtils.openMessage(IStatus.ERROR, e.getMessage());
	}
}
 
Example #17
Source File: RunContainerProcessor.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public void generatePom(int option) {
    super.generatePom(option);

    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB
            && ComponentCategory.CATEGORY_4_CAMEL.getName().equals(getProcess().getComponentsType())) {
        try {
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(),
                    "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
 
Example #18
Source File: OSGIJavaProcessor.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public void generatePom(int option) {
    // TESB-27828: Set OSGI type for pom creator
	if(ProcessorUtilities.isExportAsOSGI()) {
		getArguments().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, "OSGI");
	}
    try {
        IRepositoryObject repositoryObject = new RepositoryObject(getProperty());
        IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(), "",
                false);
        action.run(new NullProgressMonitor());
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.generatePom(option);
}
 
Example #19
Source File: BundleJavaProcessor.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public void generatePom(int option) {
    super.generatePom(option);
    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB) {
        try {
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(),
                    "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
 
Example #20
Source File: MainMethodSearchEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 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 #21
Source File: AsynchronousProgressMonitorDialog.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Test code below
 */
public static void main(String[] arg) {
    Shell shl = new Shell();
    ProgressMonitorDialog dlg = new AsynchronousProgressMonitorDialog(shl);

    long l = System.currentTimeMillis();
    try {
        dlg.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Testing", 100000);
                for (long i = 0; i < 100000 && !monitor.isCanceled(); i++) {
                    //monitor.worked(1);
                    monitor.setTaskName("Task " + i);
                }
            }
        });
    } catch (Exception e) {
        Log.log(e);
    }
    System.out.println("Took " + ((System.currentTimeMillis() - l)));
}
 
Example #22
Source File: NativeLibrariesPropertyPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 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 #23
Source File: ConnectorConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void checkImplementationDependencies(final ConnectorImplementation implementation) {
    if(!implementation.getJarDependencies().getJarDependency().isEmpty()){
        try {
            final IProgressService service =  PlatformUI.getWorkbench().getProgressService() ;
            service.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(Messages.addingImplementationDependencies, IProgressMonitor.UNKNOWN) ;
                    final DependencyRepositoryStore depStore = RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class) ;
                    for(final String jarName : implementation.getJarDependencies().getJarDependency()){
                        if( depStore.getChild(jarName, true) == null){
                            final InputStream is = getResourceProvider().getDependencyInputStream(jarName) ;
                            if(is != null){
                                depStore.importInputStream(jarName, is) ;
                            }
                        }
                    }
                }
            }) ;
        } catch (final Exception e){
            BonitaStudioLog.error(e) ;
        }
    }
}
 
Example #24
Source File: ExcelExportWizard.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void run(final ExcelExport export) {
	try {
		getContainer().run(true, false, new IRunnableWithProgress() {
			@Override
			public void run(IProgressMonitor monitor)
					throws InvocationTargetException, InterruptedException {
				monitor.beginTask(M.Export,
						IProgressMonitor.UNKNOWN);
				export.run();
				monitor.done();
			}
		});
	} catch (Exception e) {
		log.error("Export failed", e);
	}
}
 
Example #25
Source File: SVNPropertyModifyAction.java    From APICloud-Studio with GNU General Public License v3.0 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 #26
Source File: JavaCapabilityConfigurationPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the runnable that will create the Java project or <code>null</code> if the page has
 * not been initialized. The runnable sets the project's classpath and output location to the values
 * configured in the page and adds the Java nature if not set yet. The method requires that the
 * project is created and opened.
 *
 * @return the runnable that creates the new Java project
 */
public IRunnableWithProgress getRunnable() {
	if (getJavaProject() != null) {
		return new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				try {
					configureJavaProject(monitor);
				} catch (CoreException e) {
					throw new InvocationTargetException(e);
				}
			}
		};
	}
	return null;
}
 
Example #27
Source File: ProjectCompareTree.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new default comparison of all API / implementation projects in the default workspace (i.e. the one
 * accessed via {@link IN4JSCore}) and shows this comparison in the widget.
 */
public void setComparison() {
	final ProgressMonitorDialog dlg = new ProgressMonitorDialog(getTree().getShell());
	try {
		dlg.run(false, false, new IRunnableWithProgress() {
			@Override
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				setComparison(monitor);
			}
		});
	} catch (InvocationTargetException | InterruptedException e) {
		// ignore
	}
}
 
Example #28
Source File: FindStringsToExternalizeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IRunnableWithProgress createRunnable(final IStructuredSelection selection) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor pm) throws InvocationTargetException {
			try {
				fElements= doRun(selection, pm);
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
}
 
Example #29
Source File: ChooseUrlDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void refreshRepositoriesFolders() {
  	IRunnableWithProgress runnable = new IRunnableWithProgress() {
	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
          	SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor);
  			needsRefresh = false;
	}
  	};
      try {
	new ProgressMonitorDialog(getShell()).run(true, false, runnable);
} catch (Exception e) {
          SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}    	
  }
 
Example #30
Source File: SelectionConverter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static IJavaElement[] performForkedCodeResolve(final ITypeRoot input, final ITextSelection selection) throws InvocationTargetException, InterruptedException {
	final class CodeResolveRunnable implements IRunnableWithProgress {
		IJavaElement[] result;
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				result= codeResolve(input, selection);
			} catch (JavaModelException e) {
				throw new InvocationTargetException(e);
			}
		}
	}
	CodeResolveRunnable runnable= new CodeResolveRunnable();
	PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
	return runnable.result;
}