/** {@inheritDoc} */
 public Object executeImpl(ExecutionEvent event) {
   DirectoryDialog directoryDialog = createDirectoryDialog();
   genPath = directoryDialog.open();
   if (genPath != null) {
     org.eclipse.jubula.client.ui.rcp.utils.Utils.storeLastDirPath(
         directoryDialog.getFilterPath());
     File directory = new File(genPath);
     if (directory.list().length == 0) {
       InputDialog inputDialog =
           new InputDialog(
               getActiveShell(),
               Messages.InputDialogName,
               Messages.InputDialogMessage,
               StringConstants.EMPTY,
               new PackageNameValidator());
       if (inputDialog.open() == Window.OK) {
         genPackage = inputDialog.getValue();
         IWorkbench workbench = PlatformUI.getWorkbench();
         try {
           workbench.getProgressService().run(true, true, new ConvertProjectOperation());
         } catch (InvocationTargetException | InterruptedException e) {
           LOG.error(Messages.ErrorWhileConverting, e);
         }
       }
     } else {
       ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NON_EMPTY_DIRECTORY);
     }
   }
   return null;
 }
예제 #2
0
 /**
  * Runs task in Eclipse progress dialog. NOTE: this call can't be canceled if it will block in IO
  */
 public static void runInProgressDialog(final DBRRunnableWithProgress runnable)
     throws InvocationTargetException {
   try {
     IRunnableContext runnableContext;
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
     if (workbenchWindow != null) {
       runnableContext =
           new ProgressMonitorDialog(workbench.getActiveWorkbenchWindow().getShell());
     } else {
       runnableContext = workbench.getProgressService();
     }
     runnableContext.run(
         true,
         true,
         new IRunnableWithProgress() {
           @Override
           public void run(IProgressMonitor monitor)
               throws InvocationTargetException, InterruptedException {
             runnable.run(RuntimeUtils.makeMonitor(monitor));
           }
         });
   } catch (InterruptedException e) {
     // do nothing
   }
 }
예제 #3
0
 /**
  * The action has been activated. The argument of the method represents the 'real' action sitting
  * in the workbench UI.
  *
  * @see IWorkbenchWindowActionDelegate#run
  */
 public void run(IAction action) {
   final SettingsDialog sd = new SettingsDialog(window.getShell());
   if (sd.open() == Dialog.OK) {
     if (SWTHelper.askYesNo(
         "Wirklich Datenbank anonymisieren",
         "Achtung! Diese Aktion macht die Datenbank unwiderruflich unbrauchbar! Wirklich anonymisieren?")) {
       zufallsnamen = sd.replaceNames;
       IWorkbench wb = PlatformUI.getWorkbench();
       IProgressService ps = wb.getProgressService();
       try {
         ps.busyCursorWhile(
             new IRunnableWithProgress() {
               public void run(IProgressMonitor pm) {
                 pm.beginTask("Anonymisiere Datenbank", TOTAL);
                 int jobs = 1;
                 if (sd.replaceKons) {
                   jobs++;
                 }
                 if (sd.deleteDocs) {
                   jobs++;
                 }
                 if (sd.purgeDB) {
                   jobs++;
                 }
                 doShakeNames(pm, TOTAL / jobs);
                 if (sd.replaceKons) {
                   doShakeKons(pm, TOTAL / jobs);
                 }
                 if (sd.deleteDocs) {
                   new DocumentRemover().run(pm, TOTAL / jobs);
                 }
                 if (sd.purgeDB) {
                   doPurgeDB(pm, TOTAL / jobs);
                 }
                 pm.done();
               }
             });
       } catch (InvocationTargetException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       } catch (InterruptedException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
 }
예제 #4
0
  @Override
  public boolean performFinish() {
    // save the properties
    ProjectHelper.saveStringProperty(mProject, PROPERTY_KEYSTORE, mKeystore);
    ProjectHelper.saveStringProperty(mProject, PROPERTY_ALIAS, mKeyAlias);
    ProjectHelper.saveStringProperty(
        mProject, PROPERTY_DESTINATION, mDestinationFile.getAbsolutePath());

    // run the export in an UI runnable.
    IWorkbench workbench = PlatformUI.getWorkbench();
    final boolean[] result = new boolean[1];
    try {
      workbench
          .getProgressService()
          .busyCursorWhile(
              new IRunnableWithProgress() {
                /**
                 * Run the export.
                 *
                 * @throws InvocationTargetException
                 * @throws InterruptedException
                 */
                @Override
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  try {
                    result[0] = doExport(monitor);
                  } finally {
                    monitor.done();
                  }
                }
              });
    } catch (InvocationTargetException e) {
      return false;
    } catch (InterruptedException e) {
      return false;
    }

    return result[0];
  }
예제 #5
0
  /*
   * (non-Javadoc)
   *
   * @see org.mwc.debrief.core.interfaces.IPlotLoader#loadFile(org.mwc.cmap.plotViewer.editors.CorePlotEditor,
   *      org.eclipse.ui.IEditorInput)
   */
  public void loadFile(
      final PlotEditor thePlot, final InputStream inputStream, final String fileName) {
    final Layers theLayers = (Layers) thePlot.getAdapter(Layers.class);

    try {

      // hmm, is there anything in the file?
      final int numAvailable = inputStream.available();
      if (numAvailable > 0) {

        final IWorkbench wb = PlatformUI.getWorkbench();
        final IProgressService ps = wb.getProgressService();
        ps.busyCursorWhile(
            new IRunnableWithProgress() {
              public void run(final IProgressMonitor pm) {
                // right, better suspend the LayerManager extended updates from
                // firing
                theLayers.suspendFiringExtended(true);

                try {
                  DebriefPlugin.logError(Status.INFO, "about to start loading:" + fileName, null);

                  // quick check, is this a KMZ
                  if (fileName.endsWith(".tif")) {
                    // create a layer name from the filename
                    File tmpFile = new File(fileName);
                    String layerName = tmpFile.getName();

                    // ok - get loading going
                    final ExternallyManagedDataLayer dl =
                        new ExternallyManagedDataLayer(
                            ChartBoundsWrapper.WORLDIMAGE_TYPE, layerName, fileName);
                    theLayers.addThisLayer(dl);
                  }

                  DebriefPlugin.logError(Status.INFO, "completed loading:" + fileName, null);

                  // and inform the plot editor
                  thePlot.loadingComplete(this);

                  DebriefPlugin.logError(Status.INFO, "parent plot informed", null);

                } catch (final RuntimeException e) {
                  DebriefPlugin.logError(Status.ERROR, "Problem loading datafile:" + fileName, e);
                } finally {
                  // ok, allow the layers object to inform anybody what's
                  // happening
                  // again
                  theLayers.suspendFiringExtended(false);

                  // and trigger an update ourselves
                  // theLayers.fireExtended();
                }
              }
            });
      }

    } catch (final InvocationTargetException e) {
      DebriefPlugin.logError(Status.ERROR, "Problem loading tif:" + fileName, e);
    } catch (final InterruptedException e) {
      DebriefPlugin.logError(Status.ERROR, "Problem loading tif:" + fileName, e);
    } catch (final IOException e) {
      DebriefPlugin.logError(Status.ERROR, "Problem loading tif:" + fileName, e);
    } finally {
    }
    //	}
    // ok, load the data...
    DebriefPlugin.logError(Status.INFO, "Successfully loaded tuf file", null);
  }