Resolves #2376
authorn.hoffmann <n.hoffmann@localhost>
Thu, 12 May 2011 16:47:01 +0000 (16:47 +0000)
committern.hoffmann <n.hoffmann@localhost>
Thu, 12 May 2011 16:47:01 +0000 (16:47 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractFormSection.java
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/CurrentDeterminationDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DeterminationHistoryDetailSection.java

index f20c07468baeba8cbf9b5c684079a7de3222f94e..311d7b0cfa64f2a43dcea45c11b1dd7ad70f6fd9 100644 (file)
@@ -3,6 +3,7 @@
  */
 package eu.etaxonomy.taxeditor.ui.forms;
 
+import java.util.ConcurrentModificationException;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -24,6 +25,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.TypedListener;
 import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.editors.text.EditorsUI;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 import org.eclipse.ui.forms.widgets.ToggleHyperlink;
@@ -31,6 +33,7 @@ import org.eclipse.ui.forms.widgets.ToggleHyperlink;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>Abstract AbstractFormSection class.</p>
@@ -56,6 +59,8 @@ public abstract class AbstractFormSection<ENTITY> extends Section implements ISe
        
        private ConversationHolder conversation;
 
+       private boolean handlingPropertyChange;
+
        /**
         * <p>Constructor for AbstractFormSection.</p>
         *
@@ -163,8 +168,13 @@ public abstract class AbstractFormSection<ENTITY> extends Section implements ISe
        /** {@inheritDoc} */
        public void firePropertyChangeEvent(CdmPropertyChangeEvent event) {
                Assert.isNotNull(propertyChangeListeners, "No property change listeners.");
-               for(Object listener : propertyChangeListeners){
-                       ((IPropertyChangeListener) listener).propertyChange(event);
+               try{
+                       for(Object listener : propertyChangeListeners){
+                               ((IPropertyChangeListener) listener).propertyChange(event);
+                       }
+               }catch(ConcurrentModificationException e){
+                       StoreUtil.warn(getClass(), "ConcurrentModificationException while handling PropertyChangeEvents." +
+                                       " It seems like this is not critical");
                }
        }
        
index 8b426fcfa6928476e376eb0bc6f2930253c96c08..bcce1218c99c3027a769239aa388b683707c78d2 100644 (file)
@@ -68,7 +68,7 @@ public abstract class AbstractEntityCollectionSection<ENTITY, ELEMENT> extends A
                addExpansionListener(this);
        }
        
-       private Control createToolbar() {
+       protected Control createToolbar() {
                ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
                
                Action addAction = new Action("add", Action.AS_PUSH_BUTTON){
index b4850fdb25dda552d0f4097865777f384c93e268..a974cf34df1f1da4ba158e3a1d1b3d4f76b627ee 100644 (file)
@@ -13,9 +13,17 @@ package eu.etaxonomy.taxeditor.ui.section.occurrence;
 import java.util.Arrays;
 import java.util.Collection;
 
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Control;
+
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
+import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
 
@@ -38,6 +46,47 @@ public class CurrentDeterminationDetailSection extends
                        int style) {
                super(formFactory, conversation, parentElement, "Current Determination", style);
        }
+       
+       @Override
+       protected Control createToolbar() {
+               ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+               
+               Action addAction = new Action("add", Action.AS_PUSH_BUTTON){
+                       /* (non-Javadoc)
+                        * @see org.eclipse.jface.action.Action#run()
+                        */
+                       @Override
+                       public void run() {
+                               DeterminationEvent element = createNewElement();
+                               
+                               // set as preferred determination
+                               getEntity().setPreferredDetermination(element);
+                               
+                               if(element != null){
+                                       if(! getSection().isExpanded())
+                                               getSection().setExpanded(true);
+                                       internalUpdateSection(true); 
+                               }
+                       }
+               };
+               addAction.setImageDescriptor(new ImageDescriptor() {
+                       
+                       @Override
+                       public ImageData getImageData() {
+                               return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
+                       }
+               });
+               addAction.setToolTipText(getTooltipString());
+               
+               toolBarManager.add(addAction);
+               
+               return toolBarManager.createControl(this);
+       }
+       
+       @Override
+       public void refresh() {
+               internalUpdateSection(false);
+       }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
index a3afd59ab9ddf1f1a8b46441861e30065690c45a..609d577884f45a456f9851146d1decd4cf691f3d 100644 (file)
@@ -66,7 +66,9 @@ public class DeterminationDetailElement extends AbstractCdmDetailElement<Derived
         */
        @Override
        public void handleEvent(Object eventSource) {
-               
+               if(eventSource == section_currentDetermination){
+                       section_determinationHistory.refresh();
+               }
        }
 
 }
index f59eb434658f5a87a834f421b32872c90ee9f6bd..518a1d92b7ceae1ece1bb76a0e8b394283a70c08 100644 (file)
@@ -45,5 +45,10 @@ public class DeterminationHistoryDetailSection extends
        public Collection<DeterminationEvent> getCollection(DerivedUnitFacade entity) {
                return entity != null ? entity.getOtherDeterminations() : null;
        }
+       
+       @Override
+       public void refresh() {
+               internalUpdateSection(false);
+       }
 
 }