Merge pull request #604 from srcarter3/locateCursor
Fix the functionality for locating the cursor using a hotkey
This commit is contained in:
commit
ea0372d7e4
1 changed files with 23 additions and 10 deletions
|
@ -48,6 +48,7 @@ import com.raytheon.viz.ui.tools.AbstractTool;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 1, 2009 bgonzale Initial creation
|
* May 1, 2009 bgonzale Initial creation
|
||||||
|
* Nov 8, 2023 srcarter@ucar Fix functionality of the dialog, make UI more reasonable
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -89,13 +90,12 @@ public class LocateCursorAction extends AbstractTool {
|
||||||
|
|
||||||
// set up close timer
|
// set up close timer
|
||||||
Display display = PlatformUI.getWorkbench().getDisplay();
|
Display display = PlatformUI.getWorkbench().getDisplay();
|
||||||
int oneAndAHalfSeconds = 1500;
|
int delay = 400;
|
||||||
|
|
||||||
display.timerExec(oneAndAHalfSeconds, new Runnable() {
|
display.timerExec(delay, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (dialog != null && dialog.getShell() != null
|
if (dialog != null) {
|
||||||
&& !dialog.getShell().isDisposed()) {
|
|
||||||
dialog.close();
|
dialog.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,10 @@ public class LocateCursorAction extends AbstractTool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CursorBoxDialog extends CaveJFACEDialog {
|
private static class CursorBoxDialog extends CaveJFACEDialog {
|
||||||
|
private Shell shell;
|
||||||
protected CursorBoxDialog(Shell parentShell) {
|
protected CursorBoxDialog(Shell parentShell) {
|
||||||
super(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 Point cLoc = display.getCursorLocation();
|
||||||
final Color white = display.getSystemColor(SWT.COLOR_WHITE);
|
final Color white = display.getSystemColor(SWT.COLOR_WHITE);
|
||||||
final Color black = display.getSystemColor(SWT.COLOR_BLACK);
|
final Color black = display.getSystemColor(SWT.COLOR_BLACK);
|
||||||
final int boxCount = 23; // 12 white boxes and 11 black boxes
|
final int boxCount = 15; // 8 white boxes and 7 black boxes
|
||||||
final int sideSize = 190;
|
final int sideSize = 60;
|
||||||
final int center = sideSize / 2;
|
final int center = sideSize / 2;
|
||||||
final int sideInc = center / boxCount;
|
final int sideInc = center / boxCount;
|
||||||
final int margin = sideInc * 2;
|
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,
|
newShell.setBounds(cLoc.x - center, cLoc.y - center, sideSize,
|
||||||
sideSize);
|
sideSize);
|
||||||
|
|
||||||
|
@ -169,5 +167,20 @@ public class LocateCursorAction extends AbstractTool {
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue