Fixes #2740
authorn.hoffmann <n.hoffmann@localhost>
Mon, 23 Jan 2012 10:58:24 +0000 (10:58 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 23 Jan 2012 10:58:24 +0000 (10:58 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermVocabularyDetailElement.java

index 118e915f03e153d3088de3c7f039b94b1a82350d..2f90fbb2fe5a2e0d7aae4da4bd2d357183398c1b 100644 (file)
@@ -9,15 +9,11 @@
 */\r
 package eu.etaxonomy.taxeditor.ui.section.vocabulary;\r
 \r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
-import eu.etaxonomy.cdm.model.common.Marker;\r
-import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.common.Representation;\r
 import eu.etaxonomy.cdm.model.common.TermBase;\r
 import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
 import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;\r
@@ -34,6 +30,7 @@ public abstract class AbstractTermBaseDetailElement<T extends TermBase> extends
        protected TextWithLabelElement text_label;\r
        protected TextWithLabelElement text_description;\r
        protected UriWithLabelElement uri_uri;\r
+       protected TextWithLabelElement text_abbreviatedLabel;\r
        \r
        /**\r
         * @param formFactory\r
@@ -50,9 +47,17 @@ public abstract class AbstractTermBaseDetailElement<T extends TermBase> extends
        @Override\r
        protected void createControls(ICdmFormElement formElement,\r
                        T entity, int style) {\r
-               text_label = formFactory.createTextWithLabelElement(formElement, "Label", getEntity().getLabel(), style);\r
+               Representation representation = getEntity().getRepresentation(CdmStore.getDefaultLanguage());\r
+               \r
+               if(representation == null){\r
+                       formFactory.createLabel(formElement, "No represantation for the current default Language");\r
+                       return;\r
+               }\r
+               \r
+               text_label = formFactory.createTextWithLabelElement(formElement, "Label", representation.getLabel(), style);\r
+               text_abbreviatedLabel = formFactory.createTextWithLabelElement(formElement, "Abbrev. Label", representation.getAbbreviatedLabel(), style);\r
                text_description = formFactory.createMultilineTextWithLabel(formElement, "Description", 100, style);\r
-               text_description.setText(getEntity().getDescription());\r
+               text_description.setText(representation.getDescription());\r
                uri_uri = formFactory.createUriWithLabelElement(formElement, "URI", getEntity().getUri(), style);\r
                \r
        }\r
@@ -62,6 +67,22 @@ public abstract class AbstractTermBaseDetailElement<T extends TermBase> extends
                super.setEntity(entity);\r
                setEnabled(TermBasePropertyTester.isModifiable(entity));\r
        }\r
+       \r
+       protected void handleRepresentation(Object eventSource){\r
+               Representation representation = getEntity().getRepresentation(CdmStore.getDefaultLanguage());\r
+               \r
+               if (representation == null){\r
+                       return;\r
+               }\r
+               \r
+               if (eventSource == text_label){\r
+                       representation.setLabel(text_label.getText());\r
+               }else if (eventSource == text_abbreviatedLabel){\r
+                       representation.setAbbreviatedLabel(text_abbreviatedLabel.getText());\r
+               }else if (eventSource == text_description){\r
+                       representation.setText(text_description.getText());\r
+               }\r
+       }\r
 \r
        public abstract TermVocabulary getVocabulary();\r
                \r
index 5c210aecdc296a5de9db7eee73e50fe18df66c72..98945bfe1ad989704f7f5e551727929563ca7a08 100644 (file)
@@ -13,6 +13,7 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.Language;\r
 import eu.etaxonomy.cdm.model.common.Representation;\r
 import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
 \r
@@ -37,12 +38,7 @@ public class DefinedTermDetailElement<T extends DefinedTermBase> extends Abstrac
         */\r
        @Override\r
        public void handleEvent(Object eventSource) {\r
-               if (eventSource == text_label){\r
-                       getEntity().setLabel(text_label.getText());\r
-               }else if (eventSource == text_description){\r
-                       Representation representation = getEntity().getRepresentation(Language.DEFAULT());\r
-                       representation.setText(text_description.getText());\r
-               }\r
+               handleRepresentation(eventSource);\r
        }\r
 \r
        /* (non-Javadoc)\r
index a4dabeef1fadf34d5a5c969a6ccae933e53a2fbd..1cbaa5c96e88c2427c7729ddb493154e9da2711b 100644 (file)
 package eu.etaxonomy.taxeditor.ui.section.vocabulary;\r
 \r
 import java.net.URISyntaxException;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
 \r
 import eu.etaxonomy.cdm.model.common.Language;\r
-import eu.etaxonomy.cdm.model.common.Marker;\r
 import eu.etaxonomy.cdm.model.common.Representation;\r
 import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
 import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;\r
@@ -46,7 +45,7 @@ public class TermVocabularyDetailElement extends AbstractTermBaseDetailElement<T
                        TermVocabulary entity, int style) {\r
                \r
                super.createControls(formElement, entity, style);\r
-               uri_uriTermSource = formFactory.createUriWithLabelElement(formElement, "URI Term Source", getEntity().getTermSourceUri(), style);\r
+               uri_uriTermSource = formFactory.createUriWithLabelElement(formElement, "Term Source URI", getEntity().getTermSourceUri(), style);\r
        }\r
 \r
        /* (non-Javadoc)\r
@@ -55,27 +54,19 @@ public class TermVocabularyDetailElement extends AbstractTermBaseDetailElement<T
        @Override\r
        public void handleEvent(Object eventSource) {\r
                \r
-               if (eventSource == text_label) {\r
-                       getEntity().setLabel(text_label.getText());\r
-                       getEntity().setTitleCache(null);\r
-               } else if (eventSource == text_description) {\r
-                       \r
-                       Representation representation = getEntity().getRepresentation(Language.DEFAULT());\r
-                       representation.setText(text_description.getText());\r
-               } else if (eventSource == uri_uri) {\r
-                       \r
+               handleRepresentation(eventSource);\r
+               \r
+               if (eventSource == uri_uri) {\r
                        try {\r
                                getEntity().setUri(uri_uri.getUri());\r
                        } catch (URISyntaxException e) {\r
-                               \r
-                               e.printStackTrace();\r
+                               StoreUtil.errorDialog("Not a URI", getClass(), "You have to provide a valid URI");\r
                        }\r
                } else if (eventSource == uri_uriTermSource) {\r
                        try {\r
                                getEntity().setTermSourceUri(uri_uriTermSource.getUri());\r
                        } catch (URISyntaxException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
+                               StoreUtil.errorDialog("Not a URI", getClass(), "You have to provide a valid URI");\r
                        }\r
                }\r
        }\r