示例#1
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();
       }
     }
   }
 }