List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog getShell
@Override
public Shell getShell()
From source file:org.pentaho.di.ui.core.database.dialog.GetPreviewTableProgressDialog.java
License:Apache License
public List<Object[]> open() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { db = new Database(Spoon.loggingObject, dbMeta); try { db.connect();//from w ww. ja v a 2 s. com if (limit > 0) { db.setQueryLimit(limit); } rows = db.getFirstRows(tableName, limit, new ProgressMonitorAdapter(monitor)); rowMeta = db.getReturnRowMeta(); } catch (KettleException e) { throw new InvocationTargetException(e, "Couldn't find any rows because of an error :" + e.toString()); } finally { db.disconnect(); } } }; try { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { 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 } } } }; // Start the cancel tracker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { showErrorDialog(e); return null; } catch (InterruptedException e) { showErrorDialog(e); return null; } return rows; }
From source file:org.pentaho.di.ui.core.database.dialog.GetQueryFieldsProgressDialog.java
License:Apache License
public RowMetaInterface open() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { db = new Database(Spoon.loggingObject, dbMeta); try { db.connect();/*from w w w. j ava 2 s . c o m*/ result = db.getQueryFields(sql, false); if (monitor.isCanceled()) { throw new InvocationTargetException(new Exception("This operation was cancelled!")); } } catch (Exception e) { throw new InvocationTargetException(e, "Problem encountered determining query fields: " + e.toString()); } finally { db.disconnect(); } } }; try { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { public void run() { IProgressMonitor monitor = pmd.getProgressMonitor(); while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) { try { Thread.sleep(250); } catch (InterruptedException e) { // Ignore } } if (monitor.isCanceled()) { // Disconnect and see what happens! try { db.cancelQuery(); } catch (Exception e) { // Ignore } } } }; // Dump the cancel looker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { showErrorDialog(e); return null; } catch (InterruptedException e) { showErrorDialog(e); return null; } return result; }
From source file:org.pentaho.di.ui.core.database.dialog.GetTableSizeProgressDialog.java
License:Apache License
public Long open() { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { db = new Database(Spoon.loggingObject, dbMeta); try { db.connect();// ww w .j a v a 2s . c o m String sql = dbMeta.getDatabaseInterface().getSelectCountStatement(tableName); RowMetaAndData row = db.getOneRow(sql); size = row.getRowMeta().getInteger(row.getData(), 0); if (monitor.isCanceled()) { throw new InvocationTargetException(new Exception("This operation was cancelled!")); } } catch (KettleException e) { throw new InvocationTargetException(e, "Couldn't get a result because of an error :" + e.toString()); } finally { db.disconnect(); } } }; try { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { 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 } } } }; // Start the cancel tracker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { showErrorDialog(e); return null; } catch (InterruptedException e) { showErrorDialog(e); return null; } return size; }
From source file:org.pentaho.di.ui.spoon.dialog.CheckTransProgressDialog.java
License:Apache License
public void open() { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { transMeta.checkSteps(remarks, onlySelected, new ProgressMonitorAdapter(monitor), space, repository, metaStore); } catch (Exception e) { throw new InvocationTargetException(e, BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.RuntimeError.ErrorCheckingTransformation.Exception", e.toString()));/*from w w w . j ava2 s.c o m*/ } } }; try { // Run something in the background to cancel active database queries, force this if needed! Runnable run = new Runnable() { public void run() { IProgressMonitor monitor = pmd.getProgressMonitor(); while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) { try { Thread.sleep(250); } catch (InterruptedException e) { // Ignore sleep interruption exception } } if (monitor.isCanceled()) { // Disconnect and see what happens! try { transMeta.cancelQueries(); } catch (Exception e) { // Ignore cancel errors } } } }; // Dump the cancel looker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Title"), BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Message"), e); } catch (InterruptedException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Title"), BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Message"), e); } }
From source file:org.pentaho.di.ui.spoon.trans.TransGraph.java
License:Apache License
/** * Display the input- or outputfields for a step. * * @param stepMeta The step (it's metadata) to query * @param before set to true if you want to have the fields going INTO the step, false if you want to see all the * fields that exit the step. *///from w ww. j ava 2s . co m private void inputOutputFields(StepMeta stepMeta, boolean before) { spoon.refreshGraph(); transMeta.setRepository(spoon.rep); SearchFieldsProgressDialog op = new SearchFieldsProgressDialog(transMeta, stepMeta, before); boolean alreadyThrownError = false; try { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { @Override public void run() { IProgressMonitor monitor = pmd.getProgressMonitor(); while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) { try { Thread.sleep(250); } catch (InterruptedException e) { // Ignore } } if (monitor.isCanceled()) { // Disconnect and see what happens! try { transMeta.cancelQueries(); } catch (Exception e) { // Ignore } } } }; // Dump the cancel looker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Title"), BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Message"), e); alreadyThrownError = true; } catch (InterruptedException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Title"), BaseMessages.getString(PKG, "TransGraph.Dialog.GettingFields.Message"), e); alreadyThrownError = true; } RowMetaInterface fields = op.getFields(); if (fields != null && fields.size() > 0) { StepFieldsDialog sfd = new StepFieldsDialog(shell, transMeta, SWT.NONE, stepMeta.getName(), fields); String sn = (String) sfd.open(); if (sn != null) { StepMeta esi = transMeta.findStep(sn); if (esi != null) { editStep(esi); } } } else { if (!alreadyThrownError) { modalMessageDialog(getString("TransGraph.Dialog.CouldntFindFields.Title"), getString("TransGraph.Dialog.CouldntFindFields.Message"), SWT.OK | SWT.ICON_INFORMATION); } } }
From source file:org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog.java
License:Apache License
/** * Opens the progress dialog/*from w w w . j av a2 s. c o m*/ * @param showErrorDialogs dictates whether error dialogs should be shown when errors occur - can be set to false * to let the caller control error dialogs instead. * @return a {@link TransMeta} */ public TransMeta open(final boolean showErrorDialogs) { IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { doPreview(monitor, showErrorDialogs); } }; try { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); // Run something in the background to cancel active database queries, forecably if needed! Runnable run = new Runnable() { 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 */ } } } }; // Start the cancel tracker in the background! new Thread(run).start(); pmd.run(true, true, op); } catch (InvocationTargetException e) { if (showErrorDialogs) { new ErrorDialog(shell, BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"), e); } transMeta = null; } catch (InterruptedException e) { if (showErrorDialogs) { new ErrorDialog(shell, BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"), e); } transMeta = null; } return transMeta; }
From source file:org.xmind.ui.internal.sharing.SharingUtils.java
License:Open Source License
public static void run(final IRunnableWithProgress runnable, Display display) { final Throwable[] exception = new Throwable[] { null }; if (display != null && !display.isDisposed()) { display.syncExec(new Runnable() { public void run() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); dialog.setOpenOnRun(false); final boolean[] completed = new boolean[] { false }; Display.getCurrent().timerExec(240, new Runnable() { public void run() { if (!completed[0]) dialog.open(); }/*www . jav a2 s.c o m*/ }); try { dialog.run(true, false, runnable); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } finally { completed[0] = true; dialog.close(); Shell shell = dialog.getShell(); if (shell != null) { shell.dispose(); } } } }); } else { try { runnable.run(new NullProgressMonitor()); } catch (InterruptedException e) { // ignore } catch (InvocationTargetException e) { exception[0] = e.getCause(); } catch (Throwable e) { exception[0] = e; } } if (exception[0] != null) { LocalNetworkSharingUI.log("Failed to disconnect from local network sharing service:", //$NON-NLS-1$ exception[0]); } }