Issue #1353 Fix bug in TextWorkstationDlg "Show All" option and TextEditorDialog cancel edit.

Change-Id: Iaff7b8b64e2b1a94680c29087d174a27658c5873

Former-commit-id: 9d770cf725 [formerly 65699f7a26] [formerly 77c60c8925 [formerly 8eee3bf91d4e40b55b36f699ecf7ca37bc6591aa]]
Former-commit-id: 77c60c8925
Former-commit-id: 258dd80db8
This commit is contained in:
Roger Ferrel 2012-12-13 13:48:28 -06:00
parent 541c2cf5e3
commit d3482bd513
2 changed files with 42 additions and 58 deletions

View file

@ -303,6 +303,8 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* Do not use changed BBB from OUPResponse.
* 17OCT2012 1229 rferrel Changes for non-blocking SWTMessageBox.
* 05Nov2012 15560 S. Naples Added check to see if we are in edit mode before capturing keys.
* 13Dec2012 1353 rferrel Change to make edit cancel message not
* dispaly the red had kill job message.
* </pre>
*
* @author lvenable
@ -396,10 +398,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private static final int PAGE_SCROLL_LINES = 20;
private static final int MIN_WIDTH = 760;
private static final int MIN_HEIGHT = 635;
private static final int EDITOR_WIDTH = 80;
/* filters for file import/export and attach functions. */
@ -1245,10 +1243,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
@Override
public void shellClosed(ShellEvent event) {
if (inEditMode) {
cancelDoClose = true;
cancelEditor(true);
bringToTop();
event.doit = false;
cancelDoClose = true;
bringToTop();
cancelEditor(true);
return;
}
@ -3532,9 +3530,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
textEditor.addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent event) {
// Ignore edit keys when not in edit mode.
if (textEditor.getEditable() == false){
return;
}
if (textEditor.getEditable() == false) {
return;
}
if (event.keyCode == SWT.DEL || event.character == SWT.BS
|| event.keyCode == SWT.SHIFT) {
// Do nothing...
@ -4422,7 +4420,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
public void hideDialog() {
if (disposeOnExit == true) {
if (disposeOnExit == false) {
hide();
return;
}
@ -4589,7 +4588,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
.getText().toUpperCase()), true);
}
updateTextEditor(body);
if ((inEditMode || resend) && saveEditedProduct(false, resend, true)) {
if ((inEditMode || resend)
&& saveEditedProduct(false, resend, true)) {
inEditMode = false;
}
@ -4635,7 +4635,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
.getText()));
}
updateTextEditor(body);
if ((inEditMode || resend) && saveEditedProduct(false, resend, false)) {
if ((inEditMode || resend)
&& saveEditedProduct(false, resend, false)) {
inEditMode = false;
}
SendPracticeProductRequest req = new SendPracticeProductRequest();
@ -6790,7 +6791,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
statusHandler.handle(p, response.getMessage());
} else {
// no failure
// As of DR 15418, nothing is done with response.getChangedBBB()
// As of DR 15418, nothing is done with
// response.getChangedBBB()
}
Thread.interrupted();

View file

@ -24,6 +24,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
@ -31,7 +32,6 @@ import java.util.TimerTask;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
@ -89,13 +89,18 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* on times on two machines being in synch.
* 26Sep2012 1196 lvenable Dialog refactor to not block.
* 02Oct2012 1229 rferrel Option to allow blocking when top dialog.
* 13Dec2012 1353 rferrel Fix bug introduced in the Show all dialogs.
*
* </pre>
*
* @author lvenable
*/
public class TextWorkstationDlg extends CaveSWTDialog implements
SelectionListener, ITextEditorCallback, INotificationObserver {
ITextEditorCallback, INotificationObserver {
private final int INIT_BUTTON_CNT = 4;
private final int MAX_BUTTON_CNT = 8;
private String productToDisplay = null;
@ -125,11 +130,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
private Date date;
private int currentBtnCount = 4;
private List<Button> textBtnArray;
private ArrayList<Button> textBtnArray;
private ArrayList<TextEditorDialog> textEditorArray;
private List<TextEditorDialog> textEditorArray;
private TextEditorDialog wgDlg;
@ -430,19 +433,19 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
textBtnArray = new ArrayList<Button>();
textEditorArray = new ArrayList<TextEditorDialog>();
for (int x = 1; x <= 4; ++x) {
for (int x = 1; x <= INIT_BUTTON_CNT; ++x) {
createButtonAndTextEditor(x);
}
}
private void addNewWindowButton() {
++currentBtnCount;
if (currentBtnCount <= 8) {
int currentBtnCount = textEditorArray.size();
if (currentBtnCount < MAX_BUTTON_CNT) {
++currentBtnCount;
createButtonAndTextEditor(currentBtnCount);
}
if (currentBtnCount == 8) {
if (currentBtnCount == MAX_BUTTON_CNT) {
newWindowMenuItem.setEnabled(false);
}
@ -462,11 +465,8 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
});
textBtnArray.add(textBtn);
TextEditorDialog teDlg = new TextEditorDialog(shell, btnTitle, false,
this, ((Integer) btnNumber).toString(), true, true,
CAVE.PERSPECTIVE_INDEPENDENT);
textEditorArray.add(teDlg);
// Make place holder for the edit dialog and only create if requested.
textEditorArray.add(null);
}
private synchronized void createWarngenDisplay() {
@ -477,15 +477,15 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
}
private void showTextEditor(int editorIndex) {
boolean result = textEditorArray.get(editorIndex).isDisposed();
if (result) {
TextEditorDialog teDlg = textEditorArray.get(editorIndex);
if (teDlg == null) {
// create a new instance
String btnTitle = "Text " + (editorIndex + 1);
TextEditorDialog teDlg = new TextEditorDialog(shell, btnTitle,
false, this, ((Integer) (editorIndex + 1)).toString(),
true, true, CAVE.PERSPECTIVE_INDEPENDENT);
teDlg = new TextEditorDialog(shell, btnTitle, false, this,
((Integer) (editorIndex + 1)).toString(), true, true,
CAVE.PERSPECTIVE_INDEPENDENT);
textEditorArray.add(editorIndex, teDlg);
textEditorArray.set(editorIndex, teDlg);
}
textEditorArray.get(editorIndex).showDialog();
@ -500,7 +500,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
private void hideAllTextEditors() {
Shell myShell;
for (TextEditorDialog teDlg : textEditorArray) {
teDlg.hideDialog();
if (teDlg != null) {
teDlg.hideDialog();
}
}
for (int i = 1; i < 9; i++) {
ITextWorkstationCallback cb = TextDisplayModel.getInstance()
@ -536,29 +538,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
utcTimeLabel.setText(sdfUTC.format(date));
}
public void widgetSelected(SelectionEvent e) {
if (e.getSource() == textBtnArray.get(0)) {
System.out.println("Text 1 was clicked...");
} else if (e.getSource() == textBtnArray.get(1)) {
System.out.println("Text 2 was clicked...");
} else if (e.getSource() == textBtnArray.get(2)) {
System.out.println("Text 3 was clicked...");
} else if (e.getSource() == textBtnArray.get(3)) {
System.out.println("Text 4 was clicked...");
} else if (e.getSource() == textBtnArray.get(4)) {
System.out.println("Text 5 was clicked...");
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void restoreText(int teID) {
// Pass in "token-1" as teID and use "Text " + ((Integer)
// token+1).toString()) as the restored text.
textBtnArray.get(teID).setText(
"Text " + ((Integer) (teID + 1)).toString());
textBtnArray.get(teID).setText("Text " + (teID + 1));
}
@Override