ref #9838: change order of ui element creation and setting entity in collection elements
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / media / MediaRepresentationPartElement.java
index b8cc1294b02341a85c368efba8d167a20845518e..ea9d55dc9ea2fc0f4cc188bb9bc15d9f9195b8a7 100644 (file)
@@ -45,23 +45,28 @@ public class MediaRepresentationPartElement<T extends MediaRepresentationPart> e
                text_uri = formFactory.createUriWithLabelElement(element, "URI", null, style);
                text_size = formFactory.createFloatTextWithLabelElement(element, "Size", null, style);
                text_size.setEnabled(false);
+               if (entity != null){
+                       setEntity(entity);
+               }
        }
 
        @Override
        public void setEntity(T entity) {
                this.entity = entity;
-               if(entity.getSize() != null){
-                       text_size.setText(FileUtils.byteCountToDisplaySize(entity.getSize()));
+               if (text_size != null){
+                       if(entity.getSize() != null){
+                               text_size.setText(FileUtils.byteCountToDisplaySize(entity.getSize()));
+                       }
+                       if(entity.getUri() != null){
+                               text_uri.setParsedText(entity.getUri());
+                       } else {
+                   String uriBuffer = getParentMediaDetailElement().getUriBuffer();
+                   if(uriBuffer!=null){
+                       text_uri.setText(uriBuffer);
+                       text_uri.parseText();//just to update the error label
+                   }
+               }
                }
-               if(entity.getUri() != null){
-                       text_uri.setParsedText(entity.getUri());
-               } else {
-            String uriBuffer = getParentMediaDetailElement().getUriBuffer();
-            if(uriBuffer!=null){
-                text_uri.setText(uriBuffer);
-                text_uri.parseText();//just to update the error label
-            }
-        }
        }
 
        @Override