Add checkbox to result composite
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / search / facet / term / TermSearchResultComposite.java
index 57354b6942bf98846a8a81a41f1265ec015cdb41..e7114a1cf0150d94882f322f68cdceda07f67ce2 100644 (file)
@@ -17,16 +17,12 @@ import org.eclipse.swt.events.FocusEvent;
 import org.eclipse.swt.events.FocusListener;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 
-import eu.etaxonomy.taxeditor.model.ColorResources;
-import eu.etaxonomy.taxeditor.preference.Resources;
-
 /**
  * @author pplitzner
  * @since Jan 23, 2019
@@ -37,7 +33,8 @@ public class TermSearchResultComposite extends Composite {
     private Label label;
     private boolean isSelected;
     private TermSearchResult result;
-    private Label lblItemDash;
+    private Button btnCheck;
+    private Composite composite_1;
 
     /**
      * Create the composite.
@@ -56,18 +53,20 @@ public class TermSearchResultComposite extends Composite {
         setLayout(gridLayout);
 
         Composite composite = new Composite(this, SWT.NONE);
-        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
-        composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 2));
+        composite.setLayout(new GridLayout(1, false));
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+
+        btnCheck = new Button(composite, SWT.CHECK);
+        btnCheck.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
 
-        lblItemDash = new Label(composite, SWT.NONE);
-        lblItemDash.setText("   -   ");
-        label = new Label(this, SWT.NONE);
+        composite_1 = new Composite(this, SWT.NONE);
+        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
+        composite_1.setLayout(new GridLayout(1, false));
+        label = new Label(composite_1, SWT.NONE);
+        label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
         label.setText(result.getContent().getRepresentation_L10n());
         label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
         GridDataFactory.fillDefaults().applyTo(label);
-
-        Label lblDescription = new Label(this, SWT.NONE);
-        lblDescription.setText("Some description of the term. This can be a longer text. Also images appear in this area if they are present.");
         label.addFocusListener(new FocusListener() {
 
             @Override
@@ -93,7 +92,6 @@ public class TermSearchResultComposite extends Composite {
             public void mouseUp(MouseEvent e) {
                 System.out.println("mouseUp");
                 isSelected = !isSelected;
-                setBgColor();
             }
 
 
@@ -106,6 +104,9 @@ public class TermSearchResultComposite extends Composite {
                 System.out.println("mouseDoubleClick");
             }
         });
+
+        Label lblDescription = new Label(composite_1, SWT.NONE);
+        lblDescription.setText("Some description of the term. This can be a longer text. Also images appear in this area if they are present.");
     }
 
     public boolean isSelected() {
@@ -116,22 +117,11 @@ public class TermSearchResultComposite extends Composite {
         return result;
     }
 
-    private void setBgColor() {
-        if(isSelected){
-            Color colorSelected = ColorResources.getColor(Resources.COLOR_LIST_EVEN);
-            TermSearchResultComposite.this.setBackground(colorSelected);
-            label.setBackground(colorSelected);
-            lblItemDash.setBackground(colorSelected);
-        }
-        else{
-            Color colorControlBackground = ColorResources.getColor(Resources.COLOR_SWT_BG_DEFAULT);
-            TermSearchResultComposite.this.setBackground(colorControlBackground);
-            label.setBackground(colorControlBackground);
-            lblItemDash.setBackground(colorControlBackground);
-        }
-    }
     @Override
     protected void checkSubclass() {
         // Disable the check that prevents subclassing of SWT components
     }
+    public Button getBtnCheck() {
+        return btnCheck;
+    }
 }