From: Patric Plitzner Date: Wed, 4 Dec 2013 08:34:15 +0000 (+0000) Subject: - adapted sub classes of AbstractPostOperation X-Git-Tag: 3.6.0~841^2~44 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/0a534d095fa23c6ebad41e2b2c4635d636a89581 - adapted sub classes of AbstractPostOperation --- diff --git a/.gitattributes b/.gitattributes index 1b676b7de..5d3b3263f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1191,8 +1191,8 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewT eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTeamWizard.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewUserWizard.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/PolytomousKeyWizardPage.java -text +eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractDescriptionPostOperation.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPersistentPostOperation.java -text -eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostDescribableOperation.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostTaxonOperation.java -text eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/IPostOperationEnabled.java -text diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.java index ef6b021c6..850747b62 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.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,13 +32,13 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; * @version 1.0 */ public class ChangeConceptRelationshipTypeOperation extends AbstractPostTaxonOperation { - + private Taxon relatedTaxon; - + private TaxonRelationship taxonRelationship; - + private TaxonRelationshipType oldRelationshipType; - + private TaxonRelationshipType newRelationshipType; /** @@ -55,20 +55,20 @@ public class ChangeConceptRelationshipTypeOperation extends AbstractPostTaxonOpe IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon, TaxonRelationshipType type, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); this.relatedTaxon = relatedTaxon; - + Set taxonRelationships = taxon.getTaxonRelations(relatedTaxon); - + if(taxonRelationships.size() > 1){ StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " + "accepted and the related taxon. This case is not handled by the software yet"); return; } - + this.taxonRelationship = taxonRelationships.iterator().next(); this.oldRelationshipType = taxonRelationship.getType(); this.newRelationshipType = type; } - + /* (non-Javadoc) * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) */ @@ -76,17 +76,17 @@ public class ChangeConceptRelationshipTypeOperation extends AbstractPostTaxonOpe @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Remove relatedTaxon and old relationship // FIXME since taxon relationships come in a set, which relationships are we going to delete here? - taxon.removeTaxon(relatedTaxon, oldRelationshipType); + element.removeTaxon(relatedTaxon, oldRelationshipType); monitor.worked(20); - + // Add new relationship // TODO add microcitation for misapplied name to property sheet - relatedTaxon.addTaxonRelation(taxon, newRelationshipType, null, null); + relatedTaxon.addTaxonRelation(element, newRelationshipType, null, null); monitor.worked(40); - + return postExecute(relatedTaxon); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java index 9f5221ddc..62e56bcd4 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.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,14 +37,14 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; */ public class ChangeConceptToSynonymOperation extends AbstractPostTaxonOperation { - + private Taxon concept; private HomotypicalGroup homotypicalGroup; private TaxonRelationship taxonRelationship; private TaxonRelationshipType oldRelationshipType; - + private SynonymRelationship newSynonymRelationship; /** @@ -61,18 +61,18 @@ public class ChangeConceptToSynonymOperation extends IUndoContext undoContext, Taxon taxon, Taxon concept, HomotypicalGroup homotypicalGroup, IPostOperationEnabled editor) { super(label, undoContext, taxon, editor); - + Set taxonRelationships = taxon.getTaxonRelations(concept); - + if(taxonRelationships.size() > 1){ StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " + "accepted and the related taxon. This case is not handled by the software yet"); return; } - + this.taxonRelationship = taxonRelationships.iterator().next(); this.oldRelationshipType = taxonRelationship.getType(); - + this.concept = concept; this.homotypicalGroup = homotypicalGroup != null ? homotypicalGroup : HomotypicalGroup.NewInstance(); } @@ -84,21 +84,21 @@ public class ChangeConceptToSynonymOperation extends @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Create new synonym using concept name TaxonNameBase synonymName = concept.getName(); - + // Remove concept relation from taxon - taxon.removeTaxon(concept, oldRelationshipType); + element.removeTaxon(concept, oldRelationshipType); monitor.worked(20); - + // Add name to new homotypic group homotypicalGroup.addTypifiedName(synonymName); monitor.worked(40); - + // Create a new synonym for the taxon - newSynonymRelationship = taxon.addHeterotypicSynonymName(synonymName); - + newSynonymRelationship = element.addHeterotypicSynonymName(synonymName); + return postExecute(newSynonymRelationship.getSynonym()); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java index 8ee04835c..d2b5af65d 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.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,16 +35,16 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation { /** * The synonym to be moved. */ - private Synonym synonym; + private final Synonym synonym; /** * The former homotypical group the synonym belonged to */ - private HomotypicalGroup oldHomotypicalGroup; + private final HomotypicalGroup oldHomotypicalGroup; /** * The homotypical group the synonym is to be moved to */ - private HomotypicalGroup newHomotypicalGroup; - + private final HomotypicalGroup newHomotypicalGroup; + /** *

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 Set synonymTypes; @@ -53,7 +53,7 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe public ChangeSynonymToMisapplicationOperation(String label, IUndoContext undoContext, Taxon taxon, Synonym synonym, IPostOperationEnabled editor) { super(label, undoContext, taxon, editor); - + this.synonym = synonym; } @@ -61,7 +61,7 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // get name from synonym TaxonNameBase synonymName = synonym.getName(); @@ -69,18 +69,18 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe misapplication = Taxon.NewInstance(synonymName, null); CdmStore.getService(ITaxonService.class).saveOrUpdate(misapplication); monitor.worked(20); - + // store synonymRelationshipType for later undo operations - synonymTypes = synonym.getRelationType(taxon); - - // remove synonym from taxon - taxon.removeSynonym(synonym); + synonymTypes = synonym.getRelationType(element); + + // remove synonym from taxon + element.removeSynonym(synonym); monitor.worked(40); - + // add misapplied name to taxon // TODO add microcitation for misapplied name to property sheet (if microcitation is indeed needed?!) - taxon.addMisappliedName(misapplication, null, null); - + element.addMisappliedName(misapplication, null, null); + // redraw editor if exists return postExecute(misapplication); } @@ -91,11 +91,11 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe throws ExecutionException { // add misapplied name to taxon // TODO add citation for misapplied name to property sheet - taxon.addMisappliedName(misapplication, null, null); - + element.addMisappliedName(misapplication, null, null); + // remove synonym from taxon - taxon.removeSynonym(synonym); - + element.removeSynonym(synonym); + // redraw editor if exists return postExecute(null); } @@ -104,15 +104,15 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // remove misapplied name from taxon - taxon.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR()); - + element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR()); + // add synonym to taxon for (SynonymRelationshipType synonymType : synonymTypes){ - taxon.addSynonym(synonym, synonymType); + element.addSynonym(synonym, synonymType); } - + // redraw editor if exists return postExecute(null); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java index 83b6f2ce3..d0d3d74c3 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.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,11 +32,11 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; public class CreateSynonymInExistingHomotypicalGroupOperation extends AbstractPostTaxonOperation { - private HomotypicalGroup group; - private TaxonNameBase newSynonymName; + private final HomotypicalGroup group; + private final TaxonNameBase newSynonymName; private SynonymRelationship synonymRelationship; - + /** *

Constructor 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 Set synonymTypes; /** @@ -60,33 +60,33 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation { @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Store synonymRelationshipType for later undo operations - synonymTypes = synonym.getRelationType(taxon); + synonymTypes = synonym.getRelationType(element); monitor.worked(20); - + // Remove synonym from taxon - + CdmApplicationController controller; - + controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration(); - + ITaxonService service = controller.getTaxonService(); if (synonym.getId() == 0){ - taxon.removeSynonym(synonym); - + element.removeSynonym(synonym); + } else { service.deleteSynonym(synonym, null); } // taxon.removeSynonym(synonym); // CdmStore.getTaxonService().deleteSynonymRelationships(synonym); // CdmStore.getTaxonService().delete(synonym); - + monitor.worked(40); // Redraw editor if exists - - return postExecute(taxon); + + return postExecute(element); } /* (non-Javadoc) @@ -95,7 +95,7 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation { /** {@inheritDoc} */ @Override public IStatus redo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { + throws ExecutionException { return execute(monitor, info); } @@ -106,12 +106,12 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + // Add synonym to taxon for (SynonymRelationshipType synonymType : synonymTypes){ - taxon.addSynonym(synonym, synonymType); + element.addSynonym(synonym, synonymType); } - + // Redraw editor if exists return postExecute(synonym); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java index dbc7f7a04..49f714668 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java @@ -3,21 +3,12 @@ package eu.etaxonomy.taxeditor.editor.name.operation; import java.util.Iterator; import java.util.Set; -import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; 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.core.runtime.Status; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.handlers.HandlerUtil; import eu.etaxonomy.cdm.api.application.CdmApplicationController; import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; @@ -25,26 +16,23 @@ 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.model.taxon.Classification; -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.TaxonEditorInput; -import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; import eu.etaxonomy.taxeditor.store.CdmStore; public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{ //private Taxon taxon; - private Classification classification; - - - - + private final Classification classification; + + + + public DeleteTaxonOperation(String label, IUndoContext undoContext, Taxon taxon, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { super(label, undoContext, taxon, activePage, postOperationEnabled, conversationEnabled); - this.taxon = taxon; - + this.element = taxon; + Set nodes = taxon.getTaxonNodes(); if (nodes.size() == 1 && classification == null){ this.taxonNode = nodes.iterator().next(); @@ -60,38 +48,38 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{ //TODO } this.classification = classification; - + } - + @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + monitor.worked(20); bind(); - - + + CdmApplicationController controller; - + controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration(); - + ITaxonService service = controller.getTaxonService(); try { - - service.deleteTaxon(taxon, new TaxonDeletionConfigurator(), classification); - + + service.deleteTaxon(element, new TaxonDeletionConfigurator(), classification); + } catch (DataChangeNoRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); - + } - + //closeObsoleteEditor(taxon); monitor.worked(40); - - + + return postExecute(null); } @@ -108,6 +96,6 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{ // TODO Auto-generated method stub return null; } - - + + } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.java index 8cbb446d9..a30c1f9d3 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.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. */ @@ -15,14 +15,11 @@ 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.core.runtime.Status; import eu.etaxonomy.cdm.api.service.ITaxonService; -import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.Synonym; import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; import eu.etaxonomy.cdm.model.taxon.Taxon; -import eu.etaxonomy.taxeditor.editor.EditorUtil; import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; import eu.etaxonomy.taxeditor.store.CdmStore; @@ -36,11 +33,11 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; * @version 1.0 */ public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation { - - private Synonym synonym; + + private final Synonym synonym; // TODO store the old relationship for undo reasons private SynonymRelationshipType synonymRelationshipType; - + /** *

Constructor 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 Set taxonRelationships; + + private final Set taxonRelationships; /** @@ -45,7 +45,7 @@ public class DeleteConceptRelationOperation extends AbstractPostTaxonOperation { IUndoContext undoContext, Taxon taxon, Set relations, IPostOperationEnabled postOperationEnabled) { super(label, undoContext, taxon, postOperationEnabled); - + taxonRelationships = relations; } @@ -56,17 +56,17 @@ public class DeleteConceptRelationOperation extends AbstractPostTaxonOperation { @Override public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + monitor.worked(20); - + // Remove relation from taxon for(TaxonRelationship relationship : taxonRelationships){ - taxon.removeTaxonRelation(relationship); + element.removeTaxonRelation(relationship); monitor.worked(10); } monitor.worked(10); - return postExecute(taxon); + return postExecute(element); } /* (non-Javadoc) @@ -86,12 +86,12 @@ public class DeleteConceptRelationOperation extends AbstractPostTaxonOperation { @Override public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - + for(TaxonRelationship relationship : taxonRelationships){ - taxon.addTaxonRelation(relationship); + element.addTaxonRelation(relationship); monitor.worked(10); } - - return postExecute(taxon); + + return postExecute(element); } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java index fa09a1ed3..8bd9fa6f4 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java @@ -124,16 +124,15 @@ public class DescriptiveContentProvider implements ITreeContentProvider { return featureTree; } - /** - * Get all descriptions associated with the given TaxonEditorInput - * - * @param parentElement - * @return - */ - protected List getDescriptions(IDescribable parentElement) { - Set> elementDescriptions = parentElement.getDescriptions(); - List resultDescriptions = new ArrayList(); - for(DescriptionBase description : elementDescriptions){ + /** + * Get all descriptions associated with the given object + * @param parentElement + * @return + */ + protected List getDescriptions(IDescribable parentElement) { + Set elementDescriptions = parentElement.getDescriptions(); + List resultDescriptions = new ArrayList(); + for(DescriptionBase description : elementDescriptions){ if(! description.isImageGallery()){ MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); Set descriptionMarkers = description.getMarkers(); @@ -148,10 +147,9 @@ public class DescriptiveContentProvider implements ITreeContentProvider { resultDescriptions.add(description); } } - } - return resultDescriptions; - } + return resultDescriptions; + } /* (non-Javadoc) * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java index e946cde5a..cb8582f84 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java @@ -21,6 +21,7 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; @@ -64,6 +65,10 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP protected TreeViewer viewer; + /** + * Maps {@link FeatureNodeContainerTree} to their corresponding {@link TaxonDescritpion}.
+ * This serves as input for the {@link ITreeContentProvider} of the {@link TreeViewer} + */ protected Map, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap, FeatureNodeContainerTree>(); protected ToggleDescriptionAction showAllElementsAction; diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java index 8065668b9..445ec48a5 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java @@ -20,7 +20,7 @@ import eu.etaxonomy.cdm.model.description.TaxonDescription; import eu.etaxonomy.cdm.model.description.TextData; import eu.etaxonomy.cdm.model.media.Media; import eu.etaxonomy.cdm.model.taxon.Taxon; -import eu.etaxonomy.taxeditor.operation.AbstractPostDescribableOperation; +import eu.etaxonomy.taxeditor.operation.AbstractDescriptionPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; /** @@ -31,10 +31,9 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; * @created 05.02.2009 * @version 1.0 */ -public class CreateTaxonDescriptionOperation extends AbstractPostDescribableOperation{ +public class CreateTaxonDescriptionOperation extends AbstractDescriptionPostOperation{ - private TaxonDescription description; - private boolean isImageGallery; + private final boolean isImageGallery; /** *

Constructor 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 { /** Constant ID="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 Set treeNodes; - private TaxonDeletionConfigurator config; + private final TaxonDeletionConfigurator config; /** @@ -87,7 +81,7 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ this.treeNodes = treeNodes; this.config = config; } - + /* (non-Javadoc) * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) @@ -104,15 +98,15 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ if(taxonNode != null && taxonNode instanceof TaxonNode){ //((TaxonNode) treeNode).delete(); - taxon = ((TaxonNode)taxonNode).getTaxon(); + element = ((TaxonNode)taxonNode).getTaxon(); try { service.deleteTaxonNode((TaxonNode)taxonNode, config); } catch (DataChangeNoRollbackException e) { - + throw new ExecutionException(e.getMessage()); - + } - + }else if(taxonNode != null && taxonNode instanceof Classification){ Classification taxonomicTree = (Classification) taxonNode; /*if(taxonomicTree.hasChildNodes()){ @@ -125,8 +119,8 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ }catch(ReferencedObjectUndeletableException e){ throw new ExecutionException(e.getMessage()); } - - + + /*}else{ try{ CdmStore.getService(IClassificationService.class).delete(taxonomicTree); @@ -141,7 +135,7 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ throw new ExecutionException(e.getMessage()); } } - + monitor.worked(40); return postExecute(null); } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractDescriptionPostOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractDescriptionPostOperation.java new file mode 100644 index 000000000..c84a01ab7 --- /dev/null +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractDescriptionPostOperation.java @@ -0,0 +1,35 @@ +// $Id$ +/** +* Copyright (C) 2013 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.operation; + +import org.eclipse.core.commands.operations.IUndoContext; + +import eu.etaxonomy.cdm.model.description.DescriptionBase; +import eu.etaxonomy.cdm.model.description.IDescribable; +import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; + +/** + * @author pplitzner + * @date 04.12.2013 + * + */ +public abstract class AbstractDescriptionPostOperation, D extends DescriptionBase>> extends AbstractPostOperation { + + protected D description; + + /** + * + */ + public AbstractDescriptionPostOperation(String label, IUndoContext undoContext, + T describable, IPostOperationEnabled postOperationEnabled) { + super(label, undoContext, describable, postOperationEnabled); + } + +} diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostDescribableOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostDescribableOperation.java deleted file mode 100644 index dad07844f..000000000 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostDescribableOperation.java +++ /dev/null @@ -1,30 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2013 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.operation; - -import eu.etaxonomy.cdm.model.description.IDescribable; - -/** - * @author pplitzner - * @date 03.12.2013 - * - */ -public abstract class AbstractPostDescribableOperation extends AbstractPostOperation { - - protected IDescribable describable; - - /** - * @param label - */ - public AbstractPostDescribableOperation(String label) { - super(label); - } - -} diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java index 9506bd4b4..5b7c68ec8 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java @@ -10,28 +10,65 @@ package eu.etaxonomy.taxeditor.operation; import org.eclipse.core.commands.operations.AbstractOperation; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import eu.etaxonomy.cdm.model.common.CdmBase; +import eu.etaxonomy.cdm.model.common.ICdmBase; /** * @author pplitzner * @date 03.12.2013 * */ -public abstract class AbstractPostOperation extends AbstractOperation { +public abstract class AbstractPostOperation extends AbstractOperation { + /** - * + * A reference to the {@link ICdmBase} element the concrete operation is working on + */ + protected T element; + + /** + * */ protected IPostOperationEnabled postOperationEnabled; + /** - * @param label + *

Constructor 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 be null 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 AbstractPostOperation { /** * A reference to the taxons TaxonNode @@ -39,31 +34,7 @@ public abstract class AbstractPostTaxonOperation extends AbstractPostOperation { protected UUID parentNodeUuid; - /** - *

Constructor 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); + } }