Merge branch 'develop' of ssh://dev.e-taxonomy.eu/var/git/taxeditor into develop
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 25 Aug 2015 08:21:25 +0000 (10:21 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 25 Aug 2015 08:21:25 +0000 (10:21 +0200)
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/AbstractFormSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/TextWithLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java

index 3c21795a881653ad9f600e5db57caf48d5f776c0..f7a01268f93f05b428b927c4244e5289f704b165 100644 (file)
@@ -17,3 +17,6 @@ LanguageEditorPreferencePage_RestartRequired=After changing the default language
 OrderPreferencePage_NewNavigatorWindowRequired=After changing the order of the taxon nodes, closing and reopen of the taxon navigator is required.\r
 OrderPreferencePage_PleaseReopenNavigator=Please close and reopen the taxon navigator.\r
 UriWithLabelElement_URL_NOT_SAVED=URL won't be saved\! \r
+UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URL is invalid.\r
+UriWithLabelElement_INVALID_URL=Invalid URL\r
+UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Open in external browser\r
index d03d93e3212ec61a52ba2a967485ccbf75d2d28f..51409eb7ab32f33627d760f932108590391f33eb 100644 (file)
@@ -15,4 +15,7 @@ LanguageEditorPreferencePage_EditorHasToRestart=Der Anwendung muss neu gestartet
 LanguageEditorPreferencePage_PleaseRestart=Bitte neu starten\r
 LanguageEditorPreferencePage_RestartRequired=Nach dem Wechsel der Standardsprache ist ein Neustart erforderlich.\r
 OrderPreferencePage_NewNavigatorWindowRequired=Nach dem Ändern der Taxon Sortierung, ist das Schließen und erneute Öffnen des taxon Navigators erforderlich.\r
-UriWithLabelElement_URL_NOT_SAVED=URL wird nicht gespeichert\! 
\ No newline at end of file
+UriWithLabelElement_URL_NOT_SAVED=URL wird nicht gespeichert\!\r
+UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnt nicht geöffnet werden. URL is ung\u00FCtlig.\r
+UriWithLabelElement_INVALID_URL=Ung\u00FCltiger URL\r
+UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Im Browser öffnen 
\ No newline at end of file
index b583632dc67d605b13f78c2873294140b1f4b386..0aa1e9c64bf59c75a92f0ac8e4439478b7219c74 100644 (file)
@@ -36,6 +36,9 @@ public class Messages extends NLS {
     public static String CdmDataSourceViewPart_7;
     public static String CdmDataSourceViewPart_8;
     public static String CdmDataSourceViewPart_9;
+    public static String UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
+    public static String UriWithLabelElement_INVALID_URL;
+    public static String UriWithLabelElement_OPEN_EXTERNAL_BROWSER;
     public static String UriWithLabelElement_URL_NOT_SAVED;
     static {
         // initialize resource bundle
index 336f39eb8bb75ba4d4f52a1a6ab6a1c9e9d67020..66f714a87147fcdd77112130eec42e3f64b3cf35 100644 (file)
@@ -160,6 +160,7 @@ public class ImageResources {
 
     public static final String CHARACTER_DATA_DERIVATE = "character_data_derivate";
 
+    public static final String WEB = "web";
 
 
        /***************************************************************************
@@ -381,6 +382,9 @@ public class ImageResources {
                registerImage(registry, CHARACTER_DATA_DERIVATE,
                        "character_data_derivate-16x16-32.png");
 
+               registerImage(registry, WEB,
+                       "web.gif");
+
        }
 
        private void registerImage(ImageRegistry registry, String key,
index 6afa2b7bff3931051f4dad493bc4a9231b920c7a..a50561e501a82bb5de8d37b8de0b2fb76dfdcc85 100644 (file)
@@ -52,6 +52,11 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 //TODO shouldn't ENTITY be bound with super class ICdmBase for example (AbstractFormSection<ENTITY extends ICdmBase>)?
 public abstract class AbstractFormSection<ENTITY> extends Section implements ISelectionChangedListener, IEntityElement<ENTITY>, IConversationEnabled {
 
+    /**
+     * The default number of columns in detail sections
+     */
+    public static final int DEFAULT_NUM_COLUMNS = 2;
+
        private ISelectionProvider selectionProvider;
 
        private ENTITY entity;
index d5f7b310542dc1212a42e43036f53a09078d8417..039b54c0d7826c31c25ce617e039b2e4ae892e80 100644 (file)
@@ -9,6 +9,7 @@ import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
@@ -19,10 +20,6 @@ import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.taxeditor.preference.Resources;
 
 /**
- * <p>
- * TextWithLabelElement class.
- * </p>
- *
  * @author n.hoffmann
  * @version $Id: $
  */
@@ -34,11 +31,14 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
 
     private final boolean isMultiLine;
 
-    /** Constant <code>MAX_HEIGHT=0</code> */
     public static final int MAX_HEIGHT = 0;
-    /** Constant <code>SINGLE=-1</code> */
     public static final int SINGLE = -1;
 
+    protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, boolean isMultiLine) {
+        super(formFactory, parentElement);
+        this.isMultiLine = isMultiLine;
+    }
+
     protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
             String initialText, Integer textHeight, int style) {
         this(formFactory, parentElement, labelString, initialText, textHeight, null, false, style);
@@ -54,45 +54,19 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
         this(formFactory, parentElement, labelString, initialText, textHeight, textLimit, false, style);
     }
 
-    /**
-     * <p>
-     * Constructor for TextWithLabelElement.
-     * </p>
-     *
-     * @param formFactory
-     *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
-     *            object.
-     * @param parentElement
-     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
-     *            object.
-     * @param labelString
-     *            a {@link java.lang.String} object.
-     * @param initialText
-     *            a {@link java.lang.String} object.
-     * @param textHeight
-     *            a {@link java.lang.Integer} object.
-     *            @param textLimit max characters allowed to enter
-     * @param style
-     *            a int.
-     * @wbp.parser.entryPoint
-     */
     protected TextWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
             String initialText, Integer textHeight, Integer textLimit, boolean isMultiLine, int style) {
         super(formFactory, parentElement);
 
         this.isMultiLine = isMultiLine;
 
-        if (labelString != null) {
-            label = formFactory.createLabel(getLayoutComposite(), CdmUtils.Nz(labelString), SWT.NULL);
-            addControl(label);
-            if(isMultiLine){
-                label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
-            }
-            else{
-                label.setLayoutData(LayoutConstants.LEFT());
-            }
-        }
+        initLabel(formFactory, labelString, isMultiLine, getLayoutComposite());
 
+        initText(formFactory, initialText, textHeight, textLimit, isMultiLine, style, getLayoutComposite());
+    }
+
+    protected void initText(CdmFormFactory formFactory, String initialText, Integer textHeight, Integer textLimit,
+            boolean isMultiLine, int style, Composite layoutComposite) {
         int scrollStyle = textHeight == null ? SWT.NULL : (SWT.V_SCROLL | SWT.MULTI);
 
         int combinedStyle = style | SWT.BORDER | scrollStyle;
@@ -102,7 +76,7 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
             combinedStyle = combinedStyle | SWT.WRAP;
         }
 
-        text = formFactory.createText(getLayoutComposite(), "", combinedStyle);
+        text = formFactory.createText(layoutComposite, "", combinedStyle);
         text.setTextLimit(textLimit!=null?textLimit:Text.LIMIT);
 
         addControl(text);
@@ -145,6 +119,19 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
         setText(initialText);
     }
 
+    protected void initLabel(CdmFormFactory formFactory, String labelString, boolean isMultiLine, Composite layoutComposite) {
+        if (labelString != null) {
+            label = formFactory.createLabel(layoutComposite, CdmUtils.Nz(labelString), SWT.NULL);
+            addControl(label);
+            if(isMultiLine){
+                label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+            }
+            else{
+                label.setLayoutData(LayoutConstants.LEFT());
+            }
+        }
+    }
+
     /**
      * Get the text of this composites text composite
      *
@@ -174,13 +161,6 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events
-     * .ModifyEvent)
-     */
     /** {@inheritDoc} */
     @Override
     public void modifyText(ModifyEvent e) {
@@ -211,9 +191,6 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
         text.setForeground(getColor(symbolicName));
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled()
-     */
     @Override
     public boolean isEnabled() {
         return text.isEnabled();
@@ -241,36 +218,16 @@ public class TextWithLabelElement extends AbstractCdmFormElement implements Modi
         setBackground(selected ? SELECTED : getPersistentBackground());
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#setFocus()
-     */
     /** {@inheritDoc} */
     @Override
     public void setFocus() {
         text.setFocus();
     }
 
-    /**
-     * <p>
-     * getMainControl
-     * </p>
-     *
-     * @return a {@link org.eclipse.swt.widgets.Control} object.
-     */
     public Control getMainControl() {
         return text;
     }
 
-    /**
-     * <p>
-     * setTextLimit
-     * </p>
-     *
-     * @param limit
-     *            a int.
-     */
     public void setTextLimit(int limit) {
         text.setTextLimit(limit);
     }
index 31486b409b4788876b0f697593e6c9dc7a7dbf6d..40a55fa89e2dedeffbd42715786802e66a2a43d4 100644 (file)
 
 package eu.etaxonomy.taxeditor.ui.element;
 
+import java.net.MalformedURLException;
 import java.net.URI;
 
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
 import eu.etaxonomy.taxeditor.Messages;
+import eu.etaxonomy.taxeditor.model.ImageResources;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
  * @author n.hoffmann
@@ -27,14 +40,59 @@ import eu.etaxonomy.taxeditor.Messages;
 public class UriWithLabelElement extends TextWithLabelElement {
 
     private final Label labelException;
+    private final Button btnOpenBrowser;
 
        protected UriWithLabelElement(CdmFormFactory formFactory,
                        ICdmFormElement parentElement, String labelString,
                        URI initialUri, Integer textHeight, int style) {
-               super(formFactory, parentElement, labelString, null, textHeight, style);
+               super(formFactory, parentElement, false);
+
+               //label
+        initLabel(formFactory, labelString, false, getLayoutComposite());
+
+        //composite(uri + button)
+        Composite textAndButton = formFactory.createComposite(getLayoutComposite(), style);
+        textAndButton.setLayout(LayoutConstants.LAYOUT(2, false));
+        textAndButton.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
+
+        //uri text
+        initText(formFactory, null, textHeight, null, false, style, textAndButton);
+
+        //button
+               btnOpenBrowser = formFactory.createButton(textAndButton, "", SWT.NONE); //$NON-NLS-1$
+               btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.WEB));
+               btnOpenBrowser.setToolTipText(Messages.UriWithLabelElement_OPEN_EXTERNAL_BROWSER);
+               btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
+                   @Override
+                   public void widgetSelected(SelectionEvent e) {
+                       String errorTitle = Messages.UriWithLabelElement_INVALID_URL;
+                       String errorText = Messages.UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
+
+                       URI uri = getUri();
+                       if(uri!=null){
+                           try {
+                        PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(uri.toURL());
+                    } catch (PartInitException pie) {
+                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, pie));
+                    } catch (MalformedURLException mue) {
+                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, mue));
+                    } catch (IllegalArgumentException iae) {
+                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, iae));
+                    }
+                       }
+                       else{
+                           MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, null));
+                       }
+                   }
+        });
+               btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
 
                labelException = formFactory.createLabel(getLayoutComposite(), "", SWT.WRAP); //$NON-NLS-1$
-               labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+               int numColumns = AbstractFormSection.DEFAULT_NUM_COLUMNS;
+               if(getLayoutComposite().getLayout() instanceof TableWrapLayout){
+                   numColumns = ((TableWrapLayout)getLayoutComposite().getLayout()).numColumns;
+               }
+        labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(numColumns, 1));
                addControl(labelException);
                setUri(initialUri);
        }
index 1d279078c2e55a8004b3448d2bbe20ac4ebd3a2c..cf2a786c869a2fd781942d8c52231af1900b5fea 100644 (file)
@@ -70,7 +70,7 @@ public abstract class AbstractCdmDetailSection<ENTITY> extends AbstractFormSecti
        protected void createControlsByType(AbstractCdmDetailSection<ENTITY> formElement, Class<ENTITY> entityClass, int style) {
            TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();
            layout.topMargin = 10;
-           layout.numColumns = 2;
+           layout.numColumns = DEFAULT_NUM_COLUMNS;
 
            getLayoutComposite().setLayout(layout);
            if(entityClass==null){