Пример #1
0
  /**
   * Needs to be implemented because of IExportWizard/IWorkbenchWizard. Entry point.
   *
   * @param workbench the current workbench
   * @param selection the current object selection
   */
  public void init(IWorkbench workbench, IStructuredSelection selection) {
    try {
      if (finishedRiskAnalysis == null) {
        StartNewRiskAnalysis command = new StartNewRiskAnalysis(cnaElement);
        command = ServiceFactory.lookupCommandService().executeCommand(command);
        finishedRiskAnalysis = command.getFinishedRiskAnalysis();
        finishedRiskLists = command.getFinishedRiskLists();
      } else {
        finishedRiskLists =
            FinishedRiskAnalysisListsHome.getInstance().loadById(finishedRiskAnalysis.getDbId());
        previousAnalysis = true;
      }
    } catch (CommandException e) {
      ExceptionUtil.log(e, Messages.RiskAnalysisWizard_1);
    }

    loadAllGefaehrdungen();
    loadAllMassnahmen();
    loadAssociatedGefaehrdungen();

    loadOwnGefaehrdungen();
    addOwnGefaehrdungen();

    addRisikoMassnahmenUmsetzungen(loadRisikomassnahmen());
  }
Пример #2
0
 @Override
 protected void okPressed() {
   SaveLdapUser saveLdapUser = new SaveLdapUser(personSet);
   try {
     saveLdapUser = ServiceFactory.lookupCommandService().executeCommand(saveLdapUser);
   } catch (UsernameExistsException e) {
     log.error(e.getMessage());
     if (log.isDebugEnabled()) {
       log.debug("Stacktrace: ", e); // $NON-NLS-1$
     }
     MessageDialog.openError(
         this.getShell(),
         Messages.LdapImportDialog_45,
         NLS.bind(Messages.LdapImportDialog_46, e.getUsername()));
     return;
   } catch (CommandException e) {
     throw new RuntimeException(e);
   }
   updateModel(saveLdapUser.getImportRootObject(), saveLdapUser.getChangedElements());
   super.okPressed();
   InfoDialogWithShowToggle.openInformation(
       Messages.LdapImportDialog_42,
       NLS.bind(Messages.LdapImportDialog_43, saveLdapUser.getChangedElements().size()),
       Messages.LdapImportDialog_44,
       PreferenceConstants.INFO_IMPORT_LDAP);
 }
Пример #3
0
 private void loadLdapUser() {
   try {
     LoadLdapUser loadLdapUser = new LoadLdapUser(getParameter());
     loadLdapUser = ServiceFactory.lookupCommandService().executeCommand(loadLdapUser);
     personSet.clear();
     List<PersonInfo> personList = loadLdapUser.getPersonList();
     if (personList != null) {
       List<PersonInfo> accountList = new ArrayList<PersonInfo>(personList);
       personSet.addAll(accountList);
     }
     // Get the content for the viewer, setInput will call getElements in the
     // contentProvider
     refreshTable();
   } catch (SizeLimitExceededException sizeLimitExceededException) {
     log.warn("To many results ehen searching for LDAP users."); // $NON-NLS-1$
     if (log.isDebugEnabled()) {
       log.debug("stacktrace: ", sizeLimitExceededException); // $NON-NLS-1$
     }
     personSet.clear();
     refreshTable();
     MessageDialog.openInformation(
         getShell(), Messages.LdapImportDialog_6, Messages.LdapImportDialog_7);
   } catch (Throwable t) {
     log.error("Error while setting table data", t); // $NON-NLS-1$
     personSet.clear();
     refreshTable();
     MessageDialog.openError(
         getShell(), Messages.LdapImportDialog_45, Messages.LdapImportDialog_1);
   }
 }
Пример #4
0
 public void removeAssociatedGefaehrdung(Gefaehrdung currentGefaehrdung) throws Exception {
   /* remove from List of Associated Gefaehrdungen */
   DisassociateGefaehrdungsUmsetzung command =
       new DisassociateGefaehrdungsUmsetzung(
           finishedRiskAnalysis, finishedRiskLists.getDbId(), currentGefaehrdung);
   command = ServiceFactory.lookupCommandService().executeCommand(command);
   finishedRiskLists = command.getFinishedRiskLists();
   finishedRiskAnalysis = command.getFinishedRiskAnalysis();
 }
  @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();
  }
 /** @return */
 private List<ITVerbund> loadITVerbuende() {
   LoadCnATreeElementTitles<ITVerbund> compoundLoader =
       new LoadCnATreeElementTitles<ITVerbund>(ITVerbund.class);
   try {
     compoundLoader = ServiceFactory.lookupCommandService().executeCommand(compoundLoader);
   } catch (Exception e) {
     ExceptionUtil.log(e, Messages.GenerateReportDialog_20);
   }
   return compoundLoader.getElements();
 }
  private List<Organization> loadScopes() {
    LoadCnATreeElementTitles<Organization> compoundLoader =
        new LoadCnATreeElementTitles<Organization>(Organization.class);
    try {
      compoundLoader = ServiceFactory.lookupCommandService().executeCommand(compoundLoader);
    } catch (Exception e) {
      ExceptionUtil.log(e, Messages.GenerateReportDialog_19);
    }

    return compoundLoader.getElements();
  }
Пример #8
0
  public RiskAnalysisWizard(CnATreeElement parent, FinishedRiskAnalysis analysis) {
    this(parent);

    try {
      LoadChildrenForExpansion command = new LoadChildrenForExpansion(analysis);
      command = ServiceFactory.lookupCommandService().executeCommand(command);
      finishedRiskAnalysis = (FinishedRiskAnalysis) command.getElementWithChildren();
    } catch (CommandException e) {
      ExceptionUtil.log(e, Messages.RiskAnalysisWizard_0);
    }
  }
Пример #9
0
 /**
  * Saves all Gefaehrdungen associated to the chosen IT-system in a List.
  *
  * @throws CommandException
  */
 private void loadAssociatedGefaehrdungen() {
   try {
     LoadAssociatedGefaehrdungen command = new LoadAssociatedGefaehrdungen(cnaElement);
     command = ServiceFactory.lookupCommandService().executeCommand(command);
     this.finishedRiskLists
         .getAssociatedGefaehrdungen()
         .addAll(command.getAssociatedGefaehrdungen());
   } catch (CommandException e) {
     ExceptionUtil.log(e, Messages.RiskAnalysisWizard_5);
   }
 }
Пример #10
0
 private void deleteAttachments() {
   Iterator iterator = ((IStructuredSelection) viewer.getSelection()).iterator();
   while (iterator.hasNext()) {
     ReportTemplateMetaData sel = (ReportTemplateMetaData) iterator.next();
     try {
       ServiceFactory.lookupReportDepositService().remove(sel, Locale.getDefault().getLanguage());
     } catch (ReportDepositException e) {
       ExceptionUtil.log(e, "Error deleting Reporttemplate:\t" + sel.getOutputname());
     }
   }
 }
Пример #11
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;
  }
Пример #12
0
 private String loadLogin(CnATreeElement element) {
   String login = null;
   try {
     LoadConfiguration command = new LoadConfiguration(element);
     command = ServiceFactory.lookupCommandService().executeCommand(command);
     Configuration configuration = command.getConfiguration();
     if (configuration != null) {
       login = configuration.getUser();
     }
   } catch (CommandException e) {
     LOG.error("Error while loading account data.", e); // $NON-NLS-1$
   }
   return login;
 }
Пример #13
0
 private void syncEnabledServer() {
   try {
     int searchServiceImplementation =
         ServiceFactory.lookupSearchService().getImplementationtype();
     if (ISearchService.ES_IMPLEMENTATION_TYPE_DUMMY == searchServiceImplementation) {
       this.setEnabled(false);
     } else if (checkRights()
         && ISearchService.ES_IMPLEMENTATION_TYPE_REAL == searchServiceImplementation) {
       this.setEnabled(true);
     }
   } catch (Exception e) {
     Logger.getLogger(OpenSearchViewAction.class)
         .error("Can't connect to searchService, disabling searchView", e);
     this.setEnabled(false);
   }
 }
  /** Marks all checkboxes of Gefaehrdungen associated to the selected Baustein. */
  private void assignBausteinGefaehrdungen() {
    try {
      LoadAssociatedGefaehrdungen command = new LoadAssociatedGefaehrdungen(wizard.getCnaElement());
      command = ServiceFactory.lookupCommandService().executeCommand(command);
      List<GefaehrdungsUmsetzung> list = command.getAssociatedGefaehrdungen();

      for (GefaehrdungsUmsetzung selectedGefaehrdung : list) {
        for (Gefaehrdung gefaehrdung : wizard.getAllGefaehrdungen()) {
          if (gefaehrdung.getId().equals(selectedGefaehrdung.getId())) {
            associateGefaehrdung(gefaehrdung, true);
          }
        }
      }
    } catch (CommandException e) {
      ExceptionUtil.log(e, ""); // $NON-NLS-1$
    }
  }
Пример #15
0
  public void addAssociatedGefaehrdung(Gefaehrdung currentGefaehrdung) {

    try {
      if (!GefaehrdungsUtil.listContainsById(
          finishedRiskLists.getAssociatedGefaehrdungen(), currentGefaehrdung)) {
        /* Add to List of Associated Gefaehrdungen */
        AssociateGefaehrdungsUmsetzung command =
            new AssociateGefaehrdungsUmsetzung(
                finishedRiskLists.getDbId(),
                currentGefaehrdung,
                this.finishedRiskAnalysis.getDbId());
        command = ServiceFactory.lookupCommandService().executeCommand(command);

        finishedRiskLists = command.getFinishedRiskLists();
      }
    } catch (CommandException e) {
      ExceptionUtil.log(e, ""); // $NON-NLS-1$
    }
  }
Пример #16
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();
 }
Пример #17
0
 private IReportDepositService getReportService() {
   return ServiceFactory.lookupReportDepositService();
 }
Пример #18
0
 private ICommandService createCommandServive() {
   return ServiceFactory.lookupCommandService();
 }
Пример #19
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();
  }