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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.ValidationEditorLine.java

License:Open Source License

private void createEditor() {
    this.setLayout(new GridLayout(1, false));
    ((GridLayout) this.getLayout()).marginHeight = 0;
    ((GridLayout) this.getLayout()).verticalSpacing = 0;

    _composite = new Composite(this, SWT.NONE);
    _composite.setLayoutData(new GridData());
    ((GridData) _composite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _composite.getLayoutData()).grabExcessHorizontalSpace = true;
    _composite.setLayout(new GridLayout(12, false));
    ((GridLayout) _composite.getLayout()).marginHeight = 0;
    ((GridLayout) _composite.getLayout()).verticalSpacing = 0;

    if (_showLabel) {
        ((GridLayout) _composite.getLayout()).numColumns = 13;

        _labelSource = new Label(_composite, SWT.NONE);
        _labelSource.setText(NLMessages.getString("Editor_reference") + "*");
        _labelSource.setLayoutData(new GridData());
        ((GridData) _labelSource.getLayoutData()).horizontalSpan = 1;
        ((GridData) _labelSource.getLayoutData()).horizontalAlignment = SWT.RIGHT;
    }//from  w  ww . j a  v  a 2s.co m
    _sourceText = new Text(_composite, SWT.BORDER);
    _sourceText.setBackground(WHITE_COLOR);
    _sourceText.setLayoutData(new GridData());
    ((GridData) _sourceText.getLayoutData()).horizontalSpan = 5;
    ((GridData) _sourceText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _sourceText.getLayoutData()).grabExcessHorizontalSpace = true;

    _sourceText.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            ee.widget = ValidationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
            ContentProposalAdapter adapter = new ContentProposalAdapter(_sourceText, new TextContentAdapter(),
                    new FacetContentProposalProvider(_facade.getAllReferenceFacets()), null, null);
            adapter.setLabelProvider(new AutoCompleteNameLabelProvider());
            adapter.addContentProposalListener(new IContentProposalListener() {

                @Override
                public void proposalAccepted(final IContentProposal proposal) {
                    _sourceText.setText(proposal.getContent());
                    if (((Facet) proposal).getKey() != null) {
                        if (_validationStm.getReference() == null) {
                            _validationStm.setReference(new Reference());
                        }
                        _validationStm.getReference().setSourceId(new PdrId(((Facet) proposal).getKey()));
                        _decoValId.setImage(null);
                        contentChanged();

                    }
                }
            });
            // }
            // catch (org.eclipse.jface.bindings.keys.ParseException e1)
            // {
            //
            // e1.printStackTrace();
            // }

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_sourceText.getText() != null && _sourceText.getText().trim().length() == 23) {
                PdrId id = new PdrId(_sourceText.getText());
                PdrObject o = _facade.getPdrObject(id);
                if (o != null) {
                    _validationStm.getReference().setSourceId(id);
                    _decoValId.setImage(null);
                }

            }
            if (_validationStm.getReference().getSourceId() != null)

            {
                if (_facade.getReference(_validationStm.getReference().getSourceId()) != null) {
                    _decoValId.setDescriptionText("");
                    _decoValId.setImage(null);
                } else {
                    _decoValId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    _decoValId.setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation"));
                }
            }
            if (_validationStm.getReference().getQuality() == null) {
                _validationStm.getReference().setQuality("certain");
            }
            contentChanged();
        }
    });
    _sourceText.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (_sourceText.getText().length() == 23) {
                PdrObject o = _facade.getReference(new PdrId(_sourceText.getText()));
                if (o != null) {
                    _decoValId.setImage(null);
                    _validationStm.getReference().setSourceId(new PdrId(_sourceText.getText()));
                    _sourceText.setText(o.getDisplayNameWithID());
                } else {
                    _validationStm.getReference().setSourceId(null);
                    _decoValId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                }
            } else if (_sourceText.getText().trim().length() == 0) {
                _validationStm.getReference().setSourceId(null);
                _decoValId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();
        }
    });

    _decoValId = new ControlDecoration(_sourceText, SWT.LEFT | SWT.TOP);

    _searchButton = new Button(_composite, SWT.NONE);
    _searchButton.setToolTipText(NLMessages.getString("Editor_linkWithSource"));
    _searchButton.setImage(_imageReg.get(IconsInternal.SEARCH));
    _searchButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {

            IWorkbench workbench = PlatformUI.getWorkbench();
            Display display = workbench.getDisplay();
            Shell shell = new Shell(display);
            SelectObjectDialog dialog = new SelectObjectDialog(shell, 2);
            dialog.open();
            if (_facade.getRequestedId() != null) {
                _validationStm.getReference().setSourceId(_facade.getRequestedId());
                if (_validationStm.getReference().isValidId()) {
                    _decoValId.setImage(null);
                    PdrObject o = _facade.getReference(_validationStm.getReference().getSourceId());
                    if (o != null) {
                        _sourceText.setText(o.getDisplayNameWithID()); //$NON-NLS-1$
                    }
                }
            } else {
                if (!_validationStm.getReference().isValidId()) {
                    _decoValId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    _sourceText.setText("");
                }
            }
            contentChanged();
        }
    });
    _editRefButton = new Button(_composite, SWT.PUSH);
    _editRefButton.setImage(_imageReg.get(IconsInternal.REFERENCE_EDIT));
    _editRefButton.setLayoutData(new GridData());
    _editRefButton.setToolTipText(NLMessages.getString("Editor_edit_reference_tooltip")); //$NON-NLS-1$

    _editRefButton.pack();

    _editRefButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {
            if (_validationStm.getReference() != null && _validationStm.getReference().getSourceId() != null) {
                ReferenceMods ref = _facade.getReference(_validationStm.getReference().getSourceId());
                if (ref != null) {
                    _facade.setCurrentReference(ref);

                    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                            .getService(IHandlerService.class);
                    try {
                        handlerService.executeCommand(
                                "org.bbaw.pdr.ae.view.main.commands.OpenSourceEditorDialog", null); //$NON-NLS-1$
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (NotDefinedException e) {
                        e.printStackTrace();
                    } catch (NotEnabledException e) {
                        e.printStackTrace();
                    } catch (NotHandledException e) {
                        e.printStackTrace();
                    }
                }
            }

        }
    });
    _newButton = new Button(_composite, SWT.NONE);
    _newButton.setToolTipText(NLMessages.getString("Editor_create_new_ref_tip"));
    _newButton.setImage(_imageReg.get(IconsInternal.REFERENCE_NEW));
    _newButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {
            Event ee = new Event();
            ee.widget = ValidationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
            IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                    .getService(IHandlerService.class);
            try {
                handlerService.executeCommand("org.bbaw.pdr.ae.view.main.commands.NewReference", null); //$NON-NLS-1$
            } catch (ExecutionException e) {
                e.printStackTrace();
            } catch (NotDefinedException e) {
                e.printStackTrace();
            } catch (NotEnabledException e) {
                e.printStackTrace();
            } catch (NotHandledException e) {
                e.printStackTrace();
            }
            if (_facade.getCurrentReference() != null) {
                _validationStm.getReference().setSourceId(_facade.getCurrentReference().getPdrId());
                _sourceText.setText(_facade.getReference(_validationStm.getReference().getSourceId())
                        .getDisplayNameWithID()); //$NON-NLS-1$
            }
            if (_validationStm.getReference().isValidId()) {
                _decoValId.setImage(null);
            } else {
                _decoValId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();

        }
    });

    _labelInternal = new Label(_composite, SWT.NONE);
    _labelInternal.setText(NLMessages.getString("Editor_internal"));
    _labelInternal.setLayoutData(new GridData());
    ((GridData) _labelInternal.getLayoutData()).horizontalSpan = 1;
    ((GridData) _labelInternal.getLayoutData()).horizontalAlignment = SWT.RIGHT;

    _sourcePageText = new Text(_composite, SWT.BORDER);
    _sourcePageText.setLayoutData(new GridData());
    ((GridData) _sourcePageText.getLayoutData()).horizontalSpan = 3;
    ((GridData) _sourcePageText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _sourcePageText.getLayoutData()).grabExcessHorizontalSpace = true;
    _sourcePageText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            ee.widget = ValidationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
            String[] vals = new String[] { "test" };
            try {
                vals = _facade.getMainSearcher().getFacets("validation", "internal", null, null, //$NON-NLS-1$
                        null);
            } catch (Exception e1) {

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

        @Override
        public void focusLost(FocusEvent e) {
            if (_sourcePageText.getText() != null && _sourcePageText.getText().trim().length() > 0) {
                _validationStm.getReference().setInternal(_sourcePageText.getText());
            }
            contentChanged();

        }
    });

}

From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java

License:Open Source License

/**
 * Builds the aspect search./*from   ww  w. ja va2s  .c om*/
 */
private void buildAspectSearch() {
    DataType dtAll = new DataType();
    dtAll.setValue("ALL");
    dtAll.setLabel("ALL");
    _aspectQuery = new PdrQuery();
    _aspectQuery.setType(0);
    _criteria = new Criteria();
    _criteria.setType("tagging"); //$NON-NLS-1$
    _aspectQuery.getCriterias().add(_criteria);
    final Criteria c = _aspectQuery.getCriterias().firstElement();

    _searchATagComp = new Composite(_aspectSearchGroup, SWT.NONE);
    _searchATagComp.setLayout(new GridLayout());
    ((GridLayout) _searchATagComp.getLayout()).makeColumnsEqualWidth = true;
    ((GridLayout) _searchATagComp.getLayout()).numColumns = 15;
    _searchATagComp.setLayoutData(new GridData());
    ((GridData) _searchATagComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _searchATagComp.getLayoutData()).grabExcessHorizontalSpace = true;
    // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200;
    ((GridData) _searchATagComp.getLayoutData()).grabExcessVerticalSpace = false;
    ((GridData) _searchATagComp.getLayoutData()).horizontalSpan = 1;

    Label sem = new Label(_searchATagComp, SWT.NONE);
    sem.setText(NLMessages.getString("Dialog_semantic"));
    sem.setLayoutData(new GridData());
    ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) sem.getLayoutData()).horizontalSpan = 2;

    Label tagName = new Label(_searchATagComp, SWT.NONE);
    tagName.setText(NLMessages.getString("Dialog_Markup"));
    tagName.setLayoutData(new GridData());
    ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagName.getLayoutData()).horizontalSpan = 2;

    Label tagType = new Label(_searchATagComp, SWT.NONE);
    tagType.setText(NLMessages.getString("Dialog_type"));
    tagType.setLayoutData(new GridData());
    ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagType.getLayoutData()).horizontalSpan = 2;

    Label tagSubtype = new Label(_searchATagComp, SWT.NONE);
    tagSubtype.setText(NLMessages.getString("Dialog_subtype"));
    tagSubtype.setLayoutData(new GridData());
    ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2;

    Label searchTextLabel = new Label(_searchATagComp, SWT.NONE);
    searchTextLabel.setText(NLMessages.getString("Dialog_searchText"));
    searchTextLabel.setLayoutData(new GridData());
    ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 5;

    Label fuzzy = new Label(_searchATagComp, SWT.NONE);
    fuzzy.setText(NLMessages.getString("Dialog_fuzzy"));
    fuzzy.setLayoutData(new GridData());
    ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1;

    final Combo semCombo = new Combo(_searchATagComp, 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(_searchATagComp, 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(_searchATagComp, 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(false));
    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);
            } else {
                selection = cd.getValue();
            }
            c.setCrit1(selection);
            setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null);
        }
    });

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

    final Combo subtypeCombo = new Combo(_searchATagComp, SWT.READ_ONLY);
    final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo);
    subtypeComboViewer.setContentProvider(new MarkupContentProvider(false));
    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);
        }
    });

    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());
    }

    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());
            }
        }
    });

    final Text searchText = new Text(_searchATagComp, 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 = 5;
    if (c.getSearchText() != null) {
        searchText.setText(c.getSearchText());
    }
    searchText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            String[] vals = new String[] {};
            try {
                vals = _mainSearcher.getFacets("tagging", c.getCrit1(), c.getCrit2(), null, null);
            } catch (Exception e1) {

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

        }

        @Override
        public void focusLost(final FocusEvent e) {
            c.setSearchText(searchText.getText());
        }
    });
    searchText.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setSearchText(searchText.getText());
                searchAspects();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
    final Button fuzzyB = new Button(_searchATagComp, 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());
        }
    });

    _searchADateComp = new Composite(_aspectSearchGroup, SWT.NONE);
    _searchADateComp.setLayout(new GridLayout());
    ((GridLayout) _searchADateComp.getLayout()).makeColumnsEqualWidth = true;
    ((GridLayout) _searchADateComp.getLayout()).numColumns = 13;
    _searchADateComp.setLayoutData(new GridData());
    ((GridData) _searchADateComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _searchADateComp.getLayoutData()).grabExcessHorizontalSpace = true;
    // ((GridData) searchADateComp.getLayoutData()).heightHint = 200;
    ((GridData) _searchADateComp.getLayoutData()).grabExcessVerticalSpace = false;
    ((GridData) _searchADateComp.getLayoutData()).horizontalSpan = 1;

    Label typeDate = new Label(_searchADateComp, SWT.NONE);
    typeDate.setText(NLMessages.getString("Dialog_type"));
    typeDate.setLayoutData(new GridData());
    ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) typeDate.getLayoutData()).horizontalSpan = 2;

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

    Label month = new Label(_searchADateComp, SWT.NONE);
    month.setText(NLMessages.getString("Dialog_month"));
    month.setLayoutData(new GridData());
    ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) month.getLayoutData()).horizontalSpan = 1;

    Label year = new Label(_searchADateComp, SWT.NONE);
    year.setText(NLMessages.getString("Dialog_year"));
    year.setLayoutData(new GridData());
    ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) year.getLayoutData()).horizontalSpan = 2;

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

    Label notAfter = new Label(_searchADateComp, SWT.NONE);
    notAfter.setText(NLMessages.getString("Dialog_day"));
    notAfter.setLayoutData(new GridData());
    ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) notAfter.getLayoutData()).horizontalSpan = 1;

    Label month2 = new Label(_searchADateComp, SWT.NONE);
    month2.setText(NLMessages.getString("Dialog_month"));
    month2.setLayoutData(new GridData());
    ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) month2.getLayoutData()).horizontalSpan = 1;

    Label year2 = new Label(_searchADateComp, SWT.NONE);
    year2.setText(NLMessages.getString("Dialog_year"));
    year2.setLayoutData(new GridData());
    ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) year2.getLayoutData()).horizontalSpan = 2;

    final Combo typeDCombo = new Combo(_searchADateComp, 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) {
                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;
            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(_searchADateComp, SWT.NONE);
    from.setText(NLMessages.getString("Dialog_from"));
    from.setLayoutData(new GridData());
    ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) from.getLayoutData()).horizontalSpan = 1;

    final Combo day1Combo = new Combo(_searchADateComp, 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(_searchADateComp, 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(_searchADateComp, SWT.NULL);
    // year1Spinner.setLayoutData(new GridData());
    // year1Spinner.setLayoutData(new GridData());
    // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment =
    // SWT.FILL;
    // ((GridData) year1Spinner.getLayoutData()).grabExcessHorizontalSpace =
    // true;
    // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2;
    // year1Spinner.setMinimum(0);
    // year1Spinner.setMaximum(9999);
    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(_searchADateComp, SWT.NONE);
    to.setText(NLMessages.getString("Dialog_to"));
    to.setLayoutData(new GridData());
    ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) to.getLayoutData()).horizontalSpan = 1;

    final Combo day2Combo = new Combo(_searchADateComp, 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(_searchADateComp, 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(_searchADateComp, SWT.NULL);
    // year2Spinner.setLayoutData(new GridData());
    // year2Spinner.setLayoutData(new GridData());
    // ((GridData) year2Spinner.getLayoutData()).horizontalAlignment =
    // SWT.FILL;
    // ((GridData) year2Spinner.getLayoutData()).grabExcessHorizontalSpace =
    // true;
    // ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 2;
    // year2Spinner.setMinimum(0);
    // year2Spinner.setMaximum(9999);
    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(_searchADateComp, 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());
        }
    });

}

From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java

License:Open Source License

/**
 * Builds the person search.//ww w .j a  v a2  s . c o m
 */
private void buildPersonSearch() {
    DataType dtAll = new DataType();
    dtAll.setValue("ALL");
    dtAll.setLabel("ALL");
    _personQuery = new PdrQuery();
    _personQuery.setType(1);
    _criteria = new Criteria();
    _criteria.setType("tagging"); //$NON-NLS-1$
    _personQuery.getCriterias().add(_criteria);
    _criteria = new Criteria();
    _criteria.setType("tagging"); //$NON-NLS-1$
    _personQuery.getCriterias().add(_criteria);

    _criteria = new Criteria();
    _personQuery.getCriterias().add(_criteria);
    _criteria.setType("relation"); //$NON-NLS-1$

    _criteria = new Criteria();
    _personQuery.getCriterias().add(_criteria);
    _criteria.setType("date"); //$NON-NLS-1$

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

        if (c.getType().equals("tagging")) //$NON-NLS-1$
        {
            if (tag1) {
                tag1 = false;
                _searchPTagComp = new Composite(_personSearchGroup, SWT.NONE);
                _searchPTagComp.setLayout(new GridLayout());
                ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true;
                ((GridLayout) _searchPTagComp.getLayout()).numColumns = 15;
                _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"));
                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"));
                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_markup"));
                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"));
                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"));
                tagSubtype.setLayoutData(new GridData());
                ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2;

                Label searchTextLabel = new Label(_searchPTagComp, SWT.NONE);
                searchTextLabel.setText(NLMessages.getString("Dialog_searchText"));
                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"));
                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"));
                include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences"));
                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(_searchPTagComp, SWT.NONE);
                l.setText(NLMessages.getString("Dialog_Markup"));
                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(false));
            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);
                    } else {
                        selection = cd.getValue();
                    }
                    c.setCrit1(selection);
                    setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null);
                }
            });

            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(false));
            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);
                }
            });

            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());
            }

            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());
                    }
                }
            });

            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 FocusListener() {
                @Override
                public void focusGained(final FocusEvent e) {
                    String[] vals = new String[] {};
                    try {
                        vals = _mainSearcher.getFacets("tagging", c.getCrit1(), c.getCrit2(), null, null);
                    } catch (Exception e1) {

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

                }

                @Override
                public void focusLost(final FocusEvent e) {
                    c.setSearchText(searchText.getText());
                }
            });
            searchText.addKeyListener(new KeyListener() {
                @Override
                public void keyPressed(final KeyEvent e) {
                    if (e.keyCode == SWT.CR) {
                        c.setSearchText(searchText.getText());
                        searchPersons();
                    }
                }

                @Override
                public void keyReleased(final KeyEvent e) {
                }
            });

            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());
                }
            });

        } // if tagging

        if (c.getType().equals("relation")) //$NON-NLS-1$
        {
            if (rel1) {
                rel1 = false;
                _searchPRelComp = new Composite(_personSearchGroup, 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"));
                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"));
                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"));
                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"));
                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"));
                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"));
                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 (Exception 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 (Exception 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(false));
            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(false));
            classComboViewer.setLabelProvider(new MarkupLabelProvider());
            classComboViewer.setComparator(new ConfigDataComparator());
            setComboViewerInput(contextComboViewer, "relation", null, null, null);
            if (c.getRelationContext() != null) {
                setComboViewerByString(contextComboViewer, c.getRelationContext());
                setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null);

            } 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);
                }
            });

            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);
            relObjText.addFocusListener(new FocusListener() {

                @Override
                public void focusGained(final FocusEvent e) {
                }

                @Override
                public void focusLost(final FocusEvent e) {

                }

            });

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

                }
            });

            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());
                }
            });
            searchText.addKeyListener(new KeyListener() {
                @Override
                public void keyPressed(final KeyEvent e) {
                    if (e.keyCode == SWT.CR) {
                        c.setSearchText(searchText.getText());
                        searchPersons();
                    }
                }

                @Override
                public void keyReleased(final KeyEvent e) {
                }
            });
            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(_personSearchGroup, SWT.NONE);
                _searchPDateComp.setLayout(new GridLayout());
                ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true;
                ((GridLayout) _searchPDateComp.getLayout()).numColumns = 15;
                _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;

                Label l2 = new Label(_searchPDateComp, SWT.NONE);
                l2.setText(NLMessages.getString("Dialog_date"));
                l2.setLayoutData(new GridData());
                ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) l2.getLayoutData()).horizontalSpan = 2;

                Label typeDate = new Label(_searchPDateComp, SWT.NONE);
                typeDate.setText(NLMessages.getString("Dialog_type"));
                typeDate.setLayoutData(new GridData());
                ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) typeDate.getLayoutData()).horizontalSpan = 2;

                Label bl = new Label(_searchPDateComp, SWT.NONE);
                bl.setText(""); //$NON-NLS-1$
                Label notBefore = new Label(_searchPDateComp, SWT.NONE);
                notBefore.setText(NLMessages.getString("Dialog_day"));
                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"));
                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"));
                year.setLayoutData(new GridData());
                ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) year.getLayoutData()).horizontalSpan = 2;

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

                Label notAfter = new Label(_searchPDateComp, SWT.NONE);
                notAfter.setText(NLMessages.getString("Dialog_day"));
                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"));
                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"));
                year2.setLayoutData(new GridData());
                ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL;
                ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true;
                ((GridData) year2.getLayoutData()).horizontalSpan = 2;

                Label include = new Label(_searchPDateComp, SWT.NONE);
                include.setText(""); //$NON-NLS-1$
                include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences"));
                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(_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) {
                        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;
                    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"));
            from.setLayoutData(new GridData());
            ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) from.getLayoutData()).horizontalSpan = 1;

            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);
            // year1Spinner.setLayoutData(new GridData());
            // year1Spinner.setLayoutData(new GridData());
            // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment
            // = SWT.FILL;
            // ((GridData)
            // year1Spinner.getLayoutData()).grabExcessHorizontalSpace =
            // true;
            // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2;
            // year1Spinner.setMinimum(0);
            // year1Spinner.setMaximum(9999);
            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"));
            to.setLayoutData(new GridData());
            ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) to.getLayoutData()).horizontalSpan = 1;

            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.NONE);
            year2Spinner.setLayoutData(new GridData());
            year2Spinner.setLayoutData(new GridData());
            ((GridData) year2Spinner.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) year2Spinner.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 1;
            year2Spinner.setMinimum(0);
            year2Spinner.setMaximum(9999);
            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());
                }
            });

        } // if date
    }
}

From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java

License:Open Source License

/**
 * Builds the reference search./*from www.  j  a  v  a 2s  . c o  m*/
 */
private void buildReferenceSearch() {
    _referenceQuery = new PdrQuery();
    _referenceQuery.setType(2);
    _criteria = new Criteria();
    _criteria.setType("reference"); //$NON-NLS-1$
    _referenceQuery.getCriterias().add(_criteria);

    final Criteria c = _referenceQuery.getCriterias().firstElement();
    Composite searchRefComp = new Composite(_refSearchGroup, SWT.NONE);
    searchRefComp.setLayout(new GridLayout());
    ((GridLayout) searchRefComp.getLayout()).makeColumnsEqualWidth = true;
    ((GridLayout) searchRefComp.getLayout()).numColumns = 10;
    searchRefComp.setLayoutData(new GridData());
    ((GridData) searchRefComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchRefComp.getLayoutData()).grabExcessHorizontalSpace = true;
    // ((GridData) searchRefComp.getLayoutData()).heightHint = 200;
    ((GridData) searchRefComp.getLayoutData()).grabExcessVerticalSpace = false;
    ((GridData) searchRefComp.getLayoutData()).horizontalSpan = 1;

    Label op = new Label(searchRefComp, SWT.NONE);
    op.setText(NLMessages.getString("Dialog_genre"));
    op.setLayoutData(new GridData());
    ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) op.getLayoutData()).horizontalSpan = 2;

    Label tagName = new Label(searchRefComp, SWT.NONE);
    tagName.setText(NLMessages.getString("Dialog_role"));
    tagName.setLayoutData(new GridData());
    ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagName.getLayoutData()).horizontalSpan = 2;

    Label tagType = new Label(searchRefComp, SWT.NONE);
    tagType.setText(NLMessages.getString("Dialog_name"));
    tagType.setLayoutData(new GridData());
    ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagType.getLayoutData()).horizontalSpan = 5;

    Label fuzzy = new Label(searchRefComp, SWT.NONE);
    fuzzy.setText(NLMessages.getString("Dialog_fuzzy"));
    fuzzy.setLayoutData(new GridData());
    ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1;

    final Combo genreCombo = new Combo(searchRefComp, 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));

    }

    final Combo roleCombo = new Combo(searchRefComp, SWT.READ_ONLY);
    roleCombo.setLayoutData(new GridData());
    roleCombo.setLayoutData(new GridData());
    ((GridData) roleCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) roleCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) roleCombo.getLayoutData()).horizontalSpan = 2;
    ComboViewer comboViewer = new ComboViewer(roleCombo);
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            String str = (String) element;
            if (str.equals("ALL")) {
                return str;
            }
            return NLMessages.getString("Editor_role_" + str);
        }
    });

    String[] input = new String[AEConstants.REF_ROLETERM_CODE.length + 1];
    System.arraycopy(new String[] { "ALL" }, 0, input, 0, 1);
    System.arraycopy(AEConstants.REF_ROLETERM_CODE, 0, input, 1, AEConstants.REF_ROLETERM_CODE.length);
    comboViewer.setInput(input);
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

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

    });

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

    // if (c.getCrit1() != null)
    // {
    // roleCombo.setText(c.getCrit1());
    // }
    // else
    // {
    // roleCombo.select(0);
    // c.setCrit1(roleCombo.getItem(0));
    //
    //
    // }
    // roleCombo.addSelectionListener(new SelectionAdapter(){
    // public void widgetSelected(SelectionEvent se)
    // {
    // // if (!(semCombo.getSelectionIndex() > semCombo.getItems().length))
    // // {
    // c.setCrit1(roleCombo.getItem(roleCombo.getSelectionIndex()));
    // // }
    // }
    // });

    final Text nameText = new Text(searchRefComp, SWT.BORDER);
    nameText.setLayoutData(new GridData());
    nameText.setLayoutData(new GridData());
    ((GridData) nameText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) nameText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) nameText.getLayoutData()).horizontalSpan = 5;
    if (c.getCrit3() != null) {
        nameText.setText(c.getCrit3());
    }
    nameText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            String[] vals = new String[] {};
            try {
                vals = _mainSearcher.getFacets("reference", "namePart", null, null, null);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            new AutoCompleteField(nameText, new TextContentAdapter(), vals);

        }

        @Override
        public void focusLost(final FocusEvent e) {
            c.setCrit3(nameText.getText());
        }
    });
    nameText.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setCrit3(nameText.getText());
                searchReferences();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
    final Button fuzzyB = new Button(searchRefComp, 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());
        }
    });

    Label title = new Label(searchRefComp, SWT.NONE);
    title.setText(NLMessages.getString("Dialog_refTitle"));
    title.setLayoutData(new GridData());
    ((GridData) title.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) title.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) title.getLayoutData()).horizontalSpan = 2;

    final Text searchText2 = new Text(searchRefComp, SWT.BORDER);
    searchText2.setLayoutData(new GridData());
    searchText2.setLayoutData(new GridData());
    ((GridData) searchText2.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText2.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText2.getLayoutData()).horizontalSpan = 8;
    if (c.getCrit4() != null) {
        searchText2.setText(c.getCrit4());
    }
    searchText2.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            String[] vals = new String[] {};
            try {
                vals = _mainSearcher.getFacets("reference", "title", null, null, null);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            new AutoCompleteField(searchText2, new TextContentAdapter(), vals);

        }

        @Override
        public void focusLost(final FocusEvent e) {
            c.setCrit4(searchText2.getText());
        }
    });
    searchText2.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setCrit4(searchText2.getText());
                searchReferences();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
    Label searchText = new Label(searchRefComp, SWT.NONE);
    searchText.setText(NLMessages.getString("Dialog_freeSearch"));
    searchText.setLayoutData(new GridData());
    ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText.getLayoutData()).horizontalSpan = 2;

    final Text searchText3 = new Text(searchRefComp, SWT.BORDER);
    searchText3.setLayoutData(new GridData());
    searchText3.setLayoutData(new GridData());
    ((GridData) searchText3.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText3.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText3.getLayoutData()).horizontalSpan = 8;
    if (c.getSearchText() != null) {
        searchText3.setText(c.getSearchText());
    }
    searchText3.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(final FocusEvent e) {
            c.setSearchText(searchText3.getText());
        }
    });
    searchText3.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setSearchText(searchText3.getText());
                searchReferences();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });

}

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

License:Open Source License

/**
 * Builds the reference search.//from   w w  w .j  av  a  2  s.c om
 * @param i the i
 * @param object the object
 */
private void buildReferenceSearch(final int i, final Object object) {

    final Criteria c = _referenceQuery.getCriterias().firstElement();
    Composite searchRefComp = new Composite(_referenceSearchGroup, SWT.NONE);
    searchRefComp.setLayout(new GridLayout());
    ((GridLayout) searchRefComp.getLayout()).makeColumnsEqualWidth = true;
    ((GridLayout) searchRefComp.getLayout()).numColumns = 10;
    searchRefComp.setLayoutData(new GridData());
    ((GridData) searchRefComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchRefComp.getLayoutData()).grabExcessHorizontalSpace = true;
    // ((GridData) searchRefComp.getLayoutData()).heightHint = 200;
    ((GridData) searchRefComp.getLayoutData()).grabExcessVerticalSpace = false;
    ((GridData) searchRefComp.getLayoutData()).horizontalSpan = 1;

    Button chooseFacetsButton = new Button(searchRefComp, SWT.CHECK);
    chooseFacetsButton.setText(NLMessages.getString("Dialog_faceted_search"));
    chooseFacetsButton.setLayoutData(new GridData());
    ((GridData) chooseFacetsButton.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) chooseFacetsButton.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) chooseFacetsButton.getLayoutData()).horizontalSpan = 2;
    chooseFacetsButton.setSelection(_referenceQuery.getType() == 5);
    chooseFacetsButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {
            if (_referenceQuery.getType() == 5) {
                _referenceQuery.setType(2);
            } else {
                _referenceQuery.setType(5);
            }
        }
    });

    Label refFacet = new Label(searchRefComp, SWT.NONE);
    refFacet.setText(NLMessages.getString("Dialog_faceted_by"));
    refFacet.setLayoutData(new GridData());
    ((GridData) refFacet.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) refFacet.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) refFacet.getLayoutData()).horizontalSpan = 2;

    final Combo facetTypeCombo = new Combo(searchRefComp, SWT.READ_ONLY);
    facetTypeCombo.setLayoutData(new GridData());
    facetTypeCombo.setLayoutData(new GridData());
    ((GridData) facetTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) facetTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) facetTypeCombo.getLayoutData()).horizontalSpan = 2;
    ComboViewer facetTypeComboViewer = new ComboViewer(facetTypeCombo);
    facetTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    facetTypeComboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            String str = (String) element;
            return NLMessages.getString("Editor_" + str); //$NON-NLS-1$
        }
    });

    String[] refFacets = new String[] { "title", "subtitle", "partName", "name", "genre", "dateCreated", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            "dateIssued", "dateCaptured", "copyrightDate", "publisher", "place", "edition", "physicalLocation", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
            "shelfLocator" }; //$NON-NLS-1$

    facetTypeComboViewer.setInput(refFacets);

    final Combo refFacetsCombo = new Combo(searchRefComp, SWT.READ_ONLY);
    refFacetsCombo.setLayoutData(new GridData());
    final ComboViewer refFacetsComboViewer = new ComboViewer(refFacetsCombo);
    refFacetsComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    refFacetsComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            String str = (String) element;
            return str;
        }

    });
    facetTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            String s = (String) obj;
            String type = null;
            if (s.equals("name")) //$NON-NLS-1$
            {
                s = "namePart"; //$NON-NLS-1$
                type = "family"; //$NON-NLS-1$
            }
            try {
                _referenceFacets = _mainSearcher.getFacets("reference", s, type, null, null); //$NON-NLS-1$
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (s.equals("genre")) //$NON-NLS-1$
            {
                _referenceQuery.setKey("genre"); //$NON-NLS-1$
                String[] genreLabel = new String[_referenceFacets.length];
                for (int i = 0; i < _referenceFacets.length; i++) {
                    ReferenceModsTemplate temp = _facade.getReferenceModsTemplates().get(_referenceFacets[i]);
                    if (temp != null) {
                        genreLabel[i] = temp.getLabel();
                    } else {
                        genreLabel[i] = _referenceFacets[i];
                    }
                }
                refFacetsComboViewer.setInput(genreLabel);
            } else {
                _referenceQuery.setKey(null);
                refFacetsComboViewer.setInput(_referenceFacets);
            }
            setQueryFacets(_referenceQuery, _referenceFacets);
        }

    });

    // refFacetsComboViewer.setInput(facade.getReferenceModsTemplates());
    // refFacetsComboViewer.addSelectionChangedListener(new
    // ISelectionChangedListener() {
    //
    // public void selectionChanged(SelectionChangedEvent event) {
    // ISelection selection = event.getSelection();
    // Object obj = ((IStructuredSelection) selection).getFirstElement();
    // ReferenceModsTemplate template = (ReferenceModsTemplate) obj;
    //
    // }
    //
    // });

    refFacetsCombo.setLayoutData(new GridData());
    ((GridData) refFacetsCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) refFacetsCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) refFacetsCombo.getLayoutData()).horizontalSpan = 4;

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

    Label tagName = new Label(searchRefComp, SWT.NONE);
    tagName.setText(NLMessages.getString("Dialog_role")); //$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(searchRefComp, SWT.NONE);
    tagType.setText(NLMessages.getString("Dialog_name")); //$NON-NLS-1$
    tagType.setLayoutData(new GridData());
    ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) tagType.getLayoutData()).horizontalSpan = 5;

    Label fuzzy = new Label(searchRefComp, 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;

    final Combo genreCombo = new Combo(searchRefComp, 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));

    }

    final Combo roleCombo = new Combo(searchRefComp, SWT.READ_ONLY);
    roleCombo.setLayoutData(new GridData());
    roleCombo.setLayoutData(new GridData());
    ((GridData) roleCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) roleCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) roleCombo.getLayoutData()).horizontalSpan = 2;
    ComboViewer comboViewer = new ComboViewer(roleCombo);
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            String str = (String) element;
            if (str.equals("ALL")) {
                return str; //$NON-NLS-1$
            }
            return NLMessages.getString("Editor_role_" + str); //$NON-NLS-1$
        }
    });

    String[] input = new String[AEConstants.REF_ROLETERM_CODE.length + 1];
    System.arraycopy(new String[] { "ALL" }, 0, input, 0, 1); //$NON-NLS-1$
    System.arraycopy(AEConstants.REF_ROLETERM_CODE, 0, input, 1, AEConstants.REF_ROLETERM_CODE.length);
    comboViewer.setInput(input);
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

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

    });

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

    // if (c.getCrit1() != null)
    // {
    // roleCombo.setText(c.getCrit1());
    // }
    // else
    // {
    // roleCombo.select(0);
    // c.setCrit1(roleCombo.getItem(0));
    //
    //
    // }
    // roleCombo.addSelectionListener(new SelectionAdapter(){
    // public void widgetSelected(SelectionEvent se)
    // {
    // // if (!(semCombo.getSelectionIndex() > semCombo.getItems().length))
    // // {
    // c.setCrit1(roleCombo.getItem(roleCombo.getSelectionIndex()));
    // // }
    // }
    // });

    final Text nameText = new Text(searchRefComp, SWT.BORDER);
    nameText.setLayoutData(new GridData());
    nameText.setLayoutData(new GridData());
    ((GridData) nameText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) nameText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) nameText.getLayoutData()).horizontalSpan = 5;
    if (c.getCrit3() != null) {
        nameText.setText(c.getCrit3());
    }
    nameText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            String[] vals = new String[] {};
            try {
                vals = _mainSearcher.getFacets("reference", "namePart", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            new AutoCompleteField(nameText, new TextContentAdapter(), vals);

        }

        @Override
        public void focusLost(final FocusEvent e) {
            c.setCrit3(nameText.getText());
        }
    });
    nameText.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setCrit3(nameText.getText());
                okPressed();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
    final Button fuzzyB = new Button(searchRefComp, 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());
        }
    });

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

    final Text searchText2 = new Text(searchRefComp, SWT.BORDER);
    searchText2.setLayoutData(new GridData());
    searchText2.setLayoutData(new GridData());
    ((GridData) searchText2.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText2.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText2.getLayoutData()).horizontalSpan = 8;
    if (c.getCrit4() != null) {
        searchText2.setText(c.getCrit4());
    }
    searchText2.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            String[] vals = new String[] {};
            try {
                vals = _mainSearcher.getFacets("reference", "title", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            new AutoCompleteField(searchText2, new TextContentAdapter(), vals);

        }

        @Override
        public void focusLost(final FocusEvent e) {
            c.setCrit4(searchText2.getText());
        }
    });
    searchText2.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setCrit4(searchText2.getText());
                okPressed();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
    Label searchText = new Label(searchRefComp, SWT.NONE);
    searchText.setText(NLMessages.getString("Dialog_freeSearch")); //$NON-NLS-1$
    searchText.setLayoutData(new GridData());
    ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText.getLayoutData()).horizontalSpan = 2;

    final Text searchText3 = new Text(searchRefComp, SWT.BORDER);
    searchText3.setLayoutData(new GridData());
    searchText3.setLayoutData(new GridData());
    ((GridData) searchText3.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) searchText3.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) searchText3.getLayoutData()).horizontalSpan = 8;
    if (c.getSearchText() != null) {
        searchText3.setText(c.getSearchText());
    }
    searchText3.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(final FocusEvent e) {
            c.setSearchText(searchText3.getText());
        }
    });
    searchText3.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(final KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                c.setSearchText(searchText3.getText());
                okPressed();
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
        }
    });
}

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

License:Open Source License

/**
 * <h4>Load time spatial dim.</h4>
 * <p>//from  w  w  w.ja  v  a2 s . c  om
 * 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.AspectEditorDialog.java

License:Open Source License

/**
 * Load validation.//w w  w.j  av a  2s.  co  m
 * @param type the type
 * @param src the src
 */
private void loadValidation(final int type, final Integer src) {
    if (_scrollCompVal != null) {
        _scrollCompVal.dispose();
    }
    _scrollCompVal = new ScrolledComposite(_sourceComposite, SWT.V_SCROLL);
    _scrollCompVal.setExpandHorizontal(true);
    _scrollCompVal.setExpandVertical(true);
    _scrollCompVal.setMinSize(SWT.DEFAULT, SWT.DEFAULT);

    _scrollCompVal.setLayout(new GridLayout());
    _scrollCompVal.setLayoutData(new GridData());
    ((GridData) _scrollCompVal.getLayoutData()).heightHint = 490;
    ((GridData) _scrollCompVal.getLayoutData()).widthHint = 700;

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

    Composite contentCompVal = new Composite(_scrollCompVal, SWT.NONE);
    contentCompVal.setLayout(new GridLayout());
    _scrollCompVal.setContent(contentCompVal);

    switch (type) {
    case 0:
        break; // nix, normales laden
    case 1: // neue reference einfgen
        if (_currentAspect.getValidation() == null) {
            _currentAspect.setValidation(new Validation());
            _currentAspect.getValidation().setValidationStms(new Vector<ValidationStm>());
            _currentAspect.getValidation().getValidationStms().add(new ValidationStm());
            _currentAspect.getValidation().getValidationStms().lastElement().setReference(new Reference());
        } else {
            _currentAspect.getValidation().getValidationStms().add(new ValidationStm());
            _currentAspect.getValidation().getValidationStms().lastElement().setReference(new Reference());

        }
        break;
    case 2: // reference lschen
        _currentAspect.getValidation().remove(src);
        break;
    default:
        break;

    }
    if (_currentAspect.getValidation() != null) {
        for (int i = 0; i < _currentAspect.getValidation().getValidationStms().size(); i++) {
            final ValidationStm vs = _currentAspect.getValidation().getValidationStms().get(i);

            Group valGroup = new Group(contentCompVal, SWT.SHADOW_IN);
            valGroup.setLayout(new GridLayout());
            ((GridLayout) valGroup.getLayout()).numColumns = 1;
            ((GridLayout) valGroup.getLayout()).makeColumnsEqualWidth = false;

            valGroup.setLayoutData(new GridData());
            ((GridData) valGroup.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) valGroup.getLayoutData()).grabExcessHorizontalSpace = true;
            int l = i + 1;
            valGroup.setText(NLMessages.getString("Editor_reference") + l);

            final Composite sourceComposite = new Composite(valGroup, SWT.NONE);
            sourceComposite.setData("src", i); //$NON-NLS-1$
            sourceComposite.setLayout(new GridLayout());
            ((GridLayout) sourceComposite.getLayout()).numColumns = 7;
            ((GridLayout) sourceComposite.getLayout()).makeColumnsEqualWidth = false;
            sourceComposite.setLayoutData(new GridData());
            ((GridData) sourceComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) sourceComposite.getLayoutData()).grabExcessHorizontalSpace = true;

            Label sourceLabel2 = new Label(sourceComposite, SWT.NONE);
            sourceLabel2.setText(NLMessages.getString("Editor_reference"));
            sourceLabel2.setLayoutData(new GridData());

            final Text sourceText = new Text(sourceComposite, SWT.BORDER);
            sourceText.setEditable(_mayWrite);
            sourceText.setBackground(WHITE_COLOR);
            sourceText.setLayoutData(new GridData());
            ((GridData) sourceText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) sourceText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) sourceText.getLayoutData()).horizontalSpan = 3;
            final ControlDecoration decoValId = new ControlDecoration(sourceText, SWT.LEFT | SWT.TOP);
            ControlDecoration decoValIdInfo = new ControlDecoration(sourceText, SWT.LEFT | SWT.BOTTOM);
            decoValIdInfo.setDescriptionText(NLMessages.getString("Editor_proposal_cntl_all_ref"));
            decoValIdInfo.setImage(FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            decoValIdInfo.setShowOnlyOnFocus(false);

            Button relateRefButton = new Button(sourceComposite, SWT.PUSH);
            relateRefButton.setText(NLMessages.getString("Editor_select_dots"));
            relateRefButton.setImage(_imageReg.get(IconsInternal.SEARCH));
            relateRefButton.setEnabled(_mayWrite);
            relateRefButton.setLayoutData(new GridData());
            relateRefButton.setToolTipText(NLMessages.getString("Editor_linkWithSource")); //$NON-NLS-1$

            //            relateRefButton.pack();

            Button newRefButton = new Button(sourceComposite, SWT.PUSH);
            newRefButton.setText(NLMessages.getString("Editor_create_new_ref"));
            newRefButton.setToolTipText(NLMessages.getString("Editor_create_new_ref_tip"));
            newRefButton.setImage(_imageReg.get(IconsInternal.REFERENCE_NEW));
            newRefButton.setEnabled(_mayWrite);
            newRefButton.setLayoutData(new GridData());

            //            newRefButton.pack();

            Button editRefButton = new Button(sourceComposite, SWT.PUSH);
            editRefButton.setImage(_imageReg.get(IconsInternal.REFERENCE_EDIT));
            editRefButton.setEnabled(_mayWrite);
            editRefButton.setLayoutData(new GridData());
            editRefButton.setToolTipText(NLMessages.getString("Editor_edit_reference_tooltip")); //$NON-NLS-1$

            //            editRefButton.pack();

            if (vs.getReference().getSourceId() != null) //$NON-NLS-1$
            {
                decoValId.setImage(null);
                PdrObject o = _facade.getReference(vs.getReference().getSourceId());
                if (o != null) {
                    sourceText.setText(o.getDisplayNameWithID());
                } else {
                    sourceText.setText(vs.getReference().getSourceId().toString());
                    decoValId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    decoValId.setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation"));
                }
            } else {
                sourceText.setText("");
                decoValId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }

            sourceText.addFocusListener(new FocusListener() {

                @Override
                public void focusGained(final FocusEvent e) {
                    char[] autoActivationCharacters = new char[] { '.', '#' };
                    KeyStroke keyStroke;

                    try {
                        keyStroke = KeyStroke.getInstance("Ctrl+Space");
                        ContentProposalAdapter adapter = new ContentProposalAdapter(sourceText,
                                new TextContentAdapter(),
                                new FacetContentProposalProvider(_facade.getAllReferenceFacets()), keyStroke,
                                autoActivationCharacters);
                        adapter.setLabelProvider(new AutoCompleteNameLabelProvider());
                        adapter.addContentProposalListener(new IContentProposalListener() {

                            @Override
                            public void proposalAccepted(final IContentProposal proposal) {
                                sourceText.setText(proposal.getContent());
                                if (((Facet) proposal).getKey() != null) {
                                    vs.getReference().setSourceId(new PdrId(((Facet) proposal).getKey()));
                                    decoValId.setImage(null);
                                    validate();
                                }
                            }
                        });
                    } catch (org.eclipse.jface.bindings.keys.ParseException e1) {

                        e1.printStackTrace();
                    }

                }

                @Override
                public void focusLost(final FocusEvent e) {
                    if (vs.getReference().getSourceId() != null
                            && _facade.getReference(vs.getReference().getSourceId()) != null) {
                        decoValId.setDescriptionText("");
                        decoValId.setImage(null);
                    } else {
                        vs.getReference().setSourceId(null);
                        decoValId.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                        decoValId.setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation"));
                    }
                    validate();

                }
            });
            sourceText.addKeyListener(new KeyListener() {
                @Override
                public void keyPressed(final KeyEvent e) {
                }

                @Override
                public void keyReleased(final KeyEvent e) {
                    if (sourceText.getText().length() == 23) {
                        PdrObject o = _facade.getReference(new PdrId(sourceText.getText()));
                        if (o != null) {
                            decoValId.setImage(null);
                            vs.getReference().setSourceId(new PdrId(sourceText.getText()));
                            sourceText.setText(o.getDisplayNameWithID());
                        }
                    } else if (sourceText.getText().trim().length() == 0) {
                        vs.getReference().setSourceId(null);
                    }

                    validate();
                }
            });

            relateRefButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {

                    IWorkbench workbench = PlatformUI.getWorkbench();
                    Display display = workbench.getDisplay();
                    Shell shell = new Shell(display);
                    SelectObjectDialog dialog = new SelectObjectDialog(shell, 2);
                    dialog.open();
                    if (_facade.getRequestedId() != null) {
                        vs.getReference().setSourceId(_facade.getRequestedId());
                        if (vs.getReference().isValidId()) {
                            decoValId.setImage(null);
                            PdrObject o = _facade.getReference(vs.getReference().getSourceId());
                            if (o != null) {
                                sourceText.setText(o.getDisplayNameWithID()); //$NON-NLS-1$
                            }
                        }
                    } else {
                        if (!vs.getReference().isValidId()) {
                            decoValId.setImage(FieldDecorationRegistry.getDefault()
                                    .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                            sourceText.setText("");
                        }
                    }
                    validate();
                }
            });
            newRefButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {

                    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                            .getService(IHandlerService.class);
                    try {
                        handlerService.executeCommand("org.bbaw.pdr.ae.view.main.commands.NewReference", null); //$NON-NLS-1$
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (NotDefinedException e) {
                        e.printStackTrace();
                    } catch (NotEnabledException e) {
                        e.printStackTrace();
                    } catch (NotHandledException e) {
                        e.printStackTrace();
                    }
                    if (_facade.getCurrentReference() != null) {
                        vs.getReference().setSourceId(_facade.getCurrentReference().getPdrId());
                        sourceText.setText(
                                _facade.getReference(vs.getReference().getSourceId()).getDisplayNameWithID()); //$NON-NLS-1$
                    }
                    if (vs.getReference().isValidId()) {
                        decoValId.setImage(null);
                    } else {
                        decoValId.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    }
                    validate();

                }
            });

            editRefButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    if (vs.getReference() != null && vs.getReference().getSourceId() != null) {
                        ReferenceMods ref = _facade.getReference(vs.getReference().getSourceId());
                        if (ref != null) {
                            _facade.setCurrentReference(ref);
                            System.out.println(
                                    "current reference revisions: " + ref.getRecord().getRevisions().size());
                            for (Revision r : ref.getRecord().getRevisions())
                                System.out.println(" " + r.getRef() + " " + r.getTimeStamp());

                            IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                                    .getService(IHandlerService.class);
                            try {
                                handlerService.executeCommand(
                                        "org.bbaw.pdr.ae.view.main.commands.OpenSourceEditorDialog", null); //$NON-NLS-1$
                            } catch (ExecutionException e) {
                                e.printStackTrace();
                            } catch (NotDefinedException e) {
                                e.printStackTrace();
                            } catch (NotEnabledException e) {
                                e.printStackTrace();
                            } catch (NotHandledException e) {
                                e.printStackTrace();
                            }
                            System.out.println("After editing:");
                            System.out.println(
                                    "current reference revisions: " + ref.getRecord().getRevisions().size());

                        }
                    }

                }
            });

            Label intenalLabel = new Label(sourceComposite, SWT.NONE);
            intenalLabel.setText(NLMessages.getString("Editor_internal"));
            intenalLabel.setLayoutData(new GridData());

            final Text internalText = new Text(sourceComposite,
                    SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
            internalText.setEditable(_mayWrite);
            internalText.setBackground(WHITE_COLOR);
            internalText.setLayoutData(new GridData());
            ((GridData) internalText.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) internalText.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) internalText.getLayoutData()).horizontalSpan = 6;

            if (vs.getReference().getInternal() != null) //$NON-NLS-1$
            {
                internalText.setText(vs.getReference().getInternal());
            }
            internalText.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent e) {
                    vs.getReference().setInternal(internalText.getText());
                }

                @Override
                public void focusGained(FocusEvent event) {
                    String[] vals = new String[] { "test", "test2" };
                    try {
                        vals = _mainSearcher.getFacets("validation", "internal", null, null, //$NON-NLS-1$
                                null);
                    } catch (Exception e1) {

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

                }

            });

            // Label blancL = new Label(sourceComposite, SWT.None);
            //               blancL.setText(""); //$NON-NLS-1$
            // blancL.setLayoutData(new GridData());

            Label refQualLabel = new Label(sourceComposite, SWT.NONE);
            refQualLabel.setText(NLMessages.getString("Editor_quality")); //$NON-NLS-1$
            refQualLabel.setLayoutData(new GridData());
            final Button[] radios = new Button[AEConstants.REFRENCEQUALITIES.length];
            final ControlDecoration decoValQual = new ControlDecoration(refQualLabel, SWT.LEFT | SWT.TOP);
            SelectionListener refListener = new SelectionAdapter() {
                @Override
                public void widgetDefaultSelected(final SelectionEvent e) {
                }

                @Override
                public void widgetSelected(final SelectionEvent e) {
                    final String qual = (String) ((Button) e.getSource()).getData("text");
                    vs.getReference().setQuality(qual); //$NON-NLS-1$
                    // System.out.println("quality set to " + qual);
                    if (vs.getReference().isValidQuality()) {
                        decoValQual.setImage(null);
                    } else {
                        decoValQual.setImage(FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    }
                    validate();
                }
            };
            for (int j = 0; j < AEConstants.REFRENCEQUALITIES.length; j++) {
                radios[j] = new Button(sourceComposite, SWT.RADIO);
                radios[j].setText(NLMessages.getString("Editor_" + AEConstants.REFRENCEQUALITIES[j]));
                radios[j].setData("text", AEConstants.REFRENCEQUALITIES[j]);

                radios[j].addSelectionListener(refListener);
                radios[j].setEnabled(_mayWrite);
                radios[j].setLayoutData(new GridData());
            }
            if (vs.getReference().getQuality() != null) {
                ViewHelper.setRadioByString(radios, vs.getReference().getQuality());
            } else {
                decoValId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }

            Label refauthority = new Label(sourceComposite, SWT.NONE);
            if (vs.getAuthority() != null) {
                User u = null;
                try {
                    u = _facade.getUserManager().getUserById(vs.getAuthority().toString());
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if (u != null) {
                    refauthority.setText("User: " + u.getDisplayName());
                } else {
                    refauthority.setText("User: " + vs.getAuthority().toString());
                }
            } else {
                refauthority.setText("User: " + _facade.getCurrentUser().getPdrId().toString());
                vs.setAuthority(_facade.getCurrentUser().getPdrId());
            }
            refauthority.setLayoutData(new GridData());
            ((GridData) refauthority.getLayoutData()).horizontalSpan = 3;

            Label refCitLabel = new Label(sourceComposite, SWT.NONE);
            refCitLabel.setText(NLMessages.getString("Editor_interpretation"));
            refCitLabel.setLayoutData(new GridData());
            ((GridData) refCitLabel.getLayoutData()).horizontalSpan = 3;

            final Text refCitation = new Text(sourceComposite,
                    SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
            refCitation.setEditable(_mayWrite);
            refCitation.setBackground(WHITE_COLOR);
            refCitation.setLayoutData(new GridData());
            ((GridData) refCitation.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) refCitation.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) refCitation.getLayoutData()).heightHint = 36;
            ((GridData) refCitation.getLayoutData()).horizontalSpan = 6;

            if (vs.getInterpretation() != null) {
                refCitation.setText(vs.getInterpretation());
            }

            refCitation.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(final FocusEvent e) {
                    vs.setInterpretation(refCitation.getText());
                }
            });

            final Button delReference = new Button(sourceComposite, SWT.PUSH);
            delReference.setText(NLMessages.getString("Editor_delete"));
            delReference.setToolTipText(NLMessages.getString("Editor_remove_valStm_tip"));
            delReference.setImage(_imageReg.get(IconsInternal.REFERENCE_REMOVE));
            delReference.setEnabled(_mayWrite);
            delReference.setEnabled(_currentAspect.getValidation().getValidationStms().size() > 1);

            delReference.setLayoutData(_gridData);
            delReference.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    loadValidation(2, ((Integer) sourceComposite.getData("src"))); //$NON-NLS-1$
                    validate();

                }
            });
            delReference.setLayoutData(new GridData());
            //            delReference.pack();
            //            sourceComposite.pack();
            //            valGroup.pack();

        }

    }
    contentCompVal.layout();

    _scrollCompVal.setContent(contentCompVal);
    Point point = contentCompVal.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;
    }
    _scrollCompVal.setMinSize(point);
    _scrollCompVal.layout();
    _sourceComposite.redraw();
    _sourceComposite.layout();
    //      _sourceComposite.pack();
    //      _mainTabFolder.redraw();
    _mainTabFolder.layout();
    //      _mainTabFolder.pack();
}

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

License:Open Source License

/**
 * Load access condition./*from w  w  w.ja v a  2s.co m*/
 * @param contentComp the content comp
 */
private void loadAccessCondition(final Composite contentComp) {
    Composite accConComp = new Composite(contentComp, SWT.NONE);
    accConComp.setLayoutData(new GridData());
    ((GridData) accConComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) accConComp.getLayoutData()).grabExcessHorizontalSpace = true;
    accConComp.setLayout(new GridLayout());
    ((GridLayout) accConComp.getLayout()).numColumns = 6;
    ((GridLayout) accConComp.getLayout()).makeColumnsEqualWidth = false;

    Label label1 = new Label(accConComp, SWT.NONE);
    label1.setText(NLMessages.getString("Editor_accessCon")); //$NON-NLS-1$

    if (_currentReference.getAccessCondition().getType() != null) {
        Label label29 = new Label(accConComp, SWT.NONE);
        label29.setText(NLMessages.getString("Editor_type")); //$NON-NLS-1$
        final Text type = new Text(accConComp, SWT.BORDER);
        type.setEditable(_mayWrite);
        type.setBackground(WHITE_COLOR);
        type.setLayoutData(_gridData);
        type.setText(_currentReference.getAccessCondition().getType().trim());
        type.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {

            }

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getAccessCondition().setType(type.getText());
            }
        });
    }
    if (_currentReference.getAccessCondition().getAccessCondition() != null) {
        Label label30 = new Label(accConComp, SWT.NONE);
        label30.setText(NLMessages.getString("Editor_condition")); //$NON-NLS-1$
        final Text acc = new Text(accConComp, SWT.BORDER);
        acc.setEditable(_mayWrite);
        acc.setBackground(WHITE_COLOR);
        acc.setLayoutData(_gridData);
        acc.setText(_currentReference.getAccessCondition().getAccessCondition().trim());
        acc.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "accessCondition", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

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

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

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

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

License:Open Source License

/**
 * Load identifiers./*from   ww w.  j av  a  2  s.  co m*/
 * @param contentComp the content comp
 */
private void loadIdentifiers(final Composite contentComp) {
    Composite identifierComp = new Composite(contentComp, SWT.NONE);
    identifierComp.setLayoutData(new GridData());
    ((GridData) identifierComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) identifierComp.getLayoutData()).grabExcessHorizontalSpace = true;
    identifierComp.setLayout(new GridLayout());
    ((GridLayout) identifierComp.getLayout()).numColumns = 6;
    ((GridLayout) identifierComp.getLayout()).makeColumnsEqualWidth = false;

    for (int i = 0; i < _currentReference.getIdentifiersMods().size(); i++) {
        final IdentifierMods id = _currentReference.getIdentifiersMods().get(i);

        Label label20 = new Label(identifierComp, SWT.NONE);
        label20.setText(NLMessages.getString("Editor_identifier")); //$NON-NLS-1$

        Label label21 = new Label(identifierComp, SWT.NONE);
        label21.setText(NLMessages.getString("Editor_type")); //$NON-NLS-1$
        final Combo identTypeCombo = new Combo(identifierComp, SWT.READ_ONLY);
        identTypeCombo.setEnabled(_mayWrite);
        identTypeCombo.setBackground(WHITE_COLOR);
        identTypeCombo.setData("id", i); //$NON-NLS-1$
        identTypeCombo.setLayoutData(new GridData());
        identTypeCombo.setItems(AEConstants.REF_IDENTIFIER_TYPE);
        identTypeCombo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent se) {
                id.setType(identTypeCombo.getItem(identTypeCombo.getSelectionIndex()));
            }
        });

        if (id.getType() != null) {
            identTypeCombo.select(identTypeCombo.indexOf(id.getType()));
        } else {
            identTypeCombo.select(identTypeCombo.indexOf("Signatur")); //$NON-NLS-1$
        }

        Label label22 = new Label(identifierComp, SWT.NONE);
        label22.setText(NLMessages.getString("Editor_id")); //$NON-NLS-1$

        final Text ident = new Text(identifierComp, SWT.BORDER);
        ident.setEditable(_mayWrite);
        ident.setBackground(WHITE_COLOR);
        ident.setData("id", i); //$NON-NLS-1$
        ident.setLayoutData(_gridData);
        if (id.getIdentifier() != null) {
            ident.setText(id.getIdentifier().trim());
        } else {
            ident.setText(""); //$NON-NLS-1$
        }
        ident.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "identifier", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

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

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getIdentifiersMods().get((Integer) ident.getData("id")) //$NON-NLS-1$
                        .setIdentifier(ident.getText());
            }
        });

        final Button deleteIds = new Button(identifierComp, SWT.PUSH);
        deleteIds.setText("-"); //$NON-NLS-1$
        deleteIds.setToolTipText(NLMessages.getString("Editor_remove_field"));
        deleteIds.setEnabled(_mayWrite);
        deleteIds.setLayoutData(_gridData);
        deleteIds.setData("id", i); //$NON-NLS-1$
        deleteIds.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                int index = (Integer) deleteIds.getData("id");
                if (_currentReference.getIdentifiersMods().size() > index) {
                    _currentReference.getIdentifiersMods().removeElementAt(index); //$NON-NLS-1$
                    loadValues(_currentReference);
                }

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

        // if (i == _currentReference.getIdentifiersMods().size() -1)
        // {
        // final Button addIdentifier = new Button(identifierComp,
        // SWT.PUSH);
        //             addIdentifier.setText("+"); //$NON-NLS-1$
        // addIdentifier.setToolTipText(NLMessages.getString("Editor_add_identifier"));
        // addIdentifier.setEnabled(_mayWrite);
        // addIdentifier.setLayoutData(_gridData);
        // addIdentifier.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        // IdentifierMods i = new IdentifierMods();
        //                  i.setIdentifier(""); //$NON-NLS-1$
        //                  i.setType(""); //$NON-NLS-1$
        // _currentReference.getIdentifiersMods().add(i);
        // loadValues(_currentReference);
        //
        //
        // } });
        // addIdentifier.setLayoutData(new GridData());
        // }
        // else{
        // new Label(identifierComp, SWT.NONE);
        // }
    }
}

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

License:Open Source License

/**
 * Load location.//from   w w  w  .j  av a  2  s  .com
 * @param contentComp the content comp
 */
private void loadLocation(final Composite contentComp) {
    Composite locationComp = new Composite(contentComp, SWT.NONE);
    locationComp.setLayoutData(new GridData());
    ((GridData) locationComp.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) locationComp.getLayoutData()).grabExcessHorizontalSpace = true;
    locationComp.setLayout(new GridLayout());
    ((GridLayout) locationComp.getLayout()).numColumns = 3;
    ((GridLayout) locationComp.getLayout()).makeColumnsEqualWidth = false;

    LocationMods l = _currentReference.getLocation();

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

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

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getLocation().setUrl(url.getText());
            }
        });

        // final Button addDate = new Button(locationComp, SWT.PUSH);
        //         addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_add_extra_location"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(l.getPhysicalLocation() == null && _mayWrite);
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        //               _currentReference.getLocation().setPhysicalLocation(" "); //$NON-NLS-1$
        // loadValues(_currentReference);
        // } });
        // addDate.setLayoutData(new GridData());

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

            }
        });
        delDate.setLayoutData(new GridData());
    }
    if (l.getPhysicalLocation() != null) {
        Label label26 = new Label(locationComp, SWT.NONE);
        label26.setText(NLMessages.getString("Editor_physicalLocation")); //$NON-NLS-1$
        final Text physL = new Text(locationComp, SWT.BORDER);
        physL.setEditable(_mayWrite);
        physL.setBackground(WHITE_COLOR);
        physL.setLayoutData(_gridData);
        physL.setText(l.getPhysicalLocation().trim());
        physL.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "physicalLocation", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

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

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getLocation().setPhysicalLocation(physL.getText());
            }
        });

        // final Button addDate = new Button(locationComp, SWT.PUSH);
        //         addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_add_shelf"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(l.getShelfLocator() == null && _mayWrite);
        //
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        //               _currentReference.getLocation().setShelfLocator(" "); //$NON-NLS-1$
        // loadValues(_currentReference);
        // } });
        // addDate.setLayoutData(new GridData());

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

            }
        });
        delDate.setLayoutData(new GridData());
    }
    if (l.getShelfLocator() != null) {
        Label label27 = new Label(locationComp, SWT.NONE);
        label27.setText(NLMessages.getString("Editor_shelfLocator")); //$NON-NLS-1$
        final Text shelfL = new Text(locationComp, SWT.BORDER);
        shelfL.setEditable(_mayWrite);
        shelfL.setBackground(WHITE_COLOR);
        shelfL.setLayoutData(_gridData);
        shelfL.setText(l.getShelfLocator().trim());
        shelfL.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(final FocusEvent e) {
                String[] vals = new String[] { "test", "test2" }; //$NON-NLS-1$ //$NON-NLS-2$
                try {
                    vals = _mainSearcher.getFacets("reference", "shelfLocator", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
                } catch (Exception e1) {

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

            @Override
            public void focusLost(final FocusEvent e) {
                _currentReference.getLocation().setShelfLocator(shelfL.getText());
            }
        });

        // final Button addDate = new Button(locationComp, SWT.PUSH);
        //         addDate.setText("+"); //$NON-NLS-1$
        // addDate.setToolTipText(NLMessages.getString("Editor_add_url"));
        // addDate.setLayoutData(_gridData);
        // addDate.setEnabled(l.getUrl() == null && _mayWrite);
        // addDate.addSelectionListener(new SelectionAdapter()
        // {
        // public void widgetSelected(final SelectionEvent event)
        // {
        //               _currentReference.getLocation().setUrl(" "); //$NON-NLS-1$
        // loadValues(_currentReference);
        // } });
        // addDate.setLayoutData(new GridData());

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

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

}