From c3ea59680ce2f7d4973f975963657e125c871832 Mon Sep 17 00:00:00 2001 From: Patric Plitzner Date: Tue, 27 Aug 2013 17:07:27 +0000 Subject: [PATCH] - added creation of FieldUnits via wizard to bulk editor --- .../command/DynamicNewObjectMenu.java | 37 +++++++++---------- .../newWizard/NewDerivedUnitBaseWizard.java | 23 ++++++++---- .../specimen/SpecimenGeneralElement.java | 16 +++++--- .../taxeditor/view/detail/DetailsViewer.java | 14 +++++-- 4 files changed, 54 insertions(+), 36 deletions(-) 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 cf09eda13..bc9116b1e 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 @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* 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. */ @@ -26,7 +26,6 @@ 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; @@ -42,7 +41,7 @@ import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; public class DynamicNewObjectMenu extends CompoundContributionItem { private static final Logger logger = Logger .getLogger(DynamicNewObjectMenu.class); - + private IHandlerService handlerService = (IHandlerService) BulkEditorUtil.getService(IHandlerService.class); private Map classLabelPairs; /* (non-Javadoc) @@ -51,15 +50,16 @@ public class DynamicNewObjectMenu extends CompoundContributionItem { /** {@inheritDoc} */ @Override protected IContributionItem[] getContributionItems() { - + classLabelPairs = getClassLabelPairs(); - + return new IContributionItem[] { new ContributionItem() { - public void fill(Menu menu, int index){ + @Override + public void fill(Menu menu, int index){ for(final Object key : classLabelPairs.keySet()){ createMenuItem(menu, key); - } + } } } }; @@ -70,9 +70,11 @@ public class DynamicNewObjectMenu extends CompoundContributionItem { menuItem.setText(classLabelPairs.get(key)); menuItem.addSelectionListener(new SelectionListener(){ - public void widgetDefaultSelected(SelectionEvent e) {} + @Override + public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent ev) { + @Override + public void widgetSelected(SelectionEvent ev) { Event event = new Event(); event.data = key; event.text = classLabelPairs.get(key); @@ -82,15 +84,10 @@ public class DynamicNewObjectMenu extends CompoundContributionItem { logger.error("Error executing command", e); throw new RuntimeException("Error executing command", e); } - } + } }); - - //FIXME:3.3MC Need corresponding Details Viewer section for FieldUnit - if(key == SpecimenOrObservationType.FieldUnit){ - menuItem.setEnabled(false); - } } - + /** * Get class label pairs from Annotated Line Editor's entity creator. * @return @@ -99,13 +96,13 @@ public class DynamicNewObjectMenu extends CompoundContributionItem { IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editor != null){ IEditorInput input = editor.getEditorInput(); - + if(input instanceof AbstractBulkEditorInput){ IEntityCreator entityCreator = ((AbstractBulkEditorInput) input).getEntityCreator(); return entityCreator.getKeyLabelPairs(); } } - + return null; - } + } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java index 1dfb04352..59ba07120 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java @@ -14,7 +14,9 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; import eu.etaxonomy.cdm.api.service.IOccurrenceService; import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; +import eu.etaxonomy.cdm.model.occurrence.FieldUnit; import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen; +import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.store.CdmStore; @@ -30,7 +32,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage; * @created Jun 16, 2010 * @version 1.0 */ -public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard { +public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard> { private SpecimenOrObservationType specOrObsType = null; public NewDerivedUnitBaseWizard() { @@ -47,16 +49,21 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard createNewEntity() { if(specOrObsType == null) { return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); } else { @@ -73,6 +80,8 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard