From e7db089b44a08348e663b01c3a6cfbacfb91c694 Mon Sep 17 00:00:00 2001 From: srcarter3 Date: Wed, 8 Nov 2023 16:12:52 -0800 Subject: [PATCH] Fix the functionality for locating the cursor using a hotkey - for some reason this was completely broken in v20 - updated the size and display length for better UI experience - fixed the drawing and closing of the locate window --- .../d2d/ui/actions/LocateCursorAction.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/LocateCursorAction.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/LocateCursorAction.java index 4a6fc34538..32f2133429 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/LocateCursorAction.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/LocateCursorAction.java @@ -48,6 +48,7 @@ import com.raytheon.viz.ui.tools.AbstractTool; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 1, 2009 bgonzale Initial creation + * Nov 8, 2023 srcarter@ucar Fix functionality of the dialog, make UI more reasonable * * * @@ -89,13 +90,12 @@ public class LocateCursorAction extends AbstractTool { // set up close timer Display display = PlatformUI.getWorkbench().getDisplay(); - int oneAndAHalfSeconds = 1500; + int delay = 400; - display.timerExec(oneAndAHalfSeconds, new Runnable() { + display.timerExec(delay, new Runnable() { @Override public void run() { - if (dialog != null && dialog.getShell() != null - && !dialog.getShell().isDisposed()) { + if (dialog != null) { dialog.close(); } } @@ -103,9 +103,10 @@ public class LocateCursorAction extends AbstractTool { } private static class CursorBoxDialog extends CaveJFACEDialog { + private Shell shell; protected CursorBoxDialog(Shell parentShell) { super(parentShell); - setShellStyle(SWT.NO_TRIM | SWT.MODELESS); + shell = new Shell(parentShell, SWT.NO_TRIM | SWT.MODELESS); } /* @@ -123,15 +124,12 @@ public class LocateCursorAction extends AbstractTool { final Point cLoc = display.getCursorLocation(); final Color white = display.getSystemColor(SWT.COLOR_WHITE); final Color black = display.getSystemColor(SWT.COLOR_BLACK); - final int boxCount = 23; // 12 white boxes and 11 black boxes - final int sideSize = 190; + final int boxCount = 15; // 8 white boxes and 7 black boxes + final int sideSize = 60; final int center = sideSize / 2; final int sideInc = center / boxCount; final int margin = sideInc * 2; - GridData shellGD = new GridData(SWT.FILL, SWT.FILL, true, true); - newShell.setLayout(new GridLayout(1, false)); - newShell.setLayoutData(shellGD); newShell.setBounds(cLoc.x - center, cLoc.y - center, sideSize, sideSize); @@ -168,6 +166,21 @@ public class LocateCursorAction extends AbstractTool { // drawn. return null; } + + @Override + public int open() { + configureShell(shell); + shell.setVisible(true); + return getReturnCode(); + } + + @Override + public boolean close() { + shell.dispose(); + shell = null; + super.close(); + return true; + } } }