private void createImportSection(final Composite composite) {
   Hyperlink link = new Hyperlink(composite, SWT.None);
   link.addHyperlinkListener(
       new HyperlinkAdapter() {
         @Override
         public void linkActivated(HyperlinkEvent e) {
           ImportEnvironmentsWizard newWizard = new ImportEnvironmentsWizard();
           WizardDialog dialog =
               new WizardDialog(Display.getCurrent().getActiveShell(), newWizard);
           dialog.open();
         }
       });
   link.setText("Import an existing environment into the Servers view");
   link.setUnderlined(true);
   GridData layoutData = new GridData();
   layoutData.horizontalSpan = 2;
   link.setLayoutData(layoutData);
 }
  /*
   * (non-Javadoc)
   * @see org.eclipse.ice.viz.service.widgets.PlotComposite#createInfoContent(org.eclipse.swt.widgets.Composite, int)
   */
  @Override
  protected Composite createInfoContent(Composite parent, int style) {
    // Get the info Composite and its child with the message label.
    final Composite infoComposite = super.createInfoContent(parent, style);
    final Composite msgComposite = (Composite) infoComposite.getChildren()[1];

    // Get a Display and Shell used to create the hyperlink.
    final Display display = infoComposite.getDisplay();
    final Shell shell = infoComposite.getShell();

    // Set the text to display in the hyperlink.
    final String linkText = "Click here to update the connection " + "preferences.";

    // Create a link to the preference page.
    link = new Hyperlink(msgComposite, SWT.NONE);
    link.setText(linkText);
    link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    link.setUnderlined(true);
    link.setForeground(display.getSystemColor(SWT.COLOR_LINK_FOREGROUND));
    // Add the listener to redirect the user to the preferences.
    link.addHyperlinkListener(
        new IHyperlinkListener() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            // Open up the viz service connection preferences.
            PreferencesUtil.createPreferenceDialogOn(
                    shell, getConnectionPreferencePageID(), null, null)
                .open();
          }

          @Override
          public void linkEntered(HyperlinkEvent e) {
            // Nothing to do yet.
          }

          @Override
          public void linkExited(HyperlinkEvent e) {
            // Nothing to do yet.
          }
        });

    return infoComposite;
  }
  /**
   * Create the link to the element
   *
   * @see
   *     org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
   * @param parent the parent composite
   * @return the hyperlink control
   */
  @Override
  protected Control createCustomArea(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Hyperlink hyperLink = toolkit.createHyperlink(parent, label, SWT.UNDERLINE_LINK);
    hyperLink.setBackground(parent.getBackground());
    hyperLink.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
    if (allowNavigation) {
      hyperLink.addHyperlinkListener(
          new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
              navigateToElement();
              okPressed();
            }
          });
    }
    return hyperLink;
  }
  @Override
  public void createControl(Composite parent) {
    GridData gd;

    Composite composite = new Composite(parent, SWT.NULL);
    setControl(composite);

    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.NONE).setText("Select Template:");

    tree = new Tree(composite, SWT.BORDER | SWT.FULL_SELECTION);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 100;
    tree.setLayoutData(gd);

    viewer = new TreeViewer(tree);
    contentProvider = new RepoTemplateContentProvider(false);
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(new RepoTemplateLabelProvider(loadedImages));
    viewer.addFilter(latestFilter);
    setTemplates(Collections.singletonList(emptyTemplate));

    btnLatestOnly = new Button(composite, SWT.CHECK);
    btnLatestOnly.setText("Show latest versions only");
    btnLatestOnly.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    btnLatestOnly.setSelection(true);

    new Label(composite, SWT.NONE).setText("Description:");

    Composite cmpDescription = new Composite(composite, SWT.BORDER);
    cmpDescription.setBackground(tree.getBackground());

    txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false);
    FormText formText = new FormText(txtDescription, SWT.NO_FOCUS);
    txtDescription.setFormText(formText);
    txtDescription.setBackground(tree.getBackground());
    formText.setBackground(tree.getBackground());
    formText.setForeground(tree.getForeground());
    formText.setFont("fixed", JFaceResources.getTextFont());
    formText.setFont("italic", JFaceResources.getFontRegistry().getItalic(""));

    GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd_cmpDescription.heightHint = 100;
    cmpDescription.setLayoutData(gd_cmpDescription);

    GridLayout layout_cmpDescription = new GridLayout(1, false);
    cmpDescription.setLayout(layout_cmpDescription);

    GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_txtDescription.heightHint = 100;
    txtDescription.setLayoutData(gd_txtDescription);

    Hyperlink linkRetina = new Hyperlink(composite, SWT.NONE);
    linkRetina.setText("Why is this text blurred?");
    linkRetina.setUnderlined(true);
    linkRetina.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay()));
    linkRetina.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
          }
        });
    viewer.addOpenListener(
        new IOpenListener() {
          @Override
          public void open(OpenEvent event) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            setTemplate(element instanceof Template ? (Template) element : null);
            getContainer().updateButtons();
            IWizardPage nextPage = getNextPage();
            if (nextPage != null) getContainer().showPage(nextPage);
          }
        });
    btnLatestOnly.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean latestOnly = btnLatestOnly.getSelection();
            if (latestOnly) viewer.addFilter(latestFilter);
            else viewer.removeFilter(latestFilter);
          }
        });
    linkRetina.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent ev) {
            try {
              IWorkbenchBrowserSupport browser = PlatformUI.getWorkbench().getBrowserSupport();
              browser
                  .getExternalBrowser()
                  .openURL(
                      new URL(
                          "https://github.com/bndtools/bndtools/wiki/Blurry-Form-Text-on-High-Resolution-Displays"));
            } catch (Exception e) {
              log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", e));
            }
          }
        });
  }
  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);
  }
Beispiel #6
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);
  }