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;
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);
+ }
}
}
+++ /dev/null
-// $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();
- }
-}
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
- AbstractCdmDetailElement<PolytomousKey> {
+ AbstractIdentifiableEntityDetailElement<PolytomousKey> {
public PolytomousKeyDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
super(formFactory, formElement);
}
- private ToggleableTextElement text_title;
-
@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);
}
*/
@Override
public void handleEvent(Object eventSource) {
- if (eventSource == text_title) {
- getEntity().setTitleCache(text_title.getText());
- }
+ handleToggleableCacheField();
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
}