From 0a534d095fa23c6ebad41e2b2c4635d636a89581 Mon Sep 17 00:00:00 2001 From: Patric Plitzner
Constructor for ChangeHomotypicGroupOperation.
* @@ -55,16 +55,16 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation { * @param newHomotypicalGroup a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object. * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. */ - public ChangeHomotypicGroupOperation(String label, IUndoContext undoContext, + public ChangeHomotypicGroupOperation(String label, IUndoContext undoContext, Taxon taxon, Synonym synonym, HomotypicalGroup newHomotypicalGroup, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); - + this.synonym = synonym; if(synonym == null){ throw new IllegalArgumentException( "A null synonym was provided."); } - + this.oldHomotypicalGroup = synonym.getHomotypicGroup(); this.newHomotypicalGroup = newHomotypicalGroup != null ? newHomotypicalGroup : HomotypicalGroup.NewInstance(); } @@ -76,32 +76,32 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation { @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Get synonym name TaxonNameBase, ?> synonymName = synonym.getName(); monitor.worked(20); - + // TODO pass in homotypical group's taxon in case we are dragging from one editor to another - + // Switch groups oldHomotypicalGroup.removeTypifiedName(synonymName); monitor.worked(40); newHomotypicalGroup.addTypifiedName(synonymName); - - if(! synonym.getAcceptedTaxa().contains(taxon)){ + + if(! synonym.getAcceptedTaxa().contains(element)){ for(Taxon acceptedTaxon : synonym.getAcceptedTaxa()){ acceptedTaxon.removeSynonym(synonym); } - + SynonymRelationshipType type = SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(); - if(newHomotypicalGroup.getTypifiedNames().contains(taxon.getName())){ + if(newHomotypicalGroup.getTypifiedNames().contains(element.getName())){ type = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF(); } - - taxon.addSynonym(synonym, type); + + element.addSynonym(synonym, type); } - + // Redraw editor if it exists return postExecute(synonym); } @@ -123,19 +123,19 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Get synonym name TaxonNameBase, ?> synonymName = this.synonym.getName(); if(synonymName == null){ // TODO } - + // TODO pass in homotypical group's taxon in case we are dragging from one editor to another - + // Switch groups newHomotypicalGroup.removeTypifiedName(synonymName); - oldHomotypicalGroup.addTypifiedName(synonymName); - + oldHomotypicalGroup.addTypifiedName(synonymName); + // Redraw editor if it exists return postExecute(synonym); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java index 5d8b351fd..2c7f81315 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java @@ -22,11 +22,10 @@ import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.Synonym; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; -import eu.etaxonomy.taxeditor.editor.EditorUtil; +import eu.etaxonomy.taxeditor.model.AbstractUtility; import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; import eu.etaxonomy.taxeditor.store.CdmStore; -import eu.etaxonomy.taxeditor.store.StoreUtil; /** * Change the taxonomic parent of a given taxon. @@ -38,12 +37,12 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation { private Taxon newTaxon; - private Synonym synonym; - private ITaxonTreeNode parentNode; + private final Synonym synonym; + private final ITaxonTreeNode parentNode; private TaxonNode newNode; - private Synonym[] synonymsInHomotypicalGroup; + private final Synonym[] synonymsInHomotypicalGroup; /** *Constructor for ChangeSynonymToAcceptedTaxonOperation.
@@ -61,7 +60,7 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos Taxon taxon, ITaxonTreeNode parentNode, Synonym synonym, Synonym[] synonymsInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { super(label, undoContext, postOperationEnabled, conversationEnabled); - this.taxon = taxon; + this.element = taxon; this.parentNode = parentNode; this.synonym = synonym; this.synonymsInHomotypicalGroup = synonymsInHomotypicalGroup; @@ -76,9 +75,9 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos throws ExecutionException { try { - newTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym, taxon, true, true, null, null); + newTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym, element, true, true, null, null); } catch (HomotypicalGroupChangeException e) { - EditorUtil.warningDialog("Operation may lead to inconsistent data", getClass(), e.getMessage()); + AbstractUtility.warningDialog("Operation may lead to inconsistent data", getClass(), e.getMessage()); return postExecute(null); } monitor.worked(20); @@ -117,9 +116,9 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos throws ExecutionException { // TODO implement - biggest problem is that any window open for new taxon must be closed first - StoreUtil.warn(this.getClass(), "Not yet implemented"); + AbstractUtility.warn(this.getClass(), "Not yet implemented"); - return postExecute(taxon); + return postExecute(element); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperation.java index 95ae23f9d..5bcc43ef5 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -32,9 +32,9 @@ import eu.etaxonomy.taxeditor.store.CdmStore; * @version 1.0 */ public class ChangeSynonymToConceptOperation extends AbstractPostTaxonOperation { - private Synonym synonym; - private TaxonRelationshipType taxonRelationshipType; - + private final Synonym synonym; + private final TaxonRelationshipType taxonRelationshipType; + /** *Constructor for ChangeSynonymToConceptOperation.
* @@ -48,10 +48,10 @@ public class ChangeSynonymToConceptOperation extends AbstractPostTaxonOperation public ChangeSynonymToConceptOperation(String label, IUndoContext undoContext, Taxon taxon, Synonym synonym, TaxonRelationshipType taxonRelationshipType, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); - + this.taxonRelationshipType = taxonRelationshipType; this.synonym = synonym; - + } /* (non-Javadoc) @@ -64,20 +64,20 @@ public class ChangeSynonymToConceptOperation extends AbstractPostTaxonOperation // // Get name from synonym // TaxonNameBase, ?> synonymName = synonym.getName(); -// +// // // remove synonym from taxon // taxon.removeSynonym(synonym); -// +// // // Create a taxon with synonym name // Taxon fromTaxon = Taxon.NewInstance(synonymName, null); -// -// // Add taxon relation +// +// // Add taxon relation // fromTaxon.addTaxonRelation(taxon, taxonRelationshipType, null, null); monitor.worked(20); - Taxon fromTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, taxon, taxonRelationshipType, null, null); + Taxon fromTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, element, taxonRelationshipType, null, null); monitor.worked(40); - + // TaxonRelationshipType. // logger.warn("Not yet implemented."); diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java index 86490aa85..3bd310bd3 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -37,7 +37,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore; */ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOperation { - private Synonym synonym; + private final Synonym synonym; private Taxon misapplication; private SetConstructor for CreateSynonymInExistingHomotypicalGroupOperation.
* @@ -61,29 +61,29 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Add name to given homotypic group group.addTypifiedName(newSynonymName); monitor.worked(20); - + // Create a new synonym for the taxon // TODO add citations - if(group.equals(taxon.getHomotypicGroup())){ - synonymRelationship = taxon.addHomotypicSynonymName(newSynonymName, null, null); + if(group.equals(element.getHomotypicGroup())){ + synonymRelationship = element.addHomotypicSynonymName(newSynonymName, null, null); }else{ - synonymRelationship = taxon.addHeterotypicSynonymName(newSynonymName); + synonymRelationship = element.addHeterotypicSynonymName(newSynonymName); } monitor.worked(40); - + // Synonym affectedSynonym = null; -// +// // for(Synonym synonym : group.getSynonymsInGroup(taxon.getSec())){ // if(synonym.getName() == synonymName){ // affectedSynonym = synonym; // break; // } // } - + return postExecute(synonymRelationship.getSynonym()); } @@ -105,8 +105,8 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - taxon.removeSynonymRelation(synonymRelationship); - + element.removeSynonymRelation(synonymRelationship); + return postExecute(null); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java index aaadbb1a8..6fca0efc6 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -35,9 +35,9 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation { - + // TODO replace this with TaxonNameBase - private TaxonNameBase newSynonymName; + private final TaxonNameBase newSynonymName; private SynonymRelationship newSynonymRelationship; /** @@ -52,7 +52,7 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation public CreateSynonymInNewGroupOperation(String label, IUndoContext undoContext, Taxon taxon, TaxonNameBase newSynonymName, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); - + this.newSynonymName = newSynonymName; } @@ -63,13 +63,13 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Add name to new homotypic group HomotypicalGroup.NewInstance().addTypifiedName(newSynonymName); monitor.worked(20); - + // Create a new synonym for the taxon - newSynonymRelationship = taxon.addHeterotypicSynonymName(newSynonymName); + newSynonymRelationship = element.addHeterotypicSynonymName(newSynonymName); monitor.worked(40); return postExecute(newSynonymRelationship.getSynonym()); @@ -92,11 +92,11 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - // Remove the synonym - taxon.removeSynonymRelation(newSynonymRelationship); + + // Remove the synonym + element.removeSynonymRelation(newSynonymRelationship); newSynonymRelationship = null; - + return postExecute(null); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java index 1874fa2eb..fb4856897 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -30,8 +30,8 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class DeleteMisapplicationOperation extends AbstractPostTaxonOperation { - - private Taxon misapplication; + + private final Taxon misapplication; private Reference> citation; @@ -49,7 +49,7 @@ public class DeleteMisapplicationOperation extends AbstractPostTaxonOperation { public DeleteMisapplicationOperation(String label, IUndoContext undoContext, Taxon taxon, Taxon misapplication, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); - + this.misapplication = misapplication; } @@ -62,7 +62,7 @@ public class DeleteMisapplicationOperation extends AbstractPostTaxonOperation { throws ExecutionException { // Find misapplication relation, save citation information - for (TaxonRelationship relationship : taxon.getTaxonRelations()) { + for (TaxonRelationship relationship : element.getTaxonRelations()) { if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) && relationship.getFromTaxon().equals(misapplication)) { citation = relationship.getCitation(); @@ -70,9 +70,9 @@ public class DeleteMisapplicationOperation extends AbstractPostTaxonOperation { } } monitor.worked(20); - + // Remove misapplied name relation from taxon - taxon.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR()); + element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR()); monitor.worked(40); return postExecute(null); @@ -95,9 +95,9 @@ public class DeleteMisapplicationOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - taxon.addMisappliedName(misapplication, citation, microcitation); - + + element.addMisappliedName(misapplication, citation, microcitation); + return postExecute(misapplication); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java index 4ba88a6d3..cba17dc07 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -34,8 +34,8 @@ import eu.etaxonomy.taxeditor.store.CdmStore; * @version 1.0 */ public class DeleteSynonymOperation extends AbstractPostTaxonOperation { - - private Synonym synonym; + + private final Synonym synonym; private SetConstructor for SwapSynonymAndAcceptedOperation.
* @@ -53,7 +50,7 @@ public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext, Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) { super("Swap Synonym And Accepted Taxon Operation", undoContext, taxon, postOperationEnabled); - + this.synonym = synonym; } @@ -64,14 +61,14 @@ public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + monitor.worked(20); - - CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym, taxon); - + + CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym, element); + monitor.worked(40); - return postExecute(taxon); + return postExecute(element); } /* (non-Javadoc) diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java index a92057d36..40c92af92 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -30,10 +30,10 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class CreateConceptRelationOperation extends AbstractPostTaxonOperation { - - private Taxon concept; - private TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer; - + + private final Taxon concept; + private final TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer; + /** *Constructor for CreateConceptRelationOperation.
* @@ -51,7 +51,7 @@ public class CreateConceptRelationOperation extends AbstractPostTaxonOperation { this.concept = concept; this.taxonRelationshipTypeInverseContainer = taxonRelationshipTypeInverseContainer; } - + public CreateConceptRelationOperation(String label, IUndoContext undoContext, Taxon taxon, Taxon concept, TaxonRelationshipType taxonRelationshipType , IPostOperationEnabled postOperationEnabled) { @@ -69,12 +69,12 @@ public class CreateConceptRelationOperation extends AbstractPostTaxonOperation { monitor.worked(20); // add concept to taxon if(taxonRelationshipTypeInverseContainer.isInverse()){ - concept.addTaxonRelation(taxon, taxonRelationshipTypeInverseContainer.getType(), null, null); + concept.addTaxonRelation(element, taxonRelationshipTypeInverseContainer.getType(), null, null); } else { - taxon.addTaxonRelation(concept, taxonRelationshipTypeInverseContainer.getType(), null, null); + element.addTaxonRelation(concept, taxonRelationshipTypeInverseContainer.getType(), null, null); } monitor.worked(40); - + // redraw editor if exists return postExecute(concept); } @@ -96,9 +96,9 @@ public class CreateConceptRelationOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - taxon.removeTaxon(concept, taxonRelationshipTypeInverseContainer.getType()); - + + element.removeTaxon(concept, taxonRelationshipTypeInverseContainer.getType()); + // redraw editor if exists return postExecute(null); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java index 4e6a243dd..9f71fae56 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -31,8 +31,8 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class DeleteConceptRelationOperation extends AbstractPostTaxonOperation { - - private SetConstructor for CreateTaxonDescriptionOperation.
@@ -59,7 +58,7 @@ public class CreateTaxonDescriptionOperation extends AbstractPostDescribableOper * @param isImageGallery a boolean. */ public CreateTaxonDescriptionOperation(String label, IUndoContext undoContext, - Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) { + Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) { super(label, undoContext, taxon, postOperationEnabled); this.isImageGallery = isImageGallery; @@ -73,7 +72,7 @@ public class CreateTaxonDescriptionOperation extends AbstractPostDescribableOper public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - description = TaxonDescription.NewInstance(taxon); + description = TaxonDescription.NewInstance(element); monitor.worked(20); if(isImageGallery){ @@ -96,7 +95,7 @@ public class CreateTaxonDescriptionOperation extends AbstractPostDescribableOper public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - describable.addDescription(description); + element.addDescription(description); return postExecute(description); } @@ -109,7 +108,7 @@ public class CreateTaxonDescriptionOperation extends AbstractPostDescribableOper public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - describable.removeDescription(description); + element.removeDescription(description); return postExecute(null); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java index fa8c8762a..daa0394da 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/DeleteTaxonDescriptionOperation.java @@ -1,8 +1,8 @@ /** * 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. */ @@ -28,8 +28,8 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class DeleteTaxonDescriptionOperation extends AbstractPostTaxonOperation { - - private TaxonDescription description; + + private final TaxonDescription description; /** *Constructor for DeleteTaxonDescriptionOperation.
@@ -42,9 +42,9 @@ public class DeleteTaxonDescriptionOperation extends AbstractPostTaxonOperation public DeleteTaxonDescriptionOperation(String label, IUndoContext undoContext, TaxonDescription description, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, postOperationEnabled); - + this.description = description; - taxon = description.getTaxon(); + element = description.getTaxon(); } /* (non-Javadoc) @@ -56,7 +56,7 @@ public class DeleteTaxonDescriptionOperation extends AbstractPostTaxonOperation throws ExecutionException { monitor.worked(20); - taxon.removeDescription(description); + element.removeDescription(description); monitor.worked(40); return postExecute(description); @@ -80,8 +80,8 @@ public class DeleteTaxonDescriptionOperation extends AbstractPostTaxonOperation public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - taxon.addDescription(description); - + element.addDescription(description); + return postExecute(null); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/CreateImageOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/CreateImageOperation.java index e505d1389..f6025c0d9 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/CreateImageOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/CreateImageOperation.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. */ @@ -31,10 +31,10 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @version 1.0 */ public class CreateImageOperation extends AbstractPostTaxonOperation { - + private ImageFile imageFile; - private DescriptionBase> description; + private final DescriptionBase> description; /** *Constructor for CreateImageOperation.
@@ -67,7 +67,7 @@ public class CreateImageOperation extends AbstractPostTaxonOperation { super(label, undoContext, taxon, postOperationEnabled); this.description = description; } - + /* (non-Javadoc) * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) */ @@ -75,13 +75,13 @@ public class CreateImageOperation extends AbstractPostTaxonOperation { @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + if (imageFile == null) { imageFile = ImageFile.NewInstance(null, null); } monitor.worked(20); - ImagesUtility.addTaxonImage(taxon, description, imageFile); + ImagesUtility.addTaxonImage(element, description, imageFile); monitor.worked(40); return postExecute(imageFile); @@ -94,9 +94,9 @@ public class CreateImageOperation extends AbstractPostTaxonOperation { @Override public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - ImagesUtility.addTaxonImage(taxon, description, imageFile); - + + ImagesUtility.addTaxonImage(element, description, imageFile); + return postExecute(imageFile); } @@ -107,9 +107,9 @@ public class CreateImageOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - ImagesUtility.removeTaxonImage(taxon, description, imageFile); - + + ImagesUtility.removeTaxonImage(element, description, imageFile); + return postExecute(null); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java index f312a1a42..8f1c80849 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java @@ -1,15 +1,13 @@ /** * Copyright (C) 2011 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. */ package eu.etaxonomy.taxeditor.editor.view.uses.operation; -import java.util.UUID; - import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.runtime.IAdaptable; @@ -28,7 +26,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore; /** * CreateTaxonUseOperation Class - * @author a.theys + * @author a.theys * @created mar 13, 2012 * @version 1.0 */ @@ -62,7 +60,7 @@ public class CreateTaxonUseOperation extends CreateTaxonDescriptionOperation { Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) { super(label, undoContext, taxon, postOperationEnabled); } - + /* (non-Javadoc) * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) */ @@ -70,8 +68,8 @@ public class CreateTaxonUseOperation extends CreateTaxonDescriptionOperation { @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - description = TaxonDescription.NewInstance(taxon); + + description = TaxonDescription.NewInstance(element); monitor.worked(20); MarkerType useMarkerType = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); marker = Marker.NewInstance(useMarkerType, true); diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java index d33a439b7..28b7b2011 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java @@ -21,7 +21,7 @@ import eu.etaxonomy.cdm.model.description.Feature; import eu.etaxonomy.cdm.model.description.TaxonDescription; import eu.etaxonomy.cdm.model.description.TextData; import eu.etaxonomy.cdm.model.taxon.Taxon; -import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; +import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; @@ -31,7 +31,7 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @created mar 13, 2012 * @version 1.0 */ -public class CreateUseRecordOperation extends AbstractPostTaxonOperation { +public class CreateUseRecordOperation extends AbstractPostOperation { /** ConstantID="eu.etaxonomy.taxeditor.editor.view.use."{trunked}
*/
public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseSummaryOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseSummaryOperation.java
index b478f00ba..80c85db61 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseSummaryOperation.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseSummaryOperation.java
@@ -20,7 +20,7 @@ import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -30,7 +30,7 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
* @created mar 13, 2012
* @version 1.0
*/
-public class CreateUseSummaryOperation extends AbstractPostTaxonOperation {
+public class CreateUseSummaryOperation extends AbstractPostOperation {
public static final String ID = "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
index 9cd017a22..1f9cea4df 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
@@ -17,27 +17,21 @@ import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-import eu.etaxonomy.cdm.api.application.CdmApplicationController;
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
-import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.common.ITreeNode;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* DeleteTreeNodeOperation class.
@@ -49,7 +43,7 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; public class DeleteOperation extends AbstractPersistentPostOperation{ private SetConstructor for AbstractPostOperation.
+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. */ - public AbstractPostOperation(String label) { + protected AbstractPostOperation(String label, IUndoContext undoContext) { super(label); + addContext(undoContext); + } + + /** + *Constructor for AbstractPostOperation.
+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param element a {@link ICdmBase} object on which this operation is working. + */ + public AbstractPostOperation(String label, IUndoContext undoContext, T element) { + this(label, undoContext); + this.element = element; + } + + /** + * @param label + * @param element + * @param postOperationEnabled + */ + public AbstractPostOperation(String label, IUndoContext undoContext, + T element, IPostOperationEnabled postOperationEnabled) { + this(label, undoContext); + this.element = element; + this.postOperationEnabled = postOperationEnabled; } /** @@ -42,7 +79,7 @@ public abstract class AbstractPostOperation extends AbstractOperation { * @param objectAffectedByOperation the affected object. Should benull
if not needed
* @return a {@link org.eclipse.core.runtime.IStatus} object.
*/
- protected IStatus postExecute(CdmBase objectAffectedByOperation) {
+ protected IStatus postExecute(CdmBase objectAffectedByOperation) {
if(postOperationEnabled != null){
return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java
index 6c75b7987..b37c54010 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java
@@ -1,8 +1,8 @@
/**
* 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.
*/
@@ -25,12 +25,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
* @created 14.01.2009
* @version 1.0
*/
-public abstract class AbstractPostTaxonOperation extends AbstractPostOperation {
-
- /**
- * A reference to the taxon the concrete operation is working on
- */
- protected Taxon taxon;
+public abstract class AbstractPostTaxonOperation extends AbstractPostOperationConstructor for AbstractPostOperation.
- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - */ - protected AbstractPostTaxonOperation(String label, IUndoContext undoContext) { - super(label); - addContext(undoContext); - } - - /** - *Constructor for AbstractPostOperation.
- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. - */ - public AbstractPostTaxonOperation(String label, IUndoContext undoContext, - Taxon taxon) { - this(label, undoContext); - - this.taxon = taxon; - } - + /** *Constructor for AbstractPostOperation.
* @@ -74,10 +45,9 @@ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { */ public AbstractPostTaxonOperation(String label, IUndoContext undoContext, Taxon taxon, IPostOperationEnabled postOperationEnabled) { - this(label, undoContext, taxon); - this.postOperationEnabled = postOperationEnabled; + super(label, undoContext, taxon, postOperationEnabled); } - + /** *Constructor for AbstractPostOperation.
* @@ -90,7 +60,7 @@ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled); this.taxonNode = taxonNode; } - + /** *Constructor for AbstractPostOperation.
* @@ -100,12 +70,10 @@ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. */ public AbstractPostTaxonOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){ - this(label, undoContext); - + super(label, undoContext, null, postOperationEnabled); this.parentNodeUuid = parentNodeUuid; - this.postOperationEnabled = postOperationEnabled; } - + /** *Constructor for AbstractPostOperation.
* @@ -115,9 +83,15 @@ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { */ public AbstractPostTaxonOperation(String label, IUndoContext undoContext, IPostOperationEnabled postOperationEnabled) { - this(label, undoContext); - this.postOperationEnabled = postOperationEnabled; + super(label, undoContext, null, postOperationEnabled); } - - + + /** + * @param text + * @param undoContext + * @param taxon + */ + public AbstractPostTaxonOperation(String label, IUndoContext undoContext, Taxon taxon) { + this(label, undoContext, taxon, null); + } } -- 2.34.1