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

Former-commit-id: 3ca1080fa0 [formerly c7e9e83612df941e1c6a99cac5d07a724525bbb3]
Former-commit-id: d098b2e271
This commit is contained in:
Lee Venable 2012-12-13 14:24:55 -06:00 committed by Gerrit Code Review
commit fabb15ab10
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. * Do not use changed BBB from OUPResponse.
* 17OCT2012 1229 rferrel Changes for non-blocking SWTMessageBox. * 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. * 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> * </pre>
* *
* @author lvenable * @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 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; private static final int EDITOR_WIDTH = 80;
/* filters for file import/export and attach functions. */ /* filters for file import/export and attach functions. */
@ -1245,10 +1243,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
@Override @Override
public void shellClosed(ShellEvent event) { public void shellClosed(ShellEvent event) {
if (inEditMode) { if (inEditMode) {
cancelDoClose = true;
cancelEditor(true);
bringToTop();
event.doit = false; event.doit = false;
cancelDoClose = true;
bringToTop();
cancelEditor(true);
return; return;
} }
@ -3532,9 +3530,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
textEditor.addVerifyKeyListener(new VerifyKeyListener() { textEditor.addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent event) { public void verifyKey(VerifyEvent event) {
// Ignore edit keys when not in edit mode. // Ignore edit keys when not in edit mode.
if (textEditor.getEditable() == false){ if (textEditor.getEditable() == false) {
return; return;
} }
if (event.keyCode == SWT.DEL || event.character == SWT.BS if (event.keyCode == SWT.DEL || event.character == SWT.BS
|| event.keyCode == SWT.SHIFT) { || event.keyCode == SWT.SHIFT) {
// Do nothing... // Do nothing...
@ -4422,7 +4420,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
} }
public void hideDialog() { public void hideDialog() {
if (disposeOnExit == true) { if (disposeOnExit == false) {
hide();
return; return;
} }
@ -4589,7 +4588,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
.getText().toUpperCase()), true); .getText().toUpperCase()), true);
} }
updateTextEditor(body); updateTextEditor(body);
if ((inEditMode || resend) && saveEditedProduct(false, resend, true)) { if ((inEditMode || resend)
&& saveEditedProduct(false, resend, true)) {
inEditMode = false; inEditMode = false;
} }
@ -4635,7 +4635,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
.getText())); .getText()));
} }
updateTextEditor(body); updateTextEditor(body);
if ((inEditMode || resend) && saveEditedProduct(false, resend, false)) { if ((inEditMode || resend)
&& saveEditedProduct(false, resend, false)) {
inEditMode = false; inEditMode = false;
} }
SendPracticeProductRequest req = new SendPracticeProductRequest(); SendPracticeProductRequest req = new SendPracticeProductRequest();
@ -6790,7 +6791,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
statusHandler.handle(p, response.getMessage()); statusHandler.handle(p, response.getMessage());
} else { } else {
// no failure // no failure
// As of DR 15418, nothing is done with response.getChangedBBB() // As of DR 15418, nothing is done with
// response.getChangedBBB()
} }
Thread.interrupted(); Thread.interrupted();

View file

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