]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Make component addition dialog resizable and remember last dimensions 54/3854/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 6 Feb 2020 20:36:22 +0000 (22:36 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 6 Feb 2020 20:36:22 +0000 (22:36 +0200)
gitlab #73

Change-Id: I95f9e61cd930f5fc8dca46d45839e89510768b55

org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java

index 95b22512b7b06e534fe810a4ec37e195c179f930..720d88cec826729ba748870ace5a4acb7472b02a 100644 (file)
@@ -7,6 +7,7 @@ import java.util.Set;
 
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
 import org.eclipse.jface.resource.JFaceResources;
@@ -49,6 +50,10 @@ import org.simantics.utils.ui.ExceptionUtils;
 
 public class ComponentSelectionDialog extends Dialog implements ISelectionChangedListener {
 
+       private static final String DIALOG = "ComponentSelectionDialog"; //$NON-NLS-1$
+
+       private IDialogSettings dialogSettings;
+
        private ResourceManager resourceManager;
 
        private String libUri;
@@ -74,7 +79,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
        private Text lengthText;
        // Turn component
        private Text angleText;
-       // Rotated In-line, or turn conponent.
+       // Rotated In-line, or turn component.
        private Text rotationAngleText;
 
        // Input for new PipeRun
@@ -113,8 +118,20 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                this.libUri = libUri;
 
                usedNames = new HashSet<>();
+
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+
+               IDialogSettings settings = Activator.getDefault().getDialogSettings();
+               dialogSettings = settings.getSection(DIALOG);
+               if (dialogSettings == null)
+                       dialogSettings = settings.addNewSection(DIALOG);
        }
-       
+
+       @Override
+       protected IDialogSettings getDialogBoundsSettings() {
+               return dialogSettings;
+       }
+
        @Override
        protected void configureShell(Shell newShell) {
                super.configureShell(newShell);
@@ -179,7 +196,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                turns = P3DUtil.filterUserComponents(turns);
                inlines = P3DUtil.filterUserComponents(inlines);
 
-               ExpandBar expandBar = new ExpandBar(composite, SWT.NONE);
+               ExpandBar expandBar = new ExpandBar(composite, SWT.V_SCROLL);
 
                ExpandItem inlineItem = new ExpandItem(expandBar, SWT.NONE);
                inlineItem.setText("Inline");
@@ -216,7 +233,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                endViewer.addSelectionChangedListener(this);
 
                GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(2, 1).applyTo(expandBar);
-               GridDataFactory.fillDefaults().minSize(500, 500).hint(500, 500).applyTo(composite);
+               GridDataFactory.fillDefaults().grab(true, true).minSize(500, 500).hint(500, 500).applyTo(composite);
 
                Label label = new Label(composite, SWT.NONE);
                label.setText("Position");