Omaha #5054 Fix Text workstation window locations on multimonitor display
Change-Id: I0bdb999ccd7f033e46dc62d2b8b6b31dcc9aa34f Former-commit-id: bbd448c086fd28c777d434d7308d137ba553840a
This commit is contained in:
parent
a19811a730
commit
5085377b9d
3 changed files with 129 additions and 58 deletions
|
@ -106,6 +106,7 @@ import org.eclipse.swt.widgets.Layout;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.Monitor;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -356,6 +357,8 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations;
|
|||
* simulated time.
|
||||
* Sep 30, 2015 4860 skorolev Corrected misspelling.
|
||||
* 07Oct2015 RM 18132 D. Friedman Exlucde certain phensigs from automatic ETN incrementing.
|
||||
* Oct 28, 2015 5054 randerso Make Text Editor windows appear on same monitor as the parent.
|
||||
* Removed hard coded offset for window placement.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -394,6 +397,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
private static final List<String> defaultNoETNIncrementPhenSigs = Arrays
|
||||
.asList("HU.A", "HU.S", "HU.W", "TR.A", "TR.W", "SS.A", "SS.W",
|
||||
"TY.A", "TY.W");
|
||||
|
||||
/**
|
||||
* Path of ETN rules localization file
|
||||
*/
|
||||
|
@ -1581,7 +1585,17 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
createMenus();
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
initializeComponents();
|
||||
createTopButtonRow();
|
||||
|
||||
Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
createTextRow();
|
||||
createHeaderTextField();
|
||||
createEditorControlButtons();
|
||||
createTextAreaEditor();
|
||||
createScriptRunnerControlBar();
|
||||
createStatusBar();
|
||||
|
||||
// initialize scripting controls
|
||||
setScriptControls(false);
|
||||
|
@ -3034,23 +3048,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
dftFont = new Font(getDisplay(), fontName, fontSize, SWT.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the components and put them on the display.
|
||||
*/
|
||||
private void initializeComponents() {
|
||||
createTopButtonRow();
|
||||
|
||||
Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
createTextRow();
|
||||
createHeaderTextField();
|
||||
createEditorControlButtons();
|
||||
createTextAreaEditor();
|
||||
createScriptRunnerControlBar();
|
||||
createStatusBar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the top row of buttons on the display.
|
||||
*/
|
||||
|
@ -5103,11 +5100,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
* saveEditedProduct, does not actually save anything.
|
||||
*/
|
||||
if (shouldSetETNtoNextValue(prod)) {
|
||||
statusHandler.handle(Priority.INFO, "Will increment ETN for this product.");
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Will increment ETN for this product.");
|
||||
prod.setProduct(VtecUtil.getVtec(
|
||||
removeSoftReturns(prod.getProduct()), true));
|
||||
} else {
|
||||
statusHandler.handle(Priority.INFO, "Will NOT increment ETN for this product.");
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Will NOT increment ETN for this product.");
|
||||
}
|
||||
/*
|
||||
* This silly bit of code updates the ETN of a VTEC in the
|
||||
|
@ -5140,13 +5139,15 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
try {
|
||||
if (!resend) {
|
||||
if (shouldSetETNtoNextValue(prod)) {
|
||||
statusHandler.handle(Priority.INFO, "Will increment ETN for this product.");
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Will increment ETN for this product.");
|
||||
body = VtecUtil
|
||||
.getVtec(removeSoftReturns(MixedCaseProductSupport
|
||||
.conditionalToUpper(prod.getNnnid(),
|
||||
textEditor.getText())));
|
||||
} else {
|
||||
statusHandler.handle(Priority.INFO, "Will NOT increment ETN for this product.");
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Will NOT increment ETN for this product.");
|
||||
}
|
||||
}
|
||||
updateTextEditor(body);
|
||||
|
@ -5194,7 +5195,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
LocalizationFile lf = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(ETN_RULES_FILE);
|
||||
if (lf == null) {
|
||||
throw new Exception("ETN rules file (" + ETN_RULES_FILE + ") not found.");
|
||||
throw new Exception("ETN rules file (" + ETN_RULES_FILE
|
||||
+ ") not found.");
|
||||
}
|
||||
return JAXB.unmarshal(lf.getFile(), EtnRules.class);
|
||||
}
|
||||
|
@ -5204,7 +5206,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
try {
|
||||
excludedPhenSigs = getETNRules().getExcludePhenSigs();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
statusHandler
|
||||
.handle(Priority.WARN,
|
||||
"Error loading ETN assignment rules. Will use default rules.",
|
||||
e);
|
||||
excludedPhenSigs = defaultNoETNIncrementPhenSigs;
|
||||
|
@ -7723,20 +7726,35 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
protected void preOpened() {
|
||||
// Shell shell = ted.getShell();
|
||||
if (textWorkstationFlag) {
|
||||
Rectangle rect = getShell().getDisplay().getClientArea();
|
||||
int x = rect.width / 4;
|
||||
|
||||
// account for dual monitor
|
||||
if (rect.width > (rect.height * 2)) {
|
||||
x /= 2;
|
||||
// get bounds of monitor containing parent shell
|
||||
Point parentLoc = getParent().getShell().getLocation();
|
||||
Rectangle rect = null;
|
||||
for (Monitor monitor : getShell().getDisplay().getMonitors()) {
|
||||
rect = monitor.getBounds();
|
||||
if (rect.contains(parentLoc)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int x = rect.x + rect.width / 4;
|
||||
int y = rect.y;
|
||||
|
||||
int index = getText().indexOf(" ");
|
||||
int editorIndex = new Integer(getText().substring(index + 1))
|
||||
.intValue();
|
||||
|
||||
int offset = (editorIndex - 1) * 25;
|
||||
getShell().setLocation(x + offset, (rect.height / 4) + offset);
|
||||
Rectangle bounds = getShell().getBounds();
|
||||
Rectangle clientArea = getShell().getClientArea();
|
||||
|
||||
/*
|
||||
* NOTE: this offset includes the height of the title bar and the
|
||||
* menu. There appears to be no way to get just the title bar in
|
||||
* Eclipse 3.8 We may be able to do this in Eclipse 4
|
||||
*/
|
||||
int xOffset = (editorIndex - 1) * (bounds.width - clientArea.width);
|
||||
int yOffset = (editorIndex - 1)
|
||||
* (bounds.height - clientArea.height);
|
||||
getShell().setLocation(x + xOffset, y + yOffset);
|
||||
}
|
||||
|
||||
inEditMode = false;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.raytheon.viz.textworkstation;
|
||||
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Monitor;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
@ -38,9 +41,9 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 28, 2011 mschenke Initial creation
|
||||
* Oct 02, 2012 1229 rferrel Make a blocking dialog.
|
||||
* Oct 17, 2012 1229 rferrel Changes for non-blocking
|
||||
* TextWorkstationDlg.
|
||||
* Oct 17, 2012 1229 rferrel Changes for non-blocking TextWorkstationDlg.
|
||||
* Sep 09, 2014 3580 mapeters Removed {@link SerializationUtil} usage.
|
||||
* Oct 28, 2015 5054 randerso Make TextWorkstationDlg appear on current monitor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,8 +62,20 @@ public class TextWorkstationComponent extends AbstractCAVEDialogComponent {
|
|||
*/
|
||||
@Override
|
||||
protected void startInternal(String componentName) throws Exception {
|
||||
TextWorkstationDlg textWorkstationDlg = new TextWorkstationDlg(
|
||||
new Shell(Display.getCurrent()));
|
||||
Display display = Display.getCurrent();
|
||||
Shell shell = new Shell(display);
|
||||
|
||||
Point cursor = display.getCursorLocation();
|
||||
for (Monitor monitor : display.getMonitors()) {
|
||||
Rectangle bounds = monitor.getBounds();
|
||||
if (bounds.contains(cursor)) {
|
||||
shell.setLocation(bounds.x, bounds.y);
|
||||
shell.setSize(bounds.width, bounds.height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TextWorkstationDlg textWorkstationDlg = new TextWorkstationDlg(shell);
|
||||
textWorkstationDlg.open();
|
||||
blockUntilClosed(textWorkstationDlg);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,15 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Monitor;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.jms.notification.INotificationObserver;
|
||||
|
@ -93,6 +96,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 30Jan2013 DR 14736 D. Friedman Display local time.
|
||||
* 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button).
|
||||
* 25July2013 DR 15733 Greg Hull Make dflt and max number of Text Buttons configurable.
|
||||
* 28Oct2015 5054 randerso Make TextWorkstationDlg appear in upper left corner of
|
||||
* monitor where parent shell is located
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -157,7 +162,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
* - CAVE.DO_NOT_BLOCK or CAVE.NONE
|
||||
*/
|
||||
public TextWorkstationDlg(Shell parent) {
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE,
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.MIN /* | SWT.RESIZE */,
|
||||
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.INDEPENDENT_SHELL
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
|
||||
|
@ -204,28 +209,15 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
fontAwipsLabel = new Font(shell.getDisplay(), "Helvetica", 24,
|
||||
SWT.ITALIC);
|
||||
|
||||
INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getDefaultNumEditors();
|
||||
INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg()
|
||||
.getDefaultNumEditors();
|
||||
MAX_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getMaxNumEditors();
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
initializeComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void opened() {
|
||||
if (productToDisplay != null) {
|
||||
wgDlg.showWarngenProduct(productToDisplay, notify);
|
||||
}
|
||||
|
||||
// Display the first Text Editor
|
||||
showTextEditor(0);
|
||||
}
|
||||
|
||||
private void initializeComponents() {
|
||||
sdfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
String localTZName = System.getenv("FXA_LOCAL_TZ");
|
||||
sdfLocal.setTimeZone(localTZName != null ?
|
||||
TimeZone.getTimeZone(localTZName) : TimeZone.getDefault());
|
||||
sdfLocal.setTimeZone(localTZName != null ? TimeZone
|
||||
.getTimeZone(localTZName) : TimeZone.getDefault());
|
||||
|
||||
createMenus();
|
||||
new Label(shell, SWT.NONE).setText("host: "
|
||||
|
@ -242,6 +234,40 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
alarmDlg.openInvisible();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
|
||||
*/
|
||||
@Override
|
||||
protected void preOpened() {
|
||||
super.preOpened();
|
||||
|
||||
// set location to upper left corner of monitor containing parent shell
|
||||
Point parentLoc = getParent().getShell().getLocation();
|
||||
|
||||
Point loc = new Point(0, 0);
|
||||
for (Monitor monitor : getDisplay().getMonitors()) {
|
||||
Rectangle bounds = monitor.getBounds();
|
||||
if (bounds.contains(parentLoc)) {
|
||||
loc.x = bounds.x;
|
||||
loc.y = bounds.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
shell.setLocation(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void opened() {
|
||||
if (productToDisplay != null) {
|
||||
wgDlg.showWarngenProduct(productToDisplay, notify);
|
||||
}
|
||||
|
||||
// Display the first Text Editor
|
||||
showTextEditor(0);
|
||||
}
|
||||
|
||||
private void createMenus() {
|
||||
Menu menuBar = new Menu(shell, SWT.BAR);
|
||||
|
||||
|
@ -268,6 +294,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem selectUserIdMenuItem = new MenuItem(fileMenu, SWT.NONE);
|
||||
selectUserIdMenuItem.setText("Select User ID...");
|
||||
selectUserIdMenuItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (userIdDlg == null || userIdDlg.isDisposed()) {
|
||||
userIdDlg = new SelectUserIdDlg(shell);
|
||||
|
@ -300,6 +327,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem exitMenuItem = new MenuItem(fileMenu, SWT.NONE);
|
||||
exitMenuItem.setText("Exit");
|
||||
exitMenuItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
getShell().close();
|
||||
}
|
||||
|
@ -323,6 +351,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem hideAllMenuItem = new MenuItem(windowsMenu, SWT.NONE);
|
||||
hideAllMenuItem.setText("Hide All");
|
||||
hideAllMenuItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
hideAllTextEditors();
|
||||
}
|
||||
|
@ -334,6 +363,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem showAllMenuItem = new MenuItem(windowsMenu, SWT.NONE);
|
||||
showAllMenuItem.setText("Show All");
|
||||
showAllMenuItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
showAllTextEditors();
|
||||
}
|
||||
|
@ -350,6 +380,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
newWindowMenuItem = new MenuItem(windowsMenu, SWT.NONE);
|
||||
newWindowMenuItem.setText("New Window");
|
||||
newWindowMenuItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
addNewWindowButton();
|
||||
}
|
||||
|
@ -360,6 +391,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem evaluationLogItem = new MenuItem(evalSubMenu, SWT.NONE);
|
||||
evaluationLogItem.setText("Evaluation Log");
|
||||
evaluationLogItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
notImplementedYet("Evaluation Log");
|
||||
}
|
||||
|
@ -368,6 +400,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem endOfShiftItem = new MenuItem(evalSubMenu, SWT.NONE);
|
||||
endOfShiftItem.setText("End of Shift");
|
||||
endOfShiftItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
notImplementedYet("End of Shift");
|
||||
}
|
||||
|
@ -376,6 +409,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
MenuItem questionnaireItem = new MenuItem(evalSubMenu, SWT.NONE);
|
||||
questionnaireItem.setText("Questionnaire");
|
||||
questionnaireItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
notImplementedYet("Questionnaire");
|
||||
}
|
||||
|
@ -419,6 +453,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
AlarmAlertNotificationObserver.getInstance();
|
||||
|
||||
alertAlarmBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (alarmDlg == null) {
|
||||
AlarmAlertNotificationObserver.getInstance();
|
||||
|
@ -467,6 +502,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
textBtn.setText(btnTitle);
|
||||
textBtn.setLayoutData(gd);
|
||||
textBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
showTextEditor(textBtnArray.indexOf(event.getSource()));
|
||||
}
|
||||
|
@ -528,8 +564,10 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
timer = new Timer();
|
||||
|
||||
updateTimeTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
getDisplay().syncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTimeLabels();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue