From 77e8cd467f30a68b20008f3802d25ea4edb28ab1 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 31 Jul 2013 09:00:07 -0500 Subject: [PATCH 01/16] Issue #2239 fixed scaling of MakeHazard maps when polygons cross the date line Change-Id: Idd3745f141b78c74a39cf99746acb45d5f143b10 Former-commit-id: 390f5b243925ae45b54db39d418c3715e5ea182a [formerly f4feae82505c29bc49113682d2cd584ec3ed6233] Former-commit-id: 47b977cdec376c4fa2600e1f9761f3ac54537a76 --- .../ui/zoneselector/ZoneSelectorResource.java | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java index 108d509d04..a1cfec80d5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/zoneselector/ZoneSelectorResource.java @@ -99,8 +99,9 @@ import com.vividsolutions.jts.io.WKBReader; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 11, 2011 randerso Initial creation - * Apr 10, 2013 #1854 randerso Fix for compatibility with PostGIS 2.0 - * May 30, 2013 #2028 randerso Fixed date line issue with map display + * Apr 10, 2013 #1854 randerso Fix for compatibility with PostGIS 2.0 + * May 30, 2013 #2028 randerso Fixed date line issue with map display + * Jul 31, 2013 #2239 randerso Fixed scaling of maps that cross the date line * * * @@ -271,7 +272,7 @@ public class ZoneSelectorResource extends DbMapResource { numPoints += g.getNumPoints(); resultingGeoms.put(zoneName, g); - if (myWfo != null && myWfo.equals(wfo)) { + if ((myWfo != null) && myWfo.equals(wfo)) { if (existingGeom != null) { wfoPoints -= existingGeom.getNumPoints(); } @@ -636,7 +637,8 @@ public class ZoneSelectorResource extends DbMapResource { info.setColor(color); int index = info.getShapeIndex(); - if (this.target != null && index >= 0 && index < shapeList.length) { + if ((this.target != null) && (index >= 0) + && (index < shapeList.length)) { shapeList[index].dispose(); shapeList[index] = computeShape(this.target, this.descriptor, info.getGeometry(), color); @@ -698,8 +700,8 @@ public class ZoneSelectorResource extends DbMapResource { // + Arrays.toString(c2) + " dpp:" + dppX); double simpLev = getSimpLev(dppX); - if (simpLev < lastSimpLev - || lastExtent == null + if ((simpLev < lastSimpLev) + || (lastExtent == null) || !lastExtent.getEnvelope().contains( clipToProjExtent(screenExtent).getEnvelope())) { if (!paintProps.isZooming()) { @@ -742,27 +744,27 @@ public class ZoneSelectorResource extends DbMapResource { aTarget.drawShadedShapes(paintProps.getAlpha(), 1.0f, shapeList); } - if (outlineShape != null && outlineShape.isDrawable() + if ((outlineShape != null) && outlineShape.isDrawable() && getCapability(OutlineCapability.class).isOutlineOn()) { aTarget.drawWireframeShape(outlineShape, this.outlineColor, getCapability(OutlineCapability.class).getOutlineWidth(), getCapability(OutlineCapability.class).getLineStyle()); - } else if (outlineShape == null + } else if ((outlineShape == null) && getCapability(OutlineCapability.class).isOutlineOn()) { issueRefresh(); } - if (wfoShape != null && wfoShape.isDrawable() + if ((wfoShape != null) && wfoShape.isDrawable() && getCapability(OutlineCapability.class).isOutlineOn()) { aTarget.drawWireframeShape(wfoShape, this.wfoOutlineColor, getCapability(OutlineCapability.class).getOutlineWidth(), getCapability(OutlineCapability.class).getLineStyle()); - } else if (wfoShape == null + } else if ((wfoShape == null) && getCapability(OutlineCapability.class).isOutlineOn()) { issueRefresh(); } - if (labels != null && (this.labelZones || this.labelZoneGroups)) { + if ((labels != null) && (this.labelZones || this.labelZoneGroups)) { if (font == null) { font = GFEFonts.getFont(aTarget, 2); } @@ -792,7 +794,7 @@ public class ZoneSelectorResource extends DbMapResource { + Math.abs(tuple.y - y); minDistance = Math.min(distance, minDistance); } - if (minDistance > 100 * worldToScreenRatio) { + if (minDistance > (100 * worldToScreenRatio)) { String[] text = new String[] { "", "" }; if (this.labelZones) { text[0] = zone; @@ -1048,15 +1050,24 @@ public class ZoneSelectorResource extends DbMapResource { byte[] b = (byte[]) mappedResult.getRowColumnValue(i, "extent"); if (b != null) { - Geometry g = wkbReader.read(b); - Envelope env = g.getEnvelopeInternal(); + Geometry geom = wkbReader.read(b); - ReferencedEnvelope llEnv = new ReferencedEnvelope(env, - MapUtil.LATLON_PROJECTION); - ReferencedEnvelope projEnv = llEnv.transform( - gloc.getCrs(), true); + // world wrap correct the geometry and then + // get the envelope of each geometry in the collection + geom = this.worldWrapCorrector.correct(geom); - this.boundingEnvelope.expandToInclude(projEnv); + for (int n = 0; n < geom.getNumGeometries(); n++) { + Geometry g = geom.getGeometryN(n); + + Envelope env = g.getEnvelopeInternal(); + + ReferencedEnvelope llEnv = new ReferencedEnvelope( + env, MapUtil.LATLON_PROJECTION); + ReferencedEnvelope projEnv = llEnv.transform( + gloc.getCrs(), true); + + this.boundingEnvelope.expandToInclude(projEnv); + } } } @@ -1101,8 +1112,8 @@ public class ZoneSelectorResource extends DbMapResource { latLonToCRS.transform(new double[] { 0, 90 }, 0, output, 0, 1); Coordinate northPole = new Coordinate(output[0], output[1]); - if (northPole.x >= ll.x && northPole.x <= ur.x - && northPole.y >= ll.y && northPole.y <= ur.y) { + if ((northPole.x >= ll.x) && (northPole.x <= ur.x) + && (northPole.y >= ll.y) && (northPole.y <= ur.y)) { pole = northPole; } @@ -1115,8 +1126,8 @@ public class ZoneSelectorResource extends DbMapResource { latLonToCRS.transform(new double[] { 0, -90 }, 0, output, 0, 1); Coordinate southPole = new Coordinate(output[0], output[1]); - if (southPole.x >= ll.x && southPole.x <= ur.x - && southPole.y >= ll.y && southPole.y <= ur.y) { + if ((southPole.x >= ll.x) && (southPole.x <= ur.x) + && (southPole.y >= ll.y) && (southPole.y <= ur.y)) { pole = southPole; } } catch (TransformException e) { @@ -1149,7 +1160,7 @@ public class ZoneSelectorResource extends DbMapResource { List polygons = new ArrayList(4); for (Coordinate[] q : quadrant) { - if (q[1].x > q[0].x && q[1].y > q[0].y) { + if ((q[1].x > q[0].x) && (q[1].y > q[0].y)) { polygons.add(polygonFromGloc(gloc, delta, q[0], q[1])); } } @@ -1186,19 +1197,19 @@ public class ZoneSelectorResource extends DbMapResource { double dx = width / nx; double dy = height / ny; - Coordinate[] coordinates = new Coordinate[2 * (nx + ny) + 1]; + Coordinate[] coordinates = new Coordinate[(2 * (nx + ny)) + 1]; int i = 0; for (int x = 0; x < nx; x++) { - coordinates[i++] = new Coordinate(x * dx + ll.x, ll.y); + coordinates[i++] = new Coordinate((x * dx) + ll.x, ll.y); } for (int y = 0; y < ny; y++) { - coordinates[i++] = new Coordinate(ur.x, y * dy + ll.y); + coordinates[i++] = new Coordinate(ur.x, (y * dy) + ll.y); } for (int x = nx; x > 0; x--) { - coordinates[i++] = new Coordinate(x * dx + ll.x, ur.y); + coordinates[i++] = new Coordinate((x * dx) + ll.x, ur.y); } for (int y = ny; y > 0; y--) { - coordinates[i++] = new Coordinate(ll.x, y * dy + ll.y); + coordinates[i++] = new Coordinate(ll.x, (y * dy) + ll.y); } coordinates[i++] = coordinates[0]; From bbb7f1dd491505f6481bff301bc1e525cc3b2390 Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Thu, 1 Aug 2013 09:20:23 -0400 Subject: [PATCH 02/16] 13.5.1-9 baseline Former-commit-id: 97fe6a670f234d273e96639f4e47483fc4e00c28 [formerly 06a1dd45adedbe259f9c30ebf93f2f90017fe945] Former-commit-id: 6e60cd9a79cf4db9d7086306f1f3b70f4e81f233 --- .../cave/etc/textws/gui/FontSizeCfg.xml | 14 +- .../cave/etc/textws/gui/TextColorsCfg.xml | 16 +- .../cave/etc/textws/gui/TextEditorCfg.xml | 51 ++ .../radar/rsc/graphic/RadarMLResource.java | 268 ++++---- .../viz/texteditor/dialogs/FontSizeCfg.java | 6 +- .../texteditor/dialogs/RGBColorAdapter.java | 2 - .../viz/texteditor/dialogs/SizeButtonCfg.java | 41 +- .../texteditor/dialogs/TextColorElement.java | 43 +- .../viz/texteditor/dialogs/TextColorsCfg.java | 52 +- .../viz/texteditor/dialogs/TextEditorCfg.java | 217 ++++++ .../texteditor/dialogs/TextEditorDialog.java | 289 +++----- .../textworkstation/TextWorkstationDlg.java | 11 +- .../raytheon/viz/warngen/gis/PolygonUtil.java | 222 +++++- .../viz/warngen/gui/WarngenDialog.java | 9 +- .../viz/warngen/gui/WarngenLayer.java | 168 ++--- .../ncep/pgen/outlooksettings.xml | 12 +- ncep/gov.noaa.nws.ncep.ui.pgen/plugin.xml | 8 + .../ncep/ui/pgen/tools/PgenSelectHandler.java | 7 +- .../ncep/resourceTemplates/Lightning.xml | 5 + .../plugin.xml | 10 + .../rsc/lightning/rsc/LightningResource.java | 79 ++- .../rsc/ncgrid/contours/ContourSupport.java | 643 +++++++++++------- .../viz/rsc/ncgrid/dgdriv/TestDgdriv.java | 6 +- .../nws/ncep/viz/tools/contour/CNFNative.java | 29 +- .../ui/display/NCNonMapRenderableDisplay.java | 1 + .../ui/display/ZoomStateSourceProvider.java | 2 +- rpms/awips2.core/Installer.ldm/component.spec | 2 +- .../patch/etc/pqact.conf.template | 2 +- 28 files changed, 1316 insertions(+), 899 deletions(-) create mode 100644 cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml create mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorCfg.java diff --git a/cave/build/static/common/cave/etc/textws/gui/FontSizeCfg.xml b/cave/build/static/common/cave/etc/textws/gui/FontSizeCfg.xml index 7c2cd954fd..4078d3e4df 100644 --- a/cave/build/static/common/cave/etc/textws/gui/FontSizeCfg.xml +++ b/cave/build/static/common/cave/etc/textws/gui/FontSizeCfg.xml @@ -8,11 +8,11 @@ Modify: 06/14/2013 Xiaochuan DR 15733 Initial creation - - --> + 07/25/2013 Greg Hull DR 15733 Deleted. moved to TextEditorCfg.xml + --> - - + \ No newline at end of file diff --git a/cave/build/static/common/cave/etc/textws/gui/TextColorsCfg.xml b/cave/build/static/common/cave/etc/textws/gui/TextColorsCfg.xml index 357ea75282..b682749300 100644 --- a/cave/build/static/common/cave/etc/textws/gui/TextColorsCfg.xml +++ b/cave/build/static/common/cave/etc/textws/gui/TextColorsCfg.xml @@ -10,14 +10,12 @@ Modify: - 06/14/2013 Xiaochuan DR 15733 Initial creation - 07/18/2013 B. Hebbard per G. Hull DR 15733 Update highlightBG & FG - - --> - - + 06/14/2013 Xiaochuan DR 15733 Initial creation + 07/25/2013 Greg Hull DR 15733 Deleted. moved to TextEditorCfg.xml + --> + \ No newline at end of file diff --git a/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml b/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml new file mode 100644 index 0000000000..b0b8035ac6 --- /dev/null +++ b/cave/build/static/common/cave/etc/textws/gui/TextEditorCfg.xml @@ -0,0 +1,51 @@ + + + + + 4 + + 8 + + + BLACK + WHITE + 0, 0, 0 + 85, 152, 215 + + + + + Small + 9 + false + + + Medium + 11 + true + + + Large + 13 + false + + + + + diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java index 295310519b..3b9f33264c 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarMLResource.java @@ -69,14 +69,17 @@ import com.raytheon.viz.radar.rsc.RadarResourceData; import com.vividsolutions.jts.geom.Coordinate; /** - * TODO Add Description + * Displays the melting layer as provided by radar (i.e. displays the levels at + * which snow is turned to a mixture of snow and water and then in turn that is + * changed to water only). * *
  * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Sep 16, 2010            mnash     Initial creation
+ * Sep 16, 2010            mnash       Initial creation
+ * Jul 13, 2103 2223       njensen     Overrode remove() to fix memory leak
  * 
  * 
* @@ -148,133 +151,140 @@ public class RadarMLResource extends RadarGraphicsResource { protected void paintInternal(IGraphicsTarget target, PaintProperties paintProps) throws VizException { GeneralEnvelope generalEnvelope = new GeneralEnvelope(2); - Map shapeMap = shapes.get(paintProps - .getDataTime()); - if (shapeMap == null || refresh == true) { - if (shapeMap != null) { - for (IWireframeShape w : shapeMap.values()) { - if (w != null) { - w.dispose(); - } - } - } - shapeMap = new HashMap(); - shapes.put(paintProps.getDataTime(), shapeMap); - displayedDate = null; + Map shapeMap = null; + synchronized (shapes) { + shapeMap = shapes.get(paintProps.getDataTime()); - IWireframeShape ws = null; - - if ((paintProps == null) || (paintProps.getDataTime() == null)) { - return; - } - - displayedDate = paintProps.getDataTime(); - - displayedLevel = displayedDate.getLevelValue().floatValue(); - - // retrieve record if not yet populated - RadarRecord radarRecord = getRadarRecord(displayedDate); - if (radarRecord == null) { - return; - } - - File loc = HDF5Util.findHDF5Location(radarRecord); - IDataStore dataStore = DataStoreFactory.getDataStore(loc); - try { - RadarDataRetriever.populateRadarRecord(dataStore, radarRecord); - } catch (FileNotFoundException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } catch (StorageException e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); - } - - ProjectedCRS crs = radarRecord.getCRS(); - // Per section 3.3.3 - generalEnvelope.setCoordinateReferenceSystem(crs); - generalEnvelope.setRange(0, -256000 * 2, 256000 * 2); - generalEnvelope.setRange(1, -256000 * 2, 256000 * 2); - - // [-2048, 2048] == range of 4095 (inclusive 0), plus 1 because - // GGR is exclusive (?) - GeneralGridGeometry gg = new GeneralGridGeometry( - new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] { - 4096, 4096 }, false), generalEnvelope); - SymbologyBlock block = radarRecord.getSymbologyBlock(); - ReferencedCoordinate coordinate1; - ReferencedCoordinate coordinate2; - Map coordinates = new HashMap(); - if (block != null) { - for (int i = 0; i < block.getNumLayers(); i++) { - for (int j = 1; j < block.getNumPackets(i); j++) { - if (block.getPacket(i, j) instanceof LinkedContourVectorPacket) { - List vector = ((LinkedContourVectorPacket) block - .getPacket(i, j)).getVectors(); - Coordinate[] coords = new Coordinate[vector.size() + 1]; - for (int l = 0; l < coords.length - 1; l++) { - if (!coordinates.containsKey(vector.get(l) - .getTheColor())) { - coordinates.put(Integer.valueOf(vector.get( - l).getTheColor()), coords); - } - - // transform the coordinates to the correct - // locations - coordinate1 = new ReferencedCoordinate( - rectifyCoordinate(new Coordinate(vector - .get(l).getI1(), vector.get(l) - .getJ1())), gg, - Type.GRID_CENTER); - coordinate2 = new ReferencedCoordinate( - rectifyCoordinate(new Coordinate(vector - .get(l).getI2(), vector.get(l) - .getJ2())), gg, - Type.GRID_CENTER); - try { - // coords[l] = coordinate1.asLatLon(); - coords[l] = coordinate2.asLatLon(); - } catch (TransformException e1) { - statusHandler.handle(Priority.PROBLEM, - e1.getLocalizedMessage(), e1); - - } catch (FactoryException e1) { - statusHandler.handle(Priority.PROBLEM, - e1.getLocalizedMessage(), e1); - - } - } - coords[coords.length - 1] = coords[0]; + if (shapeMap == null || refresh == true) { + if (shapeMap != null) { + for (IWireframeShape w : shapeMap.values()) { + if (w != null) { + w.dispose(); } } } - refresh = false; + shapeMap = new HashMap(); + shapes.put(paintProps.getDataTime(), shapeMap); + displayedDate = null; + + IWireframeShape ws = null; + + if ((paintProps == null) || (paintProps.getDataTime() == null)) { + return; + } + + displayedDate = paintProps.getDataTime(); + + displayedLevel = displayedDate.getLevelValue().floatValue(); + + // retrieve record if not yet populated + RadarRecord radarRecord = getRadarRecord(displayedDate); + if (radarRecord == null) { + return; + } + + File loc = HDF5Util.findHDF5Location(radarRecord); + IDataStore dataStore = DataStoreFactory.getDataStore(loc); + try { + RadarDataRetriever.populateRadarRecord(dataStore, + radarRecord); + } catch (FileNotFoundException e) { + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } catch (StorageException e) { + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } + + ProjectedCRS crs = radarRecord.getCRS(); + // Per section 3.3.3 + generalEnvelope.setCoordinateReferenceSystem(crs); + generalEnvelope.setRange(0, -256000 * 2, 256000 * 2); + generalEnvelope.setRange(1, -256000 * 2, 256000 * 2); + + // [-2048, 2048] == range of 4095 (inclusive 0), plus 1 because + // GGR is exclusive (?) + GeneralGridGeometry gg = new GeneralGridGeometry( + new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] { + 4096, 4096 }, false), generalEnvelope); + SymbologyBlock block = radarRecord.getSymbologyBlock(); + ReferencedCoordinate coordinate1; + ReferencedCoordinate coordinate2; + Map coordinates = new HashMap(); + if (block != null) { + for (int i = 0; i < block.getNumLayers(); i++) { + for (int j = 1; j < block.getNumPackets(i); j++) { + if (block.getPacket(i, j) instanceof LinkedContourVectorPacket) { + List vector = ((LinkedContourVectorPacket) block + .getPacket(i, j)).getVectors(); + Coordinate[] coords = new Coordinate[vector + .size() + 1]; + for (int l = 0; l < coords.length - 1; l++) { + if (!coordinates.containsKey(vector.get(l) + .getTheColor())) { + coordinates.put(Integer.valueOf(vector + .get(l).getTheColor()), coords); + } + + // transform the coordinates to the correct + // locations + coordinate1 = new ReferencedCoordinate( + rectifyCoordinate(new Coordinate( + vector.get(l).getI1(), + vector.get(l).getJ1())), + gg, Type.GRID_CENTER); + coordinate2 = new ReferencedCoordinate( + rectifyCoordinate(new Coordinate( + vector.get(l).getI2(), + vector.get(l).getJ2())), + gg, Type.GRID_CENTER); + try { + // coords[l] = coordinate1.asLatLon(); + coords[l] = coordinate2.asLatLon(); + } catch (TransformException e1) { + statusHandler.handle(Priority.PROBLEM, + e1.getLocalizedMessage(), e1); + + } catch (FactoryException e1) { + statusHandler.handle(Priority.PROBLEM, + e1.getLocalizedMessage(), e1); + + } + } + coords[coords.length - 1] = coords[0]; + } + } + } + refresh = false; + } + + // looping through the coordinates in order to create a + // wireframe + // shape + for (Integer num : coordinates.keySet()) { + if (shapeMap.get(num) == null) { + ws = target.createWireframeShape(true, this.descriptor); + } else { + ws = shapeMap.get(num); + } + ws.addLineSegment(coordinates.get(num)); + shapeMap.put(num, ws); + } } - // looping through the coordinates in order to create a wireframe - // shape - for (Integer num : coordinates.keySet()) { - if (shapeMap.get(num) == null) { - ws = target.createWireframeShape(true, this.descriptor); - } else { - ws = shapeMap.get(num); + if (shapeMap != null) { + for (Integer num : shapeMap.keySet()) { + LineStyle lineStyle = style.get(num); + if (getCapability(OutlineCapability.class).getLineStyle() != LineStyle.DEFAULT) { + lineStyle = getCapability(OutlineCapability.class) + .getLineStyle(); + } + target.drawWireframeShape( + shapeMap.get(num), + getCapability(ColorableCapability.class).getColor(), + getCapability(OutlineCapability.class) + .getOutlineWidth(), lineStyle); } - ws.addLineSegment(coordinates.get(num)); - shapeMap.put(num, ws); - } - } - - if (shapeMap != null) { - for (Integer num : shapeMap.keySet()) { - LineStyle lineStyle = style.get(num); - if (getCapability(OutlineCapability.class).getLineStyle() != LineStyle.DEFAULT) { - lineStyle = getCapability(OutlineCapability.class) - .getLineStyle(); - } - target.drawWireframeShape(shapeMap.get(num), - getCapability(ColorableCapability.class).getColor(), - getCapability(OutlineCapability.class) - .getOutlineWidth(), lineStyle); } } @@ -379,4 +389,18 @@ public class RadarMLResource extends RadarGraphicsResource { c.y = 4096 - c.y; return c; } + + @Override + public void remove(DataTime dataTime) { + synchronized (shapes) { + Map shapeMap = shapes.remove(dataTime); + if (shapeMap != null) { + for (IWireframeShape shp : shapeMap.values()) { + shp.dispose(); + } + shapeMap.clear(); + } + } + super.remove(dataTime); + } } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/FontSizeCfg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/FontSizeCfg.java index b106539fa9..498d08d6e9 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/FontSizeCfg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/FontSizeCfg.java @@ -19,6 +19,7 @@ **/ package com.raytheon.viz.texteditor.dialogs; +import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -38,7 +39,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 07, 2013 DR 15733 Xiaochuan Initial creation + * Jun 07, 2013 DR 15733 Xiaochuan Initial creation + * Jul 25, 2013 DR 15733 Greg Hull Now part of TextEditorCfg ; don't return null array * * * @@ -52,7 +54,7 @@ public class FontSizeCfg implements ISerializableObject { private List buttons; public List getButtons() { - return buttons; + return ( buttons != null ? buttons : new ArrayList() ); } public void setButtons(List buttons) { diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RGBColorAdapter.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RGBColorAdapter.java index d394e603ca..c325a75743 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RGBColorAdapter.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RGBColorAdapter.java @@ -57,8 +57,6 @@ public class RGBColorAdapter extends XmlAdapter { int sz = colorString.split(",").length; if( colorString.split(",").length == 1) { - System.out.println(" Convert string color " - + colorString + ",,,"); rgb = RGBColors.getRGBColor(colorString); } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SizeButtonCfg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SizeButtonCfg.java index 3dd073a91c..89c0ddf45f 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SizeButtonCfg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/SizeButtonCfg.java @@ -16,6 +16,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 07, 2013 DR 15733 Xiaochuan Initial creation + * July 25, 2013 DR 15733 G. Hull now part of TextEditorCfg ; rm sizeEnabled * * * @@ -25,17 +26,20 @@ import com.raytheon.uf.common.serialization.ISerializableObject; @XmlAccessorType(XmlAccessType.NONE) public class SizeButtonCfg implements ISerializableObject { + + private final int DEFAULT_FONT_SIZE = 11; + @XmlElement(name = "LabelName") - private String labelName; + private String labelName="Medium"; - @XmlElement(name = "SizeEnabled") - private boolean sizeEnabled; - - @XmlElement(name = "FontSize") - private int fontSize; + @XmlElement(name = "FontName") + private String fontName = "Courier"; + + @XmlElement(name = "FontSize") + private int fontSize= DEFAULT_FONT_SIZE; @XmlElement(name = "Selected") - private boolean selected; + private boolean selected=true; public String getLabelName() { return labelName; @@ -45,20 +49,15 @@ public class SizeButtonCfg implements ISerializableObject { this.labelName = labelName; } - public boolean isSizeEnabled() { - return sizeEnabled; - } - - public void setSizeEnabled(boolean sizeEnabled) { - this.sizeEnabled = sizeEnabled; - } - public int getFontSize() { - return fontSize; + if( fontSize < 5 || fontSize > 40 ) { // sanity check + return DEFAULT_FONT_SIZE; + } + return fontSize; } public void setFontSize(int fontSize) { - this.fontSize = fontSize; + this.fontSize = fontSize; } public boolean isSelected() { @@ -68,4 +67,12 @@ public class SizeButtonCfg implements ISerializableObject { public void setSelected(boolean selected) { this.selected = selected; } + + public String getFontName() { + return fontName; + } + + public void setFontName(String fontName) { + this.fontName = fontName; + } } \ No newline at end of file diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorElement.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorElement.java index 3bb95d7a35..5fb2947daf 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorElement.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorElement.java @@ -1,18 +1,7 @@ package com.raytheon.viz.texteditor.dialogs; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.raytheon.uf.common.serialization.ISerializableObject; - -import org.eclipse.swt.graphics.RGB; - /** - * TODO Add Description + * OBSOLETE - Class removed * *
  * 
@@ -21,6 +10,7 @@ import org.eclipse.swt.graphics.RGB;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 24, 2013  DR 15733   Xiaochuan     Initial creation
+ * Jul 29, 2013  DR 15733   B. Hebbard    Mark class deleted (per G. Hull)
  * 
  * 
* @@ -28,31 +18,6 @@ import org.eclipse.swt.graphics.RGB; * @version 1.0 */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "TextColorElement") -public class TextColorElement implements ISerializableObject { - - @XmlAttribute - @XmlJavaTypeAdapter(RGBColorAdapter.class) - private RGB color; - - @XmlAttribute - private String paramName; - - public RGB getColor() { - return color; - } - - public void setColor(RGB color) { - this.color = color; - } - - public String getParamName() { - return paramName; - } - - public void setParamName(String paramName) { - this.paramName = paramName; - } - +public class TextColorElement { + // OBSOLETE - Class removed as part of refactor by G. Hull for DR 15733 } \ No newline at end of file diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorsCfg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorsCfg.java index 17af89845c..382cf0ffa0 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorsCfg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextColorsCfg.java @@ -1,36 +1,7 @@ -/** - * 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.List; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; - -import com.raytheon.uf.common.serialization.ISerializableObject; - /** - * TODO Add Description + * OBSOLETE - Class removed * *
  * 
@@ -39,28 +10,13 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 15, 2013  DR 15733   Xiaochuan     Initial creation
+ * Jul 29, 2013  DR 15733   B. Hebbard    Mark class deleted (per G. Hull)
  * 
  * 
* * @author XHuang * @version 1.0 */ -@XmlRootElement(name = "textColorsCfg") -@XmlAccessorType(XmlAccessType.NONE) -public class TextColorsCfg implements ISerializableObject { - @XmlElements({ @XmlElement(name = "TextColorElement", type = TextColorElement.class) }) - private List colorElements; - - public List getTextColorElements() { - return colorElements; - } - - public void setTextColorElements(List colorElements) { - this.colorElements = colorElements; - } - - - - - +public class TextColorsCfg { + // OBSOLETE - Class removed as part of refactor by G. Hull for DR 15733 } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorCfg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorCfg.java new file mode 100644 index 0000000000..0d2157ebbc --- /dev/null +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorCfg.java @@ -0,0 +1,217 @@ +/** + * 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.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXB; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import org.eclipse.swt.graphics.RGB; + +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.ISerializableObject; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 15, 2013  DR 15733   Xiaochuan     Initial creation
+ * Jul 25, 2013  DR 15733   Greg Hull     Combined FontSizeCfg, elements from TextColorsCfg 
+ * 										  and added defaultNumEditors and  maxNumEditors
+ * 
+ * 
+ * + * @author XHuang + * @version 1.0 + */ +@XmlRootElement(name = "textEditorCfg") +@XmlAccessorType(XmlAccessType.NONE) +public class TextEditorCfg implements ISerializableObject { + + @XmlElement + private Integer defaultNumEditors=4; + + @XmlElement + private Integer maxNumEditors=8; + + @XmlElement + private FontSizeCfg fontSizeCfg=new FontSizeCfg(); + + private static SizeButtonCfg selectedFontButton = null; + + @XmlElement + @XmlJavaTypeAdapter(RGBColorAdapter.class) + private RGB textForegroundColor = new RGB( 0, 0, 0 ); + + @XmlElement + @XmlJavaTypeAdapter(RGBColorAdapter.class) + private RGB textBackgroundColor = new RGB( 255, 255, 255 ); + + @XmlElement + @XmlJavaTypeAdapter(RGBColorAdapter.class) + private RGB highlightTextForegroundColor = new RGB( 0, 0, 0 ); + + @XmlElement + @XmlJavaTypeAdapter(RGBColorAdapter.class) + private RGB highlightTextBackgroundColor = new RGB( 85, 152, 215 ); + + public Integer getDefaultNumEditors() { + return defaultNumEditors; + } + + public void setDefaultNumEditors(Integer defaultNumEditors) { + if( defaultNumEditors > 0 && defaultNumEditors < 100 ) { // sanity check + this.defaultNumEditors = defaultNumEditors; + } + } + + public Integer getMaxNumEditors() { + return maxNumEditors; + } + + public void setMaxNumEditors(Integer maxNumEditors) { + if( maxNumEditors > 0 && maxNumEditors < 200 ) { // sanity check + this.maxNumEditors = maxNumEditors; + } + } + + public FontSizeCfg getFontSizeCfg() { + return fontSizeCfg; + } + + public void setFontSizeCfg(FontSizeCfg fontSizeCfg) { + this.fontSizeCfg = fontSizeCfg; + } + + public static SizeButtonCfg getSelectedFontButton() { + return selectedFontButton; + } + + public RGB getTextForegroundColor() { + return textForegroundColor; + } + + public void setTextForegroundColor(RGB textForegroundColor) { + this.textForegroundColor = textForegroundColor; + } + + public RGB getTextBackgroundColor() { + return textBackgroundColor; + } + + public void setTextBackgroundColor(RGB textBackgroundColor) { + this.textBackgroundColor = textBackgroundColor; + } + + public RGB getHighlightTextForegroundColor() { + return highlightTextForegroundColor; + } + + public void setHighlightTextForegroundColor(RGB highlightTextForegroundColor) { + this.highlightTextForegroundColor = highlightTextForegroundColor; + } + + public RGB getHighlightTextBackgroundColor() { + return highlightTextBackgroundColor; + } + + public void setHighlightTextBackgroundColor(RGB highlightTextBackgroundColor) { + this.highlightTextBackgroundColor = highlightTextBackgroundColor; + } + + private static TextEditorCfg textEditorCfg = null; + + public static TextEditorCfg getTextEditorCfg() { + + if( textEditorCfg == null ) { + try { + IPathManager pm = PathManagerFactory.getPathManager(); + File path = pm.getStaticFile("textws/gui/TextEditorCfg.xml"); + if( path == null ) { + throw new Exception("localization file textws/gui/TextEditorCfg.xml not found"); + } + + textEditorCfg = JAXB.unmarshal(path, TextEditorCfg.class); + } + catch (Exception ex) { + IUFStatusHandler statusHandler = UFStatus + .getHandler(TextEditorDialog.class); + statusHandler.handle(Priority.ERROR, "Error with TextEditorCfg.xml file. Using defaults: ", ex); + textEditorCfg = new TextEditorCfg(); + } + + FontSizeCfg fontSizeCfg = textEditorCfg.getFontSizeCfg(); + + if( fontSizeCfg == null ) { + // set meaningful dflt values + FontSizeCfg fscfg = new FontSizeCfg(); + fscfg.setButtons( new ArrayList() ); + textEditorCfg.setFontSizeCfg( fscfg ); + } + + // do some sanity checking + if( fontSizeCfg.getButtons() == null || + fontSizeCfg.getButtons().isEmpty() ) { + // default to 1 medium button + selectedFontButton = new SizeButtonCfg(); + fontSizeCfg.setButtons( new ArrayList() ); + fontSizeCfg.getButtons().add( selectedFontButton ); + } + else { + for( SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) { + if( buttonCfg.isSelected() ) { + if( selectedFontButton == null ) { + selectedFontButton = buttonCfg; + } + else { + buttonCfg.setSelected( false ); + System.out.println("Sanity check in textEditorCfg.xml file:" + + " only 1 font button can be selected" ); + } + } + } + if( selectedFontButton == null ) { + System.out.println("Sanity check in textEditorCfg.xml file:" + + " no font button set asselected. Defaulting to the first" ); + selectedFontButton = fontSizeCfg.getButtons().get(0); + } + } + } + return textEditorCfg; + } +} 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 4877425341..bd5d96466a 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,7 +144,6 @@ 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; @@ -323,11 +322,11 @@ 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 - * set the highlight colors. + * 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 + * set the highlight colors. + * 25July2013 15733 GHull Read font and color prefs from TextEditorCfg. * * * @@ -378,9 +377,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, private final int HIGHLIGHT_BG = SWT.COLOR_RED; -// Color red = shell.getDisplay().getSystemColor(SWT.COLOR_RED); -// Color black = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK); - /** * The length of BEGIN_ELEMENT_TAG. */ @@ -1023,11 +1019,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, */ private Font dftFont; - /** - * default funt size. - */ - private final int DEFAULT_FUNT_SIZE = 11; - /** * Composite containing the editor buttons. */ @@ -1389,8 +1380,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, private Color highlightBackground; // protected Color color; - - /** * Constructor with additional cave style rules * @@ -1545,7 +1534,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } commandHistory = new CommandHistory(); - + // Create the menus createMenus(); @@ -2960,18 +2949,20 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, * The font size sub menu. */ private void createFontSizeSubMenu(Menu fontSizeSubMenu) { - int selectFontSize = DEFAULT_FUNT_SIZE; - FontSizeCfg fontSizeCfg = getFontSizeCfg(); + FontSizeCfg fontSizeCfg = TextEditorCfg.getTextEditorCfg().getFontSizeCfg(); + SizeButtonCfg seldFontBtn = TextEditorCfg.getTextEditorCfg().getSelectedFontButton(); + for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) { MenuItem item = new MenuItem(fontSizeSubMenu, SWT.RADIO); item.setText(buttonCfg.getLabelName()); - item.setSelection(buttonCfg.isSelected()); + item.setSelection( false ); item.setData(buttonCfg); - if (buttonCfg.isSizeEnabled() && buttonCfg.isSelected()) { - selectFontSize = buttonCfg.getFontSize(); + + // if this button is the initial selection. + if( seldFontBtn.getLabelName().equals( buttonCfg.getLabelName() ) ) { item.setSelection(true); - setDefaultFont(selectFontSize); + setDefaultFont( seldFontBtn.getFontSize(), seldFontBtn.getFontName() ); } item.addSelectionListener(new SelectionAdapter() { @@ -2980,7 +2971,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, MenuItem item = (MenuItem) event.getSource(); if (item.getSelection()) { int selectFontSize = ( (SizeButtonCfg) item.getData()).getFontSize(); - setDefaultFont(selectFontSize); + String seldFontName = ((SizeButtonCfg) item.getData()).getFontName(); + + setDefaultFont( selectFontSize, seldFontName ); textEditor.setFont(dftFont); headerTF.setFont(dftFont); @@ -2991,80 +2984,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } - private FontSizeCfg getFontSizeCfg() { - FontSizeCfg fontSizeCfg = null; - - try { - IPathManager pm = PathManagerFactory.getPathManager(); - File path = pm.getStaticFile("textws/gui/FontSizeCfg.xml"); - fontSizeCfg = JAXB.unmarshal(path, FontSizeCfg.class); - - } catch (Exception e) { - IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - statusHandler.handle(Priority.ERROR, - "Unable to parse Autowrap menu configuration.", e); - fontSizeCfg = new FontSizeCfg(); - - } - - // Perform Sanity Checks on configuration. - StringBuilder message = new StringBuilder(); - - // Check buttonCfg values. - int selectionCnt = 0; - String selectionLabel = null; - if (fontSizeCfg.getButtons() != null) { - for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) { - if (buttonCfg.isSelected()) { - ++selectionCnt; - if (selectionCnt == 1) { - selectionLabel = buttonCfg.getLabelName(); - } else { - buttonCfg.setSelected(false); - } - } - - if (buttonCfg.isSizeEnabled()) { - int fntSize = buttonCfg.getFontSize(); - if (fntSize <= 0) { - message.append("Item \"") - .append(buttonCfg.getLabelName()) - .append("\" bad fntSize value (") - .append(buttonCfg.getFontSize()) - .append(") changing to ") - .append(DEFAULT_FUNT_SIZE).append("\n"); - buttonCfg.setFontSize(DEFAULT_FUNT_SIZE); - } - } - } - - if (selectionCnt == 0 && fontSizeCfg.getButtons().size() > 0) { - SizeButtonCfg buttonCfg = fontSizeCfg.getButtons().get(0); - message.append("No button selected. Selecting top item \"") - .append(buttonCfg.getLabelName()).append("\"\n"); - buttonCfg.setSelected(true); - } else if (selectionCnt > 1) { - message.append(selectionCnt) - .append(" items selected; will select item \"") - .append(selectionLabel).append("\"\n"); - } - - if (message.length() > 0) { - message.insert(0, "FontSize problem(s): "); - IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - statusHandler.handle(Priority.PROBLEM, message.toString()); - } - } - - return fontSizeCfg; - - } - - public void setDefaultFont(int fontSize) { - dftFont = new Font(getDisplay(), "Courier", fontSize, SWT.NORMAL); - + public void setDefaultFont( int fontSize, String fontName ) { + dftFont = new Font( getDisplay(), fontName, fontSize, SWT.NORMAL); } /** @@ -3805,7 +3726,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); textEditorComp = new Composite(shell, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); - TextColorsCfg textColorCfg = null; +// TextColorsCfg textColorCfg = null; textEditorComp.setLayout(gridLayout); textEditorComp.setLayoutData(gd); @@ -3825,10 +3746,10 @@ 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(textColorCfg); +// textColorCfg = getTextColorCfg(); + setDefaultTextColor( TextEditorCfg.getTextEditorCfg() ); textEditor.setForeground(textForeground); textEditor.setBackground(textBackground); @@ -4029,83 +3950,41 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, }); } - private TextColorsCfg getTextColorCfg() { - TextColorsCfg textColorsCfg = null; - - try { - IPathManager pm = PathManagerFactory.getPathManager(); - File path = pm.getStaticFile("textws/gui/TextColorsCfg.xml"); - textColorsCfg = JAXB.unmarshal(path, TextColorsCfg.class); - - } catch (Exception e) { - IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - statusHandler.handle(Priority.ERROR, - "Unable to parse TextColors configuration.", e); - textColorsCfg = new TextColorsCfg(); - - } - - // Perform Sanity Checks on configuration. - StringBuilder message = new StringBuilder(); - - for (TextColorElement textElm : textColorsCfg.getTextColorElements()) { - String prmtName = textElm.getParamName(); - if (prmtName == null) { - message.append("Item \"paramName\" problem!\n"); - - } - - if( textElm.getColor() == null ) { - message.append("Item \"color\" data enter problem!\n"); - } - - if (message.length() > 0) { - message.insert(0, "TextColorsCfg broblem(s): "); - IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - statusHandler.handle(Priority.PROBLEM, message.toString()); - } - - } - - return textColorsCfg; - - } +// private TextColorsCfg getTextColorCfg() { +// TextColorsCfg textColorsCfg = TextEditorCfg.getTextEditorCfg().getTextColorsCfg(); +// +// // Perform Sanity Checks on configuration. +// StringBuilder message = new StringBuilder(); +// +// for (TextColorElement textElm : textColorsCfg.getTextColorElements()) { +// String prmtName = textElm.getParamName(); +// if (prmtName == null) { +// message.append("Item \"paramName\" problem!\n"); +// +// } +// +// if( textElm.getColor() == null ) { +// message.append("Item \"color\" data enter problem!\n"); +// } +// +// if (message.length() > 0) { +// message.insert(0, "TextColorsCfg broblem(s): "); +// IUFStatusHandler statusHandler = UFStatus +// .getHandler(TextEditorDialog.class); +// statusHandler.handle(Priority.PROBLEM, message.toString()); +// } +// +// } +// +// return textColorsCfg; +// } - private void setDefaultTextColor(TextColorsCfg clrCfg) { - - for (TextColorElement textElm : clrCfg.getTextColorElements()) { - - String paramName = textElm.getParamName().trim(); - if( paramName.equalsIgnoreCase("textBG")) { - if ( textElm.getColor() != null) - textBackground = new Color(shell.getDisplay(), textElm.getColor()); - else - textBackground = shell.getDisplay().getSystemColor(UPDATE_BG); - - } - else if( paramName.equalsIgnoreCase("textFG")) { - if ( textElm.getColor() != null) - textForeground = new Color(shell.getDisplay(), textElm.getColor()); - else - textForeground = shell.getDisplay().getSystemColor(UPDATE_FG); - } - else if( paramName.equalsIgnoreCase("highlightBG")) { - if ( textElm.getColor() != null) - highlightBackground = new Color(shell.getDisplay(), textElm.getColor()); - else - highlightBackground = shell.getDisplay().getSystemColor(HIGHLIGHT_BG); - } - else if( paramName.equalsIgnoreCase("highlightFG")) { - if ( textElm.getColor() != null) - highlightForeground = new Color(shell.getDisplay(), textElm.getColor()); - else - highlightForeground = shell.getDisplay().getSystemColor(UPDATE_FG); - } - - } - + private void setDefaultTextColor(TextEditorCfg txtClrCfg ) { + + textBackground = new Color( shell.getDisplay(), txtClrCfg.getTextBackgroundColor() ); + textForeground = new Color(shell.getDisplay(), txtClrCfg.getTextForegroundColor() ); + highlightBackground = new Color(shell.getDisplay(), txtClrCfg.getHighlightTextBackgroundColor() ); + highlightForeground = new Color(shell.getDisplay(), txtClrCfg.getHighlightTextForegroundColor() ); } /** @@ -5123,7 +5002,6 @@ 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(); @@ -5712,25 +5590,27 @@ 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 @@ -5738,8 +5618,7 @@ 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); @@ -5749,16 +5628,14 @@ 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 { @@ -5798,8 +5675,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' @@ -6104,7 +5981,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); } @@ -7197,7 +7074,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/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java index 4defe68bb7..8b818e5bdd 100644 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java +++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java @@ -51,6 +51,7 @@ import com.raytheon.viz.texteditor.TextWorkstationConstants; import com.raytheon.viz.texteditor.alarmalert.dialogs.CurrentAlarmQueue; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertNotificationObserver; +import com.raytheon.viz.texteditor.dialogs.TextEditorCfg; import com.raytheon.viz.texteditor.dialogs.TextEditorDialog; import com.raytheon.viz.texteditor.msgs.ITextEditorCallback; import com.raytheon.viz.texteditor.msgs.ITextWorkstationCallback; @@ -92,6 +93,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 13Dec2012 1353 rferrel Fix bug introduced in the Show all dialogs. * 30Jan2013 DR 14736 D. Friedman Display local time. * 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button). + * 25July2013 DR 15733 Greg Hull Make dflt and max number of Text Buttons configurable. * * * @@ -100,9 +102,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; public class TextWorkstationDlg extends CaveSWTDialog implements ITextEditorCallback, INotificationObserver { - private final int INIT_BUTTON_CNT = 4; + private int INIT_BUTTON_CNT = 4; - private final int MAX_BUTTON_CNT = 8; + private int MAX_BUTTON_CNT = 8; private String productToDisplay = null; @@ -203,6 +205,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements fontAwipsLabel = new Font(shell.getDisplay(), "Helvetica", 24, SWT.ITALIC); + INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getDefaultNumEditors(); + MAX_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getMaxNumEditors(); + // Initialize all of the controls and layouts initializeComponents(); } @@ -437,7 +442,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements textBtnArray = new ArrayList