AnnotatedLineEditor : added check and code for the case when the creator also saves...
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 22 Jul 2013 16:03:50 +0000 (16:03 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 22 Jul 2013 16:03:50 +0000 (16:03 +0000)
NewObjectHandler : removed popup for title cache
DynamicNewObjectMenu : menu item for SpecimenOrObservationType.FieldUnit disabled for the moment

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java

index dd461e780bf7c76c185069310cbb05b019a5cfd1..fef97c5d67759b05d7980faf2374054072ff74df 100644 (file)
@@ -24,9 +24,12 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * A list-based editor, where each line in the editor's document is associated with a domain object.
@@ -148,18 +151,38 @@ public class AnnotatedLineEditor extends TextEditor implements IConversationEnab
         */
        public LineAnnotation createAnnotatedLineNewObject(Object key, String titleCache) {
                
+               
+
                // Create new object
                Object entity = ((AnnotatedLineDocumentProvider) getDocumentProvider()).
                                                        getEntityCreator(getEditorInput()).createEntity(key, titleCache);
-
+               // checks if the creator also saves the entity (in a different conversation), in which case 
+               // we need to bind back this editors conversation
+               // we also need to reload the entity because the conversation used to
+               // to create / save the entity may have been closed
+               if(((AnnotatedLineDocumentProvider) getDocumentProvider()).getEntityCreator(getEditorInput()).savesEntity()) {          
+                       getConversationHolder().bind();
+                       Object object = CdmStore.getService(IOccurrenceService.class).load(((CdmBase)entity).getUuid());                        
+                       entity = HibernateProxyHelper.deproxy(object);                  
+               }
+               
+               if(entity == null) {
+                       return null;
+               }
                LineAnnotation annotation = createAnnotatedLine(entity);
                if (annotation != null) {
                        annotation.markAsNew(true);
                }
+
                return annotation;
                
        }
        
+         @Override
+         public boolean isDirty() {
+               return super.isDirty();           
+         }
+       
        /**
         * Creates an annotated line at the end of the document. The annotation contains the entity.
         *
index 43b4b8e5e7a98a08c931a041bbbfb1db740bdf32..99c5640973d74eb0edc512a2f10bce06f87dc816 100644 (file)
@@ -44,13 +44,8 @@ public class NewObjectHandler extends AbstractHandler {
                        
                        Object key = ((Event)event.getTrigger()).data;
                        if (key != null) {
-                               
-                               
-                               String text = ((Event)event.getTrigger()).text;
-                               InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), "Create " + text, "Enter new " + text, "", null);
-                               if (dialog.open() != Window.CANCEL) {
-                                       ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue());
-                               }
+
+                               ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, "Untitled");
                                
                        } else {
                                ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject();
index 60535de12ff220caf42a405cc792dbf448bfd1d4..cf09eda13ffeb7456c33c8083f8a648d47317747 100644 (file)
@@ -26,6 +26,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.CompoundContributionItem;
 import org.eclipse.ui.handlers.IHandlerService;
 
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
@@ -83,6 +84,11 @@ public class DynamicNewObjectMenu extends CompoundContributionItem {
                                }
                        }                               
                });
+               
+               //FIXME:3.3MC Need corresponding Details Viewer section for FieldUnit
+               if(key == SpecimenOrObservationType.FieldUnit){
+                       menuItem.setEnabled(false);
+               }
        }
        
        /**