eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetContentProvider.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetValueEditingSupport.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetValueLabelProvider.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySourceAdapter.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/SourceViewerConfig.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/ZoologicalNamePropertySource.java -text
org.eclipse.ui.forms,
org.eclipse.core.resources,
org.eclipse.ui.views,
- eu.etaxonomy.cdmLibrary,
org.eclipse.pde.source,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ eu.etaxonomy.cdmLibrary
Eclipse-LazyStart: true
Export-Package: com.swtdesigner,
eu.etaxonomy.taxeditor,
import org.eclipse.core.runtime.IPath;\r
import org.eclipse.core.runtime.Path;\r
import org.eclipse.jface.preference.IPreferenceStore;\r
-import org.eclipse.jface.preference.PreferenceConverter;\r
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.jface.resource.ImageRegistry;\r
import org.eclipse.swt.graphics.Image;\r
import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;\r
import eu.etaxonomy.cdm.model.name.BotanicalName;\r
import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
logger.trace("Trace");\r
\r
boolean initDatastore = false;\r
-// initDatastore = true;\r
+ initDatastore = true;\r
if (initDatastore)\r
initDatastore();\r
else {\r
/* ***************************************************************************************\r
NOMENCLATURAL STATUS\r
************************************************************************************** */ \r
- OrderedTermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = null;\r
+ TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = null;\r
\r
- public OrderedTermVocabulary<NomenclaturalStatusType> getNomStatusVocabulary() {\r
+ public TermVocabulary<NomenclaturalStatusType> getNomStatusVocabulary() {\r
if (nomStatusVocabulary == null) {\r
nomStatusVocabulary = cdmApp.getNameService().getStatusTypeVocabulary();\r
}\r
/* ***************************************************************************************\r
NAME RELATIONS\r
************************************************************************************** */ \r
- OrderedTermVocabulary<NameRelationshipType> nameRelationshipTypeVocabulary = null;\r
+ TermVocabulary<NameRelationshipType> nameRelationshipTypeVocabulary = null;\r
\r
- public OrderedTermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary() {\r
+ public TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary() {\r
if (nameRelationshipTypeVocabulary == null) {\r
nameRelationshipTypeVocabulary = cdmApp.getNameService().getNameRelationshipTypeVocabulary();\r
}\r
import org.eclipse.ui.views.properties.IPropertySheetPage;\r
import org.eclipse.ui.views.properties.PropertySheetPage;\r
\r
-import eu.etaxonomy.cdm.model.name.BotanicalName;\r
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
import eu.etaxonomy.cdm.model.name.NonViralName;\r
import eu.etaxonomy.cdm.model.name.Rank;\r
import eu.etaxonomy.taxeditor.view.nameviewersupport.NameComposite;\r
import eu.etaxonomy.taxeditor.view.nameviewersupport.SimpleSelectionProvider;\r
import eu.etaxonomy.taxeditor.view.nameviewersupport.TaxonCompositeFactory;\r
-import eu.etaxonomy.taxeditor.view.propertysheetsupport.BotanicalNamePropertySource;\r
import eu.etaxonomy.taxeditor.view.propertysheetsupport.CustomSortPropertySheetEntry;\r
+import eu.etaxonomy.taxeditor.view.propertysheetsupport.PropertySourceAdapter;\r
\r
/**\r
* @author p.ciardelli\r
this.getSite().setSelectionProvider(provider);\r
provider.setSelection(\r
new StructuredSelection(\r
- new BotanicalNamePropertySource((BotanicalName) taxon.getName())));\r
+ new PropertySourceAdapter(taxon.getName()).getPropertySource()\r
+ ));\r
taxonCompositeFactory.setSelectionProvider(provider);\r
}\r
\r
}\r
\r
public void setShowError(boolean hasProblem) {\r
- \r
- hasProblem = false;\r
- \r
+ \r
String text = this.getTextWidget().getText();\r
\r
Iterator<Annotation> annotations = this.getAnnotationModel().getAnnotationIterator();\r
this.getAnnotationModel().removeAnnotation(annotation);\r
}\r
\r
- // Failed attempt to get multi-line squigglies drawn\r
if (hasProblem && text.length() > 0) {\r
- for (int i = 1; i <= this.getTextWidget().getLineCount(); i++) {\r
- this.getAnnotationModel().addAnnotation(\r
- new ErrorAnnotation(i, "Could not parse."), \r
- new Position(0, text.length()));\r
- }\r
+ this.getAnnotationModel().addAnnotation(\r
+ new ErrorAnnotation(0, "Could not parse."), \r
+ new Position(0, text.length()));\r
}\r
}\r
\r
import com.swtdesigner.ResourceManager;\r
\r
import eu.etaxonomy.cdm.model.name.BotanicalName;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl;\r
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;\r
import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
import eu.etaxonomy.taxeditor.controller.ActionAddQuickName;\r
import eu.etaxonomy.taxeditor.controller.ActionDeleteTaxon;\r
} else {\r
// Set Taxon's TitleCache, save it to CDM\r
// taxon.getName().setTitleCache((String) value);\r
- TaxonNameParserBotanicalNameImpl.NewInstance().parseFullName\r
- ((BotanicalName) taxon.getName(), (String) value, \r
- null, true);\r
+ NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+ NonViralName nonViralName = (NonViralName) taxon.getName();\r
+ if (nonViralName != null) {\r
+ parser.parseFullName(nonViralName, (String) value, null, true);\r
+ }\r
new ActionSaveTaxon(taxon).run();\r
}\r
}\r
import org.eclipse.swt.widgets.MenuItem;\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.ui.forms.IManagedForm;\r
+import org.eclipse.ui.views.properties.IPropertySource;\r
\r
-import eu.etaxonomy.cdm.model.name.BotanicalName;\r
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.taxon.Synonym;\r
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl;\r
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;\r
import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
import eu.etaxonomy.taxeditor.view.MoveDialogView;\r
import eu.etaxonomy.taxeditor.view.NameViewer;\r
-import eu.etaxonomy.taxeditor.view.propertysheetsupport.BotanicalNamePropertySource;\r
+import eu.etaxonomy.taxeditor.view.propertysheetsupport.PropertySourceAdapter;\r
\r
/**\r
* @author p.ciardelli\r
if (!(data instanceof TaxonBase)) {\r
return;\r
}\r
- TaxonNameBase<TaxonNameBase> taxonNameBase = ((TaxonBase) data).getName();\r
- if (taxonNameBase instanceof BotanicalName) {\r
- \r
- BotanicalNamePropertySource propertySource = \r
- new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+ TaxonNameBase taxonNameBase = ((TaxonBase) data).getName();\r
+// if (taxonNameBase instanceof BotanicalName) {\r
+// \r
+// BotanicalNamePropertySource propertySource = \r
+// new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+ IPropertySource propertySource = new PropertySourceAdapter(taxonNameBase).getPropertySource(); \r
selectionProvider.setSelection(\r
new StructuredSelection(propertySource));\r
// propertySource.addPropertyChangeListener(new PropertyChangeListener() {\r
// }\r
// \r
// });\r
- }\r
+// }\r
\r
}\r
});\r
\r
@Override\r
public void handleSplitText(String text) {\r
- TaxonNameParserBotanicalNameImpl parser = TaxonNameParserBotanicalNameImpl.NewInstance();\r
- BotanicalName name = parser.parseFullReference(text, null);\r
- \r
+ NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+ NomenclaturalCode nomCode = null;\r
+ NonViralName name = parser.parseFullReference(text, nomCode, null); \r
+ logger.warn(name.getClass().getSimpleName());\r
+ \r
SynonymRelationship synonymRelation = taxon.addHeterotypicSynonymName(name);\r
Synonym synonym = synonymRelation.getSynonym();\r
GroupComposite newGroupComposite = createGroupComposite(parent, synonym.getName().getHomotypicalGroup());\r
\r
@Override\r
public void parse(String text) {\r
- TaxonNameParserBotanicalNameImpl.NewInstance().parseFullName\r
- ((BotanicalName) data.getName(), text, null, true);\r
- nameViewer.setShowError(data.getName().getHasProblem());\r
+ \r
+ TaxonBase taxonBase = (TaxonBase) nameComposite.getData();\r
+ \r
+ NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+ NonViralName nonViralName = (NonViralName) taxonBase.getName();\r
+ if (nonViralName != null) {\r
+ parser.parseFullName(nonViralName, text, null, true);\r
+ nameViewer.setShowError(nonViralName.getHasProblem());\r
+ logger.warn(nonViralName.getClass().getSimpleName());\r
+ }\r
}\r
\r
});\r
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\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
package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
\r
-import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
+\r
+import eu.etaxonomy.cdm.model.name.BotanicalName;\r
\r
/**\r
- * Property source for Botanical Name entries.\r
+ * Property source for BotanicalName entries.\r
* \r
* @author p.ciardelli\r
- *\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
*/\r
public class BotanicalNamePropertySource extends NonViralNamePropertySource {\r
-\r
- public BotanicalNamePropertySource(NonViralName name) {\r
+ private static final Logger logger = Logger\r
+ .getLogger(BotanicalNamePropertySource.class);\r
+ \r
+ // Property unique keys\r
+ public static final String P_ID_REFERENCEYEAR = "referenceyear"; \r
+ // Property display keys\r
+ public static final String P_REFERENCEYEAR = "099:Reference Year"; \r
+ \r
+ public BotanicalNamePropertySource(BotanicalName name) {\r
super(name);\r
- // TODO Auto-generated constructor stub\r
+ addDescriptor(P_ID_REFERENCEYEAR);\r
+ }\r
+ \r
+ protected void addDescriptor(String id) {\r
+ if (id.equals(P_ID_REFERENCEYEAR)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_REFERENCEYEAR, P_REFERENCEYEAR));\r
+ }\r
+ super.addDescriptor(id);\r
+ }\r
+ \r
+ @Override\r
+ public Object getPropertyValue(Object id) {\r
+ if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
+ return 1;\r
+ }\r
+ if (id.equals(P_ID_REFERENCEYEAR)) {\r
+ return subEmptyForNull(name.getReferenceYear());\r
+ }\r
+ return super.getPropertyValue(id);\r
}\r
}
\ No newline at end of file
\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
import eu.etaxonomy.cdm.model.name.NonViralName;\r
public static final String P_ID_NOMENCLATURAL_CODE = "nomenclaturalcode";\r
public static final String P_ID_NOMENCLATURAL_REF = "nomenclaturalref";\r
public static final String P_ID_NOMENCLATURAL_MICROREF = "nomenclaturalmicroref";\r
+ public static final String P_ID_REFERENCEYEAR = "referenceyear";\r
\r
// Property display keys\r
// Note: for an explanation of the sorting prefixes ("04:"), \r
\r
// Get terms from rank vocabulary\r
List<Rank> ranksList = new ArrayList<Rank>();\r
- ranksList.addAll(rankVocabulary.getTerms());\r
- \r
+ ranksList.addAll(rankVocabulary.getOrderedTerms(null));\r
// Populate ranks menu labels \r
List<String> ranksMenuList = new ArrayList<String>();\r
for (Rank rank : ranksList) {\r
\r
// Convert rank lists to array\r
ranks = ranksList.toArray(new Rank[ranksList.size()]);\r
- P_RANK_MENU = ranksMenuList.toArray(new String[ranksMenuList.size()]); \r
+ P_RANK_MENU = ranksMenuList.toArray(new String[ranksMenuList.size()]);\r
}\r
\r
- static String[] P_NOMENCLATURALCODE_MENU = new String[] { "ICBN", "ICZN" };\r
+ static String[] P_NOMENCLATURALCODE_MENU = new String[] { "ICZN", "ICBN" };\r
\r
// ***********************************************************\r
// NOMENCLATURAL STATUS\r
// ***********************************************************\r
- static OrderedTermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
+ static TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
TaxEditorPlugin.getDefault().getNomStatusVocabulary();\r
static NomenclaturalStatusType[] nomStatusTypes = null;\r
static String[] P_NOMSTATUS_MENU = null;\r
\r
// Get terms from nom status vocabulary\r
List<NomenclaturalStatusType> nomStatusTypesList = new ArrayList<NomenclaturalStatusType>();\r
- nomStatusTypesList.addAll(TaxEditorPlugin.getDefault().getNomStatusVocabulary().getTerms());\r
+ nomStatusTypesList.addAll(nomStatusVocabulary.getTerms());\r
\r
// // Populate nom status type menu labels \r
List<String> nomStatusTypesMenuList = new ArrayList<String>();\r
* \r
* @param id\r
*/\r
- private void addDescriptor(String id) {\r
- name.getNomenclaturalMicroReference();\r
- name.getNomenclaturalReference();\r
+ protected void addDescriptor(String id) {\r
if (id.equals(P_ID_PARSED)) {\r
descriptors.addElement(\r
new PropertyDescriptor(P_ID_PARSED, P_PARSED));\r
new TextPropertyDescriptor(P_ID_NOMENCLATURAL_MICROREF,P_NOMENCLATURAL_MICROREF));\r
}\r
}\r
-\r
- private PropertyChangeListener taxonChangeListener = new PropertyChangeListener() {\r
- public void propertyChange(PropertyChangeEvent arg0) {\r
- \r
- }\r
- }; \r
- \r
- private void addPropertyChangeListener(String id) {\r
- if (id.equals(P_ID_TITLECACHE)) {\r
- this.name.addPropertyChangeListener("titleCache", new PropertyChangeListener() {\r
-\r
- @Override\r
- public void propertyChange(PropertyChangeEvent evt) {\r
-// System.out.println(evt.getPropertyName());\r
- }\r
- });\r
- }\r
- }\r
\r
/**\r
* Constructor for top level property fields. All fields that are not subfields\r
String parentid, String[] keys) {\r
this.name = name;\r
this.parentid = parentid;\r
- this.propertyChangeSupport = new PropertyChangeSupport(name);\r
+// this.propertyChangeSupport = new PropertyChangeSupport(name);\r
for (String key : keys) {\r
addDescriptor(key);\r
- addPropertyChangeListener(key);\r
}\r
- name.addPropertyChangeListener("specificEpithet", taxonChangeListener);\r
}\r
\r
@Override\r
\r
@Override\r
public Object getPropertyValue(Object id) {\r
- if (id.equals(P_ID_PARSED)) \r
+ if (id.equals(P_ID_PARSED)) {\r
return name.getHasProblem() == true ? "problem" : "parsed" ;\r
+ }\r
if (id.equals(P_ID_RANK)) {\r
if (this.name.getRank() == null) {\r
return 0;\r
}\r
if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
// TODO put in logic "if BotanicalName / ZoologicalName ..."\r
- return 0;\r
+ return 1;\r
}\r
if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
INomenclaturalReference nomenclaturalReference = (INomenclaturalReference) name.getNomenclaturalReference();\r
* @param string\r
* @return\r
*/\r
- private String subEmptyForNull(String string) {\r
+ protected String subEmptyForNull(String string) {\r
if (string == null)\r
return "";\r
return string;\r
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\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
+package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.views.properties.IPropertySource;\r
+\r
+import eu.etaxonomy.cdm.model.name.BotanicalName;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
+\r
+/**\r
+ * Returns a property source appropriate to the selected object. \r
+ * \r
+ * @author p.ciardelli\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
+ */\r
+public class PropertySourceAdapter {\r
+ private static final Logger logger = Logger\r
+ .getLogger(PropertySourceAdapter.class);\r
+ \r
+ private TaxonNameBase taxonNameBase;\r
+\r
+ public PropertySourceAdapter(TaxonNameBase taxonNameBase) {\r
+ this.taxonNameBase = taxonNameBase;\r
+ }\r
+\r
+ public IPropertySource getPropertySource() {\r
+ Class clazz = taxonNameBase.getClass();\r
+ logger.warn("Requesting property source for a " + clazz);\r
+ if (clazz == BotanicalName.class) {\r
+ return new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+ }\r
+ if (clazz == ZoologicalName.class) {\r
+ return new ZoologicalNamePropertySource((ZoologicalName) taxonNameBase);\r
+ } \r
+ return new NonViralNamePropertySource((NonViralName) taxonNameBase);\r
+ }\r
+}\r
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\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
+package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
+\r
+/**\r
+ * Property source for ZoologicalName entries.\r
+ * \r
+ * @author p.ciardelli\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
+ */\r
+public class ZoologicalNamePropertySource extends NonViralNamePropertySource {\r
+ private static final Logger logger = Logger\r
+ .getLogger(ZoologicalNamePropertySource.class);\r
+\r
+ private ZoologicalName zoologicalName;\r
+ \r
+ // Property unique keys\r
+ public static final String P_ID_PUBLICATIONYEAR = "publicationyear";\r
+ // Property display keys\r
+ public static final String P_PUBLICATIONYEAR = "099:Publication Year";\r
+ \r
+ public ZoologicalNamePropertySource(ZoologicalName name) {\r
+ super(name);\r
+ this.zoologicalName = name;\r
+ addDescriptor(P_ID_PUBLICATIONYEAR);\r
+ }\r
+\r
+ @Override\r
+ public Object getPropertyValue(Object id) {\r
+ if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
+ return 0;\r
+ }\r
+ if (id.equals(P_ID_PUBLICATIONYEAR)) {\r
+ String publicationYear = Integer.toString(zoologicalName.getPublicationYear());\r
+ if (publicationYear.equals("0")) {\r
+ return "";\r
+ } else {\r
+ return publicationYear;\r
+ }\r
+ }\r
+ return super.getPropertyValue(id);\r
+ }\r
+}\r