- adapted EntitiySelectionElement to be able to use with WindowBuilder
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 7 Aug 2013 08:25:48 +0000 (08:25 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 7 Aug 2013 08:25:48 +0000 (08:25 +0000)
16 files changed:
.gitattributes
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractDeterminationEventDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GatheringEventDetailElementComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/ResourceManager.java [new file with mode: 0644]

index 2ad3e435af2e2d4ae8c83733b21c5102ba9ddde0..ddff259efd0e37e7fadbe7ead6ad9fc7f1847487 100644 (file)
@@ -1258,7 +1258,6 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/Abs
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementWithErrors.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractCdmFormElementWithErrors.java -text
-eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/BrowserElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/BrowserElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmElementFactory.java -text
@@ -1314,6 +1313,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/Abs
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractIdentifiableEntityDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/EmptyElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractIdentifiableEntityDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/EmptyElement.java -text
@@ -1422,6 +1422,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/nam
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractDeterminationEventDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/TypeDesignationSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractDeterminationEventDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectionWizardPage.java -text
@@ -1434,6 +1435,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occ
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationHistoryDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationHistoryDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldObservationDetailSection.java -text
@@ -1498,6 +1500,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/voc
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermVocabularyDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermVocabularyDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/NomenclaturalAuthorTeamSelectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/GoogleLanguageApiWrapper.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/NomenclaturalAuthorTeamSelectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/TaxonNodeSelectionElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/GoogleLanguageApiWrapper.java -text
@@ -1530,6 +1533,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/De
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/reporting/ReportingViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/reporting/ReportingViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewer.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/ResourceManager.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java -text
 eu.etaxonomy.taxeditor.store/src/main/resources/eu/etaxonomy/cdm/editorApplicationContext.xml -text
 eu.etaxonomy.taxeditor.store/src/main/resources/log4j.properties -text
 eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java -text
 eu.etaxonomy.taxeditor.store/src/main/resources/eu/etaxonomy/cdm/editorApplicationContext.xml -text
 eu.etaxonomy.taxeditor.store/src/main/resources/log4j.properties -text
index 81cf6a69473df48fd19b00be9e864e3a2498d1ee..64f37b8b187c09bd6db4131b008eccab3b2ad40c 100644 (file)
@@ -8,12 +8,14 @@ import java.util.Set;
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import org.eclipse.wb.swt.SWTResourceManager;
 
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
 
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
@@ -35,11 +37,13 @@ public class AbstractCdmFormElementComposite extends Composite implements ICdmFo
         */
        public AbstractCdmFormElementComposite(Composite parent, final FormToolkit formFactory, ICdmFormElement parentFormElement, int style) {
                super(parent, style);
         */
        public AbstractCdmFormElementComposite(Composite parent, final FormToolkit formFactory, ICdmFormElement parentFormElement, int style) {
                super(parent, style);
+               setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
 
                this.parentElement = parentFormElement;
                if(formFactory instanceof CdmFormFactory){
                    this.formFactory = (CdmFormFactory) formFactory;
                }
 
                this.parentElement = parentFormElement;
                if(formFactory instanceof CdmFormFactory){
                    this.formFactory = (CdmFormFactory) formFactory;
                }
+               //TODO what to do when not instance of CdmFormFactory
 
                TableWrapLayout twl_layoutComposite = new TableWrapLayout();
                twl_layoutComposite.numColumns = 2;
 
                TableWrapLayout twl_layoutComposite = new TableWrapLayout();
                twl_layoutComposite.numColumns = 2;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractEntityCollectionElementComposite.java
deleted file mode 100644 (file)
index c83b4c7..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-package eu.etaxonomy.taxeditor.ui.element;
-
-import org.eclipse.jface.resource.ResourceManager;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-
-public abstract class AbstractEntityCollectionElementComposite<ENTITY>
-       extends AbstractCdmFormElementComposite
-       implements IEntityElement<ENTITY>, SelectionListener, IConversationEnabled {
-
-       protected ENTITY entity;
-
-       private final Composite container;
-
-       private final Composite box;
-
-       private final Button button_remove;
-
-       private Color backgroundColor;
-
-    /**
-     * Create the composite.
-     *
-     * @param parent
-     * @param style
-     */
-    public AbstractEntityCollectionElementComposite(Composite parent, ICdmFormElement parentFormElement, FormToolkit formFactory, ENTITY entity, SelectionListener removeListener, int style) {
-        super(parent, parentFormElement, style);
-
-        box = formFactory.createComposite(parent);
-        box.setBackgroundMode(SWT.INHERIT_DEFAULT);
-        addControl(box);
-
-        TableWrapLayout boxLayout = LayoutConstants.LAYOUT(2, false);
-        boxLayout.topMargin = 4;
-        boxLayout.bottomMargin = 4;
-        box.setLayout(boxLayout);
-
-        box.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
-
-        container = formFactory.createComposite(box);
-        container.setBackgroundMode(SWT.INHERIT_DEFAULT);
-
-        setLayoutComposite(container);
-
-        addControl(container);
-        Layout containerLayout = LayoutConstants.LAYOUT(2, false);
-
-        container.setLayout(containerLayout);
-        container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
-
-        // if (removeListener != null) {
-        button_remove = formFactory.createButton(box, null, SWT.PUSH);
-        addControl(button_remove);
-        button_remove.setLayoutData(LayoutConstants.RIGHT());
-        button_remove.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
-        button_remove.setToolTipText("Remove");
-//        button_remove.addSelectionListener(removeListener);
-        // }
-
-        createControls(this, style);
-        setEntity(entity);
-
-    }
-
-       /**
-        * Init gets executed before any other setup of the section takes place
-        *
-        * Implement this if you want to configure the section
-        */
-       public void init() {
-               // default implementation is empty
-       }
-
-       /**
-        * <p>
-        * Setter for the field <code>entity</code>.
-        * </p>
-        *
-        * @param entity
-        *            a ENTITY object.
-        */
-       public abstract void setEntity(ENTITY entity);
-
-       /**
-        * <p>
-        * Getter for the field <code>entity</code>.
-        * </p>
-        *
-        * @return a ENTITY object.
-        */
-       @Override
-    public ENTITY getEntity() {
-               return entity;
-       }
-
-       /**
-        * <p>
-        * createControls
-        * </p>
-        *
-        * @param element
-        *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
-        *            object.
-        * @param style
-        *            a int.
-        */
-       public abstract void createControls(ICdmFormElement element, int style);
-
-       /**
-        * Mark <code>this</code> element as selected.
-        */
-       @Override
-    public void setSelected(boolean selected) {
-
-               for (ICdmFormElement element : getElements()) {
-                       if (element instanceof ISelectable) {
-                               ((ISelectable) element).setSelected(selected);
-                       }
-               }
-               setBackground(selected ? SELECTED : getPersistentBackground());
-       }
-
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
-        * .eclipse.jface.util.PropertyChangeEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void propertyChange(PropertyChangeEvent event) {
-               if (event == null) {
-                       return;
-               }
-               Object eventSource = event.getSource();
-               if (getElements().contains(eventSource)) {
-                       handleEvent(eventSource);
-               }
-       }
-
-       /**
-        * <p>
-        * handleEvent
-        * </p>
-        *
-        * @param eventSource
-        *            a {@link java.lang.Object} object.
-        */
-       public abstract void handleEvent(Object eventSource);
-
-       /** {@inheritDoc} */
-       @Override
-    public void setBackground(Color color) {
-               backgroundColor = color;
-               super.setBackground(backgroundColor);
-               box.setBackground(backgroundColor);
-               container.setBackground(backgroundColor);
-       }
-
-       /**
-        * {@inheritDoc}
-        *
-        * React when selection occurs
-        */
-       @Override
-    public void widgetSelected(SelectionEvent e) {
-
-       }
-
-       /** {@inheritDoc} */
-       @Override
-    public void widgetDefaultSelected(SelectionEvent e) {
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public Composite getLayoutComposite() {
-               return container;
-       }
-
-       /**
-        * <p>
-        * Getter for the field <code>backgroundColor</code>.
-        * </p>
-        *
-        * @return the backgroundColor
-        */
-       public Color getBackgroundColor() {
-               return backgroundColor;
-       }
-
-       /**
-        * <p>
-        * getConversationHolder
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *         object.
-        */
-       @Override
-    public ConversationHolder getConversationHolder() {
-               if (getParentElement() instanceof IConversationEnabled) {
-                       return ((IConversationEnabled) getParentElement())
-                                       .getConversationHolder();
-               }
-               throw new IllegalArgumentException(
-                               "Parent element should be IConversationEnabled");
-       }
-
-       /** {@inheritDoc} */
-       @Override
-    public void update(CdmDataChangeMap changeEvents) {
-       }
-
-}
index d30d716f51aa979e4b09e6348cb0dcacda4e05dc..2983554163992b17d2585ab4c423e55a27cf6009 100644 (file)
@@ -1,6 +1,9 @@
 package eu.etaxonomy.taxeditor.ui.element;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 package eu.etaxonomy.taxeditor.ui.element;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.forms.widgets.FormToolkit;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite;
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
 
 public final class CdmElementFactory {
     /**
 
 public final class CdmElementFactory {
     /**
@@ -28,4 +31,19 @@ public final class CdmElementFactory {
         CdmTextField cdmNumberField = new CdmTextField(parent, formFactory, parentFormElement, initialText, textHeight, style);
         return cdmNumberField;
     }
         CdmTextField cdmNumberField = new CdmTextField(parent, formFactory, parentFormElement, initialText, textHeight, style);
         return cdmNumberField;
     }
+    /**
+     * @wbp.factory
+     * @wbp.factory.parameter.source formFactory formFactory
+     * @wbp.factory.parameter.source conversation getConversationHolder()
+     * @wbp.factory.parameter.source parentElement element
+     * @wbp.factory.parameter.source clazz eu.etaxonomy.cdm.model.taxon.TaxonBase.class
+     * @wbp.factory.parameter.source labelString "Taxon"
+     * @wbp.factory.parameter.source entity (eu.etaxonomy.cdm.model.taxon.TaxonBase) null
+     * @wbp.factory.parameter.source mode eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite.NOTHING
+     * @wbp.factory.parameter.source style style
+     */
+    public static EntitySelectionElementComposite createEntitySelectionElementComposite(Composite parent, FormToolkit formFactory, ConversationHolder conversation, ICdmFormElement parentElement, Class clazz, String labelString, ICdmBase entity, int mode, int style) {
+        EntitySelectionElementComposite entitySelectionElementComposite = new EntitySelectionElementComposite(parent, formFactory, conversation, parentElement, clazz, labelString, entity, mode, style);
+        return entitySelectionElementComposite;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index 6f0e6262d96a32b1c5d0fc1e500aba09cb533fd9..645d0d333b70c6dff4e08bd2527ca1abe588e34a 100644 (file)
@@ -199,6 +199,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitFacadeDetailSecti
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElementComposite;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationHistoryDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationDetailSection;
@@ -2095,8 +2096,7 @@ public class CdmFormFactory extends FormToolkit {
         } else if (entity instanceof NamedArea) {
             element = new NamedAreaDetailElement(this, parentElement, (NamedArea) entity, removeListener, style);
         } else if (entity instanceof DeterminationEvent) {
         } 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);
+            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) {
         } else if (entity instanceof Specimen) {
             element = new SpecimenCollectionDetailElement(this, parentElement, (Specimen) entity, removeListener, style);
         } else if (entity instanceof User) {
@@ -2125,8 +2125,18 @@ public class CdmFormFactory extends FormToolkit {
 
         else if (backgroundColor != null && !backgroundColor.isDisposed()) {
             element.setPersistentBackground(backgroundColor);
 
         else if (backgroundColor != null && !backgroundColor.isDisposed()) {
             element.setPersistentBackground(backgroundColor);
+            adapt(element);
+            parentElement.addElement(element);
         }
 
         }
 
+        return element;
+    }
+
+    public DeterminationEventDetailElementComposite createDeterminationEventDetailElementComposite(AbstractFormSection parentElement,
+            Object versionableEntity, SelectionListener removeListener, Color backgroundColor, int style){
+        Object entity = HibernateProxyHelper.deproxy(versionableEntity);
+        DeterminationEventDetailElementComposite element = new DeterminationEventDetailElementComposite(parentElement.getLayoutComposite(), this, parentElement, (DeterminationEvent) entity,
+                removeListener, style);
         adapt(element);
         parentElement.addElement(element);
         return element;
         adapt(element);
         parentElement.addElement(element);
         return element;
index ca1353b2c53d0de4301743261bc778221977301e..0465b70eca537cfc6200b8e91eed808cb7d0afeb 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * European Distributed Institute of Taxonomy
  * http://www.e-taxonomy.eu
  * 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.
  */
  * 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.
  */
@@ -36,7 +36,7 @@ import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
  * <p>
  * Abstract AbstractEntityCollectionElement class.
  * </p>
  * <p>
  * Abstract AbstractEntityCollectionElement class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Nov 16, 2009
  * @version 1.0
  * @author n.hoffmann
  * @created Nov 16, 2009
  * @version 1.0
@@ -47,9 +47,9 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
 
        protected ENTITY entity;
 
 
        protected ENTITY entity;
 
-       private Composite container;
+       private final Composite container;
 
 
-       private Composite box;
+       private final Composite box;
 
        private Button button_remove;
 
 
        private Button button_remove;
 
@@ -59,7 +59,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * Constructor for AbstractEntityCollectionElement.
         * </p>
         * <p>
         * Constructor for AbstractEntityCollectionElement.
         * </p>
-        * 
+        *
         * @param style
         *            a int.
         * @param formFactory
         * @param style
         *            a int.
         * @param formFactory
@@ -129,7 +129,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
 
        /**
         * Init gets executed before any other setup of the section takes place
 
        /**
         * Init gets executed before any other setup of the section takes place
-        * 
+        *
         * Implement this if you want to configure the section
         */
        public void init() {
         * Implement this if you want to configure the section
         */
        public void init() {
@@ -140,7 +140,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * Setter for the field <code>entity</code>.
         * </p>
         * <p>
         * Setter for the field <code>entity</code>.
         * </p>
-        * 
+        *
         * @param entity
         *            a ENTITY object.
         */
         * @param entity
         *            a ENTITY object.
         */
@@ -150,10 +150,11 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * Getter for the field <code>entity</code>.
         * </p>
         * <p>
         * Getter for the field <code>entity</code>.
         * </p>
-        * 
+        *
         * @return a ENTITY object.
         */
         * @return a ENTITY object.
         */
-       public ENTITY getEntity() {
+       @Override
+    public ENTITY getEntity() {
                return entity;
        }
 
                return entity;
        }
 
@@ -161,7 +162,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * createControls
         * </p>
         * <p>
         * createControls
         * </p>
-        * 
+        *
         * @param element
         *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
         *            object.
         * @param element
         *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
         *            object.
@@ -173,7 +174,8 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
        /**
         * Mark <code>this</code> element as selected.
         */
        /**
         * Mark <code>this</code> element as selected.
         */
-       public void setSelected(boolean selected) {
+       @Override
+    public void setSelected(boolean selected) {
 
                for (ICdmFormElement element : getElements()) {
                        if (element instanceof ISelectable) {
 
                for (ICdmFormElement element : getElements()) {
                        if (element instanceof ISelectable) {
@@ -185,7 +187,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
 
        /*
         * (non-Javadoc)
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
         * .eclipse.jface.util.PropertyChangeEvent)
         * @see
         * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
         * .eclipse.jface.util.PropertyChangeEvent)
@@ -206,14 +208,15 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * handleEvent
         * </p>
         * <p>
         * handleEvent
         * </p>
-        * 
+        *
         * @param eventSource
         *            a {@link java.lang.Object} object.
         */
        public abstract void handleEvent(Object eventSource);
 
        /** {@inheritDoc} */
         * @param eventSource
         *            a {@link java.lang.Object} object.
         */
        public abstract void handleEvent(Object eventSource);
 
        /** {@inheritDoc} */
-       public void setBackground(Color color) {
+       @Override
+    public void setBackground(Color color) {
                backgroundColor = color;
                super.setBackground(color);
                box.setBackground(color);
                backgroundColor = color;
                super.setBackground(color);
                box.setBackground(color);
@@ -222,15 +225,17 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
 
        /**
         * {@inheritDoc}
 
        /**
         * {@inheritDoc}
-        * 
+        *
         * React when selection occurs
         */
         * React when selection occurs
         */
-       public void widgetSelected(SelectionEvent e) {
+       @Override
+    public void widgetSelected(SelectionEvent e) {
 
        }
 
        /** {@inheritDoc} */
 
        }
 
        /** {@inheritDoc} */
-       public void widgetDefaultSelected(SelectionEvent e) {
+       @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
        }
 
        /** {@inheritDoc} */
        }
 
        /** {@inheritDoc} */
@@ -243,7 +248,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * Getter for the field <code>backgroundColor</code>.
         * </p>
         * <p>
         * Getter for the field <code>backgroundColor</code>.
         * </p>
-        * 
+        *
         * @return the backgroundColor
         */
        public Color getBackgroundColor() {
         * @return the backgroundColor
         */
        public Color getBackgroundColor() {
@@ -254,11 +259,12 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
         * <p>
         * getConversationHolder
         * </p>
         * <p>
         * getConversationHolder
         * </p>
-        * 
+        *
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
         *         object.
         */
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
         *         object.
         */
-       public ConversationHolder getConversationHolder() {
+       @Override
+    public ConversationHolder getConversationHolder() {
                if (getParentElement() instanceof IConversationEnabled) {
                        return ((IConversationEnabled) getParentElement())
                                        .getConversationHolder();
                if (getParentElement() instanceof IConversationEnabled) {
                        return ((IConversationEnabled) getParentElement())
                                        .getConversationHolder();
@@ -268,6 +274,7 @@ public abstract class AbstractEntityCollectionElement<ENTITY> extends
        }
 
        /** {@inheritDoc} */
        }
 
        /** {@inheritDoc} */
-       public void update(CdmDataChangeMap changeEvents) {
+       @Override
+    public void update(CdmDataChangeMap changeEvents) {
        }
 }
        }
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElementComposite.java
new file mode 100644 (file)
index 0000000..1cc7f6f
--- /dev/null
@@ -0,0 +1,275 @@
+// $Id$
+/**
+ * Copyright (C) 2013 EDIT
+ * 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.
+ */
+package eu.etaxonomy.taxeditor.ui.section;
+
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import org.eclipse.wb.swt.ResourceManager;
+import org.eclipse.wb.swt.SWTResourceManager;
+
+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.ui.element.AbstractCdmFormElementComposite;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
+import eu.etaxonomy.taxeditor.ui.element.ISelectable;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+
+/**
+ * @author pplitzner
+ * @date 02.08.2013
+ *
+ */
+public abstract class AbstractEntityCollectionElementComposite<ENTITY> extends AbstractCdmFormElementComposite implements IEntityElement<ENTITY>, SelectionListener, IConversationEnabled {
+
+    protected ENTITY entity;
+
+    private final Composite container;
+
+//    private final Composite box;
+
+    private final Button btnRstre;
+
+    private Color backgroundColor;
+
+    /**
+     * <p>
+     * Constructor for AbstractEntityCollectionElement.
+     * </p>
+     *
+     * @param style
+     *            a int.
+     * @param formFactory
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+     *            object.
+     * @param section
+     *            a
+     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+     *            object.
+     * @param entity
+     *            a ENTITY object.
+     * @param removeListener
+     *            a {@link org.eclipse.swt.events.SelectionListener} object.
+     * @param <ENTITY>
+     *            a ENTITY object.
+     */
+    public AbstractEntityCollectionElementComposite(Composite parent, FormToolkit formFactory, ICdmFormElement parentFormElement, ENTITY entity, SelectionListener removeListener, Color backgroundColor, int style) {
+        super(parent, formFactory, parentFormElement, style);
+        setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
+
+        init();
+
+        if(formFactory instanceof CdmFormFactory){
+            ((CdmFormFactory) formFactory).addPropertyChangeListener(this);
+        }
+
+        // section.getLayoutComposite().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));
+
+//        box = formFactory.createComposite(this);
+        this.setBackgroundMode(SWT.INHERIT_DEFAULT);
+        addControl(this);
+
+        TableWrapLayout boxLayout = LayoutConstants.LAYOUT(2, false);
+        boxLayout.topMargin = 4;
+        boxLayout.bottomMargin = 4;
+        this.setLayout(boxLayout);
+
+        this.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+        // box.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
+
+        container = formFactory.createComposite(this);
+        container.setBackgroundMode(SWT.INHERIT_DEFAULT);
+
+        // container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+        setLayoutComposite(container);
+
+        addControl(container);
+        Layout containerLayout = LayoutConstants.LAYOUT(2, false);
+
+        container.setLayout(containerLayout);
+        container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+            btnRstre = formFactory.createButton(this, null, SWT.PUSH);
+            addControl(btnRstre);
+            btnRstre.setLayoutData(LayoutConstants.RIGHT());
+            btnRstre.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
+            btnRstre.setToolTipText("Remove");
+
+        if (removeListener != null) {
+            btnRstre.addSelectionListener(removeListener);
+        }
+
+        createControls(this, style);
+
+        setEntity(entity);
+    }
+
+    /**
+     * Init gets executed before any other setup of the section takes place
+     *
+     * Implement this if you want to configure the section
+     */
+    public void init() {
+        // default implementation is empty
+    }
+
+    /**
+     * <p>
+     * Setter for the field <code>entity</code>.
+     * </p>
+     *
+     * @param entity
+     *            a ENTITY object.
+     */
+    public abstract void setEntity(ENTITY entity);
+
+    /**
+     * <p>
+     * Getter for the field <code>entity</code>.
+     * </p>
+     *
+     * @return a ENTITY object.
+     */
+    @Override
+    public ENTITY getEntity() {
+        return entity;
+    }
+
+    /**
+     * <p>
+     * createControls
+     * </p>
+     *
+     * @param element
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+     *            object.
+     * @param style
+     *            a int.
+     */
+    public abstract void createControls(ICdmFormElement element, int style);
+
+    /**
+     * Mark <code>this</code> element as selected.
+     */
+    @Override
+    public void setSelected(boolean selected) {
+
+        for (ICdmFormElement element : getElements()) {
+            if (element instanceof ISelectable) {
+                ((ISelectable) element).setSelected(selected);
+            }
+        }
+        setBackground(selected ? SELECTED : getPersistentBackground());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
+     * .eclipse.jface.util.PropertyChangeEvent)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void propertyChange(PropertyChangeEvent event) {
+        if (event == null) {
+            return;
+        }
+        Object eventSource = event.getSource();
+        if (getElements().contains(eventSource)) {
+            handleEvent(eventSource);
+        }
+    }
+
+    /**
+     * <p>
+     * handleEvent
+     * </p>
+     *
+     * @param eventSource
+     *            a {@link java.lang.Object} object.
+     */
+    public abstract void handleEvent(Object eventSource);
+
+    /** {@inheritDoc} */
+    @Override
+    public void setBackground(Color color) {
+        if(color!=null){
+            backgroundColor = color;
+            super.setBackground(color);
+//            box.setBackground(color);
+//            container.setBackground(color);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * React when selection occurs
+     */
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Composite getLayoutComposite() {
+        return container;
+    }
+
+    /**
+     * <p>
+     * Getter for the field <code>backgroundColor</code>.
+     * </p>
+     *
+     * @return the backgroundColor
+     */
+    public Color getBackgroundColor() {
+        return backgroundColor;
+    }
+
+    /**
+     * <p>
+     * getConversationHolder
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+     *         object.
+     */
+    @Override
+    public ConversationHolder getConversationHolder() {
+        if (getParentElement() instanceof IConversationEnabled) {
+            return ((IConversationEnabled) getParentElement()).getConversationHolder();
+        }
+        throw new IllegalArgumentException("Parent element should be IConversationEnabled");
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void update(CdmDataChangeMap changeEvents) {
+    }
+}
index 38ecea49fe4a3f1dddee003bd4e68086474a4d82..f017e45b16940b2422fcb87be8bee09ce04fa725 100644 (file)
@@ -280,7 +280,7 @@ public abstract class AbstractEntityCollectionSection<ENTITY, ELEMENT> extends A
        }
 
        /**
        }
 
        /**
-        * Remove an element from the entities collection and update the section 
+        * Remove an element from the entities collection and update the section
         *
         * @param element a ELEMENT object.
         */
         *
         * @param element a ELEMENT object.
         */
@@ -288,7 +288,7 @@ public abstract class AbstractEntityCollectionSection<ENTITY, ELEMENT> extends A
                removeElement(element);
                internalUpdateSection(true);
        }
                removeElement(element);
                internalUpdateSection(true);
        }
-       
+
        /**
         * Get the specific collection of this entity
         *
        /**
         * Get the specific collection of this entity
         *
index 7fc9405420bb9b7974e3ad1b2902192ff1fb4456..6efdf0354c90930c243d89648ba5afefce9918d7 100644 (file)
@@ -1,15 +1,19 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
 * 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.
 */
 
 package eu.etaxonomy.taxeditor.ui.section.occurrence;
 
 * 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.
 */
 
 package eu.etaxonomy.taxeditor.ui.section.occurrence;
 
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
@@ -78,4 +82,12 @@ public abstract class AbstractDeterminationEventDetailSection extends
                return "No determinations yet.";
        }
 
                return "No determinations yet.";
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createElementComposite(java.lang.Object, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.graphics.Color)
+        */
+       @Override
+       protected void createElementComposite(DeterminationEvent element, SelectionListener removeListener, Color backgroundColor) {
+        formFactory.createDeterminationEventDetailElementComposite(this, element, removeListener, backgroundColor, SWT.NULL);
+       }
+
 }
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/AbstractEventDetailElementComposite.java
new file mode 100644 (file)
index 0000000..56e782a
--- /dev/null
@@ -0,0 +1,93 @@
+// $Id$
+/**
+ * Copyright (C) 2013 EDIT
+ * 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.
+ */
+package eu.etaxonomy.taxeditor.ui.section.occurrence;
+
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.model.agent.AgentBase;
+import eu.etaxonomy.cdm.model.common.EventBase;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElementComposite;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
+
+/**
+ * @author pplitzner
+ * @date 02.08.2013
+ *
+ */
+public abstract class AbstractEventDetailElementComposite<T extends EventBase> extends AbstractEntityCollectionElementComposite<T> {
+
+    protected EntitySelectionElement<AgentBase> selection_agent;
+    protected TextWithLabelElement text_description;
+    protected TimePeriodElement element_timePeriod;
+
+    /**
+     * <p>
+     * Constructor for AbstractEventDetailElement.
+     * </p>
+     *
+     * @param formFactory
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+     *            object.
+     * @param section
+     *            a
+     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+     *            object.
+     * @param entity
+     *            a T object.
+     * @param removeListener
+     *            a {@link org.eclipse.swt.events.SelectionListener} object.
+     * @param style
+     *            a int.
+     * @param <T>
+     *            a T object.
+     */
+    public AbstractEventDetailElementComposite(Composite parent, FormToolkit formFactory, AbstractFormSection section, T entity, SelectionListener removeListener, int style) {
+        super(parent, formFactory, section, entity, removeListener, null, style);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
+     * (java.lang.Object)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void setEntity(T entity) {
+        if(entity!=null){
+            selection_agent.setEntity(entity.getActor());
+            text_description.setText(entity.getDescription());
+            element_timePeriod.setEntity(entity.getTimeperiod());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
+     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void createControls(ICdmFormElement element, int style) {
+        selection_agent = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Actor", null, EntitySelectionElement.ALL, style);
+        element_timePeriod = formFactory.createTimePeriodElement(element, "Time Period", null, style);
+        text_description = formFactory.createTextWithLabelElement(element, "Description", null, style);
+    }
+
+}
index d1fc2a0ff8c614ae99c82e80801c336457a76e86..ce0fc596f2986a86ecd81ca5ad1ab0e7c1308619 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
 * 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.
 */
 * 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.
 */
@@ -21,14 +21,15 @@ import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 
 /**
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 
 /**
- * <p>CollectingAreasDetailSection class.</p>
+ * <p>
+ * CollectingAreasDetailSection class.
+ * </p>
  *
  * @author n.hoffmann
  * @created Oct 14, 2010
  * @version 1.0
  */
  *
  * @author n.hoffmann
  * @created Oct 14, 2010
  * @version 1.0
  */
-public class CollectingAreasDetailSection extends
-               AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
+public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
 
        /**
         * <p>Constructor for CollectingAreasDetailSection.</p>
 
        /**
         * <p>Constructor for CollectingAreasDetailSection.</p>
@@ -59,7 +60,7 @@ public class CollectingAreasDetailSection extends
        @Override
        public NamedArea createNewElement() {
                NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
        @Override
        public NamedArea createNewElement() {
                NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
-               
+
                return selection;
        }
 
                return selection;
        }
 
index c2ae96f52ef0504d08be5275e2d622cf8f1b4a37..c4488e3175175fc0de2bbc43479798607bb6e705 100644 (file)
@@ -16,8 +16,8 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.ICdmDetailElement;
 
 /**
  * @author n.hoffmann
 
 /**
  * @author n.hoffmann
@@ -51,7 +51,7 @@ public class DeterminationDetailSection extends AbstractCdmDetailSection<Derived
         * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
         */
        @Override
         * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
         */
        @Override
-       protected AbstractCdmDetailElement<DerivedUnitFacade> createCdmDetailElement(AbstractCdmDetailSection<DerivedUnitFacade> parentElement, int style) {
+       protected ICdmDetailElement<DerivedUnitFacade> createCdmDetailElement(AbstractCdmDetailSection<DerivedUnitFacade> parentElement, int style) {
            return formFactory.createDeterminationDetailElement(parentElement);
        }
 
            return formFactory.createDeterminationDetailElement(parentElement);
        }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationEventDetailElementComposite.java
new file mode 100644 (file)
index 0000000..881d639
--- /dev/null
@@ -0,0 +1,132 @@
+// $Id$
+/**
+ * Copyright (C) 2013 EDIT
+ * 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.
+ */
+package eu.etaxonomy.taxeditor.ui.section.occurrence;
+
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
+import eu.etaxonomy.cdm.model.occurrence.DeterminationModifier;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.CdmElementFactory;
+import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementComposite;
+
+/**
+ * @author pplitzner
+ * @date 02.08.2013
+ *
+ */
+public class DeterminationEventDetailElementComposite extends AbstractEventDetailElementComposite<DeterminationEvent> {
+
+    private TermComboElement<DeterminationModifier> combo_determinationModifier;
+    private CheckboxElement checkbox_preferredFlag;
+    private EntitySelectionElementComposite<TaxonBase> selection_taxonBase;
+
+    // private TODO a set of references
+
+    /**
+     * <p>
+     * Constructor for DeterminationEventDetailElement.
+     * </p>
+     *
+     * @param formFactory
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+     *            object.
+     * @param section
+     *            a
+     *            {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
+     *            object.
+     * @param entity
+     *            a {@link eu.etaxonomy.cdm.model.occurrence.DeterminationEvent}
+     *            object.
+     * @param removeListener
+     *            a {@link org.eclipse.swt.events.SelectionListener} object.
+     * @param style
+     *            a int.
+     */
+    public DeterminationEventDetailElementComposite(Composite parent, FormToolkit formFactory, AbstractFormSection section, DeterminationEvent entity, SelectionListener removeListener, int style) {
+        super(parent, formFactory, section, entity, removeListener, style);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
+     * (eu.etaxonomy.cdm.model.common.IVersionableEntity)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void setEntity(DeterminationEvent entity) {
+        this.entity = entity;
+        combo_determinationModifier.setSelection(entity.getModifier());
+        selection_taxonBase.setEntity(entity.getTaxon());
+        super.setEntity(entity);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
+     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void createControls(ICdmFormElement element, int style) {
+        // TODO set of references
+
+        // WindowBuilder does not support generics!! That's why they are missing here
+        selection_taxonBase = CdmElementFactory.createEntitySelectionElementComposite(this, formFactory, getConversationHolder(), element, TaxonBase.class, "Taxon", (TaxonBase) null, EntitySelectionElementComposite.NOTHING, style);
+//        this.addElement(selection_taxonBase);// TODO use factory method to create and add selection_taxonBase
+
+        super.createControls(element, style);
+
+        element_timePeriod.setLabel("Determined When");
+        selection_agent.setLabel("Determined by");
+
+        combo_determinationModifier = formFactory.createTermComboElement(DeterminationModifier.class, element, "Modifier", null, style);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
+     * (java.lang.Object)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void handleEvent(Object eventSource) {
+        if (eventSource == combo_determinationModifier) {
+            getEntity().setModifier(combo_determinationModifier.getSelection());
+        } else if (eventSource == checkbox_preferredFlag) {
+            getEntity().setPreferredFlag(checkbox_preferredFlag.getSelection());
+        } else if (eventSource == selection_taxonBase) {
+            getEntity().setTaxon(selection_taxonBase.getSelection());
+        }
+        // else if(eventSource == TODO set of references){
+        //
+        // }
+        else if (eventSource == selection_agent) {
+            getEntity().setDeterminer(selection_agent.getSelection());
+        } else if (eventSource == text_description) {
+            getEntity().setDescription(text_description.getText());
+        } else if (eventSource == element_timePeriod) {
+            getEntity().setTimeperiod(element_timePeriod.getTimePeriod());
+        }
+    }
+
+}
index 44aff0cbd393aade7404871bb7da7996559420cd..b75155b75cfafbea161d7d4ed530b5a985ebe4cb 100644 (file)
@@ -33,14 +33,14 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
 
 
 
 
 
 
-    private final  CdmNumberField absoluteElevationError;
-    private final  CdmNumberField number_absoluteElevationMinimum;
-    private final  CdmNumberField number_absoluteElevationMaximum;
-    private final  CdmTextField collectingMethod;
-    private final  CdmNumberField number_distanceToGround;
-    private final  CdmNumberField number_distanceToWaterSurface;
-    private final  CdmTextField gatheringEventDescription;
-//    private CollectingAreasDetailSection section_collectingAreas;
+    private final CdmNumberField absoluteElevationError;
+    private final CdmNumberField number_absoluteElevationMinimum;
+    private final CdmNumberField number_absoluteElevationMaximum;
+    private final CdmTextField collectingMethod;
+    private final CdmNumberField number_distanceToGround;
+    private final CdmNumberField number_distanceToWaterSurface;
+    private final CdmTextField gatheringEventDescription;
+    private CollectingAreasDetailSection section_collectingAreas;
 
     /**
      * <p>
 
     /**
      * <p>
@@ -61,7 +61,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel_4, true, true);
         lblNewLabel_4.setText("Elevation Error");
 
         formFactory.adapt(lblNewLabel_4, true, true);
         lblNewLabel_4.setText("Elevation Error");
 
-        absoluteElevationError = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
+        absoluteElevationError = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
         ((TableWrapData) absoluteElevationError.getMainControl().getLayoutData()).grabVertical = false;
         TableWrapData twd_cdmNumberField = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField.grabHorizontal = true;
         ((TableWrapData) absoluteElevationError.getMainControl().getLayoutData()).grabVertical = false;
         TableWrapData twd_cdmNumberField = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField.grabHorizontal = true;
@@ -73,7 +73,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel_3, true, true);
         lblNewLabel_3.setText("Elevation Error Minumum (m)");
 
         formFactory.adapt(lblNewLabel_3, true, true);
         lblNewLabel_3.setText("Elevation Error Minumum (m)");
 
-        number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
+        number_absoluteElevationMinimum = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
         TableWrapData tableWrapData = (TableWrapData) number_absoluteElevationMinimum.getMainControl().getLayoutData();
         tableWrapData.valign = TableWrapData.TOP;
         tableWrapData.grabVertical = false;
         TableWrapData tableWrapData = (TableWrapData) number_absoluteElevationMinimum.getMainControl().getLayoutData();
         tableWrapData.valign = TableWrapData.TOP;
         tableWrapData.grabVertical = false;
@@ -86,7 +86,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel_2, true, true);
         lblNewLabel_2.setText("Elevation Maximum (m)");
 
         formFactory.adapt(lblNewLabel_2, true, true);
         lblNewLabel_2.setText("Elevation Maximum (m)");
 
-        number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
+        number_absoluteElevationMaximum = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
         TableWrapData twd_cdmNumberField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_2.grabHorizontal = true;
         number_absoluteElevationMaximum.setLayoutData(twd_cdmNumberField_2);
         TableWrapData twd_cdmNumberField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_2.grabHorizontal = true;
         number_absoluteElevationMaximum.setLayoutData(twd_cdmNumberField_2);
@@ -97,7 +97,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblTestLabel, true, true);
         lblTestLabel.setText("Collecting Method");
 
         formFactory.adapt(lblTestLabel, true, true);
         lblTestLabel.setText("Collecting Method");
 
-        collectingMethod = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0);
+        collectingMethod = CdmElementFactory.createCdmTextField(getLayoutComposite(), formFactory, this, (String) null, (Integer) null, 0);
         TableWrapData twd_cdmTextField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmTextField_1.grabHorizontal = true;
         collectingMethod.setLayoutData(twd_cdmTextField_1);
         TableWrapData twd_cdmTextField_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmTextField_1.grabHorizontal = true;
         collectingMethod.setLayoutData(twd_cdmTextField_1);
@@ -108,7 +108,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel_5, true, true);
         lblNewLabel_5.setText("Distance To Ground (m)");
 
         formFactory.adapt(lblNewLabel_5, true, true);
         lblNewLabel_5.setText("Distance To Ground (m)");
 
-        number_distanceToGround = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
+        number_distanceToGround = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
         TableWrapData twd_cdmNumberField_3 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_3.grabHorizontal = true;
         number_distanceToGround.setLayoutData(twd_cdmNumberField_3);
         TableWrapData twd_cdmNumberField_3 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_3.grabHorizontal = true;
         number_distanceToGround.setLayoutData(twd_cdmNumberField_3);
@@ -119,7 +119,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel_6, true, true);
         lblNewLabel_6.setText("Distance To Water Surface");
 
         formFactory.adapt(lblNewLabel_6, true, true);
         lblNewLabel_6.setText("Distance To Water Surface");
 
-        number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(this, formFactory, this, (Integer) null, 0);
+        number_distanceToWaterSurface = CdmElementFactory.createCdmNumberField(getLayoutComposite(), formFactory, this, (Integer) null, 0);
         TableWrapData twd_cdmNumberField_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_4.grabHorizontal = true;
         number_distanceToWaterSurface.setLayoutData(twd_cdmNumberField_4);
         TableWrapData twd_cdmNumberField_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmNumberField_4.grabHorizontal = true;
         number_distanceToWaterSurface.setLayoutData(twd_cdmNumberField_4);
@@ -130,7 +130,7 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         formFactory.adapt(lblNewLabel, true, true);
         lblNewLabel.setText("Gathering Event Description");
 
         formFactory.adapt(lblNewLabel, true, true);
         lblNewLabel.setText("Gathering Event Description");
 
-        gatheringEventDescription = CdmElementFactory.createCdmTextField(this, formFactory, this, (String) null, (Integer) null, 0);
+        gatheringEventDescription = CdmElementFactory.createCdmTextField(getLayoutComposite(), formFactory, this, (String) null, (Integer) null, 0);
         TableWrapData twd_cdmTextField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmTextField_2.grabHorizontal = true;
         gatheringEventDescription.setLayoutData(twd_cdmTextField_2);
         TableWrapData twd_cdmTextField_2 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
         twd_cdmTextField_2.grabHorizontal = true;
         gatheringEventDescription.setLayoutData(twd_cdmTextField_2);
@@ -151,18 +151,6 @@ public class GatheringEventDetailElementComposite extends AbstractCdmDetailEleme
         number_distanceToWaterSurface.setText(String.valueOf(entity.getDistanceToWaterSurface()));
         gatheringEventDescription.setText(entity.getGatheringEventDescription());
 
         number_distanceToWaterSurface.setText(String.valueOf(entity.getDistanceToWaterSurface()));
         gatheringEventDescription.setText(entity.getGatheringEventDescription());
 
-        // collectingArea
-//        number_absoluteElevationError = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Error", entity.getAbsoluteElevationError(), style);
-//        number_absoluteElevationMinimum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Minimum (m)", entity.getAbsoluteElevationMinimum(), style);
-//        number_absoluteElevationMaximum = formFactory.createIntegerTextWithLabelElement(formElement, "Elevation Maximum (m)", entity.getAbsoluteElevationMaximum(), style);
-
-//        text_collectingMethod = formFactory.createTextWithLabelElement(formElement, "Collecting Method", entity.getCollectingMethod(), style);
-
-//        number_distanceToGround = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Ground (m)", entity.getDistanceToGround(), style);
-//        number_distanceToWaterSurface = formFactory.createIntegerTextWithLabelElement(formElement, "Distance To Water Surface (m)", entity.getDistanceToWaterSurface(), style);
-        // exactLocation
-//        text_gatheringEventDescription = formFactory.createTextWithLabelElement(formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
-
 //        section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
 //        section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
 //        section_collectingAreas.setEntity(entity);
 //        section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
 //        section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
 //        section_collectingAreas.setEntity(entity);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementComposite.java
new file mode 100644 (file)
index 0000000..c819e04
--- /dev/null
@@ -0,0 +1,456 @@
+package eu.etaxonomy.taxeditor.ui.selection;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.wb.swt.ResourceManager;
+import org.eclipse.wb.swt.SWTResourceManager;
+import org.springframework.security.core.GrantedAuthority;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
+import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.preference.Resources;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
+import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElementComposite;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
+import eu.etaxonomy.taxeditor.ui.element.ILabeledElement;
+import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
+
+/**
+ * package eu.etaxonomy.taxeditor.ui.selection;
+ *
+ * import org.eclipse.core.runtime.IStatus;
+ *
+ * /**
+ * <p>
+ * Abstract AbstractSelectionElement class.
+ * </p>
+ *
+ * @author n.hoffmann
+ * @created Nov 17, 2009
+ * @version 1.0
+ * @param <T>
+ */
+public class EntitySelectionElementComposite<T extends ICdmBase> extends AbstractCdmFormElementComposite implements SelectionListener, IEnableableFormElement, ISelectableElement, IEntityElement<T>, ILabeledElement, IConversationEnabled {
+
+    /**
+     * Bitmask for configuring functionality of selection element
+     */
+    public static final int NOTHING = 0; // 000
+    public static final int EDITABLE = 1 << 0; // 001
+    public static final int DELETABLE = 1 << 1; // 010
+    public static final int SELECTABLE = 1 << 2; // 100
+    public static final int ALL = EDITABLE | DELETABLE | SELECTABLE; // 111
+
+    protected T entity;
+
+    protected Label label;
+    protected Label text;
+    protected Button button_selection;
+
+    private SelectionArbitrator selectionArbitrator;
+
+    protected Button button_edit;
+
+    private final String labelString;
+
+    private final Composite selectableComposite;
+
+    private Button button_remove;
+
+    private final boolean isEditable;
+
+    private final boolean isDeletable;
+
+    private final ConversationHolder conversation;
+    private Class<T> clazz;
+
+    /**
+     * <p>
+     * Constructor for AbstractSelectionElement.
+     * </p>
+     *
+     * @param formFactory
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+     *            object.
+     * @param conversation
+     *            TODO
+     * @param parentElement
+     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+     *            object.
+     * @param labelString
+     *            a {@link java.lang.String} object.
+     * @param entity
+     *            a T object.
+     * @param isEditable
+     *            a boolean.
+     * @param isSelectable
+     *            a boolean.
+     * @param isDeletable
+     *            a boolean.
+     * @param style
+     *            a int.
+     * @param <T>
+     *            a T object.
+     */
+    public EntitySelectionElementComposite(Composite parent, FormToolkit formFactory, ConversationHolder conversation, ICdmFormElement parentElement, String labelString, T entity, int mode, int style) {
+        super(parent, formFactory, parentElement, style);
+
+        this.isEditable = (mode & EDITABLE) == EDITABLE;
+        this.isDeletable = (mode & DELETABLE) == DELETABLE;
+        boolean isSelectable = (mode & SELECTABLE) == SELECTABLE;
+
+        this.labelString = labelString;
+
+        this.conversation = conversation;
+
+        if (isSelectable && formFactory instanceof CdmFormFactory && ((CdmFormFactory) formFactory).getSelectionProvider() != null) {
+            selectionArbitrator = ((CdmFormFactory) formFactory).createSelectionArbitrator(this);
+        }
+
+        //only for WindowBuilder
+        Composite parentComposite = this;
+        if(parentElement!=null){
+            parentComposite = parentElement.getLayoutComposite();
+        }
+
+        label = formFactory.createLabel(parentComposite, labelString, SWT.NULL);
+
+        addControl(label);
+
+        selectableComposite = formFactory.createComposite(parentComposite, style);
+
+        int columns = 2;
+        if (isEditable) {
+            columns += 1;
+        }
+        if (isDeletable) {
+            columns += 1;
+        }
+
+        selectableComposite.setLayout(LayoutConstants.LAYOUT(columns, false));
+        selectableComposite.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+        addControl(selectableComposite);
+
+        text = formFactory.createLabel(selectableComposite, null, SWT.WRAP);
+        addControl(text);
+
+        text.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+        button_selection = formFactory.createButton(selectableComposite, null, SWT.PUSH);
+        button_selection.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif"));
+        button_selection.setToolTipText("Browse existing");
+
+        addControl(button_selection);
+        button_selection.addSelectionListener(this);
+
+        if (isEditable) {
+            button_edit = formFactory.createButton(selectableComposite, null, SWT.PUSH);
+            button_edit.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/text.gif"));
+            button_edit.setToolTipText("Edit");
+            addControl(button_edit);
+            button_edit.addSelectionListener(new EditListener(this));
+        }
+
+        if (isDeletable) {
+            button_remove = formFactory.createButton(selectableComposite, null, SWT.PUSH);
+            button_remove.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
+            button_remove.setToolTipText("Remove");
+            addControl(button_remove);
+            button_remove.addSelectionListener(new DeleteListener(this));
+        }
+
+        setEntity(entity);
+    }
+
+    /**
+     *
+     * @param parent
+     * @param formFactory
+     * @param conversation
+     * @param parentElement
+     * @param clazz
+     * @param labelString
+     * @param entity
+     * @param mode
+     * @param style
+     * @wbp.parser.constructor
+     */
+    public EntitySelectionElementComposite(Composite parent, FormToolkit formFactory, ConversationHolder conversation, ICdmFormElement parentElement, Class<T> clazz, String labelString, T entity, int mode, int style) {
+        this(parent, formFactory, conversation, parentElement, labelString, entity, mode, style);
+        setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
+        this.clazz = clazz;
+    }
+
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+        T selection = SelectionDialogFactory.getSelectionFromDialog(clazz, getShell(), getConversationHolder(), getEntity());
+        setSelectionInternal(selection);
+    }
+
+    /**
+     * Return the selected object
+     *
+     * @return a T object.
+     */
+    public T getSelection() {
+        return entity;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.forms.IEnableableFormElement#setEnabled(boolean)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void setEnabled(boolean enabled) {
+        button_selection.setEnabled(enabled);
+        if (isEditable) {
+            button_edit.setEnabled(enabled && entity != null);
+        }
+    }
+
+    /**
+     * <p>
+     * setSelectionInternal
+     * </p>
+     *
+     * @param selection
+     *            a T object.
+     */
+    protected void setSelectionInternal(T selection) {
+        if (selection != null && !selection.equals(this.entity)) {
+            setEntity(selection);
+            firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
+        }
+    }
+
+    /**
+     * <p>
+     * Setter for the field <code>entity</code>.
+     * </p>
+     *
+     * @param selection
+     *            a T object.
+     */
+    public void setEntity(T selection) {
+        this.entity = selection;
+        updateElement();
+    }
+
+    /**
+     * Updates this elements view
+     */
+    protected void updateElement() {
+        String title = CdmUtils.Nz(getTitle());
+        // we have to duplicate ampersands otherwise they are treated as
+        // mnenomic (see Label.setText() documentation)
+        title = title.replace("&", "&&");
+        text.setText(title); // title can be null
+        if (isEditable) {
+            button_edit.setEnabled(entity != null);
+        }
+    }
+
+    /**
+     * <p>
+     * updateFromWizard
+     * </p>
+     */
+    protected void updateFromWizard() {
+        updateElement();
+        firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
+    }
+
+    /**
+     * <p>
+     * getTitle
+     * </p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    protected String getTitle() {
+        if (entity != null) {
+            if (entity instanceof IIdentifiableEntity) {
+                return ((IIdentifiableEntity) entity).getTitleCache();
+            } else if (entity instanceof Group) {
+                return ((Group) entity).getName();
+            } else if (entity instanceof GrantedAuthority) {
+                return ((GrantedAuthority) entity).getAuthority();
+            }
+        }
+        return "";
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setSelected(boolean selected) {
+        setBackground(selected ? SELECTED : getPersistentBackground());
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
+     */
+    /**
+     * <p>
+     * Getter for the field <code>entity</code>.
+     * </p>
+     *
+     * @return a T object.
+     */
+    @Override
+    public T getEntity() {
+        return entity;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#
+     * getSelectionArbitrator()
+     */
+    /**
+     * <p>
+     * Getter for the field <code>selectionArbitrator</code>.
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator}
+     *         object.
+     */
+    @Override
+    public SelectionArbitrator getSelectionArbitrator() {
+        return selectionArbitrator;
+    }
+
+    // TODO is method necessary
+    // /**
+    // * Convenient access to current shell
+    // *
+    // * @return a {@link org.eclipse.swt.widgets.Shell} object.
+    // */
+    // @Override
+    // public Shell getShell() {
+    // return getLayoutComposite().getShell();
+    // }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setIrrelevant(boolean irrelevant) {
+        String colorId = irrelevant ? Resources.COLOR_COMPOSITE_IRRELEVANT : Resources.COLOR_TEXT_DISABLED_BACKGROUND;
+
+        Color color = AbstractUtility.getColor(colorId);
+        text.setBackground(color);
+    }
+
+    private class DeleteListener extends SelectionAdapter {
+
+        private final EntitySelectionElementComposite<T> selectionElement;
+
+        public DeleteListener(EntitySelectionElementComposite<T> selectionElement) {
+            this.selectionElement = selectionElement;
+        }
+
+        @Override
+        public void widgetSelected(SelectionEvent e) {
+            setEntity(null);
+            firePropertyChangeEvent(new CdmPropertyChangeEvent(selectionElement, null));
+        }
+    }
+
+    private class EditListener extends SelectionAdapter {
+
+        private final EntitySelectionElementComposite<T> selectionElement;
+
+        public EditListener(EntitySelectionElementComposite<T> selectionElement) {
+            this.selectionElement = selectionElement;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        public void widgetSelected(SelectionEvent e) {
+            //TODO uncomment
+//            WizardDialog dialog = new WizardDialog(selectionElement.getShell(), new EditFromSelectionWizard(selectionElement));
+//            if (dialog.open() == IStatus.OK) {
+//                selectionElement.updateFromWizard();
+//            }
+        }
+    }
+
+    // not used
+    /** {@inheritDoc} */
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+    }
+
+    /**
+     * <p>
+     * getConversationHolder
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+     *         object.
+     */
+    @Override
+    public ConversationHolder getConversationHolder() {
+        return conversation;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setBackground(Color color) {
+        if(label !=null && color!=null){
+            label.setBackground(color);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setLabel(String labelString) {
+        if (label != null) {
+            label.setText(labelString);
+        }
+    }
+
+    /**
+     * <p>
+     * Getter for the field <code>label</code>.
+     * </p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    @Override
+    public String getLabel() {
+        if (label != null) {
+            return label.getText();
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void update(CdmDataChangeMap changeEvents) {
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/ResourceManager.java b/eu.etaxonomy.taxeditor.store/src/main/java/org/eclipse/wb/swt/ResourceManager.java
new file mode 100644 (file)
index 0000000..4bfbc6b
--- /dev/null
@@ -0,0 +1,415 @@
+/*******************************************************************************\r
+ * Copyright (c) 2011 Google, Inc.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Google, Inc. - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.wb.swt;
+
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.osgi.framework.Bundle;
+
+/**
+ * Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images,
+ * etc.
+ * 
+ * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
+ * operating system resources managed by cached objects when those objects and OS resources are no longer
+ * needed (e.g. on application shutdown)
+ * 
+ * This class may be freely distributed as part of any application or plugin.
+ * <p>
+ * 
+ * @author scheglov_ke
+ * @author Dan Rubel
+ */
+public class ResourceManager extends SWTResourceManager {
+       ////////////////////////////////////////////////////////////////////////////
+       //
+       // Image
+       //
+       ////////////////////////////////////////////////////////////////////////////
+       private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
+       /**
+        * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified
+        * class.
+        * 
+        * @param clazz
+        *            the {@link Class} relative to which to find the image descriptor.
+        * @param path
+        *            the path to the image file.
+        * @return the {@link ImageDescriptor} stored in the file at the specified path.
+        */
+       public static ImageDescriptor getImageDescriptor(Class<?> clazz, String path) {
+               return ImageDescriptor.createFromFile(clazz, path);
+       }
+       /**
+        * Returns an {@link ImageDescriptor} stored in the file at the specified path.
+        * 
+        * @param path
+        *            the path to the image file.
+        * @return the {@link ImageDescriptor} stored in the file at the specified path.
+        */
+       public static ImageDescriptor getImageDescriptor(String path) {
+               try {
+                       return ImageDescriptor.createFromURL(new File(path).toURI().toURL());
+               } catch (MalformedURLException e) {
+                       return null;
+               }
+       }
+       /**
+        * Returns an {@link Image} based on the specified {@link ImageDescriptor}.
+        * 
+        * @param descriptor
+        *            the {@link ImageDescriptor} for the {@link Image}.
+        * @return the {@link Image} based on the specified {@link ImageDescriptor}.
+        */
+       public static Image getImage(ImageDescriptor descriptor) {
+               if (descriptor == null) {
+                       return null;
+               }
+               Image image = m_descriptorImageMap.get(descriptor);
+               if (image == null) {
+                       image = descriptor.createImage();
+                       m_descriptorImageMap.put(descriptor, image);
+               }
+               return image;
+       }
+       /**
+        * Maps images to decorated images.
+        */
+       @SuppressWarnings("unchecked")
+       private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
+       /**
+        * Returns an {@link Image} composed of a base image decorated by another image.
+        * 
+        * @param baseImage
+        *            the base {@link Image} that should be decorated.
+        * @param decorator
+        *            the {@link Image} to decorate the base image.
+        * @return {@link Image} The resulting decorated image.
+        */
+       public static Image decorateImage(Image baseImage, Image decorator) {
+               return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
+       }
+       /**
+        * Returns an {@link Image} composed of a base image decorated by another image.
+        * 
+        * @param baseImage
+        *            the base {@link Image} that should be decorated.
+        * @param decorator
+        *            the {@link Image} to decorate the base image.
+        * @param corner
+        *            the corner to place decorator image.
+        * @return the resulting decorated {@link Image}.
+        */
+       public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
+               if (corner <= 0 || corner >= LAST_CORNER_KEY) {
+                       throw new IllegalArgumentException("Wrong decorate corner");
+               }
+               Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
+               if (cornerDecoratedImageMap == null) {
+                       cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
+                       m_decoratedImageMap[corner] = cornerDecoratedImageMap;
+               }
+               Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
+               if (decoratedMap == null) {
+                       decoratedMap = new HashMap<Image, Image>();
+                       cornerDecoratedImageMap.put(baseImage, decoratedMap);
+               }
+               //
+               Image result = decoratedMap.get(decorator);
+               if (result == null) {
+                       final Rectangle bib = baseImage.getBounds();
+                       final Rectangle dib = decorator.getBounds();
+                       final Point baseImageSize = new Point(bib.width, bib.height);
+                       CompositeImageDescriptor compositImageDesc = new CompositeImageDescriptor() {
+                               @Override
+                               protected void drawCompositeImage(int width, int height) {
+                                       drawImage(baseImage.getImageData(), 0, 0);
+                                       if (corner == TOP_LEFT) {
+                                               drawImage(decorator.getImageData(), 0, 0);
+                                       } else if (corner == TOP_RIGHT) {
+                                               drawImage(decorator.getImageData(), bib.width - dib.width, 0);
+                                       } else if (corner == BOTTOM_LEFT) {
+                                               drawImage(decorator.getImageData(), 0, bib.height - dib.height);
+                                       } else if (corner == BOTTOM_RIGHT) {
+                                               drawImage(decorator.getImageData(), bib.width - dib.width, bib.height - dib.height);
+                                       }
+                               }
+                               @Override
+                               protected Point getSize() {
+                                       return baseImageSize;
+                               }
+                       };
+                       //
+                       result = compositImageDesc.createImage();
+                       decoratedMap.put(decorator, result);
+               }
+               return result;
+       }
+       /**
+        * Dispose all of the cached images.
+        */
+       public static void disposeImages() {
+               SWTResourceManager.disposeImages();
+               // dispose ImageDescriptor images
+               {
+                       for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext();) {
+                               I.next().dispose();
+                       }
+                       m_descriptorImageMap.clear();
+               }
+               // dispose decorated images
+               for (int i = 0; i < m_decoratedImageMap.length; i++) {
+                       Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
+                       if (cornerDecoratedImageMap != null) {
+                               for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
+                                       for (Image image : decoratedMap.values()) {
+                                               image.dispose();
+                                       }
+                                       decoratedMap.clear();
+                               }
+                               cornerDecoratedImageMap.clear();
+                       }
+               }
+               // dispose plugin images
+               {
+                       for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext();) {
+                               I.next().dispose();
+                       }
+                       m_URLImageMap.clear();
+               }
+       }
+       ////////////////////////////////////////////////////////////////////////////
+       //
+       // Plugin images support
+       //
+       ////////////////////////////////////////////////////////////////////////////
+       /**
+        * Maps URL to images.
+        */
+       private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>();
+       /**
+        * Provider for plugin resources, used by WindowBuilder at design time.
+        */
+       public interface PluginResourceProvider {
+               URL getEntry(String symbolicName, String path);
+       }
+       /**
+        * Instance of {@link PluginResourceProvider}, used by WindowBuilder at design time.
+        */
+       private static PluginResourceProvider m_designTimePluginResourceProvider = null;
+       /**
+        * Returns an {@link Image} based on a plugin and file path.
+        * 
+        * @param plugin
+        *            the plugin {@link Object} containing the image
+        * @param name
+        *            the path to the image within the plugin
+        * @return the {@link Image} stored in the file at the specified path
+        * 
+        * @deprecated Use {@link #getPluginImage(String, String)} instead.
+        */
+       @Deprecated
+       public static Image getPluginImage(Object plugin, String name) {
+               try {
+                       URL url = getPluginImageURL(plugin, name);
+                       if (url != null) {
+                               return getPluginImageFromUrl(url);
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               return null;
+       }
+       /**
+        * Returns an {@link Image} based on a {@link Bundle} and resource entry path.
+        * 
+        * @param symbolicName
+        *            the symbolic name of the {@link Bundle}.
+        * @param path
+        *            the path of the resource entry.
+        * @return the {@link Image} stored in the file at the specified path.
+        */
+       public static Image getPluginImage(String symbolicName, String path) {
+               try {
+                       URL url = getPluginImageURL(symbolicName, path);
+                       if (url != null) {
+                               return getPluginImageFromUrl(url);
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               return null;
+       }
+       /**
+        * Returns an {@link Image} based on given {@link URL}.
+        */
+       private static Image getPluginImageFromUrl(URL url) {
+               try {
+                       try {
+                               String key = url.toExternalForm();
+                               Image image = m_URLImageMap.get(key);
+                               if (image == null) {
+                                       InputStream stream = url.openStream();
+                                       try {
+                                               image = getImage(stream);
+                                               m_URLImageMap.put(key, image);
+                                       } finally {
+                                               stream.close();
+                                       }
+                               }
+                               return image;
+                       } catch (Throwable e) {
+                               // Ignore any exceptions
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               return null;
+       }
+       /**
+        * Returns an {@link ImageDescriptor} based on a plugin and file path.
+        * 
+        * @param plugin
+        *            the plugin {@link Object} containing the image.
+        * @param name
+        *            the path to th eimage within the plugin.
+        * @return the {@link ImageDescriptor} stored in the file at the specified path.
+        * 
+        * @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead.
+        */
+       @Deprecated
+       public static ImageDescriptor getPluginImageDescriptor(Object plugin, String name) {
+               try {
+                       try {
+                               URL url = getPluginImageURL(plugin, name);
+                               return ImageDescriptor.createFromURL(url);
+                       } catch (Throwable e) {
+                               // Ignore any exceptions
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               return null;
+       }
+       /**
+        * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
+        * 
+        * @param symbolicName
+        *            the symbolic name of the {@link Bundle}.
+        * @param path
+        *            the path of the resource entry.
+        * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
+        */
+       public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) {
+               try {
+                       URL url = getPluginImageURL(symbolicName, path);
+                       if (url != null) {
+                               return ImageDescriptor.createFromURL(url);
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               return null;
+       }
+       /**
+        * Returns an {@link URL} based on a {@link Bundle} and resource entry path.
+        */
+       private static URL getPluginImageURL(String symbolicName, String path) {
+               // try runtime plugins
+               {
+                       Bundle bundle = Platform.getBundle(symbolicName);
+                       if (bundle != null) {
+                               return bundle.getEntry(path);
+                       }
+               }
+               // try design time provider
+               if (m_designTimePluginResourceProvider != null) {
+                       return m_designTimePluginResourceProvider.getEntry(symbolicName, path);
+               }
+               // no such resource
+               return null;
+       }
+       /**
+        * Returns an {@link URL} based on a plugin and file path.
+        * 
+        * @param plugin
+        *            the plugin {@link Object} containing the file path.
+        * @param name
+        *            the file path.
+        * @return the {@link URL} representing the file at the specified path.
+        * @throws Exception
+        */
+       private static URL getPluginImageURL(Object plugin, String name) throws Exception {
+               // try to work with 'plugin' as with OSGI BundleContext
+               try {
+                       Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$
+                       Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$
+                       if (BundleContextClass.isAssignableFrom(plugin.getClass())) {
+                               Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$
+                               Object bundle = getBundleMethod.invoke(plugin, new Object[0]);
+                               //
+                               Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
+                               Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
+                               Object path = pathConstructor.newInstance(new Object[]{name});
+                               //
+                               Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
+                               Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$
+                               Method findMethod = PlatformClass.getMethod("find", new Class[]{BundleClass, IPathClass}); //$NON-NLS-1$
+                               return (URL) findMethod.invoke(null, new Object[]{bundle, path});
+                       }
+               } catch (Throwable e) {
+                       // Ignore any exceptions
+               }
+               // else work with 'plugin' as with usual Eclipse plugin
+               {
+                       Class<?> PluginClass = Class.forName("org.eclipse.core.runtime.Plugin"); //$NON-NLS-1$
+                       if (PluginClass.isAssignableFrom(plugin.getClass())) {
+                               //
+                               Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
+                               Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
+                               Object path = pathConstructor.newInstance(new Object[]{name});
+                               //
+                               Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
+                               Method findMethod = PluginClass.getMethod("find", new Class[]{IPathClass}); //$NON-NLS-1$
+                               return (URL) findMethod.invoke(plugin, new Object[]{path});
+                       }
+               }
+               return null;
+       }
+       ////////////////////////////////////////////////////////////////////////////
+       //
+       // General
+       //
+       ////////////////////////////////////////////////////////////////////////////
+       /**
+        * Dispose of cached objects and their underlying OS resources. This should only be called when the cached
+        * objects are no longer needed (e.g. on application shutdown).
+        */
+       public static void dispose() {
+               disposeColors();
+               disposeFonts();
+               disposeImages();
+       }
+}
\ No newline at end of file