From bed2334f57f150818f16f56c028cf24eca9a2e69 Mon Sep 17 00:00:00 2001 From: "steve.naples" Date: Mon, 28 Apr 2014 13:55:21 +0000 Subject: [PATCH] ASM #528 Updated DrawPolygonDlg to remember location when opened and closed. Change-Id: I19ec2f2e1898506387d053b8ada80d2d2d67cf7c Former-commit-id: e0b6f674f3dcd3685ccb7ccea439b2e11526d77f [formerly ae0616b0b71e0d1952f2c3e8f461a4d8e79e934f] Former-commit-id: 760fc0002879cce88791601618d713a708ecbd16 --- .../ui/dialogs/polygon/DrawPolygonDlg.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java index ea313817a8..e011b4dc25 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/polygon/DrawPolygonDlg.java @@ -24,6 +24,8 @@ import java.util.Date; import java.util.List; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Cursor; @@ -60,6 +62,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 11, 2013 #2353 lvenable Fixed cursor memory leak. * Jan 29, 2014 16561 snaples Updated processDrawPrecipValue to remove polygon wireframe after setting value. * Feb 2, 2014 16201 snaples Added saved data flag support + * Apr 28, 2014 16707 snaples Added code to save and set location of dialog box when moved. * * * @@ -113,6 +116,12 @@ public class DrawPolygonDlg extends CaveSWTDialog { /** The polygon resource */ private final MPEPolygonResource resource; + + /** Point to hold location of dialog */ + private static org.eclipse.swt.graphics.Point dlgLoc = null; + + /** Status of dialog opened or not */ + private boolean dialogOpened = false; /** * Constructor. @@ -144,13 +153,28 @@ public class DrawPolygonDlg extends CaveSWTDialog { } @Override - protected void initializeComponents(Shell shell) { + protected void initializeComponents(final Shell shell) { setReturnValue(false); boldFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.BOLD); font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); // Initialize all of the controls and layoutsendCal initializeComponents(); + shell.addControlListener(new ControlAdapter() { + @Override + public void controlMoved(ControlEvent e) { + if (!dialogOpened) { + return; + } + + if (dlgLoc == null) { + return; + } + + dlgLoc.x = shell.getBounds().x; + dlgLoc.y = shell.getBounds().y; + } + }); } /** @@ -162,6 +186,18 @@ public class DrawPolygonDlg extends CaveSWTDialog { createCloseBtn(); } + @Override + protected void opened() { + if (dlgLoc == null) { + dlgLoc = new org.eclipse.swt.graphics.Point(shell.getBounds().x, shell.getBounds().y); + } + else { + shell.setLocation(dlgLoc); + } + dialogOpened = true; + } + + /** * Create the persistent group. */