/**\r
* Copyright (C) 2011 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
\r
/**\r
* The context listener will call this class when the uses view is being loaded.\r
- * It checks if the uses view's necessary terms are present in the database. \r
- * It will persist the terms that aren't present, using the CDMLib's services classes. \r
- * @author a.theys \r
+ * It checks if the uses view's necessary terms are present in the database.\r
+ * It will persist the terms that aren't present, using the CDMLib's services classes.\r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
public class UseObjectManager extends ContextListenerAdapter{\r
- \r
- \r
+\r
+\r
@Override\r
public void contextRefresh(IProgressMonitor monitor) {\r
monitor.subTask("Refreshing the Uses View");\r
StoreUtil.warn(getClass(), "Refreshing Uses View warn");\r
setupNecessaryItems(monitor);\r
}\r
- \r
- \r
+\r
+\r
@Override\r
public void contextStart(IMemento memento, IProgressMonitor monitor) {\r
monitor.subTask("Starting the Uses View");\r
StoreUtil.warn(getClass(), "Starting Uses View warn");\r
setupNecessaryItems(monitor);\r
}\r
- \r
+\r
private void setupNecessaryItems(IProgressMonitor monitor) {\r
- \r
+\r
//retrieve terms and vocabularies from db\r
Feature featureUseRecord = (Feature) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseRecordFeature);\r
Feature featureUseSummary = (Feature) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseSummaryFeature);\r
- \r
+\r
ConversationHolder conversation = CdmStore.createConversation();\r
- \r
- \r
+\r
+\r
//create use marker type if not exists\r
createUseMarkerType(conversation);\r
- \r
+\r
//create state vocabulary if not exists\r
createStateVocabulary(monitor, conversation);\r
- \r
+\r
//create state vocabulary if not exists\r
createCountryVocabulary(monitor, conversation);\r
- \r
+\r
//create plant part vocabulary\r
createPlantVocabulary(monitor, conversation);\r
- \r
+\r
//create human group vocabulary\r
createHumanGroupVocabulary(monitor, conversation);\r
- \r
+\r
if(featureUseRecord == null || featureUseSummary == null) {\r
- TermVocabulary<Feature> featureVocabulary = (TermVocabulary<Feature>)CdmStore.getService(IVocabularyService.class).find((UsageTermCollection.uuidFeatureVocabulary));\r
+ TermVocabulary<Feature> featureVocabulary = CdmStore.getService(IVocabularyService.class).find((UsageTermCollection.uuidFeatureVocabulary));\r
FeatureTree palmWebFeatureTree = CdmStore.getService(IFeatureTreeService.class).find(UsageTermCollection.uuidPalmWebFeatureTree);\r
- \r
+\r
if (featureUseRecord == null ) {\r
featureUseRecord = Feature.NewInstance(UsageTermCollection.useRecordFeatureLabel, UsageTermCollection.useRecordFeatureLabel, null);\r
featureUseRecord.setUuid(UsageTermCollection.uuidUseRecordFeature);\r
StoreUtil.warn(getClass(), "No current feature tree available to add use summary feature");\r
}\r
}\r
- \r
+\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(featureVocabulary);\r
if (palmWebFeatureTree != null){\r
CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(palmWebFeatureTree);\r
}\r
conversation.commit(true);\r
- \r
+\r
}\r
- conversation.close(); \r
+ conversation.close();\r
}\r
\r
\r
private void createHumanGroupVocabulary(IProgressMonitor monitor,ConversationHolder conversation) {\r
- TermVocabulary<DefinedTerm> humanGroupVocabulary = (TermVocabulary<DefinedTerm>) CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidHumanGroupVocabulary);\r
+ TermVocabulary<DefinedTerm> humanGroupVocabulary = CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidHumanGroupVocabulary);\r
if (humanGroupVocabulary == null){\r
monitor.subTask("create human group vocabulary");\r
URI termSourceUri = null;\r
} catch (URISyntaxException e) {\r
e.printStackTrace();\r
}\r
- \r
+\r
//FIXME:3.3MC----\r
//humanGroupVocabulary = TermVocabulary.NewInstance(UsageTermCollection.humanGroupLabel, UsageTermCollection.humanGroupLabel, null, termSourceUri);\r
- humanGroupVocabulary = null;\r
- humanGroupVocabulary.setUuid(UsageTermCollection.uuidHumanGroupVocabulary);\r
+// humanGroupVocabulary.setUuid(UsageTermCollection.uuidHumanGroupVocabulary);\r
//FIXME:3.3MC----\r
- \r
+\r
//FIXME:3.3MC----\r
//DefinedTerm newDummyModifier = DefinedTerm.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
- DefinedTerm newDummyModifier = null;\r
- newDummyModifier.setUuid(UsageTermCollection.uuidHumanGroupDummy);\r
+// newDummyModifier.setUuid(UsageTermCollection.uuidHumanGroupDummy);\r
//FIXME:3.3MC----\r
- \r
+\r
//FIXME:3.3MC----\r
//DefinedTerm newSubDummyModifier = DefinedTerm.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
- DefinedTerm newSubDummyModifier = null;\r
- newSubDummyModifier.setUuid(UsageTermCollection.uuidEthnicGroupDummy);\r
+// newSubDummyModifier.setUuid(UsageTermCollection.uuidEthnicGroupDummy);\r
+// newDummyModifier.addIncludes(newSubDummyModifier);\r
+// humanGroupVocabulary.addTerm(newDummyModifier);\r
//FIXME:3.3MC----\r
- \r
- newDummyModifier.addIncludes(newSubDummyModifier);\r
- humanGroupVocabulary.addTerm(newDummyModifier);\r
+\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(humanGroupVocabulary);\r
conversation.commit(true);\r
}\r
\r
\r
private void createPlantVocabulary(IProgressMonitor monitor, ConversationHolder conversation) {\r
- TermVocabulary<DefinedTerm> plantPartVocabulary = (TermVocabulary<DefinedTerm>) CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidPlantPartVocabulary);\r
+ TermVocabulary<DefinedTerm> plantPartVocabulary = CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidPlantPartVocabulary);\r
if (plantPartVocabulary == null){\r
monitor.subTask("create plant part vocabulary");\r
URI termSourceUri = null;\r
}\r
//FIXME:3.3MC----\r
//plantPartVocabulary = TermVocabulary.NewInstance(UsageTermCollection.plantPartLabel, UsageTermCollection.plantPartLabel, null, termSourceUri);\r
- plantPartVocabulary = null;\r
- plantPartVocabulary.setUuid(UsageTermCollection.uuidPlantPartVocabulary);\r
+// plantPartVocabulary.setUuid(UsageTermCollection.uuidPlantPartVocabulary);\r
//FIXME:3.3MC----\r
- \r
+\r
//FIXME:3.3MC----\r
//DefinedTerm newDummyModifier = DefinedTerm.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
- DefinedTerm newDummyModifier = null;\r
- newDummyModifier.setUuid(UsageTermCollection.uuidPlantPartDummy);\r
- plantPartVocabulary.addTerm(newDummyModifier);\r
+// newDummyModifier.setUuid(UsageTermCollection.uuidPlantPartDummy);\r
+// plantPartVocabulary.addTerm(newDummyModifier);\r
//FIXME:3.3MC----\r
- \r
+\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(plantPartVocabulary);\r
conversation.commit(true);\r
}\r
\r
\r
private void createCountryVocabulary(IProgressMonitor monitor, ConversationHolder conversation) {\r
- TermVocabulary<DefinedTerm> countryVocabulary = (TermVocabulary<DefinedTerm>) CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidCountryVocabulary);\r
+ TermVocabulary<DefinedTerm> countryVocabulary = CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidCountryVocabulary);\r
if (countryVocabulary == null){\r
monitor.subTask("create country vocabulary");\r
URI termSourceUri = null;\r
}\r
//FIXME:3.3MC----\r
//countryVocabulary = TermVocabulary.NewInstance(UsageTermCollection.countryLabel, UsageTermCollection.countryLabel, null, termSourceUri);\r
- countryVocabulary = null;\r
- countryVocabulary.setUuid(UsageTermCollection.uuidCountryVocabulary);\r
+// countryVocabulary.setUuid(UsageTermCollection.uuidCountryVocabulary);\r
//FIXME:3.3MC----\r
- \r
+\r
//FIXME:3.3MC----\r
//DefinedTerm newDummyModifier = DefinedTerm.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
- DefinedTerm newDummyModifier = null;\r
- newDummyModifier.setUuid(UsageTermCollection.uuidCountryDummy);\r
+// newDummyModifier.setUuid(UsageTermCollection.uuidCountryDummy);\r
+// countryVocabulary.addTerm(newDummyModifier);\r
//FIXME:3.3MC----\r
- countryVocabulary.addTerm(newDummyModifier);\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(countryVocabulary);\r
conversation.commit(true);\r
}\r
\r
\r
private void createStateVocabulary(IProgressMonitor monitor, ConversationHolder conversation) {\r
- TermVocabulary<State> stateVocabulary = (TermVocabulary<State>) CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidUseCategoryVocabulary);\r
+ TermVocabulary<State> stateVocabulary = CdmStore.getService(IVocabularyService.class).find(UsageTermCollection.uuidUseCategoryVocabulary);\r
if (stateVocabulary == null){\r
monitor.subTask("create state vocabulary");\r
URI termSourceUri = null;\r
}\r
//FIXME:3.3MC----\r
//stateVocabulary = TermVocabulary.NewInstance(UsageTermCollection.useCategoryVocabularyLabel, UsageTermCollection.useCategoryVocabularyLabel, null, termSourceUri);\r
- stateVocabulary = null;\r
- stateVocabulary.setUuid(UsageTermCollection.uuidUseCategoryVocabulary);\r
+// stateVocabulary.setUuid(UsageTermCollection.uuidUseCategoryVocabulary);\r
//FIXME:3.3MC----\r
State newDummyState = State.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
newDummyState.setUuid(UsageTermCollection.uuidUseCategoryDummy);\r
State newDummySubCat = State.NewInstance(UsageTermCollection.notAvailableLabel, UsageTermCollection.notAvailableLabel, null);\r
newDummySubCat.setUuid(UsageTermCollection.uuidUseSubCategoryDummy);\r
newDummyState.addIncludes(newDummySubCat);\r
- stateVocabulary.addTerm(newDummyState);\r
+ //FIXME:3.3MC----\r
+// stateVocabulary.addTerm(newDummyState);\r
+ //FIXME:3.3MC----\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(stateVocabulary);\r
conversation.commit(true);\r
}\r
if (useMarkertype == null){\r
useMarkertype = MarkerType.NewInstance(UsageTermCollection.useMakerLabel, UsageTermCollection.useMakerLabel, null);\r
useMarkertype.setUuid( UsageTermCollection.uuidUseMarkerType);\r
- TermVocabulary<MarkerType> markerTypeVocabulary = (TermVocabulary<MarkerType>)CdmStore.getService(IVocabularyService.class).find((UsageTermCollection.uuidMarkersVocabulary));\r
+ TermVocabulary<MarkerType> markerTypeVocabulary = CdmStore.getService(IVocabularyService.class).find((UsageTermCollection.uuidMarkersVocabulary));\r
markerTypeVocabulary.addTerm(useMarkertype);\r
CdmStore.getService(IVocabularyService.class).saveOrUpdate(markerTypeVocabulary);\r
conversation.commit(true);\r
// $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.
*/
import java.util.Arrays;
+import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.model.name.BotanicalName;
*/
public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<NonViralName> implements ISelectableElement, IEnableableFormElement{
+ private final Logger logger = Logger.getLogger(NameDetailElement.class);
+
private TermComboElement<Rank> combo_rank;
private TextWithLabelElement text_appendedPhrase;
private TextWithLabelElement text_uninomial;
private NumberWithLabelElement text_publicationYear;
private NumberWithLabelElement text_originalPublicationYear;
private int cursorPosition;
-
+
/**
* <p>Constructor for NameDetailElement.</p>
*
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement, NonViralName nonViralName, int style) {
-
+
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style);
-
+
combo_rank = formFactory.createTermComboElement(Rank.class, this, "Rank", nonViralName.getRank(), style);
-
+
createGenusOrUninomialControls(this, nonViralName, style);
createInfragenerericEpithetControls(this, nonViralName, style);
createSpecificEpithetControls(this, nonViralName, style);
createInfraSpecificEpithetControls(this, nonViralName, style);
-
+
createSpecificNameParts(this, nonViralName, style);
-
+
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
-
+
}
/**
protected void clearCheckRankWarnings() {
if(getEntity().hasProblem(ParserProblem.CheckRank)){
getEntity().removeParsingProblem(ParserProblem.CheckRank);
-
+
// FIXME this has to be reafctored completely. See tickets #1959, #1663, #1957, #1958
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
// nameEditor.getSelectedContainer().getNameViewer().clearErrors();
}
}
-
+
/** {@inheritDoc} */
@Override
protected void updateContent() {
if(getEntity() == null){
setEntity(NonViralName.NewInstance(null));
}
-
+
super.updateContent();
-
+
if(isIrrelevant()){
setIrrelevant(isIrrelevant());
}else{
case ICZN:
createZoologicalNameParts(formElement, nonViralName, style);
break;
- }
+ case ICVCN:
+ //TODO implement
+ logger.warn("ICVCN not yet implemented");
+ break;
+ case ICNB:
+ //TODO implement
+ logger.warn("ICNB not yet implemented");
+ break;
+ case ICNCP:
+ //TODO implement
+ logger.warn("ICNCP not yet implemented");
+ break;
+ }
}
}
-
+
private void createBotanicalNameParts(ICdmFormElement formElement, NonViralName nonViralName, int style){
BotanicalName botanicalName = (BotanicalName) nonViralName;
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", botanicalName.isAnamorphic(), style);
text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", zoologicalName.getPublicationYear(), style);
text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", zoologicalName.getOriginalPublicationYear(), style);
}
-
- private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){
+
+ private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){
String title = "Genus";
Rank rank = nonViralName.getRank();
if(rank != null && rank.isSupraGeneric()){
- title = "Uninomial";
+ title = "Uninomial";
}
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style);
}
-
+
private void createInfragenerericEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraGeneric() && !nonViralName.getRank().isSpeciesAggregate()){
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style);
}
}
-
+
private void createSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL);
}
}
-
+
private void createInfraSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL);
}
}
-
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource){
if (eventSource == toggleable_cache) {
getEntity().setNameCache(toggleable_cache.getText(),
toggleable_cache.getState());
- if (!isIrrelevant())
- setIrrelevant(toggleable_cache.getState(),
+ if (!isIrrelevant()) {
+ setIrrelevant(toggleable_cache.getState(),
Arrays.asList(new Object[] { toggleable_cache }));
+ }
}
else if(eventSource == combo_rank){
getEntity().setRank(combo_rank.getSelection());
clearCheckRankWarnings();
updateContent();
- }
+ }
else if(eventSource == text_appendedPhrase){
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
}
}
else if(eventSource == text_uninomial){
getEntity().setGenusOrUninomial(text_uninomial.getText());
- }
+ }
else if(eventSource == checkbox_anamorphic){
((BotanicalName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
}
}
-
+
/*
* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator()
*
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
*/
- public SelectionArbitrator getSelectionArbitrator() {
+ @Override
+ public SelectionArbitrator getSelectionArbitrator() {
return selectionArbitrator;
}
-
+
@Override
public void updateToggleableCacheField() {
if(! getEntity().isProtectedNameCache()){