conversations get closed explicitly now
authorn.hoffmann <n.hoffmann@localhost>
Fri, 6 Nov 2009 17:23:25 +0000 (17:23 +0000)
committern.hoffmann <n.hoffmann@localhost>
Fri, 6 Nov 2009 17:23:25 +0000 (17:23 +0000)
13 files changed:
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultView.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateTaxonomicTreeOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonNodeOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteTaxonomicTreeOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteUserOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/user/view/UserManagerView.java

index 8ab4d53e74f8b138c5fc89a6718779a482dea3bf..a5d4674806e9676a305d5b5cec14246578035359 100644 (file)
@@ -261,4 +261,13 @@ public class AnnotatedLineEditor extends TextEditor implements IConversationEnab
        public boolean postOperation(CdmBase objectAffectedByOperation) {\r
                return false;\r
        }\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.editors.text.TextEditor#dispose()\r
+        */\r
+       @Override\r
+       public void dispose() {\r
+               super.dispose();\r
+               conversation.close();\r
+       }\r
 }
\ No newline at end of file
index f8974eb7a11788cf9d730e05bbb0cbdf4b2d7ad7..35208161f682716c39df43c35ad9cd62fffa59db 100644 (file)
@@ -71,6 +71,7 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
        public void dispose() {\r
                super.dispose();\r
 //             EditorUtil.checkHidePropertySheet();\r
+               conversation.close();\r
        }\r
 \r
 \r
index 07e811e3c7dab126b45f7ecc082bec88062ea5f8..78bd8d35d37a0e3e8d89503185b78353c3058ae8 100644 (file)
@@ -102,7 +102,7 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe
                
                // add the new taxon to the editors persistence context
                CdmStore.getTaxonTreeService().saveTaxonNode(newTaxonNode);
-               
+               // we pass on the conversation, will be closed when the editor is closed
                return new TaxonEditorInput(newTaxonNode, conversation);
     }
        
@@ -136,12 +136,19 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe
         * @see org.eclipse.ui.IEditorInput#getPersistable()
         */
        public IPersistableElement getPersistable() {
-               TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
-               boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
-               if (isPersistable) {
-                       return this;
-               } else {
-                       return null;
+               ConversationHolder internalConversation = null;
+               if(conversation.isClosed())
+                       internalConversation = CdmStore.NewTransactionalConversation();
+               try{
+                       boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
+                       if (isPersistable) {
+                               return this;
+                       } else {
+                               return null;
+                       }
+               }finally{
+                       if(internalConversation != null)
+                               internalConversation.close();
                }
        }
 
index 9fca1a0fef186275a298174c69d0acee6a5cd7b0..6c7a8a54b5649fc330967e1216d592bc9a1741f1 100644 (file)
@@ -939,7 +939,6 @@ public class TaxonNameEditor extends EditorPart implements IAdaptable, IConversa
         */\r
        @Override\r
        public boolean isSaveAsAllowed() {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 }
\ No newline at end of file
index 506473aa6ab247a6f9ec894713bcbefa67821491..dc46ad549c5b61363d992d9d09fa1d163c9ceca2 100644 (file)
@@ -50,58 +50,61 @@ public class ChangeAcceptedTaxonToSynonymHandler extends AbstractHandler
         */\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();\r
-               conversation.bind();\r
                \r
-               ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);\r
-               TaxonBasePropertySource taxonBasePropertySource = \r
-                               (TaxonBasePropertySource) ((StructuredSelection) menuSelection).getFirstElement();\r
-               Taxon oldAcceptedTaxon = (Taxon) taxonBasePropertySource.getTaxonBase();\r
-               \r
-               // Choose new accepted taxon    \r
-               List<UUID> excludeTaxa = new ArrayList<UUID>();\r
-               excludeTaxa.add(oldAcceptedTaxon.getUuid());\r
-               Taxon newAcceptedTaxon = FilteredTaxonNodeSelectionDialog.selectTaxonNode(HandlerUtil.getActiveShell(event), "Choose the accepted taxon", excludeTaxa, null).getTaxon();\r
-               \r
-               \r
-               if (newAcceptedTaxon == null) {\r
-                       return null;\r
-               }\r
-               \r
-               try {\r
+               try{\r
+                       ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);\r
+                       TaxonBasePropertySource taxonBasePropertySource = \r
+                                       (TaxonBasePropertySource) ((StructuredSelection) menuSelection).getFirstElement();\r
+                       Taxon oldAcceptedTaxon = (Taxon) taxonBasePropertySource.getTaxonBase();\r
                        \r
-                       Taxon newTaxon = (Taxon) CdmStore.getTaxonService().load(newAcceptedTaxon.getUuid());\r
-                       Taxon oldTaxon = (Taxon) CdmStore.getTaxonService().load(oldAcceptedTaxon.getUuid());\r
+                       // Choose new accepted taxon    \r
+                       List<UUID> excludeTaxa = new ArrayList<UUID>();\r
+                       excludeTaxa.add(oldAcceptedTaxon.getUuid());\r
+                       Taxon newAcceptedTaxon = FilteredTaxonNodeSelectionDialog.selectTaxonNode(HandlerUtil.getActiveShell(event), "Choose the accepted taxon", excludeTaxa, null).getTaxon();\r
                        \r
-                       // Check for multiple nodes\r
-                       if (newTaxon.getTaxonNodes().size() > 1 || oldTaxon.getTaxonNodes().size() > 1) {\r
-                               MessageDialog.openInformation(HandlerUtil.getActiveShell(event), \r
-                                       "Taxon implemented in multiple trees", \r
-                                       "One or both of these taxa is implemented in multiple taxonomic trees.");\r
-                               return null;\r
-                       }\r
                        \r
-                       // Close editor\r
-                       IEditorPart editor = HandlerUtil.getActiveEditor(event);\r
-                       boolean proceed = HandlerUtil.getActiveWorkbenchWindowChecked(event).getActivePage().\r
-                                                               closeEditor(editor, true);\r
-                       if (!proceed) {\r
+                       if (newAcceptedTaxon == null) {\r
                                return null;\r
                        }\r
                        \r
-                       makeTaxonSynonym(oldTaxon, newTaxon, null, null, null);\r
+                       try {\r
+                               \r
+                               Taxon newTaxon = (Taxon) CdmStore.getTaxonService().load(newAcceptedTaxon.getUuid());\r
+                               Taxon oldTaxon = (Taxon) CdmStore.getTaxonService().load(oldAcceptedTaxon.getUuid());\r
                                \r
-                       conversation.commit();\r
-                       Set<TaxonNode> nodes = newTaxon.getTaxonNodes();\r
-                       UUID uuid = nodes.iterator().next().getUuid();\r
+                               // Check for multiple nodes\r
+                               if (newTaxon.getTaxonNodes().size() > 1 || oldTaxon.getTaxonNodes().size() > 1) {\r
+                                       MessageDialog.openInformation(HandlerUtil.getActiveShell(event), \r
+                                               "Taxon implemented in multiple trees", \r
+                                               "One or both of these taxa is implemented in multiple taxonomic trees.");\r
+                                       return null;\r
+                               }\r
+                               \r
+                               // Close editor\r
+                               IEditorPart editor = HandlerUtil.getActiveEditor(event);\r
+                               boolean proceed = HandlerUtil.getActiveWorkbenchWindowChecked(event).getActivePage().\r
+                                                                       closeEditor(editor, true);\r
+                               if (!proceed) {\r
+                                       return null;\r
+                               }\r
+                               \r
+                               makeTaxonSynonym(oldTaxon, newTaxon, null, null, null);\r
+                                       \r
+                               conversation.commit();\r
+                               Set<TaxonNode> nodes = newTaxon.getTaxonNodes();\r
+                               UUID uuid = nodes.iterator().next().getUuid();\r
+                               \r
+                               EditorUtil.open(uuid);\r
+                                                       \r
+                       } catch (PartInitException e) {\r
+                               // TODO Auto-generated catch block\r
+                               e.printStackTrace();\r
+                       }\r
                        \r
-                       EditorUtil.open(uuid);\r
-                                               \r
-               } catch (PartInitException e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
+                       return null;\r
+               }finally{\r
+                       conversation.close();\r
                }\r
-               \r
-               return null;\r
        }\r
 \r
        /**\r
index 91b182c3b681de16aef6cc60b902d866e68c7aa1..0053f0e9876e8b53eb77ebacfdc413d9c81839e5 100644 (file)
@@ -193,6 +193,7 @@ public class TaxonNavigator extends CommonNavigator implements IConversationEnab
                if(conversation != null){\r
                        conversation.unregisterForDataStoreChanges(this);\r
                }\r
+               conversation.close();\r
        }\r
        \r
        /* (non-Javadoc)\r
index 9ac54c0de528fd3d0ac3b84e03393fa62df0c0b2..e4b22856599f4bc683efa2e90ae18745cca15352 100644 (file)
@@ -114,5 +114,14 @@ public class SearchResultView extends ViewPart implements IConversationEnabled{
                // TODO Auto-generated method stub\r
                \r
        }\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.part.WorkbenchPart#dispose()\r
+        */\r
+       @Override\r
+       public void dispose() {\r
+               super.dispose();\r
+               conversation.close();\r
+       }\r
 \r
 }\r
index 3424cf6a3a302f41c5a847a93f801132c4e4e83c..96c7e9ac04d171e395c4ff0c7109de719454e95b 100644 (file)
@@ -89,23 +89,26 @@ public class CreateTaxonomicTreeOperation extends AbstractPostOperation {
        private TaxonomicTree createTaxonomicTreeIsolated(){
                // get a new conversation
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();
-               
-               TaxonomicTree tree = TaxonomicTree.NewInstance(treeLabel);
-               ReferenceBase reference;
-               if(referenceUuid == null){
-                       reference = Generic.NewInstance();
-                       reference.setTitleCache(treeLabel);
-               }else{
-                       reference = CdmStore.getReferenceService().load(referenceUuid);
+               try{
+                       TaxonomicTree tree = TaxonomicTree.NewInstance(treeLabel);
+                       ReferenceBase reference;
+                       if(referenceUuid == null){
+                               reference = Generic.NewInstance();
+                               reference.setTitleCache(treeLabel);
+                       }else{
+                               reference = CdmStore.getReferenceService().load(referenceUuid);
+                       }
+                       
+                       tree.setReference(reference);
+                       tree.setMicroReference(microReference);
+                       
+                       CdmStore.getTaxonTreeService().save(tree);
+                       
+                       conversation.commit(true);
+                       
+                       return tree;
+               }finally{
+                       conversation.close();
                }
-               
-               tree.setReference(reference);
-               tree.setMicroReference(microReference);
-               
-               CdmStore.getTaxonTreeService().save(tree);
-               
-               conversation.commit(true);
-               
-               return tree;
        }
 }
index f67cc948da2e2f5efaa9f7f5456761a1d7debd44..dae227282f2cbbb3ff676b4288febc6a71d6e949 100644 (file)
@@ -118,13 +118,16 @@ public class DeleteTaxonNodeOperation extends AbstractPostOperation {
        private boolean deleteTaxonNodeIsolated(UUID taxonNodeUuid){\r
                // get a new conversation\r
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();\r
-               \r
-               TaxonNode taxonNode = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNodeUuid);\r
-               \r
-               boolean result = taxonNode.delete();\r
-               \r
-               // commit the conversation and throw it away\r
-               conversation.commit(true);\r
-               return result;\r
+               try{\r
+                       TaxonNode taxonNode = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNodeUuid);\r
+                       \r
+                       boolean result = taxonNode.delete();\r
+                       \r
+                       // commit the conversation and throw it away\r
+                       conversation.commit(true);\r
+                       return result;\r
+               }finally{\r
+                       conversation.close();\r
+               }\r
        }\r
 }\r
index 5dbd532911ec12b5bee78052036f9b3da912ef21..23addab596959309bbd90f4e479f59e379687a08 100644 (file)
@@ -105,12 +105,15 @@ public class DeleteTaxonomicTreeOperation extends AbstractPostOperation {
        private boolean deleteTaxonomicTreeIsolated(UUID uuid) {
                // get a new conversation
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();
-               
-               TaxonomicTree taxonomicTree = CdmStore.getTaxonTreeService().getTaxonomicTreeByUuid(uuid);
-               CdmStore.getTaxonTreeService().delete(taxonomicTree);
-
-               // commit the conversation
-               conversation.commit(true);      
-               return true;
+               try{
+                       TaxonomicTree taxonomicTree = CdmStore.getTaxonTreeService().getTaxonomicTreeByUuid(uuid);
+                       CdmStore.getTaxonTreeService().delete(taxonomicTree);
+       
+                       // commit the conversation
+                       conversation.commit(true);      
+                       return true;
+               }finally{
+                       conversation.close();
+               }
        }
 }
index 441079fd5aabacc6bfa5bfaaab30831da733bec0..49711953225537bfb243221b726d73c2479e5a86 100644 (file)
@@ -58,11 +58,15 @@ public class DeleteUserOperation extends AbstractPostOperation {
                        throws ExecutionException {
                
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();
-               user = CdmStore.getUserService().find(userUuid);
-               CdmStore.getUserService().delete(user);
-               conversation.commit();
-               
-               return postExecute(null);
+               try{
+                       user = CdmStore.getUserService().find(userUuid);
+                       CdmStore.getUserService().delete(user);
+                       conversation.commit();
+                       
+                       return postExecute(null);
+               }finally{
+                       conversation.close();
+               }
        }
 
        /* (non-Javadoc)
@@ -83,10 +87,14 @@ public class DeleteUserOperation extends AbstractPostOperation {
                        throws ExecutionException {
                
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();
-               // store uuid for consecutive undo/redo steps
-               userUuid = CdmStore.getUserService().save(user);
-               conversation.commit();
-               
-               return postExecute(null);
+               try{
+                       // store uuid for consecutive undo/redo steps
+                       userUuid = CdmStore.getUserService().save(user);
+                       conversation.commit();
+                       
+                       return postExecute(null);
+               }finally{
+                       conversation.close();
+               }
        }
 }
index 9dbbfe2e65d36c8cc835314fb83c66c31810e87b..91ddd259b66694f383516dafa93acf5c8eddad16 100644 (file)
@@ -99,20 +99,24 @@ public class MoveTaxonOperation extends AbstractPostOperation {
                \r
                // get a new conversation\r
                ConversationHolder conversation = CdmStore.NewTransactionalConversation();\r
-               // find the node\r
-               TaxonNode taxonNode = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNodeUuid);\r
-               \r
-               // find the new parent node\r
-               ITreeNode newParentTreeNode = CdmStore.getTaxonTreeService().getTreeNodeByUuid(newParentTreeNodeUuid);\r
-               // add node to new parent\r
                try{\r
-                       TaxonNode newChild = newParentTreeNode.addChildNode(taxonNode, newParentTreeNode.getReference(), newParentTreeNode.getMicroReference(), taxonNode.getSynonymToBeUsed());\r
-                       // commit the conversation\r
-                       conversation.commit(true);              \r
-                       return newChild;\r
-               }catch(IllegalAncestryException e){\r
-                       StoreUtil.warningDialog("Illegal ancestry", e.getMessage());\r
+                       // find the node\r
+                       TaxonNode taxonNode = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNodeUuid);\r
+                       \r
+                       // find the new parent node\r
+                       ITreeNode newParentTreeNode = CdmStore.getTaxonTreeService().getTreeNodeByUuid(newParentTreeNodeUuid);\r
+                       // add node to new parent\r
+                       try{\r
+                               TaxonNode newChild = newParentTreeNode.addChildNode(taxonNode, newParentTreeNode.getReference(), newParentTreeNode.getMicroReference(), taxonNode.getSynonymToBeUsed());\r
+                               // commit the conversation\r
+                               conversation.commit(true);              \r
+                               return newChild;\r
+                       }catch(IllegalAncestryException e){\r
+                               StoreUtil.warningDialog("Illegal ancestry", e.getMessage());\r
+                       }\r
+                       return null;\r
+               }finally{\r
+                       conversation.close();\r
                }\r
-               return null;\r
        }\r
 }\r
index 1e788b6861e1b0cf448546d7c388ce3d5e027bc3..aff4d3db7d23f946dadd6215f0e773683c0b4d64 100644 (file)
@@ -119,4 +119,13 @@ public class UserManagerView extends ViewPart implements IConversationEnabled, I
                // data changes can only be generate here at the moment
        }
        
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+        */
+       @Override
+       public void dispose() {
+               super.dispose();
+               conversation.close();
+       }
+       
 }