Example usage for org.eclipse.jface.fieldassist ControlDecoration getDescriptionText

List of usage examples for org.eclipse.jface.fieldassist ControlDecoration getDescriptionText

Introduction

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

Prototype

public String getDescriptionText() 

Source Link

Document

Get the description text that may be shown in a hover for this decoration.

Usage

From source file:com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.java

License:Open Source License

@Override
public void focusGained(FocusEvent e) {
    Object source = e.getSource();
    String tip = "";

    if (source instanceof Control) {
        Control control = (Control) source;
        Parameter parameter = getParameter(control);
        if (parameter != null) {
            ControlDecoration decoration = mDecorations.get(parameter.id);
            if (decoration != null) {
                tip = decoration.getDescriptionText();
            }// ww w .j a v a  2 s  .  co m
        }
    }

    mTipLabel.setText(tip);
    mHelpIcon.setVisible(tip.length() > 0);
}

From source file:com.xored.af.ui.forms.parts.ControlDecorationUpdater.java

License:Open Source License

private synchronized void runUpdates() {
    final long startTime = System.currentTimeMillis();

    final Map<ControlDecoration, Update> updatesCopy = new HashMap<ControlDecoration, Update>(updates);
    updates.clear();/*from   w ww. j a va2  s . c  om*/

    final int size = updatesCopy.size();
    int changes = 0;

    for (final Map.Entry<ControlDecoration, Update> entry : updatesCopy.entrySet()) {
        final ControlDecoration decoration = entry.getKey();
        // decoration itself may be already disposed, and also its control
        // may be disposed separately because of non-atomicity of disposal
        if (decoration.getControl() != null && !decoration.getControl().isDisposed()) {
            final Update update = entry.getValue();
            boolean changed = false;
            if (!equals(decoration.getImage(), update.image)) {
                decoration.setImage(update.image);
                changed = true;
            }
            if (!equals(decoration.getDescriptionText(), update.text)) {
                decoration.setDescriptionText(update.text);
                changed = true;
            }
            if (!equals(decoration.getControl().getBackground(), update.controlBg)) {
                decoration.getControl().setBackground(update.controlBg);
                changed = true;
            }
            if (changed) {
                changes++;
            }
        }
    }

    if (DEBUG) {
        AfUiPlugin.getDefault().info("Updated " + changes + " decorations in " + size + " requests in "
                + (System.currentTimeMillis() - startTime) + " millis");
    }
}

From source file:hydrograph.ui.propertywindow.widgets.listeners.ELTEmptyTextModifyListener.java

License:Apache License

private void setToolTipErrorMessage(ControlDecoration fieldNameDecorator) {
    String errmsg = null;/*from www . j av  a 2  s  . c o m*/
    if (fieldNameDecorator.isVisible())
        errmsg = errmsg + "\n" + fieldNameDecorator.getDescriptionText();

    tootlTipErrorMessage.setErrorMessage(errmsg);

}

From source file:jasima_gui.dialogs.streamEditor.DetailsPageBase.java

License:Open Source License

public boolean checkGlobalConstraints() {
    hideError();//  ww  w.ja  va 2 s. c om

    // any local error?
    boolean anyError = false;
    for (FormProperty p : props.values()) {
        ControlDecoration deco = p.getDecoration();
        if (p.error != null) {
            anyError = true;
            deco.setDescriptionText(p.error.errorMsg);
            deco.show();
            deco.showHoverText(p.error.hoverText);
        } else {
            deco.setDescriptionText(null);
            deco.hide();
        }
    }

    if (!anyError) {
        // check global constraints
        ArrayList<ConstraintValidator> failed = new ArrayList<ConstraintValidator>();
        for (ConstraintValidator v : getConstraints()) {
            if (!v.isValid())
                failed.add(v);
        }

        // report errors
        if (failed.size() > 0) {
            anyError = true;
            String mainMsg = failed.size() == 1 ? "1 error" : String.format("%d errors", failed.size());
            master.getManagedForm().getForm().setMessage(mainMsg, IMessageProvider.ERROR,
                    failed.toArray(new IMessage[failed.size()]));

            // show error decoration on causing properties
            for (ConstraintValidator cv : failed) {
                for (FormProperty p : cv.dependsOn()) {
                    ControlDecoration deco = p.getDecoration();
                    String s = deco.getDescriptionText();
                    if (s != null)
                        s += "\n" + cv.getMessage();
                    else
                        s = cv.getMessage();
                    deco.setDescriptionText(s);
                    deco.show();
                }
            }
        } else {
            anyError = false;
        }
    }

    master.okButton.setEnabled(!anyError);

    return !anyError;
}

From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java

License:Open Source License

/**
 * Handle error decoration./*from   w ww  .  j a v  a2 s  .  c  o  m*/
 * 
 * @param errorDecoration the error decoration
 * @param valid the valid
 */
protected void handleErrorDecoration(final ControlDecoration errorDecoration, final boolean valid) {
    if (valid) {
        errorDecoration.hide();
    } else {
        errorDecoration.show();
        errorDecoration.showHoverText(errorDecoration.getDescriptionText());
    }
}

From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java

License:Open Source License

/**
 * Show error or warning./*from   w ww  .jav a 2  s . c  o  m*/
 * 
 * @param errorDecoration the error decoration
 * @param warningDecoration the warning decoration
 * @param inError the in error
 * @param inWarning the in warning
 * @param infoDecoration the info decoration
 */
protected void showErrorOrWarning(final boolean inError, final ControlDecoration errorDecoration,
        final boolean inWarning, final ControlDecoration warningDecoration,
        final ControlDecoration infoDecoration) {
    boolean shown = false;
    if (inError) {
        errorDecoration.show();
        errorDecoration.showHoverText(errorDecoration.getDescriptionText());
        shown = true;
    } else {
        errorDecoration.hide();

        if (inWarning) {
            warningDecoration.show();
            warningDecoration.showHoverText(warningDecoration.getDescriptionText());
            shown = true;
        } else {
            warningDecoration.hide();
        }
    }

    if (shown && infoDecoration != null) {
        infoDecoration.hideHover();
    }
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.RelationEditorLine.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(11, false));
    ((GridLayout) _composite.getLayout()).marginHeight = 0;
    ((GridLayout) _composite.getLayout()).verticalSpacing = 0;

    if (_showLabel) {
        ((GridLayout) _composite.getLayout()).numColumns = 12;
        _labelType = new Label(_composite, SWT.NONE);
        _labelType.setText(NLMessages.getString("Dialog_relation"));
        _labelType.setLayoutData(new GridData());
        ((GridData) _labelType.getLayoutData()).horizontalSpan = 1;
        ((GridData) _labelType.getLayoutData()).horizontalAlignment = SWT.RIGHT;
    }//from  ww  w . j  a va  2  s  .  c om

    _relationContextCombo = new Combo(_composite, SWT.READ_ONLY);
    _relationContextCombo.setBackground(WHITE_COLOR);
    _relationContextCombo.setLayoutData(new GridData());
    ((GridData) _relationContextCombo.getLayoutData()).horizontalSpan = 2;
    ((GridData) _relationContextCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relationContextCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    final ComboViewer relationContextComboViewer = new ComboViewer(_relationContextCombo);
    relationContextComboViewer.setContentProvider(new MarkupContentProvider());
    relationContextComboViewer.setLabelProvider(new MarkupLabelProvider());
    if (_relation != null && _relation.getProvider() != null
            && _facade.getConfigs().get(_relation.getProvider()) != null) {
        relationContextComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                .get("aodl:relation").getChildren());
    }

    final ControlDecoration relContextDeco = new ControlDecoration(_relationContextCombo, SWT.RIGHT | SWT.TOP);

    _relationClassCombo = new Combo(_composite, SWT.READ_ONLY);
    _relationClassCombo.setBackground(WHITE_COLOR);
    _relationClassCombo.setLayoutData(new GridData());
    ((GridData) _relationClassCombo.getLayoutData()).horizontalSpan = 1;
    ((GridData) _relationClassCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relationClassCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    final ComboViewer relationClassComboViewer = new ComboViewer(_relationClassCombo);
    relationClassComboViewer.setContentProvider(new MarkupContentProvider());
    relationClassComboViewer.setLabelProvider(new MarkupLabelProvider());
    final ControlDecoration relClassDeco = new ControlDecoration(_relationClassCombo, SWT.RIGHT | SWT.TOP);

    _relValueCombo = new Combo(_composite, SWT.BORDER | SWT.READ_ONLY);
    _relValueCombo.setBackground(WHITE_COLOR);
    _relValueCombo.setLayoutData(new GridData());
    ((GridData) _relValueCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relValueCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _relValueCombo.getLayoutData()).horizontalSpan = 1;
    final ComboViewer relValueComboViewer = new ComboViewer(_relValueCombo);
    relValueComboViewer.setContentProvider(new MarkupContentProvider());
    relValueComboViewer.setLabelProvider(new MarkupLabelProvider());
    final ControlDecoration relValueDeco = new ControlDecoration(_relValueCombo, SWT.RIGHT | SWT.TOP);

    if (_relation != null && _facade.getConfigs().get(_relation.getProvider()) != null) {
        relationContextComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                .get("aodl:relation").getChildren());
    }

    // control for relationClassCombo
    // ArrayList<String> list = cListPro
    //                  .getList("types", "type", "relation"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // for (int n = 0; n < list.size(); n++)
    // {
    // relationClassCombo.add(list.get(n));
    // }
    if (_relation != null && _relation.getContext() != null) {
        setComboViewerByString(relationContextComboViewer, _relation.getContext());
    }

    relationContextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setContext(cd.getValue());
            _relationClassCombo.removeAll();
            _relValueCombo.removeAll();
            relContextDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "context", _relation.getContext(), null, null, null));
            if (relContextDeco.getDescriptionText() != null) {
                relContextDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relContextDeco.setImage(null);
            }
            relationClassComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren());
            contentChanged();
        }

    });
    _relationContextCombo.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            ee.widget = RelationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub

        }
    });
    _relationContextCombo.layout();

    // control for relationContextCombo
    if (_relation != null && _relation.getRClass() != null) {
        if (_relation.getContext() != null && _facade.getConfigs().get(_relation.getProvider()) != null
                && _facade.getConfigs().get(_relation.getProvider()).getChildren().get("aodl:relation") != null
                && _facade.getConfigs().get(_relation.getProvider()).getChildren().get("aodl:relation")
                        .getChildren().get(_relation.getContext()) != null) {
            relationClassComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren());
        }
        setComboViewerByString(relationClassComboViewer, _relation.getRClass());
    } else {
        relationClassComboViewer.setInput(null);
        relationClassComboViewer.refresh();
    }
    relationClassComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setRClass(cd.getValue());
            relValueComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren()
                    .get(_relation.getRClass()).getChildren());
            relClassDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "class", _relation.getContext(), _relation.getRClass(), null, null));
            if (relClassDeco.getDescriptionText() != null) {
                relClassDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relClassDeco.setImage(null);
            }
            contentChanged();
        }
    });
    _relationClassCombo.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            ee.widget = RelationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub

        }
    });
    _relationClassCombo.layout();
    if (_relation != null && _relation.getRelation() != null) {
        if (_relation.getRClass() != null && _facade.getConfigs().get(_relation.getProvider()) != null
                && _facade.getConfigs().get(_relation.getProvider()).getChildren().get("aodl:relation") != null
                && _facade.getConfigs().get(_relation.getProvider()).getChildren().get("aodl:relation")
                        .getChildren().get(_relation.getContext()) != null
                && _facade.getConfigs().get(_relation.getProvider()).getChildren().get("aodl:relation")
                        .getChildren().get(_relation.getContext()).getChildren()
                        .get(_relation.getRClass()) != null) {
            relValueComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren()
                    .get(_relation.getRClass()).getChildren());
        }
        setComboViewerByString(relValueComboViewer, _relation.getRelation());
    } else {
        relValueComboViewer.setInput(null);
        relValueComboViewer.refresh();
    }
    relValueComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setRelation(cd.getValue());
            relValueDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "value", _relation.getContext(), _relation.getRClass(), _relation.getRelation(), null));
            if (relValueDeco.getDescriptionText() != null) {
                relValueDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relValueDeco.setImage(null);
            }
            contentChanged();
        }
    });
    _relValueCombo.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            ee.widget = RelationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub

        }
    });

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

    _personText = new Text(_composite, SWT.BORDER);
    _personText.setBackground(WHITE_COLOR);
    _personText.setLayoutData(new GridData());
    ((GridData) _personText.getLayoutData()).horizontalSpan = 4;
    ((GridData) _personText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _personText.getLayoutData()).grabExcessHorizontalSpace = true;

    _decoPersonId = new ControlDecoration(_personText, SWT.LEFT | SWT.TOP);

    _personText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

            Event ee = new Event();
            ee.widget = RelationEditorLine.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListener) {
                s.widgetSelected(se);
            }

            ContentProposalAdapter adapter = new ContentProposalAdapter(_personText, new TextContentAdapter(),
                    new FacetContentProposalProvider(_facade.getAllPersonsFacets()), null, null);
            adapter.setLabelProvider(new AutoCompleteNameLabelProvider());
            adapter.addContentProposalListener(new IContentProposalListener() {
                @Override
                public void proposalAccepted(final IContentProposal proposal) {
                    _personText.setText(proposal.getContent());
                    if (((Facet) proposal).getKey() != null) {
                        _relation.setObject(new PdrId(((Facet) proposal).getKey()));
                        _decoPersonId.setImage(null);
                        contentChanged();
                    }
                }
            });

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_relation != null && _relation.getObject() == null) {
                if (_personText.getText() != null
                        && _facade.getPdrObject(new PdrId(_personText.getText())) != null) {
                    _relation.setObject(new PdrId(_personText.getText()));
                    _decoPersonId.setDescriptionText("");
                    _decoPersonId.setImage(null);
                } else {
                    _relation.setObject(null);
                    _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    _decoPersonId.setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation"));
                }
            } else if (_personText.getText().trim().length() == 0) {
                _relation.setObject(null);
                _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();

        }
    });

    _personText.addKeyListener(new KeyListener() {

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

        @Override
        public void keyReleased(final KeyEvent e) {
            if (_personText.getText().length() == 23) {
                PdrObject o = _facade.getPdrObject(new PdrId(_personText.getText()));
                if (o != null) {
                    _decoPersonId.setImage(null);
                    _relation.setObject(new PdrId(_personText.getText()));
                    _personText.setText(o.getDisplayNameWithID());
                }
            } else if (_personText.getText().trim().length() == 0) {
                _relation.setObject(null);
                _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();
        }
    });

    _searchButton = new Button(_composite, SWT.NONE);
    _searchButton.setToolTipText(NLMessages.getString("Editor_open_selObjDialog_object_tip"));
    _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, 1);
            dialog.open();
            if (_facade.getRequestedId() != null) {
                _relation.setObject(_facade.getRequestedId());
                PdrObject o = _facade.getPdrObject(_relation.getObject());
                if (o != null) {
                    _personText.setText(o.getDisplayNameWithID());
                } else {
                    _personText.setText(_facade.getRequestedId().toString());
                }
                if (_relation.getObject().isValid()) {
                    _decoPersonId.setImage(null);
                }
            } else {
                if (!_relation.getObject().isValid()) {
                    _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                }
            }
            contentChanged();

        }
    });
    _deleteRelation = new Button(_composite, SWT.PUSH);
    _deleteRelation.setImage(_imageReg.get(IconsInternal.RELATION_REMOVE));
    _deleteRelation.setLayoutData(new GridData());
    ((GridData) _deleteRelation.getLayoutData()).horizontalSpan = 1;
    ((GridData) _deleteRelation.getLayoutData()).horizontalAlignment = SWT.RIGHT;

    _deleteRelation.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Event ee = new Event();
            ee.widget = RelationEditorLine.this;
            ee.data = _relation;
            ee.text = "del";
            for (Listener s : _deleteListener) {
                s.handleEvent(ee);
            }
            contentChanged();
        }

    });
    // _composite.layout();
    // _composite.pack();
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.RelationEditorLine2.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(10, false));
    ((GridLayout) _composite.getLayout()).marginHeight = 0;
    ((GridLayout) _composite.getLayout()).verticalSpacing = 0;
    new FocusListener() {

        @Override//from  w w w  .  j  a  v  a  2 s  . com
        public void focusGained(final FocusEvent e) {
            Event ee = new Event();
            // ee.data = EasyAspectEditor.this;
            ee.widget = RelationEditorLine2.this;
            SelectionEvent se = new SelectionEvent(ee);
            se.data = RelationEditorLine2.this;
            for (SelectionListener s : _selectionListeners) {
                s.widgetSelected(se);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            contentChanged();

        }

    };
    if (_showLabel) {
        ((GridLayout) _composite.getLayout()).numColumns = 11;
        _labelType = new Label(_composite, SWT.NONE);
        _labelType.setText(NLMessages.getString("Dialog_relation"));
        _labelType.setLayoutData(new GridData());
        ((GridData) _labelType.getLayoutData()).horizontalSpan = 1;
        ((GridData) _labelType.getLayoutData()).horizontalAlignment = SWT.RIGHT;
    }

    _relationContextCombo = new Combo(_composite, SWT.READ_ONLY);
    _relationContextCombo.setBackground(WHITE_COLOR);
    _relationContextCombo.setLayoutData(new GridData());
    ((GridData) _relationContextCombo.getLayoutData()).horizontalSpan = 2;
    ((GridData) _relationContextCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relationContextCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    _relationContextComboViewer = new ComboViewer(_relationContextCombo);
    _relationContextComboViewer.setContentProvider(new MarkupContentProvider());
    _relationContextComboViewer.setLabelProvider(new MarkupLabelProvider());

    final ControlDecoration relContextDeco = new ControlDecoration(_relationContextCombo, SWT.RIGHT | SWT.TOP);
    //      _relationContextCombo.addFocusListener(focusListener);
    _relationClassCombo = new Combo(_composite, SWT.READ_ONLY);
    _relationClassCombo.setBackground(WHITE_COLOR);
    _relationClassCombo.setLayoutData(new GridData());
    ((GridData) _relationClassCombo.getLayoutData()).horizontalSpan = 1;
    ((GridData) _relationClassCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relationClassCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    _relationClassComboViewer = new ComboViewer(_relationClassCombo);
    _relationClassComboViewer.setContentProvider(new MarkupContentProvider());
    _relationClassComboViewer.setLabelProvider(new MarkupLabelProvider());
    final ControlDecoration relClassDeco = new ControlDecoration(_relationClassCombo, SWT.RIGHT | SWT.TOP);
    //      _relationClassCombo.addFocusListener(focusListener);

    _relValueCombo = new Combo(_composite, SWT.BORDER | SWT.READ_ONLY);
    _relValueCombo.setBackground(WHITE_COLOR);
    _relValueCombo.setLayoutData(new GridData());
    ((GridData) _relValueCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _relValueCombo.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _relValueCombo.getLayoutData()).horizontalSpan = 1;
    _relValueComboViewer = new ComboViewer(_relValueCombo);
    _relValueComboViewer.setContentProvider(new MarkupContentProvider());
    _relValueComboViewer.setLabelProvider(new MarkupLabelProvider());
    final ControlDecoration relValueDeco = new ControlDecoration(_relValueCombo, SWT.RIGHT | SWT.TOP);
    //      _relValueCombo.addFocusListener(focusListener);

    _relationContextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setContext(cd.getValue());
            _relationClassCombo.removeAll();
            _relValueCombo.removeAll();
            relContextDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "context", _relation.getContext(), null, null, null));
            if (relContextDeco.getDescriptionText() != null) {
                relContextDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relContextDeco.setImage(null);
            }
            _relationClassComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren());
            contentChanged();
        }

    });
    _relationContextCombo.layout();

    // control for relationContextCombo

    _relationClassComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setRClass(cd.getValue());
            _relValueComboViewer.setInput(_facade.getConfigs().get(_relation.getProvider()).getChildren()
                    .get("aodl:relation").getChildren().get(_relation.getContext()).getChildren()
                    .get(_relation.getRClass()).getChildren());
            relClassDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "class", _relation.getContext(), _relation.getRClass(), null, null));
            if (relClassDeco.getDescriptionText() != null) {
                relClassDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relClassDeco.setImage(null);
            }
            contentChanged();
        }
    });

    _relValueComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            ConfigData cd = (ConfigData) obj;
            _relation.setRelation(cd.getValue());
            relValueDeco.setDescriptionText(PDRConfigProvider.readDocu(_relation.getProvider(), "relation",
                    "value", _relation.getContext(), _relation.getRClass(), _relation.getRelation(), null));
            if (relValueDeco.getDescriptionText() != null) {
                relValueDeco.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
            } else {
                relValueDeco.setImage(null);
            }
            contentChanged();
        }
    });

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

    _personText = new Text(_composite, SWT.BORDER);
    _personText.setBackground(WHITE_COLOR);
    _personText.setLayoutData(new GridData());
    ((GridData) _personText.getLayoutData()).horizontalSpan = 4;
    ((GridData) _personText.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _personText.getLayoutData()).grabExcessHorizontalSpace = true;

    _decoPersonId = new ControlDecoration(_personText, SWT.LEFT | SWT.TOP);

    _personText.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {

            Event ee = new Event();
            ee.widget = RelationEditorLine2.this;
            SelectionEvent se = new SelectionEvent(ee);
            for (SelectionListener s : _selectionListeners) {
                s.widgetSelected(se);
            }

            ContentProposalAdapter adapter = new ContentProposalAdapter(_personText, new TextContentAdapter(),
                    new FacetContentProposalProvider(_facade.getAllPersonsFacets()), null, null);
            adapter.setLabelProvider(new AutoCompleteNameLabelProvider());
            adapter.addContentProposalListener(new IContentProposalListener() {
                @Override
                public void proposalAccepted(final IContentProposal proposal) {
                    _personText.setText(proposal.getContent());
                    if (((Facet) proposal).getKey() != null) {
                        _relation.setObject(new PdrId(((Facet) proposal).getKey()));
                        _decoPersonId.setImage(null);
                        contentChanged();
                    }
                }
            });

        }

        @Override
        public void focusLost(final FocusEvent e) {
            if (_relation != null && _relation.getObject() == null) {
                if (_personText.getText() != null
                        && _facade.getPdrObject(new PdrId(_personText.getText())) != null) {
                    _relation.setObject(new PdrId(_personText.getText()));
                    _decoPersonId.setDescriptionText("");
                    _decoPersonId.setImage(null);
                } else {
                    _relation.setObject(null);
                    _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                    _decoPersonId.setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation"));
                }
            } else if (_personText.getText().trim().length() == 0) {
                _relation.setObject(null);
                _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();

        }
    });

    _personText.addKeyListener(new KeyListener() {

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

        @Override
        public void keyReleased(final KeyEvent e) {
            if (_personText.getText().length() == 23) {
                PdrObject o = _facade.getPdrObject(new PdrId(_personText.getText()));
                if (o != null) {
                    _decoPersonId.setImage(null);
                    _relation.setObject(new PdrId(_personText.getText()));
                    _personText.setText(o.getDisplayNameWithID());
                }
            } else if (_personText.getText().trim().length() == 0) {
                _relation.setObject(null);
                _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
            }
            contentChanged();
        }
    });

    _searchButton = new Button(_composite, SWT.NONE);
    _searchButton.setToolTipText(NLMessages.getString("Editor_open_selObjDialog_object_tip"));
    _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, 1);
            dialog.open();
            if (_facade.getRequestedId() != null) {
                _relation.setObject(_facade.getRequestedId());
                PdrObject o = _facade.getPdrObject(_relation.getObject());
                if (o != null) {
                    _personText.setText(o.getDisplayNameWithID());
                } else {
                    _personText.setText(_facade.getRequestedId().toString());
                }
                if (_relation.getObject().isValid()) {
                    _decoPersonId.setImage(null);
                }
            } else {
                if (!_relation.getObject().isValid()) {
                    _decoPersonId.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage());
                }
            }
            validate();

        }
    });

    // _composite.layout();
    // _composite.pack();
}

From source file:org.bbaw.pdr.ae.view.control.templates.aspectsemantic.controller.config.MarkupTemplateConfigEditor.java

License:Open Source License

private void loadIndividualSettings(final AspectConfigTemplate aspectConfigTemplate, Composite composite) {
    _prevWidget = null;/*from  w w  w . j  a  v a 2  s  .  co  m*/
    for (Control c : composite.getChildren()) {
        c.dispose();
    }
    boolean pathB = false;
    boolean combo = false;
    boolean date = false;
    boolean levelSpanB = false;
    boolean relation = false;
    boolean preSuffix = false;
    boolean horizontalSpan = false;

    switch (aspectConfigTemplate.getWidgetType()) {
    case 0: //text
        pathB = true;
        combo = false;
        date = false;
        levelSpanB = false;
        relation = false;
        preSuffix = true;
        horizontalSpan = true;
        break;
    case 1: //combo
        pathB = false;
        combo = true;
        date = false;
        levelSpanB = true;
        relation = false;
        preSuffix = true;
        horizontalSpan = true;
        break;
    case 2: //date
        pathB = true;
        combo = false;
        date = true;
        levelSpanB = false;
        relation = false;
        preSuffix = true;
        horizontalSpan = false;
        break;
    case 3: // date_combo
        pathB = false;
        combo = true;
        date = true;
        levelSpanB = true;
        relation = false;
        preSuffix = true;
        horizontalSpan = false;
        break;
    case 4: // relation
        pathB = false;
        combo = false;
        date = false;
        levelSpanB = false;
        relation = false;
        preSuffix = false;
        horizontalSpan = false;
        break;
    case 5: // relation_defined
        pathB = false;
        combo = false;
        date = false;
        levelSpanB = false;
        relation = true;
        preSuffix = false;
        horizontalSpan = true;
        break;
    case 6: // timeStm
        pathB = false;
        combo = false;
        date = true;
        levelSpanB = false;
        relation = false;
        preSuffix = false;
        horizontalSpan = false;
        break;
    case 7: // reference
        pathB = false;
        combo = false;
        date = false;
        levelSpanB = false;
        relation = false;
        preSuffix = false;
        horizontalSpan = false;
        break;
    default:
        break;
    }
    final boolean pathCombo = combo;

    // path
    SelectionListener aspectFacetListener = new SelectionAdapter() {
        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final String type = (String) ((Button) e.getSource()).getData();
            aspectConfigTemplate.setPos(type);
            //                 System.out.println("aspectFacetQuery key set to " + type); //$NON-NLS-1$
            if (type.equals("type")) //$NON-NLS-1$
            {
                aspectConfigTemplate.setType(null);
            } else if (type.equals("subtype")) //$NON-NLS-1$
            {
                aspectConfigTemplate.setSubtype(null);
                aspectConfigTemplate.setRole(null);
            } else if (type.equals("role")) //$NON-NLS-1$
            {
                aspectConfigTemplate.setRole(null);

            }

        }
    };
    if (pathB || pathCombo) {
        Label path = new Label(composite, SWT.RIGHT);
        path.setText(NLMessages.getString("Config_Path"));
        path.setLayoutData(new GridData());
        ((GridData) path.getLayoutData()).horizontalSpan = 4;

        Label taggingElement = new Label(composite, SWT.NONE);
        taggingElement.setText(NLMessages.getString("Editor_markup_element") + "*");
        taggingElement.setLayoutData(new GridData());

        Combo comboTaggingElement = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT);
        comboTaggingElement.setBackground(WHITE_COLOR);
        comboTaggingElement.setLayoutData(new GridData());
        ((GridData) comboTaggingElement.getLayoutData()).horizontalSpan = 3;
        ((GridData) comboTaggingElement.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) comboTaggingElement.getLayoutData()).grabExcessHorizontalSpace = true;

        ComboViewer comboTaggingElementViewer = new ComboViewer(comboTaggingElement);
        comboTaggingElementViewer.setContentProvider(new MarkupContentProvider());
        comboTaggingElementViewer.setLabelProvider(new MarkupLabelProvider());
        if (_facade.getConfigs().containsKey(_provider)) {
            // TODO comboTaggingElementViewer
            //         comboTaggingElementViewer.setInput(
            //                     _facade.getConfigs().get(_provider).getChildren());
            comboTaggingElementViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 0));
        }

        final ControlDecoration elementDeco = new ControlDecoration(comboTaggingElement, SWT.RIGHT | SWT.TOP);
        elementDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "element",
                aspectConfigTemplate.getElement(), null, null, null));
        if (elementDeco.getDescriptionText() != null) {
            elementDeco.setImage(FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
        } else {
            elementDeco.setImage(null);
        }

        Label taggingType = new Label(composite, SWT.NONE);
        taggingType.setText(NLMessages.getString("Editor_type") + "*");
        taggingType.setLayoutData(new GridData());

        final Combo comboTaggingType = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT);
        comboTaggingType.setBackground(WHITE_COLOR);
        comboTaggingType.setLayoutData(new GridData());
        ((GridData) comboTaggingType.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) comboTaggingType.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) comboTaggingType.getLayoutData()).horizontalSpan = 3;

        final ComboViewer comboTaggingTypeViewer = new ComboViewer(comboTaggingType);
        comboTaggingTypeViewer.setContentProvider(new MarkupContentProvider());
        comboTaggingTypeViewer.setLabelProvider(new MarkupLabelProvider());
        // comboTaggingType.setItems(readConfigs(_markupProvider, "markup",
        // "type", eListName, null, null));
        final ControlDecoration typeDeco = new ControlDecoration(comboTaggingType, SWT.RIGHT | SWT.TOP);

        if (aspectConfigTemplate.getElement() != null) {
            if (aspectConfigTemplate.getElement().startsWith("aodl:")) {
                aspectConfigTemplate.setElement(aspectConfigTemplate.getElement().substring(5));
            }
            if (_facade.getConfigs().get(_provider).getChildren()
                    .containsKey(aspectConfigTemplate.getElement())) {
                if (pathCombo) {
                    //                  comboTaggingTypeViewer.setInput(
                    //                              
                    //                              _facade.getConfigs().get(_provider).getChildren()
                    //                                 .get("aodl:" + aspectConfigTemplate.getElement()).getChildren());
                    // TODO comboTaggingTypeViewer
                    comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1));
                    ConfigItem ci = new ConfigItem();
                    ci.setLabel("COMBO Selection");
                    ci.setValue("COMBO Selection");
                    ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0);
                } else {
                    //                  comboTaggingTypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren()
                    //                        .get("aodl:" + aspectConfigTemplate.getElement()).getChildren());
                    // TODO: comboTaggingTypeViewer
                    comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1));
                }
            }
        }

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

        final Combo comboTaggingSubtype = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT);
        comboTaggingSubtype.setBackground(WHITE_COLOR);
        comboTaggingSubtype.setLayoutData(new GridData());
        ((GridData) comboTaggingSubtype.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) comboTaggingSubtype.getLayoutData()).grabExcessHorizontalSpace = true;
        comboTaggingSubtype.setEnabled(false);
        final ComboViewer comboTaggingSubtypeViewer = new ComboViewer(comboTaggingSubtype);
        comboTaggingSubtypeViewer.setContentProvider(new MarkupContentProvider());
        comboTaggingSubtypeViewer.setLabelProvider(new MarkupLabelProvider());
        final ControlDecoration subtypeDeco = new ControlDecoration(comboTaggingSubtype, SWT.RIGHT | SWT.TOP);

        ((GridData) comboTaggingSubtype.getLayoutData()).horizontalSpan = 3;

        Label taggingRole = new Label(composite, SWT.NONE);
        taggingRole.setText(NLMessages.getString("Editor_role"));
        taggingRole.setLayoutData(new GridData());

        final Combo comboTaggingRole = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT);
        comboTaggingRole.setBackground(WHITE_COLOR);
        comboTaggingRole.setLayoutData(new GridData());
        ((GridData) comboTaggingRole.getLayoutData()).horizontalAlignment = GridData.FILL;
        ((GridData) comboTaggingRole.getLayoutData()).grabExcessHorizontalSpace = true;
        final ComboViewer comboTaggingRoleViewer = new ComboViewer(comboTaggingRole);
        comboTaggingRoleViewer.setContentProvider(new MarkupContentProvider());
        comboTaggingRoleViewer.setLabelProvider(new MarkupLabelProvider());
        comboTaggingRole.setEnabled(false);
        final ControlDecoration roleDeco = new ControlDecoration(comboTaggingRole, SWT.RIGHT | SWT.TOP);

        ((GridData) comboTaggingRole.getLayoutData()).horizontalSpan = 3;

        _loading = true;

        comboTaggingElementViewer.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.getValue().startsWith("aodl:")) {
                    aspectConfigTemplate.setElement(cd.getValue().substring(5));
                } else {
                    aspectConfigTemplate.setElement(cd.getValue());
                }
                comboTaggingSubtype.removeAll();
                comboTaggingSubtype.setEnabled(false);
                if (!_loading) {
                    comboTaggingType.removeAll();
                    aspectConfigTemplate.setType(""); //$NON-NLS-1$
                    aspectConfigTemplate.setSubtype(""); //$NON-NLS-1$
                    aspectConfigTemplate.setRole(""); //$NON-NLS-1$
                }
                comboTaggingRole.removeAll();
                comboTaggingRole.setEnabled(false);

                elementDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "element",
                        aspectConfigTemplate.getElement(), null, null, null));
                if (elementDeco.getDescriptionText() != null
                        && elementDeco.getDescriptionText().trim().length() > 0) {
                    elementDeco.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                } else {
                    elementDeco.setImage(null);
                }
                typeDeco.setImage(null);
                typeDeco.setDescriptionText(null);
                subtypeDeco.setImage(null);
                subtypeDeco.setDescriptionText(null);
                roleDeco.setImage(null);
                roleDeco.setDescriptionText(null);
                if (_facade.getConfigs().containsKey(_provider)) {
                    //               HashMap<String,ConfigData> children = 
                    //                  _facade.getConfigs().get(_provider).getChildren()
                    //                        .get("aodl:" + aspectConfigTemplate.getElement()).getChildren();

                    // TODO: comboTaggingTypeViewer
                    comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1));
                    if (pathCombo) {
                        ConfigItem ci = new ConfigItem();
                        ci.setLabel("COMBO Selection");
                        ci.setValue("COMBO Selection");
                        ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0);
                        if (!_loading) {
                            comboTaggingTypeViewer.setSelection(new StructuredSelection(ci));
                            aspectConfigTemplate.setPos("type");
                        }
                    } else if (!_loading) {
                        comboTaggingTypeViewer
                                .setSelection(new StructuredSelection(comboTaggingTypeViewer.getElementAt(0)));
                    }
                }
                comboTaggingTypeViewer.refresh();
                // comboTaggingType.setItems(readConfigs(_markupProvider,
                // "markup", "type", eListName, null, null));
            }

        });

        comboTaggingTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection iSelection = event.getSelection();
                Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                ConfigData cd = (ConfigData) obj;
                comboTaggingSubtype.removeAll();
                comboTaggingRole.removeAll();
                comboTaggingRole.setEnabled(false);
                if (!_loading) {
                    aspectConfigTemplate.setSubtype(""); //$NON-NLS-1$
                    aspectConfigTemplate.setRole(""); //$NON-NLS-1$
                }
                if (cd != null) {
                    if (cd.getValue().equals("COMBO Selection")) {
                        comboTaggingRole.setEnabled(false);
                        comboTaggingSubtype.setEnabled(false);
                        aspectConfigTemplate.setType(null);
                        aspectConfigTemplate.setSubtype(null);
                        aspectConfigTemplate.setRole(null);
                        aspectConfigTemplate.setPos("type");
                    } else {
                        aspectConfigTemplate.setType(cd.getValue());
                        //                  ConfigData input = null;
                        //                  if (_facade.getConfigs().containsKey(_provider))
                        //                  {
                        //                     input = _facade.getConfigs().get(_provider).getChildren()
                        //                           .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()
                        //                           .get(aspectConfigTemplate.getType());
                        //                  }
                        //                  if (input != null)
                        if (ifMarkupsOnLevel(aspectConfigTemplate, 1)) {
                            //HashMap<String, ConfigData> children = input.getChildren();
                            // TODO comboTaggingSubtypeViewer
                            HashMap<String, ConfigData> children = getMarkupsOnLevel(aspectConfigTemplate, 2);
                            comboTaggingSubtypeViewer.setInput(children);

                            if (pathCombo && !_loading) {
                                ConfigItem ci = new ConfigItem();
                                ci.setLabel("COMBO Selection");
                                ci.setValue("COMBO Selection");
                                ViewHelper.comboViewerInsertElement(comboTaggingSubtypeViewer, ci, 0);
                                if (!_loading) {
                                    comboTaggingSubtypeViewer.setSelection(new StructuredSelection(ci));
                                    aspectConfigTemplate.setPos("subtype");
                                }
                            }
                            comboTaggingSubtype.setEnabled(true);
                        }
                        typeDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "type",
                                aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), null, null));
                        if (typeDeco.getDescriptionText() != null
                                && typeDeco.getDescriptionText().trim().length() > 0) {
                            typeDeco.setImage(FieldDecorationRegistry.getDefault()
                                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                        } else {
                            typeDeco.setImage(null);
                        }
                    }

                }

                subtypeDeco.setImage(null);
                subtypeDeco.setDescriptionText(null);
                roleDeco.setImage(null);
                roleDeco.setDescriptionText(null);
                processMarkupComboSettings(aspectConfigTemplate);
                updatePreviewWidget(aspectConfigTemplate);
            }

        });

        // Label blancType = new Label(tagging1Coposite, SWT.NONE);
        // blancType.setText("");
        // blancType.setLayoutData(new GridData());

        comboTaggingSubtypeViewer.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) {
                    aspectConfigTemplate.setSubtype(cd.getValue());
                    comboTaggingRole.removeAll();
                    if (!_loading) {
                        aspectConfigTemplate.setRole(""); //$NON-NLS-1$
                    }
                    comboTaggingSubtype.layout();
                    if (cd.getValue().equals("COMBO Selection") && !_loading) {
                        comboTaggingRole.setEnabled(false);
                        aspectConfigTemplate.setSubtype(null);
                        aspectConfigTemplate.setRole(null);
                        aspectConfigTemplate.setPos("subtype");
                    } else {
                        //                  ConfigData input = _facade.getConfigs().get(_provider);
                        //                  if (input != null)
                        //                  {
                        //                     input = input.getChildren().get("aodl:" + aspectConfigTemplate.getElement());
                        //                  }
                        //                  if (input != null)
                        //                  {
                        //                     input = input.getChildren().get(aspectConfigTemplate.getType());
                        //                  }
                        //                  if (input != null)
                        //                  {
                        //                     input = input.getChildren().get(aspectConfigTemplate.getSubtype());
                        //                  }
                        //                  if (input != null)
                        if (ifMarkupsOnLevel(aspectConfigTemplate, 2)) {
                            // TODO comboTaggingRoleViewer
                            HashMap<String, ConfigData> children = getMarkupsOnLevel(aspectConfigTemplate, 3);
                            comboTaggingRoleViewer.setInput(children);
                            if (pathCombo) {
                                ConfigItem ci = new ConfigItem();
                                ci.setLabel("COMBO Selection");
                                ci.setValue("COMBO Selection");
                                ViewHelper.comboViewerInsertElement(comboTaggingRoleViewer, ci, 0);
                                comboTaggingRoleViewer.setSelection(new StructuredSelection(ci));
                                aspectConfigTemplate.setPos("role");
                            }
                            comboTaggingRole.setEnabled(true);

                        }
                        subtypeDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup",
                                "subtype", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(),
                                aspectConfigTemplate.getSubtype(), null));
                        if (subtypeDeco.getDescriptionText() != null
                                && subtypeDeco.getDescriptionText().trim().length() > 0) {
                            subtypeDeco.setImage(FieldDecorationRegistry.getDefault()
                                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                        } else {
                            subtypeDeco.setImage(null);
                        }
                    }
                    roleDeco.setImage(null);
                    roleDeco.setDescriptionText(null);
                    processMarkupComboSettings(aspectConfigTemplate);
                    updatePreviewWidget(aspectConfigTemplate);

                }
            }

        });
        // Label blancSubtype = new Label(tagging1Coposite, SWT.NONE);
        // blancSubtype.setText("");
        // blancSubtype.setLayoutData(new GridData());
        // end subtype

        comboTaggingRoleViewer.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) {
                    if (cd.getValue().equals("COMBO Selection")) {
                        aspectConfigTemplate.setRole(null);
                        aspectConfigTemplate.setPos("role");
                    } else {
                        aspectConfigTemplate.setRole(cd.getValue());
                        roleDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "role",
                                aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(),
                                aspectConfigTemplate.getSubtype(), aspectConfigTemplate.getRole()));
                        if (roleDeco.getDescriptionText() != null
                                && roleDeco.getDescriptionText().trim().length() > 0) {
                            roleDeco.setImage(FieldDecorationRegistry.getDefault()
                                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                        } else {
                            roleDeco.setImage(null);
                        }
                    }
                    processMarkupComboSettings(aspectConfigTemplate);
                    updatePreviewWidget(aspectConfigTemplate);

                } else {
                    roleDeco.setImage(null);
                }

            }
        });

        // set combos
        if (date && comboTaggingElementViewer != null) {
            aspectConfigTemplate.setElement("date");
            if (_facade.getConfigs().get(_provider) != null
                    && _facade.getConfigs().get(_provider).getChildren().containsKey("aodl:date")) {
                comboTaggingElementViewer.setSelection(new StructuredSelection(
                        _facade.getConfigs().get(_provider).getChildren().get("aodl:date")));
                comboTaggingElement.setEnabled(false);
                comboTaggingType.setEnabled(true);
                comboTaggingTypeViewer.refresh();
            }
        }
        if (aspectConfigTemplate.getElement() != null) {
            if (!aspectConfigTemplate.getElement().startsWith("aodl:")) {
                setComboViewerByString(comboTaggingElementViewer, "aodl:" + aspectConfigTemplate.getElement());
            } else {
                setComboViewerByString(comboTaggingElementViewer, aspectConfigTemplate.getElement());
            }

            if (aspectConfigTemplate.getType() != null) {
                //               if (_facade.getConfigs().get(_provider) != null
                //                     && _facade.getConfigs().get(_provider).getChildren()
                //                           .get("aodl:" + aspectConfigTemplate.getElement()) != null)
                if (ifMarkupsOnLevel(aspectConfigTemplate, 0)) {
                    //                  comboTaggingTypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren()
                    //                        .get("aodl:" + aspectConfigTemplate.getElement()).getChildren());
                    //TODO comboTaggingTypeViewer
                    comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1));

                    if (pathCombo && aspectConfigTemplate.getPos() != null
                            && aspectConfigTemplate.getPos().equals("type")) {
                        ConfigItem ci = new ConfigItem();
                        ci.setLabel("COMBO Selection");
                        ci.setValue("COMBO Selection");
                        ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0);
                        setComboViewerByString(comboTaggingTypeViewer, "COMBO Selection");
                    } else {
                        setComboViewerByString(comboTaggingTypeViewer, aspectConfigTemplate.getType());
                    }
                    //                  if (aspectConfigTemplate.getType() != null
                    //                        && _facade.getConfigs().get(_provider).getChildren()
                    //                              .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()
                    //                              .get(aspectConfigTemplate.getType()) != null)
                    if (ifMarkupsOnLevel(aspectConfigTemplate, 1))

                    {
                        //                     comboTaggingSubtypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren()
                        //                           .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()
                        //                           .get(aspectConfigTemplate.getType()).getChildren());
                        // TODO: comboTaggingSubtypeViewer
                        comboTaggingSubtypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 2));
                        if (pathCombo && aspectConfigTemplate.getPos() != null
                                && aspectConfigTemplate.getPos().equals("subtype")) {
                            ConfigData ci = new ConfigData();
                            ci.setLabel("COMBO Selection");
                            ci.setValue("COMBO Selection");
                            ViewHelper.comboViewerInsertElement(comboTaggingSubtypeViewer, ci, 0);
                            setComboViewerByString(comboTaggingSubtypeViewer, "COMBO Selection");
                        } else {
                            setComboViewerByString(comboTaggingSubtypeViewer,
                                    aspectConfigTemplate.getSubtype());

                        }

                        //                     if (aspectConfigTemplate.getSubtype() != null
                        //                           && _facade.getConfigs().get(_provider).getChildren()
                        //                           .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()
                        //                              .get(aspectConfigTemplate.getType()).getChildren()
                        //                                 .get(aspectConfigTemplate.getSubtype()) != null)
                        if (ifMarkupsOnLevel(aspectConfigTemplate, 2)) {
                            // TODO comboTaggingRoleViewer
                            comboTaggingRoleViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 3));

                            if (pathCombo && aspectConfigTemplate.getPos() != null
                                    && aspectConfigTemplate.getPos().equals("role")) {
                                ConfigItem ci = new ConfigItem();
                                ci.setLabel("COMBO Selection");
                                ci.setValue("COMBO Selection");
                                ViewHelper.comboViewerInsertElement(comboTaggingRoleViewer, ci, 0);
                                setComboViewerByString(comboTaggingRoleViewer, "COMBO Selection");
                            } else {
                                setComboViewerByString(comboTaggingRoleViewer, aspectConfigTemplate.getRole());

                            }
                        }
                    }
                }

            }
            _loading = false;
        } else {
            comboTaggingElementViewer.setSelection(new StructuredSelection(
                    _facade.getConfigs().get(_provider).getChildren().get("aodl:persName")));
            comboTaggingElement.setEnabled(true);
            if (_facade.getConfigs().containsKey(_provider)) {
                comboTaggingTypeViewer.setInput(
                        _facade.getConfigs().get(_provider).getChildren().get("aodl:persName").getChildren());
            }
            comboTaggingTypeViewer.refresh();
        }
    }
    if (levelSpanB) {
        // levelSpan
        Label levelSpan = new Label(composite, SWT.NONE);
        levelSpan.setText(NLMessages.getString("Config_level_span"));
        levelSpan.setLayoutData(new GridData());
        ((GridData) levelSpan.getLayoutData()).horizontalSpan = 1;
        ((GridData) levelSpan.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) levelSpan.getLayoutData()).horizontalAlignment = SWT.FILL;
        levelSpan.pack();

        final Spinner levelSpanSpinner = new Spinner(composite, SWT.NONE | SWT.READ_ONLY);
        levelSpanSpinner.setLayoutData(new GridData());
        ((GridData) levelSpanSpinner.getLayoutData()).horizontalSpan = 1;
        ((GridData) levelSpanSpinner.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) levelSpanSpinner.getLayoutData()).horizontalAlignment = SWT.FILL;
        levelSpanSpinner.setSelection(aspectConfigTemplate.getLevelSpan());

        levelSpanSpinner.setMaximum(3);
        levelSpanSpinner.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent se) {
                aspectConfigTemplate.setLevelSpan(levelSpanSpinner.getSelection());
                updatePreviewWidget(aspectConfigTemplate);

            }
        }); // SelectionListener
    }
    if (combo) {
        Label levelSpan = new Label(composite, SWT.NONE);
        levelSpan.setText(NLMessages.getString("Config_Preview"));
        levelSpan.setLayoutData(new GridData());
        ((GridData) levelSpan.getLayoutData()).horizontalSpan = 1;
        ((GridData) levelSpan.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) levelSpan.getLayoutData()).horizontalAlignment = SWT.FILL;
        levelSpan.pack();

        Composite c = new Composite(composite, SWT.BORDER);
        c.setLayoutData(new GridData());
        c.setLayout(new GridLayout(1, false));
        ((GridLayout) c.getLayout()).marginHeight = 0;
        ((GridLayout) c.getLayout()).verticalSpacing = 0;
        ((GridLayout) c.getLayout()).marginWidth = 0;
        ((GridData) c.getLayoutData()).heightHint = 20;
        ((GridData) c.getLayoutData()).horizontalSpan = 1;
        ((GridData) c.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) c.getLayoutData()).horizontalAlignment = SWT.FILL;
        _prevWidget = new AEAspectWidgetCustomizable(c, aspectConfigTemplate, SWT.NONE);
        updatePreviewWidget(aspectConfigTemplate);
        c.layout();
        c.pack();
    }

    if (date) {
        Label date1 = new Label(composite, SWT.RIGHT);
        date1.setText(NLMessages.getString("Editor_add_dates") + "1");
        date1.setLayoutData(new GridData());

        final Combo date1Combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        date1Combo.setBackground(WHITE_COLOR);
        date1Combo.setLayoutData(new GridData());
        ((GridData) date1Combo.getLayoutData()).horizontalSpan = 1;
        ((GridData) date1Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) date1Combo.getLayoutData()).grabExcessHorizontalSpace = true;
        ComboViewer date1ComboViewer = new ComboViewer(date1Combo);
        date1ComboViewer.setContentProvider(ArrayContentProvider.getInstance());
        date1ComboViewer.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;
            }

        });

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

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

        });
        if (aspectConfigTemplate.getDate1() != null) {
            StructuredSelection selection = new StructuredSelection(aspectConfigTemplate.getDate1());
            date1ComboViewer.setSelection(selection);
        } else {
            date1Combo.select(0);
            ISelection selection = date1ComboViewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            String s = (String) obj;
            aspectConfigTemplate.setDate1(s);
        }

        Label date2 = new Label(composite, SWT.RIGHT);
        date2.setText(NLMessages.getString("Editor_add_dates") + "2");
        date2.setLayoutData(new GridData());

        final Combo date2Combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        date2Combo.setBackground(WHITE_COLOR);
        date2Combo.setLayoutData(new GridData());
        ((GridData) date2Combo.getLayoutData()).horizontalSpan = 1;
        ((GridData) date2Combo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) date2Combo.getLayoutData()).grabExcessHorizontalSpace = true;
        ComboViewer date2ComboViewer = new ComboViewer(date2Combo);
        date2ComboViewer.setContentProvider(ArrayContentProvider.getInstance());
        date2ComboViewer.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(final Object element) {
                String str = (String) element;
                if (str.trim().length() > 0) {
                    String label = NLMessages.getString("Editor_time_" + str);
                    if (label != null && !label.startsWith("!")) {
                        return label;
                    }
                }
                return str;
            }

        });

        String[] _afters = new String[] { "", "to", "notAfter" }; //$NON-NLS-1$
        date2ComboViewer.setInput(_afters);
        date2ComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

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

        });
        if (aspectConfigTemplate.getDate2() != null) {
            StructuredSelection selection = new StructuredSelection(aspectConfigTemplate.getDate2());
            date2ComboViewer.setSelection(selection);
        } else {
            date2Combo.select(0);
            ISelection selection = date2ComboViewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            String s = (String) obj;
            aspectConfigTemplate.setDate2(s);
        }
    }

    if (relation) {
        Label relationContextLabel = new Label(composite, SWT.NONE);
        relationContextLabel.setText(NLMessages.getString("Editor_context"));
        relationContextLabel.setLayoutData(new GridData());
        ((GridData) relationContextLabel.getLayoutData()).horizontalSpan = 1;

        Combo relationContextCombo = new Combo(composite, SWT.READ_ONLY);
        relationContextCombo.setBackground(WHITE_COLOR);
        relationContextCombo.setLayoutData(new GridData());
        ((GridData) relationContextCombo.getLayoutData()).horizontalSpan = 3;
        ((GridData) relationContextCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) relationContextCombo.getLayoutData()).grabExcessHorizontalSpace = true;
        final ComboViewer relationContextComboViewer = new ComboViewer(relationContextCombo);
        relationContextComboViewer.setContentProvider(new MarkupContentProvider());
        relationContextComboViewer.setLabelProvider(new MarkupLabelProvider());

        final ControlDecoration relContextDeco = new ControlDecoration(relationContextCombo,
                SWT.RIGHT | SWT.TOP);

        Label relationTypeLabel = new Label(composite, SWT.NONE);
        relationTypeLabel.setText(NLMessages.getString("Editor_class"));
        relationTypeLabel.setLayoutData(new GridData());
        ((GridData) relationTypeLabel.getLayoutData()).horizontalSpan = 1;

        final Combo relationClassCombo = new Combo(composite, SWT.READ_ONLY);
        relationClassCombo.setBackground(WHITE_COLOR);
        relationClassCombo.setLayoutData(new GridData());
        ((GridData) relationClassCombo.getLayoutData()).horizontalSpan = 3;
        ((GridData) relationClassCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) relationClassCombo.getLayoutData()).grabExcessHorizontalSpace = true;
        final ComboViewer relationClassComboViewer = new ComboViewer(relationClassCombo);
        relationClassComboViewer.setContentProvider(new MarkupContentProvider());
        relationClassComboViewer.setLabelProvider(new MarkupLabelProvider());
        final ControlDecoration relClassDeco = new ControlDecoration(relationClassCombo, SWT.RIGHT | SWT.TOP);

        Label relCitationLabel = new Label(composite, SWT.NONE);
        relCitationLabel.setText(NLMessages.getString("Config_value"));
        relCitationLabel.setLayoutData(new GridData());

        final Combo relValueCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
        relValueCombo.setBackground(WHITE_COLOR);
        relValueCombo.setLayoutData(new GridData());
        ((GridData) relValueCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
        ((GridData) relValueCombo.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) relValueCombo.getLayoutData()).horizontalSpan = 3;
        final ComboViewer relValueComboViewer = new ComboViewer(relValueCombo);
        relValueComboViewer.setContentProvider(new MarkupContentProvider());
        relValueComboViewer.setLabelProvider(new MarkupLabelProvider());
        final ControlDecoration relValueDeco = new ControlDecoration(relValueCombo, SWT.RIGHT | SWT.TOP);

        if (_facade.getConfigs().get(_provider) != null) {
            relationContextComboViewer.setInput(
                    _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren());
        }

        // control for relationClassCombo
        // ArrayList<String> list = cListPro
        //                  .getList("types", "type", "relation"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        // for (int n = 0; n < list.size(); n++)
        // {
        // relationClassCombo.add(list.get(n));
        // }
        if (aspectConfigTemplate.getElement() != null) {
            setComboViewerByString(relationContextComboViewer, aspectConfigTemplate.getElement());
        }

        relationContextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection iSelection = event.getSelection();
                Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                ConfigData cd = (ConfigData) obj;
                aspectConfigTemplate.setElement(cd.getValue());
                relationClassCombo.removeAll();
                relValueCombo.removeAll();
                relContextDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "context",
                        aspectConfigTemplate.getElement(), null, null, null));
                if (relContextDeco.getDescriptionText() != null) {
                    relContextDeco.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                } else {
                    relContextDeco.setImage(null);
                }
                relationClassComboViewer
                        .setInput(_facade.getConfigs().get(_provider).getChildren().get("aodl:relation")
                                .getChildren().get(aspectConfigTemplate.getElement()).getChildren());
            }

        });

        relationContextCombo.layout();

        // control for relationContextCombo
        if (aspectConfigTemplate.getType() != null) {
            if (aspectConfigTemplate.getElement() != null && _facade.getConfigs().get(_provider) != null
                    && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation") != null
                    && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren()
                            .get(aspectConfigTemplate.getElement()) != null) {
                relationClassComboViewer
                        .setInput(_facade.getConfigs().get(_provider).getChildren().get("aodl:relation")
                                .getChildren().get(aspectConfigTemplate.getElement()).getChildren());
            }
            setComboViewerByString(relationClassComboViewer, aspectConfigTemplate.getType());
        } else {
            relationClassComboViewer.setInput(null);
            relationClassComboViewer.refresh();
        }
        relationClassComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection iSelection = event.getSelection();
                Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                ConfigData cd = (ConfigData) obj;
                aspectConfigTemplate.setType(cd.getValue());
                relValueComboViewer.setInput(_facade.getConfigs().get(_provider).getChildren()
                        .get("aodl:relation").getChildren().get(aspectConfigTemplate.getElement()).getChildren()
                        .get(aspectConfigTemplate.getType()).getChildren());
                relValueComboViewer.refresh();
                relClassDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "class",
                        aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), null, null));
                if (relClassDeco.getDescriptionText() != null) {
                    relClassDeco.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                } else {
                    relClassDeco.setImage(null);
                }
            }
        });

        relationClassCombo.layout();
        if (aspectConfigTemplate.getSubtype() != null) {
            if (aspectConfigTemplate.getType() != null && _facade.getConfigs().get(_provider) != null
                    && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation") != null
                    && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren()
                            .get(aspectConfigTemplate.getElement()) != null
                    && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren()
                            .get(aspectConfigTemplate.getElement()).getChildren()
                            .get(aspectConfigTemplate.getType()) != null) {
                relValueComboViewer.setInput(_facade.getConfigs().get(_provider).getChildren()
                        .get("aodl:relation").getChildren().get(aspectConfigTemplate.getElement()).getChildren()
                        .get(aspectConfigTemplate.getType()).getChildren());
            }
            setComboViewerByString(relValueComboViewer, aspectConfigTemplate.getSubtype());
        } else {
            relValueComboViewer.setInput(null);
            relValueComboViewer.refresh();
        }
        relValueComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                ISelection iSelection = event.getSelection();
                Object obj = ((IStructuredSelection) iSelection).getFirstElement();
                ConfigData cd = (ConfigData) obj;
                aspectConfigTemplate.setSubtype(cd.getValue());
                relValueDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "value",
                        aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(),
                        aspectConfigTemplate.getSubtype(), null));
                if (relValueDeco.getDescriptionText() != null) {
                    relValueDeco.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                } else {
                    relValueDeco.setImage(null);
                }
            }
        });

    }
    if (preSuffix) {
        Label prefix = new Label(composite, SWT.NONE);
        prefix.setText(NLMessages.getString("Config_Prefix"));
        prefix.setLayoutData(new GridData());

        final Text prefixText = new Text(composite, SWT.BORDER);
        prefixText.setLayoutData(new GridData());
        ((GridData) prefixText.getLayoutData()).horizontalSpan = 1;
        ((GridData) prefixText.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) prefixText.getLayoutData()).horizontalAlignment = SWT.FILL;
        if (aspectConfigTemplate.getPrefix() != null) {
            prefixText.setText(aspectConfigTemplate.getPrefix());
        } else {
            prefixText.setText("");
        }
        prefixText.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(final FocusEvent e) {
                aspectConfigTemplate.setPrefix(prefixText.getText().trim());
                // if (c instanceof ConfigItem)
                // {
                // ((ConfigItem) c).setLabel(labelText.getText().trim());
                // }
            }
        });

        Label suffix = new Label(composite, SWT.NONE);
        suffix.setText(NLMessages.getString("Config_suffix"));
        suffix.setLayoutData(new GridData());

        final Text suffixText = new Text(composite, SWT.BORDER);
        suffixText.setLayoutData(new GridData());
        ((GridData) suffixText.getLayoutData()).horizontalSpan = 1;
        ((GridData) suffixText.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) suffixText.getLayoutData()).horizontalAlignment = SWT.FILL;
        if (aspectConfigTemplate.getSuffix() != null) {
            suffixText.setText(aspectConfigTemplate.getSuffix());
        } else {
            suffixText.setText("");
        }
        suffixText.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(final FocusEvent e) {
                aspectConfigTemplate.setSuffix(suffixText.getText().trim());
                // if (c instanceof ConfigItem)
                // {
                // ((ConfigItem) c).setLabel(labelText.getText().trim());
                // }
            }
        });
    }

    // levelSpan
    if (horizontalSpan) {
        Label horizontalSpanL = new Label(composite, SWT.NONE);
        horizontalSpanL.setText(NLMessages.getString("Config_horizontal_span"));
        horizontalSpanL.setLayoutData(new GridData());
        ((GridData) horizontalSpanL.getLayoutData()).horizontalSpan = 1;
        ((GridData) horizontalSpanL.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) horizontalSpanL.getLayoutData()).horizontalAlignment = SWT.FILL;
        horizontalSpanL.pack();

        final Combo horizontalSpanCombo = new Combo(composite, SWT.NONE | SWT.READ_ONLY);
        horizontalSpanCombo.setLayoutData(new GridData());
        ((GridData) horizontalSpanCombo.getLayoutData()).horizontalSpan = 1;
        ((GridData) horizontalSpanCombo.getLayoutData()).grabExcessHorizontalSpace = true;
        ((GridData) horizontalSpanCombo.getLayoutData()).horizontalAlignment = SWT.FILL;

        if (relation) {
            horizontalSpanCombo.setItems(new String[] { "50%", "75%", "100%" });
        } else {
            horizontalSpanCombo.setItems(new String[] { "25%", "50%", "75%", "100%" });
        }
        horizontalSpanCombo.select(aspectConfigTemplate.getHorizontalSpan() - 1);

        horizontalSpanCombo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent se) {
                String selection = horizontalSpanCombo.getItem(horizontalSpanCombo.getSelectionIndex());
                if (selection.startsWith("25")) {
                    aspectConfigTemplate.setHorizontalSpan(1);
                } else if (selection.startsWith("50")) {
                    aspectConfigTemplate.setHorizontalSpan(2);
                } else if (selection.startsWith("75")) {
                    aspectConfigTemplate.setHorizontalSpan(3);
                } else if (selection.startsWith("100")) {
                    aspectConfigTemplate.setHorizontalSpan(4);
                }
            }
        }); // SelectionListener
    } else {
        aspectConfigTemplate.setHorizontalSpan(4);
    }
    composite.layout();
}

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

License:Open Source License

/**
 * Load classification.//from  w  w w  .  j a va2 s . c o m
 * @param type the type
 * @param cla the cla
 */
private void loadClassification(final int type, final Integer cla) {
    if (_scrollCompClass != null) {
        _scrollCompClass.dispose();
    }
    _scrollCompClass = new ScrolledComposite(_classificationComposite, SWT.V_SCROLL);
    _scrollCompClass.setExpandHorizontal(true);
    _scrollCompClass.setExpandVertical(true);
    _scrollCompClass.setMinHeight(1);
    _scrollCompClass.setMinWidth(1);

    _scrollCompClass.setLayout(new GridLayout());
    _scrollCompClass.setLayoutData(new GridData());
    ((GridData) _scrollCompClass.getLayoutData()).heightHint = 100;
    ((GridData) _scrollCompClass.getLayoutData()).widthHint = 700;
    ((GridData) _scrollCompClass.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _scrollCompClass.getLayoutData()).grabExcessHorizontalSpace = true;

    Composite contentCompClass = new Composite(_scrollCompClass, SWT.NONE);
    contentCompClass.setLayout(new GridLayout());
    ((GridLayout) contentCompClass.getLayout()).numColumns = 4;
    ((GridLayout) contentCompClass.getLayout()).makeColumnsEqualWidth = false;
    ((GridLayout) contentCompClass.getLayout()).marginHeight = 0;
    ((GridLayout) contentCompClass.getLayout()).marginWidth = 0;
    _scrollCompClass.setContent(contentCompClass);

    switch (type) {
    case 0:
        break; // nix, normales laden
    case 1: // neue SemanticStm einfgen
        if (_currentAspect.getSemanticDim() == null) {
            _currentAspect.setSemanticDim(new SemanticDim());
            _currentAspect.getSemanticDim().setSemanticStms(new Vector<SemanticStm>());
            _currentAspect.getSemanticDim().getSemanticStms().add(new SemanticStm());
        } else {
            _currentAspect.getSemanticDim().getSemanticStms().add(new SemanticStm());

        }
        _currentAspect.getSemanticDim().getSemanticStms().lastElement()
                .setProvider(Platform
                        .getPreferencesService().getString(CommonActivator.PLUGIN_ID,
                                "PRIMARY_SEMANTIC_PROVIDER", AEConstants.CLASSIFICATION_AUTHORITY, null)
                        .toUpperCase()); //$NON-NLS-1$
        break;
    case 2: // SemanticStm lschen
        _currentAspect.getSemanticDim().remove(cla);
        break;
    default:
        break;
    }
    // contentCompClass = (Composite)scrollCompClass.getContent();
    // Control[] children = contentCompClass.getChildren();
    // for (Control c : children)
    // {
    // c.dispose();
    // }

    if (_currentAspect.getSemanticDim() != null) {
        for (int i = 0; i < _currentAspect.getSemanticDim().getSemanticStms().size(); i++) {
            final SemanticStm semanticStm = _currentAspect.getSemanticDim().getSemanticStms().get(i);

            if (_facade.isPersonNameTag(semanticStm.getLabel())) {
                _addBelongsToButton.setEnabled(false);
                _addRelationsButton.setEnabled(false);
                while (_currentAspect.getRelationDim().getRelationStms().size() > 1) {
                    _currentAspect.getRelationDim().getRelationStms()
                            .remove(_currentAspect.getRelationDim().getRelationStms().lastElement());
                }
            } else {
                setMessage("");
                _addBelongsToButton.setEnabled(_mayWrite);
                _addRelationsButton.setEnabled(_mayWrite);
            }

            final Combo claProviderCombo = new Combo(contentCompClass, SWT.DROP_DOWN | SWT.READ_ONLY);
            claProviderCombo.setItems(PDRConfigProvider.readConfigs(_semanticProvider, "_semanticProvider",
                    null, null, null, null));
            claProviderCombo.setEnabled(_mayWrite);
            claProviderCombo.setLayoutData(new GridData());
            ((GridData) claProviderCombo.getLayoutData()).minimumWidth = 100;
            // ((GridData)
            // claProviderCombo.getLayoutData()).horizontalAlignment =
            // SWT.LEFT;
            // claProviderCombo.pack();
            claProviderCombo.setBackground(WHITE_COLOR);

            final Combo classifierCombo = new Combo(contentCompClass, SWT.DROP_DOWN | SWT.READ_ONLY);
            classifierCombo.setEnabled(_mayWrite);
            classifierCombo.setBackground(WHITE_COLOR);
            final ComboViewer comboSemanticViewer = new ComboViewer(classifierCombo);
            comboSemanticViewer.setContentProvider(new MarkupContentProvider());
            comboSemanticViewer.setLabelProvider(new MarkupLabelProvider());

            claProviderCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent se) {
                    semanticStm.setProvider(claProviderCombo.getItem(claProviderCombo.getSelectionIndex()));
                    classifierCombo.removeAll();

                    if (semanticStm.getProvider() != null && semanticStm.getProvider().trim().length() > 0) {
                        if (_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) != null
                                && _facade.getConfigs().get(semanticStm.getProvider().toUpperCase())
                                        .getChildren().get("aodl:semanticStm").getChildren() != null
                                && !_facade.getConfigs().get(semanticStm.getProvider().toUpperCase())
                                        .getChildren().get("aodl:semanticStm").getChildren().isEmpty()) {
                            comboSemanticViewer.setInput(_facade.getConfigs().get(semanticStm.getProvider())
                                    .getChildren().get("aodl:semanticStm").getChildren());

                        }
                    }
                }
            });

            // }

            if (semanticStm.getProvider() != null && semanticStm.getProvider().trim().length() > 0) {
                ViewHelper.setComboByString(claProviderCombo, semanticStm.getProvider().toUpperCase());
                if (_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) != null
                        && _facade.getConfigs().get(semanticStm.getProvider().toUpperCase()).getChildren()
                                .get("aodl:semanticStm").getChildren() != null
                        && !_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()).getChildren()
                                .get("aodl:semanticStm").getChildren().isEmpty()) {
                    comboSemanticViewer
                            .setInput(_facade.getConfigs().get(semanticStm.getProvider().toUpperCase())
                                    .getChildren().get("aodl:semanticStm").getChildren());
                }

            }
            classifierCombo.setLayoutData(new GridData());
            ((GridData) classifierCombo.getLayoutData()).grabExcessHorizontalSpace = true;
            ((GridData) classifierCombo.getLayoutData()).horizontalAlignment = SWT.FILL;
            ((GridData) classifierCombo.getLayoutData()).horizontalIndent = 6;
            final ControlDecoration decoClassC = new ControlDecoration(classifierCombo, SWT.LEFT | SWT.TOP);
            final ControlDecoration decoClassInfo = new ControlDecoration(classifierCombo, SWT.RIGHT | SWT.TOP);

            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) {
                        semanticStm.setLabel(cp.getValue());
                        decoClassInfo.setDescriptionText(PDRConfigProvider.readDocu(semanticStm.getProvider(),
                                "semanticStm", semanticStm.getLabel(), null, null, null, null));
                        if (decoClassInfo.getDescriptionText() != null) {
                            decoClassInfo.setImage(FieldDecorationRegistry.getDefault()
                                    .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                        } else {
                            decoClassInfo.setImage(null);
                        }
                        decoClassC.setImage(null);
                        if (_facade.isPersonNameTag(semanticStm.getLabel())) {
                            _addBelongsToButton.setEnabled(false);
                            _addRelationsButton.setEnabled(false);
                            setMessage(NLMessages.getString("Editor_semantic_norm_name_only_one_relation"));
                            while (_currentAspect.getRelationDim().getRelationStms().size() > 1) {
                                _currentAspect.getRelationDim().getRelationStms().remove(
                                        _currentAspect.getRelationDim().getRelationStms().lastElement());
                            }
                            loadRelationDim(0, 0, 0);
                        } else {
                            setMessage("");
                            _addBelongsToButton.setEnabled(true);
                            _addRelationsButton.setEnabled(true);
                        }
                        validate();
                    }

                }

            });

            if (semanticStm.getLabel() != null) {
                ViewHelper.setComboViewerByString(comboSemanticViewer, semanticStm.getLabel(), true);
                decoClassInfo
                        .setDescriptionText(PDRConfigProvider.readDocu(semanticStm.getProvider().toUpperCase(),
                                "semanticStm", semanticStm.getLabel(), null, null, null, null));
                if (decoClassInfo.getDescriptionText() != null) {
                    decoClassInfo.setImage(FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
                } else {
                    decoClassInfo.setImage(null);
                }
                // @SuppressWarnings("unchecked")
                // HashMap<String, ConfigData> inputs = (HashMap<String,
                // ConfigData>) comboSemanticViewer.getInput();
                // if (inputs.containsKey(semanticStm.getLabel()))
                // {
                // // System.out.println("contains key s " + s);
                // for (String key : inputs.keySet())
                // {
                // if (key.equals(semanticStm.getLabel()))
                // {
                // ConfigData cd = inputs.get(key);
                //
                // // StructuredSelection sel = new
                // // StructuredSelection(cd);
                // // comboSemanticViewer.setSelection(sel, true);
                // comboSemanticViewer.reveal(cd);
                // break;
                // }
                // }
                // }
            } else {
                decoClassC.setImage(FieldDecorationRegistry.getDefault()
                        .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage());
            }

            // classifierCombo.pack();

            final Button delSemanticStm = new Button(contentCompClass, SWT.PUSH);
            delSemanticStm.setToolTipText(NLMessages.getString("Editor_remove_semStm_tip"));
            delSemanticStm.setImage(_imageReg.get(IconsInternal.CLASSIFICATION_REMOVE));
            delSemanticStm.setLayoutData(new GridData());
            ((GridData) delSemanticStm.getLayoutData()).horizontalAlignment = SWT.RIGHT;
            ((GridData) delSemanticStm.getLayoutData()).horizontalIndent = 6;
            delSemanticStm.setData("cla", i); //$NON-NLS-1$
            delSemanticStm
                    .setEnabled(_currentAspect.getSemanticDim().getSemanticStms().size() > 1 && _mayWrite);
            delSemanticStm.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent event) {
                    loadClassification(2, (Integer) delSemanticStm.getData("cla")); //$NON-NLS-1$
                    validate();

                }
            });
            //            delSemanticStm.pack();
            if (i == 0) {
                Button addFurtherClassifier = new Button(contentCompClass, SWT.PUSH);
                addFurtherClassifier.setToolTipText(NLMessages.getString("Editor_add_semStm_tip"));
                addFurtherClassifier.setImage(_imageReg.get(IconsInternal.CLASSIFICATION_ADD));
                addFurtherClassifier.setEnabled(_mayWrite);
                addFurtherClassifier.setLayoutData(new GridData());
                ((GridData) addFurtherClassifier.getLayoutData()).horizontalAlignment = SWT.LEFT;
                addFurtherClassifier.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent event) {
                        loadClassification(1, null);
                        validate();
                    }
                });
                //               addFurtherClassifier.pack();
            } else {
                Label blanc = new Label(contentCompClass, SWT.NONE);
                blanc.setText("");
            }
            // ccCompo.redraw();
            // ccCompo.layout();
            // ccCompo.pack();
        }
    }
    // classificationGroup.redraw();
    // classificationGroup.layout();
    // classificationGroup.pack();
    contentCompClass.layout();
    contentCompClass.layout();
    _scrollCompClass.setContent(contentCompClass);
    Point point = contentCompClass.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    // System.out.println("contentComp Class height " + point.y);
    Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    if (point.x > mp.x - 20) {
        point.x = mp.x - 20;
    }
    _scrollCompClass.setMinSize(point);
    _scrollCompClass.layout();

    _classificationComposite.redraw();
    _classificationComposite.layout();
    //      _classificationComposite.pack();
    //      _mainTabFolder.redraw();
    _mainTabFolder.layout();
    //      _mainTabFolder.pack();

}