\r
import java.beans.PropertyChangeEvent;\r
import java.beans.PropertyChangeListener;\r
+import java.util.Set;\r
import java.util.Vector;\r
\r
import org.apache.log4j.Logger;\r
import eu.etaxonomy.cdm.model.name.Rank;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
-import eu.etaxonomy.cdm.model.reference.Generic;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.taxeditor.propertysheet.reference.IReferenceSearch;\r
import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;\r
+import eu.etaxonomy.taxeditor.propertysheet.reference.ReferenceSearchDescriptor;\r
+import eu.etaxonomy.taxeditor.propertysheet.type.TypeCollectionPropertySource;\r
+import eu.etaxonomy.taxeditor.propertysheet.type.TypePropertyDescriptor;\r
\r
/**\r
* @author p.ciardelli\r
// Property unique keys\r
public static final String P_ID_TAXONNAME = "P_ID_TAXONNAME";\r
public static final String P_ID_TAXONSEC = "P_ID_TAXONSEC";\r
+ public static final String P_ID_TYPES = "P_ID_TYPES";\r
\r
// Property display keys\r
- public static final String P_TAXONNAME = "00:Misapplied Name";\r
- public static final String P_TAXONSEC = "01:Sec";\r
+ public String P_TAXONNAME;\r
+ public static final String P_TAXONSEC = "01:Secundum";\r
+ public static final String P_TYPES = "02:Name Types";\r
\r
- public TaxonBasePropertySource(TaxonBase taxon) {\r
+ \r
+ public TaxonBasePropertySource(TaxonBase taxon, String nameTitle) {\r
this.taxon = taxon;\r
\r
+ this.P_TAXONNAME = "00:" + nameTitle;\r
+ \r
addDescriptor(P_ID_TAXONNAME);\r
addDescriptor(P_ID_TAXONSEC);\r
+ addDescriptor(P_ID_TYPES); \r
}\r
\r
protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>();\r
if (id.equals(P_ID_TAXONNAME)) {\r
descriptors.addElement(\r
new PropertyDescriptor(P_ID_TAXONNAME, P_TAXONNAME));\r
- }\r
- \r
+ } \r
if (id.equals(P_ID_TAXONSEC)) {\r
- descriptors.addElement(\r
- new PropertyDescriptor(P_ID_TAXONSEC, P_TAXONSEC));\r
+ descriptors.addElement(new ReferenceSearchDescriptor(P_ID_TAXONSEC, P_TAXONSEC, IReferenceSearch.BIBREF) {\r
+ protected void saveReference(ReferenceBase reference) {\r
+ setPropertyValue(P_ID_TAXONSEC, reference);\r
+ }\r
+ });\r
}\r
+ if (id.equals(P_ID_TYPES)) {\r
+ descriptors.addElement(\r
+ new TypePropertyDescriptor(P_ID_TYPES, P_TYPES, taxon.getName()) {\r
+ protected void saveTypes(Set set) {\r
+ setPropertyValue(P_ID_TYPES, set);\r
+ }\r
+ }\r
+ );\r
+ };\r
}\r
\r
/* (non-Javadoc)\r
// Edit taxon's name\r
if (id.equals(P_ID_TAXONNAME)) {\r
\r
+ if (taxon == null) {\r
+ logger.warn("no taxon");\r
+ return null;\r
+ }\r
TaxonNameBase name = taxon.getName();\r
\r
// Create taxon name as necessary\r
\r
// Edit taxon's sec. reference\r
if (id.equals(P_ID_TAXONSEC)) {\r
- \r
- ReferenceBase sec = taxon.getSec();\r
- \r
- // Create sec reference as necessary\r
- if (sec == null) {\r
- sec = Generic.NewInstance();\r
+\r
+ if (taxon == null) {\r
+ return null;\r
}\r
+ ReferenceBase sec = taxon.getSec();\r
\r
// Create property source for submenu\r
ReferencePropertySource secPropertySource = new ReferencePropertySource(sec);\r
return secPropertySource;\r
}\r
\r
+ if (id.equals(P_ID_TYPES)) {\r
+ if (taxon.getName() != null) {\r
+ return new TypeCollectionPropertySource(taxon.getName(), taxon.getName().getSpecimenTypeDesignations());\r
+ }\r
+ }\r
+ \r
return null;\r
}\r
\r
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)\r
*/\r
public void setPropertyValue(Object id, Object value) {\r
- // All setting done in submenus\r
+ if (id.equals(P_ID_TAXONSEC)) {\r
+ if (value instanceof ReferenceBase) {\r
+ taxon.setSec((ReferenceBase) value);\r
+ }\r
+ }\r
}\r
}\r