Fixes #2436; PolytomousKeyListView now allows deletion of multiple elements
authorn.hoffmann <n.hoffmann@localhost>
Mon, 6 Jun 2011 11:38:53 +0000 (11:38 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 6 Jun 2011 11:38:53 +0000 (11:38 +0000)
.gitattributes
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ClassificationWizardPage.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/PolytomousKeyWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java

index b3fca189543db0cdef09a9ff7871837c9c528b21..c74e3df114e2456a2f584af68edeb3ef2802fc70 100644 (file)
@@ -806,7 +806,6 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonTra
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TextHelper.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TimeHelper.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TextHelper.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TimeHelper.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java -text
-eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ClassificationWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ExternalReferenceServiceWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewClassificationWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewCollectionWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ExternalReferenceServiceWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewClassificationWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewCollectionWizard.java -text
index a916177ffff382ed476272aa6f752fa7b08619ce..ede0de647847c1f9670a21bb166d2ba9e1951577 100644 (file)
@@ -10,6 +10,8 @@
 
 package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
 
 
 package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
 
+import java.util.List;
+
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -37,19 +39,27 @@ public class DeleteHandler extends AbstractHandler {
        public Object execute(ExecutionEvent event) throws ExecutionException {
                IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
                
        public Object execute(ExecutionEvent event) throws ExecutionException {
                IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
                
-               PolytomousKey key = (PolytomousKey) selection.getFirstElement();
+               List<PolytomousKey> keys = selection.toList();
+               
+               if(keys.isEmpty()){
+                       return null;
+               }
+               
+               boolean confirmation = NavigationUtil.confirmDialog("Confirm deletaion", "Do you want to delete the selected key" + (keys.size() == 1 ? "" : "s") + "?");
                
                
-               if(NavigationUtil.confirmDialog("Confirm deletaion", "Do you really want to delete the key: " + key.getTitleCache())){
+               if(confirmation){
                
                
-                       try {
-                               AbstractPostOperation operation = new DeleteOperation(
-                                               event.getCommand().getName(),
-                                               NavigationUtil.getUndoContext(), key, 
-                                               (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false),
-                                               (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false));
-                               NavigationUtil.executeOperation(operation);
-                       } catch (NotDefinedException e) {
-                               NavigationUtil.error(getClass(), e);
+                       for(PolytomousKey key : keys){
+                               try {
+                                       AbstractPostOperation operation = new DeleteOperation(
+                                                       event.getCommand().getName(),
+                                                       NavigationUtil.getUndoContext(), key, 
+                                                       (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false),
+                                                       (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false));
+                                       NavigationUtil.executeOperation(operation);
+                               } catch (NotDefinedException e) {
+                                       NavigationUtil.error(getClass(), e);
+                               }
                        }
                }
                
                        }
                }
                
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ClassificationWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/ClassificationWizardPage.java
deleted file mode 100644 (file)
index 544ad4e..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-// $Id$
-/**
- * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
- * http://www.e-taxonomy.eu
- * 
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * See LICENSE.TXT at the top of this package for the full license terms.
- */
-
-package eu.etaxonomy.taxeditor.newWizard;
-
-import org.apache.log4j.Logger;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.model.common.LanguageString;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
-import eu.etaxonomy.taxeditor.ui.forms.RootElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
-
-/**
- * <p>
- * ClassificationWizardPage class.
- * </p>
- * 
- * @author n.hoffmann
- * @created Sep 29, 2010
- * @version 1.0
- */
-@Deprecated
-// remove this file when refactoring is complete
-public class ClassificationWizardPage extends WizardPage implements
-               IPropertyChangeListener, IConversationEnabled {
-       private static final Logger logger = Logger
-                       .getLogger(ClassificationWizardPage.class);
-       private Classification classification;
-
-       private final ConversationHolder conversation;
-       private final CdmFormFactory formFactory;
-       private Composite control;
-       private TextWithLabelElement text_classificationLabel;
-       private ReferenceSelectionElement selection_reference;
-       private TextWithLabelElement text_referenceDetail;
-
-       /**
-        * <p>
-        * Constructor for ClassificationWizardPage.
-        * </p>
-        * 
-        * @param conversation
-        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *            object.
-        * @param classification
-        *            a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
-        */
-       protected ClassificationWizardPage(ConversationHolder conversation,
-                       Classification classification) {
-               super("Classification");
-               this.setTitle("Classification");
-               this.setDescription(classification == null ? "Create a new Classification."
-                               : "Edit Classification.");
-
-               this.classification = classification;
-               this.conversation = conversation;
-
-               this.formFactory = new CdmFormFactory(Display.getCurrent());
-
-               formFactory.addPropertyChangeListener(this);
-
-               initialize();
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
-        * .Composite)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void createControl(Composite parent) {
-               control = formFactory.createComposite(parent);
-
-               control.setLayout(CdmFormFactory.LAYOUT(2, false));
-               RootElement rootElement = new RootElement(formFactory, control);
-
-               text_classificationLabel = formFactory.createTextWithLabelElement(
-                               rootElement, "Label", classification.getName().getText(),
-                               SWT.NULL);
-               selection_reference = (ReferenceSelectionElement) formFactory
-                               .createSelectionElement(SelectionType.REFERENCE,
-                                               getConversationHolder(), rootElement, "Reference",
-                                               classification.getReference(),
-                                               ReferenceSelectionElement.DEFAULT, SWT.NULL);
-               text_referenceDetail = formFactory.createTextWithLabelElement(
-                               rootElement, "Reference Detail",
-                               classification.getMicroReference(), SWT.NULL);
-
-               Color bgColor = getShell().getBackground();
-
-               rootElement.setBackground(bgColor);
-               control.setBackground(bgColor);
-
-               setControl(control);
-       }
-
-       private void initialize() {
-               if (classification == null) {
-                       classification = Classification.NewInstance(null, null,
-                                       CdmStore.getDefaultLanguage());
-               }
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
-        * .jface.util.PropertyChangeEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void propertyChange(PropertyChangeEvent event) {
-               Object eventSource = event.getSource();
-
-               if (eventSource == text_classificationLabel) {
-                       classification.setName(LanguageString.NewInstance(
-                                       text_classificationLabel.getText(),
-                                       CdmStore.getDefaultLanguage()));
-               } else if (eventSource == selection_reference) {
-                       classification.setReference(selection_reference.getEntity());
-               } else if (eventSource == text_referenceDetail) {
-                       classification.setMicroReference(text_referenceDetail.getText());
-               }
-
-               checkComplete();
-       }
-
-       /**
-        * 
-        */
-       private void checkComplete() {
-               if (CdmUtils.isEmpty(text_classificationLabel.getText())) {
-                       setMessage("A Classifications label may not be empty");
-                       setPageComplete(false);
-               } else {
-                       setMessage(null);
-                       setPageComplete(true);
-               }
-       }
-
-       /**
-        * <p>
-        * Getter for the field <code>classification</code>.
-        * </p>
-        * 
-        * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
-        */
-       public Classification getClassification() {
-               return classification;
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
-        * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void update(CdmDataChangeMap changeEvents) {
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
-        * ()
-        */
-       /** {@inheritDoc} */
-       @Override
-       public ConversationHolder getConversationHolder() {
-               return conversation;
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void dispose() {
-               formFactory.removePropertyChangeListener(this);
-               super.dispose();
-       }
-}
index 795f0175c3e2040dcf2beef699961f4c06ae94a1..7b02512df4a39472706740444e67693171ae93ba 100644 (file)
@@ -29,6 +29,7 @@ public class PolytomousKeyWizardPage extends AbstractCdmEntityWizardPage<Polytom
        public AbstractCdmDetailElement createElement(ICdmFormElement rootElement) {
                PolytomousKeyDetailElement element = (PolytomousKeyDetailElement) formFactory.createCdmDetailElement(DetailType.POLYTOMOUS_KEY, rootElement, SWT.NULL);
                element.setEntity(entity);
        public AbstractCdmDetailElement createElement(ICdmFormElement rootElement) {
                PolytomousKeyDetailElement element = (PolytomousKeyDetailElement) formFactory.createCdmDetailElement(DetailType.POLYTOMOUS_KEY, rootElement, SWT.NULL);
                element.setEntity(entity);
+               setPageComplete(true);
                return element;
        }
 }
                return element;
        }
 }
index e94f2f2ff537eb769554928f25fb7d4c6ff40d02..39d9594521e9432f12a37d10b85540bf7996383b 100644 (file)
@@ -11,25 +11,24 @@ import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.forms.ToggleableTextElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
 
 /**
  * @author n.hoffmann
  * 
  */
 public class PolytomousKeyDetailElement extends
 
 /**
  * @author n.hoffmann
  * 
  */
 public class PolytomousKeyDetailElement extends
-               AbstractCdmDetailElement<PolytomousKey> {
+               AbstractIdentifiableEntityDetailElement<PolytomousKey> {
 
        public PolytomousKeyDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
                super(formFactory, formElement);
        }
 
 
        public PolytomousKeyDetailElement(CdmFormFactory formFactory,
                        ICdmFormElement formElement) {
                super(formFactory, formElement);
        }
 
-       private ToggleableTextElement text_title;
-
        @Override
        protected void createControls(ICdmFormElement formElement,
                        PolytomousKey entity, int style) {
        @Override
        protected void createControls(ICdmFormElement formElement,
                        PolytomousKey entity, int style) {
-               text_title = formFactory.createToggleableTextField(formElement,
+               toggleable_cache = formFactory.createToggleableTextField(formElement,
                                "Title Cache", entity.getTitleCache(),
                                entity.isProtectedTitleCache(), SWT.NULL);
        }
                                "Title Cache", entity.getTitleCache(),
                                entity.isProtectedTitleCache(), SWT.NULL);
        }
@@ -43,9 +42,7 @@ public class PolytomousKeyDetailElement extends
         */
        @Override
        public void handleEvent(Object eventSource) {
         */
        @Override
        public void handleEvent(Object eventSource) {
-               if (eventSource == text_title) {
-                       getEntity().setTitleCache(text_title.getText());
-               }
+               handleToggleableCacheField();
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 }
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 }