import org.eclipse.swt.widgets.Table;\r
import org.eclipse.swt.widgets.Text;\r
\r
+import eu.etaxonomy.cdm.model.common.AnnotatableEntity;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
\r
public class AnnotationsDialog extends Dialog {\r
\r
private WritableList list = new WritableList();\r
private Annotation selectedAnnotation;\r
+ private AnnotatableEntity entity;\r
\r
/**\r
* Create the dialog\r
this(parent, SWT.NONE);\r
}\r
\r
- public AnnotationsDialog(Shell parent, Set<Annotation> annotations) {\r
+ public AnnotationsDialog(Shell parent, AnnotatableEntity entity) {\r
this(parent, SWT.NONE);\r
+ this.entity = entity;\r
+ Set<Annotation> annotations = entity.getAnnotations();\r
for (Annotation annotation : annotations) {\r
list.add(annotation);\r
}\r
addButton.addMouseListener(new MouseAdapter() {\r
@Override\r
public void mouseDown(MouseEvent e) {\r
+ if (text.getText().equals("")) {\r
+ return;\r
+ }\r
Annotation annotation = Annotation.NewInstance(text.getText(), null);\r
list.add(annotation);\r
+ entity.addAnnotation(annotation);\r
text.setText("");\r
}\r
});\r
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));\r
table.setLinesVisible(false);\r
table.setHeaderVisible(false);\r
-// table.s\r
new Label(composite, SWT.NONE);\r
\r
ObservableListContentProvider providerList = new ObservableListContentProvider();\r
\r
public void run() {\r
list.remove(annotation);\r
+ entity.removeAnnotation(annotation);\r
}\r
}\r
}
\ No newline at end of file
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
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.IReferenceSearch;\r
import eu.etaxonomy.taxeditor.propertysheet.reference.NomenclaturalReferencePropertySource;\r
import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;\r
-import eu.etaxonomy.taxeditor.propertysheet.reference.ReferenceSearchDescriptor;\r
\r
/**\r
* @author p.ciardelli\r
public static final String P_NAMERELATIONS = "11:Name Relations";\r
public static final String P_TYPE = "12:Type";\r
public static final String P_ANNOTATIONS = "14:Annotations";\r
- public static final String P_NOMSTATUS = "10:Nomenclatural Status";\r
+ public static final String P_NOMSTATUS = "100:Nomenclatural Status";\r
public static final String P_UUID = "01:UUID";\r
public static final String P_NUM_OF_BASES = "12:Number of Bases";\r
public static final String P_MARKERS = "13:Markers";\r
public static final String P_CREATEDBY = "16:Created By";\r
public static final String P_NOMENCLATURAL_CODE = "02:Nomenclatural Code";\r
public static final String P_NOMENCLATURAL_REF = "09:Nomenclatural Reference";\r
- public static final String P_NOMENCLATURAL_MICROREF = "10:Micro Reference";\r
+ public static final String P_NOMENCLATURAL_MICROREF = "10:Reference Detail";\r
\r
protected static final String[] TOP_LEVEL_PROPERTIES = new String[] {\r
P_ID_PARSED, P_ID_RANK, P_ID_TITLECACHE, P_ID_ANNOTATIONS, P_ID_NOMSTATUS, \r
P_ID_NAMERELATIONS, P_ID_UUID, P_ID_NOMENCLATURAL_REF, P_ID_NOMENCLATURAL_MICROREF,\r
- P_ID_TYPE, P_ID_CREATED, P_ID_CREATEDBY, P_ID_NOMENCLATURAL_CODE }; \r
+ P_ID_CREATED, P_ID_CREATEDBY, P_ID_NOMENCLATURAL_CODE }; \r
\r
// ***********************************************************\r
// RANKS\r
P_RANK_MENU = ranksMenuList.toArray(new String[ranksMenuList.size()]);\r
}\r
\r
- static String[] P_NOMENCLATURALCODE_MENU = new String[] { "ICZN", "ICBN" };\r
- static String[] P_NOMREF_TYPE_MENU = new String[] { "Article", "Bibtex", "Book", "Book Section", "Generic" }; \r
-\r
// ***********************************************************\r
// NOMENCLATURAL STATUS\r
// ***********************************************************\r
- static TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
- TaxEditorPlugin.getDefault().getNomStatusVocabulary();\r
- static NomenclaturalStatusType[] nomStatusTypes = null;\r
- static String[] P_NOMSTATUS_MENU = null;\r
- private static void populateNomStatusTypes() {\r
+// static TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
+// TaxEditorPlugin.getDefault().getNomStatusVocabulary();\r
+ NomenclaturalStatusType[] nomStatusTypes = null;\r
+ String[] P_NOMSTATUS_MENU = null;\r
+ private void populateNomStatusTypes() {\r
\r
// Get terms from nom status vocabulary\r
List<NomenclaturalStatusType> nomStatusTypesList = new ArrayList<NomenclaturalStatusType>();\r
- nomStatusTypesList.addAll(nomStatusVocabulary.getTerms());\r
+ TermVocabulary<NomenclaturalStatusType> statusVocab = TaxEditorPlugin.getDefault().getNomStatusVocabulary();\r
+ \r
+ // If there is no status vocabulary, init type and status w empty arrays and return\r
+ if (statusVocab == null) {\r
+ nomStatusTypes = new NomenclaturalStatusType[]{};\r
+ P_NOMSTATUS_MENU = new String[]{};\r
+ return;\r
+ }\r
+ \r
+ nomStatusTypesList.addAll(statusVocab.getTerms());\r
\r
// Populate nom status type menu labels \r
List<String> nomStatusTypesMenuList = new ArrayList<String>();\r
descriptors.addElement(\r
new AnnotationsPropertyDescriptor(P_ID_ANNOTATIONS, P_ANNOTATIONS, name) {\r
protected void saveAnnotations(Set set) {\r
- \r
setPropertyValue(P_ID_ANNOTATIONS, set);\r
}\r
}\r
if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
descriptors.addElement(\r
new PropertyDescriptor(P_ID_NOMENCLATURAL_REF,P_NOMENCLATURAL_REF)); \r
-// descriptors.addElement(\r
-// new ReferenceSearchDescriptor(P_ID_NOMENCLATURAL_REF, P_NOMENCLATURAL_REF, IReferenceSearch.NOMREF) {\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
\r
// Microreference\r
\r
// Authorship cache \r
if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
+// name.setProtectedAuthorshipCache(true);\r
name.setAuthorshipCache((String) value);\r
}\r
\r
- // Annotations \r
- if (id.equals(P_ID_ANNOTATIONS)) {\r
- if (value instanceof Set) {\r
- \r
- Set existingAnnotations = name.getAnnotations(); \r
- Set newAnnotations = (Set) value;\r
- \r
- for (Object object : newAnnotations) {\r
- if (object instanceof Annotation && !existingAnnotations.contains(object)) {\r
- name.addAnnotation((Annotation) object);\r
- }\r
- }\r
- \r
- for (Object object : existingAnnotations) {\r
- if (object instanceof Annotation && !newAnnotations.contains(object)) {\r
- name.removeAnnotation((Annotation) object);\r
- } \r
- }\r
- \r
- }\r
- }\r
// Nomenclatural status \r
if (id.equals(P_ID_NOMSTATUS)) {\r
NomenclaturalStatus nomStatus;\r
name.setNomenclaturalMicroReference((String) value);\r
}\r
\r
- // Reset both caches to reflect property sheet changes\r
- name.setTitleCache(name.generateTitle(), false);\r
- name.setFullTitleCache(name.generateFullTitle(), false);\r
+ // If there is no rank, generated caches will be blank, wiping out the freetext area\r
+ if (name.getRank() != null) {\r
+ \r
+ // Reset both caches to reflect property sheet changes\r
+ name.setTitleCache(name.generateTitle(), false);\r
+ name.setFullTitleCache(name.generateFullTitle(), false);\r
+ }\r
\r
name.firePropertyChange(ITaxEditorConstants.REFRESH_NAMEVIEWER, null, null);\r
\r