Issue #1196 Changes for WarnGenConfirmationDlg.

Change-Id: I5abb882d642e0e2c247432f87dbac0f82656c5f3

Former-commit-id: 4b24258c4c [formerly 60d1f0788345be4b4212704dc7b04e575d8c0fc9]
Former-commit-id: 0ef53ff1b8
This commit is contained in:
Roger Ferrel 2012-09-24 12:03:59 -05:00
parent 020bcd91ea
commit ce8bf085af
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.CommandHistory;
import com.raytheon.viz.texteditor.command.CommandType; import com.raytheon.viz.texteditor.command.CommandType;
import com.raytheon.viz.texteditor.command.ICommand; 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.FaxMessageDlg;
import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg; import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg;
import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback; import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback;
@ -4409,22 +4408,36 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell,
"Problem Detected by QC", qcCheck.getErrorMessage(), "Problem Detected by QC", qcCheck.getErrorMessage(),
"Do you really want to Send?\n", mode); "Do you really want to Send?\n", mode);
wgcd.open(new SessionDelegate() { wgcd.setCloseCallback(new ICloseCallback() {
@Override @Override
public void dialogDismissed(Object dialogResult) { public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(dialogResult)) if (Boolean.TRUE.equals(returnValue))
finishSendProduct1(resend, title, mode, finishSendProduct(resend, title, mode,
productMessage, modeMessage); productMessage, modeMessage);
} }
}); });
wgcd.open();
return; 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, CAVEMode mode, StringBuilder productMessage,
StringBuilder modeMessage) { StringBuilder modeMessage) {
Pattern p = Pattern.compile(".\\%[s]."); Pattern p = Pattern.compile(".\\%[s].");
@ -4459,16 +4472,26 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title, WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title,
productMessage.toString(), modeMessage.toString(), mode); productMessage.toString(), modeMessage.toString(), mode);
wgcd.open(new SessionDelegate() { wgcd.setCloseCallback(new ICloseCallback() {
@Override @Override
public void dialogDismissed(Object dialogResult) { public void dialogClosed(Object returnValue) {
if (Boolean.TRUE.equals(dialogResult)) if (Boolean.TRUE.equals(returnValue)) {
finishSendProduct2(resend, result); 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) // DR14553 (make upper case in product)
String body = textEditor.getText().toUpperCase(); String body = textEditor.getText().toUpperCase();

View file

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