public ShowKonsolidatorAction(IWorkbenchWindow window, String label) {
   this.window = window;
   setText(label);
   setId(ID);
   // setActionDefinitionId(ID);
   setImageDescriptor(ImageCache.getInstance().getImageDescriptor(ImageCache.KONSOLIDATOR));
   window.getSelectionService().addSelectionListener(this);
   setToolTipText(Messages.ShowKonsolidatorAction_1);
   setRightID(ActionRightIDs.KONSOLIDATOR);
   if (Activator.getDefault().isStandalone()
       && !Activator.getDefault().getInternalServer().isRunning()) {
     IInternalServerStartListener listener =
         new IInternalServerStartListener() {
           @Override
           public void statusChanged(InternalServerEvent e) {
             if (e.isStarted()) {
               setEnabled(checkRights());
             }
           }
         };
     Activator.getDefault().getInternalServer().addInternalServerStatusListener(listener);
   } else {
     setEnabled(checkRights());
   }
 }
Ejemplo n.º 2
0
 private void syncEnabledStandalone() {
   DisableSearchActionListener listener = new DisableSearchActionListener(this);
   Activator.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
   this.addPropertyChangeListener(listener);
   this.setEnabled(
       !Activator.getDefault()
           .getPreferenceStore()
           .getBoolean(PreferenceConstants.SEARCH_DISABLE));
 }
Ejemplo n.º 3
0
 @Override
 public void createPartControl(Composite parent) {
   this.parent = parent;
   huiComposite = new HitroUIComposite(parent, false);
   try {
     // no validation here, so empty list passed
     huiComposite.createView(
         attachment.getEntity(),
         true,
         true,
         new String[] {},
         false,
         new ArrayList<String>(0),
         Activator.getDefault()
             .getPreferenceStore()
             .getBoolean(PreferenceConstants.USE_VALIDATION_GUI_HINTS));
   } catch (DBException e) {
     LOG.error("Error while creating editor", e); // $NON-NLS-1$
   }
   InputHelperFactory.setInputHelpers(
       HitroUtil.getInstance()
           .getTypeFactory()
           .getEntityType(attachment.getEntity().getEntityType()),
       huiComposite);
 }
Ejemplo n.º 4
0
 private void syncEnabledWithPreference() {
   if (Activator.getDefault().isStandalone()) {
     syncEnabledStandalone();
   } else {
     syncEnabledServer();
   }
 }
  @Override
  protected void okPressed() {
    if (textFile.getText().length() == 0 || scopeCombo.getSelectionIndex() < 0) {
      MessageDialog.openWarning(
          getShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_6);
      return;
    }
    List<Integer> rootElements = new ArrayList<Integer>(0);
    rootElements.add(getRootElement());
    if (getRootElements() != null) rootElements.addAll(Arrays.asList(getRootElements()));
    IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
    boolean dontShow =
        preferenceStore.getBoolean(PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING);
    IValidationService vService = ServiceFactory.lookupValidationService();
    boolean validationsExistant = false;
    for (Integer scopeId : rootElements) {
      if (vService.getValidations(scopeId, (Integer) null).size() > 0) {
        validationsExistant = true;
        break;
      }
    }

    if (!dontShow && validationsExistant) {
      MessageDialogWithToggle dialog =
          MessageDialogWithToggle.openYesNoQuestion(
              getParentShell(),
              Messages.GenerateReportDialog_5,
              Messages.GenerateReportDialog_21,
              Messages.GenerateReportDialog_23,
              dontShow,
              preferenceStore,
              PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING);
      preferenceStore.setValue(
          PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING, dialog.getToggleState());

      if (!(dialog.getReturnCode() == IDialogConstants.OK_ID
          || dialog.getReturnCode() == IDialogConstants.YES_ID)) {
        return;
      }
    }

    String f = textFile.getText();
    chosenReportType = reportTypes[comboReportType.getSelectionIndex()];
    chosenOutputFormat = chosenReportType.getOutputFormats()[comboOutputFormat.getSelectionIndex()];

    chosenReportType.setReportFile(textReportTemplateFile.getText());

    // This just appends the chosen report's extension if the existing
    // suffix does not match. Could be enhanced.
    if (!f.endsWith(chosenOutputFormat.getFileSuffix())) {
      f += "." + chosenOutputFormat.getFileSuffix(); // $NON-NLS-1$
    }

    outputFile = new File(f);
    resetScopeCombo();
    super.okPressed();
  }
Ejemplo n.º 6
0
  @Override
  public IStatus runInWorkspace(IProgressMonitor mon) throws CoreException {

    final long startTime = System.currentTimeMillis();

    try {

      Display.getDefault()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  searchView.disableSearch();
                }
              });

      Activator.inheritVeriniceContextState();

      final VeriniceSearchResult result = ServiceFactory.lookupSearchService().query(query);
      result.setVeriniceQuery(query);

      Display.getDefault()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  searchView.updateResultCombobox(result);
                  if (LOG.isDebugEnabled()) {
                    LOG.debug(
                        "executing search for "
                            + query.getQuery()
                            + " lasts:\t"
                            + String.valueOf(((System.currentTimeMillis() - startTime) / 1000))
                            + " seconds");
                  }
                }
              });

    } finally {
      Display.getDefault()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  searchView.enableSearch();
                }
              });
    }

    return Status.OK_STATUS;
  }
Ejemplo n.º 7
0
 @Override
 public void propertyChange(PropertyChangeEvent event) {
   boolean disabled =
       Activator.getDefault()
           .getPreferenceStore()
           .getBoolean(PreferenceConstants.SEARCH_DISABLE);
   if (PreferenceConstants.SEARCH_DISABLE.equals(event.getProperty())) {
     if (checkRights() && disabled) {
       action.setEnabled(false);
     } else if (checkRights() && !disabled) {
       action.setEnabled(true);
     }
   }
 }
 public ImportPersonFromLdap(IWorkbenchWindow window, String label) {
   this.window = window;
   setText(label);
   setId(ID);
   setImageDescriptor(ImageCache.getInstance().getImageDescriptor(ImageCache.PERSON));
   setToolTipText(Messages.getString("ImportPersonFromLdap.1")); // $NON-NLS-1$
   setRightID(ActionRightIDs.IMPORTLDAP);
   if (Activator.getDefault().isStandalone()
       && !Activator.getDefault().getInternalServer().isRunning()) {
     IInternalServerStartListener listener =
         new IInternalServerStartListener() {
           @Override
           public void statusChanged(InternalServerEvent e) {
             if (e.isStarted()) {
               setEnabled(checkRights());
             }
           }
         };
     Activator.getDefault().getInternalServer().addInternalServerStatusListener(listener);
   } else {
     setEnabled(checkRights());
   }
 }
Ejemplo n.º 9
0
 private String initDefaultFolder() {
   IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
   defaultFolder = prefs.getString(PreferenceConstants.DEFAULT_FOLDER_REPORT);
   defaultTemplateFolder = prefs.getString(PreferenceConstants.DEFAULT_TEMPLATE_FOLDER_REPORT);
   if (defaultFolder == null || defaultFolder.isEmpty()) {
     defaultFolder = System.getProperty("user.home");
   }
   if (defaultTemplateFolder == null || defaultTemplateFolder.isEmpty()) {
     defaultTemplateFolder = System.getProperty("user.home");
   }
   if (!defaultFolder.endsWith(System.getProperty(FILE_SEPARATOR))) {
     defaultFolder = defaultFolder + System.getProperty(FILE_SEPARATOR);
   }
   if (!defaultTemplateFolder.endsWith(System.getProperty(FILE_SEPARATOR))) {
     defaultTemplateFolder = defaultTemplateFolder + System.getProperty(FILE_SEPARATOR);
   }
   return defaultFolder;
 }
Ejemplo n.º 10
0
 @Override
 public void doSave(IProgressMonitor monitor) {
   monitor.beginTask(Messages.AttachmentEditor_1, IProgressMonitor.UNKNOWN);
   boolean isNew = attachment.getDbId() == null;
   Set<INoteChangedListener> listener = attachment.getListener();
   SaveNote command = new SaveNote(attachment);
   try {
     command = getCommandService().executeCommand(command);
     attachment = (Attachment) command.getAddition();
     huiComposite.dispose();
     huiComposite = new HitroUIComposite(parent, false);
     huiComposite.createView(
         attachment.getEntity(),
         true,
         true,
         new String[] {},
         false,
         ServiceFactory.lookupValidationService()
             .getPropertyTypesToValidate(attachment.getEntity(), attachment.getDbId()),
         Activator.getDefault()
             .getPreferenceStore()
             .getBoolean(PreferenceConstants.USE_VALIDATION_GUI_HINTS));
     parent.layout();
     // file-data is immutable, just save new file-data
     if (isNew) {
       AttachmentFileCreationFactory.createAttachmentFile(
           attachment, FileUtils.readFileToByteArray(new File(attachment.getFilePath())));
     }
   } catch (Exception e) {
     LOG.error("Error while saving file", e); // $NON-NLS-1$
     ExceptionUtil.log(e, Messages.AttachmentEditor_3);
   }
   monitor.done();
   attachment.getListener().addAll(listener);
   isModelModified = false;
   firePropertyChange(IEditorPart.PROP_DIRTY);
   attachment.getEntity().addChangeListener(this.modelListener);
   setPartName(attachment.getTitel());
   attachment.fireChange();
 }
  public void run(IAction action) {

    try {

      Object sel =
          ((IStructuredSelection) targetPart.getSite().getSelectionProvider().getSelection())
              .getFirstElement();
      if (sel instanceof CnATreeElement) {
        boolean inheritIcon =
            Activator.getDefault()
                .getPreferenceStore()
                .getBoolean(PreferenceConstants.INHERIT_SPECIAL_GROUP_ICON);
        CnATreeElement parent = (CnATreeElement) sel;
        CnATreeElement newBaustein =
            CnAElementFactory.getInstance()
                .saveNew(parent, BausteinUmsetzung.TYPE_ID, null, inheritIcon);

        EditorFactory.getInstance().openEditor(newBaustein);
      }

    } catch (Exception e) {
      ExceptionUtil.log(e, Messages.AddBausteinActionDelegate_0);
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.action.Action#run()
   */
  @Override
  public void run() {
    Activator.inheritVeriniceContextState();

    IStructuredSelection selection =
        (IStructuredSelection) window.getSelectionService().getSelection(BsiModelView.ID);
    if (selection == null) {
      return;
    }
    final List<BausteinUmsetzung> selectedElements = new ArrayList<BausteinUmsetzung>();
    EntityType entType = null;
    for (Iterator iter = selection.iterator(); iter.hasNext(); ) {
      Object o = iter.next();
      if (o instanceof BausteinUmsetzung) {
        BausteinUmsetzung baustein = (BausteinUmsetzung) o;
        initParent(baustein);
        selectedElements.add(baustein);
      }
    }

    final KonsolidatorDialog dialog = new KonsolidatorDialog(window.getShell(), selectedElements);
    if (dialog.open() != Window.OK || dialog.getSource() == null) {
      return;
    }

    if (!KonsolidatorDialog.askConsolidate(window.getShell())) {
      return;
    }

    try {
      // close editors first:
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(true);

      PlatformUI.getWorkbench()
          .getProgressService()
          .busyCursorWhile(
              new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  Activator.inheritVeriniceContextState();
                  monitor.setTaskName(Messages.ShowKonsolidatorAction_2);
                  monitor.beginTask(Messages.ShowKonsolidatorAction_3, selectedElements.size() + 1);

                  BausteinUmsetzung source = dialog.getSource();

                  try {
                    // change targets on server:
                    KonsolidatorCommand command = new KonsolidatorCommand(selectedElements, source);
                    command = ServiceFactory.lookupCommandService().executeCommand(command);

                    // reload state from server:
                    for (CnATreeElement element : command.getChangedElements()) {
                      CnAElementFactory.getLoadedModel().databaseChildChanged(element);
                    }

                  } catch (CommandException e) {
                    ExceptionUtil.log(e, Messages.ShowKonsolidatorAction_4);
                  }

                  monitor.done();
                }
              });
    } catch (InterruptedException e) {
      ExceptionUtil.log(e, Messages.ShowKonsolidatorAction_5);
    } catch (Exception e) {
      ExceptionUtil.log(e, Messages.ShowKonsolidatorAction_6);
    }
  }
Ejemplo n.º 13
0
  @Override
  protected void okPressed() {
    try {
      if (textFile.getText().length() == 0 || scopeCombo.getSelectionIndex() < 0) {
        MessageDialog.openWarning(
            getShell(), Messages.GenerateReportDialog_5, Messages.GenerateReportDialog_6);
        return;
      }
      List<Integer> scopeIds = new ArrayList<Integer>(0);
      if (getRootElement() != null) {
        scopeIds.add(getRootElement());
      }
      if (getRootElements() != null) {
        for (Integer scopeId : getRootElements()) {
          if (scopeId != null) {
            scopeIds.add(scopeId);
          }
        }
      }
      IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
      boolean dontShow =
          preferenceStore.getBoolean(PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING);
      IValidationService vService = ServiceFactory.lookupValidationService();
      boolean validationsExistant = false;
      for (Integer scopeId : scopeIds) {
        if (vService.getValidations(scopeId, (Integer) null).size() > 0) {
          validationsExistant = true;
          break;
        }
      }

      if (!dontShow && validationsExistant) {
        MessageDialogWithToggle dialog =
            MessageDialogWithToggle.openYesNoQuestion(
                getParentShell(),
                Messages.GenerateReportDialog_5,
                Messages.GenerateReportDialog_21,
                Messages.GenerateReportDialog_23,
                dontShow,
                preferenceStore,
                PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING);
        preferenceStore.setValue(
            PreferenceConstants.SHOW_REPORT_VALIDATION_WARNING, dialog.getToggleState());

        if (!(dialog.getReturnCode() == IDialogConstants.OK_ID
            || dialog.getReturnCode() == IDialogConstants.YES_ID)) {
          return;
        }
      }

      String f = textFile.getText();
      if (reportTemplates.length > 0) {
        chosenReportMetaData = reportTemplates[comboReportType.getSelectionIndex()];
      } else {
        showNoReportsExistant();
        return;
      }
      chosenOutputFormat =
          getDepositService()
              .getOutputFormat(
                  chosenReportMetaData.getOutputFormats()[comboOutputFormat.getSelectionIndex()]);

      // This just appends the chosen report's extension if the existing
      // suffix does not match. Could be enhanced.
      if (!f.endsWith(chosenOutputFormat.getFileSuffix())) {
        f += "." + chosenOutputFormat.getFileSuffix(); // $NON-NLS-1$
      }

      String currentPath = setupDirPath();
      if (useDefaultFolder) {
        Activator.getDefault()
            .getPreferenceStore()
            .setValue(PreferenceConstants.DEFAULT_FOLDER_REPORT, currentPath);
      }
      currentPath = getOldTemplateFolderPath();
      outputFile = new File(f);
    } catch (Exception e) {
      LOG.error("Error while creating report.", e);
      MessageDialog.openError(getShell(), "Error", "An error occurred while creating report.");
      return;
    }
    super.okPressed();
  }
Ejemplo n.º 14
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);

    String importDb =
        Activator.getDefault().getPluginPreferences().getString(PreferenceConstants.GS_DB_URL);

    Label intro = new Label(container, SWT.NONE);
    intro.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
    intro.setText(NLS.bind(Messages.GSImportDialog_13, importDb));
    Link prefLink = new Link(container, SWT.NONE);
    prefLink.setText(Messages.GSImportDialog_1);
    prefLink.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            setReturnCode(CANCEL);
            close();
            ShowPreferencesAction action = new ShowPreferencesAction(GSImportPreferencePage.ID);
            action.run();
          }
        });

    Label intro2 = new Label(container, SWT.NONE);
    intro2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
    intro2.setText(Messages.GSImportDialog_2);

    final Button button4 = new Button(parent, SWT.CHECK);
    button4.setText(Messages.GSImportDialog_3);
    button4.setEnabled(false);
    button4.setSelection(true);
    button4.pack();

    final Button button5 = new Button(parent, SWT.CHECK);
    button5.setSelection(true);
    button5.setText(Messages.GSImportDialog_4);
    button5.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            bausteine = button5.getSelection();
          }
        });
    button5.pack();

    final Button button6 = new Button(parent, SWT.CHECK);
    button6.setSelection(true);
    button6.setText(Messages.GSImportDialog_5);
    button6.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            rollen = button6.getSelection();
          }
        });
    button6.pack();

    final Button button9 = new Button(parent, SWT.CHECK);
    button9.setSelection(true);
    button9.setText(Messages.GSImportDialog_6);
    button9.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            bausteinPersonen = button9.getSelection();
          }
        });
    button9.pack();

    final Button button = new Button(parent, SWT.CHECK);
    button.setSelection(true);
    button.setText(Messages.GSImportDialog_7);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            massnahmenPersonen = button.getSelection();
          }
        });
    button.pack();

    final Button button7 = new Button(parent, SWT.CHECK);
    button7.setSelection(true);
    button7.setText(Messages.GSImportDialog_8);
    button7.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            kosten = button7.getSelection();
          }
        });
    button7.pack();

    final Button button10 = new Button(parent, SWT.CHECK);
    button10.setSelection(true);
    button10.setText("Notizen");
    button10.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            notizen = button10.getSelection();
          }
        });
    button10.pack();

    final Button button8 = new Button(parent, SWT.CHECK);
    button8.setSelection(true);
    button8.setText(Messages.GSImportDialog_9);
    button8.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            umsetzung = button8.getSelection();
          }
        });
    button8.pack();

    final Button button2 = new Button(parent, SWT.CHECK);
    button2.setSelection(true);
    button2.setText(Messages.GSImportDialog_10);
    button2.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            zielObjekteZielobjekte = button2.getSelection();
          }
        });
    button2.pack();

    final Button button3 = new Button(parent, SWT.CHECK);
    button3.setSelection(true);
    button3.setText(Messages.GSImportDialog_11);
    button3.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            schutzbedarf = button3.getSelection();
          }
        });
    button3.pack();

    return container;
  }