Example usage for org.eclipse.jface.viewers ComboViewer getElementAt

List of usage examples for org.eclipse.jface.viewers ComboViewer getElementAt

Introduction

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

Prototype

public Object getElementAt(int index) 

Source Link

Document

Returns the element with the given index from this list viewer.

Usage

From source file:org.bbaw.pdr.ae.view.main.dialogs.ExpertSearchDialog.java

License:Open Source License

/**
 * Builds the person search./*from w  w  w  . j  a  v  a2s  .  c o m*/
 * @param type the type
 * @param crit the crit
 */
private void buildPersonSearch(final int type, final Integer crit) {
    DataType dtAll = new DataType();
    dtAll.setValue("ALL"); //$NON-NLS-1$
    dtAll.setLabel("ALL"); //$NON-NLS-1$
    if (_scrollCompSearch != null) {
        _scrollCompSearch.dispose();
    }
    if (_searchPTagComp != null) {
        _searchPTagComp.dispose();
    }
    // if (placeGroup != null) placeGroup.dispose();
    _scrollCompSearch = new ScrolledComposite(_personSearchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    _scrollCompSearch.setExpandHorizontal(true);
    _scrollCompSearch.setExpandVertical(true);
    _scrollCompSearch.setMinHeight(1);
    _scrollCompSearch.setMinWidth(1);

    _scrollCompSearch.setLayout(new GridLayout());
    _scrollCompSearch.setLayoutData(new GridData());
    ((GridData) _scrollCompSearch.getLayoutData()).heightHint = 400;
    ((GridData) _scrollCompSearch.getLayoutData()).horizontalSpan = 4;
    ((GridData) _scrollCompSearch.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _scrollCompSearch.getLayoutData()).grabExcessHorizontalSpace = true;
    _scrollCompSearch.pack();

    Composite contentCompSearch = new Composite(_scrollCompSearch, SWT.NONE);
    contentCompSearch.setLayout(new GridLayout());

    _scrollCompSearch.setContent(contentCompSearch);

    boolean tag1 = true;
    boolean rel1 = true;
    boolean date1 = true;
    switch (type) {
    case 0:
        // pdrQuery = new PdrQuery();
        // criteria = new Criteria();
        // pdrQuery.getCriterias().add(criteria);

        break; // normales laden
    case 1: // neues criteria einfgen
        _criteria = new Criteria();
        _pdrQuery.getCriterias().add(_criteria);
        _criteria.setType("tagging"); //$NON-NLS-1$
        //         System.out.println("in case 1"); //$NON-NLS-1$
        //         System.out.println("anzahl crit " + pdrQuery.getCriterias().size()); //$NON-NLS-1$
        break;
    case 2: // criteria lschen
        _pdrQuery.getCriterias().removeElementAt(crit);
        break;
    case 3: // neue relation einfgen
        _criteria = new Criteria();
        _pdrQuery.getCriterias().add(_criteria);
        _criteria.setType("relation"); //$NON-NLS-1$
        break;
    case 4: // relation lschen
        _pdrQuery.getCriterias().removeElementAt(crit);
        break;
    case 5: // date criteria einfgen
        _criteria = new Criteria();
        _pdrQuery.getCriterias().add(_criteria);
        _criteria.setType("date"); //$NON-NLS-1$
        break;
    case 6:
        _pdrQuery.getCriterias().removeElementAt(crit);
        break;
    case 7: // reference criteria einfgen
        _criteria = new Criteria();
        _pdrQuery.getCriterias().add(_criteria);
        _criteria.setType("reference"); //$NON-NLS-1$
        break;
    case 8:
        _pdrQuery.getCriterias().removeElementAt(crit);
        break;
    default:
        break;
    }

    Collections.sort(_pdrQuery.getCriterias());

    // load last search.
    if (_facade.getLastExpertSearch() != null) {
        _pdrQuery = _facade.getLastExpertSearch();
    }

    for (int i = 0; i < _pdrQuery.getCriterias().size(); i++) {
        //         System.out.println("for i = " + i); //$NON-NLS-1$
        final Criteria c = _pdrQuery.getCriterias().get(i);

        if (c.getType().equals("tagging")) //$NON-NLS-1$
        {
            if (tag1) {
                tag1 = false;
                _searchPTagComp = new Composite(contentCompSearch, SWT.NONE);
                _searchPTagComp.setLayout(new GridLayout());
                ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true;
                ((GridLayout) _searchPTagComp.getLayout()).numColumns = 21;
                _searchPTagComp.setLayoutData(new GridData());
                ((GridData) _searchPTagComp.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) _searchPTagComp.getLayoutData()).grabExcessHorizontalSpace = true;
                // ((GridData) searchPTagComp.getLayoutData()).heightHint =
                // 200;
                ((GridData) _searchPTagComp.getLayoutData()).grabExcessVerticalSpace = false;
                ((GridData) _searchPTagComp.getLayoutData()).horizontalSpan = 1;

                Label op = new Label(_searchPTagComp, SWT.NONE);
                op.setText(NLMessages.getString("Dialog_operand")); //$NON-NLS-1$
                op.setLayoutData(new GridData());
                ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) op.getLayoutData()).horizontalSpan = 2;

                Label sem = new Label(_searchPTagComp, SWT.NONE);
                sem.setText(NLMessages.getString("Dialog_semantic")); //$NON-NLS-1$
                sem.setLayoutData(new GridData());
                ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) sem.getLayoutData()).horizontalSpan = 2;

                Label tagName = new Label(_searchPTagComp, SWT.NONE);
                tagName.setText(NLMessages.getString("Dialog_tagging")); //$NON-NLS-1$
                tagName.setLayoutData(new GridData());
                ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagName.getLayoutData()).horizontalSpan = 2;

                Label tagType = new Label(_searchPTagComp, SWT.NONE);
                tagType.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$
                tagType.setLayoutData(new GridData());
                ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagType.getLayoutData()).horizontalSpan = 2;

                Label tagSubtype = new Label(_searchPTagComp, SWT.NONE);
                tagSubtype.setText(NLMessages.getString("Dialog_subtype")); //$NON-NLS-1$
                tagSubtype.setLayoutData(new GridData());
                ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2;

                Label tagRole = new Label(_searchPTagComp, SWT.NONE);
                tagRole.setText(NLMessages.getString("Dialog_role")); //$NON-NLS-1$
                tagRole.setLayoutData(new GridData());
                ((GridData) tagRole.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagRole.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagRole.getLayoutData()).horizontalSpan = 2;

                Label tagKey = new Label(_searchPTagComp, SWT.NONE);
                tagKey.setText(NLMessages.getString("Dialog_key")); //$NON-NLS-1$
                tagKey.setLayoutData(new GridData());
                ((GridData) tagKey.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagKey.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagKey.getLayoutData()).horizontalSpan = 3;

                Label searchTextLabel = new Label(_searchPTagComp, SWT.NONE);
                searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$
                searchTextLabel.setLayoutData(new GridData());
                ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3;

                Label fuzzy = new Label(_searchPTagComp, SWT.NONE);
                fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); //$NON-NLS-1$
                fuzzy.setLayoutData(new GridData());
                ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1;

                Label include = new Label(_searchPTagComp, SWT.NONE);
                include.setText(NLMessages.getString("Dialog_include")); //$NON-NLS-1$
                include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$
                include.setLayoutData(new GridData());
                ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) include.getLayoutData()).horizontalSpan = 1;

                Label del = new Label(_searchPTagComp, SWT.NONE);
                del.setText(NLMessages.getString("Dialog_del")); //$NON-NLS-1$
                del.setLayoutData(new GridData());
                ((GridData) del.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) del.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) del.getLayoutData()).horizontalSpan = 1;
            }

            if (i == 0) {
                Label l = new Label(_searchPTagComp, SWT.NONE);
                l.setLayoutData(new GridData());
                l.setLayoutData(new GridData());
                ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) l.getLayoutData()).horizontalSpan = 2;
            } else {
                final Combo opCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
                opCombo.setLayoutData(new GridData());
                opCombo.add(Operator.AND.toString());
                opCombo.add(Operator.OR.toString());
                opCombo.add(Operator.NOT.toString());
                opCombo.setLayoutData(new GridData());
                ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) opCombo.getLayoutData()).horizontalSpan = 2;
                if (c.getOperator() != null) {
                    opCombo.setText(c.getOperator());
                } else {
                    opCombo.select(0);
                    c.setOperator(opCombo.getItem(0));

                }
                opCombo.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent se) {
                        c.setOperator(opCombo.getItem(opCombo.getSelectionIndex()));
                    }
                });
            }

            final Combo semCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
            semCombo.setLayoutData(new GridData());
            ComboViewer comboSemanticViewer = new ComboViewer(semCombo);
            comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider());
            comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider());
            ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true);

            if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) {
                comboSemanticViewer.setInput(_facade.getAllSemantics());
                if (c.getCrit0() != null) {
                    setComboViewerByString(comboSemanticViewer, c.getCrit0());
                } else {
                    semCombo.select(0);
                    c.setCrit0(semCombo.getItem(0));
                }
            }
            semCombo.setLayoutData(new GridData());
            ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) semCombo.getLayoutData()).horizontalSpan = 2;

            comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    IAEPresentable cp = (IAEPresentable) obj;
                    if (cp != null) {
                        c.setCrit0(cp.getValue());
                    }
                }
            });
            semCombo.pack();
            final Combo tagCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
            tagCombo.setLayoutData(new GridData());
            tagCombo.setLayoutData(new GridData());
            ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2;
            final ComboViewer tagComboViewer = new ComboViewer(tagCombo);
            tagComboViewer.setContentProvider(new MarkupContentProvider(true));
            tagComboViewer.setLabelProvider(new MarkupLabelProvider());
            tagComboViewer.setComparator(new ConfigDataComparator());
            if (_facade.getConfigs().containsKey(_markupProvider)) {
                HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren();
                tagComboViewer.setInput(input);
            }
            if (c.getCrit1() != null) {
                setComboViewerByString(tagComboViewer, c.getCrit1());
            } else {
                Object obj = tagComboViewer.getElementAt(0);
                if (obj != null) {
                    tagComboViewer.setSelection(new StructuredSelection(obj));
                    ConfigData cd = (ConfigData) tagComboViewer.getElementAt(0);
                    if (cd.getValue().startsWith("aodl:")) //$NON-NLS-1$
                    {
                        c.setCrit1(cd.getValue().substring(5));
                    } else {
                        c.setCrit1(cd.getValue());
                    }
                }
            }
            final Combo typeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
            typeCombo.setLayoutData(new GridData());
            typeCombo.setLayoutData(new GridData());
            ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2;
            final ComboViewer typeComboViewer = new ComboViewer(typeCombo);
            typeComboViewer.setContentProvider(new MarkupContentProvider());
            typeComboViewer.setLabelProvider(new MarkupLabelProvider());
            typeComboViewer.setComparator(new ConfigDataComparator());

            tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    String selection;
                    if (cd.getValue().startsWith("aodl:")) {
                        selection = cd.getValue().substring(5); //$NON-NLS-1$
                    } else {
                        selection = cd.getValue();
                    }
                    c.setCrit1(selection);
                    setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); //$NON-NLS-1$
                }
            });

            if (c.getCrit2() != null) {
                setComboViewerByString(typeComboViewer, c.getCrit2());
            }

            final Combo subtypeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
            final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo);
            subtypeComboViewer.setContentProvider(new MarkupContentProvider());
            subtypeComboViewer.setLabelProvider(new MarkupLabelProvider());
            subtypeComboViewer.setComparator(new ConfigDataComparator());

            typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    subtypeComboViewer.setInput(null);
                    if (cd != null) {
                        c.setCrit2(cd.getValue());
                    }
                    setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); //$NON-NLS-1$
                }
            });

            subtypeCombo.setLayoutData(new GridData());
            subtypeCombo.setLayoutData(new GridData());
            ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2;
            if (c.getCrit3() != null) {
                setComboViewerByString(subtypeComboViewer, c.getCrit3());
            }

            final Combo roleCombo = new Combo(_searchPTagComp, SWT.READ_ONLY);
            final ComboViewer roleComboViewer = new ComboViewer(roleCombo);
            roleComboViewer.setContentProvider(new MarkupContentProvider());
            roleComboViewer.setLabelProvider(new MarkupLabelProvider());
            roleComboViewer.setComparator(new ConfigDataComparator());

            subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    if (cd != null) {
                        c.setCrit3(cd.getValue());
                    }
                    setComboViewerInput(roleComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), //$NON-NLS-1$
                            c.getCrit3());
                }
            });

            roleCombo.setLayoutData(new GridData());
            roleCombo.setLayoutData(new GridData());
            ((GridData) roleCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) roleCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) roleCombo.getLayoutData()).horizontalSpan = 2;
            if (c.getCrit4() != null) {
                setComboViewerByString(roleComboViewer, c.getCrit4());
            }
            roleComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    if (cd != null) {
                        c.setCrit4(cd.getValue());
                    }
                }
            });

            final Text keyText = new Text(_searchPTagComp, SWT.BORDER);
            keyText.setLayoutData(new GridData());
            keyText.setLayoutData(new GridData());
            ((GridData) keyText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) keyText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) keyText.getLayoutData()).horizontalSpan = 2;
            if (c.getCrit5() != null) {
                keyText.setText(c.getCrit5());
            }
            keyText.setEnabled(false);

            final Button keySet = new Button(_searchPTagComp, SWT.PUSH);
            keySet.setEnabled(false);
            keySet.setText(NLMessages.getString("Dialog_set_key")); //$NON-NLS-1$
            keySet.setFont(JFaceResources.getDialogFont());
            keySet.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                }
            });

            final Text searchText = new Text(_searchPTagComp, SWT.BORDER);
            searchText.setLayoutData(new GridData());
            searchText.setLayoutData(new GridData());
            ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) searchText.getLayoutData()).horizontalSpan = 3;
            if (c.getSearchText() != null) {
                searchText.setText(c.getSearchText());
            }
            searchText.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(final FocusEvent e) {
                    c.setSearchText(searchText.getText());
                }
            });

            final Button fuzzyB = new Button(_searchPTagComp, SWT.CHECK);
            fuzzyB.setLayoutData(new GridData());
            fuzzyB.setSelection(c.isFuzzy());
            fuzzyB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setFuzzy(!c.isFuzzy());
                }
            });

            final Button includeB = new Button(_searchPTagComp, SWT.CHECK);
            includeB.setLayoutData(new GridData());
            includeB.setSelection(c.isIncludeConcurrences());
            includeB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setIncludeConcurrences(!c.isIncludeConcurrences());
                }
            });

            final Button delTagCriteria = new Button(_searchPTagComp, SWT.PUSH);
            delTagCriteria.setLayoutData(new GridData());
            delTagCriteria.setText("-"); //$NON-NLS-1$
            delTagCriteria.setData("tag", i); //$NON-NLS-1$

            delTagCriteria.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    buildPersonSearch(2, ((Integer) delTagCriteria.getData("tag"))); //$NON-NLS-1$
                }
            });

        } // if tagging

        if (c.getType().equals("relation")) //$NON-NLS-1$
        {
            if (rel1) {
                rel1 = false;
                _searchPRelComp = new Composite(contentCompSearch, SWT.NONE);
                _searchPRelComp.setLayout(new GridLayout());
                ((GridLayout) _searchPRelComp.getLayout()).makeColumnsEqualWidth = true;
                ((GridLayout) _searchPRelComp.getLayout()).numColumns = 15;
                _searchPRelComp.setLayoutData(new GridData());
                ((GridData) _searchPRelComp.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) _searchPRelComp.getLayoutData()).grabExcessHorizontalSpace = true;
                // ((GridData) searchPRelComp.getLayoutData()).heightHint =
                // 200;
                ((GridData) _searchPRelComp.getLayoutData()).grabExcessVerticalSpace = false;
                ((GridData) _searchPRelComp.getLayoutData()).horizontalSpan = 1;

                Label l = new Label(_searchPRelComp, SWT.NONE);
                l.setText(NLMessages.getString("Dialog_relation")); //$NON-NLS-1$
                l.setLayoutData(new GridData());
                ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) l.getLayoutData()).horizontalSpan = 2;

                Label context = new Label(_searchPRelComp, SWT.NONE);
                context.setText(NLMessages.getString("Dialog_context")); //$NON-NLS-1$
                context.setLayoutData(new GridData());
                ((GridData) context.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) context.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) context.getLayoutData()).horizontalSpan = 2;

                Label classL = new Label(_searchPRelComp, SWT.NONE);
                classL.setText(NLMessages.getString("Dialog_class")); //$NON-NLS-1$
                classL.setLayoutData(new GridData());
                ((GridData) classL.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) classL.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) classL.getLayoutData()).horizontalSpan = 2;

                Label relObj = new Label(_searchPRelComp, SWT.NONE);
                relObj.setText(NLMessages.getString("Dialog_relObject")); //$NON-NLS-1$
                relObj.setLayoutData(new GridData());
                ((GridData) relObj.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) relObj.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) relObj.getLayoutData()).horizontalSpan = 4;

                Label searchTextLabel = new Label(_searchPRelComp, SWT.NONE);
                searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$
                searchTextLabel.setLayoutData(new GridData());
                ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3;

                Label fuzzy = new Label(_searchPRelComp, SWT.NONE);
                fuzzy.setText(""); //$NON-NLS-1$
                fuzzy.setLayoutData(new GridData());
                ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1;

                Label include = new Label(_searchPRelComp, SWT.NONE);
                include.setText(""); //$NON-NLS-1$
                include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$
                include.setLayoutData(new GridData());
                ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) include.getLayoutData()).horizontalSpan = 1;

            }

            if (i == 0) {
                Label l = new Label(_searchPRelComp, SWT.NONE);
                l.setLayoutData(new GridData());
                l.setLayoutData(new GridData());
                ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) l.getLayoutData()).horizontalSpan = 2;
            } else {
                final Combo opCombo = new Combo(_searchPRelComp, SWT.READ_ONLY);
                opCombo.setLayoutData(new GridData());
                opCombo.add(Operator.AND.toString());
                opCombo.add(Operator.OR.toString());
                opCombo.add(Operator.NOT.toString());
                opCombo.setLayoutData(new GridData());
                ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) opCombo.getLayoutData()).horizontalSpan = 2;
                if (c.getOperator() != null) {
                    opCombo.setText(c.getOperator());
                } else {
                    opCombo.select(0);
                    c.setOperator(opCombo.getItem(0));

                }
                opCombo.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent se) {
                        c.setOperator(opCombo.getItem(opCombo.getSelectionIndex()));
                    }
                });
            }
            // final Combo contextCombo = new Combo(searchPRelComp,
            // SWT.READ_ONLY);
            // contextCombo.setLayoutData(new GridData());
            // contextCombo.setLayoutData(new GridData());
            // ((GridData) contextCombo.getLayoutData()).horizontalAlignment
            // = SWT.FILL;
            // ((GridData)
            // contextCombo.getLayoutData()).grabExcessHorizontalSpace =
            // true ;
            // ((GridData) contextCombo.getLayoutData()).horizontalSpan = 2;
            //
            //
            // final Combo classCombo = new Combo(searchPRelComp,
            // SWT.READ_ONLY);
            // classCombo.setLayoutData(new GridData());
            // classCombo.setLayoutData(new GridData());
            // ((GridData) classCombo.getLayoutData()).horizontalAlignment =
            // SWT.FILL;
            // ((GridData)
            // classCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            // ((GridData) classCombo.getLayoutData()).horizontalSpan = 2;
            //
            //
            // if (c.getRelationContext() != null)
            // {
            // contextCombo.select(contextCombo.indexOf(c.getRelationContext()));
            // }
            // else
            // {
            // try {
            //                  contextCombo.setItems(mainSearcher.getFacets("relation", null, null, null, null)); //$NON-NLS-1$ //$NON-NLS-2$
            // } catch (XQException e1) {
            // e1.printStackTrace();
            // }
            //               contextCombo.add("ALL", 0); //$NON-NLS-1$
            // contextCombo.select(0);
            // c.setRelationContext(contextCombo.getItem(0));
            //
            // }
            // contextCombo.addSelectionListener(new SelectionAdapter(){
            // public void widgetSelected(SelectionEvent se){
            // String selection =
            // contextCombo.getItem(contextCombo.getSelectionIndex());
            // c.setRelationContext(selection);
            // try {
            // classCombo.setItems(mainSearcher
            //            .getFacets("relation", null, selection, null, null)); //$NON-NLS-1$ //$NON-NLS-2$
            // } catch (XQException e1) {
            // e1.printStackTrace();
            // }
            //                  classCombo.add("ALL", 0); //$NON-NLS-1$
            // classCombo.select(0);
            // c.setRelationContext(classCombo.getItem(0));
            //
            // }
            // });
            //
            // if (c.getRelationClass() != null)
            // {
            // classCombo.setText(c.getRelationClass());
            // }
            // else
            // {
            //
            //               classCombo.add("ALL", 0); //$NON-NLS-1$
            // classCombo.select(0);
            // c.setRelationClass(classCombo.getItem(0));
            // }
            //
            //
            // classCombo.addSelectionListener(new SelectionAdapter(){
            // public void widgetSelected(SelectionEvent se){
            // String selection =
            // classCombo.getItem(classCombo.getSelectionIndex());
            // c.setRelationContext(selection);
            //
            // }
            // });
            //
            final Combo contextCombo = new Combo(_searchPRelComp, SWT.READ_ONLY);
            contextCombo.setLayoutData(new GridData());
            contextCombo.setLayoutData(new GridData());
            ((GridData) contextCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) contextCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) contextCombo.getLayoutData()).horizontalSpan = 2;
            final ComboViewer contextComboViewer = new ComboViewer(contextCombo);
            contextComboViewer.setContentProvider(new MarkupContentProvider());
            contextComboViewer.setLabelProvider(new MarkupLabelProvider());
            contextComboViewer.setComparator(new ConfigDataComparator());

            final Combo classCombo = new Combo(_searchPRelComp, SWT.READ_ONLY);
            classCombo.setLayoutData(new GridData());
            classCombo.setLayoutData(new GridData());
            ((GridData) classCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) classCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) classCombo.getLayoutData()).horizontalSpan = 2;
            final ComboViewer classComboViewer = new ComboViewer(classCombo);
            classComboViewer.setContentProvider(new MarkupContentProvider());
            classComboViewer.setLabelProvider(new MarkupLabelProvider());
            classComboViewer.setComparator(new ConfigDataComparator());
            setComboViewerInput(contextComboViewer, "relation", null, null, null); //$NON-NLS-1$
            if (c.getRelationContext() != null) {
                setComboViewerByString(contextComboViewer, c.getRelationContext());
                setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); //$NON-NLS-1$

            } else {
                contextComboViewer.setSelection(new StructuredSelection(contextComboViewer.getElementAt(0)));
                ConfigData cd = (ConfigData) contextComboViewer.getElementAt(0);
                c.setRelationContext(cd.getValue());

            }
            contextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    c.setRelationContext(cd.getValue());
                    setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); //$NON-NLS-1$
                }
            });

            if (c.getRelationClass() != null) {
                setComboViewerByString(classComboViewer, c.getRelationClass());
            }

            classComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection iSelection = event.getSelection();
                    Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                    ConfigData cd = (ConfigData) obj;
                    c.setRelationClass(cd.getValue());
                }
            });

            final Text relObjText = new Text(_searchPRelComp, SWT.BORDER);
            relObjText.setLayoutData(new GridData());
            relObjText.setLayoutData(new GridData());
            ((GridData) relObjText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) relObjText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) relObjText.getLayoutData()).horizontalSpan = 3;
            if (c.getRelatedId() != null) {
                relObjText.setText(c.getRelatedId().toString());
            }
            relObjText.setEnabled(false);

            final Button setObj = new Button(_searchPRelComp, SWT.PUSH);
            setObj.setEnabled(false);
            setObj.setText(NLMessages.getString("Dialog_set_key")); //$NON-NLS-1$
            setObj.setFont(JFaceResources.getDialogFont());
            setObj.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                }
            });

            final Text searchText = new Text(_searchPRelComp, SWT.BORDER);
            searchText.setLayoutData(new GridData());
            searchText.setLayoutData(new GridData());
            ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) searchText.getLayoutData()).horizontalSpan = 3;
            if (c.getSearchText() != null) {
                searchText.setText(c.getSearchText());
            }
            searchText.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(final FocusEvent e) {
                    c.setSearchText(searchText.getText());
                }
            });

            final Button fuzzyB = new Button(_searchPRelComp, SWT.CHECK);
            fuzzyB.setLayoutData(new GridData());
            fuzzyB.setSelection(c.isFuzzy());
            fuzzyB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setFuzzy(!c.isFuzzy());
                }
            });

            final Button includeB = new Button(_searchPRelComp, SWT.CHECK);
            includeB.setLayoutData(new GridData());
            includeB.setSelection(c.isIncludeConcurrences());
            includeB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setIncludeConcurrences(!c.isIncludeConcurrences());
                }
            });

        } // if relation
        if (c.getType().equals("date")) //$NON-NLS-1$
        {
            if (date1) {
                date1 = false;
                _searchPDateComp = new Composite(contentCompSearch, SWT.NONE);
                _searchPDateComp.setLayout(new GridLayout());
                ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true;
                ((GridLayout) _searchPDateComp.getLayout()).numColumns = 21;
                _searchPDateComp.setLayoutData(new GridData());
                ((GridData) _searchPDateComp.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) _searchPDateComp.getLayoutData()).grabExcessHorizontalSpace = true;
                // ((GridData) searchPDateComp.getLayoutData()).heightHint =
                // 200;
                ((GridData) _searchPDateComp.getLayoutData()).grabExcessVerticalSpace = false;
                ((GridData) _searchPDateComp.getLayoutData()).horizontalSpan = 1;

                if (i != 0) {
                    Label l2 = new Label(_searchPDateComp, SWT.NONE);
                    l2.setLayoutData(new GridData());
                    l2.setLayoutData(new GridData());
                    ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) l2.getLayoutData()).horizontalSpan = 2;
                } else {
                    Label op = new Label(_searchPDateComp, SWT.NONE);
                    op.setText(NLMessages.getString("Dialog_operand")); //$NON-NLS-1$
                    op.setLayoutData(new GridData());
                    ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) op.getLayoutData()).horizontalSpan = 2;
                }

                Label typeDate = new Label(_searchPDateComp, SWT.NONE);
                typeDate.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$
                typeDate.setLayoutData(new GridData());
                ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) typeDate.getLayoutData()).horizontalSpan = 3;

                Label bl = new Label(_searchPDateComp, SWT.NONE);
                bl.setText(""); //$NON-NLS-1$
                bl.setLayoutData(new GridData());
                ((GridData) bl.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) bl.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) bl.getLayoutData()).horizontalSpan = 2;

                Label notBefore = new Label(_searchPDateComp, SWT.NONE);
                notBefore.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$
                notBefore.setLayoutData(new GridData());
                ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) notBefore.getLayoutData()).horizontalSpan = 1;

                Label month = new Label(_searchPDateComp, SWT.NONE);
                month.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$
                month.setLayoutData(new GridData());
                ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) month.getLayoutData()).horizontalSpan = 1;

                Label year = new Label(_searchPDateComp, SWT.NONE);
                year.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$
                year.setLayoutData(new GridData());
                ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) year.getLayoutData()).horizontalSpan = 3;

                Label bl2 = new Label(_searchPDateComp, SWT.NONE);
                bl2.setText(""); //$NON-NLS-1$
                bl2.setLayoutData(new GridData());

                ((GridData) bl2.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) bl2.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) bl2.getLayoutData()).horizontalSpan = 2;

                Label notAfter = new Label(_searchPDateComp, SWT.NONE);
                notAfter.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$
                notAfter.setLayoutData(new GridData());
                ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) notAfter.getLayoutData()).horizontalSpan = 1;

                Label month2 = new Label(_searchPDateComp, SWT.NONE);
                month2.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$
                month2.setLayoutData(new GridData());
                ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) month2.getLayoutData()).horizontalSpan = 1;

                Label year2 = new Label(_searchPDateComp, SWT.NONE);
                year2.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$
                year2.setLayoutData(new GridData());
                ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) year2.getLayoutData()).horizontalSpan = 3;

                if (i != 0) {
                    Label l2 = new Label(_searchPDateComp, SWT.NONE);
                    l2.setLayoutData(new GridData());
                    l2.setLayoutData(new GridData());
                    ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) l2.getLayoutData()).horizontalSpan = 2;
                } else {
                    Label include = new Label(_searchPDateComp, SWT.NONE);
                    include.setText(NLMessages.getString("Dialog_include")); //$NON-NLS-1$
                    include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$
                    include.setLayoutData(new GridData());
                    ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) include.getLayoutData()).horizontalSpan = 1;

                    Label del = new Label(_searchPDateComp, SWT.NONE);
                    del.setText(NLMessages.getString("Dialog_del")); //$NON-NLS-1$
                    del.setLayoutData(new GridData());
                    ((GridData) del.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) del.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) del.getLayoutData()).horizontalSpan = 1;
                }

            }

            if (i == 0) {
                Label l = new Label(_searchPDateComp, SWT.NONE);
                l.setLayoutData(new GridData());
                ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) l.getLayoutData()).horizontalSpan = 2;
            } else {
                final Combo opCombo = new Combo(_searchPDateComp, SWT.READ_ONLY);
                opCombo.setLayoutData(new GridData());
                opCombo.add(Operator.AND.toString());
                opCombo.add(Operator.OR.toString());
                opCombo.add(Operator.NOT.toString());
                opCombo.setLayoutData(new GridData());
                ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) opCombo.getLayoutData()).horizontalSpan = 2;
                if (c.getOperator() != null) {
                    opCombo.setText(c.getOperator());
                } else {
                    opCombo.select(0);
                    c.setOperator(opCombo.getItem(0));

                }
                opCombo.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent se) {
                        c.setOperator(opCombo.getItem(opCombo.getSelectionIndex()));
                    }
                });
            }

            final Combo typeDCombo = new Combo(_searchPDateComp, SWT.READ_ONLY);
            typeDCombo.setLayoutData(new GridData());
            ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo);
            timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
            timeTypeComboViewer.setLabelProvider(new LabelProvider() {

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

            });
            timeTypeComboViewer.setInput(AEConstants.TIME_TYPES);
            timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection selection = event.getSelection();
                    Object obj = ((IStructuredSelection) selection).getFirstElement();
                    String s = (String) obj;
                    c.setDateType(s);
                }

            });
            if (c.getDateType() != null) {
                StructuredSelection selection = new StructuredSelection(c.getDateType());
                timeTypeComboViewer.setSelection(selection);
            } else {
                StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]);
                timeTypeComboViewer.setSelection(selection);
                c.setDateType(AEConstants.TIME_TYPES[0]);
            }
            typeDCombo.pack();
            typeDCombo.setLayoutData(new GridData());
            ((GridData) typeDCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) typeDCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) typeDCombo.getLayoutData()).horizontalSpan = 2;

            Label from = new Label(_searchPDateComp, SWT.NONE);
            from.setText(NLMessages.getString("Dialog_from")); //$NON-NLS-1$
            from.setLayoutData(new GridData());
            ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) from.getLayoutData()).horizontalSpan = 2;

            final Combo day1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY);
            day1Combo.setLayoutData(new GridData());
            day1Combo.setItems(AEConstants.DAYS);
            day1Combo.setLayoutData(new GridData());
            ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1;

            if (c.getDateFrom() == null) {
                PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$
                // dateFrom.setDay(0);
                // dateFrom.setMonth(0);
                // dateFrom.setYear(0);
                c.setDateFrom(dateFrom);
                day1Combo.select(c.getDateFrom().getDay());
            }
            //            System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$
            // else
            // {
            //
            // day1Combo.select(0);
            // c.getDateFrom().setDay(0);
            //
            // }

            day1Combo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    c.getDateFrom().setDay(day1Combo.getSelectionIndex());
                }
            });

            final Combo month1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY);
            month1Combo.setLayoutData(new GridData());
            month1Combo.setItems(AEConstants.MONTHS);
            month1Combo.setLayoutData(new GridData());
            ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1;
            if (c.getDateFrom() != null) {
                month1Combo.select(c.getDateFrom().getMonth());
            } else {

                month1Combo.select(0);
                c.getDateFrom().setMonth(0);

            }

            month1Combo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    c.getDateFrom().setMonth(month1Combo.getSelectionIndex());
                }
            });

            final YearSpinner year1Spinner = new YearSpinner(_searchPDateComp, SWT.NULL);
            if (c.getDateFrom() != null) {
                year1Spinner.setSelection(c.getDateFrom().getYear());
            } else {

                year1Spinner.setSelection(_preselection);
                c.getDateFrom().setYear(_preselection);

            }

            year1Spinner.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetDefaultSelected(final SelectionEvent e) {
                    c.getDateFrom().setYear(year1Spinner.getSelection());

                }

                @Override
                public void widgetSelected(final SelectionEvent e) {
                    c.getDateFrom().setYear(year1Spinner.getSelection());
                }

            });

            Label to = new Label(_searchPDateComp, SWT.NONE);
            to.setText(NLMessages.getString("Dialog_to")); //$NON-NLS-1$
            to.setLayoutData(new GridData());
            ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) to.getLayoutData()).horizontalSpan = 2;

            final Combo day2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY);
            day2Combo.setLayoutData(new GridData());
            day2Combo.setItems(AEConstants.DAYS);
            day2Combo.setLayoutData(new GridData());
            ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1;
            if (c.getDateTo() == null) {
                PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$
                c.setDateTo(dateTo);
                day2Combo.select(c.getDateTo().getDay());
            }

            day2Combo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    c.getDateTo().setDay(day2Combo.getSelectionIndex());
                }
            });

            final Combo month2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY);
            month2Combo.setLayoutData(new GridData());
            month2Combo.setItems(AEConstants.MONTHS);
            month2Combo.setLayoutData(new GridData());
            ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1;
            if (c.getDateTo() != null) {
                month2Combo.select(c.getDateTo().getMonth());
            } else {

                month2Combo.select(0);
                c.getDateTo().setMonth(0);

            }

            month2Combo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    c.getDateTo().setMonth(month2Combo.getSelectionIndex());
                }
            });

            final YearSpinner year2Spinner = new YearSpinner(_searchPDateComp, SWT.NULL);
            if (c.getDateTo() != null) {
                year2Spinner.setSelection(c.getDateTo().getYear());
            } else {
                year2Spinner.setSelection(_preselection);
                c.getDateTo().setYear(_preselection);
            }

            year2Spinner.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetDefaultSelected(final SelectionEvent e) {
                    c.getDateTo().setYear(year2Spinner.getSelection());

                }

                @Override
                public void widgetSelected(final SelectionEvent e) {
                    c.getDateTo().setYear(year2Spinner.getSelection());
                }

            });

            final Button includeB = new Button(_searchPDateComp, SWT.CHECK);
            includeB.setLayoutData(new GridData());
            includeB.setSelection(c.isIncludeConcurrences());
            includeB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setIncludeConcurrences(!c.isIncludeConcurrences());
                }
            });

            final Button delTagCriteria = new Button(_searchPDateComp, SWT.PUSH);
            delTagCriteria.setLayoutData(new GridData());
            delTagCriteria.setText("-"); //$NON-NLS-1$
            delTagCriteria.setData("tag", i); //$NON-NLS-1$

            delTagCriteria.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    buildPersonSearch(2, ((Integer) delTagCriteria.getData("tag"))); //$NON-NLS-1$
                }
            });
        } // if date
        if (c.getType().equals("reference")) //$NON-NLS-1$
        {
            _searchPRefComp = new Composite(contentCompSearch, SWT.NONE);
            _searchPRefComp.setLayout(new GridLayout());
            ((GridLayout) _searchPRefComp.getLayout()).makeColumnsEqualWidth = true;
            ((GridLayout) _searchPRefComp.getLayout()).numColumns = 15;
            _searchPRefComp.setLayoutData(new GridData());
            ((GridData) _searchPRefComp.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) _searchPRefComp.getLayoutData()).grabExcessHorizontalSpace = true;
            // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200;
            ((GridData) _searchPRefComp.getLayoutData()).grabExcessVerticalSpace = false;
            ((GridData) _searchPRefComp.getLayoutData()).horizontalSpan = 1;

            final Combo opCombo = new Combo(_searchPRefComp, SWT.READ_ONLY);
            opCombo.setLayoutData(new GridData());
            opCombo.add(Operator.AND.toString());
            opCombo.add(Operator.OR.toString());
            opCombo.add(Operator.NOT.toString());
            opCombo.setLayoutData(new GridData());
            ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) opCombo.getLayoutData()).horizontalSpan = 2;
            if (c.getOperator() != null) {
                opCombo.setText(c.getOperator());
            } else {
                opCombo.select(0);
                c.setOperator(opCombo.getItem(0));

            }
            opCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    c.setOperator(opCombo.getItem(opCombo.getSelectionIndex()));
                }
            });

            Label sem = new Label(_searchPRefComp, SWT.NONE);
            sem.setText(NLMessages.getString("Dialog_reference")); //$NON-NLS-1$
            sem.setLayoutData(new GridData());
            ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) sem.getLayoutData()).horizontalSpan = 2;

            Label tagName = new Label(_searchPRefComp, SWT.NONE);
            tagName.setText(NLMessages.getString("Dialog_genre")); //$NON-NLS-1$
            tagName.setLayoutData(new GridData());
            ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) tagName.getLayoutData()).horizontalSpan = 2;

            final Combo genreCombo = new Combo(_searchPRefComp, SWT.READ_ONLY);
            genreCombo.setLayoutData(new GridData());
            ComboViewer genreComboViewer = new ComboViewer(genreCombo);
            genreComboViewer.setContentProvider(new RefTemplateContentProvider(false));
            genreComboViewer.setLabelProvider(new LabelProvider() {

                @Override
                public String getText(final Object element) {
                    ReferenceModsTemplate template = (ReferenceModsTemplate) element;
                    return template.getLabel();
                }

            });

            genreComboViewer.setInput(_facade.getAllGenres());
            genreComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection selection = event.getSelection();
                    Object obj = ((IStructuredSelection) selection).getFirstElement();
                    ReferenceModsTemplate template = (ReferenceModsTemplate) obj;
                    if (template != null) {
                        c.setCrit0(template.getValue());
                    }
                }

            });
            genreCombo.add("ALL", 0); //$NON-NLS-1$

            genreCombo.setLayoutData(new GridData());
            ((GridData) genreCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) genreCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) genreCombo.getLayoutData()).horizontalSpan = 2;
            if (c.getCrit0() != null) {
                StructuredSelection selection = new StructuredSelection(c.getCrit0());
                genreComboViewer.setSelection(selection);
            } else {
                genreCombo.select(0);
                c.setCrit0(genreCombo.getItem(0));

            }

            Label tagType = new Label(_searchPRefComp, SWT.NONE);
            tagType.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$
            tagType.setLayoutData(new GridData());
            ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) tagType.getLayoutData()).horizontalSpan = 2;

            final Text searchText = new Text(_searchPRefComp, SWT.BORDER);
            searchText.setLayoutData(new GridData());
            searchText.setLayoutData(new GridData());
            ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) searchText.getLayoutData()).horizontalSpan = 3;
            if (c.getSearchText() != null) {
                searchText.setText(c.getSearchText());
            }
            searchText.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(final FocusEvent e) {
                    c.setSearchText(searchText.getText());
                }
            });

            final Button fuzzyB = new Button(_searchPRefComp, SWT.CHECK);
            fuzzyB.setLayoutData(new GridData());
            fuzzyB.setSelection(c.isFuzzy());
            fuzzyB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setFuzzy(!c.isFuzzy());
                }
            });

            final Button includeB = new Button(_searchPRefComp, SWT.CHECK);
            includeB.setLayoutData(new GridData());
            includeB.setSelection(c.isIncludeConcurrences());
            includeB.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    c.setIncludeConcurrences(!c.isIncludeConcurrences());
                }
            });

        } // if reference
    }
    contentCompSearch.layout();
    _scrollCompSearch.setContent(contentCompSearch);
    _scrollCompSearch.setMinSize(contentCompSearch.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
    _scrollCompSearch.layout();
    _personSearchGroup.redraw();
    _personSearchGroup.layout();
    _personSearchGroup.pack();
    _personSearchGroup.layout();
    // personSearchGroup.pack();

}

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

License:Open Source License

/**
 * <h4>Load time spatial dim.</h4>
 * <p>/*ww w .j  a  v a  2 s .  c  o m*/
 * generates GUI elements for representation and modification of
 * {@link TimeDim} and {@link SpatialDim} information of the current {@link Aspect}.
 * </p><p>
 * Can also add/remove {@link TimeStm}/{@link SpatialStm} or {@link Time}/{@link Place} 
 * objects prior to GUI assemblage. Functional behaviour is determined by parameter <code>type</code>:
 * <ul><li>0. Do nothing, just make GUI stuff</li>
 * <li>1. Add new {@link TimeStm}</li>
 * <li>2. Delete {@link TimeStm} at index <code>timeStm</code></li>
 * <li>3. Add new {@link Time} object at index <code>timeStm</code></li>
 * <li>4. Delete {@link Time} element  index <code>timeStm</code></li>
 * <li>5. add new {@link SpatialStm}</li>
 * <li>6. Delete {@link SpatialStm}</li>
 * <li>7. Add new {@link Place} at  index <code>spatialStm</code></li>
 * <li>8. Delete {@link Place} at  index <code>spatialStm</code></li>
 * <li>15. Add both new {@link TimeStm} and {@link SpatialStm}</li></ul>
 * </p>
 * @param type numerical value specifying functional behaviour
 * @param timeStm index of {@link TimeStm} to be deleted or to which an additional {@link Time} object is to be added
 * @param time index of {@link Time} element to be deleted. The {@link TimeStm} in which deletion is to be done must be specified using <code>timeStm</code> param. 
 * @param spatialStm index of {@link SpatialStm} which should be deleted or extended by a new {@link Place} element
 * @param place index of {@link Place} element which shall be deleted. spatialStm must we specified as well, obviously.
 */
private void loadTimeSpatialDim(Integer type, final Integer timeStm, final Integer time,
        final Integer spatialStm, final Integer place) {
    System.out.println("LOAD loadTimeSpatialDim");
    if (_scrollCompTimePlace != null) {
        _scrollCompTimePlace.dispose();
    }
    if (_timeGroup != null) {
        _timeGroup.dispose();
    }
    if (_placeGroup != null) {
        _placeGroup.dispose();
    }
    _scrollCompTimePlace = new ScrolledComposite(_dimensionComposite, SWT.BORDER | SWT.V_SCROLL);
    _scrollCompTimePlace.setExpandHorizontal(true);
    _scrollCompTimePlace.setExpandVertical(true);
    _scrollCompTimePlace.setMinHeight(1);
    _scrollCompTimePlace.setMinWidth(1);

    _scrollCompTimePlace.setLayout(new GridLayout());
    _scrollCompTimePlace.setLayoutData(new GridData());
    ((GridData) _scrollCompTimePlace.getLayoutData()).heightHint = 490;
    ((GridData) _scrollCompTimePlace.getLayoutData()).widthHint = 700;
    ((GridData) _scrollCompTimePlace.getLayoutData()).horizontalSpan = 2;

    ((GridData) _scrollCompTimePlace.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _scrollCompTimePlace.getLayoutData()).grabExcessHorizontalSpace = true;
    _scrollCompTimePlace.layout();

    Composite contentCompTimePlace = new Composite(_scrollCompTimePlace, SWT.NONE);
    contentCompTimePlace.setLayout(new GridLayout());
    _scrollCompTimePlace.setContent(contentCompTimePlace);

    if (_currentAspect.getTimeDim() == null) {
        _currentAspect.setTimeDim(new TimeDim());
        _currentAspect.getTimeDim().setTimeStms(new Vector<TimeStm>());
    }
    if (_currentAspect.getSpatialDim() == null) {
        _currentAspect.setSpatialDim(new SpatialDim());
        _currentAspect.getSpatialDim().setSpatialStms(new Vector<SpatialStm>());
    }
    if (_currentAspect.getTimeDim().getTimeStms().size() == 0
            && _currentAspect.getSpatialDim().getSpatialStms().size() == 0) {
        type = 15;
    } else if (_currentAspect.getTimeDim().getTimeStms().size() == 0) {
        type = 1;
    } else if (_currentAspect.getSpatialDim().getSpatialStms().size() == 0) {
        type = 5;
    }

    switch (type) {
    case 0:
        break; // nix, normales laden
    case 1: // neues timeStm einfgen

        _currentAspect.getTimeDim().getTimeStms().add(new TimeStm());

        break;
    case 2: // timeStm lschen
        _currentAspect.getTimeDim().remove(timeStm);
        break;
    case 3: // neue time einfgen
        _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().add(new Time());
        _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().lastElement()
                .setTimeStamp(new PdrDate(PRESELECTED_YEAR, 0, 0));

        break;
    case 4: // time lschen
        _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().removeElementAt(time);
        break;

    case 5: // neues spatialStm einfgen

        _currentAspect.getSpatialDim().getSpatialStms().add(new SpatialStm());

        break;
    case 6: // spatialStm lschen
        _currentAspect.getSpatialDim().remove(spatialStm);
        break;
    case 7: // neuer place einfgen
        _currentAspect.getSpatialDim().getSpatialStms().get(spatialStm).getPlaces().add(new Place());
        break;
    case 8: // place lschen
        _currentAspect.getSpatialDim().getSpatialStms().get(spatialStm).getPlaces().removeElementAt(place);
        break;
    case 15: // neues spatialStm und timeStm einfgen
        _currentAspect.getTimeDim().getTimeStms().add(new TimeStm());
        _currentAspect.getSpatialDim().getSpatialStms().add(new SpatialStm());
        break;
    default:
        break;
    }

    if (_currentAspect.getTimeDim() != null && _currentAspect.getTimeDim().getTimeStms() != null) {
        for (int i = 0; i < _currentAspect.getTimeDim().getTimeStms().size(); i++) {
            final TimeStm tStm = _currentAspect.getTimeDim().getTimeStms().get(i);
            _timeGroup = new Group(contentCompTimePlace, SWT.SHADOW_IN);
            _timeGroup.setData("timeStm", i); //$NON-NLS-1$
            _timeGroup.setLayout(new GridLayout());
            ((GridLayout) _timeGroup.getLayout()).numColumns = 5;
            _timeGroup.setLayoutData(new GridData());
            ((GridLayout) _timeGroup.getLayout()).makeColumnsEqualWidth = false;
            ((GridData) _timeGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) _timeGroup.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) _timeGroup.getLayoutData()).minimumHeight = 20;

            int m = 1 + i;
            _timeGroup.setText(NLMessages.getString("Editor_timeStm") + m);

            Label spatialStmTypeLabel = new Label(_timeGroup, SWT.NONE);
            spatialStmTypeLabel.setText(NLMessages.getString("Editor_space_type"));
            spatialStmTypeLabel.setLayoutData(new GridData());

            final Combo timeStmCombo = new Combo(_timeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            timeStmCombo.setEnabled(_mayWrite);
            timeStmCombo.setBackground(WHITE_COLOR);
            timeStmCombo.setLayoutData(new GridData());
            ((GridData) timeStmCombo.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) timeStmCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) timeStmCombo.getLayoutData()).horizontalSpan = 2;
            ComboViewer timeStmComboViewer = new ComboViewer(timeStmCombo);
            timeStmComboViewer.setContentProvider(ArrayContentProvider.getInstance());
            timeStmComboViewer.setLabelProvider(new LabelProvider() {

                @Override
                public String getText(final Object element) {
                    String str = (String) element;
                    return NLMessages.getString("Editor_timetypes_" + str);
                }

            });

            timeStmComboViewer.setInput(AEConstants.TIMEDIMTYPES);
            timeStmComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection selection = event.getSelection();
                    Object obj = ((IStructuredSelection) selection).getFirstElement();
                    String s = (String) obj;
                    tStm.setType(s);
                }

            });
            if (tStm.getType() != null) {
                StructuredSelection selection = new StructuredSelection(tStm.getType());
                timeStmComboViewer.setSelection(selection);
            } else {
                timeStmCombo.select(0);
                ISelection selection = timeStmComboViewer.getSelection();
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                String s = (String) obj;
                tStm.setType(s);
            }

            final Button delTimeStm = new Button(_timeGroup, SWT.PUSH);
            delTimeStm.setText(NLMessages.getString("Editor_delete"));
            delTimeStm.setToolTipText(NLMessages.getString("Editor_remove_timeStm_tip"));
            delTimeStm.setImage(_imageReg.get(IconsInternal.TIME_REMOVE));
            delTimeStm.setLayoutData(_gridData);
            delTimeStm.setData("timeStm", i); //$NON-NLS-1$
            delTimeStm.setEnabled(_currentAspect.getTimeDim().getTimeStms().size() > 1 && _mayWrite);
            delTimeStm.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    //               System.out.println("del timeStm " + (Integer) delTimeStm.getData("timeStm")); //$NON-NLS-1$ //$NON-NLS-2$
                    loadTimeSpatialDim(2, (Integer) delTimeStm.getData("timeStm"), null, null, null); //$NON-NLS-1$
                    validate();

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

            final Button addTime = new Button(_timeGroup, SWT.PUSH);
            addTime.setText(NLMessages.getString("Editor_addTime"));
            addTime.setToolTipText(NLMessages.getString("Editor_add_time_tip"));
            addTime.setImage(_imageReg.get(IconsInternal.ADD));
            addTime.setEnabled(_mayWrite);
            addTime.setLayoutData(_gridData);
            addTime.setData("timeStm", i); //$NON-NLS-1$
            addTime.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    //               System.out.println("add time " + (Integer) addTime.getData("timeStm")); //$NON-NLS-1$ //$NON-NLS-2$
                    loadTimeSpatialDim(3, (Integer) addTime.getData("timeStm"), null, null, null); //$NON-NLS-1$
                    validate();

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

            if (tStm.getTimes() != null) {

                for (int j = 0; j < tStm.getTimes().size(); j++) {
                    final Time tTime = tStm.getTimes().get(j);
                    final Composite compositeTime = new Composite(_timeGroup, SWT.NONE);
                    compositeTime.setData("timeStm", i); //$NON-NLS-1$
                    compositeTime.setData("time", j); //$NON-NLS-1$
                    compositeTime.setLayout(new GridLayout());
                    compositeTime.setLayoutData(new GridData());
                    ((GridLayout) compositeTime.getLayout()).numColumns = 8;
                    ((GridLayout) compositeTime.getLayout()).makeColumnsEqualWidth = false;
                    ((GridData) compositeTime.getLayoutData()).horizontalSpan = 5;
                    ((GridData) compositeTime.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) compositeTime.getLayoutData()).grabExcessHorizontalSpace = true;

                    FocusListener focusListener = new FocusAdapter() {
                    };
                    int l = j + 1;
                    Label timeLabel = new Label(compositeTime, SWT.NONE);
                    timeLabel.setText(NLMessages.getString("Editor_time_space") + l);
                    timeLabel.setLayoutData(new GridData());

                    final Combo timeTypeCombo = new Combo(compositeTime, SWT.DROP_DOWN | SWT.READ_ONLY);
                    timeTypeCombo.setBackground(WHITE_COLOR);
                    timeTypeCombo.setEnabled(_mayWrite);
                    timeTypeCombo.setLayoutData(new GridData());
                    ((GridData) timeTypeCombo.getLayoutData()).horizontalSpan = 1;
                    ((GridData) timeTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) timeTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                    ComboViewer timeTypeComboViewer = new ComboViewer(timeTypeCombo);
                    timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
                    timeTypeComboViewer.setLabelProvider(new LabelProvider() {

                        @Override
                        public String getText(final Object element) {
                            String str = (String) element;
                            if (NLMessages.getString("Editor_time_" + str) != null) {
                                return NLMessages.getString("Editor_time_" + str);
                            }
                            return str;
                        }

                    });

                    timeTypeComboViewer.setInput(AEConstants.TIME_TYPES);
                    timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                        @Override
                        public void selectionChanged(final SelectionChangedEvent event) {
                            ISelection selection = event.getSelection();
                            Object obj = ((IStructuredSelection) selection).getFirstElement();
                            String s = (String) obj;
                            tTime.setType(s);
                        }

                    });
                    if (tTime.getType() != null) {
                        StructuredSelection selection = new StructuredSelection(tTime.getType());
                        timeTypeComboViewer.setSelection(selection);
                    } else {
                        timeTypeCombo.select(0);
                        ISelection selection = timeTypeComboViewer.getSelection();
                        Object obj = ((IStructuredSelection) selection).getFirstElement();
                        String s = (String) obj;
                        tTime.setType(s);
                    }

                    Combo comboTimeDay = new Combo(compositeTime, 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.addFocusListener(focusListener);

                    if (tTime.getTimeStamp() != null) {
                        comboTimeDay.select(tTime.getTimeStamp().getDay());
                    }
                    comboTimeDay.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent se) {
                            tTime.getTimeStamp().setDay(timeTypeCombo.getSelectionIndex());
                        }
                    });

                    final Combo comboTimeMonth = new Combo(compositeTime, 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.addFocusListener(focusListener);

                    if (tTime.getTimeStamp() != null) {
                        comboTimeMonth.select(tTime.getTimeStamp().getMonth());
                    }
                    comboTimeMonth.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent se) {
                            tTime.getTimeStamp().setMonth(comboTimeMonth.getSelectionIndex());
                        }
                    });

                    final YearSpinner spinnerTimeYear = new YearSpinner(compositeTime, SWT.BORDER);
                    spinnerTimeYear.setEnabled(_mayWrite);
                    final ControlDecoration decoTime = new ControlDecoration(spinnerTimeYear,
                            SWT.LEFT | SWT.TOP);
                    if (tTime.getTimeStamp() != null) {
                        spinnerTimeYear.setSelection(tTime.getTimeStamp().getYear());
                    } else {
                        decoTime.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                    }
                    spinnerTimeYear.pack();
                    spinnerTimeYear.addFocusListener(focusListener);
                    spinnerTimeYear.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent se) {
                            tTime.getTimeStamp().setYear(spinnerTimeYear.getSelection());
                            if (tTime.isValid()) {
                                decoTime.setImage(null);
                            } else {
                                decoTime.setImage(FieldDecorationRegistry.getDefault()
                                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                            }
                            validate();
                        }
                    });
                    Label timeAccuracy = new Label(compositeTime, SWT.NONE);
                    timeAccuracy.setText(NLMessages.getString("Editor_quality2"));
                    timeAccuracy.setLayoutData(new GridData());

                    final Combo timeAccuracyCombo = new Combo(compositeTime, SWT.DROP_DOWN | SWT.READ_ONLY);
                    timeAccuracyCombo.setEnabled(_mayWrite);
                    timeAccuracyCombo.setBackground(WHITE_COLOR);
                    timeAccuracyCombo.setLayoutData(new GridData());
                    ((GridData) timeAccuracyCombo.getLayoutData()).horizontalSpan = 2;
                    ((GridData) timeAccuracyCombo.getLayoutData()).horizontalSpan = 1;
                    ((GridData) timeAccuracyCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) timeAccuracyCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                    ComboViewer timeAccuracyComboViewer = new ComboViewer(timeAccuracyCombo);
                    timeAccuracyComboViewer.setContentProvider(ArrayContentProvider.getInstance());
                    timeAccuracyComboViewer.setLabelProvider(new LabelProvider() {

                        @Override
                        public String getText(final Object element) {
                            String str = (String) element;
                            return NLMessages.getString("Editor_accuracy_" + str);
                        }

                    });

                    timeAccuracyComboViewer.setInput(AEConstants.TIME_ACCURACY);
                    timeAccuracyComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                        @Override
                        public void selectionChanged(final SelectionChangedEvent event) {
                            ISelection selection = event.getSelection();
                            Object obj = ((IStructuredSelection) selection).getFirstElement();
                            String s = (String) obj;
                            tTime.setAccuracy(s);
                        }

                    });
                    if (tTime.getAccuracy() != null) //$NON-NLS-1$ //$NON-NLS-2$
                    {
                        StructuredSelection selection = new StructuredSelection(tTime.getAccuracy());
                        timeAccuracyComboViewer.setSelection(selection);
                    } else {
                        timeAccuracyCombo.select(0);
                        ISelection selection = timeAccuracyComboViewer.getSelection();
                        Object obj = ((IStructuredSelection) selection).getFirstElement();
                        String s = (String) obj;
                        tTime.setAccuracy(s);
                    }

                    final Button delTime = new Button(compositeTime, SWT.PUSH);
                    delTime.setText(NLMessages.getString("Editor_deleteTime"));
                    delTime.setToolTipText(NLMessages.getString("Editor_remove_time_tip"));
                    delTime.setImage(_imageReg.get(IconsInternal.REMOVE));
                    delTime.setEnabled(_mayWrite);
                    // delTime.setImage(Activator.getDefault().getImageDescriptor("remove).createImage());
                    delTime.setLayoutData(_gridData);
                    delTime.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent event) {
                            //                     System.out.println("del time " + (Integer) compositeTime //$NON-NLS-1$
                            // .getData("timeStm")
                            //   + " " + (Integer) compositeTime.getData("time")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            loadTimeSpatialDim(4, (Integer) compositeTime.getData("timeStm"), //$NON-NLS-1$
                                    (Integer) compositeTime.getData("time"), null, null); //$NON-NLS-1$
                            validate();
                        }
                    });
                    delTime.setLayoutData(new GridData());
                    delTime.pack();
                    compositeTime.layout();
                } // compositeTime
            }
            // timeGroup
        }
    }

    // XXX this is were spatialStm controls are put together. What about this 'set key' button??
    // XXX also, are newly created place elements correctly put into aspects contents?
    if (_currentAspect.getSpatialDim() != null && _currentAspect.getSpatialDim().getSpatialStms() != null) {
        for (int i = 0; i < _currentAspect.getSpatialDim().getSpatialStms().size(); i++) {
            final SpatialStm sStm = _currentAspect.getSpatialDim().getSpatialStms().get(i);
            int l = i + 1;
            _placeGroup = new Group(contentCompTimePlace, SWT.SHADOW_IN);
            _placeGroup.setData("spatialStm", i); //$NON-NLS-1$
            _placeGroup.setLayout(new GridLayout());
            ((GridLayout) _placeGroup.getLayout()).numColumns = 5;
            _placeGroup.setText(NLMessages.getString("Editor_spatialStm") + l);
            _placeGroup.setLayoutData(new GridData());
            ((GridData) _placeGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) _placeGroup.getLayoutData()).minimumHeight = 60;
            ((GridData) _placeGroup.getLayoutData()).grabExcessHorizontalSpace = true;

            Label spatialStmTypeLabel = new Label(_placeGroup, SWT.NONE);
            spatialStmTypeLabel.setText(
                    NLMessages.getString("Editor_stm_space") + l + NLMessages.getString("Editor_space_type"));
            spatialStmTypeLabel.setLayoutData(new GridData());

            final Combo spatialTypCombo = new Combo(_placeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            spatialTypCombo.setEnabled(_mayWrite);
            spatialTypCombo.setBackground(WHITE_COLOR);
            spatialTypCombo.setLayoutData(new GridData());
            ((GridData) spatialTypCombo.getLayoutData()).horizontalAlignment = GridData.FILL;
            ((GridData) spatialTypCombo.getLayoutData()).horizontalSpan = 2;
            ((GridData) spatialTypCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ComboViewer spatialTypComboViewer = new ComboViewer(spatialTypCombo);
            spatialTypComboViewer.setContentProvider(ArrayContentProvider.getInstance());
            spatialTypComboViewer.setLabelProvider(new LabelProvider() {

                @Override
                public String getText(final Object element) {
                    String str = (String) element;
                    return NLMessages.getString("Editor_spatialdim_types_" + str);
                }

            });

            spatialTypComboViewer.setInput(AEConstants.SPATIALDIMTYPES);
            spatialTypComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

                @Override
                public void selectionChanged(final SelectionChangedEvent event) {
                    ISelection selection = event.getSelection();
                    Object obj = ((IStructuredSelection) selection).getFirstElement();
                    String s = (String) obj;
                    sStm.setType(s);
                }

            });
            if (sStm.getType() != null) //$NON-NLS-1$
            {
                StructuredSelection selection = new StructuredSelection(sStm.getType());
                spatialTypComboViewer.setSelection(selection);
            } else {
                spatialTypCombo.select(0);
                ISelection selection = spatialTypComboViewer.getSelection();
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                String s = (String) obj;
                sStm.setType(s);
            }

            final Button delSpatialStm = new Button(_placeGroup, SWT.PUSH);
            delSpatialStm.setText(NLMessages.getString("Editor_delete"));
            delSpatialStm.setToolTipText(NLMessages.getString("Editor_remove_spatialStm_tip"));
            delSpatialStm.setImage(_imageReg.get(IconsInternal.PLACE_REMOVE));
            delSpatialStm.setEnabled(_currentAspect.getSpatialDim().getSpatialStms().size() > 1 && _mayWrite);

            delSpatialStm.setLayoutData(_gridData);
            delSpatialStm.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    //                  System.out.println("del timeStm " + (Integer) placeGroup //$NON-NLS-1$
                    //                        .getData("spatialStm")); //$NON-NLS-1$
                    loadTimeSpatialDim(6, null, null, ((Integer) _placeGroup.getData("spatialStm")), null); //$NON-NLS-1$

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

            final Button addPlace = new Button(_placeGroup, SWT.PUSH);
            addPlace.setText(NLMessages.getString("Editor_addPlace"));
            addPlace.setToolTipText(NLMessages.getString("Editor_add_place_tip"));
            addPlace.setImage(_imageReg.get(IconsInternal.ADD));
            addPlace.setEnabled(_mayWrite);
            addPlace.setLayoutData(_gridData);
            addPlace.setData("spatialStm", i); //$NON-NLS-1$
            addPlace.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    //                  System.out.println("add place " + (Integer) placeGroup //$NON-NLS-1$
                    //                        .getData("spatialStm")); //$NON-NLS-1$
                    loadTimeSpatialDim(7, null, null, ((Integer) addPlace.getData("spatialStm")), null); //$NON-NLS-1$

                    validate();

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

            if (sStm.getPlaces() != null) {
                for (int j = 0; j < sStm.getPlaces().size(); j++) {
                    int m = j + 1;

                    final Place p = sStm.getPlaces().get(j);
                    final Composite compositePlace = new Composite(_placeGroup, SWT.NONE);
                    compositePlace.setData("spatialStm", i); //$NON-NLS-1$
                    compositePlace.setData("place", j); //$NON-NLS-1$
                    compositePlace.setLayout(new GridLayout());
                    compositePlace.setLayoutData(new GridData());
                    ((GridLayout) compositePlace.getLayout()).numColumns = 6;
                    ((GridLayout) compositePlace.getLayout()).makeColumnsEqualWidth = true;
                    ((GridData) compositePlace.getLayoutData()).horizontalAlignment = GridData.FILL;
                    ((GridData) compositePlace.getLayoutData()).horizontalSpan = 5;

                    @SuppressWarnings("unused")
                    FocusListener focusListener = new FocusAdapter() {

                    };

                    Label spacialLabel = new Label(compositePlace, SWT.NONE);
                    spacialLabel.setText(NLMessages.getString("Editor_palce_space") + m
                            + NLMessages.getString("Editor_space_name"));
                    spacialLabel.setLayoutData(new GridData());

                    final Text placeText = new Text(compositePlace, SWT.BORDER);
                    placeText.setEditable(_mayWrite);
                    placeText.setBackground(WHITE_COLOR);
                    placeText.setLayoutData(new GridData());
                    ((GridData) placeText.getLayoutData()).horizontalAlignment = GridData.FILL;
                    ((GridData) placeText.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) placeText.getLayoutData()).horizontalSpan = 5;
                    final ControlDecoration decoPlace = new ControlDecoration(placeText, SWT.LEFT | SWT.TOP);

                    if (p.getPlaceName() != null) {
                        placeText.setText(p.getPlaceName()); //$NON-NLS-1$

                    } else {
                        placeText.setText(""); //$NON-NLS-1$
                        decoPlace.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                    }
                    placeText.addFocusListener(new FocusListener() {
                        @Override
                        public void focusLost(final FocusEvent e) {
                            p.setPlaceName(placeText.getText()); //$NON-NLS-1$
                            if (p.isValid()) {
                                decoPlace.setImage(null);
                            } else {
                                decoPlace.setImage(FieldDecorationRegistry.getDefault()
                                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                            }
                            validate();

                        }

                        @Override
                        public void focusGained(FocusEvent e) {
                            String[] vals = new String[] { "NO PLACE FOUNG" };
                            try {
                                vals = _mainSearcher.getFacets("tagging", "placeName", p.getType(),
                                        p.getSubtype(), null);
                            } catch (Exception e1) {

                                e1.printStackTrace();
                            }
                            new AutoCompleteField(placeText, new TextContentAdapter(), vals);
                        }
                    });
                    placeText.addKeyListener(new KeyListener() {
                        @Override
                        public void keyPressed(final KeyEvent e) {
                        }

                        @Override
                        public void keyReleased(final KeyEvent e) {
                            p.setPlaceName(placeText.getText()); //$NON-NLS-1$
                            if (p.isValid()) {
                                decoPlace.setImage(null);
                            } else {
                                decoPlace.setImage(FieldDecorationRegistry.getDefault()
                                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                            }
                            validate();
                        }
                    });

                    Label placeTypeL = new Label(compositePlace, SWT.NONE);
                    placeTypeL.setText(NLMessages.getString("Editor_type"));
                    placeTypeL.setLayoutData(new GridData());

                    final Combo placeTypeCombo = new Combo(compositePlace, SWT.DROP_DOWN | SWT.READ_ONLY);
                    placeTypeCombo.setEnabled(_mayWrite);
                    placeTypeCombo.setBackground(WHITE_COLOR);
                    placeTypeCombo.setLayoutData(new GridData());
                    ((GridData) placeTypeCombo.getLayoutData()).horizontalAlignment = GridData.FILL;
                    ((GridData) placeTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) placeTypeCombo.getLayoutData()).horizontalSpan = 2;

                    ComboViewer placeTypeComboViewer = new ComboViewer(placeTypeCombo);
                    placeTypeComboViewer.setContentProvider(new MarkupContentProvider());
                    placeTypeComboViewer.setLabelProvider(new MarkupLabelProvider());
                    if (_facade.getConfigs().containsKey(_markupProvider)) {
                        placeTypeComboViewer.setInput(_facade.getConfigs().get(_markupProvider).getChildren()
                                .get("aodl:placeName").getChildren());
                    }
                    // placeTypeCombo.setItems(readConfigs(_markupProvider,
                    // "markup", "type", "placeName", null, null));
                    //
                    // for (String sdt : AEConstants.PLACESCALE)
                    // {
                    // placeTypeCombo.add(sdt);
                    // }
                    if (p.getType() != null) {
                        ViewHelper.setComboViewerByString(placeTypeComboViewer, p.getType(), true);

                    } else {
                        ConfigData cd = (ConfigData) placeTypeComboViewer.getElementAt(0);
                        p.setType(cd.getValue());
                    }

                    Label placeSubtypeL = new Label(compositePlace, SWT.NONE);
                    placeSubtypeL.setText(NLMessages.getString("Editor_subtype"));
                    placeSubtypeL.setLayoutData(new GridData());

                    final Combo placeSubtypeCombo = new Combo(compositePlace, SWT.DROP_DOWN | SWT.READ_ONLY);
                    placeSubtypeCombo.setEnabled(_mayWrite);
                    placeSubtypeCombo.setBackground(WHITE_COLOR);
                    placeSubtypeCombo.setLayoutData(new GridData());
                    ((GridData) placeSubtypeCombo.getLayoutData()).horizontalAlignment = GridData.FILL;
                    ((GridData) placeSubtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) placeSubtypeCombo.getLayoutData()).horizontalSpan = 2;
                    final ComboViewer placeSubtypeComboViewer = new ComboViewer(placeSubtypeCombo);
                    placeSubtypeComboViewer.setContentProvider(new MarkupContentProvider());
                    placeSubtypeComboViewer.setLabelProvider(new MarkupLabelProvider());

                    placeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                        @Override
                        public void selectionChanged(final SelectionChangedEvent event) {
                            ISelection iSelection = event.getSelection();
                            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                            ConfigData cd = (ConfigData) obj;
                            p.setType(cd.getValue());
                            placeSubtypeComboViewer.setInput(_facade.getConfigs().get(_markupProvider)
                                    .getChildren().get("aodl:placeName").getChildren().get(p.getType())
                                    .getChildren());
                        }
                    });

                    // for (String sdt : AEConstants.PLACESCALE)
                    // {
                    // placeSubtypeCombo.add(sdt);
                    // }
                    if (p.getSubtype() != null) {
                        ViewHelper.setComboViewerByString(placeSubtypeComboViewer, p.getSubtype(), true);
                    }
                    placeSubtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                        @Override
                        public void selectionChanged(final SelectionChangedEvent event) {
                            ISelection iSelection = event.getSelection();
                            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                            ConfigData cd = (ConfigData) obj;
                            p.setSubtype(cd.getValue());
                        }
                    });

                    Label placeKeyL = new Label(compositePlace, SWT.NONE);
                    placeKeyL.setText(NLMessages.getString("Editor_key"));
                    placeKeyL.setLayoutData(new GridData());

                    // XXX this is the spatialStm place's 'key' attr
                    final Text placeKeyText = new Text(compositePlace, SWT.BORDER);
                    placeKeyText.setEditable(_mayWrite);
                    placeKeyText.setBackground(WHITE_COLOR);
                    placeKeyText.setLayoutData(new GridData());
                    ((GridData) placeKeyText.getLayoutData()).horizontalAlignment = SWT.FILL;
                    ((GridData) placeKeyText.getLayoutData()).grabExcessHorizontalSpace = true;
                    ((GridData) placeKeyText.getLayoutData()).horizontalSpan = 3;
                    if (p.getKey() != null) {
                        placeKeyText.setText(p.getKey()); //$NON-NLS-1$
                    } else {
                        placeKeyText.setText(""); //$NON-NLS-1$
                    }
                    //XXX value from text field is only copied on lost focus event
                    placeKeyText.addFocusListener(new FocusAdapter() {
                        @Override
                        public void focusLost(final FocusEvent e) {
                            p.setKey(placeKeyText.getText());
                        }
                    });

                    final Button delPlace = new Button(compositePlace, SWT.PUSH);
                    delPlace.setText(NLMessages.getString("Editor_deletePlace"));
                    delPlace.setToolTipText(NLMessages.getString("Editor_remove_place_tip"));
                    delPlace.setImage(_imageReg.get(IconsInternal.REMOVE));
                    delPlace.setEnabled(_mayWrite);
                    delPlace.setLayoutData(_gridData);
                    delPlace.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent event) {
                            //                        System.out.println("del place " + (Integer) compositePlace //$NON-NLS-1$
                            //.getData("spatialStm") + " " + (Integer) compositePlace.getData("place")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            loadTimeSpatialDim(8, null, null, (Integer) compositePlace.getData("spatialStm"), //$NON-NLS-1$
                                    (Integer) compositePlace.getData("place")); //$NON-NLS-1$
                            validate();
                        }
                    });
                    delPlace.setLayoutData(new GridData());
                    delPlace.pack();

                    compositePlace.layout(); // compositePlace
                }
            }
            _timeGroup.layout();

            _placeGroup.layout(); // placeGroup
        }
    }
    contentCompTimePlace.layout();

    _scrollCompTimePlace.setContent(contentCompTimePlace);
    Point point = contentCompTimePlace.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    if (point.x > mp.x - 20) {
        point.x = mp.x - 20;
    }
    _scrollCompTimePlace.setMinSize(point);
    _scrollCompTimePlace.layout();
    _dimensionComposite.redraw();
    _dimensionComposite.layout();
    //      _dimensionComposite.pack();
    //      _mainTabFolder.redraw();
    _mainTabFolder.layout();
    //      _mainTabFolder.pack();
}

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

License:Open Source License

/**
 * Load identifiers./*from w ww . j a  v a 2 s . c o  m*/
 * @param add the add
 * @param del the del
 */
private void loadIdentifiers(final boolean add, final Integer del) {
    if (_scrollCompIdentifier != null) {
        _scrollCompIdentifier.dispose();
    }
    _scrollCompIdentifier = new ScrolledComposite(_identifierComposite,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    _scrollCompIdentifier.setExpandHorizontal(true);
    _scrollCompIdentifier.setExpandVertical(true);
    _scrollCompIdentifier.setMinSize(SWT.DEFAULT, SWT.DEFAULT);
    _scrollCompIdentifier.setLayoutData(new GridData());
    ((GridData) _scrollCompIdentifier.getLayoutData()).heightHint = 300;
    ((GridData) _scrollCompIdentifier.getLayoutData()).widthHint = 580;

    ((GridData) _scrollCompIdentifier.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _scrollCompIdentifier.getLayoutData()).grabExcessHorizontalSpace = true;
    _scrollCompIdentifier.setMinHeight(1);
    _scrollCompIdentifier.setMinWidth(1);

    _scrollCompIdentifier.setLayout(new GridLayout());

    Composite contentCompIdentifier = new Composite(_scrollCompIdentifier, SWT.NONE);
    contentCompIdentifier.setLayout(new GridLayout());
    _scrollCompIdentifier.setContent(contentCompIdentifier);

    if (add && _currentPerson.getIdentifiers() == null) {
        _currentPerson.setIdentifiers(new Identifiers());
        _currentPerson.getIdentifiers().setIdentifiers(new Vector<Identifier>());
        _currentPerson.getIdentifiers().getIdentifiers().add(new Identifier());
    } else if (add) {
        _currentPerson.getIdentifiers().getIdentifiers().add(new Identifier());

    }
    if (del != null) {
        //         System.out.println("old size " + _currentPerson.getIdentifiers().getIdentifiers().size()); //$NON-NLS-1$
        _currentPerson.getIdentifiers().remove(del);
    }

    for (int i = 0; i < _currentPerson.getIdentifiers().getIdentifiers().size(); i++) {
        int m = i + 1;
        final Identifier identifier = _currentPerson.getIdentifiers().getIdentifiers().get(i);
        final Group idGroup = new Group(contentCompIdentifier, SWT.SHADOW_IN);
        idGroup.setText(NLMessages.getString("Editor_externalIdentifiers") + m); //$NON-NLS-1$
        idGroup.setLayoutData(new GridData());
        idGroup.setLayout(new GridLayout());
        idGroup.setData("num", i); //$NON-NLS-1$
        ((GridData) idGroup.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) idGroup.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridLayout) idGroup.getLayout()).numColumns = 5;
        ((GridLayout) idGroup.getLayout()).makeColumnsEqualWidth = false;

        // final Combo externalIdentifierCombo = new Combo(idGroup,
        // SWT.DROP_DOWN | SWT.READ_ONLY);
        // externalIdentifierCombo.setLayoutData(new GridData());
        // externalIdentifierCombo.setEnabled(_mayWrite);
        // externalIdentifierCombo.setBackground(WHITE_COLOR);
        // // ((GridData)
        // // externalIdentifierCombo.getLayoutData()).horizontalAlignment
        // // = SWT.FILL;
        // // ((GridData)
        // //
        // externalIdentifierCombo.getLayoutData()).grabExcessHorizontalSpace
        // // = true;
        // for (String sdt : AEConstants.EXTERNAL_IDENTIFIER_PROVIDER)
        // {
        // externalIdentifierCombo.add(sdt);
        // }

        final Combo idProviderCombo = new Combo(idGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        idProviderCombo.setEnabled(_mayWrite);
        idProviderCombo.setBackground(WHITE_COLOR);
        final ComboViewer idProviderComboViewer = new ComboViewer(idProviderCombo);
        idProviderComboViewer.setContentProvider(new MarkupContentProvider());
        idProviderComboViewer.setLabelProvider(new MarkupLabelProvider());

        idProviderCombo.setLayoutData(new GridData());
        ((GridData) idProviderCombo.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) idProviderCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) idProviderCombo.getLayoutData()).horizontalIndent = 6;
        if (_facade.getConfigs().get(_configProvider) != null
                && _facade.getConfigs().get(_configProvider).getUsage() != null && !_facade.getConfigs()
                        .get(_configProvider).getUsage().getIdentifiers().getChildren().isEmpty()) {
            ConfigData cd = _facade.getConfigs().get(_configProvider).getUsage().getIdentifiers();
            idProviderComboViewer.setInput(cd.getChildren());

        }
        idProviderComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection iSelection = event.getSelection();
                Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                IAEPresentable cp = (IAEPresentable) obj;
                if (cp != null) {
                    identifier.setProvider(cp.getValue());
                    validate();
                }

            }

        });

        if (identifier.getProvider() != null) {
            ViewHelper.setComboViewerByString(idProviderComboViewer, identifier.getProvider(), true);
        } else if (idProviderCombo.getItemCount() > 0) {
            idProviderComboViewer.setSelection(new StructuredSelection(idProviderComboViewer.getElementAt(0)));
        }

        final Text idText = new Text(idGroup, SWT.BORDER);
        idText.setLayoutData(new GridData());
        idText.setEditable(_mayWrite);
        idText.setBackground(WHITE_COLOR);
        ((GridData) idText.getLayoutData()).horizontalSpan = 3;
        ((GridData) idText.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) idText.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) idText.getLayoutData()).horizontalIndent = 8;

        final ControlDecoration decoIdent = new ControlDecoration(idText, SWT.LEFT | SWT.TOP);
        if (identifier.getIdentifier() != null) {
            idText.setText(identifier.getIdentifier()); //$NON-NLS-1$
        } else {
            idText.setText(""); //$NON-NLS-1$
            decoIdent.setImage(FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
        }

        idText.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(final FocusEvent e) {
                identifier.setIdentifier(idText.getText()); //$NON-NLS-1$
                if (identifier.isValidId()) {
                    decoIdent.setImage(null);
                } else {
                    decoIdent.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                }
                validate();
            }
        });
        idText.addKeyListener(new KeyListener() {

            @Override
            public void keyPressed(final KeyEvent e) {
            }

            @Override
            public void keyReleased(final KeyEvent e) {
                //               System.out.println("key released"); //$NON-NLS-1$
                identifier.setIdentifier(idText.getText()); //$NON-NLS-1$
                if (identifier.isValidId()) {
                    decoIdent.setImage(null);
                } else {
                    decoIdent.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                }
                validate();
            }
        });

        final Button showData = new Button(idGroup, SWT.PUSH);
        showData.setText(NLMessages.getString("Editor_showData")); //$NON-NLS-1$
        showData.setToolTipText(NLMessages.getString("Editor_showData_tooltip"));
        showData.setImage(_imageReg.get(IconsInternal.BROWSER));
        showData.setLayoutData(new GridData());
        showData.setData("num", i); //$NON-NLS-1$
        showData.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {

                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                        .getService(IHandlerService.class);
                _facade.setRequestedIdentifierType(identifier.getProvider()); //$NON-NLS-1$
                _facade.setRequestedIdentifier(identifier.getIdentifier()); //$NON-NLS-1$
                try {
                    handlerService.executeCommand("org.bbaw.pdr.ae.view.identifiers.commands" + //$NON-NLS-1$
                    ".OpenBrowserDialog", null); //$NON-NLS-1$
                } catch (ExecutionException e) {
                    e.printStackTrace();
                } catch (NotDefinedException e) {
                    e.printStackTrace();
                } catch (NotEnabledException e) {
                    e.printStackTrace();
                } catch (NotHandledException e) {
                    e.printStackTrace();
                }
            }
        });

        Label qualityLabel = new Label(idGroup, SWT.NONE);
        qualityLabel.setText(""); //$NON-NLS-1$
        qualityLabel.setLayoutData(new GridData());
        final ControlDecoration decoIdentQual = new ControlDecoration(qualityLabel, SWT.LEFT | SWT.TOP);
        // final String qual = "";
        SelectionListener idListener = new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(final SelectionEvent e) {

                validate();

            }

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final String qual = (String) ((Button) e.getSource()).getData("text");
                //                 System.out.println("pnd qual: " + pndQual); //$NON-NLS-1$
                identifier.setQuality(qual); //$NON-NLS-1$
                if (identifier.isValidQuality()) {
                    decoIdentQual.setImage(null);
                } else {
                    decoIdentQual.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
                }
                validate();
            }
        };

        final Button[] radios = new Button[_ratings.length];

        for (int j = 0; j < _ratings.length; j++) {
            radios[j] = new Button(idGroup, SWT.RADIO);
            radios[j].setText(NLMessages.getString("Editor_" + _ratings[j]));
            radios[j].setData("text", _ratings[j]);
            radios[j].setEnabled(_mayWrite);
            radios[j].setLayoutData(new GridData());
            radios[j].addSelectionListener(idListener);
        }

        if (identifier.getQuality() != null) {
            ViewHelper.setRadioByString(radios, identifier.getQuality());
        } else {
            decoIdentQual.setImage(FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());

        }
        Label b = new Label(idGroup, SWT.NONE);
        b.setText(""); //$NON-NLS-1$
        b.setLayoutData(new GridData());
        Label idAuthorityLabel = new Label(idGroup, SWT.NONE);
        idAuthorityLabel.setText(NLMessages.getString("Editor_createdBy")); //$NON-NLS-1$
        idAuthorityLabel.setLayoutData(new GridData());

        final Text idAuthorityText = new Text(idGroup, SWT.BORDER | SWT.READ_ONLY);
        idAuthorityText.setData("num", i); //$NON-NLS-1$

        if (identifier.getAuthority() != null) {
            User u = null;
            try {
                u = _facade.getUserManager().getUserById(identifier.getAuthority().toString());
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            if (u != null) {
                idAuthorityText.setText(u.getDisplayName());
            } else {
                idAuthorityText.setText(identifier.getAuthority().toString());
            }
        } else {
            idAuthorityText.setText(_facade.getCurrentUser().getPdrId().toString());
            identifier.setAuthority(_facade.getCurrentUser().getPdrId());
        }

        idAuthorityText.setLayoutData(new GridData());
        ((GridData) idAuthorityText.getLayoutData()).horizontalSpan = 3;
        ((GridData) idAuthorityText.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) idAuthorityText.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) idAuthorityText.getLayoutData()).horizontalIndent = 8;
        final Button delIdentifier = new Button(idGroup, SWT.PUSH);
        delIdentifier.setText(NLMessages.getString("Editor_delete")); //$NON-NLS-1$
        delIdentifier.setToolTipText(NLMessages.getString("Editor_remove_identifier_tooltip"));
        delIdentifier.setImage(_imageReg.get(IconsInternal.IDENTIFIER_REMOVE));
        delIdentifier.setLayoutData(new GridData());
        delIdentifier.setData("num", i); //$NON-NLS-1$
        delIdentifier.setEnabled(_mayWrite);

        delIdentifier.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                //               System.out.println("del identifier " + (Integer) delIdentifier.getData("num")); //$NON-NLS-1$ //$NON-NLS-2$
                loadIdentifiers(false, (Integer) delIdentifier.getData("num")); //$NON-NLS-1$
                validate();

            }
        });
        idGroup.layout();
        idGroup.pack();
    } // idGroup
    contentCompIdentifier.redraw();
    contentCompIdentifier.layout();

    _scrollCompIdentifier.setContent(contentCompIdentifier);
    Point point = contentCompIdentifier.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    if (point.x > mp.x - 20) {
        point.x = mp.x - 20;
    }
    _scrollCompIdentifier.setMinSize(point);
    _scrollCompIdentifier.layout();
    _identifierComposite.redraw();
    _identifierComposite.layout();

    // _scrollCompIdentifier.setSize(DIALOG_DEFAULT_BOUNDS,
    // DIALOG_DEFAULT_BOUNDS);
    _identifierComposite.update();
}

From source file:org.eclipse.emf.diffmerge.ui.setup.ComparisonSetupWizardPage.java

License:Open Source License

/**
 * Create the section for selecting the comparison method
 * @param parent_p a non-null composite/*from ww w .j a  v a 2  s  .  c om*/
 */
protected void createComparisonMethodSection(Composite parent_p) {
    // Group
    Group group = new Group(parent_p, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    group.setLayout(new GridLayout(1, false));
    group.setText(Messages.ComparisonSetupWizardPage_GroupMethod);
    // Widgets and viewers
    ComboViewer methodViewer = createComparisonMethodViewer(group);
    createConfigureMethodButton(group);
    // Init
    methodViewer.setInput(_setup);
    Object first = methodViewer.getElementAt(0);
    IStructuredSelection viewerSelection;
    if (first != null)
        viewerSelection = new StructuredSelection(first);
    else
        viewerSelection = new StructuredSelection();
    methodViewer.setSelection(viewerSelection);
}

From source file:org.fusesource.ide.camel.editor.globalconfiguration.dataformat.wizards.pages.DataFormatSelectionPage.java

License:Open Source License

/**
 * @param container//from w w  w  .  jav  a 2s  .  c  om
 */
private void createDataFormatSelectionLine(Composite container) {
    Label l = new Label(container, SWT.NONE);
    l.setText(UIMessages.dataFormatSelectionPage_dataformatLabel);
    l.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));

    ComboViewer dataformatComboViewer = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    dataformatComboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    dataformatComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    dataformatComboViewer.setLabelProvider(new DataFormatLabelProvider());
    dataformatComboViewer.setComparator(new ViewerComparator());
    dataformatComboViewer.setInput(dfModel.getSupportedDataFormats().toArray());

    dbc.bindValue(ViewerProperties.singleSelection().observe(dataformatComboViewer), PojoProperties
            .value(DataFormatSelectionPage.class, "dataFormatSelected", DataFormat.class).observe(this)); //$NON-NLS-1$
    dataformatComboViewer.setSelection(new StructuredSelection(dataformatComboViewer.getElementAt(0)));
}

From source file:org.gumtree.gumnix.sics.batch.ui.views.DrivableCommandView.java

License:Open Source License

private void createParameterArea(final Composite parent, final DrivableParameter parameter) {
    /*********************************************************************
     * Initialise//from  ww  w  .ja  v  a 2s .  c  om
     *********************************************************************/
    parent.setMenu(new Menu(parent));
    final Composite parameterArea = getToolkit().createComposite(parent);
    GridLayoutFactory.swtDefaults().margins(0, 0).spacing(10, SWT.DEFAULT).numColumns(4).applyTo(parameterArea);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(parameterArea);

    final ComboViewer drivableComboViewer = new ComboViewer(parameterArea, SWT.READ_ONLY);
    drivableComboViewer.setContentProvider(new ArrayContentProvider());
    drivableComboViewer.setLabelProvider(new LabelProvider());
    drivableComboViewer.setSorter(new ViewerSorter());
    drivableComboViewer.setInput(SicsBatchUIUtils.getSicsDrivableIds());
    GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).applyTo(drivableComboViewer.getCombo());

    final Text targetText = getToolkit().createText(parameterArea, "", SWT.BORDER);
    targetText.setToolTipText("Enter target value");
    GridDataFactory.swtDefaults().hint(WIDTH_PARAMETER, SWT.DEFAULT).applyTo(targetText);

    if (DrivableCommand.isDrivingMultipleAllowed()) {
        Button addButton = getToolkit().createButton(parameterArea, "", SWT.PUSH);
        addButton.setImage(InternalImage.ADD.getImage());
        addButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                createNewParameter(parent);
                fireRefresh();
            }
        });

        Button removeButton = getToolkit().createButton(parameterArea, "", SWT.PUSH);
        removeButton.setImage(InternalImage.REMOVE.getImage());
        removeButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                // Do not delete if there is not too much left
                if (getCommand().getParameters().length <= 1) {
                    return;
                }
                parameterArea.dispose();
                getCommand().removeDrivableParameter(parameter);
                fireRefresh();
            }
        });
    }
    /*********************************************************************
     * Validation
     *********************************************************************/
    final ControlDecoration controlDec = new ControlDecoration(targetText, SWT.LEFT | SWT.BOTTOM);
    // Validate on target value change
    targetText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validate(targetText, controlDec, drivableComboViewer);
        }
    });
    // Validate on device change
    drivableComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            validate(targetText, controlDec, drivableComboViewer);
        }
    });

    /*********************************************************************
     * Data binding
     *********************************************************************/
    Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() {
        public void run() {
            bindingContext.bindValue(ViewersObservables.observeSingleSelection(drivableComboViewer),
                    BeansObservables.observeValue(parameter, "deviceId"), new UpdateValueStrategy(),
                    new UpdateValueStrategy());
            bindingContext.bindValue(SWTObservables.observeText(targetText, SWT.Modify),
                    BeansObservables.observeValue(parameter, "target"), new UpdateValueStrategy(),
                    new UpdateValueStrategy());

            /*********************************************************************
             * Default selection
             *********************************************************************/
            if (parameter.getDeviceId() == null) {
                if (drivableComboViewer.getCombo().getItemCount() > 0) {
                    drivableComboViewer.setSelection(new StructuredSelection(drivableComboViewer
                            .getElementAt(drivableComboViewer.getCombo().getItemCount() - 1)));
                }
            }
        }
    });
}

From source file:org.hibernate.eclipse.launch.AddPropertyDialog.java

License:Open Source License

private void initDefaultNames(ExporterFactory ef2, ComboViewer viewer) {
    viewer.setContentProvider(new IStructuredContentProvider() {

        ExporterFactory localEf;//  ww w. j a va 2s  .  c  o  m

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            localEf = (ExporterFactory) newInput;
        }

        public void dispose() {
            localEf = null;
        }

        public Object[] getElements(Object inputElement) {
            Iterator<Map.Entry<String, ExporterProperty>> set = localEf.getDefaultExporterProperties()
                    .entrySet().iterator();
            List<ExporterProperty> values = new ArrayList<ExporterProperty>(4);
            while (set.hasNext()) {
                Map.Entry<String, ExporterProperty> element = set.next();
                //if(!localEf.hasLocalValueFor((String) element.getKey())) {
                ExporterProperty exporterProperty = localEf.getExporterProperty(element.getKey());
                if (exporterProperty != null) {
                    values.add(exporterProperty);
                }
                //}
            }
            return values.toArray(new ExporterProperty[values.size()]);
        }
    });

    viewer.setLabelProvider(new ILabelProvider() {

        public void removeListener(ILabelProviderListener listener) {

        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void dispose() {

        }

        public void addListener(ILabelProviderListener listener) {

        }

        public String getText(Object element) {
            ExporterProperty exporterProperty = ((ExporterProperty) element);
            return exporterProperty.getDescriptionForLabel();
        }

        public Image getImage(Object element) {
            return null;
        }

    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        private SelectionListener getSelectionListener(ExporterProperty prop) {
            if (!("path".equals(prop.getType()) || "directory".equals(prop.getType()))) //$NON-NLS-1$//$NON-NLS-2$
                return null;
            final boolean isPath = "path".equals(prop.getType()); //$NON-NLS-1$
            return new SelectionListener() {
                public void widgetDefaultSelected(SelectionEvent e) {
                    widgetSelected(e);
                }

                public void widgetSelected(SelectionEvent e) {
                    String title = isPath ? HibernateConsoleMessages.ExporterSettingsTab_select_path
                            : HibernateConsoleMessages.ExporterSettingsTab_select_dir;
                    String description = isPath ? HibernateConsoleMessages.ExporterSettingsTab_select_path2
                            : HibernateConsoleMessages.ExporterSettingsTab_select_dir2;

                    MessageDialog dialog = new MessageDialog(getShell(), title, null, description,
                            MessageDialog.QUESTION,
                            new String[] { HibernateConsoleMessages.CodeGenerationSettingsTab_filesystem,
                                    HibernateConsoleMessages.CodeGenerationSettingsTab_workspace,
                                    IDialogConstants.CANCEL_LABEL },
                            1);
                    int answer = dialog.open();
                    String strPath = null;
                    if (answer == 0) { // filesystem
                        DirectoryDialog dialog2 = new DirectoryDialog(getShell());
                        dialog2.setText(title);
                        dialog2.setMessage(description);

                        String dir = dialog2.open();
                        if (dir != null) {
                            strPath = dir;
                        }
                    } else if (answer == 1) { // workspace                        
                        IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), (IPath) null,
                                new Path[0], title, description, new String[0], isPath, true, false);
                        if (paths != null && paths.length > 0) {
                            strPath = paths[0].toOSString();
                            if (isPath) {
                                for (int i = 1; i < paths.length; i++) {
                                    strPath += ';' + paths[i].toOSString();
                                }
                            }
                        }
                    } else
                        return;
                    String oldPath = ((Text) value).getText();
                    if (isPath && oldPath.trim().length() > 0 && strPath != null)
                        ((Text) value).setText(oldPath + ';' + strPath);
                    else {
                        if (strPath != null)
                            ((Text) value).setText(strPath);
                    }
                }
            };
        }

        public void selectionChanged(SelectionChangedEvent event) {
            if (value == null)
                return;
            IStructuredSelection iss = (IStructuredSelection) event.getSelection();
            if (!iss.isEmpty()) {
                ExporterProperty prop = (ExporterProperty) iss.getFirstElement();
                if ("boolean".equalsIgnoreCase(prop.getType())) { //$NON-NLS-1$
                    disposeBrowseButton();
                    createComboValueComposite(new String[] { String.valueOf(true), String.valueOf(false) });
                    ((Combo) value).select(
                            Boolean.valueOf(ef.getPropertyValue(prop.getName())).booleanValue() ? 0 : 1);
                } else if ("directory".equalsIgnoreCase(prop.getType())//$NON-NLS-1$
                        || "path".equalsIgnoreCase(prop.getType())) { //$NON-NLS-1$
                    disposeBrowseButton();
                    createTextValueComposite(1);
                    ((Text) value).setText(ef.getPropertyValue(prop.getName()));
                    createBrowseButton(getSelectionListener(prop), prop);
                } else {
                    disposeBrowseButton();
                    createTextValueComposite(2);
                    ((Text) value).setText(ef.getPropertyValue(prop.getName()));
                }
            } else {
                createTextValueComposite(2);
            }
        }
    });
    viewer.setInput(ef);
    if (viewer.getCombo().getItemCount() > 0) {
        Object selected = null;
        if (selectedPropertyId != null) {
            selected = ef.getExporterProperty(selectedPropertyId);
        } else {
            selected = viewer.getElementAt(0);
        }
        viewer.setSelection(new StructuredSelection(selected));
        viewer.getCombo().select(viewer.getCombo().getSelectionIndex());
    }
}

From source file:org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.java

License:Open Source License

private void createTypeControl() {
    /* line type combo */
    // combo text
    final Label comboTextLabel = new Label(this, SWT.NONE);
    comboTextLabel.setText(Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.2")); //$NON-NLS-1$

    final ComboViewer lineTypeCombo = new ComboViewer(this, SWT.READ_ONLY);
    final GridData comboGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);

    lineTypeCombo.getControl().setLayoutData(comboGridData);
    lineTypeCombo.setContentProvider(new ArrayContentProvider());

    final String[] types = new String[4];
    types[0] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.3"); //$NON-NLS-1$
    types[1] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.4"); //$NON-NLS-1$
    types[2] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.5"); //$NON-NLS-1$
    types[3] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.6"); //$NON-NLS-1$
    lineTypeCombo.setInput(types);/*w w  w. j  av  a  2  s  .  c  om*/
    lineTypeCombo.setSelection(new StructuredSelection(lineTypeCombo.getElementAt(0)));

    lineTypeCombo.setLabelProvider(new LabelProvider() {
        /**
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        @Override
        public String getText(final Object element) {
            return super.getText(element);
        }
    });

    // selection listener
    lineTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        @SuppressWarnings("synthetic-access") //$NON-NLS-1$
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            final Object element = selection.getFirstElement();

            final String string = (String) element;

            if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.8")) //$NON-NLS-1$
            {
                final float[] dashArray = new float[2];
                dashArray[0] = 1;
                dashArray[1] = 0;
                m_stroke.setDashArray(dashArray);
            } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.9")) //$NON-NLS-1$
            {
                final float[] dashArray = new float[2];
                dashArray[0] = 10f;
                dashArray[1] = 5f;
                m_stroke.setDashArray(dashArray);
            } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.10")) //$NON-NLS-1$
            {
                final float[] dashArray = new float[2];
                dashArray[0] = 2f;
                dashArray[1] = 1.9f;
                m_stroke.setDashArray(dashArray);
            } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.11")) //$NON-NLS-1$
            {
                final float[] dashArray = new float[4];
                dashArray[0] = 10f;
                dashArray[1] = 5f;
                dashArray[2] = 2f;
                dashArray[3] = 1.9f;
                m_stroke.setDashArray(dashArray);
            }
            contentChanged();
        }
    });
}

From source file:org.kalypso.ui.wizards.results.editor.VectorEditorComposite.java

License:Open Source License

private void createUomControl(final Composite comp) {
    /* uom type combo */
    // combo text
    final Label comboTextLabel = new Label(comp, SWT.NONE);
    comboTextLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    comboTextLabel.setText(Messages.getString("org.kalypso.ui.wizards.results.VectorEditorComposite.4")); //$NON-NLS-1$

    final ComboViewer uomTypeCombo = new ComboViewer(comp, SWT.READ_ONLY);
    final GridData comboGridData = new GridData(SWT.END, SWT.CENTER, false, false);
    comboGridData.widthHint = 25;//w w w.j  a va  2 s  .  c  om
    uomTypeCombo.getControl().setLayoutData(comboGridData);
    uomTypeCombo.setContentProvider(new ArrayContentProvider());

    final String[] types = new String[2];
    types[0] = "Meter"; //$NON-NLS-1$
    types[1] = "Pixel"; //$NON-NLS-1$

    uomTypeCombo.setInput(types);
    if (m_uom == UOM.pixel)
        uomTypeCombo.setSelection(new StructuredSelection(uomTypeCombo.getElementAt(1)));
    else
        uomTypeCombo.setSelection(new StructuredSelection(uomTypeCombo.getElementAt(0)));

    uomTypeCombo.setLabelProvider(new LabelProvider() {
        /**
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        @Override
        public String getText(final Object element) {

            return super.getText(element);
        }
    });

    // selection listener
    uomTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        @SuppressWarnings("synthetic-access")
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            final Object element = selection.getFirstElement();

            final String string = (String) element;

            // TODO: get the GraphicFill from a GraphicFill editor.
            // right now, there is just possible a plain fill .

            if (string == "Meter") //$NON-NLS-1$
            {
                m_symb.setUom(UOM.meter);
            } else if (string == "Pixel") //$NON-NLS-1$
            {
                m_symb.setUom(UOM.pixel);
            }

            contentChanged();
        }
    });
}

From source file:org.svenk.redmine.ui.wizard.querypage.RedmineQueryPage.java

License:Open Source License

private void createTextGroup(final Composite parent) {

    LabelProvider labelProvider = new RedmineLabelProvider();
    Collection<SearchField> searchFields = new ArrayList<SearchField>();

    for (SearchField searchField : SearchField.values()) {
        if (searchField.isListType() || searchField.isGeneric()) {
            continue;
        }// ww  w .java2 s  .c  o  m
        searchFields.add(searchField);

        Text text = new Text(parent, SWT.BORDER);
        text.setEnabled(false);
        txtSearchValues.put(searchField, text);

        ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
        String defaultValue = searchField.isRequired() ? null : OPERATOR_TITLE;
        combo.setContentProvider(new RedmineContentProvider(defaultValue));
        combo.setLabelProvider(labelProvider);
        searchOperators.put(searchField, combo);
        combo.setInput(searchField.getCompareOperators());
        combo.setSelection(new StructuredSelection(combo.getElementAt(0)));

        combo.addSelectionChangedListener(
                new RedmineCompareOperatorSelectionListener(txtSearchValues.get(searchField)));
    }

    RedmineGuiHelper.placeTextElements(parent, searchFields, txtSearchValues, searchOperators);
}