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

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

Introduction

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

Prototype

public LabelProvider() 

Source Link

Document

Creates a new label provider.

Usage

From source file:carisma.ui.eclipse.preferences.pages.EditorPriorityList.java

License:Open Source License

/**
 * Opens a dialog to add an editor to the priority list.
 * @return the result, or <code>null</code> if nothing chosen
 *//*from  w  w w.  jav a 2 s. c  om*/
String openEditorSelectionDialog() {
    ListDialog dialog = new ListDialog(this.container.getShell());
    dialog.setContentProvider(ArrayContentProvider.getInstance());
    dialog.setLabelProvider(new LabelProvider());
    dialog.setTitle("Add editor for automatic opening");
    // TODO write Context help and reference it here

    java.util.List<String> input = getAvailableEditors();
    dialog.setInput(input);
    dialog.open();

    Object[] result = dialog.getResult();
    if (result != null && result.length > 0) {
        return (String) result[0];
    }

    return null;

}

From source file:ch.elexis.agenda.preferences.Tageseinteilung.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    ret.setLayout(new GridLayout());
    new Label(ret, SWT.None).setText(Messages.Tageseinteilung_enterPeriods);
    final Combo cbBereich = new Combo(ret, SWT.READ_ONLY | SWT.SINGLE);
    cbBereich.setItems(bereiche);//from   w w  w . ja v  a 2s .  c om

    Composite grid = new Composite(ret, SWT.BORDER);
    grid.setLayout(new GridLayout(7, true));
    grid.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    new Label(grid, SWT.CENTER).setText(Messages.Tageseinteilung_mo);
    new Label(grid, SWT.CENTER).setText(Messages.Tageseinteilung_tu);
    new Label(grid, SWT.CENTER).setText(Messages.Tageseinteilung_we);
    new Label(grid, SWT.CENTER).setText(Messages.Tageseinteilung_th);
    new Label(grid, SWT.NONE).setText(Messages.Tageseinteilung_fr);
    new Label(grid, SWT.NONE).setText(Messages.Tageseinteilung_sa);
    new Label(grid, SWT.NONE).setText(Messages.Tageseinteilung_so);
    tMo = new Text(grid, SWT.BORDER | SWT.MULTI);
    tMo.setEnabled(false);
    tMo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    originalBackgroundColor = tMo.getBackground();
    tDi = new Text(grid, SWT.BORDER | SWT.MULTI);
    tDi.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tDi.setEnabled(false);
    tMi = new Text(grid, SWT.BORDER | SWT.MULTI);
    tMi.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tMi.setEnabled(false);
    tDo = new Text(grid, SWT.BORDER | SWT.MULTI);
    tDo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tDo.setEnabled(false);
    tFr = new Text(grid, SWT.BORDER | SWT.MULTI);
    tFr.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tFr.setEnabled(false);
    tSa = new Text(grid, SWT.BORDER | SWT.MULTI);
    tSa.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tSa.setEnabled(false);
    tSo = new Text(grid, SWT.BORDER | SWT.MULTI);
    tSo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    tSo.setEnabled(false);
    cbBereich.select(actBereich);

    Composite editDayComposite = new Composite(grid, SWT.None);
    editDayComposite.setLayoutData(SWTHelper.getFillGridData(7, true, 1, false));
    editDayComposite.setLayout(new GridLayout(3, false));

    btnEditValuesFor = new Button(editDayComposite, SWT.NONE);
    btnEditValuesFor.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            StructuredSelection ss = (StructuredSelection) comboViewerDayEditSelector.getSelection();
            editSelection = (DAYS) ss.getFirstElement();
            if (editSelection == null)
                return;

            Text[] days = new Text[] { tMo, tDi, tMi, tDo, tFr, tSa, tSo };
            for (Text text : days) {
                text.setEnabled(false);
                text.setBackground(originalBackgroundColor);
            }

            switch (editSelection) {
            case MONDAY:
                editSelectionText = tMo;
                break;
            case TUESDAY:
                editSelectionText = tDi;
                break;
            case FRIDAY:
                editSelectionText = tFr;
                break;
            case SATURDAY:
                editSelectionText = tSa;
                break;
            case SUNDAY:
                editSelectionText = tSo;
                break;
            case THURSDAY:
                editSelectionText = tDo;
                break;
            case WEDNESDAY:
                editSelectionText = tMi;
                break;
            default:
                break;
            }
            editSelectionText.setEnabled(true);
            editSelectionText
                    .setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_YELLOW));
            btnApplyEdit.setEnabled(true);
            dateTimeStartingFrom.setEnabled(true);
            editSelectionText.setFocus();
        }
    });
    btnEditValuesFor.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnEditValuesFor.setText(Messages.Tageseinteilung_lblEditValuesFor_text);

    comboViewerDayEditSelector = new ComboViewer(editDayComposite, SWT.NONE);
    Combo comboDayEditSelector = comboViewerDayEditSelector.getCombo();
    comboDayEditSelector.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    compositeEditStarting = new Composite(editDayComposite, SWT.NONE);
    compositeEditStarting.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    GridLayout gl_compositeEditStarting = new GridLayout(3, false);
    gl_compositeEditStarting.verticalSpacing = 0;
    gl_compositeEditStarting.marginHeight = 0;
    compositeEditStarting.setLayout(gl_compositeEditStarting);

    lblChangedValuesAre = new Label(compositeEditStarting, SWT.NONE);
    lblChangedValuesAre.setText(Messages.Tageseinteilung_lblChangedValuesAre_text);

    dateTimeStartingFrom = new DateTime(compositeEditStarting, SWT.BORDER);
    TimeTool tomorrow = new TimeTool();
    tomorrow.addDays(1);
    dateTimeStartingFrom.setDate(tomorrow.get(TimeTool.YEAR), tomorrow.get(TimeTool.MONTH),
            tomorrow.get(TimeTool.DAY_OF_MONTH));
    dateTimeStartingFrom.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            setErrorMessage(null);
            DateTime dt = (DateTime) e.getSource();
            int day = dateTimeStartingFrom.getDay(); // Calendar.DAY_OF_MONTH
            int month = dateTimeStartingFrom.getMonth(); // Calendar.MONTH
            int year = dateTimeStartingFrom.getYear(); // Calendar.YEAR
            String timeString = String.format("%02d", day) + "." + String.format("%02d", month + 1) + "."
                    + String.format("%04d", year);
            TimeTool tt = new TimeTool(timeString);
            if (tt.isBefore(new TimeTool())) {
                setErrorMessage(Messages.Tageseinteilung_no_past_Date);
                TimeTool tomorrow = new TimeTool();
                tomorrow.addDays(1);
                dateTimeStartingFrom.setDate(tomorrow.get(TimeTool.YEAR), tomorrow.get(TimeTool.MONTH),
                        tomorrow.get(TimeTool.DAY_OF_MONTH));
            }
        }
    });
    dateTimeStartingFrom.setEnabled(false);

    btnApplyEdit = new Button(compositeEditStarting, SWT.NONE);
    btnApplyEdit.setText(Messages.Tageseinteilung_btnNewButton_text);
    btnApplyEdit.setEnabled(false);
    btnApplyEdit.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // Apply the selected edits starting from the selected date
            int day = dateTimeStartingFrom.getDay(); // Calendar.DAY_OF_MONTH
            int month = dateTimeStartingFrom.getMonth(); // Calendar.MONTH
            int year = dateTimeStartingFrom.getYear(); // Calendar.YEAR
            String timeString = String.format("%02d", day) + "." + String.format("%02d", month + 1) + "."
                    + String.format("%04d", year);
            ProgressMonitorDialog pmd = new ProgressMonitorDialog(UiDesk.getTopShell());
            IRunnableWithProgress irp = new TermineLockedTimesUpdater(new TimeTool(timeString), editSelection,
                    editSelectionText.getText(), Termin.TerminBereiche[actBereich]);
            try {
                pmd.run(false, false, irp);
                editSelectionText.setBackground(originalBackgroundColor);
                editSelectionText.setEnabled(false);
            } catch (InvocationTargetException e1) {
                Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Execution Error", e1);
                StatusManager.getManager().handle(status, StatusManager.SHOW);
            } catch (InterruptedException e1) {
                Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Execution Error", e1);
                StatusManager.getManager().handle(status, StatusManager.SHOW);
            }

            dateTimeStartingFrom.setEnabled(false);
            btnApplyEdit.setEnabled(false);
        }
    });

    comboViewerDayEditSelector.setContentProvider(ArrayContentProvider.getInstance());
    comboViewerDayEditSelector.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            TimeTool.DAYS day = (TimeTool.DAYS) element;
            return day.fullName;
        }
    });
    TimeTool.DAYS[] days = TimeTool.DAYS.values();
    comboViewerDayEditSelector.setInput(days);
    comboViewerDayEditSelector.setSelection(new StructuredSelection(days[0]));

    compositeDayBorders = new Composite(ret, SWT.NONE);
    compositeDayBorders.setLayout(new GridLayout(2, false));

    Composite compositeStart = new Composite(compositeDayBorders, SWT.NONE);
    compositeStart.setLayout(new GridLayout(3, false));

    Label btnDayStartHourIsSet = new Label(compositeStart, SWT.CHECK);
    btnDayStartHourIsSet.setText(Messages.Tageseinteilung_btnCheckButton_text);

    sodt = new Text(compositeStart, SWT.BORDER);
    sodt.setTextLimit(4);

    Label lblHours = new Label(compositeStart, SWT.NONE);
    lblHours.setText(Messages.Tageseinteilung_lblHours_text);

    Composite compositeEnd = new Composite(compositeDayBorders, SWT.NONE);
    compositeEnd.setLayout(new GridLayout(3, false));

    Label btnEndStartHourIsSet = new Label(compositeEnd, SWT.CHECK);
    btnEndStartHourIsSet.setText(Messages.Tageseinteilung_btnCheckButton_text_1);

    eodt = new Text(compositeEnd, SWT.BORDER);
    eodt.setTextLimit(4);

    Label lblHours_1 = new Label(compositeEnd, SWT.NONE);
    lblHours_1.setText(Messages.Tageseinteilung_lblHours_1_text);

    reload();
    cbBereich.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int idx = cbBereich.getSelectionIndex();
            if (idx != -1) {
                save();
                actBereich = idx;
                reload();
            }
        }

    });
    return ret;
}

From source file:ch.elexis.base.ch.labortarif_2009.ui.dialogs.EalSelektor.java

License:Open Source License

public EalSelektor(Shell shell) {
    super(shell);
    setTitle("EAL Code Selektion");

    setListLabelProvider(new LabelProvider() {
        @Override// ww  w.j  a  va 2s  . co m
        public String getText(Object element) {
            if (element == null) {
                return "";
            }
            return labelCache.get((Labor2009Tarif) element);
        }
    });
}

From source file:ch.elexis.base.messages.MsgDetailDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    ret.setLayout(new GridLayout(4, false));

    Label lblMessageInfo = new Label(ret, SWT.NONE);
    lblMessageInfo.setLayoutData(SWTHelper.getFillGridData(4, true, 1, false));
    String msgLabel = (incomingMsg == null) ? new TimeTool().toString(TimeTool.FULL_GER)
            : new TimeTool(incomingMsg.get(Message.FLD_TIME)).toString(TimeTool.FULL_GER);
    lblMessageInfo.setText(Messages.MsgDetailDialog_messageDated + msgLabel);

    new Label(ret, SWT.NONE).setText(Messages.MsgDetailDialog_from);
    lblFrom = new Label(ret, SWT.NONE);

    new Label(ret, SWT.NONE).setText(Messages.MsgDetailDialog_to);
    cbTo = new ComboViewer(ret, SWT.SINGLE | SWT.READ_ONLY);
    cbTo.setContentProvider(ArrayContentProvider.getInstance());
    cbTo.setLabelProvider(new LabelProvider() {
        @Override//  w  w w  .  j av a2  s .  c o m
        public String getText(Object element) {
            Anwender anw = (Anwender) element;
            return anw.getLabel();
        }
    });
    cbTo.setInput(users);
    cbTo.setSelection(new StructuredSelection(users.get(0)));

    new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(SWTHelper.getFillGridData(4, true, 1, false));

    if (incomingMsg != null) {
        lblFrom.setText(incomingMsg.getSender().getLabel());
        Anwender sender = null;
        for (Anwender anwender : users) {
            if (incomingMsg.getDest().getId().equals(anwender.getId())) {
                sender = anwender;
                break;
            }
        }
        if (sender != null) {
            cbTo.setSelection(new StructuredSelection(sender));
        }

        cbTo.getCombo().setEnabled(false);

        new Label(ret, SWT.NONE).setText(Messages.MsgDetailDialog_message);
        Label lblIncomingMsg = new Label(ret, SWT.None);
        lblIncomingMsg.setLayoutData(SWTHelper.getFillGridData(3, true, 1, true));
        lblIncomingMsg.setText(incomingMsg.get(Message.FLD_TEXT));

        new Label(ret, SWT.NONE).setText(Messages.MsgDetailDialog_answer);
    } else {
        lblFrom.setText(CoreHub.actUser.getLabel());
        new Label(ret, SWT.NONE).setText(Messages.MsgDetailDialog_message);
    }

    txtMessage = SWTHelper.createText(ret, 1, SWT.BORDER);
    txtMessage.setLayoutData(SWTHelper.getFillGridData(3, true, 1, true));
    txtMessage.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (txtMessage.getText() != null && txtMessage.getText().length() > 0) {
                getShell().setDefaultButton(bAnswer);
            } else {
                getShell().setDefaultButton(bOK);
            }
        }
    });

    return ret;
}

From source file:ch.elexis.core.ui.contacts.controls.StammDatenComposite.java

License:Open Source License

public StammDatenComposite(Composite parent, int style) {
    super(parent, style);
    decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
    tdlp = new TableDecoratingLabelProvider(
            new ContactSelectorObservableMapLabelProvider(new ObservableMap[] {}), decorator);

    setLayout(new GridLayout(6, false));

    { // HEADER/*from   w ww. j a v  a2 s . c  o m*/
        compositeHeader = new Composite(this, SWT.NONE);
        compositeHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 6, 1));
        compositeHeader.setLayout(new GridLayout(3, false));

        lblContactType = new Label(compositeHeader, SWT.NONE);

        lblHeadline = new Label(compositeHeader, SWT.NONE);
        lblHeadline.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        lblCode = new Label(compositeHeader, SWT.NONE);
        GridData gd_lblCode = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gd_lblCode.widthHint = 40;
        lblCode.setLayoutData(gd_lblCode);
    }

    { // TYPE_PERSON - Title prefix
        txtTitleFront = new Text(this, SWT.BORDER);
        gd_txtTitleFront = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gd_txtTitleFront.widthHint = 60;
        txtTitleFront.setLayoutData(gd_txtTitleFront);
        txtTitleFront.setMessage("Titel");
        ContentProposalAdapter cpaTitleFront = new ContentProposalAdapter(txtTitleFront,
                new TextContentAdapter(),
                new TitleProposalProvider(TitleProposalProvider.TITLE_POSITION_PREFIX), null, null);
        cpaTitleFront.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    }

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

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

    { // TYPE_PERSON - Title back
        txtTitleBack = new Text(this, SWT.BORDER);
        gd_txtTitleBack = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gd_txtTitleBack.widthHint = 60;
        txtTitleBack.setLayoutData(gd_txtTitleBack);
        txtTitleBack.setMessage("Titel");
        ContentProposalAdapter cpaTitleBack = new ContentProposalAdapter(txtTitleBack, new TextContentAdapter(),
                new TitleProposalProvider(TitleProposalProvider.TITLE_POSITION_SUFFIX), null, null);
        cpaTitleBack.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    }

    { // TYPE_PERSON - Sex
        comboViewerSex = new ComboViewer(this, SWT.NONE);
        gd_comboSex = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        comboViewerSex.getCombo().setLayoutData(gd_comboSex);
        comboViewerSex.setContentProvider(ArrayContentProvider.getInstance());
        comboViewerSex.setLabelProvider(new LabelProvider() {
            @Override
            public String getText(Object element) {
                switch ((ContactGender) element) {
                case FEMALE:
                    return "W";
                case MALE:
                    return "M";
                case UNDEFINED:
                    return "X";
                default:
                    return "?";
                }
            }
        });
        comboViewerSex.setInput(ContactGender.values());
    }
    { // TYPE_PERSON - Birthday
        dateTimeDob = new DateTime(this, SWT.BORDER | SWT.LONG);
        gd_dateTimeDob = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        dateTimeDob.setLayoutData(gd_dateTimeDob);
    }

    Group grpAddress = new Group(this, SWT.NONE);
    grpAddress.setLayout(new GridLayout(3, false));
    grpAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 7, 1));
    grpAddress.setText("Adresse");
    {
        // TODO: Default selection according to current Mandant's country
        comboViewerCountry = new ComboViewer(grpAddress, SWT.NONE);
        GridData gd_combo_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
        gd_combo_1.widthHint = 55;
        comboViewerCountry.getCombo().setLayoutData(gd_combo_1);
        comboViewerCountry.setContentProvider(ArrayContentProvider.getInstance());
        comboViewerCountry.setInput(Country.values());
        comboViewerCountry.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                Country selCountry = (Country) ((StructuredSelection) event.getSelection()).getFirstElement();
                if (selCountry == Country.NDF) {
                    comboViewerCountry.getCombo()
                            .setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
                    ContactGeonames.setCountry(null);
                } else {
                    comboViewerCountry.getCombo()
                            .setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
                    ContactGeonames.setCountry(selCountry);
                }

            }
        });
    }
    {
        txtCity = new Text(grpAddress, SWT.BORDER);
        txtCity.setMessage("Ortschaft");
        txtCity.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        ContentProposalAdapter cpaCity = new ContentProposalAdapter(txtCity, new TextContentAdapter(), cityIP,
                null, null);
        cpaCity.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
        cpaCity.addContentProposalListener(new IContentProposalListener() {
            @Override
            public void proposalAccepted(IContentProposal proposal) {
                txtZIP.setText(cityIP.findZipForCityName(proposal.getContent()));
            }
        });
    }
    { // ZIP
        txtZIP = new Text(grpAddress, SWT.BORDER);
        txtZIP.setMessage("PLZ");
        txtZIP.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        txtZIP.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
                String currZip = ((Text) e.widget).getText();
                if (currZip == null || currZip.length() < 4)
                    return;
                streetIP.setZip(currZip);
            }
        });

        ContentProposalAdapter cpaZip = new ContentProposalAdapter(txtZIP, new TextContentAdapter(), zipIP,
                null, null);
        cpaZip.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
        cpaZip.addContentProposalListener(new IContentProposalListener() {
            @Override
            public void proposalAccepted(IContentProposal proposal) {
                txtCity.setText(zipIP.findCityNameForZip(proposal.getContent()));
            }
        });
    }

    Label lblImageCountry = new Label(grpAddress, SWT.NONE);
    GridData gd_lblImageCountry = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_lblImageCountry.widthHint = 55;
    lblImageCountry.setLayoutData(gd_lblImageCountry);

    {
        txtStreet = new Text(grpAddress, SWT.BORDER);
        txtStreet.setMessage("Strasse, Hausnummer");
        txtStreet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

        ContentProposalAdapter cpaStreet = new ContentProposalAdapter(txtStreet, new TextContentAdapter(),
                streetIP, null, null);
        cpaStreet.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    }

    Group grpKontaktdaten = new Group(this, SWT.NONE);
    grpKontaktdaten.setText("Kontaktdaten");
    grpKontaktdaten.setLayout(new GridLayout(4, false));
    grpKontaktdaten.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 7, 1));

    Label lblImgPhone = new Label(grpKontaktdaten, SWT.NONE);
    lblImgPhone.setImage(Images.IMG_TELEPHONE.getImage());
    lblImgPhone.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    txtTelefon = new Text(grpKontaktdaten, SWT.BORDER);
    txtTelefon.setMessage("Telefon-Nummer");
    txtTelefon.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtTelefon.addFocusListener(preDialFocuListener);

    Label lblImgePhone2 = new Label(grpKontaktdaten, SWT.NONE);
    lblImgePhone2.setImage(Images.IMG_TELEPHONE.getImage());
    lblImgePhone2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    txtTelefon2 = new Text(grpKontaktdaten, SWT.BORDER);
    txtTelefon2.setMessage("Telefon-Nummer");
    txtTelefon2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtTelefon2.addFocusListener(preDialFocuListener);

    Label lblImgMobilePhone = new Label(grpKontaktdaten, SWT.NONE);
    lblImgMobilePhone.setImage(Images.IMG_MOBILEPHONE.getImage());
    lblImgMobilePhone.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    txtMobil = new Text(grpKontaktdaten, SWT.BORDER);
    txtMobil.setMessage("Handy-Nummer");
    txtMobil.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtMobil.addFocusListener(preDialFocuListener);

    Label lblImgFax = new Label(grpKontaktdaten, SWT.NONE);
    lblImgFax.setImage(Images.IMG_FAX.getImage());
    lblImgFax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    txtFax = new Text(grpKontaktdaten, SWT.BORDER);
    txtFax.setMessage("Fax-Nummer");
    txtFax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtFax.addFocusListener(preDialFocuListener);

    btnEmail = new Button(grpKontaktdaten, SWT.FLAT);
    btnEmail.setImage(Images.IMG_MAIL.getImage());
    btnEmail.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnEmail.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                URI uriMailTo = new URI("mailto", txtEmail.getText(), null);
                Desktop.getDesktop().mail(uriMailTo);
            } catch (URISyntaxException | IOException ex) {
                log.warn("Error opening URI", ex);
            }
        }
    });

    txtEmail = new Text(grpKontaktdaten, SWT.BORDER);
    txtEmail.setMessage("E-Mail Adresse");
    txtEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    btnWebsite = new Button(grpKontaktdaten, SWT.FLAT);
    btnWebsite.setImage(Images.IMG_WEB.getImage());
    btnWebsite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnWebsite.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                URI uriURL = new URI(txtWebsite.getText());
                if (!uriURL.isAbsolute()) {
                    uriURL = new URI("http://" + txtWebsite.getText());
                }
                Desktop.getDesktop().browse(uriURL);
            } catch (URISyntaxException | IOException ex) {
                log.warn("Error opening URI", ex);
            }
        }
    });

    txtWebsite = new Text(grpKontaktdaten, SWT.BORDER);
    txtWebsite.setMessage("Webseite");
    txtWebsite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    { // Notes
        Group grpNotes = new Group(this, SWT.NONE);
        grpNotes.setLayout(new GridLayout(1, false));
        grpNotes.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 7, 1));
        grpNotes.setText("Notizen");
        txtNotes = new Text(grpNotes, SWT.V_SCROLL | SWT.WRAP);
        GridData gd_txtNotes = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
        gd_txtNotes.heightHint = (int) (5 * txtNotes.getFont().getFontData()[0].height);
        txtNotes.setLayoutData(gd_txtNotes);
    }

    initDataBindings();
}

From source file:ch.elexis.core.ui.contacts.views.Patientenblatt2.java

License:Open Source License

void recreateUserpanel() {
    // cUserfields.setRedraw(false);
    if (ipp != null) {
        ipp.dispose();/*from   w ww .  java 2s.co m*/
        ipp = null;
    }

    ArrayList<InputData> fields = new ArrayList<InputData>(20);
    fields.add(new InputData(Messages.Patientenblatt2_name, Patient.FLD_NAME, InputData.Typ.STRING, null)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_firstname, Patient.FLD_FIRSTNAME, InputData.Typ.STRING,
            null)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_birthdate, Patient.BIRTHDATE, InputData.Typ.DATE, null)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_sex, Patient.FLD_SEX, null,
            new String[] { Person.FEMALE, Person.MALE }, false));

    IStructuredSelectionResolver isr = new IStructuredSelectionResolver() {
        @Override
        public StructuredSelection resolveStructuredSelection(String value) {
            MaritalStatus selection = MaritalStatus.byNumericSafe(value);
            return new StructuredSelection(selection);
        }
    };
    fields.add(new InputData(Messages.Patientenblatt2_civilState, Patient.FLD_EXTINFO,
            PatientConstants.FLD_EXTINFO_MARITAL_STATUS, Typ.COMBO_VIEWER, ArrayContentProvider.getInstance(),
            new LabelProvider() {
                @Override
                public String getText(Object element) {
                    MaritalStatus ms = (MaritalStatus) element;
                    if (ms != null) {
                        return ms.getLocaleText();
                    }
                    return super.getText(element);
                }
            }, isr, MaritalStatus.values()));

    fields.add(
            new InputData(Messages.Patientenblatt2_phone1, Patient.FLD_PHONE1, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$
    fields.add(
            new InputData(Messages.Patientenblatt2_phone2, Patient.FLD_PHONE2, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_mobile, Patient.MOBILE, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_fax, Patient.FLD_FAX, InputData.Typ.STRING, null, 30)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_email, Patient.FLD_E_MAIL, // $NON-NLS-1$
            new LabeledInputField.IExecLinkProvider() {
                @Override
                public void executeString(InputData ltf) {
                    if (ltf.getText().length() == 0)
                        return;
                    try {
                        URI uriMailTo = new URI("mailto", ltf.getText(), null);
                        Desktop.getDesktop().mail(uriMailTo);
                    } catch (URISyntaxException e1) {
                        Status status = new Status(IStatus.WARNING, Hub.PLUGIN_ID,
                                "Error in using mail address " + ltf);
                        StatusManager.getManager().handle(status, StatusManager.SHOW);
                    } catch (IOException e2) {
                        Status status = new Status(IStatus.WARNING, Hub.PLUGIN_ID,
                                "Error in using mail address " + ltf);
                        StatusManager.getManager().handle(status, StatusManager.SHOW);
                    }
                }
            }));
    fields.add(new InputData(Messages.Patientenblatt2_group, Patient.FLD_GROUP, InputData.Typ.STRING, null)); // $NON-NLS-1$
    fields.add(new InputData(Messages.Patientenblatt2_balance, Patient.FLD_BALANCE,
            new LabeledInputField.IContentProvider() { // $NON-NLS-1$

                public void displayContent(PersistentObject po, InputData ltf) {
                    ltf.setText(actPatient.getKontostand().getAmountAsString());
                }

                public void reloadContent(PersistentObject po, InputData ltf) {
                    if (new AddBuchungDialog(getShell(), actPatient).open() == Dialog.OK) {
                        ltf.setText(actPatient.getKontostand().getAmountAsString());
                    }
                }

            }));
    fields.add(new InputData(Messages.Patientenblatt2_regularPhysician, PatientConstants.FLD_EXTINFO_STAMMARZT,
            new LabeledInputField.IContentProvider() { // $NON-NLS-1$

                public void displayContent(PersistentObject po, InputData ltf) {
                    Patient p = (Patient) po;
                    String result = "";
                    if (p.getStammarzt() != null && p.getStammarzt().exists()) {
                        result = p.getStammarzt().getLabel(true);
                    }
                    ltf.setText(result);
                }

                public void reloadContent(PersistentObject po, InputData ltf) {
                    if (bLocked) {
                        return;
                    }
                    KontaktSelektor ks = new KontaktSelektor(getShell(), Kontakt.class,
                            Messages.Patientenblatt2_selectRegularPhysicianTitle,
                            Messages.Patientenblatt2_selectRegularPhysicianMessage, null);
                    ks.enableEmptyFieldButton();
                    if (ks.open() == Dialog.OK) {
                        Object contactSel = ks.getSelection();
                        if (contactSel == null) {
                            ((Patient) po).removeStammarzt();
                            ltf.setText("");
                        } else {
                            Kontakt k = (Kontakt) contactSel;
                            ((Patient) po).setStammarzt(k);
                            ltf.setText(k.getLabel(true));
                        }
                    }
                }
            }));

    fields.add(new InputData(Messages.Patientenblatt2_ahvNumber, XidConstants.DOMAIN_AHV,
            new LabeledInputField.IContentProvider() {
                public void displayContent(PersistentObject po, InputData ltf) {
                    Patient p = (Patient) po;
                    ltf.setText(p.getXid(XidConstants.DOMAIN_AHV));
                }

                public void reloadContent(final PersistentObject po, final InputData ltf) {
                    if (bLocked) {
                        return;
                    }
                    ArrayList<String> extFlds = new ArrayList<String>();
                    Kontakt k = (Kontakt) po;
                    for (String dom : Xid.getXIDDomains()) {
                        XIDDomain xd = Xid.getDomain(dom);
                        if ((k.istPerson() && xd.isDisplayedFor(Person.class))
                                || (k.istOrganisation() && xd.isDisplayedFor(Organisation.class))) {
                            extFlds.add(Xid.getSimpleNameForXIDDomain(dom) + "=" + dom); //$NON-NLS-1$
                        } else if (k.istOrganisation() && xd.isDisplayedFor(Labor.class)) {
                            extFlds.add(Xid.getSimpleNameForXIDDomain(dom) + "=" + dom);
                        }
                    }

                    KontaktExtDialog dlg = new KontaktExtDialog(UiDesk.getTopShell(), (Kontakt) po,
                            extFlds.toArray(new String[0]));
                    dlg.open();
                    Patient p = (Patient) po;
                    ltf.setText(p.getXid(XidConstants.DOMAIN_AHV));
                }
            }));

    fields.add(new InputData(Messages.Patientenblatt2_legalGuardian,
            PatientConstants.FLD_EXTINFO_LEGAL_GUARDIAN, new LabeledInputField.IContentProvider() {
                @Override
                public void displayContent(PersistentObject po, InputData ltf) {
                    Patient p = (Patient) po;
                    String guardianLabel = "";
                    Kontakt legalGuardian = p.getLegalGuardian();
                    if (legalGuardian != null && legalGuardian.exists()) {
                        guardianLabel = legalGuardian.get(Kontakt.FLD_NAME1) + " "
                                + legalGuardian.get(Kontakt.FLD_NAME2);
                    }
                    ltf.setText(guardianLabel);
                }

                @Override
                public void reloadContent(PersistentObject po, InputData ltf) {
                    if (bLocked) {
                        return;
                    }
                    KontaktSelektor ks = new KontaktSelektor(getShell(), Kontakt.class,
                            Messages.Patientenblatt2_selectLegalGuardianTitle,
                            Messages.Patientenblatt2_selectLegalGuardianMessage, null);
                    ks.enableEmptyFieldButton();
                    if (ks.open() == Dialog.OK) {
                        String guardianLabel = "";
                        Object contactSel = ks.getSelection();
                        Kontakt legalGuardian = null;

                        // get legal guardian if one is defined
                        if (contactSel != null) {
                            legalGuardian = (Kontakt) contactSel;
                            guardianLabel = legalGuardian.get(Kontakt.FLD_NAME1) + " "
                                    + legalGuardian.get(Kontakt.FLD_NAME2);
                        }
                        ((Patient) po).setLegalGuardian(legalGuardian);
                        ltf.setText(guardianLabel);
                    }
                }
            }));

    String[] userfields = CoreHub.userCfg.get(CFG_EXTRAFIELDS, StringConstants.EMPTY)
            .split(StringConstants.COMMA);
    for (String extfield : userfields) {
        if (!StringTool.isNothing(extfield)) {
            fields.add(new InputData(extfield, Patient.FLD_EXTINFO, InputData.Typ.STRING, extfield));
        }
    }
    ipp = new InputPanel(cUserfields, 3, 3, fields.toArray(new InputData[0]));
    ipp.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    ipp.changed(ipp.getChildren());
    // cUserfields.setRedraw(true);
    cUserfields.setBounds(ipp.getBounds());

    refresh();
    if (actPatient != null) {
        setPatient(actPatient);
    }
    layout(true);
}

From source file:ch.elexis.core.ui.dialogs.DiagnoseSelektor.java

License:Open Source License

public DiagnoseSelektor(Shell shell) {
    super(shell);
    setTitle(Messages.DiagnoseSelektorDialog_Title);

    // create a list of all diagnoses
    java.util.List<IConfigurationElement> list = Extensions
            .getExtensions(ExtensionPointConstantsUi.DIAGNOSECODE);

    diagnoses.add(new NoDiagnose());

    if (list != null) {
        for (IConfigurationElement ic : list) {
            try {
                PersistentObjectFactory po = (PersistentObjectFactory) ic
                        .createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_ELF);
                CodeSelectorFactory codeSelectorFactory = (CodeSelectorFactory) ic
                        .createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CSF);
                // get all available diagnoses available (TI can not be Queried as it is
                // not in the database)
                if (!(codeSelectorFactory.getCodeSystemName().equalsIgnoreCase("TI-Code"))) { //$NON-NLS-1$
                    if (IDiagnose.class.isAssignableFrom(codeSelectorFactory.getElementClass())) {
                        Query<IDiagnose> qd = new Query<IDiagnose>(codeSelectorFactory.getElementClass());
                        diagnoses.addAll(qd.execute());
                    }//from   w ww . jav  a2s .c om
                } else {
                    // get TI Code via content provider
                    CommonViewer cv = new CommonViewer();
                    ViewerConfigurer vc = codeSelectorFactory.createViewerConfigurer(new CommonViewer());
                    cv.create(vc, shell, SWT.NONE, this);

                    ITreeContentProvider tcp = (ITreeContentProvider) vc.getContentProvider();
                    Object[] roots = tcp.getElements(null);
                    addDiagnoses(tcp, roots);

                    cv.dispose();
                }
            } catch (CoreException ex) {
                ExHandler.handle(ex);
            }
        }
    }

    setListLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element == null) {
                return "";
            }
            return ((IDiagnose) element).getLabel();
        }
    });

    setDetailsLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element == null) {
                return "";
            }
            return ((IDiagnose) element).getCodeSystemName() + " " + ((IDiagnose) element).getLabel();
        }
    });
}

From source file:ch.elexis.core.ui.dialogs.ImageChooser.java

License:Open Source License

public ImageChooser(Shell shell) {
    super(shell, new LabelProvider() {
        @Override// w  w w  . j a va  2 s  .c o  m
        public Image getImage(Object element) {
            if (element instanceof UiDBImage) {
                return ((UiDBImage) element).getImage();
            }
            return null;
        }

        @Override
        public String getText(Object element) {
            if (element instanceof DBImage) {
                return ((DBImage) element).getName();
            }
            return "?"; //$NON-NLS-1$
        }
    });
}

From source file:ch.elexis.core.ui.dialogs.KonsZumVerrechnenWizardDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    ret.setLayout(new GridLayout(4, false));
    cbMarked = new Button(ret, SWT.CHECK);
    cbMarked.setText(ALLMARKED);/*from   w w w  . ja v a  2 s . c  om*/
    cbMarked.setLayoutData(SWTHelper.getFillGridData(4, true, 1, false));
    cbBefore = new Button(ret, SWT.CHECK);
    cbBefore.setText(TREATMENTBEGINBEFORE);
    ddc1 = new DayDateCombo(ret, "", TAGEN_BZW_DEM); //$NON-NLS-1$
    ddc1.spinDaysBack();
    cbTime = new Button(ret, SWT.CHECK);
    cbTime.setText(TREATMENTENDBEFORE);

    ddc2 = new DayDateCombo(ret, "", TAGEN_BZW_DEM); //$NON-NLS-1$
    ddc2.spinDaysBack();
    int prev = CoreHub.localCfg.get(CONFIG + "beginBefore", 30) * -1; //$NON-NLS-1$
    TimeTool ttNow = new TimeTool();
    ttNow.addDays(prev);
    ddc1.setDays(prev);

    prev = CoreHub.localCfg.get(CONFIG + "endBefore", 20) * -1; //$NON-NLS-1$
    ddc2.setDays(prev);
    ddc1.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false));

    ddc2.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false));
    cbAmount = new Button(ret, SWT.CHECK);
    cbAmount.setText(TREATMENT_AMOUNTHIGHER);
    mi1 = new MoneyInput(ret);
    mi1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    mi1.setLayoutData(SWTHelper.getFillGridData(3, true, 1, false));

    cbQuartal = new Button(ret, SWT.CHECK);
    cbQuartal.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    cbQuartal.setText(TREATMENT_TRIMESTER);

    cbTimespan = new Button(ret, SWT.CHECK);
    cbTimespan.setText(TREATMENT_TIMESPAN);
    timespanFrom = new DateTime(ret, SWT.NONE);
    Label lblTill = new Label(ret, SWT.NONE);
    lblTill.setText(TREATMENT_TIMESPAN_TILL);
    timespanTo = new DateTime(ret, SWT.NONE);
    cbTimespan.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            timespanFrom.setEnabled(cbTimespan.getSelection());
            timespanTo.setEnabled(cbTimespan.getSelection());
        }
    });

    cbAccountingSys = new Button(ret, SWT.CHECK);
    cbAccountingSys.setText(TREATMENT_ACCOUNTING_SYS);
    cbAccountingSys.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            cAccountingSys.getCombo().setEnabled(cbAccountingSys.getSelection());
        }
    });
    cAccountingSys = new ComboViewer(ret, SWT.NONE);
    Combo combo = cAccountingSys.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
    cAccountingSys.setContentProvider(ArrayContentProvider.getInstance());
    cAccountingSys.setLabelProvider(new LabelProvider());
    String[] accSystems = Fall.getAbrechnungsSysteme();
    cAccountingSys.setInput(accSystems);
    cAccountingSys.setSelection(new StructuredSelection(accSystems[0]));

    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(SWTHelper.getFillGridData(4, true, 1, false));
    cbSkip = new Button(ret, SWT.CHECK);
    cbSkip.setText(SKIPSELECTION);
    cbSkip.setSelection(CoreHub.globalCfg.get(CFG_SKIP, false));
    cbBefore.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ddc1.setEnabled(cbBefore.getSelection());
        }

    });
    cbTime.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ddc2.setEnabled(cbTime.getSelection());
        }

    });

    cAccountingSys.getCombo().setEnabled(false);
    timespanFrom.setEnabled(false);
    timespanTo.setEnabled(false);
    ddc1.setEnabled(false);
    ddc2.setEnabled(false);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    new Label(ret, SWT.NONE);
    return ret;
}

From source file:ch.elexis.core.ui.dialogs.SelectFallNoObligationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    Composite areaComposite = new Composite(composite, SWT.NONE);
    areaComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    areaComposite.setLayout(new FormLayout());

    Label lbl = new Label(areaComposite, SWT.NONE);
    lbl.setText("Fall erstellen");

    ToolBarManager tbManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP);
    tbManager.add(GlobalActions.neuerFallAction);
    ToolBar toolbar = tbManager.createControl(areaComposite);

    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 5);
    fd.left = new FormAttachment(0, 5);
    lbl.setLayoutData(fd);/*  w ww . j  av a 2s  .  c  o  m*/

    fd = new FormData();
    fd.top = new FormAttachment(0, 5);
    fd.left = new FormAttachment(30, 5);
    toolbar.setLayoutData(fd);

    lbl = new Label(areaComposite, SWT.NONE);
    lbl.setText("Fall auswhlen");

    noOblFallCombo = new ComboViewer(areaComposite);

    noOblFallCombo.setContentProvider(new ArrayContentProvider());

    noOblFallCombo.setInput(getNoObligationFaelle());
    noOblFallCombo.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Fall) element).getLabel();
        }
    });

    if (lastSelectedFall != null)
        noOblFallCombo.setSelection(new StructuredSelection(lastSelectedFall));

    ElexisEventDispatcher.getInstance()
            .addListeners(new UpdateFallComboListener(noOblFallCombo, Fall.class, 0xff));

    fd = new FormData();
    fd.top = new FormAttachment(toolbar, 5);
    fd.left = new FormAttachment(0, 5);
    lbl.setLayoutData(fd);

    fd = new FormData();
    fd.top = new FormAttachment(toolbar, 5);
    fd.left = new FormAttachment(30, 5);
    fd.right = new FormAttachment(100, -5);
    noOblFallCombo.getControl().setLayoutData(fd);

    return areaComposite;
}