Package org.rssowl.ui.internal.dialogs

Examples of org.rssowl.ui.internal.dialogs.StartupProgressDialog


  private void startCore() {

    /* Dialog to show progress */
    Display.setAppName("RSSOwl"); //$NON-NLS-1$
    Display.getDefault(); //Create the Display
    final StartupProgressDialog dialog = new StartupProgressDialog();
    dialog.setOpenOnRun(false);

    /* Runnable to start core */
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
      public void run(IProgressMonitor monitor) {
        LongOperationMonitor callbackMonitor = new LongOperationMonitor(monitor) {
          private boolean updateUi = true;

          @Override
          public void beginLongOperation(boolean isCancelable) {
            if (!isLongOperationRunning()) {
              super.beginLongOperation(isCancelable);
              dialog.open();
            }
          }

          @Override
          public void worked(int work) {
            super.worked(work);
            if (updateUi)
              updateUi();
          }

          @Override
          public void subTask(String name) {
            super.subTask(name);
            if (updateUi)
              updateUi();
          }

          private void updateUi() {
            Display display = Display.getDefault();
            try {
              if (!isCanceled() && !display.isDisposed() && dialog.getShell() != null && !dialog.getShell().isDisposed()) {
                display.readAndDispatch();
                display.update();
              }
            }

            /*
             * Ensure to catch any Exception here and disable the update of the
             * UI given that the operation being performed can be a critical one.
             */
            catch (Exception e) {
              updateUi = false;
              logError(e.getMessage(), e);
            }
          }
        };

        /* Start Core */
        try {
          Owl.startup(callbackMonitor);
        }

        /* Handle OOM Error */
        catch (OutOfMemoryError e) {
          Activator.this.fStartupStatus = createErrorStatus(e.getMessage());
          Activator.getDefault().getLog().log(Activator.this.fStartupStatus);
        }

        /* Handle Exception (because any exception here is a show stopper) */
        catch (Exception e) {
          Activator.this.fStartupStatus = createErrorStatus(e.getMessage(), e);
          Activator.getDefault().getLog().log(Activator.this.fStartupStatus);
        }
      }
    };

    /* Execute the Runnable */
    try {
      dialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
      logError(e.getMessage(), e);
    } catch (InterruptedException e) {
      logError(e.getMessage(), e);
    }
View Full Code Here


  private void startCore() {

    /* Dialog to show progress */
    Display.setAppName("RSSOwl"); //$NON-NLS-1$
    Display.getDefault(); //Create the Display
    final StartupProgressDialog dialog = new StartupProgressDialog();
    dialog.setOpenOnRun(false);

    /* Runnable to start core */
    IRunnableWithProgress runnable = new IRunnableWithProgress() {
      public void run(IProgressMonitor monitor) {
        LongOperationMonitor callbackMonitor = new LongOperationMonitor(monitor) {
          private boolean updateUi = true;

          @Override
          public void beginLongOperation(boolean isCancelable) {
            if (!isLongOperationRunning()) {
              super.beginLongOperation(isCancelable);
              dialog.open();
            }
          }

          @Override
          public void worked(int work) {
            super.worked(work);
            if (updateUi)
              updateUi();
          }

          @Override
          public void subTask(String name) {
            super.subTask(name);
            if (updateUi)
              updateUi();
          }

          private void updateUi() {
            Display display = Display.getDefault();
            try {
              if (!isCanceled() && !display.isDisposed() && dialog.getShell() != null && !dialog.getShell().isDisposed()) {
                display.readAndDispatch();
                display.update();
              }
            }

            /*
             * Ensure to catch any Exception here and disable the update of the
             * UI given that the operation being performed can be a critical one.
             */
            catch (Exception e) {
              updateUi = false;
              logError(e.getMessage(), e);
            }
          }
        };

        /* Start Core */
        try {
          Owl.startup(callbackMonitor);
        }

        /* Handle any Throwable */
        catch (Throwable e) {
          Activator.this.fStartupStatus = createErrorStatus(e.getMessage(), e);
          Activator.getDefault().getLog().log(Activator.this.fStartupStatus);
        }
      }
    };

    /* Execute the Runnable */
    try {
      dialog.run(false, true, runnable);
    } catch (InvocationTargetException e) {
      logError(e.getMessage(), e);
    } catch (InterruptedException e) {
      logError(e.getMessage(), e);
    }
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.dialogs.StartupProgressDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.