commit 3dfb53046a024a29a2550f83f5102134f109bb0b
Author: Cherian Mathew <c.mathew@bgbm.org>
Date:   Mon Jul 22 16:03:50 2013 +0000

    AnnotatedLineEditor : added check and code for the case when the creator also saves the entity
    NewObjectHandler : removed popup for title cache
    DynamicNewObjectMenu : menu item for SpecimenOrObservationType.FieldUnit disabled for the moment

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
index dd461e780..fef97c5d6 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
@@ -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.
 	 *
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java
index 43b4b8e5e..99c564097 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/handler/NewObjectHandler.java
@@ -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();
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java
index 60535de12..cf09eda13 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java
@@ -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);
+		}
 	}
 	
 	/**
