diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index e7c7366f79..f385e13376 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -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(); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java index 0b6c343ac1..0465df0876 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java @@ -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. * * * @@ -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) {