diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java index 2164386d34..7b37b7e5fd 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java @@ -708,13 +708,10 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements if (response == SWT.NO || parentEditor.isDisposed()) { return; } - parentEditor.enableSend(false); sendEnabled = false; if (isAfosPilComplete()) { unOfficialProd = true; } - } else { - parentEditor.enableSend(true); } // call the set methods diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/QCConfirmationMsg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/QCConfirmationMsg.java deleted file mode 100644 index b1970fc363..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/QCConfirmationMsg.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.texteditor.dialogs; - -import com.raytheon.viz.texteditor.qc.QualityControl; - -/** - * Produces the product message and mode message for the warngen confirmation - * dialog for warnings failing QC. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 23, 2013 2176       jsanchez     Initial creation
- * 
- * 
- * - * @author jsanchez - * @version 1.0 - */ - -public class QCConfirmationMsg implements IWarnGenConfirmationable { - - private QualityControl qcCheck = new QualityControl(); - - @Override - public boolean checkWarningInfo(String header, String body, String nnn) { - return qcCheck.checkWarningInfo(header, body, nnn); - } - - @Override - public String getTitle() { - return "Problem Detected by QC"; - } - - @Override - public String getProductMessage() { - return qcCheck.getErrorMessage(); - } - - @Override - public String getModeMessage() { - return "Do you really want to Send?\n"; - } - -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java deleted file mode 100644 index c8e470d32d..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java +++ /dev/null @@ -1,581 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.viz.texteditor.dialogs; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.TimeZone; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer; -import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; -import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; -import com.raytheon.uf.common.dataplugin.text.request.GetWmoIdRequest; -import com.raytheon.uf.common.dataplugin.text.request.RemoteRetrievalRequest; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.common.wmo.WMOHeader; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.requests.ThriftClient; -import com.raytheon.viz.texteditor.command.CommandFactory; -import com.raytheon.viz.texteditor.command.CommandFailedException; -import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -import com.raytheon.viz.ui.dialogs.ICloseCallback; - -/** - * The Remote Site Request dialog. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 9/13/07      368         lvenable    Initial creation.
- * 10/11/2007   482         grichard    Reformatted file.
- * 09/20/2012   1196        rferrel     Changing dialogs being called to not block.
- * 09/09/2014   3580        mapeters    Removed IQueryTransport usage (no longer exists).
- * Aug 31, 2015 4749        njensen     Changed setCloseCallback to addCloseCallback
- * 
- * 
- * - * @author lvenable - */ -public class RemoteSiteRequestDlg extends CaveSWTDialog implements - IWmoIdSelectionCallback { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(RemoteSiteRequestDlg.class); - - private StyledText ttaaiiTF; - - private StyledText ccccTF; - - /** - * AFOS site ID text field. - */ - private StyledText wsfoIdTF; - - /** - * Product category text field. - */ - private StyledText productCatTF; - - /** - * Product designator text field. - */ - private StyledText prodDesignatorTF; - - /** - * Address text field. Defines the site where a text product or message is - * sent. - */ - private StyledText addresseeTF; - - private Button enterBtn; - - private String initialAfosID; - - private WmoIdSelectionDialog wmoIdSelectionDialog; - - boolean lookupAllowed = true; - - /** - * Constructor. - * - * @param parent - * Parent shell. - */ - public RemoteSiteRequestDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT - | CAVE.DO_NOT_BLOCK); - setText("Send Request"); - } - - @Override - protected Layout constructShellLayout() { - return new GridLayout(1, false); - } - - @Override - protected Object constructShellLayoutData() { - return new GridData(); - } - - @Override - protected void initializeComponents(Shell shell) { - createInputFields(); - createBottomButtons(); - checkEnableEnter(); - } - - /** - * Create the input fields. - */ - private void createInputFields() { - Composite topComp = new Composite(shell, SWT.NONE); - GridLayout gridLayout = new GridLayout(2, false); - gridLayout.marginLeft = 1; - gridLayout.marginTop = 1; - gridLayout.horizontalSpacing = 20; - topComp.setLayout(gridLayout); - GridData gd = null; - Label sepLbl = null; - - gd = new GridData(70, SWT.DEFAULT); - ttaaiiTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY); - ttaaiiTF.setTextLimit(6); - ttaaiiTF.setLayoutData(gd); - ttaaiiTF.setEnabled(false); - ttaaiiTF.setEditable(false); - ttaaiiTF.setBackground(shell.getBackground()); - - Label ttaaiiLbl = new Label(topComp, SWT.NONE); - ttaaiiLbl.setText("TTAAii"); - - gd = new GridData(45, SWT.DEFAULT); - ccccTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY); - ccccTF.setEnabled(false); - ccccTF.setEditable(false); - ccccTF.setLayoutData(gd); - ccccTF.setBackground(shell.getBackground()); - Label ccccLbl = new Label(topComp, SWT.NONE); - ccccLbl.setText("CCCC"); - - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - // Create the WSFO ID text field. - gd = new GridData(45, SWT.DEFAULT); - wsfoIdTF = new StyledText(topComp, SWT.BORDER); - wsfoIdTF.setTextLimit(3); - wsfoIdTF.setLayoutData(gd); - - Label wsfoIdLbl = new Label(topComp, SWT.NONE); - wsfoIdLbl.setText("WSFO Identification"); - - // Create the product category text field. - gd = new GridData(45, SWT.DEFAULT); - productCatTF = new StyledText(topComp, SWT.BORDER); - productCatTF.setTextLimit(3); - productCatTF.setLayoutData(gd); - - Label productCatLbl = new Label(topComp, SWT.NONE); - productCatLbl.setText("Product Category"); - - // Create the product designator text field. - gd = new GridData(45, SWT.DEFAULT); - prodDesignatorTF = new StyledText(topComp, SWT.BORDER); - prodDesignatorTF.setTextLimit(3); - prodDesignatorTF.setLayoutData(gd); - - Label prodDesignatorLbl = new Label(topComp, SWT.NONE); - prodDesignatorLbl.setText("Product Designator"); - - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - // Create the addressee text field. - gd = new GridData(45, SWT.DEFAULT); - addresseeTF = new StyledText(topComp, SWT.BORDER); - addresseeTF.setTextLimit(4); - addresseeTF.setText("DEF"); - addresseeTF.setLayoutData(gd); - - Label addresseeLbl = new Label(topComp, SWT.NONE); - addresseeLbl.setText("Addressee"); - - setupTextFieldListeners(); - - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - // TODO set fields should be moved to preOpen() - String ccc = ""; - String nnn = ""; - String xxx = ""; - try { - ccc = initialAfosID.substring(0, 3); - nnn = initialAfosID.substring(3, 6); - xxx = initialAfosID.substring(6); - } catch (Exception e) { - // ignore - } - wsfoIdTF.setText(ccc); - productCatTF.setText(nnn); - prodDesignatorTF.setText(xxx); - } - - private void setupTextFieldListeners() { - // forces all fields to uppercase and only allows numbers/digits - textFieldVerifyListener(wsfoIdTF); - textFieldVerifyListener(productCatTF); - textFieldVerifyListener(prodDesignatorTF); - textFieldVerifyListener(addresseeTF); - - // forces overwrite and arrow key traversal - textFieldKeyListener(wsfoIdTF, addresseeTF, productCatTF); - textFieldKeyListener(productCatTF, wsfoIdTF, prodDesignatorTF); - textFieldKeyListener(prodDesignatorTF, productCatTF, addresseeTF); - textFieldKeyListener(addresseeTF, prodDesignatorTF, wsfoIdTF); - - textFieldModifyListener(wsfoIdTF, productCatTF, true); - textFieldModifyListener(productCatTF, prodDesignatorTF, true); - textFieldModifyListener(prodDesignatorTF, addresseeTF, false); - } - - /** - * Create the bottom Enter and Cancel buttons. - */ - private void createBottomButtons() { - // Create a composite that will center added controls/composites. - Composite buttonArea = new Composite(shell, SWT.NONE); - buttonArea.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, - false)); - buttonArea.setLayout(new GridLayout(1, false)); - - // Create a composite to hold the enter and cancel buttons. - Composite buttons = new Composite(buttonArea, SWT.NONE); - buttons.setLayout(new GridLayout(2, true)); - - // Create the Enter button. - enterBtn = new Button(buttons, SWT.PUSH); - enterBtn.setLayoutData(new GridData(GridData.FILL_BOTH)); - enterBtn.setText("Enter"); - enterBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - if (createReturnValue(false)) - shell.dispose(); - } - }); - - // Create the Cancel button. - Button cancelBtn = new Button(buttons, SWT.PUSH); - cancelBtn.setLayoutData(new GridData(GridData.FILL_BOTH)); - cancelBtn.setText("Cancel"); - cancelBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - setReturnValue(null); - shell.dispose(); - } - }); - } - - private Calendar createCalRelativeTo(Calendar relative, - WMOHeader wmoHeader, int monthAdjustment) { - Calendar c = new GregorianCalendar(relative.getTimeZone()); - c.setTimeInMillis(relative.getTimeInMillis()); - c.add(GregorianCalendar.MONTH, monthAdjustment); - c.set(GregorianCalendar.DAY_OF_MONTH, wmoHeader.getDay()); - c.set(GregorianCalendar.HOUR_OF_DAY, wmoHeader.getHour()); - c.set(GregorianCalendar.MINUTE, wmoHeader.getMinute()); - c.set(GregorianCalendar.SECOND, 0); - c.set(GregorianCalendar.MILLISECOND, 0); - return c; - } - - private Calendar getCloserCalendar(Calendar reference, Calendar a, - Calendar b) { - return Math.abs(a.getTimeInMillis() - reference.getTimeInMillis()) < Math - .abs(b.getTimeInMillis() - reference.getTimeInMillis()) ? a : b; - } - - private boolean createReturnValue(boolean validateOnly) { - String ccc = wsfoIdTF.getText(); - String nnn = productCatTF.getText(); - String xxx = prodDesignatorTF.getText(); - String addr = addresseeTF.getText(); - if (ccc.length() != 3 || nnn.length() != 3 || xxx.length() < 1 - || xxx.length() > 3 || addr.length() < 1) - return false; - - if (validateOnly) - return true; - - String afosID = ccc + nnn + xxx; - GetWmoIdRequest request = new GetWmoIdRequest(); - request.setAfosId(afosID); - - RemoteRetrievalRequest req = new RemoteRetrievalRequest(); - // TODO: Translate addr via awipsSites.txt or siteDistLists.txt - req.setAddressee(addr); - req.setAfosID(afosID); - - List latest = null; - try { - latest = CommandFactory.getAfosCommand(req.getAfosID()) - .executeCommand(); - } catch (CommandFailedException e) { - statusHandler.handle(Priority.PROBLEM, - "Error retrieving metatdata", e); - // but keep going... - } - - if (latest != null && latest.size() > 0) { - Calendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT")); - c.setTimeInMillis(latest.get(0).getRefTime()); - req.setMostRecentTime(c.getTimeInMillis()); // default - try { - WMOHeader wmo = new WMOHeader(latest.get(0).getProduct() - .getBytes()); - Calendar t = getCloserCalendar(c, - createCalRelativeTo(c, wmo, 0), - createCalRelativeTo(c, wmo, 1)); - t = getCloserCalendar(c, t, createCalRelativeTo(c, wmo, -1)); - req.setMostRecentTime(t.getTimeInMillis()); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error determining product time", e); - } - } else - req.setMostRecentTime(0); - - String ttaaii = ttaaiiTF.getText(); - String cccc = ccccTF.getText(); - if (ttaaii.length() > 0 && cccc.length() > 0) { - req.setWmoHeader(ttaaii + " " + cccc); - } else { - req.setWmoHeader(""); - } - - req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current - // time plus - // 10 minutes - - setReturnValue(req); - return true; - } - - private void textFieldKeyListener(final StyledText tf, - final StyledText previousTF, final StyledText nextTF) { - tf.addKeyListener(new KeyAdapter() { - - @Override - public void keyPressed(KeyEvent e) { - char c = e.character; - - if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) { - int pos = tf.getCaretOffset(); - String text = tf.getText(); - - if (text.length() > pos) { - StringBuilder b = new StringBuilder(text); - b.deleteCharAt(pos); - tf.setText(b.toString()); - tf.setSelection(pos); - } - } else if (e.keyCode == SWT.ARROW_UP) { - previousTF.setFocus(); - previousTF.selectAll(); - } else if (e.keyCode == SWT.ARROW_DOWN) { - nextTF.setFocus(); - nextTF.selectAll(); - } - } - }); - } - - private void textFieldVerifyListener(final StyledText tf) { - tf.addVerifyListener(new VerifyListener() { - @Override - public void verifyText(VerifyEvent e) { - e.text = e.text.toUpperCase(); - StringBuilder b = null; - int posMod = 0; - char[] chars = e.text.toCharArray(); - for (int i = 0; i < chars.length; i++) { - char c = chars[i]; - if (!Character.isLetterOrDigit(c) - && !Character.isSpaceChar(c)) { - if (b == null) { - b = new StringBuilder(e.text); - } - b.deleteCharAt(i - posMod++); - } - } - - if (b != null) { - e.text = b.toString(); - } - } - }); - } - - private void textFieldModifyListener(final StyledText tf, - final StyledText nextTF, final boolean limitCheck) { - tf.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent event) { - if (!limitCheck || tf.getCharCount() == tf.getTextLimit()) { - if (wmoIdSelectionDialog == null) { - lookupWmoIDs(); - } else { - wmoIdSelectionDialog.close(); - wmoIdSelectionDialog = null; - lookupWmoIDs(); - } - } else { - if (wmoIdSelectionDialog != null) { - wmoIdSelectionDialog.close(); - wmoIdSelectionDialog = null; - } - setWmoId("", ""); - checkEnableEnter(); - } - - if (!isDisposed()) { - if (tf.getCaretOffset() == tf.getTextLimit()) { - nextTF.setFocus(); - nextTF.selectAll(); - } - - checkEnableEnter(); - } - } - }); - } - - private void lookupWmoIDs() { - if (lookupAllowed && wsfoIdTF.getCharCount() == wsfoIdTF.getTextLimit() - && productCatTF.getCharCount() == productCatTF.getTextLimit() - && prodDesignatorTF.getText().length() > 0) { - GetWmoIdRequest request = new GetWmoIdRequest(); - request.setAfosId(wsfoIdTF.getText() + productCatTF.getText() - + prodDesignatorTF.getText()); - lookupAllowed = false; - - try { - Object response = ThriftClient.sendRequest(request); - if (response != null) { - if (response instanceof AfosWmoIdDataContainer) { - AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response; - if (container.getErrorMessage() != null) { - statusHandler - .handle(Priority.PROBLEM, - "Error occurred looking up WMO IDs\nMessage from server[" - + container - .getErrorMessage() - + "]"); - } - - java.util.List list = container - .getIdList(); - - if (list.size() > 1) { - ArrayList ttaaiiIds = new ArrayList( - list.size()); - ArrayList ccccIds = new ArrayList( - list.size()); - for (AfosToAwips id : list) { - ttaaiiIds.add(id.getWmottaaii()); - ccccIds.add(id.getWmocccc()); - } - - wmoIdSelectionDialog = new WmoIdSelectionDialog( - shell, this, ttaaiiIds, ccccIds); - wmoIdSelectionDialog - .addCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed( - Object returnValue) { - lookupAllowed = true; - wmoIdSelectionDialog = null; - } - }); - wmoIdSelectionDialog.setBlockOnOpen(false); - wmoIdSelectionDialog.open(); - return; - } else if (list.size() == 1) { - AfosToAwips id = list.get(0); - setWmoId(id.getWmottaaii(), id.getWmocccc()); - } else { - setWmoId("", ""); - } - checkEnableEnter(); - } else { - statusHandler.handle(Priority.PROBLEM, - "Received unhandled WMO Id lookup response from server. Received obj of type [" - + response.getClass() + "], contents[" - + response + "]"); - } - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error occurred looking up WMO IDs", e); - } - - lookupAllowed = true; - } - } - - public void setRequest(RemoteRetrievalRequest lastRemoteRetrievalRequest) { - initialAfosID = null; - if (lastRemoteRetrievalRequest != null) - initialAfosID = lastRemoteRetrievalRequest.getAfosID(); - } - - private void checkEnableEnter() { - boolean enabled = false; - if (enterBtn != null && !isDisposed()) { - if (ttaaiiTF.getCharCount() > 0 && ccccTF.getCharCount() > 0 - && addresseeTF.getCharCount() > 0) { - enabled = true; - } - enterBtn.setEnabled(enabled); - } - } - - @Override - public void setWmoId(String ttaaii, String cccc) { - ttaaiiTF.setText(ttaaii); - ccccTF.setText(cccc); - checkEnableEnter(); - } -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SendConfirmationMsg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SendConfirmationMsg.java deleted file mode 100644 index 374c7852ca..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SendConfirmationMsg.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.texteditor.dialogs; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.raytheon.viz.core.mode.CAVEMode; -import com.raytheon.viz.texteditor.qc.QualityControl; - -/** - * Produces the product message and mode message for the warngen confirmation - * dialog for sending a warning. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jul 23, 2013 2176       jsanchez     Initial creation
- * 
- * 
- * - * @author jsanchez - * @version 1.0 - */ - -public class SendConfirmationMsg implements IWarnGenConfirmationable { - - private String title; - - private boolean resend; - - private String afosId; - - public SendConfirmationMsg(boolean resend, String afosId, String nnn) { - this.resend = resend; - this.afosId = afosId; - title = QualityControl.getProductWarningType(nnn); - } - - @Override - public boolean checkWarningInfo(String header, String body, String nnn) { - return true; - } - - @Override - public String getTitle() { - return title; - } - - @Override - public String getProductMessage() { - StringBuilder productMessage = new StringBuilder(); - if (resend) { - productMessage.append("You are about to RESEND a " + afosId + "\n"); - productMessage.append(title).append(".\n"); - } else { - productMessage.append("You are about to SEND a " + afosId + "\n"); - productMessage.append(title).append(".\n"); - } - return productMessage.toString(); - } - - @Override - public String getModeMessage() { - CAVEMode mode = CAVEMode.getMode(); - StringBuilder modeMessage = new StringBuilder(); - modeMessage.append("The workstation is in ").append(mode) - .append(" mode."); - if (resend) { - modeMessage.append("\nThere is no QC check for resend product."); - } - - Pattern p = Pattern.compile(".\\%[s]."); - Matcher m = p.matcher(TextEditorDialog.STORED_SENT_MSG); - boolean result = (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST - .equals(mode)); - modeMessage.append(result ? m.replaceAll(" ") : m.replaceAll(" not ")); - - return modeMessage.toString(); - } - -} 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 798594aa84..d3d3528286 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 @@ -28,7 +28,6 @@ import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; -import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; @@ -50,10 +49,8 @@ import javax.xml.bind.JAXB; import javax.xml.bind.JAXBException; import org.apache.commons.lang.StringUtils; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.ErrorDialog; @@ -110,8 +107,6 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.menus.IMenuService; -import com.raytheon.uf.common.activetable.SendPracticeProductRequest; -import com.raytheon.uf.common.dataplugin.text.RemoteRetrievalResponse; import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct; import com.raytheon.uf.common.dataplugin.text.db.MixedCaseProductSupport; import com.raytheon.uf.common.dataplugin.text.db.OperationalStdTextProduct; @@ -144,7 +139,6 @@ import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.wmo.WMOHeader; import com.raytheon.uf.viz.core.VizApp; -import com.raytheon.uf.viz.core.auth.UserController; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob; import com.raytheon.uf.viz.core.requests.ThriftClient; @@ -162,7 +156,6 @@ import com.raytheon.viz.texteditor.command.CommandType; import com.raytheon.viz.texteditor.command.ICommand; import com.raytheon.viz.texteditor.command.IProductQueryCallback; import com.raytheon.viz.texteditor.command.ProductQueryJob; -import com.raytheon.viz.texteditor.dialogs.LineWrapCheckConfirmationMsg.AnswerChoices; import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback; import com.raytheon.viz.texteditor.msgs.IAwipsBrowserCallback; import com.raytheon.viz.texteditor.msgs.IRecoverEditSessionCallback; @@ -185,7 +178,6 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.dialogs.SWTMessageBox; -import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; /** * Main Text Editor dialog. @@ -642,21 +634,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private MenuItem printSelectionItem; - /** - * Fax All products menu item. - */ - private MenuItem faxAllItem; - - /** - * Fax selected aread menu item. - */ - private MenuItem faxSelectionItem; - - /** - * Configuration Auto fax menu item. - */ - private MenuItem configAutoFaxItem; - /** * Enter editor mode menu item. */ @@ -667,11 +644,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private MenuItem saveItem; - /** - * Send and Exit menu item. - */ - private MenuItem sendExitEditorItem; - /** * Cancel editor item. */ @@ -687,21 +659,11 @@ public class TextEditorDialog extends CaveSWTDialog */ private MenuItem exportFromFileItem; - /** - * Request from remote site menu item. - */ - private MenuItem requestFromRemoteSiteItem; - /** * Recover edit session menu item. */ private MenuItem recoverEditSessionItem; - /** - * Re-send warning product menu item. - */ - private MenuItem resendWarningProductnItem; - /** * Close menu item. */ @@ -1092,21 +1054,11 @@ public class TextEditorDialog extends CaveSWTDialog */ private Button editorEditHeaderBtn; - /** - * Editor send button. - */ - private Button editorSendBtn; - /** * Editor cancel button. */ private Button editorCancelBtn; - /** - * Editor attach button. - */ - private Button editorAttachBtn; - /** * Editor insert/overwrite combo box. */ @@ -1308,16 +1260,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private String addressee = "ALL"; - /** - * Name of any attachment file - */ - private String attachedFilename = null; - - /** - * Contents of an attachment file. - */ - private byte[] attachedFile = null; - /** * Edit options for a popup menu. */ @@ -1693,17 +1635,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - sendExitEditorItem = new MenuItem(fileMenu, SWT.NONE); - sendExitEditorItem.setText("Send && Exit Editor"); - sendExitEditorItem.setEnabled(false); - sendExitEditorItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("File -> Send & Exit clicked"); - sendProduct(false); - } - }); - cancelEditorItem = new MenuItem(fileMenu, SWT.NONE); cancelEditorItem.setText("Cancel Editor"); cancelEditorItem.setEnabled(false); @@ -1735,33 +1666,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - new MenuItem(fileMenu, SWT.SEPARATOR); - - requestFromRemoteSiteItem = new MenuItem(fileMenu, SWT.NONE); - requestFromRemoteSiteItem.setText("Request From Remote Site..."); - requestFromRemoteSiteItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - RemoteSiteRequestDlg requestDlg = new RemoteSiteRequestDlg( - shell); - if (lastRemoteRetrievalRequest != null) { - requestDlg.setRequest(lastRemoteRetrievalRequest); - } - requestDlg.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - RemoteRetrievalRequest req = (RemoteRetrievalRequest) returnValue; - if (req != null) { - lastRemoteRetrievalRequest = req; - sendRemoteRetrievalRequest(req); - } - } - }); - requestDlg.open(); - } - }); - recoverEditSessionItem = new MenuItem(fileMenu, SWT.NONE); recoverEditSessionItem.setText("Recover Edit Sesssion..."); recoverEditSessionItem.addSelectionListener(new SelectionAdapter() { @@ -1777,19 +1681,6 @@ public class TextEditorDialog extends CaveSWTDialog new MenuItem(fileMenu, SWT.SEPARATOR); - resendWarningProductnItem = new MenuItem(fileMenu, SWT.NONE); - resendWarningProductnItem.setText("Resend Warning Product..."); - resendWarningProductnItem.setEnabled(false); - resendWarningProductnItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("File -> Resend Warning Product... clicked"); - sendProduct(true); - } - }); - - new MenuItem(fileMenu, SWT.SEPARATOR); - closeItem = new MenuItem(fileMenu, SWT.NONE); closeItem.setText("Close\tAlt+F4"); closeItem.setAccelerator(SWT.ALT | SWT.F4); @@ -3647,19 +3538,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - // Add the Send button. - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - editorSendBtn = new Button(editorBtnRowComp, SWT.PUSH); - editorSendBtn.setText("Send"); - editorSendBtn.setLayoutData(gd); - editorSendBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("Send button clicked"); - sendProduct(false); - } - }); - // Add the Cancel button. gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); editorCancelBtn = new Button(editorBtnRowComp, SWT.PUSH); @@ -3673,18 +3551,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - // Add the Attach button. - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - editorAttachBtn = new Button(editorBtnRowComp, SWT.PUSH); - editorAttachBtn.setText("Attach"); - editorAttachBtn.setLayoutData(gd); - editorAttachBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - attachFile(); - } - }); - // Add the Insert/Overwrite combo box. gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); editorInsertCmb = new Combo(editorBtnRowComp, @@ -4381,10 +4247,7 @@ public class TextEditorDialog extends CaveSWTDialog // fields to function properly. If focus is not set to a button, then // the text fields' listeners do not activate properly. enterEditorBtn.setFocus(); - statusBarLabel.setText(""); - attachedFile = null; - attachedFilename = null; return true; } @@ -4536,20 +4399,11 @@ public class TextEditorDialog extends CaveSWTDialog importFromFileItem.setEnabled(!inEditMode); recoverEditSessionItem.setEnabled(!inEditMode); - // --------------------------------- - // File Menu menu items - // Disabled when in editor mode - // --------------------------------- - resendWarningProductnItem - .setEnabled(!inEditMode && textEditor.getText() != null - && textEditor.getText().length() > 0); - // --------------------------------- // File Menu menu items // Enabled when in editor mode // --------------------------------- saveItem.setEnabled(inEditMode); - sendExitEditorItem.setEnabled(inEditMode); cancelEditorItem.setEnabled(inEditMode); // --------------------------------- @@ -4741,67 +4595,6 @@ public class TextEditorDialog extends CaveSWTDialog } } - /** - * Attaches the contents of a file to a product. - */ - private void attachFile() { - FileDialog dlg = new FileDialog(shell, SWT.OPEN); - dlg.setText("Attach File"); - dlg.setFilterNames(FILTER_NAMES); - dlg.setFilterExtensions(FILTER_EXTS); - if (attachedFilename != null && attachedFilename.trim().length() > 0) { - int startIndex = statusBarLabel.getText().indexOf(":") + 1; - int endIndex = statusBarLabel.getText().lastIndexOf(File.separator) - + 1; - String filterPath = statusBarLabel.getText().substring(startIndex, - endIndex); - dlg.setFilterPath(filterPath); - dlg.setFileName(statusBarLabel.getText().substring(startIndex)); - } - String fn = dlg.open(); - if (fn != null) { - try { - File file = new File(fn); - if (file.exists() && file.length() <= 50000 - && isTextFile(file)) { - try (FileInputStream in = new FileInputStream(file)) { - byte[] bytes = new byte[(int) file.length()]; - int offset = 0; - int numRead = 0; - while (offset < bytes.length - && (numRead = in.read(bytes, offset, - bytes.length - offset)) >= 0) { - offset += numRead; - } - attachedFile = bytes; - attachedFilename = fn - .substring(fn.lastIndexOf(File.separator) + 1); - statusBarLabel.setText("Attachment: " + fn); - } - } else { - StringBuilder sb = new StringBuilder(); - if (!file.exists()) { - sb.append("File does NOT exist!\n\n"); - } else if (file.length() > 50000) { - sb.append("File size is too large!\n\n"); - } else { - sb.append("File is NOT a text file!\n\n"); - } - userInformation(sb.toString() + fn); - } - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, "Error attaching file", - e); - } - } else { - if (statusBarLabel.getText().startsWith("Attachment: ")) { - statusBarLabel.setText(""); - attachedFile = null; - attachedFilename = null; - } - } - } - /** * Export data to a file. */ @@ -4929,296 +4722,6 @@ public class TextEditorDialog extends CaveSWTDialog userInformation("Notice", information); } - /** - * Disseminate the product. - * - * @param resend - * true if product is to be resent - */ - synchronized private void sendProduct(final boolean resend) { - if (!validateTime()) { - return; - } - StdTextProduct prod = getStdTextProduct(); - if (warnGenFlag) { - QCConfirmationMsg qcMsg = new QCConfirmationMsg(); - if (!qcMsg.checkWarningInfo(headerTF.getText(), - textEditor.getText(), prod.getNnnid())) { - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - qcMsg.getTitle(), qcMsg.getProductMessage(), - qcMsg.getModeMessage()); - wgcd.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - if (Boolean.TRUE.equals(returnValue)) { - finishSendProduct(resend); - } - - } - }); - wgcd.open(); - } else { - finishSendProduct(resend); - } - } else { - finishSendProduct(resend); - } - } - - /** - * 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 - */ - private void finishSendProduct(final boolean resend) { - if (statusBarLabel.getText().startsWith("Attachment:")) { - StringBuilder sb = new StringBuilder("An Attachment file ("); - int startIndex = "Attachment:".length() + 1; - sb.append(statusBarLabel.getText().substring(startIndex)); - sb.append(") will be transmitted with this message."); - int response = TextWSMessageBox.open(shell, "Notice", sb.toString(), - SWT.OK | SWT.CANCEL); - if (SWT.OK != response) { - return; - } - } - - // verify if product has already been resent - if (!verifyResendProduct()) { - return; - } - - // verify required fields - if (!verifyRequiredFields()) { - return; - } - - // verify wrapping - if (!verifyLineWidth(resend)) { - return; - } - - concludeSendProduct(resend); - } - - private void concludeSendProduct(final boolean resend) { - StdTextProduct prod = getStdTextProduct(); - if (TextEditorCfg.getTextEditorCfg().getValidateCharacterSet() - && !validateCharacterSet(prod.getNnnid())) { - return; - } - - if (isWarnGenDlg == true) { - String afosId = prod.getCccid() + prod.getNnnid() + prod.getXxxid(); - SendConfirmationMsg sendMsg = new SendConfirmationMsg(resend, - afosId, prod.getNnnid()); - - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - sendMsg.getTitle(), sendMsg.getProductMessage(), - sendMsg.getModeMessage()); - wgcd.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - if (Boolean.TRUE.equals(returnValue)) { - checkEmergencyProduct(resend); - } - } - }); - wgcd.open(); - } else { - checkEmergencyProduct(resend); - } - } - - /** - * Checks if the product is a emergency warning product and opens up the - * WarnGen Confirmation Dialog if necessary. - * - * @param resend - * true if product is to be resent - */ - private void checkEmergencyProduct(final boolean resend) { - StdTextProduct prod = getStdTextProduct(); - EmergencyConfirmationMsg emergencyMsg = new EmergencyConfirmationMsg(); - if (emergencyMsg - .checkWarningInfo(headerTF.getText().toUpperCase(), - MixedCaseProductSupport.conditionalToUpper( - prod.getNnnid(), textEditor.getText()), - prod.getNnnid()) == false) { - - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - emergencyMsg.getTitle(), emergencyMsg.getProductMessage(), - emergencyMsg.getModeMessage()); - wgcd.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - if (Boolean.TRUE.equals(returnValue)) { - warngenCloseCallback(resend); - } - - } - }); - wgcd.open(); - } else { - warngenCloseCallback(resend); - } - } - - /** - * This is used by finishedSendProduct as the call back to the warnGen - * confirmaiton Dialog. - * - * @param resend - * @param result - */ - private void warngenCloseCallback(boolean resend) { - - StdTextProduct prod = getStdTextProduct(); - String body = MixedCaseProductSupport - .conditionalToUpper(prod.getNnnid(), textEditor.getText()); - CAVEMode mode = CAVEMode.getMode(); - boolean isOperational = CAVEMode.OPERATIONAL.equals(mode) - || CAVEMode.TEST.equals(mode); - if (isOperational) { - removeOptionalFields(); - - try { - updateTextEditor(body); - if ((inEditMode || resend) - && !saveEditedProduct(prod, false, resend, true) - .isEmpty()) { - inEditMode = false; - } - if (!resend) { - /* - * Update the vtec string in the message. It looks wrong to - * do this after saveEditedProduct, but it works because for - * this case (isOpertional && ! resend) case, - * saveEditedProduct, does not actually save anything. - */ - if (shouldSetETNtoNextValue(prod)) { - statusHandler.handle(Priority.INFO, - "Will increment ETN for this product."); - prod.setProduct(VtecUtil.getVtec( - removeSoftReturns(prod.getProduct()), true)); - } else { - statusHandler.handle(Priority.INFO, - "Will NOT increment ETN for this product."); - } - // Update editor so the proper send times are displayed. - textEditor.setText(prod.getProduct()); - } - - String product = prod.getProduct(); - - if (notify != null) { - notify.add(product); - } - - // Code in Run statement goes here! - //new Thread(new ThriftClientRunnable(req)).start(); - logInfo("Autowrap char size = " + charWrapCol); - logInfo("Sent product:\n" + product); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error transmitting text product", e); - } - } else { - try { - if (!resend) { - if (shouldSetETNtoNextValue(prod)) { - statusHandler.handle(Priority.INFO, - "Will increment ETN for this product."); - body = VtecUtil.getVtec( - removeSoftReturns(MixedCaseProductSupport - .conditionalToUpper(prod.getNnnid(), - textEditor.getText()))); - } else { - statusHandler.handle(Priority.INFO, - "Will NOT increment ETN for this product."); - } - } - updateTextEditor(body); - if ((inEditMode || resend) - && !saveEditedProduct(prod, false, resend, false) - .isEmpty()) { - inEditMode = false; - } - String practiceProd = TextDisplayModel.getInstance() - .getProduct(token); - textEditor.setText(practiceProd); - SendPracticeProductRequest req = new SendPracticeProductRequest(); - req.setProductText(practiceProd); - req.setNotifyGFE(true); - req.setDrtString(new SimpleDateFormat("yyyyMMdd_HHmm") - .format(SimulatedTime.getSystemTime().getTime())); - - ThriftClient.sendRequest(req); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error transmitting text product", e); - } - } - - if (inEditMode == false && resend == false) { - saved = true; - StdTextProductId finalProduct = this.getStdTextProduct() - .getProdId(); - String header = null; - if (finalProduct.getNnnid().equals("WRK") - && !finalProduct.getXxxid().startsWith("WG")) { - header = "ZCZC " + finalProduct.getCccid() - + finalProduct.getNnnid() + finalProduct.getXxxid() - + " " + getAddressee() + "\nTTAA00 " - + finalProduct.getSite() + " " - + finalProduct.getHdrtime(); - } else { - header = finalProduct.getWmoid() + " " + finalProduct.getSite() - + " " + finalProduct.getHdrtime() + "\n" - + finalProduct.getNnnid() + finalProduct.getXxxid(); - } - headerTF.setText(header); - cancelEditor(false); - } - } - - private EtnRules getETNRules() throws Exception { - LocalizationFile lf = PathManagerFactory.getPathManager() - .getStaticLocalizationFile(ETN_RULES_FILE); - if (lf == null) { - throw new Exception( - "ETN rules file (" + ETN_RULES_FILE + ") not found."); - } - try (InputStream stream = lf.openInputStream()) { - return JAXB.unmarshal(stream, EtnRules.class); - } - } - - private boolean shouldSetETNtoNextValue(StdTextProduct prod) { - List excludedPhenSigs = null; - try { - excludedPhenSigs = getETNRules().getExcludePhenSigs(); - } catch (Exception e) { - statusHandler.handle(Priority.WARN, - "Error loading ETN assignment rules. Will use default rules.", - e); - excludedPhenSigs = defaultNoETNIncrementPhenSigs; - } - boolean result = true; - VtecObject vo = VtecUtil.parseMessage(prod.getProduct()); - if (vo != null && excludedPhenSigs != null - && excludedPhenSigs.contains(vo.getPhensig())) { - result = false; - } - return result; - } - - /** * Recreates the original message by combining the header and the body from * the edit windows. @@ -6320,8 +5823,6 @@ public class TextEditorDialog extends CaveSWTDialog // Automatically open the editor window with returned data. if (enterEditor) { enterEditor(); - } else { - resendWarningProductnItem.setEnabled(true); } } } @@ -6548,8 +6049,6 @@ public class TextEditorDialog extends CaveSWTDialog if (statusBarLabel.getText().contains("Attachment: ")) { statusBarLabel.setText(""); - attachedFile = null; - attachedFilename = null; } } @@ -7216,49 +6715,6 @@ public class TextEditorDialog extends CaveSWTDialog updateButtonology(commandText); } - private boolean validateCharacterSet(String nnn) { - boolean rval = true; - - Pattern UPPER_PATTERN = Pattern.compile("[^" + Pattern.quote( - TextEditorCfg.getTextEditorCfg().getUpperCaseValidCharcters()) - + "]"); - - Pattern MIXED_PATTERN = Pattern.compile("[^" + Pattern.quote( - TextEditorCfg.getTextEditorCfg().getMixedCaseValidCharacters()) - + "]"); - - String body = textEditor.getText(); - Pattern pattern; - if (MixedCaseProductSupport.isMixedCase(nnn)) { - pattern = MIXED_PATTERN; - } else { - body = body.toUpperCase(); - pattern = UPPER_PATTERN; - } - - String[] separatedLines = body.split("\n"); - int lineNum = 0; - for (String line : separatedLines) { - lineNum++; - Matcher matcher = pattern.matcher(line); - if (matcher.find()) { - rval = false; - - String errorMsg = "Illegal character '" + matcher.group() - + "' on line " + lineNum + ", column " - + (matcher.start() + 1); - userInformation(errorMsg); - if (!textEditor.isDisposed()) { - int offset = body.indexOf(matcher.group()); - textEditor.setSelection(offset, offset + 1); - textEditor.redraw(); - textEditor.setFocus(); - } - } - } - return rval; - } - /** * Checks product to verify all required fields have been filled in. * @@ -7275,7 +6731,7 @@ public class TextEditorDialog extends CaveSWTDialog if (endIndex >= startIndex) { rval = false; userInformation( - "You must modify the selected region before sending or saving the product."); + "Product requires changes before saving"); if (!textEditor.isDisposed()) { textEditor.setSelection(startIndex, endIndex + 3); textEditor.setFocus(); @@ -7286,29 +6742,6 @@ public class TextEditorDialog extends CaveSWTDialog return rval; } - /** - * Checks to see if a product can be resent. - * - * @return true when product can be resent - */ - private boolean verifyResendProduct() { - boolean resend = true; - - String body = textEditor.getText(); - StdTextProduct stdTextProduct = TextDisplayModel.getInstance() - .getStdTextProduct(token); - if (body == null || body.length() == 0) { - userInformation("Resend Warning Product Error", - "There is no product to send. \n Action aborted!"); - resend = false; - } else if (isProductForbiddenToEdit(stdTextProduct, - "Resend Warning Product Error", false)) { - resend = false; - } - - return resend; - } - /** * Add RESENT to the end of the MND line */ @@ -7340,20 +6773,6 @@ public class TextEditorDialog extends CaveSWTDialog return sb.toString(); } - private void removeOptionalFields() { - String text = textEditor.getText(); - int startIndex = text.indexOf("!--"); - int endIndex = text.indexOf("--!", startIndex); - while (startIndex >= 0 && endIndex >= startIndex) { - String part1 = text.substring(0, startIndex).trim(); - String part2 = text.substring(endIndex + 3).trim(); - text = part1 + "\n\n" + part2; - startIndex = text.indexOf("!--"); - endIndex = text.indexOf("--!", startIndex); - } - textEditor.setText(text); - } - /* * This class handles a timer to auto save a product to a file. */ @@ -7765,17 +7184,6 @@ public class TextEditorDialog extends CaveSWTDialog } } - /* - * This class handles sending a request to a Thrift Client. - */ - private class ThriftClientRunnable implements Runnable { - - @Override - public void run() { - - } - } - /* * (non-Javadoc) * @@ -8513,71 +7921,6 @@ public class TextEditorDialog extends CaveSWTDialog return lineText; } - /** - * Determine if the contents of a file contains a text field. - * - * @param file - * @return - * @throws IOException - */ - private boolean isTextFile(File file) throws IOException { - boolean result = false; - - byte[] bytesFromFile = getBytesFromFile(file); - for (byte b : bytesFromFile) { - if (b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D - || b >= 0x20 && b <= 0x7E) { - result = true; - break; - } - } - - return result; - } - - /** - * Get the contents of file as a byte array. - * - * @param file - * @return bytes - * @throws IOException - */ - private byte[] getBytesFromFile(File file) throws IOException { - byte[] bytes = null; - - try (InputStream is = new FileInputStream(file)) { - - // Get the size of the file - long length = file.length(); - - if (length > Integer.MAX_VALUE) { - // File is too large - } - - // Create the byte array to hold the data - bytes = new byte[(int) length]; - - // Read in the bytes - int offset = 0; - int numRead = 0; - while (offset < bytes.length && (numRead = is.read(bytes, offset, - bytes.length - offset)) >= 0) { - offset += numRead; - } - - // Ensure all the bytes have been read in - if (offset < bytes.length) { - throw new IOException( - "Could not completely read file " + file.getName()); - } - } catch (Exception ex) { - statusHandler.handle(Priority.PROBLEM, - "Error opening input stream.", ex); - } - - return bytes; - } - private void clearButtons() { if (autoWrapMenuItem != null) { Menu menu = autoWrapMenuItem.getMenu(); @@ -8587,15 +7930,6 @@ public class TextEditorDialog extends CaveSWTDialog } } - /** - * Set the enable state of the editor's send button. - * - * @param state - */ - public void enableSend(boolean state) { - editorSendBtn.setEnabled(state); - } - /** * Queue a afosId and who to noify. * @@ -8651,32 +7985,6 @@ public class TextEditorDialog extends CaveSWTDialog return retval; } - /** - * Retrieve a product from a remote site instead of the local server. - * - * @param req - */ - private void sendRemoteRetrievalRequest(final RemoteRetrievalRequest req) { - Job job = new Job("Remote Product Request") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - RemoteRetrievalResponse response = (RemoteRetrievalResponse) ThriftClient - .sendRequest(req); - statusHandler.handle( - response.isOk() ? Priority.INFO : Priority.ERROR, - response.getStatusMessage()); - } catch (VizException e) { - statusHandler.error("Remote request failed", e); - } - return Status.OK_STATUS; - } - }; - job.setPriority(Job.LONG); - job.setSystem(true); - job.schedule(); - } - /** * Check of the bbb string to make it the empty string when it is for a * normal product. @@ -8699,7 +8007,6 @@ public class TextEditorDialog extends CaveSWTDialog editorCopyBtn.setEnabled(false); editorPasteBtn.setEnabled(false); editorFillBtn.setEnabled(false); - editorAttachBtn.setEnabled(false); overStrikeItem.setEnabled(false); if (!isTemplateOverwriteModeSet) { if (overwriteMode) { @@ -8716,7 +8023,6 @@ public class TextEditorDialog extends CaveSWTDialog editorCopyBtn.setEnabled(true); editorPasteBtn.setEnabled(true); editorFillBtn.setEnabled(true); - editorAttachBtn.setEnabled(true); if (isTemplateOverwriteModeSet && !overwriteMode) { textEditor.invokeAction(ST.TOGGLE_OVERWRITE); isTemplateOverwriteModeSet = false; @@ -8772,12 +8078,6 @@ public class TextEditorDialog extends CaveSWTDialog * @return true when able to send text product */ private boolean validateTime() { - if (shell != null && !shell.isDisposed() && shell.isVisible() - && !SimulatedTimeOperations.isTransmitAllowed()) { - SimulatedTimeOperations.displayFeatureLevelWarning(shell, - "Send Text Product"); - return false; - } return true; } @@ -8866,49 +8166,6 @@ public class TextEditorDialog extends CaveSWTDialog return paddingPatternList; } - private boolean verifyLineWidth(final boolean resend) { - int lineToWrap = findLineToWrap(); - if (lineToWrap == -1) { - return true; - } - LineWrapCheckConfirmationMsg lineWrapCheckConfirmationMsg = new LineWrapCheckConfirmationMsg( - shell); - lineWrapCheckConfirmationMsg.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - if (AnswerChoices.EDIT.equals(returnValue)) { - // do nothing - } else if (AnswerChoices.FIX.equals(returnValue)) { - while (findLineToWrap() > -1) { - int lineToWrap = findLineToWrap(); - // recompileRegex might not have been called - if (standardWrapRegex == null) { - recompileRegex(); - } - rewrapInternal(lineToWrap); - } - concludeSendProduct(resend); - } else if (AnswerChoices.SEND.equals(returnValue)) { - concludeSendProduct(resend); - } - } - }); - lineWrapCheckConfirmationMsg.open(); - return false; - } - - private int findLineToWrap() { - int rval = -1; - for (int i = 0; i < textEditor.getLineCount(); ++i) { - String line = textEditor.getLine(i).trim(); - if (line.length() > charWrapCol) { - return i; - } - } - return rval; - } - private void logInfo(String s) { statusHandler.handle(Priority.INFO, "Text " + token + " TextEditorDialog (UI Trace) - " + s); } 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 deleted file mode 100644 index 004488e6ba..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.viz.texteditor.dialogs; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.viz.core.mode.CAVEMode; -import com.raytheon.viz.texteditor.Activator; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * Main Text Editor dialog. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------  --------------------------
- * 27Jul2010    4773        cjeanbap    Initial development
- * 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.
- * 17 Sep 2013  #2384       lvenable    Fixed memory leak and utilized the disposed()
- *                                      method.
- * May 29, 2015 #4441       randerso    Fixed loading of images
- * 
- * 
- * - * @author cjeanbap - */ -public class WarnGenConfirmationDlg extends CaveSWTDialog { - - /** - * Handler used for messges. - */ - private final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - - private String productMessage; - - private String modeMessage; - - private CAVEMode mode; - - private String IMAGE_OPERATIONAL = "res/images/twsOper.gif"; - - private String IMAGE_TEST = "res/images/twsTest.gif"; - - private String IMAGE_PRACTICE = "res/images/twsPractice.gif"; - - private Image stopSign = null; - - /** - * Constructor. - * - * @param parentShell - * Parent shell. - * @param title - * Dialog title. - * @param productMessage - * Product message. - * @param modeMessage - * Mode message. - */ - protected WarnGenConfirmationDlg(Shell parentShell, String title, - String productMessage, String modeMessage) { - super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE - | CAVE.DO_NOT_BLOCK); - - setText(title); - - this.productMessage = productMessage; - this.modeMessage = modeMessage; - this.mode = CAVEMode.getMode(); - setReturnValue(Boolean.FALSE); - } - - @Override - protected void initializeComponents(Shell shell) { - Composite mainComposite = new Composite(shell, SWT.NONE); - mainComposite.setLayout(new GridLayout(1, false)); - createImage(mainComposite); - createMessageLabel(mainComposite); - createButtonRow(mainComposite); - } - - private void createImage(Composite mainComposite) { - - String imagePath = null; - try { - if (mode.equals(CAVEMode.OPERATIONAL)) { - // add Live image - imagePath = IMAGE_OPERATIONAL; - } else if (mode.equals(CAVEMode.TEST)) { - // add Test image - imagePath = IMAGE_TEST; - } else if (mode.equals(CAVEMode.PRACTICE)) { - // add Practice image - imagePath = IMAGE_PRACTICE; - } else { - // unknown - imagePath = IMAGE_OPERATIONAL; - } - - ImageDescriptor id = Activator.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, imagePath); - stopSign = id.createImage(mainComposite.getDisplay()); - Label stopSignLbl = new Label(mainComposite, 0); - stopSignLbl.setImage(stopSign); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } - } - - private void createMessageLabel(Composite mainComposite) { - Label productMsgLbl = new Label(mainComposite, 0); - productMsgLbl.setText(this.productMessage); - Label modeMsgLbl = new Label(mainComposite, 0); - modeMsgLbl.setText(this.modeMessage); - - Label sepLbl = new Label(mainComposite, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - private void createButtonRow(Composite mainComposite) { - Composite buttonRowComp = new Composite(mainComposite, SWT.NONE); - buttonRowComp.setLayout(new GridLayout(2, true)); - buttonRowComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, - false)); - - // Add the Go Ahead (Save) button. - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - Button saveBtn = new Button(buttonRowComp, SWT.PUSH); - saveBtn.setText("Go Ahead!"); - saveBtn.setLayoutData(gd); - saveBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - dispose(Boolean.TRUE); - } - }); - - // Add the Abort button. - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - Button abortCutBtn = new Button(buttonRowComp, SWT.PUSH); - abortCutBtn.setText("Abort"); - abortCutBtn.setLayoutData(gd); - abortCutBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - dispose(Boolean.FALSE); - } - }); - } - - private void dispose(Boolean returnValue) { - setReturnValue(returnValue); - close(); - } - - @Override - protected void disposed() { - if (stopSign != null) { - stopSign.dispose(); - } - } -} diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/WarngenConstants.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/WarngenConstants.java index e881a5f98c..3d2ecbbd05 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/WarngenConstants.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/WarngenConstants.java @@ -38,7 +38,7 @@ package com.raytheon.viz.warngen; public class WarngenConstants { - public static final int INSTRUCTIONS_HEIGHT = 40; + public static final int INSTRUCTIONS_HEIGHT = 20; public static final String INSTRUCTION_DRAG_STORM = "Move Centroid to Storm in any Frame"; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenAction.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenAction.java index d1fa196bde..d021e12501 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenAction.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenAction.java @@ -95,29 +95,6 @@ public class WarngenAction extends AbstractGenericToolAction { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - - if ((textWorkstationDlg == null) || textWorkstationDlg.isDisposed()) { - textWorkstationDlg = new TextWorkstationDlg(Display.getCurrent()); - textWorkstationDlg.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - textWorkstationDlg = null; - } - }); - textWorkstationDlg.open(); - } else { - textWorkstationDlg.bringToTop(); - } - - if (!SimulatedTimeOperations.isTransmitAllowed()) { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - SimulatedTimeOperations - .displayFeatureLevelWarning(shell, "WarnGen"); - return null; - } - return super.execute(arg0); } } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index 452eb83a44..0a69413320 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -85,7 +85,6 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.localization.LocalizationManager; -import com.raytheon.uf.viz.core.maps.MapManager; import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.Mode; @@ -96,7 +95,6 @@ import com.raytheon.viz.texteditor.util.SiteAbbreviationUtil; import com.raytheon.viz.texteditor.util.VtecUtil; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.input.EditableManager; import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; import com.raytheon.viz.warngen.Activator; @@ -239,15 +237,6 @@ public class WarngenDialog extends CaveSWTDialog implements private static String UPDATELISTTEXT = "UPDATE LIST "; - /** "OK" button text */ - private static final String OK_BTN_LABEL = "Create Text"; - - /** "Restart" button text */ - private static final String RS_BTN_LABEL = "Reset"; - - /** "Cancel" button text */ - private static final String CLOSE_BUTTON_LABEL = "Close"; - private static final double MIN_LATLON_DIFF = 1.0E-5; private static final double MIN_DIFF = 1.0E-8; @@ -258,8 +247,6 @@ public class WarngenDialog extends CaveSWTDialog implements final DateFormat df = new SimpleDateFormat("HH:mm EEE d-MMM"); - private final java.util.List mapsLoaded = new ArrayList(); - private Button okButton; private final BulletListManager bulletListManager; @@ -292,8 +279,6 @@ public class WarngenDialog extends CaveSWTDialog implements private Button fromTrack; - private Button warnedAreaVisible; - private Button[] mainProductBtns; private Button other; @@ -308,10 +293,6 @@ public class WarngenDialog extends CaveSWTDialog implements private Button track; - private Button changeBtn; - - private ValidPeriodDialog validPeriodDlg; - private boolean boxEditable = true; private boolean trackEditable = true; @@ -332,9 +313,9 @@ public class WarngenDialog extends CaveSWTDialog implements private Button restartBtn; - private Text start; - - private Text end; + private Label validPeriod; + + private static String SEP = " to "; private Text instructionsBox; @@ -487,18 +468,48 @@ public class WarngenDialog extends CaveSWTDialog implements /** * @param mainComposite + * + * + * + private void createRedrawBoxGroup(Composite mainComposite) { + + Group redrawBox = new Group(mainComposite, SWT.NONE); + + GridLayout gl = new GridLayout(1, false); + gl.verticalSpacing = 2; + gl.marginHeight = 1; + redrawBox.setLayout(gl); + redrawBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, + 1)); + + Composite redrawFrom = new Composite(redrawBox, SWT.NONE); + int columns = debug ? 4 : 3; + redrawFrom.setLayout(new GridLayout(columns, false)); + redrawFrom.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, + true)); + + createRedrawFromControls(redrawFrom); + } + * */ private void createTimeRangeGroup(Composite mainComposite) { + Group timeRange = new Group(mainComposite, SWT.NONE); - timeRange.setText("Time Range"); - timeRange.setLayout(new GridLayout(6, false)); - - Label dur = new Label(timeRange, SWT.BOLD); - dur.setText("Duration:"); - + GridLayout gl = new GridLayout(1, false); + gl.verticalSpacing = 2; + gl.marginHeight = 1; + timeRange.setLayout(gl); + timeRange.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, + 1)); + + Composite timeRangeComp = new Composite(timeRange, SWT.NONE); + timeRangeComp.setLayout(new GridLayout(3, false)); + timeRangeComp.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, + true)); + GridData gd = new GridData(); - gd.horizontalSpan = 3; - durationList = new Combo(timeRange, SWT.READ_ONLY); + gd.horizontalSpan = 1; + durationList = new Combo(timeRangeComp, SWT.READ_ONLY); WarngenConfiguration config = warngenLayer.getConfiguration(); if (config.getDefaultDuration() != 0) { setDefaultDuration(config.getDefaultDuration()); @@ -507,7 +518,7 @@ public class WarngenDialog extends CaveSWTDialog implements } setDurations(config.getDurations()); durationList.setText(defaultDuration.displayString); - durationList.setLayoutData(gd); + //durationList.setLayoutData(gd); durationList.setEnabled(config.isEnableDuration()); startTime = TimeUtil.newCalendar(); @@ -515,26 +526,12 @@ public class WarngenDialog extends CaveSWTDialog implements defaultDuration.minutes); gd = new GridData(); - gd.horizontalSpan = 3; - start = new Text(timeRange, SWT.BORDER | SWT.READ_ONLY); - start.setLayoutData(gd); - start.setText(df.format(this.startTime.getTime())); - - new Label(timeRange, SWT.NONE).setText(" to "); - - end = new Text(timeRange, SWT.BORDER | SWT.READ_ONLY); - end.setText(df.format(this.endTime.getTime())); - - changeBtn = new Button(timeRange, SWT.PUSH); - changeBtn.setText("Change..."); - changeBtn.setEnabled(!config.isEnableDuration()); - changeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeSelected(); - } - }); - + gd.horizontalSpan = 2; + validPeriod = new Label(timeRangeComp, SWT.FILL); + //validPeriod.setLayoutData(gd); + validPeriod.setText( df.format(this.startTime.getTime()) + + SEP + df.format(this.endTime.getTime())); + durationList.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -545,7 +542,6 @@ public class WarngenDialog extends CaveSWTDialog implements private void createProductTypeGroup(Composite mainComposite) { productType = new Group(mainComposite, SWT.NONE); - productType.setText("Product type"); GridLayout gl = new GridLayout(2, false); gl.verticalSpacing = 2; gl.marginHeight = 1; @@ -563,12 +559,10 @@ public class WarngenDialog extends CaveSWTDialog implements other.setText("Other:"); other.setEnabled(true); other.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent arg0) { otherSelected(); } - }); otherProductListCbo = new Combo(productType, SWT.READ_ONLY @@ -683,27 +677,16 @@ public class WarngenDialog extends CaveSWTDialog implements } private void createRedrawBoxGroup(Composite mainComposite) { + Group redrawBox = new Group(mainComposite, SWT.NONE); + GridLayout gl = new GridLayout(1, false); gl.verticalSpacing = 2; gl.marginHeight = 1; redrawBox.setLayout(gl); - redrawBox.setText("Redraw Box on Screen from:"); redrawBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - warnedAreaVisible = new Button(redrawBox, SWT.CHECK); - warnedAreaVisible.setText("Warned Area Visible"); - warnedAreaVisible.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, - true, 1, 1)); - warnedAreaVisible.setSelection(true); - warnedAreaVisible.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - warnedAreaVisibleToggled(); - } - }); - Composite redrawFrom = new Composite(redrawBox, SWT.NONE); int columns = debug ? 4 : 3; redrawFrom.setLayout(new GridLayout(columns, false)); @@ -721,9 +704,7 @@ public class WarngenDialog extends CaveSWTDialog implements public void widgetSelected(SelectionEvent e) { redrawFromTrack(); } - }); - fromWarned = new Button(redrawFrom, SWT.PUSH); fromWarned.setText("Warned/Hatched Area"); fromWarned.setEnabled(true); @@ -732,9 +713,7 @@ public class WarngenDialog extends CaveSWTDialog implements public void widgetSelected(SelectionEvent e) { redrawFromWarned(); } - }); - damBreakThreatArea = new Button(redrawFrom, SWT.PUSH); damBreakThreatArea.setText("Dam Break Threat Area"); damBreakThreatArea.setEnabled(false); @@ -769,24 +748,16 @@ public class WarngenDialog extends CaveSWTDialog implements private void createBackupTrackEditGroups(Composite mainComposite) { Composite backupTrackEditComp = new Composite(mainComposite, SWT.NONE); + backupTrackEditComp.setLayout(new GridLayout(3, false)); backupTrackEditComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + backupTrackEditComp.setBackground(Display. + getCurrent().getSystemColor(SWT.COLOR_TRANSPARENT)); - createReset(backupTrackEditComp); - createTrackGroup(backupTrackEditComp); - createEditGroup(backupTrackEditComp); - - } - - /** - * Create the reset button - * - * @param backupTrackEditComp - */ - private void createReset(Composite backupTrackEditComp) { restartBtn = new Button(backupTrackEditComp, SWT.PUSH); - restartBtn.setText(RS_BTN_LABEL); + restartBtn.setText("Reset"); GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); gd.widthHint = 100; restartBtn.setLayoutData(gd); @@ -796,22 +767,27 @@ public class WarngenDialog extends CaveSWTDialog implements resetPressed(); } }); + createTrackGroup(backupTrackEditComp); + createEditGroup(backupTrackEditComp); } - private void createTrackGroup(Composite backupTrackEditComp) { Group trackGroup = new Group(backupTrackEditComp, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.verticalSpacing = 2; gl.marginHeight = 1; trackGroup.setLayout(gl); - trackGroup.setText("Track type"); trackGroup.setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true)); - + trackGroup.setBackgroundMode(SWT.INHERIT_NONE); + /* + trackGroup.setBackground(Display. + getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); + */ + oneStorm = new Button(trackGroup, SWT.RADIO); - oneStorm.setText("One Storm"); + oneStorm.setText("Single Storm"); oneStorm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { @@ -850,7 +826,6 @@ public class WarngenDialog extends CaveSWTDialog implements gl.verticalSpacing = 2; gl.marginHeight = 1; editGroup.setLayout(gl); - editGroup.setText("Edit"); editGroup .setLayoutData(new GridData(SWT.DEFAULT, SWT.FILL, false, true)); @@ -899,7 +874,7 @@ public class WarngenDialog extends CaveSWTDialog implements true)); okButton = new Button(buttonComp, SWT.PUSH); - okButton.setText(OK_BTN_LABEL); + okButton.setText("Create Text"); GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); gd.widthHint = 100; okButton.setLayoutData(gd); @@ -917,7 +892,7 @@ public class WarngenDialog extends CaveSWTDialog implements }); Button btn = new Button(buttonComp, SWT.PUSH); - btn.setText(CLOSE_BUTTON_LABEL); + btn.setText("Close"); gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); gd.widthHint = 100; btn.setLayoutData(gd); @@ -1532,14 +1507,6 @@ public class WarngenDialog extends CaveSWTDialog implements realizeEditableState(); } - /** - * Whether to warn area visible was toggled - */ - private void warnedAreaVisibleToggled() { - warngenLayer.setShouldDrawShaded(warnedAreaVisible.getSelection()); - warngenLayer.issueRefresh(); - } - /** * Responsible for drawing a pre-defined warning polygon (coords) on the * WarnGen layer. @@ -1672,7 +1639,6 @@ public class WarngenDialog extends CaveSWTDialog implements boolean enableDuration = warngenLayer.getConfiguration() .isEnableDuration(); durationList.setEnabled(enableDuration); - changeBtn.setEnabled(!enableDuration); recreateDurations(durationList); // Current selection doesn't matter anymore @@ -1731,7 +1697,8 @@ public class WarngenDialog extends CaveSWTDialog implements durList.setText(defaultDuration.displayString); if (warngenLayer.getConfiguration().isEnableDuration()) { endTime = DurationUtil.calcEndTime(startTime, defaultDuration.minutes); - end.setText(df.format(endTime.getTime())); + validPeriod.setText( df.format(startTime.getTime()) + + SEP + df.format(endTime.getTime())); } warngenLayer.getStormTrackState().newDuration = defaultDuration.minutes; @@ -1947,39 +1914,6 @@ public class WarngenDialog extends CaveSWTDialog implements // TODO : this pack/layout maybe causing the issue } - private void changeSelected() { - statusHandler.debug("changeSelected"); - if ((validPeriodDlg == null) || validPeriodDlg.isDisposed()) { - validPeriodDlg = new ValidPeriodDialog(shell, (Calendar) startTime.clone(), (Calendar) endTime.clone()); - validPeriodDlg.setCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - int duration = (Integer) returnValue; - statusHandler.debug("changeSelected.dialogClosed: " - + duration); - if (duration != -1) { - durationList.setEnabled(false); - if (warngenLayer.getConfiguration().isEnableDuration()) { - endTime.add(Calendar.MINUTE, duration); - } else { - endTime = (Calendar) validPeriodDlg.getEndTime().clone(); - } - end.setText(df.format(endTime.getTime())); - warngenLayer.getStormTrackState().newDuration = duration; - warngenLayer.getStormTrackState().geomChanged = true; - warngenLayer.issueRefresh(); - changeStartEndTimes(); - } - validPeriodDlg = null; - } - }); - validPeriodDlg.open(); - } else { - validPeriodDlg.bringToTop(); - } - } - /** * */ @@ -1990,7 +1924,8 @@ public class WarngenDialog extends CaveSWTDialog implements endTime = DurationUtil.calcEndTime(extEndTime != null ? extEndTime : startTime, ((DurationData) durationList.getData(selection)).minutes); - end.setText(df.format(endTime.getTime())); + validPeriod.setText( df.format(startTime.getTime()) + + SEP + df.format(endTime.getTime())); warngenLayer.getStormTrackState().newDuration = ((DurationData) durationList .getData(selection)).minutes; @@ -2018,38 +1953,6 @@ public class WarngenDialog extends CaveSWTDialog implements // updateMaps(bulletListManager.getMapsToLoad()); } - private void updateMaps(ArrayList mapsToLoad) { - /* Load maps */ - for (String str : mapsToLoad) { - if (!mapsLoaded.contains(str)) { - MapManager.getInstance(warngenLayer.getDescriptor()) - .loadMapByName(str); - mapsLoaded.add(str); - } - } - /* Unload maps */ - ArrayList mapsToUnload = new ArrayList(); - for (String str : mapsLoaded) { - if (!mapsToLoad.contains(str)) { - MapManager.getInstance(warngenLayer.getDescriptor()).unloadMap( - str); - mapsToUnload.add(str); - } - } - for (String str : mapsToUnload) { - mapsLoaded.remove(str); - } - - /* Load maps */ - for (String str : mapsToLoad) { - if (!mapsLoaded.contains(str)) { - MapManager.getInstance(warngenLayer.getDescriptor()) - .loadMapByName(str); - mapsLoaded.add(str); - } - } - } - /** * Timer to update the start and stop time for warngen. */ @@ -2127,7 +2030,7 @@ public class WarngenDialog extends CaveSWTDialog implements .getData(updateListCbo.getItem(updateListCbo .getSelectionIndex())); startTime = TimeUtil.newCalendar(); - start.setText(df.format(startTime.getTime())); + if ((fd == null) || (WarningAction.valueOf(fd.getAct()) == WarningAction.NEW)) { endTime = DurationUtil.calcEndTime(startTime, duration); @@ -2136,7 +2039,8 @@ public class WarngenDialog extends CaveSWTDialog implements endTime = DurationUtil.calcEndTime(extEndTime, duration); } } - end.setText(df.format(endTime.getTime())); + validPeriod.setText( df.format(startTime.getTime()) + + SEP + df.format(endTime.getTime())); } } @@ -2344,7 +2248,6 @@ public class WarngenDialog extends CaveSWTDialog implements boolean enableDuration = warngenLayer.getConfiguration() .isEnableDuration(); durationList.setEnabled(enableDuration); - changeBtn.setEnabled(!enableDuration); AbstractWarningRecord newWarn = CurrentWarnings.getInstance( warngenLayer.getLocalizedSite()).getNewestByTracking( @@ -2374,18 +2277,18 @@ public class WarngenDialog extends CaveSWTDialog implements private void setTimesFromFollowup(Date startDate, Date endDate) { // Sets the Time Range start and end times on dialog - start.setText(df.format(startDate)); startTime.setTime(startDate); - end.setText(df.format(endDate)); endTime.setTime(endDate); endTime.add(Calendar.MILLISECOND, 1); + validPeriod.setText( df.format(startTime.getTime()) + + SEP + df.format(endTime.getTime())); + // Sets the duration value on the dialog int durationInMinutes = (int) (endDate.getTime() - startDate.getTime()) / (60 * 1000); durationList.setText(String.valueOf(durationInMinutes)); durationList.setEnabled(false); - changeBtn.setEnabled(false); warngenLayer.getStormTrackState().endTime = endTime; }