commit cb1498eaae20b613517905baa613566cdd286dbf
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Thu Nov 24 14:27:33 2016 +0100

    ref #6216 Added button to select color instead of clicking on color
    field
    
     - resized color field

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/PresenceAbsenceTermDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/PresenceAbsenceTermDetailElement.java
index 3515b23ca..08f6dc43f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/PresenceAbsenceTermDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/PresenceAbsenceTermDetailElement.java
@@ -11,20 +11,28 @@ package eu.etaxonomy.taxeditor.ui.section.vocabulary;
 
 import java.text.ParseException;
 
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.TableWrapData;
 
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 
 /**
  *
@@ -32,12 +40,14 @@ import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
  * @date Nov 24, 2016
  *
  */
-public class PresenceAbsenceTermDetailElement extends DefinedTermDetailElement<PresenceAbsenceTerm> implements MouseListener{
+public class PresenceAbsenceTermDetailElement extends DefinedTermDetailElement<PresenceAbsenceTerm> implements SelectionListener{
 
     private Label colorLabel;
 
     private Color color;
 
+    private Button btnColorChooser;
+
 	public PresenceAbsenceTermDetailElement(CdmFormFactory formFactory,
 			ICdmFormElement formElement) {
 		super(formFactory, formElement);
@@ -49,16 +59,35 @@ public class PresenceAbsenceTermDetailElement extends DefinedTermDetailElement<P
 
 	    Label colorTextLabel = new Label(getLayoutComposite(), style);
 	    colorTextLabel.setText("Color");
-	    colorLabel = new Label(getLayoutComposite(), style);
-	    colorLabel.addMouseListener(this);
-
-	    String defaultColor = entity.getDefaultColor();
-	    if(defaultColor!=null){
-	        java.awt.Color awtColor = java.awt.Color.decode("#"+defaultColor);
+	    TableWrapData left = LayoutConstants.LEFT();
+	    left.valign = TableWrapData.MIDDLE;
+	    colorTextLabel.setLayoutData(left);
+	    addControl(colorTextLabel);
+
+	    //composite(color label + button)
+        Composite colorAndButton = formFactory.createComposite(getLayoutComposite(), style);
+        addControl(colorAndButton);
+        GridLayout layout = new GridLayout(2, false);
+        layout.marginWidth = 0;
+        colorAndButton.setLayout(layout);
+
+        colorLabel = new Label(colorAndButton, style|SWT.BORDER);
+        colorLabel.setLayoutData(new GridData(16, 16));
+
+        String defaultColor = entity.getDefaultColor();
+        if(defaultColor!=null){
+            //TODO: Is there any utility method from SWT?
+            java.awt.Color awtColor = java.awt.Color.decode("#"+defaultColor);
             RGB rgb = new RGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
-	        color = new Color(AbstractUtility.getShell().getDisplay(), rgb);
-	        colorLabel.setBackground(color);
-	    }
+            color = new Color(AbstractUtility.getShell().getDisplay(), rgb);
+            colorLabel.setBackground(color);
+        }
+
+        //button
+        btnColorChooser = formFactory.createButton(colorAndButton, "", SWT.NONE); //$NON-NLS-1$
+        btnColorChooser.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
+        btnColorChooser.setToolTipText("Choose color");
+        btnColorChooser.addSelectionListener(this);
 	}
 
 	@Override
@@ -75,22 +104,7 @@ public class PresenceAbsenceTermDetailElement extends DefinedTermDetailElement<P
      * {@inheritDoc}
      */
     @Override
-    public void mouseDoubleClick(MouseEvent e) {
-
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void mouseDown(MouseEvent e) {
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void mouseUp(MouseEvent e) {
+    public void widgetSelected(SelectionEvent e) {
         ColorDialog dialog = new ColorDialog(AbstractUtility.getShell());
         if(color!=null){
             dialog.setRGB(color.getRGB());
@@ -112,4 +126,11 @@ public class PresenceAbsenceTermDetailElement extends DefinedTermDetailElement<P
         firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+    }
+
 }
