Finalizing PolytomousKeyListEditor
authorn.hoffmann <n.hoffmann@localhost>
Wed, 20 Apr 2011 14:57:25 +0000 (14:57 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 20 Apr 2011 14:57:25 +0000 (14:57 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/KeyEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyGraphEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/DeleteNodeHandler.java

index 046f702055e7deb47e626c72d2ff1d379897d47c..e303e0ff6299ec05972d13837cf65c13a9cd5041 100644 (file)
@@ -175,9 +175,9 @@ public class KeyEditor extends FormEditor implements IConversationEnabled,
                conversation.registerForDataStoreChanges(this);
 
                try {
-                       addPage(0, new PolytomousKeyListEditor(), input);
+                       addPage(0, new PolytomousKeyListEditor(this), input);
                        setPageText(0, "List");
-                       addPage(1, new PolytomousKeyGraphEditor(), input);
+                       addPage(1, new PolytomousKeyGraphEditor(this), input);
                        setPageText(1, "Graph");
                } catch (PartInitException e) {
                        EditorUtil.error(getClass(), e);
index 0bdd3625106a6a93db3fd44d4992dfa08d39b804..6eaddbfb1b3ce632cebeec504e04ca1dc3f75b70 100644 (file)
@@ -9,6 +9,7 @@ import org.eclipse.jface.viewers.IContentProvider;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
+import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
 
 /**
  * @author n.hoffmann
@@ -19,6 +20,14 @@ public class PolytomousKeyGraphEditor extends
                IPolytomousKeyEditorPage {
 
        public static final String ID = "eu.etaxonomy.taxeditor.editor.key.polytomous.graph";
+       private final KeyEditor editor;
+
+       /**
+        * @param keyEditor
+        */
+       public PolytomousKeyGraphEditor(KeyEditor editor) {
+               this.editor = editor;
+       }
 
        @Override
        public ConversationHolder getConversationHolder() {
index a5482753ccea4472d12368ac835ac3d35f72a0b6..324aad4ed932e41a0ceb1487f82570d66af2cb01 100644 (file)
@@ -43,6 +43,7 @@ import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
 
 /**
@@ -119,6 +120,12 @@ public class PolytomousKeyListEditor extends EditorPart implements
 
        private TableViewer viewer;
 
+       private final KeyEditor editor;
+
+       public PolytomousKeyListEditor(KeyEditor editor) {
+               this.editor = editor;
+       }
+
        /*
         * (non-Javadoc)
         * 
@@ -304,6 +311,9 @@ public class PolytomousKeyListEditor extends EditorPart implements
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                viewer.refresh();
+
+               editor.changed(objectAffectedByOperation);
+
                if (objectAffectedByOperation != null) {
                        viewer.setSelection(new StructuredSelection(
                                        objectAffectedByOperation), true);
@@ -318,8 +328,7 @@ public class PolytomousKeyListEditor extends EditorPart implements
         */
        @Override
        public boolean onComplete() {
-               // TODO Auto-generated method stub
-               return false;
+               return true;
        }
 
 }
index 2926c7d1adbbe904c7c3d1dc98923905d9d5f298..d9e42c575d974b0c05581c43f87ab89b75ab35f9 100644 (file)
@@ -56,12 +56,14 @@ public class DeleteNodeHandler extends AbstractHandler {
                                        String label = event.getCommand().getName();
                                        IUndoContext undoContext = EditorUtil.getUndoContext();
 
-                                       PolytomousKeyNode keyNode = (PolytomousKeyNode) selection
-                                                       .getFirstElement();
+                                       for (Object element : selection.toArray()) {
+                                               PolytomousKeyNode keyNode = (PolytomousKeyNode) element;
+
+                                               AbstractPostOperation operation = new DeleteNodeOperation(
+                                                               label, undoContext, keyNode, editorPage);
+                                               EditorUtil.executeOperation(operation);
+                                       }
 
-                                       AbstractPostOperation operation = new DeleteNodeOperation(
-                                                       label, undoContext, keyNode, editorPage);
-                                       EditorUtil.executeOperation(operation);
                                } catch (NotDefinedException e) {
                                        EditorUtil.warn(getClass(), "Command name not set.");
                                }