Issue #1196 Changes for WarnGenConfirmationDlg.

Change-Id: I5abb882d642e0e2c247432f87dbac0f82656c5f3

Former-commit-id: 4b24258c4c [formerly 4b24258c4c [formerly 60d1f0788345be4b4212704dc7b04e575d8c0fc9]]
Former-commit-id: 0ef53ff1b8
Former-commit-id: ce8bf085af
This commit is contained in:
Roger Ferrel 2012-09-24 12:03:59 -05:00
parent 9d87d39ca0
commit ec17241f51
2 changed files with 39 additions and 36 deletions

View file

@ -158,7 +158,6 @@ import com.raytheon.viz.texteditor.command.CommandFailedException;
import com.raytheon.viz.texteditor.command.CommandHistory;
import com.raytheon.viz.texteditor.command.CommandType;
import com.raytheon.viz.texteditor.command.ICommand;
import com.raytheon.viz.texteditor.dialogs.WarnGenConfirmationDlg.SessionDelegate;
import com.raytheon.viz.texteditor.fax.dialogs.FaxMessageDlg;
import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg;
import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback;
@ -4409,22 +4408,36 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
"Problem Detected by QC", qcCheck.getErrorMessage(),
"Do you really want to Send?\n", mode);
wgcd.open(new SessionDelegate() {
wgcd.setCloseCallback(new ICloseCallback() {
@Override
public void dialogDismissed(Object dialogResult) {
if (Boolean.TRUE.equals(dialogResult))
finishSendProduct1(resend, title, mode,
public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(returnValue))
finishSendProduct(resend, title, mode,
productMessage, modeMessage);
}
});
wgcd.open();
return;
}
}
finishSendProduct1(resend, title, mode, productMessage, modeMessage);
finishSendProduct(resend, title, mode, productMessage, modeMessage);
}
private void finishSendProduct1(final boolean resend, String title,
/**
* This finishes preparing to send a product as part of normal compleation
* of sendProduct or as part of the call back when there is a problem with
* the WarnGen being sent.
*
* @param resend
* @param title
* @param mode
* @param productMessage
* @param modeMessage
*/
private void finishSendProduct(final boolean resend, String title,
CAVEMode mode, StringBuilder productMessage,
StringBuilder modeMessage) {
Pattern p = Pattern.compile(".\\%[s].");
@ -4459,16 +4472,26 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title,
productMessage.toString(), modeMessage.toString(), mode);
wgcd.open(new SessionDelegate() {
wgcd.setCloseCallback(new ICloseCallback() {
@Override
public void dialogDismissed(Object dialogResult) {
if (Boolean.TRUE.equals(dialogResult))
finishSendProduct2(resend, result);
public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(returnValue)) {
warngenCloseCallback(resend, result);
}
}
});
wgcd.open();
}
private void finishSendProduct2(boolean resend, boolean result) {
/**
* This is used by finishedSendProduct as the call back to the warnGen
* confirmaiton Dialog.
*
* @param resend
* @param result
*/
private void warngenCloseCallback(boolean resend, boolean result) {
// DR14553 (make upper case in product)
String body = textEditor.getText().toUpperCase();

View file

@ -23,8 +23,6 @@ package com.raytheon.viz.texteditor.dialogs;
import java.io.InputStream;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@ -51,6 +49,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 10Aug2010 2187 cjeanbap Removed warnGenFlag.
* 10Nov2011 11552 rferrel returnvalue no longer null
* 08/20/2012 DR 15340 D. Friedman Use callbacks for closing
* 09/24/2012 1196 rferrel Refactored to use close callback
* added to CaveSWTDialog.
*
* </pre>
*
@ -69,17 +69,11 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
private String IMAGE_TEST = "res/images/twsTest.gif";
private String IMAGE_PRACTICE = "res/images/twsPractice.gif";
public static interface SessionDelegate {
void dialogDismissed(Object result);
}
private SessionDelegate sessionDelegate;
protected WarnGenConfirmationDlg(Shell parentShell, String title,
String productMessage, String modeMessage, CAVEMode mode) {
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL,
CAVE.NONE | CAVE.DO_NOT_BLOCK);
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE
| CAVE.DO_NOT_BLOCK);
setText(title);
@ -88,13 +82,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
this.mode = mode;
setReturnValue(Boolean.FALSE);
}
public void open(SessionDelegate sessionDelegate) {
if (sessionDelegate != null && isOpen())
throw new RuntimeException(String.format("Dialog \"%s\" already open", getText()));
this.sessionDelegate = sessionDelegate;
super.open();
}
@Override
protected void initializeComponents(Shell shell) {
@ -103,13 +90,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
createImage(mainComposite);
createMessageLabel(mainComposite);
createButtonRow(mainComposite);
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (sessionDelegate != null)
sessionDelegate.dialogDismissed(getReturnValue());
}
});
}
private void createImage(Composite mainComposite) {