]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Automatic table column resizing for SCL console manage imports dialog. 27/427/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 19 Apr 2017 08:02:46 +0000 (11:02 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 19 Apr 2017 08:36:51 +0000 (11:36 +0300)
refs #7150

Change-Id: Ie951241aaccbaa266eaaa42369ced699dd56aafb
(cherry picked from commit 233d645861c82dddfc49e3c8a144ce0d0cbf4319)

bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/imports/internal/ManageImportsDialog.java

index 082a1511448abe7e2f3d849ae2dd738c0026f7a7..f8fb202e3375c9f3b96174e8efd855b8b17a03c9 100644 (file)
@@ -10,10 +10,12 @@ import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.dialogs.TrayDialog;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.TableColumnLayout;
 import org.eclipse.jface.resource.FontDescriptor;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnWeightData;
 import org.eclipse.jface.viewers.EditingSupport;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
@@ -77,9 +79,13 @@ public class ManageImportsDialog extends TrayDialog {
         final Composite composite = (Composite) super.createDialogArea(parent);
         GridLayoutFactory.fillDefaults().margins(10,10).numColumns(2).applyTo(composite);
         GridDataFactory.fillDefaults().grab(true,true).applyTo(composite);
-        
-        tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(tableViewer.getControl());
+
+        Composite tableComposite = new Composite(composite, SWT.NONE);
+        TableColumnLayout tcl = new TableColumnLayout();
+        tableComposite.setLayout(tcl);
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite);
+
+        tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
 
         // Colors
         Display display = getShell().getDisplay(); 
@@ -186,6 +192,10 @@ public class ManageImportsDialog extends TrayDialog {
             }
         });
         
+        tcl.setColumnData(column1.getColumn(), new ColumnWeightData(5, 300));
+        tcl.setColumnData(column2.getColumn(), new ColumnWeightData(1, 150));
+        tcl.setColumnData(column3.getColumn(), new ColumnWeightData(1, 200));
+        
         // Decorations
         tableViewer.getTable().setHeaderVisible(true);
         tableViewer.getTable().setLinesVisible(true);