Exemplo n.º 1
0
  public Composite createForm(Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    ret.setLayout(new GridLayout(2, false));
    Image img = getImage();

    GridData gd1 = null;
    GridData gd2 = null;

    Composite cImg = new Composite(ret, SWT.NONE);
    if (img != null) {
      cImg.setBackgroundImage(img);
      gd1 = new GridData(img.getBounds().width, img.getBounds().height);
      gd2 = new GridData(SWT.DEFAULT, img.getBounds().height);
    } else {
      gd1 = new GridData(10, 10);
      gd2 = new GridData(SWT.DEFAULT, SWT.DEFAULT);
    }
    cImg.setLayoutData(gd1);
    Label lbl = new Label(ret, SWT.NONE);
    lbl.setLayoutData(gd2);
    lbl.setText(sticker.getLabel());
    lbl.setForeground(UiDesk.getColorFromRGB(sticker.getForeground()));
    lbl.setBackground(UiDesk.getColorFromRGB(sticker.getBackground()));
    return ret;
  }
Exemplo n.º 2
0
  public void setLeistungen(Konsultation b) {
    List<Verrechnet> lgl = Collections.emptyList();
    if (b != null) {
      lgl = b.getLeistungen();
    }
    tVerr.setRedraw(false);
    tVerr.removeAll();
    StringBuilder sdg = new StringBuilder();
    Money sum = new Money(0);
    for (Verrechnet lst : lgl) {
      sdg.setLength(0);
      int z = lst.getZahl();
      Money preis = lst.getNettoPreis().multiply(z);
      sum.addMoney(preis);
      sdg.append(z)
          .append(" ")
          .append(lst.getCode())
          .append(" ")
          .append(lst.getText()) // $NON-NLS-1$ //$NON-NLS-2$
          .append(" (")
          .append(preis.getAmountAsString())
          .append(")"); // $NON-NLS-1$ //$NON-NLS-2$
      TableItem ti = new TableItem(tVerr, SWT.WRAP);
      ti.setText(sdg.toString());
      ti.setData(lst);

      IVerrechenbar vr = lst.getVerrechenbar();
      if (vr instanceof Artikel) {
        Artikel a = (Artikel) vr;
        int abgabeEinheit = a.getAbgabeEinheit();
        if (abgabeEinheit > 0 && abgabeEinheit < a.getPackungsGroesse()) {
          ti.setImage(Images.IMG_BLOCKS_SMALL.getImage());
        }
      }

      // set table item color
      IVerrechenbar verrBar = lst.getVerrechenbar();
      if (verrBar != null) {
        Color color = UiDesk.getColorFromRGB(defaultRGB);
        String codeName = verrBar.getCodeSystemName();

        if (codeName != null) {
          String rgbColor =
              CoreHub.globalCfg.get(Preferences.LEISTUNGSCODES_COLOR + codeName, defaultRGB);
          color = UiDesk.getColorFromRGB(rgbColor);
        }
        ti.setBackground(color);
      }
    }
    tVerr.setRedraw(true);
    sdg.setLength(0);
    sdg.append(Messages.VerrechnungsDisplay_billed)
        .append(sum.getAmountAsString())
        .append(")"); // $NON-NLS-1$ //$NON-NLS-2$
    hVer.setText(sdg.toString());
  }
Exemplo n.º 3
0
  public Image getImage() {
    Image ret = null;
    DBImage dbImage = DBImage.load(sticker.get(Sticker.FLD_IMAGE_ID));
    if (!dbImage.exists()) {
      dbImage = null;
    }
    UiDBImage image = new UiDBImage(dbImage);

    ret = UiDesk.getImageRegistry().get(image.getName());
    if (ret == null) {
      ret = image.getImageScaledTo(16, 16, false);
      if (ret != null) UiDesk.getImageRegistry().put(image.getName(), ret);
    }

    return ret;
  }
Exemplo n.º 4
0
  public CstCanvas(Composite parent, int style) {
    super(parent, style);

    fontSmall = createFontofSize(7);
    fontBig = createFontofSize(12);

    Font initialFont = getDisplay().getSystemFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(7);
    }
    fontA = new Font(getDisplay(), fontData);
    BLUE = UiDesk.getColorFromRGB("1E1EFF");
    GRAY = UiDesk.getColorFromRGB("DDDDDD");
    DARKGRAY = UiDesk.getColorFromRGB("AAAAAA");
    WHITE = UiDesk.getColorFromRGB("FFFFFF");
    BRIGHTGREEN = UiDesk.getColorFromRGB("68FF00");
    ORANGE = UiDesk.getColorFromRGB("FF6800");
    BLACK = UiDesk.getColorFromRGB("000000");

    setBackground(WHITE);

    addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            // TODO: is it necessary to dispose these colors (don't think so, but make sure)
            fontA.dispose();
          }
        });
  }
Exemplo n.º 5
0
  public void catchElexisEvent(ElexisEvent ev) {
    UiDesk.asyncExec(
        new Runnable() {

          public void run() {
            dmd.reload();
          }
        });
  }
Exemplo n.º 6
0
  private void changeQuantityDialog(String p, Verrechnet v) {
    InputDialog dlg =
        new InputDialog(
            UiDesk.getTopShell(),
            Messages.VerrechnungsDisplay_changeNumberCaption, // $NON-NLS-1$
            Messages.VerrechnungsDisplay_changeNumberBody, // $NON-NLS-1$
            p,
            null);
    if (dlg.open() == Dialog.OK) {
      try {
        String val = dlg.getValue();
        if (!StringTool.isNothing(val)) {
          int changeAnzahl;
          double secondaryScaleFactor = 1.0;
          String text = v.getVerrechenbar().getText();

          if (val.indexOf(StringConstants.SLASH) > 0) {
            changeAnzahl = 1;
            String[] frac = val.split(StringConstants.SLASH);
            secondaryScaleFactor = Double.parseDouble(frac[0]) / Double.parseDouble(frac[1]);
            text =
                v.getText()
                    + " ("
                    + val
                    + Messages.VerrechnungsDisplay_Orininalpackungen; // $NON-NLS-1$
          } else if (val.indexOf('.') > 0) {
            changeAnzahl = 1;
            secondaryScaleFactor = Double.parseDouble(val);
            text = v.getText() + " (" + Double.toString(secondaryScaleFactor) + ")";
          } else {
            changeAnzahl = Integer.parseInt(dlg.getValue());
          }

          IStatus ret = v.changeAnzahlValidated(changeAnzahl);
          if (ret.isOK()) {
            v.setSecondaryScaleFactor(secondaryScaleFactor);
            v.setText(text);
          } else {
            SWTHelper.showError(Messages.VerrechnungsDisplay_error, ret.getMessage());
          }
        }
        setLeistungen((Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class));
      } catch (NumberFormatException ne) {
        SWTHelper.showError(
            Messages.VerrechnungsDisplay_invalidEntryCaption, // $NON-NLS-1$
            Messages.VerrechnungsDisplay_invalidEntryBody); // $NON-NLS-1$
      }
    }
  }
Exemplo n.º 7
0
 /**
  * den Viewer über eine Änderung benachrichtigen
  *
  * @param m eine Message: update: der Viewer muss neu eingelesen werden empty: Die Auswahl ist
  *     leer. notempty: Die Auswahl ist nicht (mehr) leer.
  */
 public void notify(final Message m) {
   if (viewer.getControl().isDisposed()) {
     return;
   }
   UiDesk.getDisplay()
       .asyncExec(
           new Runnable() {
             public void run() {
               switch (m) {
                 case update:
                   if (!viewer.getControl().isDisposed()) {
                     viewer.refresh(true);
                   }
                   break;
                 case update_keeplabels:
                   if (!viewer.getControl().isDisposed()) {
                     viewer.refresh(false);
                   }
                   break;
                 case empty:
                   if (bNew != null) {
                     if (vc.getButtonProvider().isAlwaysEnabled() == false) {
                       bNew.setEnabled(false);
                     }
                   }
                   if (createObjectAction != null) {
                     createObjectAction.setEnabled(false);
                   }
                   break;
                 case notempty:
                   if (bNew != null) {
                     bNew.setEnabled(true);
                   }
                   if (createObjectAction != null) {
                     createObjectAction.setEnabled(true);
                   }
                   break;
               }
             }
           });
 }
Exemplo n.º 8
0
 public void setBackground(Color bg) {
   if (bg != null) {
     sticker.setBackground(UiDesk.createColor(bg.getRGB()));
   }
 }
Exemplo n.º 9
0
 public Color getBackground() {
   return UiDesk.getColorFromRGB(sticker.getBackground());
 }
Exemplo n.º 10
0
  public VerrechnungsDisplay(final IWorkbenchPage p, Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout());
    this.page = p;
    defaultRGB = UiDesk.createColor(new RGB(255, 255, 255));

    hVer =
        UiDesk.getToolkit()
            .createHyperlink(this, Messages.VerrechnungsDisplay_billing, SWT.NONE); // $NON-NLS-1$
    hVer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    hVer.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            try {
              if (StringTool.isNothing(LeistungenView.ID)) {
                SWTHelper.alert(
                    Messages.VerrechnungsDisplay_error,
                    "LeistungenView.ID"); //$NON-NLS-1$ //$NON-NLS-2$
              }
              page.showView(LeistungenView.ID);
              CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget);
            } catch (Exception ex) {
              ElexisStatus status =
                  new ElexisStatus(
                      ElexisStatus.ERROR,
                      Hub.PLUGIN_ID,
                      ElexisStatus.CODE_NONE,
                      Messages.VerrechnungsDisplay_errorStartingCodeWindow + ex.getMessage(),
                      ex,
                      ElexisStatus.LOG_ERRORS);
              StatusManager.getManager().handle(status, StatusManager.SHOW);
            }
          }
        });
    makeActions();
    tVerr = UiDesk.getToolkit().createTable(this, SWT.MULTI);
    tVerr.setLayoutData(new GridData(GridData.FILL_BOTH));
    tVerr.setMenu(createVerrMenu());
    // dummy table viewer needed for SelectionsProvider for Menu
    viewer = new TableViewer(tVerr);
    // add selection event to table which provides selection to ElexisEventDispatcher
    tVerr.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            TableItem[] selection = tVerr.getSelection();
            Verrechnet verrechnet = (Verrechnet) selection[0].getData();
            ElexisEventDispatcher.fireSelectionEvent(verrechnet);

            applyMedicationAction.setEnabled(false);

            IVerrechenbar verrechenbar = verrechnet.getVerrechenbar();
            if (verrechenbar != null && (verrechenbar instanceof Artikel)) {
              applyMedicationAction.setEnabled(true);
            }
          }
        });
    tVerr.addKeyListener(
        new KeyListener() {
          @Override
          public void keyReleased(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
              if (tVerr.getSelectionIndices().length >= 1 && removeAction != null) {
                removeAction.run();
              }
            }
          }
        });
    dropTarget =
        new PersistentObjectDropTarget(
            Messages.VerrechnungsDisplay_doBill, tVerr, new DropReceiver()); // $NON-NLS-1$
    // refresh the table if a update to a Verrechnet occurs
    ElexisEventDispatcher.getInstance()
        .addListeners(
            new ElexisUiEventListenerImpl(Verrechnet.class, ElexisEvent.EVENT_UPDATE) {
              @Override
              public void runInUi(ElexisEvent ev) {
                Konsultation actKons =
                    (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
                setLeistungen(actKons);
              }
            });

    ElexisEventDispatcher.getInstance().addListeners(eeli_update);
  }
Exemplo n.º 11
0
  @Override
  public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new FillLayout());

    tk = UiDesk.getToolkit();
    form = tk.createScrolledForm(main);
    form.getBody().setLayout(new GridLayout(1, true));

    SashForm mainSash = new SashForm(form.getBody(), SWT.VERTICAL);
    mainSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    dauermedikationSection =
        tk.createExpandableComposite(
            mainSash, ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE);
    dauermedikationSection.setText("Fixmedikation");

    Composite dauermedikationComposite = tk.createComposite(dauermedikationSection);
    dauermedikationSection.setClient(dauermedikationComposite);
    Composite bottomComposite = tk.createComposite(mainSash);

    mainSash.setWeights(new int[] {25, 75});

    // Dauermedikation

    dauermedikationComposite.setLayout(new GridLayout());

    // Label lDauermedikation = tk.createLabel(dauermedikationComposite, "Fixmedikation");
    // lDauermedikation.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    dlDauerMedi = new ProblemFixMediDisplay(dauermedikationComposite, getViewSite());

    bottomComposite.setLayout(new GridLayout());

    SashForm bottomSash = new SashForm(bottomComposite, SWT.HORIZONTAL);
    bottomSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    diagnosenComposite = tk.createComposite(bottomSash);
    Composite konsultationenComposite = tk.createComposite(bottomSash);

    bottomSash.setWeights(new int[] {25, 75});

    diagnosenComposite.setLayout(new GridLayout(1, true));

    Hyperlink hDiagnosen = tk.createHyperlink(diagnosenComposite, "Diagnosen", SWT.NONE);
    hDiagnosen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    hDiagnosen.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            try {
              getViewSite().getPage().showView(DiagnosenView.ID);
            } catch (Exception ex) {
              ExHandler.handle(ex);
              log.error("Fehler beim Starten des Diagnosencodes " + ex.getMessage());
            }
          }
        });

    Table diagnosenTable = tk.createTable(diagnosenComposite, SWT.SINGLE);
    diagnosenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    diagnosenViewer = new TableViewer(diagnosenTable);
    diagnosenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    diagnosenViewer.setContentProvider(
        new IStructuredContentProvider() {
          @Override
          public Object[] getElements(Object inputElement) {
            if (actProblem != null) {
              List<IDiagnose> diagnosen = actProblem.getDiagnosen();
              return diagnosen.toArray();
            }
            return new Object[0];
          }

          @Override
          public void dispose() {
            // nothing to do
          }

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // nothing to do
          }
        });
    diagnosenViewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (!(element instanceof IDiagnose)) {
              return "";
            }

            IDiagnose diagnose = (IDiagnose) element;
            return diagnose.getLabel();
          }
        });
    diagnosenViewer.setInput(this);

    konsultationenComposite.setLayout(new GridLayout(1, true));

    Label lKonsultationen = tk.createLabel(konsultationenComposite, "Konsultationen", SWT.LEFT);
    lKonsultationen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));

    Table konsultationenTable = tk.createTable(konsultationenComposite, SWT.SINGLE);
    konsultationenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    konsultationenViewer = new TableViewer(konsultationenTable);
    konsultationenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    konsultationenViewer.setContentProvider(
        new IStructuredContentProvider() {
          @Override
          public Object[] getElements(Object inputElement) {
            if (actProblem != null) {
              List<Konsultation> konsultationen = actProblem.getKonsultationen();
              return konsultationen.toArray();
            }
            return new Object[0];
          }

          @Override
          public void dispose() {
            // nothing to do
          }

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // nothing to do
          }
        });
    konsultationenViewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (!(element instanceof Konsultation)) {
              return "";
            }

            Konsultation konsultation = (Konsultation) element;
            return konsultation.getLabel();
          }
        });
    konsultationenViewer.setInput(this);

    /* Implementation Drag&Drop */

    final TextTransfer textTransfer = TextTransfer.getInstance();
    Transfer[] types = new Transfer[] {textTransfer};

    // diagnosenComposite
    DropTarget dtarget = new DropTarget(diagnosenComposite, DND.DROP_COPY);
    dtarget.setTransfer(types);
    dtarget.addDropListener(
        new DropTargetListener() {
          @Override
          public void dragEnter(DropTargetEvent event) {
            /* Wir machen nur Copy-Operationen */
            event.detail = DND.DROP_COPY;
          }

          /* Mausbewegungen mit gedrückter Taste sind uns egal */
          @Override
          public void dragLeave(DropTargetEvent event) {
            /* leer */
          }

          @Override
          public void dragOperationChanged(DropTargetEvent event) {
            /* leer */
          }

          @Override
          public void dragOver(DropTargetEvent event) {
            /* leer */
          }

          /* Erst das Loslassen interessiert uns wieder */
          @Override
          public void drop(DropTargetEvent event) {
            String drp = (String) event.data;
            String[] dl = drp.split(",");
            for (String obj : dl) {
              PersistentObject dropped = CoreHub.poFactory.createFromString(obj);
              if (dropped instanceof IDiagnose) {
                IDiagnose diagnose = (IDiagnose) dropped;
                actProblem.addDiagnose(diagnose);

                // tell other viewers that something has changed
                IatrixEventHelper.updateProblem(actProblem);

                // update ourselves
                // TODO: implement ObjectListener
                diagnosenViewer.refresh();
              }
            }
          }

          @Override
          public void dropAccept(DropTargetEvent event) {
            /* leer */
          }
        });

    makeListeners();
    makeActions();
    menus = new ViewMenus(getViewSite());
    menus.createViewerContextMenu(diagnosenViewer, delDiagnoseAction);
    menus.createViewerContextMenu(konsultationenViewer, unassignProblemAction);

    GlobalEventDispatcher.addActivationListener(this, this);
  }