List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
IRunnableWithProgress
using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork
. From source file:org.eclipse.oomph.ui.UIUtil.java
License:Open Source License
public static void runInProgressDialog(Shell shell, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell) { @Override/*from w ww . j a v a 2 s . c o m*/ protected Point getInitialSize() { Point calculatedSize = super.getInitialSize(); if (calculatedSize.x < 800) { calculatedSize.x = 800; } return calculatedSize; } }; try { dialog.run(true, true, runnable); } catch (OperationCanceledException ex) { // Ignore. } catch (InvocationTargetException ex) { if (!(ex.getCause() instanceof OperationCanceledException)) { throw ex; } } }
From source file:org.eclipse.papyrus.customization.properties.ui.CopyContextAction.java
License:Open Source License
private void copyAll(final Context source, final File target) { final File targetDirectory = target.getParentFile(); final String targetName = target.getName(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try {/*w w w.j a v a 2 s . co m*/ dialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { monitor.beginTask(Messages.CopyContextAction_InitializingTheCopyOf + source.getName() + Messages.CopyContextAction_ThisMayTakeSomeTime, IProgressMonitor.UNKNOWN); //EcoreUtil.resolveAll(source); //This method is too expensive resolveAllResources(source); //Ignores the *.xwt files. We will copy them manually. monitor.done(); result = Status.OK_STATUS; } }); dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); if (result.getCode() == IStatus.OK) { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { targetDirectory.mkdirs(); int filesToCopy = source.eResource().getResourceSet().getResources().size(); List<Context> contexts = new LinkedList<Context>(); for (Context context : PropertiesUtil.getDependencies(source)) { if (isRelative(source, context.eResource())) { contexts.add(context); for (Tab tab : context.getTabs()) { filesToCopy += tab.getSections().size(); } } } monitor.beginTask(Messages.CopyContextAction_Copying + source.getName() + Messages.CopyContextAction_To + targetName, filesToCopy); //Copy of the context copy(source.eResource(), target); monitor.worked(1); //Copy of the dependent resources which are located in the same folder //(or subfolders) for (Resource resource : source.eResource().getResourceSet().getResources()) { if (monitor.isCanceled()) { return; } if (source.eResource() != resource && isRelative(source, resource)) { copy(resource, targetDirectory, source, targetName); } monitor.worked(1); } //Copy the XWT files (they haven't been loaded in the resource set) for (Context context : contexts) { for (Tab tab : context.getTabs()) { for (Section section : tab.getSections()) { if (monitor.isCanceled()) { return; } copy(section.getSectionFile(), targetDirectory, source); monitor.worked(1); } } } monitor.done(); } catch (IOException ex) { Activator.log.error(ex); result = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An error occured during the copy of " + source.getName(), ex); //$NON-NLS-1$ return; } result = Status.OK_STATUS; } }); } } catch (InvocationTargetException ex) { Activator.log.error(ex); } catch (InterruptedException ex) { Activator.log.error(ex); } }
From source file:org.eclipse.papyrus.customization.properties.ui.EditContextAction.java
License:Open Source License
/** * Opens an Eclipse Editor to edit the given context. * //from ww w . j a va 2s.c o m * @param context * The context to edit * @throws Exception * If the context cannot be edited */ public void openEditor(final Context context) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { dialog.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Opening the property view configuration: " + context.getName(), IProgressMonitor.UNKNOWN); try { runOpenEditor(context); } catch (CoreException ex) { Activator.log.error(ex); } monitor.done(); } }); } catch (Exception ex) { Activator.log.error(ex); } }
From source file:org.eclipse.papyrus.customization.properties.ui.RemoveContextAction.java
License:Open Source License
/** * Deletes the given context.//from www .ja v a 2 s . c o m * * @param sourceContext * The context to delete */ public void removeContext(final Context sourceContext) { //TODO : Close editors for the context being deleted final File directory = new File(sourceContext.eResource().getURI().toFileString()).getParentFile(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { dialog.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Deleting the property view configuration: " + sourceContext.getName(), IProgressMonitor.UNKNOWN); ConfigurationManager.instance.deleteContext(sourceContext); delete(directory); monitor.done(); } }); } catch (Exception ex) { Activator.log.error(ex); } }
From source file:org.eclipse.pde.internal.runtime.logview.LogView.java
License:Open Source License
public void handleImportPath(String path) { if (path != null && new Path(path).toFile().exists()) { fInputFile = new Path(path).toFile(); fDirectory = fInputFile.getParent(); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDERuntimeMessages.get().LogView_operation_importing, IProgressMonitor.UNKNOWN); readLogFile();//from www . ja v a2 s .com } }; ProgressMonitorDialog pmd = new ProgressMonitorDialog(getViewSite().getShell()); try { pmd.run(true, true, op); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } finally { fReadLogAction.setText(PDERuntimeMessages.get().LogView_readLog_reload); fReadLogAction.setToolTipText(PDERuntimeMessages.get().LogView_readLog_reload); asyncRefresh(false); resetDialogButtons(); } } }
From source file:org.eclipse.pde.internal.runtime.logview.LogView.java
License:Open Source License
protected void reloadLog() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDERuntimeMessages.get().LogView_operation_reloading, IProgressMonitor.UNKNOWN); readLogFile();// w ww .ja va 2s .c o m } }; ProgressMonitorDialog pmd = new ProgressMonitorDialog(getViewSite().getShell()); try { pmd.run(true, true, op); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } finally { fReadLogAction.setText(PDERuntimeMessages.get().LogView_readLog_restore); fReadLogAction.setToolTipText(PDERuntimeMessages.get().LogView_readLog_restore); asyncRefresh(false); resetDialogButtons(); } }
From source file:org.eclipse.pde.internal.runtime.logview.OpenLogDialog.java
License:Open Source License
private void readLargeFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDERuntimeMessages.get().OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readLargeFile(writer);/*from w w w .j a v a 2 s. c o m*/ } catch (IOException e) { writer.println(PDERuntimeMessages.get().OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:org.eclipse.pde.internal.runtime.logview.OpenLogDialog.java
License:Open Source License
private void readFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDERuntimeMessages.get().OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readFile(writer);//from www .j ava 2 s . com } catch (IOException e) { writer.println(PDERuntimeMessages.get().OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:org.eclipse.pde.internal.ui.launcher.OpenLogDialog.java
License:Open Source License
private void readLargeFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDEUIMessages.OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readLargeFile(writer);/*from w w w . ja v a2s. c o m*/ } catch (IOException e) { writer.println(PDEUIMessages.OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:org.eclipse.pde.internal.ui.launcher.OpenLogDialog.java
License:Open Source License
private void readFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(PDEUIMessages.OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readFile(writer);/* ww w. j a v a 2 s . com*/ } catch (IOException e) { writer.println(PDEUIMessages.OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }