diff --git a/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml b/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml index b0b8035ac6..13a9487cc5 100644 --- a/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml +++ b/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml @@ -5,7 +5,10 @@ History: - 07/25/2013 Greg Hull DR 15733 Created (and modified) from FontSizeCfg.xml and TextColorsCfg.xlm + 07/25/2013 Greg Hull DR 15733 Created (and modified) from FontSizeCfg.xml and TextColorsCfg.xml + 07/31/2013 B. Hebbard DR 15733 Changed highlightTextForegroundColor from "0, 0, 0" to "WHITE" + (per Joshua Huber and Greg Hull) + --> @@ -18,7 +21,7 @@ --> BLACK WHITE - 0, 0, 0 + WHITE 85, 152, 215 diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/IInputHandler.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/IInputHandler.java index ede8d437f7..8119be86a8 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/IInputHandler.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/IInputHandler.java @@ -30,6 +30,7 @@ import org.eclipse.swt.widgets.Event; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 7/1/06 chammack Initial Creation. + * 08/02/2013 DR 16427 Qinglu Lin (David's approach) Added SYSTEM_RESOURCE_LOW(1) to InputPriority. * * * @@ -39,8 +40,8 @@ import org.eclipse.swt.widgets.Event; public interface IInputHandler { public static enum InputPriority { - LOWEST(0), RESOURCE(3), SYSTEM_RESOURCE(4), PART(5), PERSPECTIVE(6), WINDOW( - 7); + LOWEST(0), SYSTEM_RESOURCE_LOW(1), RESOURCE(3), SYSTEM_RESOURCE(4), PART(5), PERSPECTIVE(6), + WINDOW(7); public Integer value; diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java index 6b95b144bd..0f8e253ddc 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/legend/D2DLegendResource.java @@ -71,6 +71,8 @@ import com.raytheon.viz.ui.actions.DummyAction; * drawn into the smaller pane. * Sep 4, 2012 15335 kshresth Will now display lightning/wind fields * when magnification set to 0 + * Aug 2, 2013 DR 16427 Qinglu Lin (David's approach) Changing InputPriority.SYSTEM_RESOURCE to + * InputPriority.SYSTEM_RESOURCE_LOW in initInternal(). * * * @@ -500,7 +502,7 @@ public class D2DLegendResource extends IDisplayPaneContainer rc = getResourceContainer(); if (rc != null) { rc.registerMouseHandler(legendHandler, - InputPriority.SYSTEM_RESOURCE); + InputPriority.SYSTEM_RESOURCE_LOW); rc.registerMouseHandler(changeModeHandler, InputPriority.RESOURCE); } } 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 bd5d96466a..6f448b23e7 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 @@ -144,6 +144,7 @@ import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport; import com.raytheon.uf.edex.wmo.message.WMOHeader; // import com.raytheon.uf.viz.core.RGBColors; 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.INotificationObserver; import com.raytheon.uf.viz.core.notification.NotificationException; @@ -322,6 +323,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox; * 31JAN2013 1563 rferrel Force location of airport tooltip. * 31JAN2013 1568 rferrel Spell checker now tied to this dialog instead of parent. * 26Apr2013 16123 snaples Removed setFocus to TextEditor in postExecute method. + * 07Jun2013 1981 mpduff Add user id to OUPRequest as it is now protected. * 20Jun2013 15733 XHuang Add functionalities that get Font size, Text colors from * *.xml files in localization; * add selection listener to catch the highlight words and @@ -1380,6 +1382,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, private Color highlightBackground; // protected Color color; + + /** * Constructor with additional cave style rules * @@ -1534,7 +1538,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } commandHistory = new CommandHistory(); - + // Create the menus createMenus(); @@ -3746,7 +3750,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, textEditor.setWordWrap(false); textEditor.setEditable(false); airportToolTip = new DefaultToolTip(textEditor, SWT.DEFAULT, true); - textEditor.setKeyBinding(SWT.INSERT, SWT.NULL); // DR 7826 + textEditor.setKeyBinding(SWT.INSERT, SWT.NULL); // DR 7826 // textColorCfg = getTextColorCfg(); setDefaultTextColor( TextEditorCfg.getTextEditorCfg() ); @@ -5002,6 +5006,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } req.setCheckBBB(true); req.setProduct(oup); + req.setUser(UserController.getUserObject()); // Code in Run statement goes here! new Thread(new ThriftClientRunnable(req)).start(); @@ -5590,27 +5595,25 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, int afosXxxLimit = 5; // second three characters is AFOS XXX /* - * DR15610 - Make sure that if the first line of the - * text product is not a WMO heading it is treated as - * part of the text body. + * DR15610 - Make sure that if the first line of the text product is not + * a WMO heading it is treated as part of the text body. */ String[] pieces = textEditor.getText().split("\r*\n", 2); if (pieces.length > 1) { pieces[0] += "\n"; // WMOHeader expects this } WMOHeader header = new WMOHeader(pieces[0].getBytes(), null); - if ( !header.isValid() ) { - headerTF.setText(""); - try { - textEditor.setText(originalText); - textEditor.setEditable(true); - textEditor.setEditable(false); - } catch (IllegalArgumentException e) { - // There is no text product body, so set it to the empty string. - textEditor.setText(""); - } - } - else { + if (!header.isValid()) { + headerTF.setText(""); + try { + textEditor.setText(originalText); + textEditor.setEditable(true); + textEditor.setEditable(false); + } catch (IllegalArgumentException e) { + // There is no text product body, so set it to the empty string. + textEditor.setText(""); + } + } else { // TODO FIX PARSING // First, set the current header by assuming that it usually @@ -5618,7 +5621,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, // though there will be exceptions to that "rule" as handled below. // So, obtain the AFOS NNNxxx. If it's where it is supposed to be // in the new format, then the existing header is already an AWIPS - // text product identifier. Otherwise it is a legacy AFOS identifier. + // text product identifier. Otherwise it is a legacy AFOS + // identifier. if (TextDisplayModel.getInstance().hasStdTextProduct(token)) { StdTextProduct textProd = TextDisplayModel.getInstance() .getStdTextProduct(token); @@ -5628,14 +5632,16 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, start = textEditor.getOffsetAtLine(thisLine + 1); if ((textEditor.getText(start, start + afosNnnLimit) .equals(prodId.getNnnid())) - && (textEditor.getText(start + afosNnnLimit + 1, start - + afosXxxLimit).equals(prodId.getXxxid()))) { + && (textEditor.getText(start + afosNnnLimit + 1, + start + afosXxxLimit).equals(prodId + .getXxxid()))) { // Text matches the products nnnid and xxxid numberOfLinesOfHeaderText = 2; - } else if (textEditor.getText(start, start + afosNnnLimit + 2) - .equals(AFOSParser.DRAFT_PIL) - || textEditor.getText(start, start + afosNnnLimit + 2) - .equals("TTAA0")) { + } else if (textEditor.getText(start, + start + afosNnnLimit + 2).equals( + AFOSParser.DRAFT_PIL) + || textEditor.getText(start, + start + afosNnnLimit + 2).equals("TTAA0")) { // Text matches temporary WRKWG# numberOfLinesOfHeaderText = 2; } else { @@ -5675,8 +5681,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, String line = null; do { numberOfBlankLines++; - line = textEditor.getLine(thisLine + numberOfLinesOfHeaderText - + numberOfBlankLines); + line = textEditor.getLine(thisLine + + numberOfLinesOfHeaderText + numberOfBlankLines); } while (line.length() == 0 || line.equals("")); // Note: 'st' is a reference to 'textEditor'... // delelete the header from the text in 'textEditor' @@ -5981,7 +5987,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, if ("MTR".equals(stdProdId.getNnnid()) && (commandText.startsWith("ALL:") || commandText.startsWith("A:") || commandText - .endsWith("000"))) { + .endsWith("000"))) { stripWMOHeaders(prod); } @@ -7074,7 +7080,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, || line.endsWith("ADVISORY") || line.endsWith("ADVISORY...TEST") || line.endsWith("ADVISORY...CORRECTED") || line - .endsWith("ADVISORY...CORRECTED...TEST"))) { + .endsWith("ADVISORY...CORRECTED...TEST"))) { line += "...RESENT"; updatedMND = true; } diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/alarms/AlertalarmStdTextProductUtil.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/alarms/AlertalarmStdTextProductUtil.java index 76f3c23386..f30156189e 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/alarms/AlertalarmStdTextProductUtil.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/alarms/AlertalarmStdTextProductUtil.java @@ -88,6 +88,8 @@ public class AlertalarmStdTextProductUtil { setCurrentReportfile(); reportAlarm(); + + System.exit(reportWriter.getAlarmCount()); } /* @@ -230,7 +232,7 @@ public class AlertalarmStdTextProductUtil { if (alarmCount > 0) { log.info(alarmCount + " alarms reported, report written to " + reportWriter.getFilename()); - saveReportTotextDb(); + //saveReportTotextDb(); } else { log.info("No alarms reported, info sent to " + reportWriter.getFilename()); diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefFilter.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefFilter.java index 8a91774037..1f5e647741 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefFilter.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefFilter.java @@ -27,6 +27,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import javax.xml.bind.JAXBException; @@ -63,6 +64,7 @@ import com.raytheon.uf.edex.decodertools.core.filterimpl.PluginDataObjectFilter; * ---------- ------- -------- -------------------------- * 1/10/2013 15497 wkwock Initial creation * 2/13/2013 1584 mpduff Fix creation of "dummy" config. + * 08/08/2013 16408 wkwock Use different metar.cfg file and options * * * @@ -167,16 +169,13 @@ public class MetarToShefFilter { } } - private PluginDataObject[] filterARun(PluginDataObject[] reports, + private PluginDataObject filterARun(PluginDataObject report, List filterElements) { - int reportCount = 0; - if (reports != null) { - - for (int i = 0; i < reports.length; i++) { - PluginDataObject r = null; - boolean keep = true; - for (AbstractFilterElement element : filterElements) { - r = element.filter(reports[i]); + if (report != null) { + PluginDataObject r = null; + boolean keep = true; + for (AbstractFilterElement element : filterElements) { + r = element.filter(report); // Only allow keep to be set to true. Once true it stays // that way. @@ -200,26 +199,12 @@ public class MetarToShefFilter { } } if (keep) { - reportCount++; + report = r; } else { - reports[i] = null; + report = null; } - } } - if (reportCount == 0) { - reports = new PluginDataObject[0]; - } else { - PluginDataObject[] newReports = new PluginDataObject[reportCount]; - int i = 0; - // Copy in the reports that passed filtering. - for (PluginDataObject report : reports) { - if (report != null) { - newReports[i++] = report; - } - } - reports = newReports; - } - return reports; + return report; } /** @@ -228,19 +213,20 @@ public class MetarToShefFilter { */ // @Override public PluginDataObject[] filter(PluginDataObject[] reports) { - PluginDataObject[] resultRpt = null; - for (MetarToShefRun mtsr : metarToShefRun) { - PluginDataObject[] tmpRprts = reports.clone(); - resultRpt = filterARun(tmpRprts, mtsr.getFilterElements()); - if (resultRpt != null && resultRpt.length >= 1) { - logger.info("Report matchs in filter " + mtsr.getFilterName()); - MetarToShefTransformer.setCfgNOption(mtsr.getConfigFileName(), - mtsr.getMetarToShefOptions()); - break; + HashMap matchList = new HashMap(); + ArrayList reportList = new ArrayList (); + for (PluginDataObject report : reports) { + for (MetarToShefRun mtsr : metarToShefRun) { + PluginDataObject resultRpt = filterARun(report, mtsr.getFilterElements()); + if (resultRpt != null ) { + reportList.add(resultRpt); + matchList.put(resultRpt.getDataURI(), mtsr); + MetarToShefTransformer.setMatchList (matchList); + break; + } } } - - return resultRpt; + return (PluginDataObject[])reportList.toArray(new PluginDataObject[reportList.size()]); } private void createDummyFilter() { diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefTransformer.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefTransformer.java index fa82c881b1..38a1bf2e37 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefTransformer.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/MetarToShefTransformer.java @@ -22,6 +22,7 @@ package com.raytheon.edex.transform.shef; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.HashMap; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -51,6 +52,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * AWIPS2 DR Work * 20120918 1185 jkorman Added save to archive capability. * Jan 30, 2010 15779 lbousaidi added 4 letter to station id for ACR + * Aug 08, 2013 16408 wkwock Use different metar.cfg file and options * * * @author jkorman @@ -81,10 +83,23 @@ public class MetarToShefTransformer extends private static final int P1_MIN = 50; private static final int P2_MAX = 5; - private static String cfgFileName="metar.cfg"; - private static String cmdLnOptions=""; - private static boolean refreshOptions=true; + /* + * Max list for optionsList and matchList to prevent memory leak. + * (500 or any big number should be fine) + */ + private static final int MAX_LIST = 500; + /* + * MetarToShefRun list which has metar.cfg file and options to used by conversion + */ + private static HashMap mtsrList = new HashMap(); + + /* + * List of metar.cfg files + options. + */ + private HashMap optionsList = new HashMap(); + private ObsToSHEFOptions defaultOptions =null; + /** * Construct an instance of this transformer. * @param cmdLine Command line options that may be used if these @@ -92,6 +107,7 @@ public class MetarToShefTransformer extends */ public MetarToShefTransformer(String cmdLine) { super(cmdLine, WMO_HEADER_FMT); + defaultOptions = options; } /** @@ -421,21 +437,38 @@ public class MetarToShefTransformer extends public final byte[] transformMetar(MetarRecord report, Headers headers) throws TransformerException { - if (refreshOptions) { - logger.info("Metar to SHEF now use config file: "+cfgFileName+" with options:"+cmdLnOptions); - options.setCfgFileName(cfgFileName); - options.updateCommandLine(cmdLnOptions); - options.updateOptions(); - refreshOptions=false; + ObsToSHEFOptions tmpOptions=null; + MetarToShefRun mtsr = mtsrList.get(report.getDataURI()); + if (mtsr==null) { + tmpOptions = defaultOptions; + } else { + tmpOptions = optionsList.get(mtsr.getConfigFileName()+mtsr.getMetarToShefOptions()); + if (tmpOptions==null) { + //just to prevent t memory leak + if (optionsList.size()>MAX_LIST) { + optionsList.clear(); + } + tmpOptions = new ObsToSHEFOptions(mtsr.getConfigFileName(),mtsr.getMetarToShefOptions(),true); + optionsList.put(mtsr.getConfigFileName()+mtsr.getMetarToShefOptions(), tmpOptions); + } + mtsrList.remove(report.getDataURI()); } + options=tmpOptions; + logger.info("Metar to SHEF for "+report.getStationId()+" use config file: "+options.getCfgFileName()+" with options:"+mtsr.getMetarToShefOptions()); configureArchiveDir(); return transformReport(report, headers); } - public static void setCfgNOption (String cfg, String options){ - cfgFileName=cfg; - cmdLnOptions=options; - refreshOptions=true; + /* + * set matchList + */ + public static void setMatchList (HashMap matchLst) { + //should add to the list and remove after use. clear if reach certain big number + if (mtsrList.size()>MAX_LIST) { + mtsrList.clear(); + } + + mtsrList.putAll(matchLst); } } \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/obs/ObsToSHEFOptions.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/obs/ObsToSHEFOptions.java index 8adc2b0213..48ffa942d6 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/obs/ObsToSHEFOptions.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/transform/shef/obs/ObsToSHEFOptions.java @@ -57,7 +57,8 @@ import com.raytheon.uf.common.localization.PathManagerFactory; * May 24, 2010 jkorman Initial creation * ====================================== * AWIPS2 DR Work - * 20120918 1185 jkorman Added save to archive capability. + * 20120918 1185 jkorman Added save to archive capability. + * Aug 08, 2013 16408 wkwock Added get configuration file name function * * * @@ -66,9 +67,6 @@ import com.raytheon.uf.common.localization.PathManagerFactory; */ public class ObsToSHEFOptions { - // 1 minute update delta. - private static final long UPDATE_DELTA = 60L * 1000L; - private static final String METAR_CFG = "metar.cfg"; private static final String ERROR_1_FMT = "Could not create {%s} context for file \"%s\""; @@ -399,8 +397,6 @@ public class ObsToSHEFOptions { private final boolean localized; - private long updateTime = 0; - /** * * @param cmdLine @@ -414,7 +410,20 @@ public class ObsToSHEFOptions { } else { readConfig(cfgFileName, optConfigContext); } - updateTime = System.currentTimeMillis(); + } + localized = useLocalized; + } + + /** + * + * @param cmdLine + */ + public ObsToSHEFOptions(String configFileName, String cmdLine, boolean useLocalized) { + cfgFileName = configFileName; + initOptions(); + parseCommandLine(cmdLine); + if (useLocalized) { + readConfig(cfgFileName, optConfigContext); } localized = useLocalized; } @@ -845,15 +854,11 @@ public class ObsToSHEFOptions { * Check if the metar.cfg needs to be reread. */ public void updateOptions() { - long cTime = System.currentTimeMillis() - updateTime; - if (cTime > UPDATE_DELTA) { - if (loaded && localized) { - if (cfgFileName==null) { - readConfig(METAR_CFG, optConfigContext); - } else { - readConfig(cfgFileName, optConfigContext); - } - updateTime = System.currentTimeMillis(); + if (loaded && localized) { + if (cfgFileName==null) { + readConfig(METAR_CFG, optConfigContext); + } else { + readConfig(cfgFileName, optConfigContext); } } } @@ -888,6 +893,8 @@ public class ObsToSHEFOptions { }else{ readConfig(cfgFileName, optConfigContext); } + } else { + logger.warn("Uanble to read file "+cfgFileName); } } } else { @@ -990,6 +997,10 @@ public class ObsToSHEFOptions { cfgFileName=fileName; } + public String getCfgFileName () { + return cfgFileName; + } + public String toString() { StringBuilder sb = new StringBuilder();