fix #6947: fix error for empty lsid field
authorKatja Luther <k.luther@bgbm.org>
Fri, 13 Nov 2020 12:39:29 +0000 (13:39 +0100)
committerKatja Luther <k.luther@bgbm.org>
Fri, 13 Nov 2020 12:39:29 +0000 (13:39 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractUriWithExceptionLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/DoiWithLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java

index 8712650efe71558ea33e70d5fc0e0b01908b2cd6..600e024d490f86cf2078a9745e21b0dce8860720 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
 import eu.etaxonomy.taxeditor.l10n.Messages;
@@ -45,7 +46,7 @@ public abstract class AbstractUriWithExceptionLabelElement <T> extends TextWithL
         initText(formFactory, null, textHeight, null, false, style, getLayoutComposite());
 
         //exceptionLabel
-//        initExceptionLabel(getLayoutComposite(), formFactory, initialObject);
+        initExceptionLabel(getLayoutComposite(), formFactory);
     }
 
     protected void initExceptionLabel(Composite parent, CdmFormFactory formFactory) {
@@ -56,8 +57,10 @@ public abstract class AbstractUriWithExceptionLabelElement <T> extends TextWithL
                }
         labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(numColumns, 1));
         labelException.setBackground(getPersistentBackground());
+        labelException.setSize(1, 1);
         labelException.setData("exceptionLabel");
                addControl(labelException);
+               this.getLayoutComposite().layout();
     }
 
     public abstract void setParsedText(T object);
@@ -66,16 +69,20 @@ public abstract class AbstractUriWithExceptionLabelElement <T> extends TextWithL
 
     public T parseText(){
         try {
-            removeLabelException();
-//            labelException.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
-//            labelException.setForeground(getPersistentBackground());
-//            labelException.setText(""); //$NON-NLS-1$
+            labelException.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
+            labelException.setForeground(getPersistentBackground());
+            labelException.setText(""); //$NON-NLS-1$
             return getParsedText();
         } catch (Exception e) {
-            initExceptionLabel(getLayoutComposite(), formFactory);
+            int numColumns = AbstractFormSection.DEFAULT_NUM_COLUMNS;
+            if(getLayoutComposite().getLayout() instanceof TableWrapLayout){
+                numColumns = ((TableWrapLayout)getLayoutComposite().getLayout()).numColumns;
+            }
+            TableWrapData layoutData = LayoutConstants.FILL_HORIZONTALLY(numColumns, 1);
             labelException.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
             labelException.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
             labelException.setText(Messages.UriWithLabelElement_URL_NOT_SAVED + e.getLocalizedMessage());
+            this.getLayoutComposite().redraw();
             return null;
         }
     }
index bf0c69beb11e60f75a51fb8501b9c35da98a6f0f..5d0c61a747cc5e25ec83e81e6436d6d7ad1fed6c 100755 (executable)
@@ -116,7 +116,7 @@ public class DoiWithLabelElement extends AbstractUriWithExceptionLabelElement<DO
             }
         });
         btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
-//        initExceptionLabel(getLayoutComposite(), formFactory);
+        initExceptionLabel(getLayoutComposite(), formFactory);
     }
 
     @Override
index 3e8b84b88d8162b729ec8640b07589cc7ef1ee41..99c7608e0b67ad8a1c8fe67cfb45ba1ea6bf9787 100644 (file)
@@ -82,7 +82,7 @@ public class UriWithLabelElement extends AbstractUriWithExceptionLabelElement<UR
         });
         btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
 
-//        initExceptionLabel(getLayoutComposite(), formFactory, initialObject);
+        initExceptionLabel(getLayoutComposite(), formFactory);
     }
 
     @Override