ref #8011 Layout improvements
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 15 Feb 2019 13:31:28 +0000 (14:31 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 15 Feb 2019 13:31:28 +0000 (14:31 +0100)
 - wrap description text
 - Use SashForm for SearchComposite

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/SearchComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/term/TermSearchResultComposite.java

index 1cb7b8bbf2bf5e22ed48c8053842209a16d93744..deb6e2186a759c0af678c44e95765b47446492a4 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.view.search.facet;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -24,13 +25,12 @@ import eu.etaxonomy.taxeditor.model.ImageResources;
  * @date 22.01.2019
  *
  */
-public class SearchComposite extends Composite {
+public class SearchComposite extends SashForm {
     private Text txtSearch;
     private ScrolledComposite filterScrolledComposite;
     private Composite filterListComposite;
     private Composite searchResultComposite;
     private ScrolledComposite resultScrolledComposite;
-    private Composite composite;
     private Button btnSearchButton;
 
     /**
@@ -45,10 +45,9 @@ public class SearchComposite extends Composite {
         Composite filterComposite = new Composite(this, SWT.NONE);
         filterComposite.setLayout(new GridLayout(1, false));
         GridData gd_filterComposite = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
-        gd_filterComposite.widthHint = 170;
         filterComposite.setLayoutData(gd_filterComposite);
 
-        composite = new Composite(filterComposite, SWT.NONE);
+        Composite composite = new Composite(filterComposite, SWT.NONE);
         composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
         composite.setLayout(new GridLayout(2, false));
 
@@ -73,6 +72,7 @@ public class SearchComposite extends Composite {
         resultScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
         resultScrolledComposite.setExpandHorizontal(true);
         resultScrolledComposite.setExpandVertical(true);
+        setWeights(new int[] {40, 60});
 
         initSearchResultList();
 
index c15bbe7cc94c5c350e173b9f87aee028984dfecb..13367a887bd53e01f4aea62a4c85a5952dd5edc4 100644 (file)
@@ -11,8 +11,8 @@ package eu.etaxonomy.taxeditor.view.search.facet.term;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DragDetectEvent;
-import org.eclipse.swt.events.DragDetectListener;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
@@ -38,21 +38,24 @@ public class TermSearchResultComposite extends CheckBoxSearchResultComposite<Ter
     public Composite createContent(Composite parent) {
         Composite content = new Composite(this, SWT.NONE);
         content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
-        content.setLayout(new GridLayout(1, false));
-        label = new Label(content, SWT.NONE);
+        GridLayout layout = new GridLayout(1, false);
+        content.setLayout(layout);
+        label = new Label(content, SWT.WRAP);
         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.addDragDetectListener(new DragDetectListener() {
 
+        Label lblDescription = new Label(content, SWT.WRAP);
+        GridData layoutData = new GridData();
+        lblDescription.setLayoutData(layoutData);
+        parent.addControlListener(new ControlAdapter() {
             @Override
-            public void dragDetected(DragDetectEvent e) {
-                System.out.println("dragDetected");
+            public void controlResized(ControlEvent e) {
+                layoutData.widthHint = parent.getClientArea().width - (6*layout.marginWidth);
+                parent.layout(true);
             }
         });
-
-        Label lblDescription = new Label(content, SWT.NONE);
         String representation_L10n_text = result.getContent().getRepresentation_L10n_text();
         if(representation_L10n_text!=null){
             lblDescription.setText(representation_L10n_text);