From 24771e19204e33f6701321f63f57a751e022197a Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 6 Feb 2020 22:36:22 +0200 Subject: [PATCH] Make component addition dialog resizable and remember last dimensions gitlab #73 Change-Id: I95f9e61cd930f5fc8dca46d45839e89510768b55 --- .../dialog/ComponentSelectionDialog.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java index 95b22512..720d88ce 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java @@ -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"); -- 2.47.1