Example usage for org.eclipse.jface.fieldassist AutoCompleteField AutoCompleteField

List of usage examples for org.eclipse.jface.fieldassist AutoCompleteField AutoCompleteField

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist AutoCompleteField AutoCompleteField.

Prototype

public AutoCompleteField(Control control, IControlContentAdapter controlContentAdapter, String... proposals) 

Source Link

Document

Construct an AutoComplete field on the specified control, whose completions are characterized by the specified array of Strings.

Usage

From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java

License:Open Source License

/**
 * Load names./*from   w w  w  .  j a  v  a 2  s. co  m*/
 * @param contentComp the content comp
 */
private void loadNames(final Composite contentComp) {
    Composite namesComp = new Composite(contentComp, SWT.NONE);
    namesComp.setLayoutData(new GridData());
    ((GridData) namesComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) namesComp.getLayoutData()).grabExcessHorizontalSpace = true;
    namesComp.setLayout(new GridLayout());
    ((GridLayout) namesComp.getLayout()).numColumns = 5;
    ((GridLayout) namesComp.getLayout()).makeColumnsEqualWidth = false;
    ((GridLayout) namesComp.getLayout()).marginHeight = 0;
    ((GridLayout) namesComp.getLayout()).marginWidth = 0;
    for (int i = 0; i < _currentReference.getNameMods().size(); i++) {
        final NameMods n = _currentReference.getNameMods().get(i);

        Label label5 = new Label(namesComp, SWT.NONE);
        label5.setText(NLMessages.getString("Editor_name") + NLMessages.getString("Editor_reference_role")); //$NON-NLS-1$

        final Combo roleC = new Combo(namesComp, SWT.READ_ONLY);
        roleC.setData("name", i); //$NON-NLS-1$
        roleC.setEnabled(_mayWrite);
        roleC.setBackground(WHITE_COLOR);
        ComboViewer comboViewer = new ComboViewer(roleC);
        comboViewer.setContentProvider(ArrayContentProvider.getInstance());
        comboViewer.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(final Object element) {
                String str = (String) element;
                return NLMessages.getString("Editor_role_" + str); //$NON-NLS-1$
            }

        });

        comboViewer.setInput(AEConstants.REF_ROLETERM_CODE);
        comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection selection = event.getSelection();
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                String s = (String) obj;
                _currentReference.getNameMods().get((Integer) roleC.getData("name")) //$NON-NLS-1$
                        .getRoleMods().setRoleTerm(s);
            }

        });

        if (n.getRoleMods() != null && n.getRoleMods().getRoleTerm() != null) {
            StructuredSelection selection = new StructuredSelection(n.getRoleMods().getRoleTerm());
            comboViewer.setSelection(selection);
        } else {
            StructuredSelection selection = new StructuredSelection("aut"); //$NON-NLS-1$
            comboViewer.setSelection(selection);
            n.getRoleMods().setRoleTerm("aut"); //$NON-NLS-1$

        }
        Composite namepartsComp = new Composite(namesComp, SWT.NONE);
        namepartsComp.setLayoutData(new GridData());
        ((GridData) namepartsComp.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) namepartsComp.getLayoutData()).grabExcessHorizontalSpace = true;
        namepartsComp.setLayout(new GridLayout());
        ((GridLayout) namepartsComp.getLayout()).numColumns = n.getNameParts().size() * 2;
        ((GridLayout) namepartsComp.getLayout()).makeColumnsEqualWidth = false;
        ((GridLayout) namepartsComp.getLayout()).marginHeight = 0;

        int num = n.getNameParts().size();
        for (int j = 0; j < num; j++) {
            final NamePart namePart = n.getNameParts().get(j);

            if (namePart.getType() != null) {
                Label label5d = new Label(namepartsComp, SWT.NONE);
                label5d.setText(NLMessages.getString("Editor_name_" + namePart.getType()) + ":"); //$NON-NLS-1$
                label5d.pack();
            }
            final Text name = new Text(namepartsComp, SWT.BORDER);
            name.setData("name", i); //$NON-NLS-1$
            name.setData("nPart", j); //$NON-NLS-1$
            name.setEditable(_mayWrite);
            name.setBackground(WHITE_COLOR);
            final ControlDecoration decoValName = new ControlDecoration(name, SWT.LEFT | SWT.TOP);

            name.setLayoutData(new GridData());
            ((GridData) name.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) name.getLayoutData()).horizontalAlignment = SWT.FILL;

            name.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                    try {
                        vals = _mainSearcher.getFacets("reference", "namePart", namePart.getType(), null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(name, new TextContentAdapter(), vals);
                    validate();

                }

                @Override
                public void focusLost(final FocusEvent e) {
                    namePart.setNamePart(name.getText());
                    validate();
                }
            });
            name.addKeyListener(new KeyListener() {

                @Override
                public void keyPressed(final KeyEvent e) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void keyReleased(final KeyEvent e) {
                    namePart.setNamePart(name.getText());
                    validate();

                }
            });
            if (namePart.getNamePart() != null) {
                name.setText(namePart.getNamePart().trim());
            }
            if (_currentReference.getTitleInfo() != null && _currentReference.getTitleInfo().isValid()
                    && _currentReference.getNameMods() != null && !_currentReference.getNameMods().isEmpty()) {

                decoValName.setImage(null);
            } else {
                decoValName.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
            }
            // max 3 nameparts
            if (j == 2) {
                break;
            }
        }
        namepartsComp.layout();

        final Button addExtra = new Button(namesComp, SWT.PUSH);
        addExtra.setText("<+>"); //$NON-NLS-1$
        addExtra.setToolTipText(NLMessages.getString("Editor_add_extra_person"));
        addExtra.setLayoutData(_gridData);
        addExtra.setData("name", i); //$NON-NLS-1$
        addExtra.setEnabled((n.getAffiliation() == null && n.getDescription() == null) && _mayWrite);
        addExtra.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getNameMods().get((Integer) addExtra.getData("name")).setType(" "); //$NON-NLS-1$ //$NON-NLS-2$
                _currentReference.getNameMods().get((Integer) addExtra.getData("name")).setAffiliation(" "); //$NON-NLS-1$ //$NON-NLS-2$
                _currentReference.getNameMods().get((Integer) addExtra.getData("name")).setDescription(" "); //$NON-NLS-1$ //$NON-NLS-2$

                loadValues(_currentReference);

            }
        });
        addExtra.setLayoutData(new GridData());

        final Button deleteName = new Button(namesComp, SWT.PUSH);
        deleteName.setText("-"); //$NON-NLS-1$
        deleteName.setToolTipText(NLMessages.getString("Editor_remove_field"));
        // deleteName.setEnabled(_mayWrite && _currentReference.isValid());
        deleteName.setLayoutData(_gridData);
        deleteName.setData("name", i); //$NON-NLS-1$
        deleteName.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {

                _currentReference.getNameMods().removeElementAt((Integer) deleteName.getData("name")); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        if ((_currentReference.getTitleInfo() != null && _currentReference.getTitleInfo().getTitle() != null)
                || (_currentReference.getNameMods() != null && _currentReference.getNameMods().size() > 1)) {
            deleteName.setEnabled(_mayWrite);
        } else {
            deleteName.setEnabled(false);
        }
        deleteName.setLayoutData(new GridData());

        // if (i == _currentReference.getNameMods().size() -1)
        // {
        // final Button addName = new Button(namesComp, SWT.PUSH);
        //            addName.setText("+"); //$NON-NLS-1$
        // addName.setToolTipText(NLMessages.getString("Editor_add_name"));
        // addName.setEnabled(_mayWrite);
        // addName.setLayoutData(_gridData);
        // addName.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        // _currentReference.getNameMods().add(new NameMods(2));
        // loadValues(_currentReference);
        //
        //
        // } });
        // addName.setLayoutData(new GridData());
        // }
        // else{
        // new Label(namesComp, SWT.NONE);
        // }

        if (n.getType() != null && n.getAffiliation() != null && n.getDescription() != null) {
            Composite namesComp2 = new Composite(namesComp, SWT.NONE);
            namesComp2.setLayoutData(new GridData());
            ((GridData) namesComp2.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) namesComp2.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) namesComp2.getLayoutData()).horizontalSpan = 9;

            namesComp2.setLayout(new GridLayout());
            ((GridLayout) namesComp2.getLayout()).numColumns = 9;
            ((GridLayout) namesComp2.getLayout()).makeColumnsEqualWidth = false;
            int span = 0;
            if (n.getType() != null) {
                Label label6 = new Label(namesComp2, SWT.NONE);
                label6.setText(NLMessages.getString("Editor_type")); //$NON-NLS-1$
                final Combo typeCombo = new Combo(namesComp2, SWT.READ_ONLY);
                typeCombo.setData("name", i); //$NON-NLS-1$
                typeCombo.setEnabled(_mayWrite);
                typeCombo.setBackground(WHITE_COLOR);
                typeCombo.setText(n.getType().trim());
                typeCombo.setLayoutData(new GridData());
                // ((GridData)
                // typeCombo.getLayoutData()).horizontalAlignment =
                // SWT.FILL;
                // ((GridData)
                // typeCombo.getLayoutData()).grabExcessHorizontalSpace =
                // true;
                ((GridData) typeCombo.getLayoutData()).horizontalSpan = 1;
                ComboViewer typeComboViewer = new ComboViewer(typeCombo);
                typeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
                typeComboViewer.setLabelProvider(new LabelProvider() {

                    @Override
                    public String getText(final Object element) {
                        String str = (String) element;
                        return NLMessages.getString("Editor_name_type_" + str); //$NON-NLS-1$
                    }

                });

                typeComboViewer.setInput(AEConstants.REF_NAME_TYPE);
                typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                    @Override
                    public void selectionChanged(final SelectionChangedEvent event) {
                        ISelection selection = event.getSelection();
                        Object obj = ((IStructuredSelection) selection).getFirstElement();
                        String s = (String) obj;
                        _currentReference.getNameMods().get((Integer) typeCombo.getData("name")) //$NON-NLS-1$
                                .setType(s);
                    }

                });
                if (n.getType().trim().length() > 0) {
                    StructuredSelection selection = new StructuredSelection(n.getType());
                    typeComboViewer.setSelection(selection);
                } else {
                    StructuredSelection selection = new StructuredSelection("personal"); //$NON-NLS-1$
                    typeComboViewer.setSelection(selection);
                    _currentReference.getNameMods().get((Integer) typeCombo.getData("name")) //$NON-NLS-1$
                            .setType("personal"); //$NON-NLS-1$
                }
                span = 2;
            }
            if (n.getAffiliation() != null) {
                Label label7 = new Label(namesComp2, SWT.NONE);
                label7.setText(NLMessages.getString("Editor_affiliation")); //$NON-NLS-1$
                final Text aff = new Text(namesComp2, SWT.BORDER);
                aff.setData("name", i); //$NON-NLS-1$
                aff.setEditable(_mayWrite);
                aff.setBackground(WHITE_COLOR);
                aff.setText(n.getAffiliation().trim());
                aff.setLayoutData(new GridData());
                ((GridData) aff.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) aff.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) aff.getLayoutData()).horizontalSpan = 2;

                aff.addFocusListener(new FocusListener() {
                    @Override
                    public void focusGained(final FocusEvent e) {
                        String[] vals = new String[] { "test2" }; //$NON-NLS-2$
                        try {
                            vals = _mainSearcher.getFacets("reference", "affiliation", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                        } catch (Exception e1) {

                            e1.printStackTrace();
                        }
                        new AutoCompleteField(aff, new TextContentAdapter(), vals);
                    }

                    @Override
                    public void focusLost(final FocusEvent e) {
                        _currentReference.getNameMods().get((Integer) aff.getData("name")) //$NON-NLS-1$
                                .setAffiliation(aff.getText());
                    }
                });
                span = span + 3;

            }
            if (n.getDescription() != null) {
                Label label8 = new Label(namesComp2, SWT.NONE);
                label8.setText(NLMessages.getString("Editor_description")); //$NON-NLS-1$
                final Text desc = new Text(namesComp2, SWT.BORDER);
                desc.setData("name", i); //$NON-NLS-1$
                desc.setEditable(_mayWrite);
                desc.setBackground(WHITE_COLOR);
                desc.setText(n.getDescription().trim());
                desc.setLayoutData(new GridData());
                ((GridData) desc.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) desc.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) desc.getLayoutData()).horizontalSpan = 2;
                desc.addFocusListener(new FocusListener() {
                    @Override
                    public void focusGained(final FocusEvent e) {
                        String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                        try {
                            vals = _mainSearcher.getFacets("reference", "description", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                        } catch (Exception e1) {

                            e1.printStackTrace();
                        }
                        new AutoCompleteField(desc, new TextContentAdapter(), vals);
                    }

                    @Override
                    public void focusLost(final FocusEvent e) {
                        _currentReference.getNameMods().get((Integer) desc.getData("name")) //$NON-NLS-1$
                                .setDescription(desc.getText());
                    }
                });
                span = span + 3;

            }
            if (span % 8 != 0) {
                Label bl = new Label(namesComp2, SWT.NONE);
                bl.setLayoutData(new GridData());
                ((GridData) bl.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) bl.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) bl.getLayoutData()).horizontalSpan = 8 - span;
            }
            final Button delExtra = new Button(namesComp2, SWT.PUSH);
            delExtra.setText("-"); //$NON-NLS-1$
            delExtra.setToolTipText(NLMessages.getString("Editor_remove_name_extra"));
            delExtra.setEnabled(_mayWrite);
            delExtra.setLayoutData(_gridData);
            delExtra.setData("name", i); //$NON-NLS-1$

            delExtra.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    _currentReference.getNameMods().get((Integer) addExtra.getData("name")).setType(null); //$NON-NLS-1$ //$NON-NLS-2$
                    _currentReference.getNameMods().get((Integer) addExtra.getData("name")) //$NON-NLS-1$
                            .setAffiliation(null); //$NON-NLS-2$
                    _currentReference.getNameMods().get((Integer) addExtra.getData("name")) //$NON-NLS-1$
                            .setDescription(null); //$NON-NLS-2$

                    loadValues(_currentReference);

                }
            });
            delExtra.setLayoutData(new GridData());
        }

    }

}

From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java

License:Open Source License

/**
 * Load note./*from   w w w . j  a  va2 s .c om*/
 * @param contentComp the content comp
 */
private void loadNote(final Composite contentComp) {
    Composite noteComp = new Composite(contentComp, SWT.NONE);
    noteComp.setLayoutData(new GridData());
    ((GridData) noteComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) noteComp.getLayoutData()).grabExcessHorizontalSpace = true;
    noteComp.setLayout(new GridLayout());
    ((GridLayout) noteComp.getLayout()).numColumns = 3;
    ((GridLayout) noteComp.getLayout()).makeColumnsEqualWidth = false;

    if (_currentReference.getNote().getNote() != null) {
        Label label17 = new Label(noteComp, SWT.None);
        label17.setText(NLMessages.getString("Editor_note")); //$NON-NLS-1$
        final Text note = new Text(noteComp, SWT.BORDER);
        note.setEditable(_mayWrite);
        note.setBackground(WHITE_COLOR);
        note.setLayoutData(_gridData);
        note.setText(_currentReference.getNote().getNote().trim());
        note.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "note", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(note, new TextContentAdapter(), vals);
            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getNote().setNote(note.getText());
            }
        });
        final Button delNote = new Button(noteComp, SWT.PUSH);
        delNote.setText("-"); //$NON-NLS-1$
        delNote.setToolTipText(NLMessages.getString("Editor_remove_field"));
        delNote.setEnabled(_mayWrite);
        delNote.setLayoutData(_gridData);
        delNote.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.setNote(null); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        delNote.setLayoutData(new GridData());

    }
    if (_currentReference.getNote().getType() != null) {
        Label label18 = new Label(noteComp, SWT.None);
        label18.setText(NLMessages.getString("Editor_noteType")); //$NON-NLS-1$
        final Text nType = new Text(noteComp, SWT.BORDER);
        nType.setEditable(_mayWrite);
        nType.setBackground(WHITE_COLOR);
        nType.setLayoutData(_gridData);
        nType.setText(_currentReference.getNote().getType().trim());
        nType.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "note", "type", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(nType, new TextContentAdapter(), vals);
            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getNote().setType(nType.getText());
            }
        });

    }

}

From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java

License:Open Source License

/**
 * Load origin info./*from ww  w  . ja v a2s .  co m*/
 * @param contentComp the content comp
 */
private void loadOriginInfo(final Composite contentComp) {
    Composite originComp = new Composite(contentComp, SWT.NONE);
    originComp.setLayoutData(new GridData());
    ((GridData) originComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) originComp.getLayoutData()).grabExcessHorizontalSpace = true;
    originComp.setLayout(new GridLayout());
    ((GridLayout) originComp.getLayout()).numColumns = 9;
    ((GridLayout) originComp.getLayout()).makeColumnsEqualWidth = false;

    OriginInfo oi = _currentReference.getOriginInfo();
    if (oi.getPlaceTerm() != null) {
        Label label13 = new Label(originComp, SWT.NONE);
        label13.setText(NLMessages.getString("Editor_place")); //$NON-NLS-1$
        final Text place = new Text(originComp, SWT.BORDER);
        place.setEditable(_mayWrite);
        place.setBackground(WHITE_COLOR);
        place.setLayoutData(new GridData());
        ((GridData) place.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) place.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) place.getLayoutData()).horizontalSpan = 7;
        place.setText(oi.getPlaceTerm().trim());
        place.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "placeTerm", "text", null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(place, new TextContentAdapter(), vals);
            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getOriginInfo().setPlaceTerm(place.getText());
            }
        });

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_field"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setPlaceTerm(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }
    if (oi.getPublisher() != null) {
        Label label12 = new Label(originComp, SWT.NONE);
        label12.setText(NLMessages.getString("Editor_publisher")); //$NON-NLS-1$
        final Text pub = new Text(originComp, SWT.BORDER);
        pub.setEditable(_mayWrite);
        pub.setBackground(WHITE_COLOR);
        pub.setLayoutData(new GridData());
        ((GridData) pub.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) pub.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) pub.getLayoutData()).horizontalSpan = 7;

        pub.setText(oi.getPublisher().trim());
        pub.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "publisher", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(pub, new TextContentAdapter(), vals);
            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getOriginInfo().setPublisher(pub.getText());
            }
        });

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_field"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setPublisher(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }

    if (oi.getDateCreated() != null) {
        Label label9 = new Label(originComp, SWT.NONE);
        label9.setText(NLMessages.getString("Editor_dateCreated")); //$NON-NLS-1$

        {
            Label labelDay = new Label(originComp, SWT.NONE);
            labelDay.setText(NLMessages.getString("Editor_day"));

            final Combo comboTimeDay = new Combo(originComp, SWT.READ_ONLY);
            comboTimeDay.setEnabled(_mayWrite);
            comboTimeDay.setBackground(WHITE_COLOR);
            comboTimeDay.setLayoutData(new GridData());
            ((GridData) comboTimeDay.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeDay.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeDay.setItems(AEConstants.DAYS);
            comboTimeDay.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreated().setDay(comboTimeDay.getSelectionIndex());
                }
            });
            Label labelMonth = new Label(originComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(originComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreated()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(originComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(originComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreated().setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateCreated().getYear() > 0) {
                comboTimeDay.select(oi.getDateCreated().getDay());
                comboTimeMonth.select(oi.getDateCreated().getMonth());
                spinnerTimeYear.setSelection(oi.getDateCreated().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateCreated(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());

    }
    if (oi.getDateCreatedTimespan() != null) {
        Composite timespanComp = new Composite(contentComp, SWT.NONE);
        timespanComp.setLayoutData(new GridData());
        ((GridData) timespanComp.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) timespanComp.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) timespanComp.getLayoutData()).horizontalSpan = 9;

        timespanComp.setLayout(new GridLayout());
        ((GridLayout) timespanComp.getLayout()).numColumns = 13;
        ((GridLayout) timespanComp.getLayout()).makeColumnsEqualWidth = false;
        Label label9 = new Label(timespanComp, SWT.NONE);
        label9.setText(NLMessages.getString("Editor_dateCreated") + " " + NLMessages.getString("Editor_from")); //$NON-NLS-1$

        {

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreatedTimespan().getDateFrom()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreatedTimespan().getDateFrom()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateCreatedTimespan().getDateFrom() != null
                    && oi.getDateCreatedTimespan().getDateFrom().getYear() > 0) {
                comboTimeMonth.select(oi.getDateCreatedTimespan().getDateFrom().getMonth());
                spinnerTimeYear.setSelection(oi.getDateCreatedTimespan().getDateFrom().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }
        {
            Label labelTo = new Label(timespanComp, SWT.NONE);
            labelTo.setText(NLMessages.getString("Editor_to"));

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreatedTimespan().getDateTo()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCreatedTimespan().getDateTo()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateCreatedTimespan().getDateTo() != null
                    && oi.getDateCreatedTimespan().getDateTo().getYear() > 0) {
                comboTimeMonth.select(oi.getDateCreatedTimespan().getDateTo().getMonth());
                spinnerTimeYear.setSelection(oi.getDateCreatedTimespan().getDateTo().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }

        final Button delDate = new Button(timespanComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateCreatedTimespan(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());

    }
    if (oi.getDateIssued() != null) {
        Label label9 = new Label(originComp, SWT.NONE);
        label9.setText(NLMessages.getString("Editor_dateIssued"));

        {
            Label labelDay = new Label(originComp, SWT.NONE);
            labelDay.setText(NLMessages.getString("Editor_day"));

            final Combo comboTimeDay = new Combo(originComp, SWT.READ_ONLY);
            comboTimeDay.setEnabled(_mayWrite);
            comboTimeDay.setBackground(WHITE_COLOR);
            comboTimeDay.setLayoutData(new GridData());
            ((GridData) comboTimeDay.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeDay.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeDay.setItems(AEConstants.DAYS);
            comboTimeDay.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssued().setDay(comboTimeDay.getSelectionIndex());
                }
            });
            Label labelMonth = new Label(originComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(originComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssued()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(originComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(originComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);

            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssued().setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateIssued().getYear() > 0) {
                comboTimeDay.select(oi.getDateIssued().getDay());
                comboTimeMonth.select(oi.getDateIssued().getMonth());
                spinnerTimeYear.setSelection(oi.getDateIssued().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }
        // final Button addDate = new Button(originComp, SWT.PUSH);
        //            addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_date_capture"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(oi.getDateCaptured() == null && _mayWrite);
        //
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        // _currentReference.getOriginInfo().setDateCaptured(new PdrDate(0,
        // 0, 0));
        // loadValues(_currentReference);
        // } });
        // addDate.setLayoutData(new GridData());

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateIssued(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());

    }
    if (oi.getDateIssuedTimespan() != null) {
        Composite timespanComp = new Composite(contentComp, SWT.NONE);
        timespanComp.setLayoutData(new GridData());
        ((GridData) timespanComp.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) timespanComp.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) timespanComp.getLayoutData()).horizontalSpan = 9;

        timespanComp.setLayout(new GridLayout());
        ((GridLayout) timespanComp.getLayout()).numColumns = 13;
        ((GridLayout) timespanComp.getLayout()).makeColumnsEqualWidth = false;
        Label label9 = new Label(timespanComp, SWT.NONE);
        label9.setText(NLMessages.getString("Editor_dateIssued") + " " + NLMessages.getString("Editor_from")); //$NON-NLS-1$

        {

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssuedTimespan().getDateFrom()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssuedTimespan().getDateFrom()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateIssuedTimespan().getDateFrom() != null
                    && oi.getDateIssuedTimespan().getDateFrom().getYear() > 0) {
                comboTimeMonth.select(oi.getDateIssuedTimespan().getDateFrom().getMonth());
                spinnerTimeYear.setSelection(oi.getDateIssuedTimespan().getDateFrom().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }
        {
            Label labelTo = new Label(timespanComp, SWT.NONE);
            labelTo.setText(NLMessages.getString("Editor_to"));

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssuedTimespan().getDateTo()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateIssuedTimespan().getDateTo()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateIssuedTimespan().getDateTo() != null
                    && oi.getDateIssuedTimespan().getDateTo().getYear() > 0) {
                comboTimeMonth.select(oi.getDateIssuedTimespan().getDateTo().getMonth());
                spinnerTimeYear.setSelection(oi.getDateIssuedTimespan().getDateTo().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }

        final Button delDate = new Button(timespanComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateIssuedTimespan(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }
    if (oi.getDateCaptured() != null) {
        Label label10 = new Label(originComp, SWT.NONE);
        label10.setText(NLMessages.getString("Editor_dateCaptured")); //$NON-NLS-1$
        {
            Label labelDay = new Label(originComp, SWT.NONE);
            labelDay.setText(NLMessages.getString("Editor_day"));
            final Combo comboTimeDayCap = new Combo(originComp, SWT.READ_ONLY);
            comboTimeDayCap.setEnabled(_mayWrite);
            comboTimeDayCap.setBackground(WHITE_COLOR);
            comboTimeDayCap.setLayoutData(new GridData());
            ((GridData) comboTimeDayCap.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeDayCap.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeDayCap.setItems(AEConstants.DAYS);
            comboTimeDayCap.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCaptured()
                            .setDay(comboTimeDayCap.getSelectionIndex());
                }
            });
            Label labelMonth = new Label(originComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));
            final Combo comboTimeMonthCap = new Combo(originComp, SWT.READ_ONLY);
            comboTimeMonthCap.setEnabled(_mayWrite);
            comboTimeMonthCap.setBackground(WHITE_COLOR);
            comboTimeMonthCap.setLayoutData(new GridData());
            ((GridData) comboTimeMonthCap.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonthCap.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonthCap.setItems(AEConstants.MONTHS);
            comboTimeMonthCap.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCaptured()
                            .setMonth(comboTimeMonthCap.getSelectionIndex());
                }
            });
            Label labelYear = new Label(originComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));
            final YearSpinner spinnerTimeYearCap = new YearSpinner(originComp, SWT.BORDER);
            spinnerTimeYearCap.setEnabled(_mayWrite);

            spinnerTimeYearCap.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCaptured()
                            .setYear(spinnerTimeYearCap.getSelection());
                }
            });
            if (oi.getDateCaptured().getYear() > 0) {
                comboTimeDayCap.select(oi.getDateCaptured().getDay());
                comboTimeMonthCap.select(oi.getDateCaptured().getMonth());
                spinnerTimeYearCap.setSelection(oi.getDateCaptured().getYear());
            } else {
                spinnerTimeYearCap.setSelection(0);
            }
        }
        // final Button addDate = new Button(originComp, SWT.PUSH);
        //            addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_add_date_copyright"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(oi.getCopyrightDate() == null && _mayWrite);
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        // _currentReference.getOriginInfo().setCopyrightDate(new PdrDate(0,
        // 0, 0));
        // loadValues(_currentReference);
        //
        // } });
        // addDate.setLayoutData(new GridData());

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateCaptured(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());

    }
    if (oi.getDateCapturedTimespan() != null) {
        Composite timespanComp = new Composite(contentComp, SWT.NONE);
        timespanComp.setLayoutData(new GridData());
        ((GridData) timespanComp.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) timespanComp.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) timespanComp.getLayoutData()).horizontalSpan = 9;

        timespanComp.setLayout(new GridLayout());
        ((GridLayout) timespanComp.getLayout()).numColumns = 13;
        ((GridLayout) timespanComp.getLayout()).makeColumnsEqualWidth = false;
        Label label9 = new Label(timespanComp, SWT.NONE);
        label9.setText(NLMessages.getString("Editor_dateCaptured") + " " + NLMessages.getString("Editor_from")); //$NON-NLS-1$

        {

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCapturedTimespan().getDateFrom()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCapturedTimespan().getDateFrom()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateCapturedTimespan().getDateFrom() != null
                    && oi.getDateCapturedTimespan().getDateFrom().getYear() > 0) {
                comboTimeMonth.select(oi.getDateCapturedTimespan().getDateFrom().getMonth());
                spinnerTimeYear.setSelection(oi.getDateCapturedTimespan().getDateFrom().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }
        {
            Label labelTo = new Label(timespanComp, SWT.NONE);
            labelTo.setText(NLMessages.getString("Editor_to"));

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCapturedTimespan().getDateTo()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getDateCapturedTimespan().getDateTo()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getDateCapturedTimespan().getDateTo() != null
                    && oi.getDateCapturedTimespan().getDateTo().getYear() > 0) {
                comboTimeMonth.select(oi.getDateCapturedTimespan().getDateTo().getMonth());
                spinnerTimeYear.setSelection(oi.getDateCapturedTimespan().getDateTo().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }

        final Button delDate = new Button(timespanComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setDateCapturedTimespan(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }
    if (oi.getCopyrightDate() != null) {
        Label label11 = new Label(originComp, SWT.NONE);
        label11.setText(NLMessages.getString("Editor_copyrightDate")); //$NON-NLS-1$
        {
            Label labelDay = new Label(originComp, SWT.NONE);
            labelDay.setText(NLMessages.getString("Editor_day"));
            final Combo comboTimeDayCop = new Combo(originComp, SWT.READ_ONLY);
            comboTimeDayCop.setEnabled(_mayWrite);
            comboTimeDayCop.setBackground(WHITE_COLOR);
            comboTimeDayCop.setLayoutData(new GridData());
            ((GridData) comboTimeDayCop.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeDayCop.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeDayCop.setItems(AEConstants.DAYS);
            comboTimeDayCop.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDate()
                            .setDay(comboTimeDayCop.getSelectionIndex());
                }
            });
            Label labelMonth = new Label(originComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));
            final Combo comboTimeMonthCop = new Combo(originComp, SWT.READ_ONLY);
            comboTimeMonthCop.setEnabled(_mayWrite);
            comboTimeMonthCop.setBackground(WHITE_COLOR);
            comboTimeMonthCop.setLayoutData(new GridData());
            ((GridData) comboTimeMonthCop.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonthCop.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonthCop.setItems(AEConstants.MONTHS);
            comboTimeMonthCop.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDate()
                            .setMonth(comboTimeMonthCop.getSelectionIndex());
                }
            });
            Label labelYear = new Label(originComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));
            final YearSpinner spinnerTimeYearCop = new YearSpinner(originComp, SWT.BORDER);
            spinnerTimeYearCop.setEnabled(_mayWrite);

            spinnerTimeYearCop.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDate()
                            .setYear(spinnerTimeYearCop.getSelection());
                }
            });
            if (oi.getCopyrightDate().getYear() > 0) {
                comboTimeDayCop.select(oi.getCopyrightDate().getDay());
                comboTimeMonthCop.select(oi.getCopyrightDate().getMonth());
                spinnerTimeYearCop.setSelection(oi.getCopyrightDate().getYear());
            } else {
                spinnerTimeYearCop.setSelection(0);
            }
        }
        // final Button addDate = new Button(originComp, SWT.PUSH);
        //            addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_add_date_creation"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(oi.getDateCreated() == null && _mayWrite);
        //
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        // _currentReference.getOriginInfo().setDateCreated(new PdrDate(0,
        // 0, 0));
        // loadValues(_currentReference);
        // } });
        // addDate.setLayoutData(new GridData());

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setCopyrightDate(null);
                loadValues(_currentReference);
            }
        });
        delDate.setLayoutData(new GridData());

    }
    if (oi.getCopyrightDateTimespan() != null) {
        Composite timespanComp = new Composite(contentComp, SWT.NONE);
        timespanComp.setLayoutData(new GridData());
        ((GridData) timespanComp.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) timespanComp.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) timespanComp.getLayoutData()).horizontalSpan = 9;

        timespanComp.setLayout(new GridLayout());
        ((GridLayout) timespanComp.getLayout()).numColumns = 13;
        ((GridLayout) timespanComp.getLayout()).makeColumnsEqualWidth = false;
        Label label9 = new Label(timespanComp, SWT.NONE);
        label9.setText(
                NLMessages.getString("Editor_copyrightDate") + " " + NLMessages.getString("Editor_from")); //$NON-NLS-1$

        {

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDateTimespan().getDateFrom()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDateTimespan().getDateFrom()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getCopyrightDateTimespan().getDateFrom() != null
                    && oi.getCopyrightDateTimespan().getDateFrom().getYear() > 0) {
                comboTimeMonth.select(oi.getCopyrightDateTimespan().getDateFrom().getMonth());
                spinnerTimeYear.setSelection(oi.getCopyrightDateTimespan().getDateFrom().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }
        {
            Label labelTo = new Label(timespanComp, SWT.NONE);
            labelTo.setText(NLMessages.getString("Editor_to"));

            Label labelMonth = new Label(timespanComp, SWT.NONE);
            labelMonth.setText(NLMessages.getString("Editor_month"));

            final Combo comboTimeMonth = new Combo(timespanComp, SWT.READ_ONLY);
            comboTimeMonth.setEnabled(_mayWrite);
            comboTimeMonth.setBackground(WHITE_COLOR);
            comboTimeMonth.setLayoutData(new GridData());
            ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true;
            comboTimeMonth.setItems(AEConstants.MONTHS);
            comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDateTimespan().getDateTo()
                            .setMonth(comboTimeMonth.getSelectionIndex());
                }
            });
            Label labelYear = new Label(timespanComp, SWT.NONE);
            labelYear.setText(NLMessages.getString("Editor_year"));

            final YearSpinner spinnerTimeYear = new YearSpinner(timespanComp, SWT.BORDER);
            spinnerTimeYear.setEnabled(_mayWrite);
            spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    _currentReference.getOriginInfo().getCopyrightDateTimespan().getDateTo()
                            .setYear(spinnerTimeYear.getSelection());
                }
            });
            if (oi.getCopyrightDateTimespan().getDateTo() != null
                    && oi.getCopyrightDateTimespan().getDateTo().getYear() > 0) {
                comboTimeMonth.select(oi.getCopyrightDateTimespan().getDateTo().getMonth());
                spinnerTimeYear.setSelection(oi.getCopyrightDateTimespan().getDateTo().getYear());
            } else {
                spinnerTimeYear.setSelection(0);
            }
        }

        final Button delDate = new Button(timespanComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_date"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setCopyrightDateTimespan(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }

    if (oi.getEdition() != null) {
        Label label15 = new Label(originComp, SWT.NONE);
        label15.setText(NLMessages.getString("Editor_edition")); //$NON-NLS-1$
        final Text edition = new Text(originComp, SWT.BORDER);
        edition.setEditable(_mayWrite);
        edition.setBackground(WHITE_COLOR);
        edition.setLayoutData(new GridData());
        ((GridData) edition.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) edition.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) edition.getLayoutData()).horizontalSpan = 7;
        edition.setText(oi.getEdition().trim());
        edition.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "edition", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
                new AutoCompleteField(edition, new TextContentAdapter(), vals);
            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getOriginInfo().setEdition(edition.getText());
            }
        });

        final Button delDate = new Button(originComp, SWT.PUSH);
        delDate.setText("-"); //$NON-NLS-1$
        delDate.setToolTipText(NLMessages.getString("Editor_remove_field"));
        delDate.setEnabled(_mayWrite);
        delDate.setLayoutData(_gridData);
        delDate.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getOriginInfo().setEdition(null);
                loadValues(_currentReference);

            }
        });
        delDate.setLayoutData(new GridData());
    }

}

From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java

License:Open Source License

/**
 * Load series title info.//from w w  w  .  j a v a2 s .c o  m
 * @param contentComp the content comp
 */
private void loadSeriesTitleInfo(final Composite contentComp) {
    Composite titleComp = new Composite(contentComp, SWT.NONE);
    titleComp.setLayoutData(new GridData());
    ((GridData) titleComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) titleComp.getLayoutData()).grabExcessHorizontalSpace = true;
    titleComp.setLayout(new GridLayout());
    ((GridLayout) titleComp.getLayout()).numColumns = 3;
    ((GridLayout) titleComp.getLayout()).makeColumnsEqualWidth = false;

    if (_currentReference.getSeriesTitleInfo().getTitle() != null) {
        Label label1 = new Label(titleComp, SWT.NONE);
        label1.setText(NLMessages.getString("Editor_add_series") + " " + NLMessages.getString("Editor_title")); //$NON-NLS-1$
        final Text stitel = new Text(titleComp, SWT.BORDER);
        stitel.setEditable(_mayWrite);
        stitel.setBackground(WHITE_COLOR);
        stitel.setLayoutData(_gridData);

        stitel.setText(_currentReference.getSeriesTitleInfo().getTitle().trim());

        //
        // {
        //         _titel.setText(NLMessages.getString("Editor_enterTitle")); //$NON-NLS-1$
        // _decoValTi.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
        // }
        stitel.addFocusListener(new FocusListener() {
            // FIXME Autocomplete
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "relatedItem", "title", null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(stitel, new TextContentAdapter(), vals);

            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getSeriesTitleInfo().setTitle(stitel.getText());
            }
        });

        Button delSTitle = new Button(titleComp, SWT.PUSH);
        delSTitle.setText("-"); //$NON-NLS-1$
        delSTitle.setToolTipText(NLMessages.getString("Editor_remove_series_title"));
        delSTitle.setEnabled(_mayWrite);
        delSTitle.setLayoutData(_gridData);
        delSTitle.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.setSeriesTitleInfo(null); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        delSTitle.setLayoutData(new GridData());
    }
    if (_currentReference.getSeriesTitleInfo().getSubTitle() != null)

    {
        Composite titleComp2 = new Composite(contentComp, SWT.NONE);

        titleComp2.setLayoutData(new GridData());
        ((GridData) titleComp2.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) titleComp2.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) titleComp2.getLayoutData()).horizontalSpan = 3;

        titleComp2.setLayout(new GridLayout());
        ((GridLayout) titleComp2.getLayout()).numColumns = 4;
        ((GridLayout) titleComp2.getLayout()).makeColumnsEqualWidth = false;

        if (_currentReference.getSeriesTitleInfo().getSubTitle() != null) {
            Label label2 = new Label(titleComp2, SWT.NONE);
            label2.setText(
                    NLMessages.getString("Editor_add_series") + " " + NLMessages.getString("Editor_subtitle"));
            final Text subSTitel = new Text(titleComp2, SWT.BORDER);
            subSTitel.setEditable(_mayWrite);
            subSTitel.setBackground(WHITE_COLOR);
            subSTitel.setLayoutData(_gridData);
            subSTitel.setText(_currentReference.getSeriesTitleInfo().getSubTitle().trim());
            subSTitel.addFocusListener(new FocusListener() {
                // FIXME
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "relatedItem", "subTitle", null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(subSTitel, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getSeriesTitleInfo().setSubTitle(subSTitel.getText());
                }
            });

        }

        final Button delExtra = new Button(titleComp2, SWT.PUSH);
        delExtra.setText("-"); //$NON-NLS-1$
        delExtra.setToolTipText(NLMessages.getString("Editor_remove_subtitle"));
        delExtra.setEnabled(_mayWrite);
        delExtra.setLayoutData(_gridData);
        delExtra.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getSeriesTitleInfo().setSubTitle(null); //$NON-NLS-1$
                loadValues(_currentReference);
            }
        });
        delExtra.setLayoutData(new GridData());
    }
    if (_currentReference.getSeriesTitleInfo().getPartName() != null
            && _currentReference.getSeriesTitleInfo().getPartNumber() != null)

    {
        Composite titleComp2 = new Composite(contentComp, SWT.NONE);

        titleComp2.setLayoutData(new GridData());
        ((GridData) titleComp2.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) titleComp2.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) titleComp2.getLayoutData()).horizontalSpan = 3;

        titleComp2.setLayout(new GridLayout());
        ((GridLayout) titleComp2.getLayout()).numColumns = 5;
        ((GridLayout) titleComp2.getLayout()).makeColumnsEqualWidth = false;

        if (_currentReference.getSeriesTitleInfo().getPartName() != null) {
            Label label2 = new Label(titleComp2, SWT.NONE);
            label2.setText(
                    NLMessages.getString("Editor_add_series") + " " + NLMessages.getString("Editor_partName")); //$NON-NLS-1$
            final Text partName = new Text(titleComp2, SWT.BORDER);
            partName.setEditable(_mayWrite);
            partName.setBackground(WHITE_COLOR);
            partName.setLayoutData(_gridData);
            partName.setText(_currentReference.getSeriesTitleInfo().getPartName().trim());
            partName.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "relatedItem", "partName", null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(partName, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getSeriesTitleInfo().setPartName(partName.getText());
                }
            });

        }
        if (_currentReference.getSeriesTitleInfo().getPartNumber() != null) {
            Label label3 = new Label(titleComp2, SWT.NONE);
            label3.setText(NLMessages.getString("Editor_add_series") + " " //$NON-NLS-1$
                    + NLMessages.getString("Editor_partNumber"));
            final Text partNum = new Text(titleComp2, SWT.BORDER);
            partNum.setEditable(_mayWrite);
            partNum.setBackground(WHITE_COLOR);
            partNum.setLayoutData(_gridData);
            partNum.setText(_currentReference.getSeriesTitleInfo().getPartNumber().trim());
            partNum.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "relatedItem", "partNumber", null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(partNum, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getSeriesTitleInfo().setPartNumber(partNum.getText());
                }
            });

        }
        final Button delExtra = new Button(titleComp2, SWT.PUSH);
        delExtra.setText("-"); //$NON-NLS-1$
        delExtra.setToolTipText(NLMessages.getString("Editor_remove_partName"));
        delExtra.setEnabled(_mayWrite);
        delExtra.setLayoutData(_gridData);
        delExtra.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getSeriesTitleInfo().setPartName(null); //$NON-NLS-1$
                _currentReference.getSeriesTitleInfo().setPartNumber(null); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        delExtra.setLayoutData(new GridData());
    }
}

From source file:org.bbaw.pdr.ae.view.main.editors.SourceEditorDialog.java

License:Open Source License

/**
 * Load title info./*w w w . java 2  s. co  m*/
 * @param contentComp the content comp
 */
private void loadTitleInfo(final Composite contentComp) {
    Composite titleComp = new Composite(contentComp, SWT.NONE);
    titleComp.setLayoutData(new GridData());
    ((GridData) titleComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) titleComp.getLayoutData()).grabExcessHorizontalSpace = true;
    titleComp.setLayout(new GridLayout());
    ((GridLayout) titleComp.getLayout()).numColumns = 3;
    ((GridLayout) titleComp.getLayout()).makeColumnsEqualWidth = false;

    if (_currentReference.getTitleInfo().getTitle() != null) {
        Label label1 = new Label(titleComp, SWT.NONE);
        label1.setText(NLMessages.getString("Editor_title")); //$NON-NLS-1$
        _titel = new Text(titleComp, SWT.BORDER);
        _titel.setEditable(_mayWrite);
        _titel.setBackground(WHITE_COLOR);
        _decoValTi = new ControlDecoration(_titel, SWT.LEFT | SWT.TOP);
        _titel.setLayoutData(_gridData);

        _titel.setText(_currentReference.getTitleInfo().getTitle().trim());
        _decoValTi.setImage(null);

        _titel.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "title", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

                    e1.printStackTrace();
                }
                new AutoCompleteField(_titel, new TextContentAdapter(), vals);

            }

            @Override
            public void focusLost(final FocusEvent e) {
                if (!_asGenreEditor) {
                    _currentReference.getTitleInfo().setTitle(_titel.getText().trim());
                    if (_currentReference.getTitleInfo().getTitle().trim().length() > 0) {
                        _decoValTi.setImage(null);
                    } else {
                        _decoValTi.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                    }
                    validate();
                } else {
                    _currentReference.getTitleInfo().setTitle(_titel.getText());
                }
            }
        });
        _titel.addKeyListener(new KeyListener() {

            @Override
            public void keyPressed(final KeyEvent arg0) {
                // TODO Auto-generated method stub

            }

            @Override
            public void keyReleased(final KeyEvent e) {
                if (!_asGenreEditor) {
                    _currentReference.getTitleInfo().setTitle(_titel.getText().trim());
                    if (_currentReference.getTitleInfo().getTitle().trim().length() > 0) {
                        _decoValTi.setImage(null);
                    } else {
                        _decoValTi.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                    }
                    validate();
                } else {
                    _currentReference.getTitleInfo().setTitle(_titel.getText());
                }
            }
        });

        _delTitle = new Button(titleComp, SWT.PUSH);
        _delTitle.setText("-"); //$NON-NLS-1$
        _delTitle.setToolTipText(NLMessages.getString("Editor_remove_title"));
        _delTitle.setEnabled(_mayWrite && _currentReference.isValid());
        _delTitle.setLayoutData(_gridData);
        _delTitle.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.setTitleInfo(null); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        _delTitle.setLayoutData(new GridData());
    }
    if (_currentReference.getTitleInfo().getSubTitle() != null)

    {
        Composite titleComp2 = new Composite(contentComp, SWT.NONE);

        titleComp2.setLayoutData(new GridData());
        ((GridData) titleComp2.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) titleComp2.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) titleComp2.getLayoutData()).horizontalSpan = 3;

        titleComp2.setLayout(new GridLayout());
        ((GridLayout) titleComp2.getLayout()).numColumns = 4;
        ((GridLayout) titleComp2.getLayout()).makeColumnsEqualWidth = false;

        if (_currentReference.getTitleInfo().getSubTitle() != null) {
            Label label2 = new Label(titleComp2, SWT.NONE);
            label2.setText(NLMessages.getString("Editor_subtitle"));
            _subTitel = new Text(titleComp2, SWT.BORDER);
            _subTitel.setEditable(_mayWrite);
            _subTitel.setBackground(WHITE_COLOR);
            _subTitel.setLayoutData(_gridData);
            _subTitel.setText(_currentReference.getTitleInfo().getSubTitle().trim());
            _subTitel.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "subTitle", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(_subTitel, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getTitleInfo().setSubTitle(_subTitel.getText());
                }
            });

        }

        final Button delExtra = new Button(titleComp2, SWT.PUSH);
        delExtra.setText("-"); //$NON-NLS-1$
        delExtra.setToolTipText(NLMessages.getString("Editor_remove_subtitle"));
        delExtra.setEnabled(_mayWrite);
        delExtra.setLayoutData(_gridData);
        delExtra.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getTitleInfo().setSubTitle(null); //$NON-NLS-1$
                loadValues(_currentReference);
            }
        });
        delExtra.setLayoutData(new GridData());
    }
    if (_currentReference.getTitleInfo().getPartName() != null
            && _currentReference.getTitleInfo().getPartNumber() != null)

    {
        Composite titleComp2 = new Composite(contentComp, SWT.NONE);

        titleComp2.setLayoutData(new GridData());
        ((GridData) titleComp2.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) titleComp2.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) titleComp2.getLayoutData()).horizontalSpan = 3;

        titleComp2.setLayout(new GridLayout());
        ((GridLayout) titleComp2.getLayout()).numColumns = 5;
        ((GridLayout) titleComp2.getLayout()).makeColumnsEqualWidth = false;

        if (_currentReference.getTitleInfo().getPartName() != null) {
            Label label2 = new Label(titleComp2, SWT.NONE);
            label2.setText(NLMessages.getString("Editor_partName")); //$NON-NLS-1$
            final Text partName = new Text(titleComp2, SWT.BORDER);
            partName.setEditable(_mayWrite);
            partName.setBackground(WHITE_COLOR);
            partName.setLayoutData(_gridData);
            partName.setText(_currentReference.getTitleInfo().getPartName().trim());
            partName.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "partName", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(partName, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getTitleInfo().setPartName(partName.getText());
                }
            });

        }
        if (_currentReference.getTitleInfo().getPartNumber() != null) {
            Label label3 = new Label(titleComp2, SWT.NONE);
            label3.setText(NLMessages.getString("Editor_partNumber")); //$NON-NLS-1$
            final Text partNum = new Text(titleComp2, SWT.BORDER);
            partNum.setEditable(_mayWrite);
            partNum.setBackground(WHITE_COLOR);
            partNum.setLayoutData(_gridData);
            partNum.setText(_currentReference.getTitleInfo().getPartNumber().trim());
            partNum.addFocusListener(new FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$

                    try {
                        vals = _mainSearcher.getFacets("reference", "partNumber", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                    } catch (Exception e1) {

                        e1.printStackTrace();
                    }
                    new AutoCompleteField(partNum, new TextContentAdapter(), vals);
                }

                @Override
                public void focusLost(final FocusEvent e) {
                    _currentReference.getTitleInfo().setPartNumber(partNum.getText());
                }
            });

        }
        final Button delExtra = new Button(titleComp2, SWT.PUSH);
        delExtra.setText("-"); //$NON-NLS-1$
        delExtra.setToolTipText(NLMessages.getString("Editor_remove_partName"));
        delExtra.setEnabled(_mayWrite);
        delExtra.setLayoutData(_gridData);
        delExtra.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                _currentReference.getTitleInfo().setPartName(null); //$NON-NLS-1$
                _currentReference.getTitleInfo().setPartNumber(null); //$NON-NLS-1$
                loadValues(_currentReference);

            }
        });
        delExtra.setLayoutData(new GridData());
    }
}

From source file:org.bonitasoft.studio.actors.ui.wizard.page.DefaultUserOrganizationWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create());

    context = new DataBindingContext();

    final Label usernameLabel = new Label(mainComposite, SWT.NONE);
    usernameLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create());
    usernameLabel.setText(Messages.userName);

    usernameText = new Text(mainComposite, SWT.BORDER);
    usernameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    autoCompletionField = new AutoCompleteField(usernameText, new TextContentAdapter(), new String[] {});

    createBindings();//from  w  ww  .  j ava 2  s  .co  m
    pageSupport = WizardPageSupport.create(this, context);

    setControl(mainComposite);
}

From source file:org.dawnsci.common.richbeans.components.wrappers.ComboWrapper.java

License:Open Source License

/**
 * @param items//from w w w. java2s . c  om
 */
public void setItems(final String[] items) {
    combo.setItems(items);
    // Auto-complete in Jface not working well.
    if (autoComplete == null)
        autoComplete = new AutoCompleteField(combo, new ComboContentAdapter(), items);
    autoComplete.setProposals(items);
}

From source file:org.ebayopensource.turmeric.eclipse.maven.ui.preferences.TurmericSOAConfigPrefPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    final IPreferenceStore prefStore = TurmericSOAConfigPrefInitializer.getPreferenceStore();
    final Composite composite = getFieldEditorParent();

    try {/*from   ww  w  .j  a va  2 s  .co  m*/
        final Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
        group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        GridLayout layout = new GridLayout(2, false);
        group.setLayout(layout);
        group.setText("Framework Version Configurations");
        final ISOAOrganizationProvider orgProvider = GlobalRepositorySystem.instanceOf()
                .getActiveRepositorySystem().getActiveOrganizationProvider();
        String soatoolsId = orgProvider.getSOAFrameworkLibraryIdentifier(SOAFrameworkLibrary.SOATOOLS);
        final ArtifactMetadata metadata = MavenEclipseUtil.artifactMetadata(soatoolsId);

        BooleanFieldEditor overwriteEditor = new BooleanFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_OVERWRITE_PREFERRED_VERSOIN,
                "Overwrite Preferred Version", group) {

            @Override
            protected void valueChanged(boolean oldValue, boolean newValue) {
                enableVersionEditor(newValue);
                super.valueChanged(oldValue, newValue);
            }

            private void enableVersionEditor(boolean newValue) {
                if (preferredVerEditor != null) {
                    preferredVerEditor.setEnabled(newValue, group);
                    if (newValue == true && StringUtils.isBlank(preferredVerEditor.getStringValue())) {
                        TurmericSOAConfigPrefPage.this.setErrorMessage("preferred version must not be empty");
                        preferredVerEditor.setErrorMessage("preferred version must not be empty");
                    }
                }
            }

            @Override
            protected void doLoadDefault() {

                super.doLoadDefault();
                enableVersionEditor(getBooleanValue());
            }
        };
        addField(overwriteEditor);
        final Collection<String> versions = new TreeSet<String>();
        if (metadata != null) {
            for (Artifact artifact : MavenCoreUtils.mavenEclipseAPI()
                    .findArtifactByNameAndGroup(metadata.getArtifactId(), metadata.getGroupId())) {
                versions.add(artifact.getVersion());
            }
        }

        final String minVersion = orgProvider.getMinimumRequiredTurmericFrameworkVersion();
        this.preferredVerEditor = new StringFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_TURMERIC_PREFERRED_VERSOIN,
                "Preferred Turmeric Version:", group) {

            @Override
            protected boolean doCheckState() {
                if (VersionUtil.compare(getStringValue(), minVersion) < 0) {
                    this.setErrorMessage("Preferred version must be equal to or greater than " + minVersion);
                    return false;
                }
                return super.doCheckState();
            }

        };
        this.preferredVerEditor.setEmptyStringAllowed(false);
        this.preferredVerEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);

        addField(preferredVerEditor);

        if (versions.isEmpty() == false) {
            Text verText = this.preferredVerEditor.getTextControl(group);
            new AutoCompleteField(verText, new TextContentAdapter(), versions.toArray(new String[0]));
        }

        this.preferredVerEditor.setEnabled(
                prefStore.getBoolean(TurmericSOAConfigPrefInitializer.PREF_KEY_OVERWRITE_PREFERRED_VERSOIN),
                group);

        prefStore.setValue(TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, minVersion);
        prefStore.setDefault(TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, minVersion);
        StringFieldEditor text = new StringFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, "Minimum Required Version:",
                group);
        text.getTextControl(group).setEditable(false);
        text.setStringValue(orgProvider.getMinimumRequiredTurmericFrameworkVersion());
        addField(text);
    } catch (Exception e) {
        logger.error(e);
        UIUtil.showErrorDialog(e);
    }
}

From source file:org.ebayopensource.turmeric.eclipse.ui.dialogs.SOAClientConfigEnvironmentDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    final Composite comp = (Composite) super.createDialogArea(parent);
    final GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 520;//from   www.j a  v a  2 s  .c om
    gd.heightHint = 300;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    comp.setLayoutData(gd);

    Composite composite = new Composite(comp, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label label = new Label(composite, SWT.NONE);
    label.setText("Environment Name:");

    environmentText = new CCombo(composite, SWT.BORDER);
    environmentText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new AutoCompleteField(environmentText, new SOACComboControlAdapter(), SOAProjectConstants.EBAY_POOL_TYPES);
    environmentText.setItems(SOAProjectConstants.EBAY_POOL_TYPES);
    environmentText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }

    });

    final Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
    group.setLayout(new GridLayout(2, false));
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    group.setLayoutData(data);

    chooseExistingEnvBtn = new Button(group, SWT.CHECK);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    chooseExistingEnvBtn.setLayoutData(data);
    chooseExistingEnvBtn.setText("Choose an existing environment to copy from");
    boolean hasExistingEnvs = existingEnvironments.isEmpty() == false;
    chooseExistingEnvBtn.setEnabled(hasExistingEnvs);
    chooseExistingEnvBtn.setSelection(hasExistingEnvs);
    chooseExistingEnvBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            environmentCombo.setEnabled(chooseExistingEnvBtn.getSelection());
            if (chooseExistingEnvBtn.getSelection() == false)
                environmentCombo.setText("");
            dialogChanged();
        }
    });

    label = new Label(group, SWT.NONE);
    label.setText("Existing Environments:");

    environmentCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
    environmentCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    environmentCombo.setItems(existingEnvironments.toArray(new String[0]));
    environmentCombo.setEnabled(hasExistingEnvs);
    environmentCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            dialogChanged();
        }
    });
    if (hasExistingEnvs) {
        environmentCombo.select(0);
    }
    environmentText.setFocus();
    return composite;
}

From source file:org.ebayopensource.turmeric.eclipse.ui.SOABasePage.java

License:Open Source License

/**
 * Create a combo box widget in standard SOA dimension and style.
 *
 * @param composite the composite//from ww  w.j  av a  2s  .  co m
 * @param labelText the label text
 * @param editable the editable
 * @param items the items
 * @param tooltip the tooltip
 * @return the c combo
 */
public CCombo createCCombo(final Composite composite, final String labelText, final boolean editable,
        final String[] items, final String tooltip) {

    final Label label = new Label(composite, SWT.LEFT);
    label.setText(labelText);
    final int defaultStyle = SWT.BORDER | SWT.DROP_DOWN;
    final int style = editable ? defaultStyle : SWT.READ_ONLY | defaultStyle;
    final CCombo combo = new CCombo(composite, style);
    if (editable == false) {
        // we still want it look like modifiable although it is ready only.
        combo.setBackground(UIUtil.display().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    } else {
        combo.setTextLimit(100);
    }
    combo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    if (items != null && items.length > 0) {
        combo.setItems(items);
        combo.select(0);
        if (editable == true)
            new AutoCompleteField(combo, new SOACComboControlAdapter(), items);
    }
    UIUtil.decorateControl(this, combo, tooltip);
    return combo;
}