Example usage for org.eclipse.jface.viewers StructuredSelection StructuredSelection

List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection StructuredSelection.

Prototype

public StructuredSelection(List elements) 

Source Link

Document

Creates a structured selection from the given List.

Usage

From source file:at.component.newcomponentwizard.generator.NewProjectCreationOperation.java

License:Open Source License

private void openFile(final IFile file) {
    final IWorkbenchWindow ww = PDEPlugin.getActiveWorkbenchWindow();
    final IWorkbenchPage page = ww.getActivePage();
    if (page == null)
        return;//  w  w w .  ja  v a2  s .  co m
    final IWorkbenchPart focusPart = page.getActivePart();
    ww.getShell().getDisplay().asyncExec(new Runnable() {
        public void run() {
            if (focusPart instanceof ISetSelectionTarget) {
                ISelection selection = new StructuredSelection(file);
                ((ISetSelectionTarget) focusPart).selectReveal(selection);
            }
            try {
                IDE.openEditor(page, file, true);
            } catch (PartInitException e) {
            }
        }
    });
}

From source file:at.medevit.ch.artikelstamm.elexis.common.ui.cv.ArtikelstammCodeSelectorFactory.java

License:Open Source License

@Override
public ViewerConfigurer createViewerConfigurer(CommonViewer cv) {
    final CommonViewer cov = cv;
    cov.setSelectionChangedListener(selChange);

    FieldDescriptor<?>[] fields = {
            new FieldDescriptor<ArtikelstammItem>(DISP_NAME, ArtikelstammItem.FLD_DSCR, Typ.STRING, null), };

    // add keyListener to search field
    Listener keyListener = new Listener() {
        @Override/*from w w  w. ja va 2 s  .  c  om*/
        public void handleEvent(Event event) {
            if (event.type == eventType) {
                if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                    slp.fireChangedEvent();
                }
            }
        }
    };
    for (FieldDescriptor<?> fd : fields) {
        fd.setAssignedListener(eventType, keyListener);
    }
    slp = new SelectorPanelProvider(fields, true);
    slp.addChangeListener(new AControlFieldListener(slp));

    Query<ArtikelstammItem> qbe = new Query<ArtikelstammItem>(ArtikelstammItem.class);
    ArtikelstammFlatDataLoader fdl = new ArtikelstammFlatDataLoader(cv, qbe, slp);

    List<IAction> actionList = new ArrayList<>();
    populateSelectorPanel(slp, fdl, actionList);
    slp.addActions(actionList.toArray(new IAction[actionList.size()]));

    SimpleWidgetProvider swp = new SimpleWidgetProvider(SimpleWidgetProvider.TYPE_LAZYLIST, SWT.NONE, null);

    ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();

    String atcLang = CoreHub.globalCfg.get(PreferenceConstants.PREF_ATC_CODE_LANGUAGE,
            ATCCodeLanguageConstants.ATC_LANGUAGE_VAL_GERMAN);
    ATCArtikelstammDecoratingLabelProvider adlp = new ATCArtikelstammDecoratingLabelProvider(
            new LagerhaltungArtikelstammLabelProvider(), decorator, atcLang);

    ViewerConfigurer vc = new ViewerConfigurer(fdl, adlp,
            // new MedINDEXArticleControlFieldProvider(cv),
            slp, new ViewerConfigurer.DefaultButtonProvider(), swp, fdl);

    // the dropdown menu on the viewer
    MenuManager menu = new MenuManager();
    menu.add(new Action(ch.elexis.core.ui.views.artikel.Messages.ArtikelContextMenu_propertiesAction) {
        {
            setImageDescriptor(Images.IMG_EDIT.getImageDescriptor());
            setToolTipText(ch.elexis.core.ui.views.artikel.Messages.ArtikelContextMenu_propertiesTooltip);
        }

        @Override
        public void run() {
            StructuredSelection structuredSelection = new StructuredSelection(cov.getSelection());
            Object element = structuredSelection.getFirstElement();
            ArtikelstammDetailDialog dd = new ArtikelstammDetailDialog(UiDesk.getTopShell(),
                    (IArtikelstammItem) element);
            dd.open();
        }
    });

    //      menu.add(new AddVerrechenbarContributionItem(cov));

    MenuManager subMenu = new MenuManager("ATC Gruppen-Selektion",
            Images.IMG_CATEGORY_GROUP.getImageDescriptor(), null) {
        @Override
        public boolean isDynamic() {
            return true;
        }

        @Override
        public boolean isVisible() {
            StructuredSelection structuredSelection = new StructuredSelection(cov.getSelection());
            Object element = structuredSelection.getFirstElement();
            if (element instanceof ArtikelstammItem) {
                ArtikelstammItem ai = (ArtikelstammItem) element;
                return (ai.getATCCode() != null && ai.getATCCode().length() > 0);
            }
            return false;
        }
    };
    subMenu.add(new ATCMenuContributionItem(cov, fdl));
    menu.add(subMenu);

    menu.add(tvfa);
    menu.add(new Separator());
    menu.add(new VATMenuContributionItem(cov));
    cv.setContextMenu(menu);

    return vc;
}

From source file:at.medevit.ch.artikelstamm.elexis.common.ui.cv.ATCMenuContributionItem.java

License:Open Source License

@Override
public void fill(Menu menu, int index) {
    StructuredSelection structuredSelection = new StructuredSelection(cov.getSelection());
    Object element = structuredSelection.getFirstElement();

    ATCCodeService atcCodeService = ATCCodeServiceConsumer.getATCCodeService();
    if (atcCodeService == null)
        return;/*from  w w  w  . jav a2 s  .co m*/

    if (element instanceof ArtikelstammItem) {
        final ArtikelstammItem ai = (ArtikelstammItem) element;
        List<ATCCode> atcHierarchy = atcCodeService.getHierarchyForATCCode(ai.getATCCode());

        for (ATCCode atcCode : atcHierarchy) {
            MenuItem temp = new MenuItem(menu, SWT.PUSH);
            if (prefAtcLanguage.equals(ATCCodeLanguageConstants.ATC_LANGUAGE_VAL_GERMAN)) {
                temp.setText(atcCode.atcCode + " " + atcCode.name_german);
            } else {
                temp.setText(atcCode.atcCode + " " + atcCode.name);
            }
            final ATCCode tempC = atcCode;
            temp.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    fdl.setUseAtcQueryFilter(true);
                    fdl.setAtcQueryFilterValue(tempC.atcCode);
                }
            });
        }
    }

}

From source file:at.medevit.ch.artikelstamm.elexis.common.ui.cv.VATMenuContributionItem.java

License:Open Source License

@Override
public void fill(Menu menu, int index) {
    StructuredSelection structuredSelection = new StructuredSelection(cv.getSelection());
    Object element = structuredSelection.getFirstElement();
    if (element instanceof ArtikelstammItem) {
        final ArtikelstammItem ai = (ArtikelstammItem) element;

        VatInfo vatInfo = ai.getVatInfo();

        MenuItem mi = new MenuItem(menu, SWT.None);
        mi.setText("MWSt. Satz fr Artikel festlegen");
        mi.setEnabled(false);/*from   www.  j a va  2s  . co  m*/

        MenuItem vatNormal = new MenuItem(menu, SWT.RADIO);
        vatNormal.setText("Normal");
        vatNormal.setSelection(vatInfo.equals(VatInfo.VAT_CH_NOTMEDICAMENT));
        vatNormal.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (vatNormal.getSelection()) {
                    ai.overrideVatInfo(VatInfo.VAT_CH_NOTMEDICAMENT);
                }
            }
        });

        MenuItem vatReduced = new MenuItem(menu, SWT.RADIO);
        vatReduced.setText("Reduziert");
        vatReduced.setSelection(vatInfo.equals(VatInfo.VAT_CH_ISMEDICAMENT));
        vatReduced.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (vatReduced.getSelection()) {
                    ai.overrideVatInfo(VatInfo.VAT_CH_ISMEDICAMENT);
                }
            }
        });

        MenuItem vatNone = new MenuItem(menu, SWT.RADIO);
        vatNone.setText("Keine (0%)");
        vatNone.setSelection(vatInfo.equals(VatInfo.VAT_NONE));
        vatNone.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (vatNone.getSelection()) {
                    ai.overrideVatInfo(VatInfo.VAT_NONE);
                }
            }
        });
    }
}

From source file:at.medevit.elexis.ehc.ui.example.wizard.ExportPatientWizardPage1.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    contentViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Control control = contentViewer.getControl();
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd.heightHint = 300;/*from  w  w w  .  ja  v a2s . c om*/
    control.setLayoutData(gd);

    contentViewer.setContentProvider(new ArrayContentProvider());
    contentViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Patient) {
                return ((Patient) element).getLabel();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof Patient) {
                if (((Patient) element).getGeschlecht().equals(Person.FEMALE)) {
                    return Images.IMG_FRAU.getImage();
                } else {
                    return Images.IMG_MANN.getImage();
                }
            }
            return super.getImage(element);
        }
    });
    Query<Patient> qp = new Query(Patient.class);
    contentViewer.setInput(qp.execute());

    Patient selectedPatient = ElexisEventDispatcher.getSelectedPatient();
    if (selectedPatient != null) {
        contentViewer.setSelection(new StructuredSelection(selectedPatient));
        contentViewer.getTable().showSelection();
    }

    setControl(composite);
}

From source file:at.medevit.elexis.gdt.ui.dialog.NeueUntersuchungAnfordernDialog.java

License:Open Source License

/**
 * Create contents of the dialog.//from  w  w  w.  j a v  a  2s. c o m
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    setTitleImage(ResourceManager.getPluginImage("at.medevit.elexis.gdt", "rsc/icons/TitleIcon6302.png"));
    setMessage("GDT Satznachricht 6302");
    setTitle("Neue Untersuchung anfordern");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(4, true));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label lblZiel = new Label(container, SWT.NONE);
    lblZiel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblZiel.setText("Ziel");

    comboViewerTarget = new ComboViewer(container, SWT.NONE);
    Combo combo = comboViewerTarget.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    comboViewerTarget.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerTarget.setLabelProvider(new ComboViewerCommPartner());
    List<IGDTCommunicationPartner> commPartners = GDTCommPartnerCollector.getRegisteredCommPartners();
    comboViewerTarget.setInput(commPartners);
    comboViewerTarget.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) comboViewerTarget.getSelection();
            IGDTCommunicationPartner cp = (IGDTCommunicationPartner) selection.getFirstElement();
            commPartner = cp;
            txtIDReceiver.setText(cp.getIDReceiver());
            if (cp.getOutgoingDefaultCharset() >= 0)
                gdt6302.setValue(GDTConstants.FELDKENNUNG_VERWENDETER_ZEICHENSATZ,
                        cp.getOutgoingDefaultCharset() + "");

            supported8402values = cp.getSupported8402values();
            supported8402valuesDescription = cp.getSupported8402valuesDescription();
            if (supported8402values != null && supported8402valuesDescription != null) {
                contentProposalProvider8402.setProposals(supported8402values, supported8402valuesDescription,
                        cp.getSupported8402valuesDetailDescription());
            }
        }
    });

    Label lblGdtidEmpfnger = new Label(container, SWT.NONE);
    lblGdtidEmpfnger.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGdtidEmpfnger.setText("ID Empfnger");

    txtIDReceiver = new Text(container, SWT.BORDER);
    txtIDReceiver.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtIDReceiver.setTextLimit(8);

    Label lblGdtidSender = new Label(container, SWT.NONE);
    lblGdtidSender.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGdtidSender.setText("ID Sender");

    txtIDSender = new Text(container, SWT.BORDER);
    txtIDSender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtIDSender.setTextLimit(8);

    Label lblNewLabel = new Label(container, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
    gd_lblNewLabel.heightHint = 5;
    lblNewLabel.setLayoutData(gd_lblNewLabel);

    Group groupPatient = new Group(container, SWT.NONE);
    groupPatient.setText("Notwendige Patienten-Daten");
    groupPatient.setLayout(new GridLayout(5, false));
    groupPatient.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));

    Label lblPatientKennung = new Label(groupPatient, SWT.NONE);
    lblPatientKennung.setText("Nummer/Kennung");

    txtPatientenKennung = new Text(groupPatient, SWT.BORDER);
    txtPatientenKennung.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtPatientenKennung.setTextLimit(10);
    new Label(groupPatient, SWT.NONE);

    Label lblGeburtsdatum = new Label(groupPatient, SWT.NONE);
    lblGeburtsdatum.setText("Geburtsdatum");

    dateTimeBirthday = new DateTime(groupPatient, SWT.BORDER | SWT.DROP_DOWN);
    dateTimeBirthday.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblPatientNachname = new Label(groupPatient, SWT.NONE);
    lblPatientNachname.setText("Nachname");

    txtPatientNachname = new Text(groupPatient, SWT.BORDER);
    txtPatientNachname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtPatientNachname.setTextLimit(28);
    new Label(groupPatient, SWT.NONE);

    Label lblPatientVorname = new Label(groupPatient, SWT.NONE);
    lblPatientVorname.setText("Vorname");

    txtPatientVorname = new Text(groupPatient, SWT.BORDER);
    txtPatientVorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtPatientVorname.setTextLimit(28);

    Group grpGeraeteSpezifisch = new Group(container, SWT.None);
    grpGeraeteSpezifisch.setLayout(new GridLayout(4, true));
    grpGeraeteSpezifisch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    grpGeraeteSpezifisch.setText("Testbezogene Daten");

    Label lblGuvk = new Label(grpGeraeteSpezifisch, SWT.NONE);
    lblGuvk.setToolTipText("Gerte und verfahrensspezifisches Kennfeld (8402)");
    lblGuvk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    lblGuvk.setText("GuvK");

    txtGuVK = new Text(grpGeraeteSpezifisch, SWT.BORDER);
    txtGuVK.setTextLimit(6);
    txtGuVK.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    contentProposalProvider8402 = new Feld8402ContentProposalProvider(new String[] {}, new String[] {},
            new String[] {});
    guvkAdapter = new ContentProposalAdapter(txtGuVK, new TextContentAdapter(), contentProposalProvider8402,
            null, null);
    guvkAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);

    Label lblTestident = new Label(grpGeraeteSpezifisch, SWT.NONE);
    lblTestident.setToolTipText("Test-Identifizierung (8410)");
    lblTestident.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    lblTestident.setText("Test-Ident");

    txtTestIdent = new Text(grpGeraeteSpezifisch, SWT.BORDER);
    txtTestIdent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtTestIdent.setTextLimit(20);

    Group grpOptionaleDaten = new Group(container, SWT.NONE);
    grpOptionaleDaten.setText("Optionale Patienten-Daten");
    grpOptionaleDaten.setLayout(new GridLayout(5, false));
    grpOptionaleDaten.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));

    Label lblTitel = new Label(grpOptionaleDaten, SWT.NONE);
    lblTitel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTitel.setText("Titel");

    txtTitel = new Text(grpOptionaleDaten, SWT.BORDER);
    txtTitel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblGeschlecht = new Label(grpOptionaleDaten, SWT.NONE);
    lblGeschlecht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGeschlecht.setText("Geschlecht");

    comboViewerGeschlecht = new ComboViewer(grpOptionaleDaten, SWT.NONE);
    Combo comboGeschlecht = comboViewerGeschlecht.getCombo();
    comboViewerGeschlecht.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerGeschlecht.setInput(new String[] { GDTConstants.SEX_MALE + "", GDTConstants.SEX_FEMALE + "" });
    comboViewerGeschlecht.setLabelProvider(new ComboViewerGeschlechtLabelProvider());
    comboGeschlecht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblVersichertennr = new Label(grpOptionaleDaten, SWT.NONE);
    lblVersichertennr.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblVersichertennr.setText("Versicherten-Nr.");

    txtVersichertenNr = new Text(grpOptionaleDaten, SWT.BORDER);
    txtVersichertenNr.setTextLimit(12);
    txtVersichertenNr.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblVersichertenart = new Label(grpOptionaleDaten, SWT.NONE);
    lblVersichertenart.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblVersichertenart.setText("Versichertenart");

    comboViewerVersichertenart = new ComboViewer(grpOptionaleDaten, SWT.NONE);
    Combo comboVersichertenart = comboViewerVersichertenart.getCombo();
    comboVersichertenart.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboViewerVersichertenart.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerVersichertenart.setInput(new String[] { GDTConstants.VERSICHERTENART_FAMILIENVERSICHERTER + "",
            GDTConstants.VERSICHERTENART_MITGLIED + "", GDTConstants.VERSICHERTENART_RENTNER + "" });
    comboViewerVersichertenart.setLabelProvider(new ComboViewerVersichertenartLabelProvider());

    Label lblStrasse = new Label(grpOptionaleDaten, SWT.NONE);
    lblStrasse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblStrasse.setText("Strasse");

    txtStrasse = new Text(grpOptionaleDaten, SWT.BORDER);
    txtStrasse.setTextLimit(28);
    txtStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblOrt = new Label(grpOptionaleDaten, SWT.NONE);
    lblOrt.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblOrt.setText("Ort");

    txtOrt = new Text(grpOptionaleDaten, SWT.BORDER);
    txtOrt.setTextLimit(30);
    txtOrt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblGroesse = new Label(grpOptionaleDaten, SWT.NONE);
    lblGroesse.setToolTipText("Gre in cm");
    lblGroesse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGroesse.setText("Gre");

    txtGroesse = new Text(grpOptionaleDaten, SWT.BORDER);
    txtGroesse.setTextLimit(10);
    txtGroesse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblGewicht = new Label(grpOptionaleDaten, SWT.NONE);
    lblGewicht.setToolTipText("Gewicht in kg");
    lblGewicht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGewicht.setText("Gewicht");

    txtGewicht = new Text(grpOptionaleDaten, SWT.BORDER);
    txtGewicht.setTextLimit(10);
    txtGewicht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblMuttersprache = new Label(grpOptionaleDaten, SWT.NONE);
    lblMuttersprache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblMuttersprache.setText("Muttersprache");

    txtMuttersprache = new Text(grpOptionaleDaten, SWT.BORDER);
    txtMuttersprache.setTextLimit(60);
    txtMuttersprache.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);
    new Label(grpOptionaleDaten, SWT.NONE);
    new Label(grpOptionaleDaten, SWT.NONE);

    initDataBindings();
    if (commPartners != null && commPartners.size() > 0) {
        comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(0)));
        if (targetIdSelection != null) {
            int idx = 0;
            for (IGDTCommunicationPartner igdtCommunicationPartner : commPartners) {
                if (igdtCommunicationPartner instanceof IGDTCommunicationPartnerProvider) {
                    String id = ((IGDTCommunicationPartnerProvider) igdtCommunicationPartner).getId();
                    if (id.equals(targetIdSelection)) {
                        comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(idx)));
                        break;
                    }
                }
                idx++;
            }
        }
    }

    return area;
}

From source file:at.medevit.elexis.gdt.ui.dialog.StammdatenUebermittelnDialog.java

License:Open Source License

/**
 * Create contents of the dialog.//  www.j a v a  2s  .c o  m
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    setTitleImage(ResourceManager.getPluginImage("at.medevit.elexis.gdt", "rsc/icons/TitleIcon6301.png"));
    setMessage("GDT Satznachricht 6301");
    setTitle("Stammdaten bermitteln");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(4, true));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label lblZiel = new Label(container, SWT.NONE);
    lblZiel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblZiel.setText("Ziel");

    comboViewerTarget = new ComboViewer(container, SWT.NONE);
    Combo combo = comboViewerTarget.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    comboViewerTarget.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerTarget.setLabelProvider(new ComboViewerCommPartner());
    List<IGDTCommunicationPartner> commPartners = GDTCommPartnerCollector.getRegisteredCommPartners();
    comboViewerTarget.setInput(commPartners);
    comboViewerTarget.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) comboViewerTarget.getSelection();
            IGDTCommunicationPartner cp = (IGDTCommunicationPartner) selection.getFirstElement();
            commPartner = cp;
            txtIDReceiver.setText(cp.getIDReceiver());
            if (cp.getOutgoingDefaultCharset() >= 0)
                gdt6301.setValue(GDTConstants.FELDKENNUNG_VERWENDETER_ZEICHENSATZ,
                        cp.getOutgoingDefaultCharset() + "");
        }
    });

    Label lblGdtidEmpfnger = new Label(container, SWT.NONE);
    lblGdtidEmpfnger.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGdtidEmpfnger.setText("ID Empfnger");

    txtIDReceiver = new Text(container, SWT.BORDER);
    txtIDReceiver.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtIDReceiver.setTextLimit(8);

    Label lblGdtidSender = new Label(container, SWT.NONE);
    lblGdtidSender.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGdtidSender.setText("ID Sender");

    txtIDSender = new Text(container, SWT.BORDER);
    txtIDSender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtIDSender.setTextLimit(8);

    Label lblNewLabel = new Label(container, SWT.NONE);
    GridData gd_lblNewLabel = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
    gd_lblNewLabel.heightHint = 5;
    lblNewLabel.setLayoutData(gd_lblNewLabel);

    Group groupPatient = new Group(container, SWT.NONE);
    groupPatient.setText("Notwendige Patienten-Daten");
    groupPatient.setLayout(new GridLayout(5, false));
    groupPatient.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));

    Label lblPatientKennung = new Label(groupPatient, SWT.NONE);
    lblPatientKennung.setText("Nummer/Kennung");

    txtPatientenKennung = new Text(groupPatient, SWT.BORDER);
    txtPatientenKennung.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtPatientenKennung.setTextLimit(10);
    new Label(groupPatient, SWT.NONE);

    Label lblGeburtsdatum = new Label(groupPatient, SWT.NONE);
    lblGeburtsdatum.setText("Geburtsdatum");

    dateTimeBirthday = new DateTime(groupPatient, SWT.BORDER | SWT.DROP_DOWN);
    dateTimeBirthday.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblPatientNachname = new Label(groupPatient, SWT.NONE);
    lblPatientNachname.setText("Nachname");

    txtPatientNachname = new Text(groupPatient, SWT.BORDER);
    txtPatientNachname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtPatientNachname.setTextLimit(28);
    new Label(groupPatient, SWT.NONE);

    Label lblPatientVorname = new Label(groupPatient, SWT.NONE);
    lblPatientVorname.setText("Vorname");

    txtPatientVorname = new Text(groupPatient, SWT.BORDER);
    txtPatientVorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    txtPatientVorname.setTextLimit(28);

    Group grpOptionaleDaten = new Group(container, SWT.NONE);
    grpOptionaleDaten.setText("Optionale Patienten-Daten");
    grpOptionaleDaten.setLayout(new GridLayout(5, false));
    grpOptionaleDaten.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));

    Label lblTitel = new Label(grpOptionaleDaten, SWT.NONE);
    lblTitel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTitel.setText("Titel");

    txtTitel = new Text(grpOptionaleDaten, SWT.BORDER);
    txtTitel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblGeschlecht = new Label(grpOptionaleDaten, SWT.NONE);
    lblGeschlecht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGeschlecht.setText("Geschlecht");

    comboViewerGeschlecht = new ComboViewer(grpOptionaleDaten, SWT.NONE);
    Combo comboGeschlecht = comboViewerGeschlecht.getCombo();
    comboViewerGeschlecht.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerGeschlecht.setInput(new String[] { GDTConstants.SEX_MALE + "", GDTConstants.SEX_FEMALE + "" });
    comboViewerGeschlecht.setLabelProvider(new ComboViewerGeschlechtLabelProvider());
    comboGeschlecht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblVersichertennr = new Label(grpOptionaleDaten, SWT.NONE);
    lblVersichertennr.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblVersichertennr.setText("Versicherten-Nr.");

    txtVersichertenNr = new Text(grpOptionaleDaten, SWT.BORDER);
    txtVersichertenNr.setTextLimit(12);
    txtVersichertenNr.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblVersichertenart = new Label(grpOptionaleDaten, SWT.NONE);
    lblVersichertenart.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblVersichertenart.setText("Versichertenart");

    comboViewerVersichertenart = new ComboViewer(grpOptionaleDaten, SWT.NONE);
    Combo comboVersichertenart = comboViewerVersichertenart.getCombo();
    comboVersichertenart.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboViewerVersichertenart.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerVersichertenart.setInput(new String[] { GDTConstants.VERSICHERTENART_FAMILIENVERSICHERTER + "",
            GDTConstants.VERSICHERTENART_MITGLIED + "", GDTConstants.VERSICHERTENART_RENTNER + "" });
    comboViewerVersichertenart.setLabelProvider(new ComboViewerVersichertenartLabelProvider());

    Label lblStrasse = new Label(grpOptionaleDaten, SWT.NONE);
    lblStrasse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblStrasse.setText("Strasse");

    txtStrasse = new Text(grpOptionaleDaten, SWT.BORDER);
    txtStrasse.setTextLimit(28);
    txtStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblOrt = new Label(grpOptionaleDaten, SWT.NONE);
    lblOrt.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblOrt.setText("Ort");

    txtOrt = new Text(grpOptionaleDaten, SWT.BORDER);
    txtOrt.setTextLimit(30);
    txtOrt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblGroesse = new Label(grpOptionaleDaten, SWT.NONE);
    lblGroesse.setToolTipText("Gre in cm");
    lblGroesse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGroesse.setText("Gre");

    txtGroesse = new Text(grpOptionaleDaten, SWT.BORDER);
    txtGroesse.setTextLimit(10);
    txtGroesse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);

    Label lblGewicht = new Label(grpOptionaleDaten, SWT.NONE);
    lblGewicht.setToolTipText("Gewicht in kg");
    lblGewicht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblGewicht.setText("Gewicht");

    txtGewicht = new Text(grpOptionaleDaten, SWT.BORDER);
    txtGewicht.setTextLimit(10);
    txtGewicht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblMuttersprache = new Label(grpOptionaleDaten, SWT.NONE);
    lblMuttersprache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblMuttersprache.setText("Muttersprache");

    txtMuttersprache = new Text(grpOptionaleDaten, SWT.BORDER);
    txtMuttersprache.setTextLimit(60);
    txtMuttersprache.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(grpOptionaleDaten, SWT.NONE);
    new Label(grpOptionaleDaten, SWT.NONE);
    new Label(grpOptionaleDaten, SWT.NONE);

    initDataBindings();
    if (commPartners != null && commPartners.size() > 0) {
        comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(0)));
        if (preSelCommPartner != null) {
            for (IGDTCommunicationPartner gdtCommPartner : commPartners) {
                if (preSelCommPartner.equals(gdtCommPartner.getClass().getName())) {
                    comboViewerTarget.setSelection(new StructuredSelection(gdtCommPartner));
                }
            }
        } else if (targetIdSelection != null) {
            int idx = 0;
            for (IGDTCommunicationPartner igdtCommunicationPartner : commPartners) {
                if (igdtCommunicationPartner instanceof IGDTCommunicationPartnerProvider) {
                    String id = ((IGDTCommunicationPartnerProvider) igdtCommunicationPartner).getId();
                    if (id.equals(targetIdSelection)) {
                        comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(idx)));
                        break;
                    }
                }
                idx++;
            }
        }
    }
    return area;
}

From source file:at.medevit.elexis.impfplan.ui.VaccinationComposite.java

License:Open Source License

@Override
public ISelection getSelection() {
    Vaccination selected = vcpl.getSelectedVaccination();
    if (selected != null) {
        return new StructuredSelection(selected);
    }/* w w  w .  j  av a2  s  . com*/
    return new StructuredSelection();
}

From source file:at.medevit.menus.dialog.AddPersonDialog.java

License:Open Source License

/**
 * Create contents of the dialog.//from   w  w  w.  j a v a 2 s. c  om
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    setMessage("Add a new person to the system.");
    setTitle("Add person");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    txtFirstname = new Text(container, SWT.BORDER);
    txtFirstname.setMessage("firstname");
    txtFirstname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    txtLastname = new Text(container, SWT.BORDER);
    txtLastname.setMessage("lastname");
    txtLastname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    ComboViewer comboViewer = new ComboViewer(container, SWT.NONE);
    comboGender = comboViewer.getCombo();
    comboGender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setInput(Gender.VALUES);
    comboViewer.setSelection(new StructuredSelection(Gender.MALE));
    new Label(container, SWT.NONE);

    return area;
}

From source file:at.medevit.menus.parts.SelectorPart.java

License:Open Source License

/**
 * Create contents of the view part./*from  w  w  w. ja va2 s  . c o m*/
 */
@PostConstruct
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(1, false));

    // -- person selector
    Label lblPerson = new Label(parent, SWT.NONE);
    lblPerson.setText("Person");

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    composite.setLayout(new TableColumnLayout());

    selectPersonTV = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
    selectPersonTV.setLabelProvider(new AdapterFactoryLabelProvider(mipaf));
    selectPersonTV.setContentProvider(new AdapterFactoryContentProvider(mipaf));
    selectPersonTV.setInput(SampleModel.getDirectory());
    selectPersonTV.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();

            Person p = (Person) selection.getFirstElement();

            selectionService.setSelection(selection.size() == 1 ? p : selection.toArray());

            if (selection.size() == 1) {
                if (p.getPartner() != null) {
                    partnerPersonTV.setSelection(new StructuredSelection(p.getPartner()));
                } else {
                    partnerPersonTV.setSelection(null);
                }
            }
        }
    });
    ViewerFilter[] filters = new ViewerFilter[] { new PersonViewerFilter(selectPersonTV) };
    selectPersonTV.setFilters(filters);

    menuService.registerContextMenu(selectPersonTV.getTable(), SELECTOR_POPUPMENU_ID);

    // -- partner selector
    Label lblPartner = new Label(parent, SWT.NONE);
    lblPartner.setText("Partner");

    Composite composite2 = new Composite(parent, SWT.NONE);
    composite2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    composite2.setLayout(new TableColumnLayout());

    partnerPersonTV = new TableViewer(composite2, SWT.BORDER | SWT.FULL_SELECTION);
    partnerPersonTV.setLabelProvider(new AdapterFactoryLabelProvider(mipaf));
    partnerPersonTV.setContentProvider(new AdapterFactoryContentProvider(mipaf));
    partnerPersonTV.setInput(SampleModel.getDirectory());

}