Safety checkin before taking out all references to nomenclatural reference that have...
authorp.ciardelli <p.ciardelli@localhost>
Thu, 13 Nov 2008 18:08:41 +0000 (18:08 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Thu, 13 Nov 2008 18:08:41 +0000 (18:08 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java

index ebe9ce189d8712c76af92e5a53384907b153ada0..30b8629c9dfad50e918e87a131fc8c0fc5d173db 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Set;
 import java.util.Vector;\r
 \r
 import org.apache.log4j.Logger;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;\r
 import org.eclipse.ui.views.properties.IPropertyDescriptor;\r
 import org.eclipse.ui.views.properties.IPropertySource;\r
@@ -47,6 +48,7 @@ import eu.etaxonomy.taxeditor.model.CdmUtil;
 import eu.etaxonomy.taxeditor.propertysheet.AnnotationPropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.AnnotationsPropertyDescriptor;\r
 import eu.etaxonomy.taxeditor.propertysheet.MarkersPropertySource;\r
+import eu.etaxonomy.taxeditor.propertysheet.reference.NomRefSearchDescriptor;\r
 import eu.etaxonomy.taxeditor.propertysheet.reference.NomenclaturalReferencePropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;\r
 \r
@@ -307,8 +309,15 @@ public class NonViralNamePropertySource implements IPropertySource {
                }\r
                if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
                        descriptors.addElement(\r
-//                                     new TextPropertyDescriptor(P_ID_NOMENCLATURAL_REF, P_NOMENCLATURAL_REF));\r
-                                       new PropertyDescriptor(P_ID_NOMENCLATURAL_REF, P_NOMENCLATURAL_REF));\r
+                                       new NomRefSearchDescriptor(P_ID_NOMENCLATURAL_REF, P_NOMENCLATURAL_REF) {\r
+                                               protected void saveReference(ReferenceBase reference) {\r
+                                                       if (reference instanceof INomenclaturalReference) {\r
+                                                               setPropertyValue(P_ID_NOMENCLATURAL_REF, reference);\r
+                                                       } else {\r
+                                                               MessageDialog.openError(UiUtil.getShell(), "Reference type error", "The selected reference cannot be used as a nomenclatural reference.");\r
+                                                       }\r
+                                               }\r
+                                       });\r
                }\r
                if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) {\r
                        descriptors.addElement(\r
@@ -317,7 +326,6 @@ public class NonViralNamePropertySource implements IPropertySource {
                if (id.equals(P_ID_NOMREF_TYPE)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_NOMREF_TYPE, P_NOMREF_TYPE));\r
-//                                     new ComboBoxPropertyDescriptor(P_ID_NOMREF_TYPE, P_NOMREF_TYPE, P_NOMREF_TYPE_MENU));\r
                }\r
                if (id.equals(P_ID_NOMREF_YEAR)) {\r
                        descriptors.addElement(\r
@@ -458,13 +466,6 @@ public class NonViralNamePropertySource implements IPropertySource {
                return "none (nonviral name)";\r
         }\r
         if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
-                       \r
-//             INomenclaturalReference nomenclaturalReference = (INomenclaturalReference) name.getNomenclaturalReference();\r
-//             if (name.getNomenclaturalReference() == null) {\r
-//                     return "";\r
-//             } else {\r
-//                     return new NonViralNamePropertySource(name, P_ID_NOMENCLATURAL_REF, getReferenceFields());\r
-//             }\r
                \r
                ReferenceBase nomRef = (ReferenceBase) name.getNomenclaturalReference();\r
                        \r
@@ -678,7 +679,9 @@ public class NonViralNamePropertySource implements IPropertySource {
                // TODO set markers\r
         }\r
         if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
-               // TODO ask Andreas M. how best to set nom. ref\r
+               if (value instanceof INomenclaturalReference) {\r
+                       name.setNomenclaturalReference((INomenclaturalReference) value);\r
+               }\r
         }\r
         if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) {\r
                name.setNomenclaturalMicroReference((String) value);\r