public boolean open() { boolean retval = true; IRunnableWithProgress op = new IRunnableWithProgress() { public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { rep.save( jobMeta, versionComment, new ProgressMonitorAdapter( monitor ) ); } catch ( KettleException e ) { throw new InvocationTargetException( e, "Error saving job" ); } } }; try { ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell ); pmd.run( true, true, op ); } catch ( InvocationTargetException e ) { new ErrorDialog( shell, "Error saving job", "An error occured saving the job!", e ); retval = false; } catch ( InterruptedException e ) { new ErrorDialog( shell, "Error saving job", "An error occured saving the job!", e ); retval = false; } return retval; } }
ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell ); pmd.run( true, true, op ); if ( !pmd.getProgressMonitor().isCanceled() && isFeedback ) {
public void run() { IProgressMonitor monitor = pmd.getProgressMonitor(); while ( pmd.getShell() == null || ( !pmd.getShell().isDisposed() && !monitor.isCanceled() ) ) { try { Thread.sleep( 100 ); } catch ( InterruptedException e ) { // Ignore } } if ( monitor.isCanceled() ) { // Disconnect and see what happens! try { trans.stopAll(); } catch ( Exception e ) { /* Ignore */ } } } };
private void handleBrowseClasses() { Shell shell = getShell(); IType itype = DialogUtils.browseClassesAsIType(shell, ResourcesPlugin.getWorkspace().getRoot().getProjects(), new ProgressMonitorDialog(shell)); if( itype != null ) { classNameText.setText(itype.getFullyQualifiedName()); } }
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.setBlockOnOpen(false); dialog.setCancelable(true); dialog.open(); final IProgressMonitor monitor = dialog.getProgressMonitor(); final IRuntimeLocator[] locators = ServerPlugin.getRuntimeLocators(); monitor.beginTask(Messages.dialogRuntimeSearchProgress, 100 * locators.length + 10); dialog.run(true, true, runnable); dialog.close(); } catch (Exception ex) { Trace.trace(Trace.SEVERE, "Error finding runtimes", ex);
final IProgressMonitor monitor = dialog.getProgressMonitor(); dialog.setCancelable(true); dialog.run( true, true, new IRunnableWithProgress() {
IContainer container= (IContainer) o; ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); IProgressMonitor pm= pmdialog.getProgressMonitor(); IFile[] states= null; try {
@Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { //if it is run in the UI Thread don't do anything. if (!fork) { enableDetails(false); } super.run(fork, cancelable, runnable); }
/** * This implementation of IRunnableContext#run(boolean, boolean, * IRunnableWithProgress) runs the given <code>IRunnableWithProgress</code> * using the progress monitor for this progress dialog and blocks until the * runnable has been run, regardless of the value of <code>fork</code>. * The dialog is opened before the runnable is run, and closed after it * completes. It is recommended that <code>fork</code> is set to true in * most cases. If <code>fork</code> is set to <code>false</code>, the * runnable will run in the UI thread and it is the runnable's * responsibility to call <code>Display.readAndDispatch()</code> to ensure * UI responsiveness. */ @Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { setCancelable(cancelable); try { aboutToRun(); // Let the progress monitor know if they need to update in UI Thread progressMonitor.forked = fork; ModalContext.run(runnable, fork, getProgressMonitor(), getShell() .getDisplay()); } finally { finishedRun(); } }
/** * Called just before the operation is run. Default behaviour is to open or * create the dialog, based on the setting of <code>getOpenOnRun</code>, * and increment the nesting depth. */ protected void aboutToRun() { if (getOpenOnRun()) { open(); } else { create(); } incrementNestingDepth(); }
/** * Saves the specified editors */ private void saveItems(TableItem items[]) { if (items.length == 0) { return; } ProgressMonitorDialog pmd = new ProgressMonitorJobsDialog(getShell()); pmd.open(); for (TableItem item : items) { Adapter editor = (Adapter) item.getData(); editor.save(pmd.getProgressMonitor()); updateItem(item, editor); } pmd.close(); updateItems(); }
/** * Called just after the operation is run. Default behaviour is to decrement * the nesting depth, and close the dialog. * * @since 3.0 */ protected void finishedRun() { decrementNestingDepth(); close(); }
@Override public boolean close() { alreadyClosed = true;//As this sometimes delayed cache if it was already closed boolean result = super.close(); if (!result) {//If it fails reset the flag alreadyClosed = false; } return result; }
public void run(Shell parent) throws InterruptedException, InvocationTargetException { IRunnableContext context= new ProgressMonitorDialog(parent); new RefactoringExecutionHelper(fPasteRefactoring, RefactoringCore.getConditionCheckingFailedSeverity(), RefactoringSaveHelper.SAVE_NOTHING, parent, context).perform(false, false); } }
final IProgressMonitor monitor = dialog.getProgressMonitor(); dialog.setCancelable(true); dialog.run(true, true, runnable); } catch (InvocationTargetException e) { DebugUIPlugin.log(e);
IContainer container= (IContainer) o; ProgressMonitorDialog pmdialog= new ProgressMonitorDialog(parentShell); IProgressMonitor pm= pmdialog.getProgressMonitor(); IFile[] states= null; try {
@Override public void run(final boolean fork, final boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { final InvocationTargetException[] invokes = new InvocationTargetException[1]; final InterruptedException[] interrupt = new InterruptedException[1]; Runnable dialogWaitRunnable = () -> { try { TimeTriggeredProgressMonitorDialog.super.run(fork, cancelable, runnable); } catch (InvocationTargetException e1) { invokes[0] = e1; } catch (InterruptedException e2) { interrupt[0]= e2; } }; final Display display = PlatformUI.getWorkbench().getDisplay(); if (display == null) { return; } //show a busy cursor until the dialog opens BusyIndicator.showWhile(display, dialogWaitRunnable); if (invokes[0] != null) { throw invokes[0]; } if (interrupt[0] != null) { throw interrupt[0]; } } }
/** * This implementation of IRunnableContext#run(boolean, boolean, * IRunnableWithProgress) runs the given <code>IRunnableWithProgress</code> * using the progress monitor for this progress dialog and blocks until the * runnable has been run, regardless of the value of <code>fork</code>. * The dialog is opened before the runnable is run, and closed after it * completes. It is recommended that <code>fork</code> is set to true in * most cases. If <code>fork</code> is set to <code>false</code>, the * runnable will run in the UI thread and it is the runnable's * responsibility to call <code>Display.readAndDispatch()</code> to ensure * UI responsiveness. */ @Override public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { setCancelable(cancelable); try { aboutToRun(); // Let the progress monitor know if they need to update in UI Thread progressMonitor.forked = fork; ModalContext.run(runnable, fork, getProgressMonitor(), getShell() .getDisplay()); } finally { finishedRun(); } }
public void run() { IProgressMonitor monitor = pmd.getProgressMonitor(); while ( pmd.getShell() == null || ( !pmd.getShell().isDisposed() && !monitor.isCanceled() ) ) { try { Thread.sleep( 100 ); } catch ( InterruptedException e ) { // Ignore } } if ( monitor.isCanceled() ) { // Disconnect and see what happens! try { db.cancelQuery(); } catch ( Exception e ) { // Ignore } } } };
/** * Called just before the operation is run. Default behaviour is to open or * create the dialog, based on the setting of <code>getOpenOnRun</code>, * and increment the nesting depth. * * @since 3.0 */ protected void aboutToRun() { if (getOpenOnRun()) { open(); } else { create(); } incrementNestingDepth(); }