From ac12d86badd84c421736d5a235dc8372e57bbc4e Mon Sep 17 00:00:00 2001 From: Patric Plitzner Date: Wed, 29 May 2013 09:17:28 +0000 Subject: [PATCH] - added java doc - formatted code --- .../ui/element/AbstractFormSection.java | 21 +- .../taxeditor/ui/element/CdmFormFactory.java | 3868 ++++++++--------- .../ui/section/AbstractCdmDetailSection.java | 56 +- .../AbstractEntityCollectionSection.java | 115 +- .../vocabulary/DefinedTermDetailSection.java | 30 +- .../taxeditor/view/detail/DetailsViewer.java | 1263 +++--- 6 files changed, 2594 insertions(+), 2759 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java index 0ebb93641..426b4c285 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java @@ -33,20 +33,24 @@ import org.eclipse.ui.forms.widgets.ToggleHyperlink; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; -import eu.etaxonomy.taxeditor.store.StoreUtil; +import eu.etaxonomy.taxeditor.model.AbstractUtility; /** *

- * Abstract AbstractFormSection class. + * Abstract super class for a {@link Section} GUI element that visualizes a CDM + * entity, manages a conversation and listens to selections *

* + * @param A CDM entity which should be visualized by this section. + * * @author n.hoffmann * @created Feb 22, 2010 * @version 1.0 * @param */ +//TODO shouldn't ENTITY be bound with super class ICdmBase for example (AbstractFormSection)? public abstract class AbstractFormSection extends Section implements - ISelectionChangedListener, ICdmFormElement, IEntityElement, + ISelectionChangedListener, IEntityElement, IConversationEnabled { private ISelectionProvider selectionProvider; @@ -217,7 +221,7 @@ public abstract class AbstractFormSection extends Section implements ((IPropertyChangeListener) listener).propertyChange(event); } } catch (ConcurrentModificationException e) { - StoreUtil.warn(getClass(), + AbstractUtility.warn(getClass(), "ConcurrentModificationException while handling PropertyChangeEvents." + " It seems like this is not critical"); } @@ -425,8 +429,7 @@ public abstract class AbstractFormSection extends Section implements // unregister selection arbitrator if (childElement instanceof ISelectableElement) { ISelectableElement selectableElement = (ISelectableElement) childElement; - if (selectableElement != null - && selectableElement.getSelectionArbitrator() != null) { + if (selectableElement.getSelectionArbitrator() != null) { formFactory.destroySelectionArbitrator(selectableElement .getSelectionArbitrator()); } @@ -568,15 +571,15 @@ public abstract class AbstractFormSection extends Section implements public ConversationHolder getConversationHolder() { if(getParentElement() instanceof RootElement || getParentElement() == null){ - IEditorPart activeEditor = StoreUtil.getActiveEditor(); + IEditorPart activeEditor = AbstractUtility.getActiveEditor(); if(activeEditor instanceof IConversationEnabled){ - ConversationHolder conversation = ((IConversationEnabled) StoreUtil.getActiveEditor()).getConversationHolder(); + ConversationHolder conversation = ((IConversationEnabled) AbstractUtility.getActiveEditor()).getConversationHolder(); return conversation; } }else if(getParentElement() instanceof IConversationEnabled){ return ((IConversationEnabled) getParentElement()).getConversationHolder(); } - StoreUtil.errorDialog("Could not get conversation for AbstractFormSection", + AbstractUtility.errorDialog("Could not get conversation for AbstractFormSection", getClass(), "There is an error in the implementation. There should have been an active editor but it wasn't", new IllegalArgumentException()); return null; diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java index 9460de11c..aab69070b 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java @@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.forms.IFormColors; +import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.internal.forms.widgets.FormFonts; @@ -93,7 +94,7 @@ import eu.etaxonomy.cdm.model.reference.Reference; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.cdm.strategy.parser.ParserProblem; -import eu.etaxonomy.taxeditor.store.StoreUtil; +import eu.etaxonomy.taxeditor.model.AbstractUtility; import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement; import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; import eu.etaxonomy.taxeditor.ui.openurl.IOpenUrlEnabled; @@ -102,6 +103,7 @@ import eu.etaxonomy.taxeditor.ui.password.EditPasswordElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement; +import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection; import eu.etaxonomy.taxeditor.ui.section.EmptyElement; import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailElement; import eu.etaxonomy.taxeditor.ui.section.agent.InstitutionDetailSection; @@ -262,2031 +264,1873 @@ import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement; */ public class CdmFormFactory extends FormToolkit { - private BoldFontHolder2 boldFontHolder2; - private MouseListener selectionMouseHandler; - private FocusListener selectionFocusHandler; + private BoldFontHolder2 boldFontHolder2; + private MouseListener selectionMouseHandler; + private FocusListener selectionFocusHandler; - private final Set selectionListenerList = new HashSet(); + private final Set selectionListenerList = new HashSet(); - private final List propertyChangeListeners = new ArrayList(); + private final List propertyChangeListeners = new ArrayList(); - private final int orientation = Window.getDefaultOrientation(); - private ISelectionProvider selectionProvider; + private final int orientation = Window.getDefaultOrientation(); + private ISelectionProvider selectionProvider; - /** Constant EMPTY_SELECTION */ - public static ISelection EMPTY_SELECTION = new ISelection() { - @Override - public boolean isEmpty() { - return true; - } - }; + /** Constant EMPTY_SELECTION */ + public static ISelection EMPTY_SELECTION = new ISelection() { + @Override + public boolean isEmpty() { + return true; + } + }; + + /** + * + * @author n.hoffmann + * @date Jan 25, 2010 + * + */ + private class SelectionMouseHandler extends MouseAdapter { + @Override + public void mouseDown(MouseEvent e) { + notifySelectionListeners(e); + } + } + + /** + * + * @author n.hoffmann + * @date Jan 25, 2010 + * + */ + private class SelectionFocusHandler extends FocusAdapter { + @Override + public void focusGained(FocusEvent e) { + notifySelectionListeners(e); + } + } - /** - * - * @author n.hoffmann - * @date Jan 25, 2010 - * - */ - private class SelectionMouseHandler extends MouseAdapter { - @Override - public void mouseDown(MouseEvent e) { - notifySelectionListeners(e); - } - } - - /** - * - * @author n.hoffmann - * @date Jan 25, 2010 - * - */ - private class SelectionFocusHandler extends FocusAdapter { - @Override - public void focusGained(FocusEvent e) { - notifySelectionListeners(e); - } - } - - private void notifySelectionListeners(TypedEvent e) { - Event event = new Event(); - event.widget = e.widget; - SelectionEvent selectionEvent = new SelectionEvent(event); - - for (Object listener : selectionListenerList) { - ((SelectionListener) listener).widgetSelected(selectionEvent); - } - } - - /** - *

- * Constructor for CdmFormFactory. - *

- * - * @param display - * a {@link org.eclipse.swt.widgets.Display} object. - * @param selectionProvider - * a {@link org.eclipse.jface.viewers.ISelectionProvider} object. - */ - public CdmFormFactory(Display display, ISelectionProvider selectionProvider) { - super(display); - this.selectionProvider = selectionProvider; - init(); - } - - /** - *

- * Constructor for CdmFormFactory. - *

- * - * @param display - * a {@link org.eclipse.swt.widgets.Display} object. - */ - public CdmFormFactory(Display display) { - super(display); - init(); - } + private void notifySelectionListeners(TypedEvent e) { + Event event = new Event(); + event.widget = e.widget; + SelectionEvent selectionEvent = new SelectionEvent(event); - /** - * - */ - private void init() { - boldFontHolder2 = new BoldFontHolder2(); - selectionMouseHandler = new SelectionMouseHandler(); - selectionFocusHandler = new SelectionFocusHandler(); - } - - /** - * Creates an instance initialized with the correct selectionProvider - * - * Make sure to remove the instance when the entityComposite disposes via - * destroySelectionArbitrator(..) - * - * @param entityElement - * a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} - * object. - */ - public SelectionArbitrator createSelectionArbitrator( - IEntityElement entityElement) { - SelectionArbitrator selectionArbitrator = new SelectionArbitrator( - entityElement); - selectionArbitrator.addSelectionProvider(selectionProvider); - selectionProvider.addSelectionChangedListener(selectionArbitrator); - addSelectionListener(selectionArbitrator); - return selectionArbitrator; - } - - /** - *

- * destroySelectionArbitrator - *

- * - * @param selectionArbitrator - * a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} - * object. - */ - public void destroySelectionArbitrator( - SelectionArbitrator selectionArbitrator) { - removeSelectionListener(selectionArbitrator); - if (selectionProvider != null) { - selectionProvider - .removeSelectionChangedListener(selectionArbitrator); - } else { - StoreUtil - .error(this.getClass(), - "Tried to destroy a selection listener from this factories listeners but was null", - null); - } - } - - /** {@inheritDoc} */ - @Override - public void adapt(Composite composite) { - composite.addMouseListener(selectionMouseHandler); - super.adapt(composite); - } - - /** - *

- * Adapts the {@link AbstractCdmFormElement}:
- * - sets the {@link IPropertyChangeListener}s handled by this class - *

- * - * @param formElement - * a - * {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement} - * object. - */ - public void adapt(AbstractCdmFormElement formElement) { - formElement.setPropertyChangeListeners(propertyChangeListeners); - } - - /** {@inheritDoc} */ - @Override - public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) { - if (trackFocus) { - control.addFocusListener(selectionFocusHandler); - } - super.adapt(control, trackFocus, trackKeyboard); - } - - /** - *

- * destroyElement - *

- * - * @param formElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - */ - public void destroyElement(ICdmFormElement formElement) { - // return if element was not initialized - if (formElement == null) { - return; - } - // destroy selection arbitrator, if any - if (formElement instanceof ISelectableElement) { - destroySelectionArbitrator(((ISelectableElement) formElement) - .getSelectionArbitrator()); - } - // remove this element form its parents list of elements - // ICdmFormElement parentElement = formElement.getParentElement(); - // if(parentElement != null){ - // parentElement.removeElement(formElement); - // } - // call destroy on child elements recursively - for (ICdmFormElement childElement : formElement.getElements()) { - destroyElement(childElement); - } - // dispose of the controls - for (Control control : formElement.getControls()) { - // we added the layoutComposite of the parental element as the - // layout composite to this formElement - // but we do not want to destroy it. - if (control.equals(formElement.getLayoutComposite())) { - continue; - } else { - control.dispose(); - control = null; - } - } - } - - /** - *

- * createEmptyCell - *

- * - * @param parent - * a {@link org.eclipse.swt.widgets.Composite} object. - * @return a {@link org.eclipse.swt.widgets.Label} object. - */ - public Label createEmptyCell(Composite parent) { - return this.createLabel(parent, null); - } - - /** - *

- * createMultilineTextWithLabel - *

- * - * @param labelString - * a {@link java.lang.String} object. - * @param textHeight - * a int. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} - * object. - */ - public TextWithLabelElement createMultilineTextWithLabel( - ICdmFormElement parentElement, String labelString, int textHeight, - int style) { - TextWithLabelElement element = new TextWithLabelElement(this, - parentElement, labelString, "", textHeight, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createMultiLanguageTextElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param multilanguageText - * a {@link java.util.Map} object. - * @param textHeight - * a int. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement} - * object. - */ - public MultilanguageTextElement createMultiLanguageTextElement( - ICdmFormElement parentElement, String labelString, - Map multilanguageText, int textHeight, - int style) { - MultilanguageTextElement element = new MultilanguageTextElement(this, - parentElement, labelString, multilanguageText, textHeight, - style); - adapt(element); - parentElement.addElement(element); - return element; - } - - public KeyStatementElement createKeyStatementElement( - ICdmFormElement parentElement, String labelString, - KeyStatement keyStatement, int textHeight, int style) { - KeyStatementElement element = new KeyStatementElement(this, - parentElement, labelString, keyStatement, textHeight, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createTextWithLabelElement - *

- * - * @param labelString - * a {@link java.lang.String} object. - * @param initialText - * a {@link java.lang.String} object. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} - * object. - */ - public TextWithLabelElement createTextWithLabelElement( - ICdmFormElement parentElement, String labelString, - String initialText, int style) { - TextWithLabelElement element = new TextWithLabelElement(this, - parentElement, labelString, initialText, null, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - public UriWithLabelElement createUriWithLabelElement( - ICdmFormElement parentElement, String labelString, URI initialUri, - int style) { - UriWithLabelElement element = new UriWithLabelElement(this, - parentElement, labelString, initialUri, null, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - * @param element - * @param string - * @param uri - * @param style - * @return - */ - public OpenUrlSelectorElement createOpenUrlSelectorElement( - ICdmFormElement parentElement, String labelString, - IOpenUrlEnabled openUrlEnabled, int style) { - OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, - parentElement, labelString, openUrlEnabled, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - * - * @param parentElement - * @param labelString - * @param conversationEnabled - * @param user - * @param style - * @return - */ - public EditPasswordElement createEditPasswordElement( - ICdmFormElement parentElement, String labelString, - ConversationHolder conversation, User user, int style) { - EditPasswordElement element = new EditPasswordElement(this, - parentElement, labelString, user, conversation); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createIntegerTextWithLabelElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param initialInteger - * a {@link java.lang.Integer} object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement} - * object. - */ - public NumberWithLabelElement createIntegerTextWithLabelElement( - ICdmFormElement parentElement, String labelString, - Integer initialInteger, int style) { - NumberWithLabelElement element = new NumberWithLabelElement(this, - parentElement, labelString, initialInteger, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createFloatTextWithLabelElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param initialFloat - * a float. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement} - * object. - */ - public NumberWithLabelElement createFloatTextWithLabelElement( - ICdmFormElement parentElement, String labelString, - float initialFloat, int style) { - NumberWithLabelElement element = new NumberWithLabelElement(this, - parentElement, labelString, initialFloat, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createLanguageStringWithLabelElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param languageString - * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement} - * object. - */ - public LanguageStringWithLabelElement createLanguageStringWithLabelElement( - ICdmFormElement parentElement, String labelString, - LanguageString languageString, int style) { - LanguageStringWithLabelElement element = new LanguageStringWithLabelElement( - this, parentElement, labelString, languageString, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createLanguageStringWithLabelElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param languageString - * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object. - * @param height - * a int. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement} - * object. - */ - public LanguageStringWithLabelElement createLanguageStringWithLabelElement( - ICdmFormElement parentElement, String labelString, - LanguageString languageString, int height, int style) { - LanguageStringWithLabelElement element = new LanguageStringWithLabelElement( - this, parentElement, labelString, languageString, height, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createTextElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param initialText - * a {@link java.lang.String} object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} - * object. - */ - public TextWithLabelElement createTextElement( - ICdmFormElement parentElement, String initialText, int style) { - TextWithLabelElement element = new TextWithLabelElement(this, - parentElement, null, initialText, null, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createKeyValueViewerElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param keyHeading - * a {@link java.lang.String} object. - * @param valueHeading - * a {@link java.lang.String} object. - * @param map - * a {@link java.util.Map} object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement} - * object. - */ - public KeyValueViewerElement createKeyValueViewerElement( - ICdmFormElement parentElement, String keyHeading, - String valueHeading, Map map) { - KeyValueViewerElement element = new KeyValueViewerElement(this, - parentElement, keyHeading, valueHeading, map); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createTermComboElement - *

+ for (Object listener : selectionListenerList) { + ((SelectionListener) listener).widgetSelected(selectionEvent); + } + } + + /** + *

+ * Constructor for CdmFormFactory. + *

+ * + * @param display + * a {@link org.eclipse.swt.widgets.Display} object. + * @param selectionProvider + * a {@link org.eclipse.jface.viewers.ISelectionProvider} object. + */ + public CdmFormFactory(Display display, ISelectionProvider selectionProvider) { + super(display); + this.selectionProvider = selectionProvider; + init(); + } + + /** + *

+ * Constructor for CdmFormFactory. + *

+ * + * @param display + * a {@link org.eclipse.swt.widgets.Display} object. + */ + public CdmFormFactory(Display display) { + super(display); + init(); + } + + /** * - * @param termComboType - * a - * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType} - * object. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param selection - * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase} - * object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement} - * object. */ + private void init() { + boldFontHolder2 = new BoldFontHolder2(); + selectionMouseHandler = new SelectionMouseHandler(); + selectionFocusHandler = new SelectionFocusHandler(); + } + + /** + * Creates an instance initialized with the correct selectionProvider + * + * Make sure to remove the instance when the entityComposite disposes via + * destroySelectionArbitrator(..) + * + * @param entityElement + * a {@link eu.etaxonomy.taxeditor.ui.element.IEntityElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} + * object. + */ + public SelectionArbitrator createSelectionArbitrator(IEntityElement entityElement) { + SelectionArbitrator selectionArbitrator = new SelectionArbitrator(entityElement); + selectionArbitrator.addSelectionProvider(selectionProvider); + selectionProvider.addSelectionChangedListener(selectionArbitrator); + addSelectionListener(selectionArbitrator); + return selectionArbitrator; + } + + /** + *

+ * destroySelectionArbitrator + *

+ * + * @param selectionArbitrator + * a + * {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} + * object. + */ + public void destroySelectionArbitrator(SelectionArbitrator selectionArbitrator) { + removeSelectionListener(selectionArbitrator); + if (selectionProvider != null) { + selectionProvider.removeSelectionChangedListener(selectionArbitrator); + } else { + AbstractUtility.error(this.getClass(), + "Tried to destroy a selection listener from this factories listeners but was null", null); + } + } + + /** {@inheritDoc} */ + @Override + public void adapt(Composite composite) { + composite.addMouseListener(selectionMouseHandler); + super.adapt(composite); + } + + /** + *

+ * Adapts the {@link AbstractCdmFormElement}:
+ * - sets the {@link IPropertyChangeListener}s handled by this class + *

+ * + * @param formElement + * a + * {@link eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement} + * object. + */ + public void adapt(AbstractCdmFormElement formElement) { + formElement.setPropertyChangeListeners(propertyChangeListeners); + } + + /** {@inheritDoc} */ + @Override + public void adapt(Control control, boolean trackFocus, boolean trackKeyboard) { + if (trackFocus) { + control.addFocusListener(selectionFocusHandler); + } + super.adapt(control, trackFocus, trackKeyboard); + } + + /** + *

+ * destroyElement + *

+ * + * @param formElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + */ + public void destroyElement(ICdmFormElement formElement) { + // return if element was not initialized + if (formElement == null) { + return; + } + // destroy selection arbitrator, if any + if (formElement instanceof ISelectableElement) { + destroySelectionArbitrator(((ISelectableElement) formElement).getSelectionArbitrator()); + } + // remove this element form its parents list of elements + // ICdmFormElement parentElement = formElement.getParentElement(); + // if(parentElement != null){ + // parentElement.removeElement(formElement); + // } + // call destroy on child elements recursively + for (ICdmFormElement childElement : formElement.getElements()) { + destroyElement(childElement); + } + // dispose of the controls + for (Control control : formElement.getControls()) { + // we added the layoutComposite of the parental element as the + // layout composite to this formElement + // but we do not want to destroy it. + if (control.equals(formElement.getLayoutComposite())) { + continue; + } else { + control.dispose(); + control = null; + } + } + } + + /** + *

+ * createEmptyCell + *

+ * + * @param parent + * a {@link org.eclipse.swt.widgets.Composite} object. + * @return a {@link org.eclipse.swt.widgets.Label} object. + */ + public Label createEmptyCell(Composite parent) { + return this.createLabel(parent, null); + } + + /** + *

+ * createMultilineTextWithLabel + *

+ * + * @param labelString + * a {@link java.lang.String} object. + * @param textHeight + * a int. + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} + * object. + */ + public TextWithLabelElement createMultilineTextWithLabel(ICdmFormElement parentElement, String labelString, + int textHeight, int style) { + TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, "", textHeight, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createMultiLanguageTextElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param multilanguageText + * a {@link java.util.Map} object. + * @param textHeight + * a int. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.element.MultilanguageTextElement} + * object. + */ + public MultilanguageTextElement createMultiLanguageTextElement(ICdmFormElement parentElement, String labelString, + Map multilanguageText, int textHeight, int style) { + MultilanguageTextElement element = new MultilanguageTextElement(this, parentElement, labelString, + multilanguageText, textHeight, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + public KeyStatementElement createKeyStatementElement(ICdmFormElement parentElement, String labelString, + KeyStatement keyStatement, int textHeight, int style) { + KeyStatementElement element = new KeyStatementElement(this, parentElement, labelString, keyStatement, + textHeight, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createTextWithLabelElement + *

+ * + * @param labelString + * a {@link java.lang.String} object. + * @param initialText + * a {@link java.lang.String} object. + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} + * object. + */ + public TextWithLabelElement createTextWithLabelElement(ICdmFormElement parentElement, String labelString, + String initialText, int style) { + TextWithLabelElement element = new TextWithLabelElement(this, parentElement, labelString, initialText, null, + style); + adapt(element); + parentElement.addElement(element); + return element; + } + + public UriWithLabelElement createUriWithLabelElement(ICdmFormElement parentElement, String labelString, + URI initialUri, int style) { + UriWithLabelElement element = new UriWithLabelElement(this, parentElement, labelString, initialUri, null, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + * @param element + * @param string + * @param uri + * @param style + * @return + */ + public OpenUrlSelectorElement createOpenUrlSelectorElement(ICdmFormElement parentElement, String labelString, + IOpenUrlEnabled openUrlEnabled, int style) { + OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled, + style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + * + * @param parentElement + * @param labelString + * @param conversationEnabled + * @param user + * @param style + * @return + */ + public EditPasswordElement createEditPasswordElement(ICdmFormElement parentElement, String labelString, + ConversationHolder conversation, User user, int style) { + EditPasswordElement element = new EditPasswordElement(this, parentElement, labelString, user, conversation); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createIntegerTextWithLabelElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param initialInteger + * a {@link java.lang.Integer} object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement} + * object. + */ + public NumberWithLabelElement createIntegerTextWithLabelElement(ICdmFormElement parentElement, String labelString, + Integer initialInteger, int style) { + NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialInteger, + style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createFloatTextWithLabelElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param initialFloat + * a float. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement} + * object. + */ + public NumberWithLabelElement createFloatTextWithLabelElement(ICdmFormElement parentElement, String labelString, + float initialFloat, int style) { + NumberWithLabelElement element = new NumberWithLabelElement(this, parentElement, labelString, initialFloat, + style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createLanguageStringWithLabelElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param languageString + * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement} + * object. + */ + public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement, + String labelString, LanguageString languageString, int style) { + LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString, + languageString, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createLanguageStringWithLabelElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param languageString + * a {@link eu.etaxonomy.cdm.model.common.LanguageString} object. + * @param height + * a int. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement} + * object. + */ + public LanguageStringWithLabelElement createLanguageStringWithLabelElement(ICdmFormElement parentElement, + String labelString, LanguageString languageString, int height, int style) { + LanguageStringWithLabelElement element = new LanguageStringWithLabelElement(this, parentElement, labelString, + languageString, height, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createTextElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param initialText + * a {@link java.lang.String} object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement} + * object. + */ + public TextWithLabelElement createTextElement(ICdmFormElement parentElement, String initialText, int style) { + TextWithLabelElement element = new TextWithLabelElement(this, parentElement, null, initialText, null, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createKeyValueViewerElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param keyHeading + * a {@link java.lang.String} object. + * @param valueHeading + * a {@link java.lang.String} object. + * @param map + * a {@link java.util.Map} object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.KeyValueViewerElement} + * object. + */ + public KeyValueViewerElement createKeyValueViewerElement(ICdmFormElement parentElement, String keyHeading, + String valueHeading, Map map) { + KeyValueViewerElement element = new KeyValueViewerElement(this, parentElement, keyHeading, valueHeading, map); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createTermComboElement + *

+ * + * @param termComboType + * a + * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.TermComboType} + * object. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param selection + * a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase} + * object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement} + * object. + */ + + public TermComboElement createTermComboElement(Class termComboType, + ICdmFormElement parentElement, String labelString, T selection, int style) { + TermComboElement element = new TermComboElement(this, parentElement, termComboType, labelString, + selection, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createEnumComboElement + *

+ * + * @param enumComboType + * a + * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType} + * object. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement} + * object. + */ + public EnumComboElement createEnumComboElement(Class enumComboType, + ICdmFormElement parentElement, int style) { + EnumComboElement element = new EnumComboElement(this, parentElement, enumComboType, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createBrowserElement + *

+ * + * @param imageUri + * a {@link java.net.URI} object. + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement} + * object. + */ + public BrowserElement createBrowserElement(ICdmFormElement parentElement, URI imageUri, int style) { + BrowserElement element = new BrowserElement(this, parentElement, imageUri, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createImageElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param imageUri + * a {@link java.net.URI} object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object. + */ + public ImageElement createImageElement(ICdmFormElement parentElement, URI imageUri, int style) { + ImageElement element = new ImageElement(this, parentElement, imageUri, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createTextActionElement + *

+ * + * @param labelString + * a {@link java.lang.String} object. + * @param initialText + * a {@link java.lang.String} object. + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param buttonLabel + * a {@link java.lang.String} object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement} + * object. + */ + public TextActionElement createTextActionElement(ICdmFormElement parentElement, String labelString, + String buttonLabel, String initialText, int style) { + TextActionElement element = new TextActionElement(this, parentElement, labelString, buttonLabel, initialText, + style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createCheckbox + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param label + * a {@link java.lang.String} object. + * @param initialState + * a boolean. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement} + * object. + */ + public CheckboxElement createCheckbox(ICdmFormElement parentElement, String label, boolean initialState, int style) { + CheckboxElement element = new CheckboxElement(this, parentElement, label, initialState, style | orientation); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + * Creates a section as a part of the form. + * + * @return the section widget + * @param section + * a + * {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} + * object. + */ + public Section adapt(AbstractFormSection section) { + section.setMenu(section.getLayoutComposite().getMenu()); + adapt(section, true, true); + + // handle focus and property change events for cdm use + section.addFocusListener(selectionFocusHandler); + section.setPropertyChangeListeners(propertyChangeListeners); + + if (section.getToggle() != null) { + section.getToggle().setHoverDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE_HOVER)); + section.getToggle().setDecorationColor(getColors().getColor(IFormColors.TB_TOGGLE)); + } - public TermComboElement createTermComboElement( - Class termComboType, ICdmFormElement parentElement, - String labelString, T selection, int style) { - TermComboElement element = new TermComboElement(this, parentElement, termComboType, labelString, selection, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createEnumComboElement - *

- * - * @param enumComboType - * a - * {@link eu.eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EnumComboType} - * object. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.term.AbstractEnumComboElement} - * object. - */ - public EnumComboElement createEnumComboElement( - Class enumComboType, ICdmFormElement parentElement, - int style) { - EnumComboElement element = new EnumComboElement(this, parentElement, enumComboType, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createBrowserElement - *

- * - * @param imageUri - * a {@link java.net.URI} object. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.BrowserElement} object. - */ - public BrowserElement createBrowserElement(ICdmFormElement parentElement, - URI imageUri, int style) { - BrowserElement element = new BrowserElement(this, parentElement, - imageUri, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createImageElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param imageUri - * a {@link java.net.URI} object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.ImageElement} object. - */ - public ImageElement createImageElement(ICdmFormElement parentElement, - URI imageUri, int style) { - ImageElement element = new ImageElement(this, parentElement, imageUri, - style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createTextActionElement - *

- * - * @param labelString - * a {@link java.lang.String} object. - * @param initialText - * a {@link java.lang.String} object. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param buttonLabel - * a {@link java.lang.String} object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextActionElement} - * object. - */ - public TextActionElement createTextActionElement( - ICdmFormElement parentElement, String labelString, - String buttonLabel, String initialText, int style) { - TextActionElement element = new TextActionElement(this, parentElement, - labelString, buttonLabel, initialText, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createCheckbox - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param label - * a {@link java.lang.String} object. - * @param initialState - * a boolean. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.CheckboxElement} object. - */ - public CheckboxElement createCheckbox(ICdmFormElement parentElement, - String label, boolean initialState, int style) { - CheckboxElement element = new CheckboxElement(this, parentElement, - label, initialState, style | orientation); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - * Creates a section as a part of the form. - * - * @return the section widget - * @param section - * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} - * object. - */ - public Section adapt(AbstractFormSection section) { - section.setMenu(section.getLayoutComposite().getMenu()); - adapt(section, true, true); - - // handle focus and property change events for cdm use - section.addFocusListener(selectionFocusHandler); - section.setPropertyChangeListeners(propertyChangeListeners); - - if (section.getToggle() != null) { - section.getToggle().setHoverDecorationColor( - getColors().getColor(IFormColors.TB_TOGGLE_HOVER)); - section.getToggle().setDecorationColor( - getColors().getColor(IFormColors.TB_TOGGLE)); - } - - section.setFont(boldFontHolder2.getBoldFont(section - .getLayoutComposite().getFont())); - - if ((section.getStyle() & Section.TITLE_BAR) != 0 - || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) { - getColors().initializeSectionToolBarColors(); - section.setTitleBarBackground(getColors().getColor( - IFormColors.TB_BG)); - section.setTitleBarBorderColor(getColors().getColor( - IFormColors.TB_BORDER)); - } - // call setTitleBarForeground regardless as it also sets the label color - section.setTitleBarForeground(getColors().getColor( - IFormColors.TB_TOGGLE)); - return section; - } - - private class BoldFontHolder2 { - private Font normalFont; - - private Font boldFont; - - public BoldFontHolder2() { - } - - public Font getBoldFont(Font font) { - createBoldFont(font); - return boldFont; - } - - private void createBoldFont(Font font) { - if (normalFont == null || !normalFont.equals(font)) { - normalFont = font; - dispose(); - } - if (boldFont == null) { - boldFont = FormFonts.getInstance().getBoldFont( - getColors().getDisplay(), normalFont); - } - } - - public void dispose() { - if (boldFont != null) { - FormFonts.getInstance().markFinished(boldFont, - getColors().getDisplay()); - boldFont = null; - } - } - } - - /** - *

- * createToggleableTextField - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param initialText - * a {@link java.lang.String} object. - * @param initialState - * a boolean. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement} - * object. - */ - public ToggleableTextElement createToggleableTextField( - ICdmFormElement parentElement, String labelString, - String initialText, boolean initialState, int style) { - ToggleableTextElement element = new ToggleableTextElement(this, - parentElement, labelString, initialText, initialState, style - | orientation); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createTimePeriodElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param timePeriod - * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement} - * object. - */ - public TimePeriodElement createTimePeriodElement( - ICdmFormElement parentElement, String labelString, - TimePeriod timePeriod, int style) { - TimePeriodElement element = new TimePeriodElement(this, parentElement, - labelString, timePeriod, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createPointElement - *

- * - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param point - * a {@link eu.etaxonomy.cdm.model.location.Point} object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object. - */ - public PointElement createPointElement(ICdmFormElement parentElement, - Point point, int style) { - PointElement element = new PointElement(this, parentElement, point, - style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createDateDetailSection - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection} - * object. - */ - public DateDetailSection createDateDetailSection( - ICdmFormElement parentElement, int style) { - DateDetailSection section = new DateDetailSection(this, parentElement, - style); - parentElement.addElement(section); - adapt(section); - return section; - } - - /** - *

- * createPartialElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param labelString - * a {@link java.lang.String} object. - * @param partial - * a {@link org.joda.time.Partial} object. - * @param style - * a int. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement} object. - */ - public PartialElement createPartialElement(ICdmFormElement parentElement, - String labelString, Partial partial, int style) { - PartialElement element = new PartialElement(this, parentElement, - labelString, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * addSelectionListener - *

- * - * @param listener - * a {@link org.eclipse.swt.events.SelectionListener} object. - */ - public void addSelectionListener(SelectionListener listener) { - selectionListenerList.add(listener); - } - - /** - *

- * removeSelectionListener - *

- * - * @param listener - * a {@link org.eclipse.swt.events.SelectionListener} object. - */ - public void removeSelectionListener(SelectionListener listener) { - if (listener == null) { - StoreUtil - .error(this.getClass(), - "Tried to remove a selection listener from this factories listeners but was null", - null); - } else { - selectionListenerList.remove(listener); - } - } - - /** - *

- * addPropertyChangeListener - *

- * - * @param listener - * a {@link org.eclipse.jface.util.IPropertyChangeListener} - * object. - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if(propertyChangeListeners.contains(listener)){ - return; - } - propertyChangeListeners.add(0, listener); - } - - /** - *

- * removePropertyChangeListener - *

- * - * @param listener - * a {@link org.eclipse.jface.util.IPropertyChangeListener} - * object. - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - propertyChangeListeners.remove(listener); - } - - /** - *

- * createHorizontalSeparator - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param style - * a int. - * @return a {@link org.eclipse.swt.widgets.Label} object. - */ - public Label createHorizontalSeparator(ICdmFormElement parentElement, - int style) { - Label separator = this.createSeparator( - parentElement.getLayoutComposite(), SWT.HORIZONTAL | style); - separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); - return separator; - } - - /** - *

- * createVersionElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param entity - * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity} - * object. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement} - * object. - */ - public VersionElement createVersionElement(ICdmFormElement parentElement, - VersionableEntity entity, int style) { - VersionElement element = new VersionElement(this, parentElement, - entity, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - * @param cdmBaseSection - * @param object - * @param style - * @return - */ - public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, - CdmBase entity, int style) { - CdmBaseElement element = new CdmBaseElement(this, parentElement, - entity, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - - /** - *

- * createVersionSection - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection} - * object. - */ - public VersionSection createVersionSection(ICdmFormElement parentElement, - int style) { - VersionSection section = new VersionSection(this, parentElement, style); - parentElement.addElement(section); - adapt(section); - return section; - } - - /** - * @param parent - * @param i - * @return - */ - public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) { - CdmBaseSection section = new CdmBaseSection(this, parentElement, style); - parentElement.addElement(section); - adapt(section); - return section; - } - - /** - *

- * createEmptyElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object. - */ - public EmptyElement createEmptyElement(ICdmFormElement parentElement) { - EmptyElement element = new EmptyElement(this, parentElement, null, - SWT.NULL); - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createHeadlineSection - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection} - * object. - */ - public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) { - HeadlineSection section = new HeadlineSection(this, parentElement, - SWT.NULL); - parentElement.addElement(section); - adapt(section); - return section; - } - - /** - *

- * createParsingMessageElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param parserProblem - * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem} - * object. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement} - * object. - */ - public ParsingMessageElement createParsingMessageElement( - ICdmFormElement parentElement, ParserProblem parserProblem, - int style) { - ParsingMessageElement element = new ParsingMessageElement(this, - parentElement, parserProblem, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - // SIMPLIFY - - /** - * - */ - public static enum DetailType { - AUTHORSHIP, - CLASSIFICATION, - COLLECTION, - DERIVED_UNIT, - DERIVED_UNIT_FACADE, - DERIVED_UNIT_GENERAL, - DESCRIPTION, - DESCRIPTIONELEMENT, - DETERMINATION, - FEATURE_DISTRIBUTION, - FIELD_OBSERVATION, - GATHERING_EVENT, - GRANTEDAUTHORITY, - GROUP, - HYBRID, - INSTITUTION, - MEDIA, - NAMED_AREA, - NAMED_AREA_LEVEL, - NAMERELATIONSHIP, - NATURAL_LANGUAGE, - NOMENCLATURALREFERENCE, - NONVIRALNAME, - PARSINGMESSAGE, - PERSON, - POLYTOMOUS_KEY, - POLYTOMOUS_KEY_NODE, - REFERENCEBASE, - REFERENCED_ENTITY, - SCIENTIFICNAME, - TAXON_NODE, - TAXON_RELATIONSHIP, - TAXONBASE, - TEAM, - TEAMORPERSONBASE, - TERM_VOCABULARY, - USE_RECORD, - USER - } - - public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, - ConversationHolder conversation, ICdmFormElement parentElement, - ISelectionProvider selectionProvider, int style) { - - AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement, selectionProvider, style); - - parentElement.addElement(section); - adapt(section); - return section; - - } - - /** - * @param definedTermClass - * @param formElement - * @param style - * @return - */ - public AbstractCdmDetailElement createDefinedTermDetailElement( - Class definedTermClass, AbstractCdmDetailSection parentElement, - int style) { - AbstractCdmDetailElement element = null; - - if (NamedArea.class.isAssignableFrom(definedTermClass)){ - element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement); - } - else { - element = new DefinedTermDetailElement(this, parentElement); - } - - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * createCdmDetailSection - *

- * - * @param detailType - * a - * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType} - * object. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param selectionProvider - * a {@link org.eclipse.jface.viewers.ISelectionProvider} object. - * @param style - * a int. - * @param conversation - * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} - * object. - */ - public AbstractFormSection createCdmDetailSection(DetailType detailType, - ConversationHolder conversation, ICdmFormElement parentElement, - ISelectionProvider selectionProvider, int style) { - AbstractFormSection section = null; - - switch (detailType) { - case SCIENTIFICNAME: - section = new NameDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case REFERENCEBASE: - section = new ReferenceDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case NOMENCLATURALREFERENCE: - section = new NomenclaturalReferenceDetailSection(this, - conversation, parentElement, selectionProvider, style); - break; - case TAXONBASE: - section = new TaxonBaseDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case AUTHORSHIP: - section = new AuthorshipDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case TEAMORPERSONBASE: - section = new TeamOrPersonBaseDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case TEAM: - section = new TeamDetailSection(this, conversation, parentElement, - null, style); - break; - case PERSON: - section = new PersonDetailSection(this, conversation, - parentElement, null, style); - break; - case DESCRIPTION: - section = new DescriptionDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case DESCRIPTIONELEMENT: - section = new DescriptionElementDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case PARSINGMESSAGE: - section = new ParsingMessagesSection(this, conversation, - parentElement, selectionProvider, style); - break; - case NONVIRALNAME: - section = new NonViralNameDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case MEDIA: - section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection( - this, conversation, parentElement, selectionProvider, style); - break; - case DERIVED_UNIT_FACADE: - section = new DerivedUnitFacadeDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case FIELD_OBSERVATION: - section = new FieldObservationDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case GATHERING_EVENT: - section = new GatheringEventDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case DERIVED_UNIT: - section = new DerivedUnitBaseDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case NATURAL_LANGUAGE: - section = new NaturalLanguageSection(this, conversation, - parentElement, selectionProvider, style); - break; - case FEATURE_DISTRIBUTION: - section = new FeatureDistributionDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case CLASSIFICATION: - section = new ClassificationDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case TAXON_NODE: - section = new TaxonNodeDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case POLYTOMOUS_KEY: - section = new PolytomousKeyDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case POLYTOMOUS_KEY_NODE: - section = new PolytomousKeyNodeDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case INSTITUTION: - section = new InstitutionDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case DERIVED_UNIT_GENERAL: - section = new GeneralDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case HYBRID: - section = new HybridDetailSection(this, conversation, - parentElement, selectionProvider, style); - break; - case USER: - section = new UserDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case GROUP: - section = new GroupDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case DETERMINATION: - section = new DeterminationDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case TAXON_RELATIONSHIP: - section = new TaxonRelationshipDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case REFERENCED_ENTITY: - section = new ReferencedEntityDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case TERM_VOCABULARY: - section = new TermVocabularyDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case NAMED_AREA: - section = new NamedAreaDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - case USE_RECORD: - section = new UseRecordDetailSection(this, conversation, parentElement, - selectionProvider, style); - break; - } - - - if (section == null) { - throw new RuntimeException( - "You tried to create a cdm detail section that is not implemented yet."); - } - - parentElement.addElement(section); - adapt(section); - return section; - } - - - - /** - *

- * createCdmDetailElement - *

- * - * @param detailType - * a - * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType} - * object. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} - * object. - */ - public AbstractCdmDetailElement createCdmDetailElement( - DetailType detailType, ICdmFormElement parentElement, int style) { - AbstractCdmDetailElement element = null; - - switch (detailType) { - case SCIENTIFICNAME: - element = new NameDetailElement(this, parentElement, style); - break; - case REFERENCEBASE: - element = new ReferenceDetailElement(this, parentElement, style); - break; - case NOMENCLATURALREFERENCE: - element = new NomenclaturalReferenceDetailElement(this, - parentElement, style); - break; - case TAXONBASE: - element = new TaxonBaseDetailElement(this, parentElement, style); - break; - case AUTHORSHIP: - element = new AuthorshipDetailElement(this, parentElement, style); - break; - case TEAM: - element = new TeamDetailElement(this, parentElement, style); - break; - case PERSON: - element = new PersonDetailElement(this, parentElement, style); - break; - case DESCRIPTION: - element = new DescriptionDetailElement(this, parentElement, style); - break; - case DESCRIPTIONELEMENT: - element = new DescriptionElementDetailElement(this, parentElement, - style); - break; - case NONVIRALNAME: - element = new NonViralNameDetailElement(this, parentElement); - break; - case DERIVED_UNIT_FACADE: - element = new DerivedUnitFacadeDetailElement(this, parentElement); - break; - case FIELD_OBSERVATION: - element = new FieldObservationDetailElement(this, parentElement); - break; - case GATHERING_EVENT: - element = new GatheringEventDetailElement(this, parentElement); - break; - case DERIVED_UNIT: - element = new DerivedUnitBaseDetailElement(this, parentElement); - break; - case NATURAL_LANGUAGE: - element = new NaturalLanguageDetailElement(this, parentElement); - break; - case FEATURE_DISTRIBUTION: - element = new FeatureDistributionDetailElement(this, parentElement); - break; - case CLASSIFICATION: - element = new ClassificationDetailElement(this, parentElement); - break; - case TAXON_NODE: - element = new TaxonNodeDetailElement(this, parentElement); - break; - case COLLECTION: - element = new CollectionDetailElement(this, parentElement); - break; - case POLYTOMOUS_KEY: - element = new PolytomousKeyDetailElement(this, parentElement); - break; - case POLYTOMOUS_KEY_NODE: - element = new PolytomousKeyNodeDetailElement(this, parentElement); - break; - case INSTITUTION: - element = new InstitutionDetailElement(this, parentElement); - break; - case DERIVED_UNIT_GENERAL: - element = new GeneralDetailElement(this, parentElement); - break; - case HYBRID: - element = new HybridDetailElement(this, parentElement); - break; - case USER: - element = new UserDetailElement(this, parentElement); - break; - case GROUP: - element = new GroupDetailElement(this, parentElement); - break; - case GRANTEDAUTHORITY: - element = new GrantedAuthorityDetailElement(this, parentElement); - break; - case DETERMINATION: - element = new DeterminationDetailElement(this, parentElement); - break; - case TAXON_RELATIONSHIP: - element = new TaxonRelationshipDetailElement(this, parentElement); - break; - case REFERENCED_ENTITY: - element = new RefereneEntityDetailElement(this, parentElement); - break; - case TERM_VOCABULARY: - element = new TermVocabularyDetailElement(this, parentElement); - break; - case NAMED_AREA: - element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement); - break; - case NAMED_AREA_LEVEL: - element = new DefinedTermDetailElement(this, parentElement); - break; - case USE_RECORD: - //element = new UseRecordDetailElement(this, parentElement, style); - element = new UseRecordDetailElement(this, parentElement); - break; - } - - if (element == null) { - StoreUtil - .error(this.getClass(), - "Detail element was not created. Seems like the case was not implemented for the requested detail type: " - + detailType, null); - } - - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - * - * @author n.hoffmann - * @created Mar 5, 2010 - * @version 1.0 - */ - public static enum EntityDetailType { - TEAM, - TEAMMEMBER, - ANNOTATION, - CREDIT, - DESCRIPTIONELEMENTSOURCE, - EXTENSION, - MARKER, - MEDIA, - DESCRIPTIONELEMENTMEDIA, - MEDIAREPRESENTATION, - MEDIAREPRESENTATIONPART, - MODIFIER, - NOMENCLATURALSTATUS, - NAME_RELATIONSHIP, - PROTOLOG, - RIGHTS, - SOURCE, - SCOPE, - DESCRIPTIONSOURCE, - TYPEDESIGNATION, - STATE_DATA, - STATISTICAL_MEASUREMENT_VALUE, - DESCRIBED_SPECIMEN, - COLLECTING_AREA, - DETERMINATION_EVENT, - SPECIMEN_COLLECTION, - IDENTIFIABLE_SOURCE_COLLECTION, - GEOGRAPHICAL_SCOPE, - SCOPE_RESTRICTION, - MEMBER, - GRANTED_AUTHORITY, - GROUPS_BY_USER, - TAXONOMIC_SCOPE, - DETERMINATION_CURRENT, - DETERMINATION_HISTORY - } - - /** - *

- * createEntityDetailSection - *

- * - * @param entityDetailType - * a - * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType} - * object. - * @param style - * a int. - * @param conversation - * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} - * object. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} - * object. - */ - public AbstractFormSection createEntityDetailSection(EntityDetailType entityDetailType, ConversationHolder conversation, ICdmFormElement parentElement, int style) { - AbstractFormSection section = null; - - switch (entityDetailType) { - case TEAM: - //TODO this is not an AbstractEntityCollectionSection - section = new TeamDetailSection(this, conversation, parentElement, - null, style); - break; - case TEAMMEMBER: - section = new TeamMemberSection(this, conversation, parentElement, - style); - break; - case ANNOTATION: - section = new AnnotationSection(this, conversation, parentElement, - style); - break; - case CREDIT: - section = new CreditSection(this, conversation, parentElement, - style); - break; - case DESCRIPTIONELEMENTSOURCE: - section = new DescriptionElementSourceSection(this, conversation, - parentElement, style); - break; - case EXTENSION: - section = new ExtensionSection(this, conversation, parentElement, - style); - break; - case MARKER: - section = new MarkerSection(this, conversation, parentElement, - style); - break; - case MEDIA: - section = new MediaSection(this, conversation, parentElement, style); - break; - case DESCRIPTIONELEMENTMEDIA: - section = new DescriptionElementMediaSection(this, conversation, - parentElement, style); - break; - case MEDIAREPRESENTATION: - section = new MediaRepresentationSection(this, conversation, - parentElement, style); - break; - case MEDIAREPRESENTATIONPART: - section = new MediaRepresentationPartSection(this, conversation, - parentElement, style); - break; - case MODIFIER: - section = new ModifierSection(this, conversation, parentElement, - style); - break; - case NOMENCLATURALSTATUS: - section = new NomenclaturalStatusSection(this, conversation, - parentElement, style); - break; - case NAME_RELATIONSHIP: - section = new NameRelationshipDetailSection(this, conversation, - parentElement, style); - break; - case PROTOLOG: - section = new ProtologueSection(this, conversation, parentElement, - style); - break; - case RIGHTS: - section = new RightsSection(this, conversation, parentElement, - style); - break; - case SOURCE: - section = new SourceSection(this, conversation, parentElement, - style); - break; - case SCOPE: - section = new ScopeSection(this, conversation, parentElement, style); - break; - case DESCRIPTIONSOURCE: - section = new DescriptionSourceSection(this, conversation, - parentElement, style); - break; - case TYPEDESIGNATION: - section = new TypeDesignationSection(this, conversation, - parentElement, style); - break; - case STATE_DATA: - section = new StateDataSection(this, conversation, parentElement, - style); - break; - case STATISTICAL_MEASUREMENT_VALUE: - section = new StatisticalMeasurementValueSection(this, - conversation, parentElement, style); - break; - case DESCRIBED_SPECIMEN: - section = new DescribedSpecimenSection(this, conversation, - parentElement, style); - break; - case COLLECTING_AREA: - section = new CollectingAreasDetailSection(this, conversation, - parentElement, style); - break; - case DETERMINATION_CURRENT: - section = new CurrentDeterminationDetailSection(this, conversation, - parentElement, style); - break; - case DETERMINATION_HISTORY: - section = new DeterminationHistoryDetailSection(this, conversation, - parentElement, style); - break; - case SPECIMEN_COLLECTION: - section = new SpecimenCollectionDetailSection(this, conversation, - parentElement, style); - break; - case IDENTIFIABLE_SOURCE_COLLECTION: - section = new SourceCollectionDetailSection(this, conversation, - parentElement, style); - break; - case GEOGRAPHICAL_SCOPE: - section = new GeographicalScopeDetailSection(this, conversation, - parentElement, style); - break; - case SCOPE_RESTRICTION: - section = new ScopeRestrictionSection(this, conversation, - parentElement, style); - break; - case MEMBER: - section = new MemberDetailSection(this, conversation, - parentElement, style); - break; - case GRANTED_AUTHORITY: - section = new GrantedAuthorityDetailSection(this, conversation, - parentElement, style); - break; - case GROUPS_BY_USER: - section = new GroupsByUserDetailSection(this, conversation, - parentElement, style); - break; - case TAXONOMIC_SCOPE: - section = new TaxonomicScopeSection(this, conversation, - parentElement, style); - break; - } - parentElement.addElement(section); - adapt(section); - return section; - } - - /** - *

- * createEntityCollectionElement - *

- * - * @param removeListener - * a {@link org.eclipse.swt.events.SelectionListener} object. - * @param style - * a int. - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} - * object. - * @param versionableEntity - * a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity} - * object. - * @param backgroundColor - * a {@link org.eclipse.swt.graphics.Color} object. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement} - * object. - */ - public AbstractEntityCollectionElement createEntityCollectionElement( - AbstractFormSection parentElement, Object versionableEntity, - SelectionListener removeListener, Color backgroundColor, int style) { - AbstractEntityCollectionElement element = null; - - Object entity = HibernateProxyHelper.deproxy(versionableEntity); - - if (entity instanceof Annotation) { - element = new AnnotationElement(this, parentElement, - (Annotation) entity, removeListener, style); - } else if (entity instanceof Person) { - element = new TeamMemberElement(this, parentElement, - (Person) entity, removeListener, style); - } else if (entity instanceof Credit) { - element = new CreditElement(this, parentElement, (Credit) entity, - removeListener, style); - } else if (entity instanceof Extension) { - element = new ExtensionElement(this, parentElement, - (Extension) entity, removeListener, style); - } else if (entity instanceof Marker) { - element = new MarkerElement(this, parentElement, (Marker) entity, - removeListener, style); - } else if (entity instanceof Media) { - element = new MediaElement(this, parentElement, (Media) entity, - removeListener, style); - } else if (entity instanceof MediaRepresentation) { - element = new MediaRepresentationElement(this, parentElement, - (MediaRepresentation) entity, removeListener, style); - } else if (entity instanceof ImageFile) { - element = new ImageFileElement(this, parentElement, - (ImageFile) entity, removeListener, style); - } else if (entity instanceof MediaRepresentationPart){ - element = new MediaRepresentationPartElement(this, parentElement, - (MediaRepresentationPart) entity, removeListener, style); - } else if (entity instanceof NomenclaturalStatus) { - element = new NomenclaturalStatusElement(this, parentElement, - (NomenclaturalStatus) entity, removeListener, style); - } else if (entity instanceof Rights) { - element = new RightsElement(this, parentElement, (Rights) entity, - removeListener, style); - } else if (entity instanceof DescriptionElementSource) { - element = new DescriptionElementSourceElement(this, parentElement, - (DescriptionElementSource) entity, removeListener, style); - } else if (entity instanceof IdentifiableSource) { - element = new IdentifiableSourceElement(this, parentElement, - (IdentifiableSource) entity, removeListener, style); - } else if (entity instanceof Scope) { - element = new ScopeElement(this, parentElement, (Scope) entity, - removeListener, style); - } else if (entity instanceof Modifier) { - element = new ModifierElement(this, parentElement, - (Modifier) entity, removeListener, style); - } else if (entity instanceof Reference) { - element = new DescriptionSourceElement(this, parentElement, - (Reference) entity, removeListener, style); - } else if (entity instanceof NameTypeDesignation) { - element = new NameTypeDesignationElement(this, parentElement, - (NameTypeDesignation) entity, removeListener, style); - } else if (entity instanceof NameRelationship) { - element = new NameRelationshipDetailElement(this, parentElement, - (NameRelationship) entity, removeListener, style); - } else if (entity instanceof SpecimenTypeDesignation) { - element = new SpecimenTypeDesignationElement(this, parentElement, - (SpecimenTypeDesignation) entity, removeListener, style); - } else if (entity instanceof StateData) { - element = new StateDataElement(this, parentElement, - (StateData) entity, removeListener, style); - } else if (entity instanceof StatisticalMeasurementValue) { - element = new StatisticalMeasurementValueElement(this, - parentElement, (StatisticalMeasurementValue) entity, - removeListener, style); - } else if (entity instanceof DerivedUnit) { - element = new DerivedUnitElement(this, parentElement, - (DerivedUnit) entity, removeListener, style); - } else if (entity instanceof NamedArea) { - element = new NamedAreaDetailElement(this, parentElement, - (NamedArea) entity, removeListener, style); - } else if (entity instanceof DeterminationEvent) { - element = new DeterminationEventDetailElement(this, parentElement, - (DeterminationEvent) entity, removeListener, style); - } else if (entity instanceof Specimen) { - element = new SpecimenCollectionDetailElement(this, parentElement, - (Specimen) entity, removeListener, style); - } else if (entity instanceof User) { - element = new MemberDetailElement(this, parentElement, - (User) entity, removeListener, style); - } else if (entity instanceof GrantedAuthority) { - element = new GrantedAuthorityCollectionElement(this, parentElement, - (GrantedAuthorityImpl) entity, removeListener, style); - } else if (entity instanceof Group) { - element = new GroupsByUserDetailElement(this, parentElement, - (Group) entity, removeListener, style); - } else if (entity instanceof Taxon) { - element = new TaxonDetailElement(this, parentElement, - (Taxon) entity, removeListener, style); - } else if (entity instanceof DescriptionElementBase) { - // this is the special case for protologs, maybe we can do this - // differently when API improves - DescriptionElementBase descriptionElement = (DescriptionElementBase) entity; - if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) { - element = new ProtologueElement(this, parentElement, - descriptionElement, removeListener, style); - } - } - - if (element == null) { - StoreUtil - .errorDialog( - "No element for entity", - this, - "Could not generate element for entity. " - + "Looks like the case is not handled already. Check implementation. Entity: " - + entity, null); - - } - - if (backgroundColor != null && !backgroundColor.isDisposed()) { - element.setPersistentBackground(backgroundColor); - } - - adapt(element); - parentElement.addElement(element); - return element; - } - - /** - *

- * Creates a selection element for the given type T. - *

- *

- * Selection elements not handled by this method: - *

    - *
  • {@link TaxonNodeSelectionElement} see {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
  • - *
  • {@link NomenclaturalAuthorTeamSelectionElement} see {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
  • - *
- *

- * - * @param clazz - * a {@link Class} object of the type that you want the selection element to handle - * @param parentElement - * a {@link ICdmFormElement} - * object. - * @param labelString - * a {@link String} object. - * @param selectionType - * @param selection - * a {@link ICdmBase} object. - * @param style - * a int. - * @param conversation - * a {@link ConversationHolder} object. - * @return a - * {@link EntitySelectionElement} - * object. - */ - public EntitySelectionElement createSelectionElement( - Class clazz, ConversationHolder conversation, - ICdmFormElement parentElement, String labelString, - T selection, int mode, int style) { - EntitySelectionElement element = new EntitySelectionElement(this, conversation, parentElement, clazz, labelString, selection, mode, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - public TaxonNodeSelectionElement createTaxonNodeSelectionElement( - ConversationHolder conversation, - ICdmFormElement parentElement, String labelString, - TaxonNode selection, int mode, int style) { - TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement, labelString, selection, mode, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement( - ConversationHolder conversation, - ICdmFormElement parentElement, String labelString, - Team selection, int mode, int style) { - NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this, conversation, parentElement, labelString, selection, mode, style); - adapt(element); - parentElement.addElement(element); - return element; - } - - - /** {@inheritDoc} */ - public LabelElement createLabel(ICdmFormElement parentElement, String text) { - LabelElement labelElement = new LabelElement(this, parentElement, text); - adapt(labelElement); - parentElement.addElement(labelElement); - return labelElement; - } - - /** - *

- * Getter for the field selectionProvider. - *

- * - * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object. - */ - public ISelectionProvider getSelectionProvider() { - return selectionProvider; - } - - /** - *

- * createDetailedDescriptionDetailElement - *

- * - * @param parentElement - * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} - * object. - * @param entity - * a - * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} - * object. - * @param style - * a int. - * @return a - * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement} - * object. - */ - public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement( - ICdmFormElement parentElement, DescriptionElementBase entity, - int style) { - AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null; - - if (entity instanceof CategoricalData) { - detailedDescriptionElement = new CategoricalDataDetailElement(this, - parentElement, (CategoricalData) entity, style); - } else if (entity instanceof CommonTaxonName) { - detailedDescriptionElement = new CommonNameDetailElement(this, - parentElement, (CommonTaxonName) entity, style); - } else if (entity instanceof Distribution) { - detailedDescriptionElement = new DistributionDetailElement(this, - parentElement, (Distribution) entity, style); - } else if (entity instanceof IndividualsAssociation) { - detailedDescriptionElement = new IndividualsAssociationDetailElement( - this, parentElement, (IndividualsAssociation) entity, style); - } else if (entity instanceof QuantitativeData) { - detailedDescriptionElement = new QuantitativeDataDetailElement( - this, parentElement, (QuantitativeData) entity, style); - } else if (entity instanceof TaxonInteraction) { - detailedDescriptionElement = new TaxonInteractionDetailElement( - this, parentElement, (TaxonInteraction) entity, style); - } else if (entity instanceof TextData) { - detailedDescriptionElement = new TextDataDetailElement(this, - parentElement, (TextData) entity, style); - } else { - throw new IllegalStateException( - "There is no interface for the given description element"); - } - adapt(detailedDescriptionElement); - parentElement.addElement(detailedDescriptionElement); - return detailedDescriptionElement; - - } - - /** - * Creates a styled text as a part of the form. - * - * @param parent - * the text parent - * @param value - * the text initial value - * @param style - * the text style - * @return the text widget - */ - public StyledText createStyledText(Composite parent, String value, int style) { - StyledText text = new StyledText(parent, getBorderStyle() | style - | getOrientation()); - if (value != null) { - text.setText(value); + section.setFont(boldFontHolder2.getBoldFont(section.getLayoutComposite().getFont())); + + if ((section.getStyle() & ExpandableComposite.TITLE_BAR) != 0 + || (section.getStyle() & ExpandableComposite.SHORT_TITLE_BAR) != 0) { + getColors().initializeSectionToolBarColors(); + section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG)); + section.setTitleBarBorderColor(getColors().getColor(IFormColors.TB_BORDER)); } - text.setForeground(getColors().getForeground()); - text.setBackground(getColors().getBackground()); - // text.addFocusListener(visibilityHandler); - return text; - } + // call setTitleBarForeground regardless as it also sets the label color + section.setTitleBarForeground(getColors().getColor(IFormColors.TB_TOGGLE)); + return section; + } + private class BoldFontHolder2 { + private Font normalFont; + private Font boldFont; + public BoldFontHolder2() { + } + + public Font getBoldFont(Font font) { + createBoldFont(font); + return boldFont; + } + + private void createBoldFont(Font font) { + if (normalFont == null || !normalFont.equals(font)) { + normalFont = font; + dispose(); + } + if (boldFont == null) { + boldFont = FormFonts.getInstance().getBoldFont(getColors().getDisplay(), normalFont); + } + } + public void dispose() { + if (boldFont != null) { + FormFonts.getInstance().markFinished(boldFont, getColors().getDisplay()); + boldFont = null; + } + } + } + + /** + *

+ * createToggleableTextField + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param initialText + * a {@link java.lang.String} object. + * @param initialState + * a boolean. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement} + * object. + */ + public ToggleableTextElement createToggleableTextField(ICdmFormElement parentElement, String labelString, + String initialText, boolean initialState, int style) { + ToggleableTextElement element = new ToggleableTextElement(this, parentElement, labelString, initialText, + initialState, style | orientation); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createTimePeriodElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param timePeriod + * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.TimePeriodElement} + * object. + */ + public TimePeriodElement createTimePeriodElement(ICdmFormElement parentElement, String labelString, + TimePeriod timePeriod, int style) { + TimePeriodElement element = new TimePeriodElement(this, parentElement, labelString, timePeriod, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createPointElement + *

+ * + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param point + * a {@link eu.etaxonomy.cdm.model.location.Point} object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.PointElement} object. + */ + public PointElement createPointElement(ICdmFormElement parentElement, Point point, int style) { + PointElement element = new PointElement(this, parentElement, point, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createDateDetailSection + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.DateDetailSection} + * object. + */ + public DateDetailSection createDateDetailSection(ICdmFormElement parentElement, int style) { + DateDetailSection section = new DateDetailSection(this, parentElement, style); + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + *

+ * createPartialElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param labelString + * a {@link java.lang.String} object. + * @param partial + * a {@link org.joda.time.Partial} object. + * @param style + * a int. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.PartialElement} + * object. + */ + public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, + int style) { + PartialElement element = new PartialElement(this, parentElement, labelString, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * addSelectionListener + *

+ * + * @param listener + * a {@link org.eclipse.swt.events.SelectionListener} object. + */ + public void addSelectionListener(SelectionListener listener) { + selectionListenerList.add(listener); + } + + /** + *

+ * removeSelectionListener + *

+ * + * @param listener + * a {@link org.eclipse.swt.events.SelectionListener} object. + */ + public void removeSelectionListener(SelectionListener listener) { + if (listener == null) { + AbstractUtility.error(this.getClass(), + "Tried to remove a selection listener from this factories listeners but was null", null); + } else { + selectionListenerList.remove(listener); + } + } + + /** + *

+ * addPropertyChangeListener + *

+ * + * @param listener + * a {@link org.eclipse.jface.util.IPropertyChangeListener} + * object. + */ + public void addPropertyChangeListener(IPropertyChangeListener listener) { + if (propertyChangeListeners.contains(listener)) { + return; + } + propertyChangeListeners.add(0, listener); + } + + /** + *

+ * removePropertyChangeListener + *

+ * + * @param listener + * a {@link org.eclipse.jface.util.IPropertyChangeListener} + * object. + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + propertyChangeListeners.remove(listener); + } + + /** + *

+ * createHorizontalSeparator + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param style + * a int. + * @return a {@link org.eclipse.swt.widgets.Label} object. + */ + public Label createHorizontalSeparator(ICdmFormElement parentElement, int style) { + Label separator = this.createSeparator(parentElement.getLayoutComposite(), SWT.HORIZONTAL | style); + separator.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); + return separator; + } + + /** + *

+ * createVersionElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param entity + * a {@link eu.etaxonomy.cdm.model.common.VersionableEntity} + * object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionElement} + * object. + */ + public VersionElement createVersionElement(ICdmFormElement parentElement, VersionableEntity entity, int style) { + VersionElement element = new VersionElement(this, parentElement, entity, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + * @param cdmBaseSection + * @param object + * @param style + * @return + */ + public CdmBaseElement createCdmBaseElement(ICdmFormElement parentElement, CdmBase entity, int style) { + CdmBaseElement element = new CdmBaseElement(this, parentElement, entity, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createVersionSection + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.VersionSection} + * object. + */ + public VersionSection createVersionSection(ICdmFormElement parentElement, int style) { + VersionSection section = new VersionSection(this, parentElement, style); + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + * @param parent + * @param i + * @return + */ + public CdmBaseSection createCdmBaseSection(ICdmFormElement parentElement, int style) { + CdmBaseSection section = new CdmBaseSection(this, parentElement, style); + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + *

+ * createEmptyElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.section.EmptyElement} object. + */ + public EmptyElement createEmptyElement(ICdmFormElement parentElement) { + EmptyElement element = new EmptyElement(this, parentElement, null, SWT.NULL); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createHeadlineSection + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.supplemental.HeadlineSection} + * object. + */ + public HeadlineSection createHeadlineSection(ICdmFormElement parentElement) { + HeadlineSection section = new HeadlineSection(this, parentElement, SWT.NULL); + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + *

+ * createParsingMessageElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param parserProblem + * a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem} + * object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessageElement} + * object. + */ + public ParsingMessageElement createParsingMessageElement(ICdmFormElement parentElement, + ParserProblem parserProblem, int style) { + ParsingMessageElement element = new ParsingMessageElement(this, parentElement, parserProblem, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + // SIMPLIFY + + /** + * Used to define which {@link AbstractCdmDetailSection} or + * {@link AbstractCdmDetailElement} should be created with + * {@link CdmFormFactory#createCdmDetailSection(DetailType, ConversationHolder, ICdmFormElement, ISelectionProvider, int)} + * or + * {@link CdmFormFactory#createCdmDetailElement(DetailType, ICdmFormElement, int)} + */ + public static enum DetailType { + AUTHORSHIP, + CLASSIFICATION, + COLLECTION, + DERIVED_UNIT, + DERIVED_UNIT_FACADE, + DERIVED_UNIT_GENERAL, + DESCRIPTION, + DESCRIPTIONELEMENT, + DETERMINATION, + FEATURE_DISTRIBUTION, + FIELD_OBSERVATION, + GATHERING_EVENT, + GRANTEDAUTHORITY, + GROUP, + HYBRID, + INSTITUTION, + MEDIA, + NAMED_AREA, + NAMED_AREA_LEVEL, + NAMERELATIONSHIP,//never used + NATURAL_LANGUAGE, + NOMENCLATURALREFERENCE, + NONVIRALNAME, + PARSINGMESSAGE, + PERSON, + POLYTOMOUS_KEY, + POLYTOMOUS_KEY_NODE, + REFERENCEBASE, + REFERENCED_ENTITY, + SCIENTIFICNAME, + TAXON_NODE, + TAXON_RELATIONSHIP, + TAXONBASE, + TEAM, + TEAMORPERSONBASE, + TERM_VOCABULARY, + USE_RECORD, + USER + } + + public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, ConversationHolder conversation, + ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { + + AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement, + selectionProvider, style); + + parentElement.addElement(section); + adapt(section); + return section; + + } + + /** + * @param definedTermClass + * @param formElement + * @param style + * @return + */ + public AbstractCdmDetailElement createDefinedTermDetailElement(Class definedTermClass, + AbstractCdmDetailSection parentElement, int style) { + AbstractCdmDetailElement element = null; + + if (NamedArea.class.isAssignableFrom(definedTermClass)) { + element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement); + } else { + element = new DefinedTermDetailElement(this, parentElement); + } + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * createCdmDetailSection + *

+ * + * @param detailType + * a + * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType} + * object. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param selectionProvider + * a {@link org.eclipse.jface.viewers.ISelectionProvider} object. + * @param style + * a int. + * @param conversation + * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} + * object. + */ + public AbstractFormSection createCdmDetailSection(DetailType detailType, ConversationHolder conversation, + ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { + AbstractFormSection section = null; + + System.out.println("DetailSection: " + detailType); + switch (detailType) { + case SCIENTIFICNAME: + section = new NameDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case REFERENCEBASE: + section = new ReferenceDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case NOMENCLATURALREFERENCE: + section = new NomenclaturalReferenceDetailSection(this, conversation, parentElement, selectionProvider, + style); + break; + case TAXONBASE: + section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case AUTHORSHIP: + section = new AuthorshipDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case TEAMORPERSONBASE: + section = new TeamOrPersonBaseDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case TEAM: + section = new TeamDetailSection(this, conversation, parentElement, null, style); + break; + case PERSON: + section = new PersonDetailSection(this, conversation, parentElement, null, style); + break; + case DESCRIPTION: + section = new DescriptionDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case DESCRIPTIONELEMENT: + section = new DescriptionElementDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case PARSINGMESSAGE: + section = new ParsingMessagesSection(this, conversation, parentElement, selectionProvider, style); + break; + case NONVIRALNAME: + section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case MEDIA: + section = new eu.etaxonomy.taxeditor.ui.section.description.MediaDetailsSection(this, conversation, + parentElement, selectionProvider, style); + break; + case DERIVED_UNIT_FACADE: + section = new DerivedUnitFacadeDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case FIELD_OBSERVATION: + section = new FieldObservationDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case GATHERING_EVENT: + section = new GatheringEventDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case DERIVED_UNIT: + section = new DerivedUnitBaseDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case NATURAL_LANGUAGE: + section = new NaturalLanguageSection(this, conversation, parentElement, selectionProvider, style); + break; + case FEATURE_DISTRIBUTION: + section = new FeatureDistributionDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case CLASSIFICATION: + section = new ClassificationDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case TAXON_NODE: + section = new TaxonNodeDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case POLYTOMOUS_KEY: + section = new PolytomousKeyDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case POLYTOMOUS_KEY_NODE: + section = new PolytomousKeyNodeDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case INSTITUTION: + section = new InstitutionDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case DERIVED_UNIT_GENERAL: + section = new GeneralDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case HYBRID: + section = new HybridDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case USER: + section = new UserDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case GROUP: + section = new GroupDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case DETERMINATION: + section = new DeterminationDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case TAXON_RELATIONSHIP: + section = new TaxonRelationshipDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case REFERENCED_ENTITY: + section = new ReferencedEntityDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case TERM_VOCABULARY: + section = new TermVocabularyDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case NAMED_AREA: + section = new NamedAreaDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + case USE_RECORD: + section = new UseRecordDetailSection(this, conversation, parentElement, selectionProvider, style); + break; + } + + if (section == null) { + throw new RuntimeException("You tried to create a cdm detail section that is not implemented yet."); + } + + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + *

+ * createCdmDetailElement + *

+ * + * @param detailType + * a + * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType} + * object. + * @param style + * a int. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} + * object. + */ + public AbstractCdmDetailElement createCdmDetailElement(DetailType detailType, ICdmFormElement parentElement, int style) { + AbstractCdmDetailElement element = null; + + switch (detailType) { + case SCIENTIFICNAME: + element = new NameDetailElement(this, parentElement, style); + break; + case REFERENCEBASE: + element = new ReferenceDetailElement(this, parentElement, style); + break; + case NOMENCLATURALREFERENCE: + element = new NomenclaturalReferenceDetailElement(this, parentElement, style); + break; + case TAXONBASE: + element = new TaxonBaseDetailElement(this, parentElement, style); + break; + case AUTHORSHIP: + element = new AuthorshipDetailElement(this, parentElement, style); + break; + case TEAM: + element = new TeamDetailElement(this, parentElement, style); + break; + case PERSON: + element = new PersonDetailElement(this, parentElement, style); + break; + case DESCRIPTION: + element = new DescriptionDetailElement(this, parentElement, style); + break; + case DESCRIPTIONELEMENT: + element = new DescriptionElementDetailElement(this, parentElement, style); + break; + case NONVIRALNAME: + element = new NonViralNameDetailElement(this, parentElement); + break; + case DERIVED_UNIT_FACADE: + element = new DerivedUnitFacadeDetailElement(this, parentElement); + break; + case FIELD_OBSERVATION: + element = new FieldObservationDetailElement(this, parentElement); + break; + case GATHERING_EVENT: + element = new GatheringEventDetailElement(this, parentElement); + break; + case DERIVED_UNIT: + element = new DerivedUnitBaseDetailElement(this, parentElement); + break; + case NATURAL_LANGUAGE: + element = new NaturalLanguageDetailElement(this, parentElement); + break; + case FEATURE_DISTRIBUTION: + element = new FeatureDistributionDetailElement(this, parentElement); + break; + case CLASSIFICATION: + element = new ClassificationDetailElement(this, parentElement); + break; + case TAXON_NODE: + element = new TaxonNodeDetailElement(this, parentElement); + break; + case COLLECTION: + element = new CollectionDetailElement(this, parentElement); + break; + case POLYTOMOUS_KEY: + element = new PolytomousKeyDetailElement(this, parentElement); + break; + case POLYTOMOUS_KEY_NODE: + element = new PolytomousKeyNodeDetailElement(this, parentElement); + break; + case INSTITUTION: + element = new InstitutionDetailElement(this, parentElement); + break; + case DERIVED_UNIT_GENERAL: + element = new GeneralDetailElement(this, parentElement); + break; + case HYBRID: + element = new HybridDetailElement(this, parentElement); + break; + case USER: + element = new UserDetailElement(this, parentElement); + break; + case GROUP: + element = new GroupDetailElement(this, parentElement); + break; + case GRANTEDAUTHORITY: + element = new GrantedAuthorityDetailElement(this, parentElement); + break; + case DETERMINATION: + element = new DeterminationDetailElement(this, parentElement); + break; + case TAXON_RELATIONSHIP: + element = new TaxonRelationshipDetailElement(this, parentElement); + break; + case REFERENCED_ENTITY: + element = new RefereneEntityDetailElement(this, parentElement); + break; + case TERM_VOCABULARY: + element = new TermVocabularyDetailElement(this, parentElement); + break; + case NAMED_AREA: + element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement); + break; + case NAMED_AREA_LEVEL: + element = new DefinedTermDetailElement(this, parentElement); + break; + case USE_RECORD: + // element = new UseRecordDetailElement(this, parentElement, style); + element = new UseRecordDetailElement(this, parentElement); + break; + } + + if (element == null) { + AbstractUtility.error(this.getClass(), + "Detail element was not created. Seems like the case was not implemented for the requested detail type: " + + detailType, null); + } + + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + * + * Used to define which {@link AbstractEntityCollectionSection} should be + * created in + * {@link CdmFormFactory#createEntityDetailSection(EntityDetailType, ConversationHolder, ICdmFormElement, int)} + * + * @author n.hoffmann + * @created Mar 5, 2010 + * @version 1.0 + */ + public static enum EntityDetailType { + TEAM, // never used + TEAMMEMBER, + ANNOTATION, + CREDIT, + DESCRIPTIONELEMENTSOURCE, + EXTENSION, + MARKER, + MEDIA, + DESCRIPTIONELEMENTMEDIA, + MEDIAREPRESENTATION, + MEDIAREPRESENTATIONPART, + MODIFIER, + NOMENCLATURALSTATUS, + NAME_RELATIONSHIP, + PROTOLOG, + RIGHTS, + SOURCE, + SCOPE, + DESCRIPTIONSOURCE, + TYPEDESIGNATION, + STATE_DATA, + STATISTICAL_MEASUREMENT_VALUE, + DESCRIBED_SPECIMEN, + COLLECTING_AREA, DETERMINATION_EVENT, // never used + SPECIMEN_COLLECTION, + IDENTIFIABLE_SOURCE_COLLECTION, + GEOGRAPHICAL_SCOPE, // never used + SCOPE_RESTRICTION, + MEMBER, + GRANTED_AUTHORITY, + GROUPS_BY_USER, + TAXONOMIC_SCOPE, + DETERMINATION_CURRENT, + DETERMINATION_HISTORY + } + + /** + *

+ * createEntityDetailSection + *

+ * + * @param entityDetailType + * a + * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType} + * object. + * @param style + * a int. + * @param conversation + * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} + * object. + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @return a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} + * object. + */ + public AbstractFormSection createEntityDetailSection(EntityDetailType entityDetailType, + ConversationHolder conversation, ICdmFormElement parentElement, int style) { + AbstractFormSection section = null; + + System.out.println("EntityDetailSection: " + entityDetailType); + switch (entityDetailType) { + case TEAM: + // TODO this is not an AbstractEntityCollectionSection + section = new TeamDetailSection(this, conversation, parentElement, null, style); + break; + case TEAMMEMBER: + section = new TeamMemberSection(this, conversation, parentElement, style); + break; + case ANNOTATION: + section = new AnnotationSection(this, conversation, parentElement, style); + break; + case CREDIT: + section = new CreditSection(this, conversation, parentElement, style); + break; + case DESCRIPTIONELEMENTSOURCE: + section = new DescriptionElementSourceSection(this, conversation, parentElement, style); + break; + case EXTENSION: + section = new ExtensionSection(this, conversation, parentElement, style); + break; + case MARKER: + section = new MarkerSection(this, conversation, parentElement, style); + break; + case MEDIA: + section = new MediaSection(this, conversation, parentElement, style); + break; + case DESCRIPTIONELEMENTMEDIA: + section = new DescriptionElementMediaSection(this, conversation, parentElement, style); + break; + case MEDIAREPRESENTATION: + section = new MediaRepresentationSection(this, conversation, parentElement, style); + break; + case MEDIAREPRESENTATIONPART: + section = new MediaRepresentationPartSection(this, conversation, parentElement, style); + break; + case MODIFIER: + section = new ModifierSection(this, conversation, parentElement, style); + break; + case NOMENCLATURALSTATUS: + section = new NomenclaturalStatusSection(this, conversation, parentElement, style); + break; + case NAME_RELATIONSHIP: + section = new NameRelationshipDetailSection(this, conversation, parentElement, style); + break; + case PROTOLOG: + section = new ProtologueSection(this, conversation, parentElement, style); + break; + case RIGHTS: + section = new RightsSection(this, conversation, parentElement, style); + break; + case SOURCE: + section = new SourceSection(this, conversation, parentElement, style); + break; + case SCOPE: + section = new ScopeSection(this, conversation, parentElement, style); + break; + case DESCRIPTIONSOURCE: + section = new DescriptionSourceSection(this, conversation, parentElement, style); + break; + case TYPEDESIGNATION: + section = new TypeDesignationSection(this, conversation, parentElement, style); + break; + case STATE_DATA: + section = new StateDataSection(this, conversation, parentElement, style); + break; + case STATISTICAL_MEASUREMENT_VALUE: + section = new StatisticalMeasurementValueSection(this, conversation, parentElement, style); + break; + case DESCRIBED_SPECIMEN: + section = new DescribedSpecimenSection(this, conversation, parentElement, style); + break; + case COLLECTING_AREA: + section = new CollectingAreasDetailSection(this, conversation, parentElement, style); + break; + case DETERMINATION_CURRENT: + section = new CurrentDeterminationDetailSection(this, conversation, parentElement, style); + break; + case DETERMINATION_HISTORY: + section = new DeterminationHistoryDetailSection(this, conversation, parentElement, style); + break; + case SPECIMEN_COLLECTION: + section = new SpecimenCollectionDetailSection(this, conversation, parentElement, style); + break; + case IDENTIFIABLE_SOURCE_COLLECTION: + section = new SourceCollectionDetailSection(this, conversation, parentElement, style); + break; + case GEOGRAPHICAL_SCOPE: + section = new GeographicalScopeDetailSection(this, conversation, parentElement, style); + break; + case SCOPE_RESTRICTION: + section = new ScopeRestrictionSection(this, conversation, parentElement, style); + break; + case MEMBER: + section = new MemberDetailSection(this, conversation, parentElement, style); + break; + case GRANTED_AUTHORITY: + section = new GrantedAuthorityDetailSection(this, conversation, parentElement, style); + break; + case GROUPS_BY_USER: + section = new GroupsByUserDetailSection(this, conversation, parentElement, style); + break; + case TAXONOMIC_SCOPE: + section = new TaxonomicScopeSection(this, conversation, parentElement, style); + break; + } + parentElement.addElement(section); + adapt(section); + return section; + } + + /** + *

+ * createEntityCollectionElement + *

+ * + * @param removeListener + * a {@link org.eclipse.swt.events.SelectionListener} object. + * @param style + * a int. + * @param parentElement + * a + * {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} + * object. + * @param versionableEntity + * a {@link eu.etaxonomy.cdm.model.common.IVersionableEntity} + * object. + * @param backgroundColor + * a {@link org.eclipse.swt.graphics.Color} object. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement} + * object. + */ + public AbstractEntityCollectionElement createEntityCollectionElement(AbstractFormSection parentElement, + Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style) { + AbstractEntityCollectionElement element = null; + + Object entity = HibernateProxyHelper.deproxy(versionableEntity); + + if (entity instanceof Annotation) { + element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style); + } else if (entity instanceof Person) { + element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style); + } else if (entity instanceof Credit) { + element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style); + } else if (entity instanceof Extension) { + element = new ExtensionElement(this, parentElement, (Extension) entity, removeListener, style); + } else if (entity instanceof Marker) { + element = new MarkerElement(this, parentElement, (Marker) entity, removeListener, style); + } else if (entity instanceof Media) { + element = new MediaElement(this, parentElement, (Media) entity, removeListener, style); + } else if (entity instanceof MediaRepresentation) { + element = new MediaRepresentationElement(this, parentElement, (MediaRepresentation) entity, removeListener, + style); + } else if (entity instanceof ImageFile) { + element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style); + } else if (entity instanceof MediaRepresentationPart) { + element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity, + removeListener, style); + } else if (entity instanceof NomenclaturalStatus) { + element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener, + style); + } else if (entity instanceof Rights) { + element = new RightsElement(this, parentElement, (Rights) entity, removeListener, style); + } else if (entity instanceof DescriptionElementSource) { + element = new DescriptionElementSourceElement(this, parentElement, (DescriptionElementSource) entity, + removeListener, style); + } else if (entity instanceof IdentifiableSource) { + element = new IdentifiableSourceElement(this, parentElement, (IdentifiableSource) entity, removeListener, + style); + } else if (entity instanceof Scope) { + element = new ScopeElement(this, parentElement, (Scope) entity, removeListener, style); + } else if (entity instanceof Modifier) { + element = new ModifierElement(this, parentElement, (Modifier) entity, removeListener, style); + } else if (entity instanceof Reference) { + element = new DescriptionSourceElement(this, parentElement, (Reference) entity, removeListener, style); + } else if (entity instanceof NameTypeDesignation) { + element = new NameTypeDesignationElement(this, parentElement, (NameTypeDesignation) entity, removeListener, + style); + } else if (entity instanceof NameRelationship) { + element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener, + style); + } else if (entity instanceof SpecimenTypeDesignation) { + element = new SpecimenTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity, + removeListener, style); + } else if (entity instanceof StateData) { + element = new StateDataElement(this, parentElement, (StateData) entity, removeListener, style); + } else if (entity instanceof StatisticalMeasurementValue) { + element = new StatisticalMeasurementValueElement(this, parentElement, (StatisticalMeasurementValue) entity, + removeListener, style); + } else if (entity instanceof DerivedUnit) { + element = new DerivedUnitElement(this, parentElement, (DerivedUnit) entity, removeListener, style); + } else if (entity instanceof NamedArea) { + element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style); + } else if (entity instanceof DeterminationEvent) { + element = new DeterminationEventDetailElement(this, parentElement, (DeterminationEvent) entity, + removeListener, style); + } else if (entity instanceof Specimen) { + element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style); + } else if (entity instanceof User) { + element = new MemberDetailElement(this, parentElement, (User) entity, removeListener, style); + } else if (entity instanceof GrantedAuthority) { + element = new GrantedAuthorityCollectionElement(this, parentElement, (GrantedAuthorityImpl) entity, + removeListener, style); + } else if (entity instanceof Group) { + element = new GroupsByUserDetailElement(this, parentElement, (Group) entity, removeListener, style); + } else if (entity instanceof Taxon) { + element = new TaxonDetailElement(this, parentElement, (Taxon) entity, removeListener, style); + } else if (entity instanceof DescriptionElementBase) { + // this is the special case for protologs, maybe we can do this + // differently when API improves + DescriptionElementBase descriptionElement = (DescriptionElementBase) entity; + if (descriptionElement.getFeature().equals(Feature.PROTOLOGUE())) { + element = new ProtologueElement(this, parentElement, descriptionElement, removeListener, style); + } + } + + if (element == null) { + AbstractUtility.errorDialog("No element for entity", this, + "Could not generate element for entity. Looks like the case is not handled already. Check implementation. Entity: " + + entity, null); + } + + else if (backgroundColor != null && !backgroundColor.isDisposed()) { + element.setPersistentBackground(backgroundColor); + } + + adapt(element); + parentElement.addElement(element); + return element; + } + + /** + *

+ * Creates a selection element for the given type T. + *

+ *

+ * Selection elements not handled by this method: + *

    + *
  • {@link TaxonNodeSelectionElement} see + * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)} + *
  • + *
  • {@link NomenclaturalAuthorTeamSelectionElement} see + * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)} + *
  • + *
+ *

+ * + * @param clazz + * a {@link Class} object of the type that you want the selection + * element to handle + * @param parentElement + * a {@link ICdmFormElement} object. + * @param labelString + * a {@link String} object. + * @param selectionType + * @param selection + * a {@link ICdmBase} object. + * @param style + * a int. + * @param conversation + * a {@link ConversationHolder} object. + * @return a {@link EntitySelectionElement} object. + */ + public EntitySelectionElement createSelectionElement(Class clazz, + ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T selection, int mode, + int style) { + EntitySelectionElement element = new EntitySelectionElement(this, conversation, parentElement, clazz, + labelString, selection, mode, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation, + ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) { + TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement, + labelString, selection, mode, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement( + ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection, + int mode, int style) { + NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this, + conversation, parentElement, labelString, selection, mode, style); + adapt(element); + parentElement.addElement(element); + return element; + } + + /** {@inheritDoc} */ + public LabelElement createLabel(ICdmFormElement parentElement, String text) { + LabelElement labelElement = new LabelElement(this, parentElement, text); + adapt(labelElement); + parentElement.addElement(labelElement); + return labelElement; + } + + /** + *

+ * Getter for the field selectionProvider. + *

+ * + * @return a {@link org.eclipse.jface.viewers.ISelectionProvider} object. + */ + public ISelectionProvider getSelectionProvider() { + return selectionProvider; + } + + /** + *

+ * createDetailedDescriptionDetailElement + *

+ * + * @param parentElement + * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} + * object. + * @param entity + * a + * {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} + * object. + * @param style + * a int. + * @return a + * {@link eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement} + * object. + */ + public AbstractDetailedDescriptionDetailElement createDetailedDescriptionDetailElement( + ICdmFormElement parentElement, DescriptionElementBase entity, int style) { + AbstractDetailedDescriptionDetailElement detailedDescriptionElement = null; + + if (entity instanceof CategoricalData) { + detailedDescriptionElement = new CategoricalDataDetailElement(this, parentElement, + (CategoricalData) entity, style); + } else if (entity instanceof CommonTaxonName) { + detailedDescriptionElement = new CommonNameDetailElement(this, parentElement, (CommonTaxonName) entity, + style); + } else if (entity instanceof Distribution) { + detailedDescriptionElement = new DistributionDetailElement(this, parentElement, (Distribution) entity, + style); + } else if (entity instanceof IndividualsAssociation) { + detailedDescriptionElement = new IndividualsAssociationDetailElement(this, parentElement, + (IndividualsAssociation) entity, style); + } else if (entity instanceof QuantitativeData) { + detailedDescriptionElement = new QuantitativeDataDetailElement(this, parentElement, + (QuantitativeData) entity, style); + } else if (entity instanceof TaxonInteraction) { + detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement, + (TaxonInteraction) entity, style); + } else if (entity instanceof TextData) { + detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style); + } else { + throw new IllegalStateException("There is no interface for the given description element"); + } + adapt(detailedDescriptionElement); + parentElement.addElement(detailedDescriptionElement); + return detailedDescriptionElement; + + } + + /** + * Creates a styled text as a part of the form. + * + * @param parent + * the text parent + * @param value + * the text initial value + * @param style + * the text style + * @return the text widget + */ + public StyledText createStyledText(Composite parent, String value, int style) { + StyledText text = new StyledText(parent, getBorderStyle() | style | getOrientation()); + if (value != null) { + text.setText(value); + } + text.setForeground(getColors().getForeground()); + text.setBackground(getColors().getBackground()); + // text.addFocusListener(visibilityHandler); + return text; + } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java index 0d013aa17..166e59d93 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2007 EDIT - * European Distributed Institute of Taxonomy + * European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu - * + * * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -17,30 +17,28 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.IExpansionListener; -import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.TableWrapLayout; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.model.common.IdentifiableEntity; import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; +import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType; import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; -import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType; /** - *

- * Abstract AbstractCdmDetailSection class. - *

- * + * This class visualizes an CDM entity of type ENTITY. + * + * @param A CDM entity which should be visualized by this section. + * * @author n.hoffmann * @created Feb 26, 2010 * @version 1.0 */ -public abstract class AbstractCdmDetailSection extends - AbstractFormSection implements IEnableableFormElement, - IExpansionListener { +public abstract class AbstractCdmDetailSection extends AbstractFormSection implements IEnableableFormElement, IExpansionListener { protected AbstractCdmDetailElement detailElement; @@ -48,7 +46,7 @@ public abstract class AbstractCdmDetailSection extends *

* Constructor for AbstractCdmDetailSection. *

- * + * * @param formFactory * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} * object. @@ -69,7 +67,7 @@ public abstract class AbstractCdmDetailSection extends ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { super(formFactory, parentElement, selectionProvider, - Section.CLIENT_INDENT | style); + ExpandableComposite.CLIENT_INDENT | style); setText(getHeading()); @@ -77,13 +75,13 @@ public abstract class AbstractCdmDetailSection extends createControls(this, SWT.NULL); } - + public AbstractCdmDetailSection(CdmFormFactory formFactory, Class clazz, ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { super(formFactory, parentElement, selectionProvider, - Section.CLIENT_INDENT | style); - + ExpandableComposite.CLIENT_INDENT | style); + setText(getHeading()); addExpansionListener(this); @@ -96,9 +94,7 @@ public abstract class AbstractCdmDetailSection extends * @param definedTermClass * @param null1 */ - protected void createControlsByType( - AbstractCdmDetailSection abstractCdmDetailSection, - Class entityClass, int style) { + protected void createControlsByType(AbstractCdmDetailSection abstractCdmDetailSection, Class entityClass, int style) { } @@ -106,7 +102,7 @@ public abstract class AbstractCdmDetailSection extends *

* createControls *

- * + * * @param formElement * a * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection} @@ -122,15 +118,14 @@ public abstract class AbstractCdmDetailSection extends layout.numColumns = 2; getLayoutComposite().setLayout(layout); - detailElement = formFactory.createCdmDetailElement(getDetailType(), - formElement, style); + detailElement = formFactory.createCdmDetailElement(getDetailType(), formElement, style); } /** *

* getDetailType *

- * + * * @return a * {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType} * object. @@ -141,7 +136,7 @@ public abstract class AbstractCdmDetailSection extends *

* getHeading *

- * + * * @return the heading for this section */ public abstract String getHeading(); @@ -161,7 +156,7 @@ public abstract class AbstractCdmDetailSection extends /* * (non-Javadoc) - * + * * @see * eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground * (org.eclipse.swt.graphics.Color) @@ -179,7 +174,7 @@ public abstract class AbstractCdmDetailSection extends *

* setEntity *

- * + * * @param entity * a ENTITY object. */ @@ -228,19 +223,22 @@ public abstract class AbstractCdmDetailSection extends } /** {@inheritDoc} */ - public void setIrrelevant(boolean irrelevant) { + @Override + public void setIrrelevant(boolean irrelevant) { if (detailElement != null) { detailElement.setIrrelevant(irrelevant); } } /** {@inheritDoc} */ - public void expansionStateChanging(ExpansionEvent e) { + @Override + public void expansionStateChanging(ExpansionEvent e) { // logger.warn("Expansion State Changing"); } /** {@inheritDoc} */ - public void expansionStateChanged(ExpansionEvent e) { + @Override + public void expansionStateChanged(ExpansionEvent e) { // logger.warn("Expansion State Changed"); } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java index 1a9f43ee5..ecc7c9107 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java @@ -1,11 +1,12 @@ /** - * + * */ package eu.etaxonomy.taxeditor.ui.section; import java.util.Collection; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; @@ -19,37 +20,42 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.IExpansionListener; -import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.ExpandableComposite; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.common.CdmUtils; +import eu.etaxonomy.taxeditor.model.AbstractUtility; import eu.etaxonomy.taxeditor.model.ImageResources; import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.preference.Resources; -import eu.etaxonomy.taxeditor.store.StoreUtil; import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; /** - *

Abstract AbstractEntityCollectionSection class.

+ * This class visualizes an CDM entity of type ENTITY and additionally provides the functionality to add + * other elements of type ELEMENT to them. + * + * @param A CDM entity which should be visualized by this section. + * @param An element that can be added (multiple times) to this entity. * * @author n.hoffmann * @version $Id: $ */ + public abstract class AbstractEntityCollectionSection extends AbstractFormSection implements IExpansionListener{ - + protected Composite container; - + private Label label_empty; private String title; - + /** *

Constructor for AbstractEntityCollectionSection.

* - * @param conversation + * @param conversation * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. * @param style a int. * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. @@ -58,18 +64,18 @@ public abstract class AbstractEntityCollectionSection extends A * @param a ELEMENT object. */ public AbstractEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation, ICdmFormElement parentElement, String title, int style) { - super(formFactory, parentElement, Section.CLIENT_INDENT | style); + super(formFactory, parentElement, ExpandableComposite.CLIENT_INDENT | style); this.title = title; this.setText(getTitleString()); showToolbar(); - + addExpansionListener(this); } - + protected Control createToolbar() { ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); - - Action addAction = new Action("add", Action.AS_PUSH_BUTTON){ + + Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){ /* (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ @@ -78,34 +84,35 @@ public abstract class AbstractEntityCollectionSection extends A ELEMENT element = createNewElement(); if(element != null){ addElement(element); - if(! getSection().isExpanded()) - getSection().setExpanded(true); + if(! getSection().isExpanded()) { + getSection().setExpanded(true); + } internalUpdateSection(true); } } }; addAction.setImageDescriptor(new ImageDescriptor() { - + @Override public ImageData getImageData() { return ImageResources.getImage(ImageResources.ADD_ICON).getImageData(); } }); addAction.setToolTipText(getTooltipString()); - + toolBarManager.add(addAction); - + return toolBarManager.createControl(this); } - + public void showToolbar(){ setTextClient(createToolbar()); } - + public void removeToolbar(){ setTextClient(null); } - + /** *

setEntity

* @@ -119,8 +126,8 @@ public abstract class AbstractEntityCollectionSection extends A } setSectionTitle(); layout(); - }; - + } + /** * Sets the title for the section. Adds a "+" sign if the collection is not empty for this section. * Override in subclasses if you want to have a different behaviour. @@ -132,7 +139,7 @@ public abstract class AbstractEntityCollectionSection extends A this.setText(getTitleString()); } } - + /** * Removes all content from the container */ @@ -143,7 +150,7 @@ public abstract class AbstractEntityCollectionSection extends A } removeElements(); } - + /** * Call this method after dynamically changing the client area. * If the options changed is set to true, will also fire a state changed @@ -153,57 +160,59 @@ public abstract class AbstractEntityCollectionSection extends A */ protected void internalUpdateSection(boolean changed){ destroyDynamicContent(); - if(isExpanded() || expandSectionWhenContentAvailable()) - renderContent(isExpanded()); - if(changed) - firePropertyChangeEvent(this); + if(isExpanded() || expandSectionWhenContentAvailable()) { + renderContent(isExpanded()); + } + if(changed) { + firePropertyChangeEvent(this); + } } /** - * Create the elements to be shown in this seciton client area + * Create the elements to be shown in this section client area */ private void renderContent(boolean forceExpansion) { Collection elements = getCollection(getEntity()); - + if(elements == null || elements.isEmpty()){ createEmptyContent(); }else{ createDynamicContents(elements); forceExpansion = true; } - + this.setExpanded(forceExpansion); - + reflow(); } - + /** *

createEmptyContent

*/ protected void createEmptyContent(){ label_empty = formFactory.createLabel(getLayoutComposite(), getEmptyString()); } - + /** * Creates the widgets for the collection * * @param elements a {@link java.util.Collection} object. */ protected void createDynamicContents(Collection elements) - { + { int i = 0; for(final ELEMENT element : elements){ SelectionAdapter removeListener = new SelectionAdapter(){ @Override public void widgetSelected(SelectionEvent e) { - removeElement(element); + removeElement(element); internalUpdateSection(true); } }; boolean modulo = i++%2 == 0; String colorResource = modulo ? Resources.COLOR_LIST_EVEN : Resources.COLOR_LIST_ODD; - createElementComposite(element, removeListener, StoreUtil.getColor(colorResource)); + createElementComposite(element, removeListener, AbstractUtility.getColor(colorResource)); } } @@ -217,7 +226,7 @@ public abstract class AbstractEntityCollectionSection extends A protected void createElementComposite(ELEMENT element, SelectionListener removeListener, Color backgroundColor){ formFactory.createEntityCollectionElement(this, element, removeListener, backgroundColor, SWT.NULL); } - + /* (non-Javadoc) * @see eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground(org.eclipse.swt.graphics.Color) */ @@ -238,7 +247,7 @@ public abstract class AbstractEntityCollectionSection extends A public String getTitleString() { return CdmUtils.Nz(title); } - + /** *

setTitleString

* @@ -249,25 +258,27 @@ public abstract class AbstractEntityCollectionSection extends A setSectionTitle(); layout(); } - + /** {@inheritDoc} */ - public void expansionStateChanging(ExpansionEvent e) { + @Override + public void expansionStateChanging(ExpansionEvent e) { // logger.warn("Expansion State Changing"); } - + /** {@inheritDoc} */ - public void expansionStateChanged(ExpansionEvent e) { + @Override + public void expansionStateChanged(ExpansionEvent e) { if(isExpanded()){ renderContent(isExpanded()); }else{ destroyDynamicContent(); } } - + private boolean expandSectionWhenContentAvailable(){ return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE); } - + /** * Get the specific collection of this entity * @@ -275,39 +286,39 @@ public abstract class AbstractEntityCollectionSection extends A * @return a {@link java.util.Collection} object. */ public abstract Collection getCollection(ENTITY entity); - + /** * Create a new Element for this collection * * @return a ELEMENT object. */ public abstract ELEMENT createNewElement(); - + /** * Add an element to the entities collection * * @param element a ELEMENT object. */ public abstract void addElement(ELEMENT element); - + /** * Remove an element from the entities collection * * @param element a ELEMENT object. */ public abstract void removeElement(ELEMENT element); - + /** * String to display when the collection is empty * * @return a {@link java.lang.String} object. */ public abstract String getEmptyString(); - + /** *

getTooltipString

* * @return String to display when hovering the add button */ - protected abstract String getTooltipString(); + protected abstract String getTooltipString(); } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java index 1e3b307c8..14c9f6267 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2009 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -15,8 +15,8 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.model.common.DefinedTermBase; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; -import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType; +import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; /** @@ -28,7 +28,7 @@ public class DefinedTermDetailSection extends Abstrac /** * @param formFactory - * @param definedTermClass + * @param definedTermClass * @param conversation * @param parentElement * @param selectionProvider @@ -47,20 +47,16 @@ public class DefinedTermDetailSection extends Abstrac protected DetailType getDetailType() { return null; } - - @Override - protected void createControlsByType( - AbstractCdmDetailSection abstractCdmDetailSection, - Class clazz, int style) { - TableWrapLayout layout = (TableWrapLayout) getLayoutComposite() - .getLayout(); - layout.topMargin = 10; - layout.numColumns = 2; - getLayoutComposite().setLayout(layout); - detailElement = formFactory.createDefinedTermDetailElement(clazz, - abstractCdmDetailSection, style); - } + @Override + protected void createControlsByType(AbstractCdmDetailSection abstractCdmDetailSection, Class clazz, int style) { + TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout(); + layout.topMargin = 10; + layout.numColumns = 2; + + getLayoutComposite().setLayout(layout); + detailElement = formFactory.createDefinedTermDetailElement(clazz, abstractCdmDetailSection, style); + } /* (non-Javadoc) * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#getHeading() diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java index 169895ef5..37884ef2e 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java @@ -1,4 +1,3 @@ - // $Id$ /** * Copyright (C) 2011 EDIT @@ -39,8 +38,6 @@ import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; import eu.etaxonomy.cdm.model.media.Media; import eu.etaxonomy.cdm.model.name.NonViralName; import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase; -import eu.etaxonomy.cdm.model.occurrence.FieldObservation; -import eu.etaxonomy.cdm.model.occurrence.Specimen; import eu.etaxonomy.cdm.model.reference.Reference; import eu.etaxonomy.cdm.model.taxon.TaxonBase; import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; @@ -97,9 +94,11 @@ import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer; import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; /** - *

- * DetailsViewer class. - *

+ * + * The DetailsViewer handles the content of the details view ( + * {@link DetailsViewPart}).
+ * Depending on the type of the selected element the section of the details view + * are created. * * @author n.hoffmann * @created Feb 12, 2010 @@ -107,536 +106,527 @@ import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart; */ public class DetailsViewer extends AbstractCdmDataViewer { - private ISelection selection; - - /** - *

- * Constructor for DetailsViewer. - *

- * - * @param parent - * a {@link org.eclipse.swt.widgets.Composite} object. - * @param viewPart - * a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} - * object. - */ - public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) { - super(parent, viewPart); - } - - // START HACK TO MAKE THE DERIVED UNIT FACADE WORK - // since we are getting implementations of DerivedUnitBase from the bulk - // editor - // and not derived unit facade objects, - - /* - * (non-Javadoc) - * - * @see - * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java - * .lang.Object) - */ - @Override - public void setInput(Object input) { - if (input instanceof DerivedUnitBase) { - try { - input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input, PreferencesUtil.getDerivedUnitConfigurator()); - } catch (DerivedUnitFacadeNotSupportedException e) { - AbstractUtility.error(getClass(), e); - } - } - super.setInput(input); - } - - @Override - protected void markViewPartDirty() { - if (getInput() instanceof DerivedUnitFacade) { - getViewPart().changed( - ((DerivedUnitFacade) getInput()).innerDerivedUnit()); - } - - super.markViewPartDirty(); - } - - // END HACK TO MAKE THE DERIVED UNIT FACADE WORK - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.Viewer#refresh() - */ - /** {@inheritDoc} */ - @Override - protected void showParts() { - // FIXME (CM) : Need to clean out this code. - // Too much type checking to decide which detail view to display. - // Need to build in a mechanism where navigators / editors are 'aware' - // of the corresponding detail viewer. - Object input = getInput(); + private ISelection selection; + + /** + *

+ * Constructor for DetailsViewer. + *

+ * + * @param parent + * a {@link org.eclipse.swt.widgets.Composite} object. + * @param viewPart + * a {@link eu.etaxonomy.taxeditor.view.AbstractCdmViewPart} + * object. + */ + public DetailsViewer(Composite parent, AbstractCdmViewPart viewPart) { + super(parent, viewPart); + } + + // START HACK TO MAKE THE DERIVED UNIT FACADE WORK + // since we are getting implementations of DerivedUnitBase from the bulk + // editor + // and not derived unit facade objects, + + /* + * (non-Javadoc) + * + * @see + * eu.etaxonomy.taxeditor.editor.view.AbstractCdmDataViewer#setInput(java + * .lang.Object) + */ + @Override + public void setInput(Object input) { + if (input instanceof DerivedUnitBase) { + try { + input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input, + PreferencesUtil.getDerivedUnitConfigurator()); + } catch (DerivedUnitFacadeNotSupportedException e) { + AbstractUtility.error(getClass(), e); + } + } + super.setInput(input); + } + + @Override + protected void markViewPartDirty() { + if (getInput() instanceof DerivedUnitFacade) { + getViewPart().changed(((DerivedUnitFacade) getInput()).innerDerivedUnit()); + } + + super.markViewPartDirty(); + } + + // END HACK TO MAKE THE DERIVED UNIT FACADE WORK + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.Viewer#refresh() + */ + /** {@inheritDoc} */ + @Override + protected void showParts() { + // FIXME (CM) : Need to clean out this code. + // Too much type checking to decide which detail view to display. + // Need to build in a mechanism where navigators / editors are 'aware' + // of the corresponding detail viewer. + Object input = getInput(); if (input instanceof TaxonBase) { - createTaxonSections(rootElement); - - } else if (input instanceof NonViralName) { - createNameSections(rootElement); - - } else if (input instanceof Reference) { - createReferenceSections(rootElement); - - } else if (input instanceof Team) { - createTeamDetailSection(rootElement); - - } else if (input instanceof Person) { - createPersonDetailSection(rootElement); - - } else if (input instanceof TeamOrPersonBase) { - createTeamOrPersonBaseDetailSection(rootElement); - - } else if (input instanceof DescriptionBase) { - Set descriptionMarkers = ((DescriptionBase) input).getMarkers(); - MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); - Boolean isUseDescription = false; - for (Marker marker : descriptionMarkers) { - if (marker.getMarkerType().equals(useMarkertype)) { - isUseDescription = true; - } - } - if (((DescriptionBase) input).isImageGallery()) { - createImageGallerySection(rootElement); - - } else if (isUseDescription) { - createUseDescriptionSection(rootElement); - } else { - createDescriptionSection(rootElement); - - } - } else if (input instanceof DescriptionElementBase) { - Set descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers(); - MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); - Boolean isUseDescription = false; - for (Marker marker : descriptionMarkers) { - if (marker.getMarkerType().equals(useMarkertype)) { - isUseDescription = true; - } - } - - if (isUseDescription == true && input instanceof CategoricalData ) { - createUseRecordSection(rootElement); - } - else { - createDescriptionElementSection(rootElement); - } - - } else if (input instanceof Media) { - createMediaElementSection(rootElement); - - } else if (input instanceof DerivedUnitFacade) { - createDerivedUnitBaseElementSection(rootElement); - - } else if (input instanceof FeatureNodeContainer) { - createFeatureDistributionSection(rootElement); - - } else if (input instanceof PolytomousKey) { - //createPolytomousKeySection(rootElement); - - } else if ((input instanceof PolytomousKeyNode) - || (input instanceof PolytomousKeyRelationship)) { - createPolytomousKeyNodeSection(rootElement); - } else if (input instanceof User) { - createUserSection(rootElement); - } else if (input instanceof Group) { - createGroupSection(rootElement); - } else if (input instanceof TaxonRelationship) { - createTaxonRelationshipSection(rootElement); - } else if (input instanceof TermVocabulary) { - createTermVocabularySection(rootElement); - } else if (input instanceof DefinedTermBase) { - createDefinedTermSection(rootElement); - } else { - destroySections(); - } - layout(); - } - - - /** - * @param rootElement - */ - private void createGroupSection(RootElement parent) { - destroySections(); - - GroupDetailSection groupDetailSection = (GroupDetailSection) formFactory - .createCdmDetailSection(DetailType.GROUP, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - MemberDetailSection memberDetailSection = (MemberDetailSection) formFactory - .createEntityDetailSection(EntityDetailType.MEMBER, - getConversationHolder(), parent, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - GrantedAuthorityDetailSection grantedAuthorityDetailSection = (GrantedAuthorityDetailSection) formFactory - .createEntityDetailSection(EntityDetailType.GRANTED_AUTHORITY, - getConversationHolder(), parent, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(groupDetailSection); - addPart(memberDetailSection); - addPart(grantedAuthorityDetailSection); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.Viewer#getSelection() - */ - /** {@inheritDoc} */ - @Override - public ISelection getSelection() { - return selection; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers - * .ISelection, boolean) - */ - /** {@inheritDoc} */ - @Override - public void setSelection(ISelection selection, boolean reveal) { - this.selection = selection; - SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection); - fireSelectionChanged(selectionChangedEvent); - } - - /** - * createTaxonSections(RootElement parent) - * @param parent - */ - private void createTaxonSections(RootElement parent) { - destroySections(); - - TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory - .createCdmDetailSection(DetailType.TAXONBASE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory - .createCdmDetailSection(DetailType.NONVIRALNAME, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory - .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory - .createEntityDetailSection( - EntityDetailType.NOMENCLATURALSTATUS, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - ProtologueSection protologSection = (ProtologueSection) formFactory - .createEntityDetailSection(EntityDetailType.PROTOLOG, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory - .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory - .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory - .createCdmDetailSection(DetailType.PARSINGMESSAGE, - getConversationHolder(), parent, this, ExpandableComposite.EXPANDED); - - addPart(taxonBaseDetailSection); - addPart(nonViralNameSection); - addPart(nomenclaturalStatusSection); - addPart(protologSection); - addPart(referenceDetailSection); - addPart(typeDesignationSection); - addPart(nameRelationshipSection); - addPart(parsingMessagesSection); - } - - /** - * createNameSections - * @param parent - */ - private void createNameSections(RootElement parent) { - destroySections(); - NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory - .createCdmDetailSection(DetailType.NONVIRALNAME, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory - .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory - .createEntityDetailSection( - EntityDetailType.NOMENCLATURALSTATUS, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - ProtologueSection protologSection = (ProtologueSection) formFactory - .createEntityDetailSection(EntityDetailType.PROTOLOG, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory - .createEntityDetailSection(EntityDetailType.TYPEDESIGNATION, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory - .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - addPart(nonViralNameSection); - addPart(nomenclaturalStatusSection); - addPart(protologSection); - addPart(referenceDetailSection); - addPart(typeDesignationSection); - addPart(nameRelationshipSection); - } - - /** - * createReferenceSections - * @param parent - */ - private void createReferenceSections(RootElement parent) { - destroySections(); - - ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory - .createCdmDetailSection(DetailType.REFERENCEBASE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(referenceDetailSection); - } - - /** - * createTeamOrPersonBaseDetailSection - * @param parent - */ - private void createTeamOrPersonBaseDetailSection(RootElement parent) { - destroySections(); - TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = (TeamOrPersonBaseDetailSection) formFactory - .createCdmDetailSection(DetailType.TEAMORPERSONBASE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(teamOrPersonBaseDetailSection); - } - - /** - * createTeamDetailSection - * @param parent - */ - private void createTeamDetailSection(RootElement parent) { - destroySections(); - TeamDetailSection teamDetailSection = (TeamDetailSection) formFactory - .createCdmDetailSection(DetailType.TEAM, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(teamDetailSection); - } - - /** - * createPersonDetailSection - * @param parent - */ - private void createPersonDetailSection(RootElement parent) { - destroySections(); - PersonDetailSection personDetailSection = (PersonDetailSection) formFactory - .createCdmDetailSection(DetailType.PERSON, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - addPart(personDetailSection); - } - - /** - * createDescriptionElementSection - * @param parent - */ - private void createDescriptionElementSection(RootElement parent) { - destroySections(); - - DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory - .createCdmDetailSection(DetailType.DESCRIPTIONELEMENT, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory - .createEntityDetailSection( - EntityDetailType.DESCRIPTIONELEMENTSOURCE, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory - .createEntityDetailSection( - EntityDetailType.DESCRIPTIONELEMENTMEDIA, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - addPart(descriptionElementDetailSection); - addPart(descriptionElementSourceSection); - addPart(descriptionElementMediaSection); - } - - /** - * createDescriptionSection - * @param parent - */ - private void createDescriptionSection(RootElement parent) { - destroySections(); - DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory - .createCdmDetailSection(DetailType.DESCRIPTION, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory - .createCdmDetailSection(DetailType.NATURAL_LANGUAGE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory - .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory - .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - ScopeSection scopeSection = (ScopeSection) formFactory - .createEntityDetailSection(EntityDetailType.SCOPE, - getConversationHolder(), parent, ExpandableComposite.TWISTIE); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - addPart(descriptionDetailSection); - addPart(naturalLanguageSection); - addPart(describedSpecimenSection); - addPart(descriptionSourceSection); - addPart(scopeSection); - } - - /** - * Creates the use Description section - * @param parent - */ - private void createUseDescriptionSection(RootElement parent) { - destroySections(); - DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory - .createCdmDetailSection(DetailType.DESCRIPTION, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory - .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, - getConversationHolder(), parent, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - addPart(descriptionDetailSection); - addPart(descriptionSourceSection); - - } - - - /** - * @param rootElement - */ - private void createImageGallerySection(RootElement parent) { - destroySections(); - DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory - .createCdmDetailSection(DetailType.DESCRIPTION, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(descriptionDetailSection); - } - - /** - * createMediaElementSection - * @param parent - */ - - private void createMediaElementSection(RootElement parent) { - destroySections(); - MediaDetailsSection mediaDetailSection = (MediaDetailsSection) formFactory - .createCdmDetailSection(DetailType.MEDIA, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(mediaDetailSection); - } - - /** - * createDerivedUnitBaseElementSection - * @param parent - */ + createTaxonSections(rootElement); + + } else if (input instanceof NonViralName) { + createNameSections(rootElement); + + } else if (input instanceof Reference) { + createReferenceSections(rootElement); + + } else if (input instanceof Team) { + createTeamDetailSection(rootElement); + + } else if (input instanceof Person) { + createPersonDetailSection(rootElement); + + } else if (input instanceof TeamOrPersonBase) { + createTeamOrPersonBaseDetailSection(rootElement); + + } else if (input instanceof DescriptionBase) { + Set descriptionMarkers = ((DescriptionBase) input).getMarkers(); + MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find( + UsageTermCollection.uuidUseMarkerType); + Boolean isUseDescription = false; + for (Marker marker : descriptionMarkers) { + if (marker.getMarkerType().equals(useMarkertype)) { + isUseDescription = true; + } + } + if (((DescriptionBase) input).isImageGallery()) { + createImageGallerySection(rootElement); + + } else if (isUseDescription) { + createUseDescriptionSection(rootElement); + } else { + createDescriptionSection(rootElement); + + } + } else if (input instanceof DescriptionElementBase) { + Set descriptionMarkers = ((DescriptionElementBase) input).getInDescription().getMarkers(); + MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find( + UsageTermCollection.uuidUseMarkerType); + Boolean isUseDescription = false; + for (Marker marker : descriptionMarkers) { + if (marker.getMarkerType().equals(useMarkertype)) { + isUseDescription = true; + } + } + + if (isUseDescription == true && input instanceof CategoricalData) { + createUseRecordSection(rootElement); + } else { + createDescriptionElementSection(rootElement); + } + + } else if (input instanceof Media) { + createMediaElementSection(rootElement); + + } else if (input instanceof DerivedUnitFacade) { + createDerivedUnitBaseElementSection(rootElement); + + } else if (input instanceof FeatureNodeContainer) { + createFeatureDistributionSection(rootElement); + + } else if (input instanceof PolytomousKey) { + // createPolytomousKeySection(rootElement); + + } else if ((input instanceof PolytomousKeyNode) || (input instanceof PolytomousKeyRelationship)) { + createPolytomousKeyNodeSection(rootElement); + } else if (input instanceof User) { + createUserSection(rootElement); + } else if (input instanceof Group) { + createGroupSection(rootElement); + } else if (input instanceof TaxonRelationship) { + createTaxonRelationshipSection(rootElement); + } else if (input instanceof TermVocabulary) { + createTermVocabularySection(rootElement); + } else if (input instanceof DefinedTermBase) { + createDefinedTermSection(rootElement); + } else { + destroySections(); + } + layout(); + } + + /** + * @param rootElement + */ + private void createGroupSection(RootElement parent) { + destroySections(); + + GroupDetailSection groupDetailSection = (GroupDetailSection) formFactory.createCdmDetailSection( + DetailType.GROUP, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + MemberDetailSection memberDetailSection = (MemberDetailSection) formFactory.createEntityDetailSection( + EntityDetailType.MEMBER, getConversationHolder(), parent, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + GrantedAuthorityDetailSection grantedAuthorityDetailSection = (GrantedAuthorityDetailSection) formFactory + .createEntityDetailSection(EntityDetailType.GRANTED_AUTHORITY, getConversationHolder(), parent, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + addPart(groupDetailSection); + addPart(memberDetailSection); + addPart(grantedAuthorityDetailSection); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.Viewer#getSelection() + */ + /** {@inheritDoc} */ + @Override + public ISelection getSelection() { + return selection; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.Viewer#setSelection(org.eclipse.jface.viewers + * .ISelection, boolean) + */ + /** {@inheritDoc} */ + @Override + public void setSelection(ISelection selection, boolean reveal) { + this.selection = selection; + SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(this, selection); + fireSelectionChanged(selectionChangedEvent); + } + + /** + * createTaxonSections(RootElement parent) + * + * @param parent + */ + private void createTaxonSections(RootElement parent) { + destroySections(); + + TaxonBaseDetailSection taxonBaseDetailSection = (TaxonBaseDetailSection) formFactory.createCdmDetailSection( + DetailType.TAXONBASE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory.createCdmDetailSection( + DetailType.NONVIRALNAME, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory + .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory + .createEntityDetailSection(EntityDetailType.NOMENCLATURALSTATUS, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + ProtologueSection protologSection = (ProtologueSection) formFactory.createEntityDetailSection( + EntityDetailType.PROTOLOG, getConversationHolder(), parent, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory.createEntityDetailSection( + EntityDetailType.TYPEDESIGNATION, getConversationHolder(), parent, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory + .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + ParsingMessagesSection parsingMessagesSection = (ParsingMessagesSection) formFactory.createCdmDetailSection( + DetailType.PARSINGMESSAGE, getConversationHolder(), parent, this, ExpandableComposite.EXPANDED); + + addPart(taxonBaseDetailSection); + addPart(nonViralNameSection); + addPart(nomenclaturalStatusSection); + addPart(protologSection); + addPart(referenceDetailSection); + addPart(typeDesignationSection); + addPart(nameRelationshipSection); + addPart(parsingMessagesSection); + } + + /** + * createNameSections + * + * @param parent + */ + private void createNameSections(RootElement parent) { + destroySections(); + NonViralNameDetailSection nonViralNameSection = (NonViralNameDetailSection) formFactory.createCdmDetailSection( + DetailType.NONVIRALNAME, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NomenclaturalReferenceDetailSection referenceDetailSection = (NomenclaturalReferenceDetailSection) formFactory + .createCdmDetailSection(DetailType.NOMENCLATURALREFERENCE, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NomenclaturalStatusSection nomenclaturalStatusSection = (NomenclaturalStatusSection) formFactory + .createEntityDetailSection(EntityDetailType.NOMENCLATURALSTATUS, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + ProtologueSection protologSection = (ProtologueSection) formFactory.createEntityDetailSection( + EntityDetailType.PROTOLOG, getConversationHolder(), parent, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + TypeDesignationSection typeDesignationSection = (TypeDesignationSection) formFactory.createEntityDetailSection( + EntityDetailType.TYPEDESIGNATION, getConversationHolder(), parent, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NameRelationshipDetailSection nameRelationshipSection = (NameRelationshipDetailSection) formFactory + .createEntityDetailSection(EntityDetailType.NAME_RELATIONSHIP, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + addPart(nonViralNameSection); + addPart(nomenclaturalStatusSection); + addPart(protologSection); + addPart(referenceDetailSection); + addPart(typeDesignationSection); + addPart(nameRelationshipSection); + } + + /** + * createReferenceSections + * + * @param parent + */ + private void createReferenceSections(RootElement parent) { + destroySections(); + + ReferenceDetailSection referenceDetailSection = (ReferenceDetailSection) formFactory.createCdmDetailSection( + DetailType.REFERENCEBASE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + + addPart(referenceDetailSection); + } + + /** + * createTeamOrPersonBaseDetailSection + * + * @param parent + */ + private void createTeamOrPersonBaseDetailSection(RootElement parent) { + destroySections(); + TeamOrPersonBaseDetailSection teamOrPersonBaseDetailSection = (TeamOrPersonBaseDetailSection) formFactory + .createCdmDetailSection(DetailType.TEAMORPERSONBASE, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + addPart(teamOrPersonBaseDetailSection); + } + + /** + * createTeamDetailSection + * + * @param parent + */ + private void createTeamDetailSection(RootElement parent) { + destroySections(); + TeamDetailSection teamDetailSection = (TeamDetailSection) formFactory.createCdmDetailSection(DetailType.TEAM, + getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + addPart(teamDetailSection); + } + + /** + * createPersonDetailSection + * + * @param parent + */ + private void createPersonDetailSection(RootElement parent) { + destroySections(); + PersonDetailSection personDetailSection = (PersonDetailSection) formFactory.createCdmDetailSection( + DetailType.PERSON, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + addPart(personDetailSection); + } + + /** + * createDescriptionElementSection + * + * @param parent + */ + private void createDescriptionElementSection(RootElement parent) { + destroySections(); + + DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory + .createCdmDetailSection(DetailType.DESCRIPTIONELEMENT, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory + .createEntityDetailSection(EntityDetailType.DESCRIPTIONELEMENTSOURCE, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory + .createEntityDetailSection(EntityDetailType.DESCRIPTIONELEMENTMEDIA, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + addPart(descriptionElementDetailSection); + addPart(descriptionElementSourceSection); + addPart(descriptionElementMediaSection); + } + + /** + * createDescriptionSection + * + * @param parent + */ + private void createDescriptionSection(RootElement parent) { + destroySections(); + DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory + .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory.createCdmDetailSection( + DetailType.NATURAL_LANGUAGE, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + DescribedSpecimenSection describedSpecimenSection = (DescribedSpecimenSection) formFactory + .createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory + .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, getConversationHolder(), parent, + ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + ScopeSection scopeSection = (ScopeSection) formFactory.createEntityDetailSection(EntityDetailType.SCOPE, + getConversationHolder(), parent, ExpandableComposite.TWISTIE); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + addPart(descriptionDetailSection); + addPart(naturalLanguageSection); + addPart(describedSpecimenSection); + addPart(descriptionSourceSection); + addPart(scopeSection); + } + + /** + * Creates the use Description section + * + * @param parent + */ + private void createUseDescriptionSection(RootElement parent) { + destroySections(); + DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory + .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory + .createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE, getConversationHolder(), parent, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + addPart(descriptionDetailSection); + addPart(descriptionSourceSection); + + } + + /** + * @param rootElement + */ + private void createImageGallerySection(RootElement parent) { + destroySections(); + DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory + .createCdmDetailSection(DetailType.DESCRIPTION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + addPart(descriptionDetailSection); + } + + /** + * createMediaElementSection + * + * @param parent + */ + + private void createMediaElementSection(RootElement parent) { + destroySections(); + MediaDetailsSection mediaDetailSection = (MediaDetailsSection) formFactory.createCdmDetailSection( + DetailType.MEDIA, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + + addPart(mediaDetailSection); + } + + /** + * createDerivedUnitBaseElementSection + * + * @param parent + */ private void createDerivedUnitBaseElementSection(RootElement parent) { destroySections(); - - GeneralDetailSection generalDetailSection = (GeneralDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED); + + GeneralDetailSection generalDetailSection = (GeneralDetailSection) formFactory.createCdmDetailSection( + DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - GatheringEventDetailSection gatheringEventDetailSection = (GatheringEventDetailSection) formFactory.createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); + GatheringEventDetailSection gatheringEventDetailSection = (GatheringEventDetailSection) formFactory + .createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - FieldObservationDetailSection fieldObservationDetailSection = (FieldObservationDetailSection) formFactory.createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); + FieldObservationDetailSection fieldObservationDetailSection = (FieldObservationDetailSection) formFactory + .createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = (DerivedUnitBaseDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); + DerivedUnitBaseDetailSection derivedUnitBaseDetailSection = (DerivedUnitBaseDetailSection) formFactory + .createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - DeterminationDetailSection determinationDetailSection = (DeterminationDetailSection) formFactory.createCdmDetailSection(DetailType.DETERMINATION, getConversationHolder(), parent, this, ExpandableComposite.TWISTIE); + DeterminationDetailSection determinationDetailSection = (DeterminationDetailSection) formFactory + .createCdmDetailSection(DetailType.DETERMINATION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE); addPart(generalDetailSection); addPart(gatheringEventDetailSection); @@ -646,135 +636,128 @@ public class DetailsViewer extends AbstractCdmDataViewer { } - /** - * @param rootElement - */ - private void createFeatureDistributionSection(RootElement parent) { - destroySections(); + /** + * @param rootElement + */ + private void createFeatureDistributionSection(RootElement parent) { + destroySections(); - FeatureDistributionDetailSection featureDistributionSection = (FeatureDistributionDetailSection) formFactory - .createCdmDetailSection(DetailType.FEATURE_DISTRIBUTION, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); + FeatureDistributionDetailSection featureDistributionSection = (FeatureDistributionDetailSection) formFactory + .createCdmDetailSection(DetailType.FEATURE_DISTRIBUTION, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); - addPart(featureDistributionSection); - } + addPart(featureDistributionSection); + } - /** - * createPolytomousKeyNodeSection - * @param parent - */ - private void createPolytomousKeyNodeSection(RootElement parent) { - destroySections(); + /** + * createPolytomousKeyNodeSection + * + * @param parent + */ + private void createPolytomousKeyNodeSection(RootElement parent) { + destroySections(); PolytomousKeyDetailSection polytomousKeyDetailSection = (PolytomousKeyDetailSection) formFactory - .createCdmDetailSection(DetailType.POLYTOMOUS_KEY, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.COMPACT); + .createCdmDetailSection(DetailType.POLYTOMOUS_KEY, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT); formFactory.createHorizontalSeparator(parent, SWT.BORDER); PolytomousKeyNodeDetailSection polytomousKeyNodeDetailSection = (PolytomousKeyNodeDetailSection) formFactory - .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); + .createCdmDetailSection(DetailType.POLYTOMOUS_KEY_NODE, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); formFactory.createHorizontalSeparator(parent, SWT.BORDER); - TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory - .createEntityDetailSection(EntityDetailType.TAXONOMIC_SCOPE, - getConversationHolder(), parent, ExpandableComposite.TWISTIE | ExpandableComposite.COMPACT); - - addPart(polytomousKeyDetailSection); - addPart(polytomousKeyNodeDetailSection); - addPart(taxonomicScopeSection); - - } - - /** - * create the UseRecordSection - * @param parent - */ - private void createUseRecordSection(RootElement parent) { - destroySections(); - - UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory - .createCdmDetailSection(DetailType.USE_RECORD, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - formFactory.createHorizontalSeparator(parent, SWT.BORDER); - - addPart(descriptionUseRecordSection); - - - } - - /** - * createUserSection - * @param parent - */ - private void createUserSection(RootElement parent) { - destroySections(); - - UserDetailSection userDetailSection = (UserDetailSection) formFactory - .createCdmDetailSection(DetailType.USER, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - GroupsByUserDetailSection groupByUserDetailSection = (GroupsByUserDetailSection) formFactory - .createEntityDetailSection(EntityDetailType.GROUPS_BY_USER, - getConversationHolder(), parent, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - addPart(userDetailSection); - addPart(groupByUserDetailSection); - } - - /** - * createTaxonRelationshipSection - * @param parent - */ - private void createTaxonRelationshipSection(RootElement parent) { - destroySections(); - - TaxonRelationshipDetailSection taxonRelationshipDetailSection = (TaxonRelationshipDetailSection) formFactory - .createCdmDetailSection(DetailType.TAXON_RELATIONSHIP, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - - ReferencedEntityDetailSection referencedEntityBaseDetailSection = (ReferencedEntityDetailSection) formFactory - .createCdmDetailSection(DetailType.REFERENCED_ENTITY, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - addPart(taxonRelationshipDetailSection); - addPart(referencedEntityBaseDetailSection); - } - - /** - * @param rootElement - */ - private void createTermVocabularySection(RootElement parent) { - destroySections(); - - TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory - .createCdmDetailSection(DetailType.TERM_VOCABULARY, - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - addPart(termVocabularyDetailSection); - } - - /** - * createDefinedTermSection - * @param parent - */ - private void createDefinedTermSection(RootElement parent) { - destroySections(); - - AbstractFormSection definedTermDetailSection = formFactory - .createDefinedTermDetailSection(getInput().getClass(), - getConversationHolder(), parent, this, ExpandableComposite.TWISTIE - | ExpandableComposite.EXPANDED); - addPart(definedTermDetailSection); - } + TaxonomicScopeSection taxonomicScopeSection = (TaxonomicScopeSection) formFactory.createEntityDetailSection( + EntityDetailType.TAXONOMIC_SCOPE, getConversationHolder(), parent, ExpandableComposite.TWISTIE + | ExpandableComposite.COMPACT); + + addPart(polytomousKeyDetailSection); + addPart(polytomousKeyNodeDetailSection); + addPart(taxonomicScopeSection); + + } + + /** + * create the UseRecordSection + * + * @param parent + */ + private void createUseRecordSection(RootElement parent) { + destroySections(); + + UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory + .createCdmDetailSection(DetailType.USE_RECORD, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + formFactory.createHorizontalSeparator(parent, SWT.BORDER); + + addPart(descriptionUseRecordSection); + + } + + /** + * createUserSection + * + * @param parent + */ + private void createUserSection(RootElement parent) { + destroySections(); + + UserDetailSection userDetailSection = (UserDetailSection) formFactory.createCdmDetailSection(DetailType.USER, + getConversationHolder(), parent, this, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + GroupsByUserDetailSection groupByUserDetailSection = (GroupsByUserDetailSection) formFactory + .createEntityDetailSection(EntityDetailType.GROUPS_BY_USER, getConversationHolder(), parent, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + addPart(userDetailSection); + addPart(groupByUserDetailSection); + } + + /** + * createTaxonRelationshipSection + * + * @param parent + */ + private void createTaxonRelationshipSection(RootElement parent) { + destroySections(); + + TaxonRelationshipDetailSection taxonRelationshipDetailSection = (TaxonRelationshipDetailSection) formFactory + .createCdmDetailSection(DetailType.TAXON_RELATIONSHIP, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + + ReferencedEntityDetailSection referencedEntityBaseDetailSection = (ReferencedEntityDetailSection) formFactory + .createCdmDetailSection(DetailType.REFERENCED_ENTITY, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + addPart(taxonRelationshipDetailSection); + addPart(referencedEntityBaseDetailSection); + } + + /** + * @param rootElement + */ + private void createTermVocabularySection(RootElement parent) { + destroySections(); + + TermVocabularyDetailSection termVocabularyDetailSection = (TermVocabularyDetailSection) formFactory + .createCdmDetailSection(DetailType.TERM_VOCABULARY, getConversationHolder(), parent, this, + ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + addPart(termVocabularyDetailSection); + } + + /** + * createDefinedTermSection + * + * @param parent + */ + private void createDefinedTermSection(RootElement parent) { + destroySections(); + + AbstractFormSection definedTermDetailSection = formFactory.createDefinedTermDetailSection( + getInput().getClass(), getConversationHolder(), parent, this, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); + addPart(definedTermDetailSection); + } } -- 2.34.1