コード例 #1
0
  @Override
  public boolean print() {
    PrintOperation printOperation = null;
    BarcodeViewGuiData guiData = null;
    try {
      guiData = new BarcodeViewGuiData();

      List<String> patientNumbers =
          SessionManager.getAppService().executeGetSourceSpecimenUniqueInventoryIds(32);

      // print operation
      printOperation = new PrintOperation(guiData, patientNumbers);

      try {
        new ProgressMonitorDialog(shell).run(true, true, printOperation);
      } catch (InvocationTargetException e1) {
        printOperation.saveFailed();
        printOperation.setError(
            Messages.PatientLabelEntryForm_print_error_title,
            "InvocationTargetException: " //$NON-NLS-1$
                + e1.getCause().getMessage());
      }

      if (printOperation.isSuccessful()) {
        updateSavePreferences();
        clearFieldsConfirm();
        return true;
      }

      if (printOperation.errorExists()) {
        BgcPlugin.openAsyncError(printOperation.getError()[0], printOperation.getError()[1]);
        return false;
      }

    } catch (BiobankServerException e) {
      BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_specimenid_error_msg, e.getMessage());
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_server_error_msg, e.getMessage());
    } catch (CBSRGuiVerificationException e1) {
      BgcPlugin.openAsyncError(
          Messages.PatientLabelEntryForm_validation_error_msg, e1.getMessage());
    } catch (InterruptedException e2) {
      // do nothing
    }
    return false;
  }
コード例 #2
0
 @Override
 public boolean isEnabled() {
   if (allowed == null)
     try {
       allowed = SessionManager.getAppService().isAllowed(new UserManagerPermission());
     } catch (ApplicationException e) {
       BgcPlugin.openAsyncError("Unable to Load User Management Data", e.getMessage());
     }
   return allowed;
 }
コード例 #3
0
 @Override
 public void init() {
   try {
     this.isDeletable =
         SessionManager.getAppService().isAllowed(new ResearchGroupDeletePermission(rg.id));
     this.isReadable =
         SessionManager.getAppService().isAllowed(new ResearchGroupReadPermission(rg.id));
     this.isEditable =
         SessionManager.getAppService().isAllowed(new ResearchGroupUpdatePermission(rg.id));
   } catch (ApplicationException e) {
     BgcPlugin.openAsyncError("Permission Error", "Unable to retrieve user permissions");
   }
 }
コード例 #4
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
      BiobankApplicationService service = SessionManager.getAppService();
      ManagerContext context =
          service.doAction(new ManagerContextGetAction(new ManagerContextGetInput())).getContext();

      new UserManagementDialog(
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), context)
          .open();
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError("Unable to Load User Management Data", e.getMessage());
    }

    return null;
  }
コード例 #5
0
  /**
   * Loads the Template from templateCombo.
   *
   * <p>A new template is loaded for each selection change in templateCombo.
   */
  private void loadSelectedTemplate() {
    if (templateCombo.getSelectionIndex() >= 0) {
      try {

        String comboSelectedTemplate = templateCombo.getItem(templateCombo.getSelectionIndex());

        // already loaded
        if ((loadedTemplate == null) || !loadedTemplate.getName().equals(comboSelectedTemplate)) {
          loadedTemplate = templateStore.getTemplate(comboSelectedTemplate);
        }

      } catch (Exception ee) {
        BgcPlugin.openAsyncError(
            Messages.PatientLabelEntryForm_verification_error_title,
            NLS.bind(Messages.PatientLabelEntryForm_verification_error_msg, ee.getMessage()));
      }

      if (loadedTemplate != null) printerText.setText(loadedTemplate.getPrinterName());
    }
  }
コード例 #6
0
  private void updateForm() {
    try {
      if (loggedIn) {
        if (templateStore == null) {
          templateStore = new TemplateStore();
        }
        setEnable(true);

        // remove and reload template combo
        templateCombo.removeAll();
        for (String templateName : templateStore.getTemplateNames()) {
          templateCombo.add(templateName);
        }

        if (templateCombo.getItemCount() > 0) templateCombo.select(0);

        for (int i = 0; i < templateCombo.getItemCount(); i++) {
          if (templateCombo
              .getItem(i)
              .equals(perferenceStore.getString(PreferenceConstants.TEMPLATE_NAME))) {
            templateCombo.select(i);
            break;
          }
        }
        templateCombo.redraw();

        loadSelectedTemplate();

      } else {
        setEnable(false);
        templateCombo.removeAll();
        templateCombo.redraw();
      }
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError(
          "Database Error", //$NON-NLS-1$
          "Error while updating form",
          e); //$NON-NLS-1$
    }
  }
コード例 #7
0
        @Override
        public void widgetSelected(SelectionEvent e) {
          BarcodeViewGuiData guiData = null;

          try {
            guiData = new BarcodeViewGuiData();

            // save dialog for pdf file.
            FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
            fileDialog.setFilterPath(
                perferenceStore.getString(PreferenceConstants.PDF_DIRECTORY_PATH));
            fileDialog.setOverwrite(true);
            fileDialog.setFileName("default.pdf"); // $NON-NLS-1$
            String pdfFilePath = fileDialog.open();

            if (pdfFilePath == null) return;

            List<String> patientNumbers =
                SessionManager.getAppService().executeGetSourceSpecimenUniqueInventoryIds(32);

            SaveOperation saveOperation = new SaveOperation(guiData, patientNumbers, pdfFilePath);

            try {
              new ProgressMonitorDialog(shell).run(true, true, saveOperation);

            } catch (InvocationTargetException e1) {
              saveOperation.saveFailed();
              saveOperation.setError(
                  Messages.PatientLabelEntryForm_saveop_error_title,
                  "InvocationTargetException: " //$NON-NLS-1$
                      + e1.getCause().getMessage());

            } catch (InterruptedException e2) {
              BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_save_error_title, e2);
            }

            if (saveOperation.isSuccessful()) {
              String parentDir = new File(pdfFilePath).getParentFile().getPath();
              if (parentDir != null)
                perferenceStore.setValue(PreferenceConstants.PDF_DIRECTORY_PATH, parentDir);

              updateSavePreferences();
              clearFieldsConfirm();
              return;
            }

            if (saveOperation.errorExists()) {
              BgcPlugin.openAsyncError(saveOperation.getError()[0], saveOperation.getError()[1]);
            }

          } catch (CBSRGuiVerificationException e1) {
            BgcPlugin.openAsyncError(e1.title, e1.messsage);
            return;
          } catch (BiobankServerException e2) {
            BgcPlugin.openAsyncError(
                Messages.PatientLabelEntryForm_specId_error_title, e2.getMessage());
          } catch (ApplicationException e3) {
            BgcPlugin.openAsyncError(
                Messages.PatientLabelEntryForm_server_error_title, e3.getMessage());
          }
        }