Issue #875 Now does faster refresh and properly handle nofification of other CAVEs of changes.

Amend: Changes from code review

Change-Id: I556174de78c98730cabcd194b657db55328cf551

Former-commit-id: be8e334da3 [formerly ae352e695a198b4f675249d1ef22118305d2f682]
Former-commit-id: 6df929a87d
This commit is contained in:
Roger Ferrel 2012-09-12 08:59:43 -05:00
parent fa7c31206b
commit 5b320fe49d
6 changed files with 751 additions and 575 deletions

View file

@ -0,0 +1,91 @@
/**
* 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.uf.viz.points;
import com.raytheon.uf.viz.points.data.GroupNode;
import com.raytheon.uf.viz.points.data.IPointNode;
import com.raytheon.uf.viz.points.data.Point;
/**
* This class is used to queue actions to perform on a Point's localization
* file.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 23, 2012 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class PointRequest {
public static enum RequestType {
ADD, UPDATE, DELETE
};
private final RequestType type;
private final IPointNode point;
/**
* The constructor.
*
* @param type
* - Kind of request to perform
* @param point
* - The point to pefrom the request on.
*/
public PointRequest(RequestType type, IPointNode point) {
this.type = type;
// Duplicate the point to capture information as it exists at the time
// of the request.
if (point.isGroup()) {
this.point = new GroupNode((Point) point);
} else {
this.point = new Point((Point) point);
}
}
public IPointNode getPoint() {
return point;
}
public RequestType getType() {
return type;
}
public String toString() {
StringBuilder sb = new StringBuilder("PointUpdatedMessage - ");
sb.append("type: ").append(type).append(", point: ");
if (point == null) {
sb.append("null\n");
} else {
sb.append("\"").append(point.getName()).append("\", \"")
.append(point.getGroup()).append("\"\n");
}
return sb.toString();
}
}

View file

@ -58,6 +58,10 @@ import com.vividsolutions.jts.geom.Coordinate;
@XmlRootElement(name = "point")
@DynamicSerialize
public class Point implements IPointNode, Comparable<IPointNode> {
/**
* This is used to compare the double values of latitude and longitude.
*/
private static final double DELTA = 0.000001;
@XmlElement(name = "name")
@DynamicSerializeElement
@ -105,7 +109,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
}
/**
* Copy contructor.
* Copy constructor.
*
* @param point
*/
@ -135,7 +139,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
*/
public Point(String pointName, Coordinate p, boolean colorActive, RGB c,
boolean hidden, boolean Movable, PointSize ms, String group) {
this.name = PointUtilities.trimAll(pointName);
setName(pointName);
this.longitude = p.x;
this.latitude = p.y;
this.colorActive = colorActive;
@ -145,7 +149,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
this.hidden = hidden;
this.movable = Movable;
this.fontSize = ms;
this.group = group;
setGroup(group);
}
/**
@ -162,7 +166,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
*/
public Point(String pointName, double lat, double lon, boolean hidden,
boolean movable, boolean colorActive, RGB c, String group) {
this.name = PointUtilities.trimAll(pointName);
setName(pointName);
this.fontSize = PointSize.DEFAULT;
this.colorActive = colorActive;
this.red = c.red;
@ -172,7 +176,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
this.hidden = hidden;
this.longitude = lon;
this.latitude = lat;
this.group = group.replace(' ', PointUtilities.DELIM_CHAR);
setGroup(group);
}
/**
@ -189,7 +193,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
*/
public Point(String pointName, double lat, double lon, boolean movable,
boolean colorActive, RGB c, PointSize size, String group) {
this.name = PointUtilities.trimAll(pointName);
setName(pointName);
this.fontSize = size;
this.colorActive = colorActive;
this.red = c.red;
@ -199,7 +203,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
this.hidden = false;
this.longitude = lon;
this.latitude = lat;
this.group = group.replace(' ', PointUtilities.DELIM_CHAR);
setGroup(group);
}
/**
@ -259,7 +263,7 @@ public class Point implements IPointNode, Comparable<IPointNode> {
* @param pointName
*/
public void setName(String pointName) {
name = pointName;
name = PointUtilities.trimAll(pointName);
}
/**
@ -364,7 +368,8 @@ public class Point implements IPointNode, Comparable<IPointNode> {
* @param group
*/
public void setGroup(String group) {
this.group = group;
this.group = PointUtilities.trimAll(group).replace(
PointUtilities.DELIM_CHAR, ' ');
}
/*
@ -455,4 +460,38 @@ public class Point implements IPointNode, Comparable<IPointNode> {
}
return getName().compareToIgnoreCase(o.getName());
}
/**
* Determine if any of the contains of point is different.
*
* @param point
* @return state true when contains differ otherwise false
*/
public boolean differentContent(Point point) {
boolean state = false;
if (!name.equals(point.name)) {
state = true;
} else if (Math.abs(latitude - point.latitude) > DELTA) {
state = true;
} else if (Math.abs(longitude - point.longitude) > DELTA) {
state = true;
} else if (colorActive != point.colorActive) {
state = true;
} else if (red != point.red) {
state = true;
} else if (green != point.green) {
state = true;
} else if (blue != point.blue) {
state = true;
} else if (hidden != point.hidden) {
state = true;
} else if (movable != point.movable) {
state = true;
} else if (fontSize != point.fontSize) {
state = true;
} else if (!group.equals(point.group)) {
state = true;
}
return state;
}
}

View file

@ -60,13 +60,13 @@ public class PointTreeContentProvider implements ITreeContentProvider {
@Override
public Object[] getElements(Object inputElement) {
IPointNode node = (IPointNode) inputElement;
return manager.getChildren(node).toArray(new IPointNode[0]);
return manager.getChildren(node, true).toArray(new IPointNode[0]);
}
@Override
public Object[] getChildren(Object parentElement) {
IPointNode node = (IPointNode) parentElement;
List<IPointNode> children = manager.getChildren(node);
List<IPointNode> children = manager.getChildren(node, true);
return children.toArray(new IPointNode[0]);
}
@ -79,6 +79,6 @@ public class PointTreeContentProvider implements ITreeContentProvider {
@Override
public boolean hasChildren(Object element) {
IPointNode node = (IPointNode) element;
return node.isGroup() && manager.getChildren(node).size() > 0;
return node.isGroup() && manager.getChildren(node, true).size() > 0;
}
}

View file

@ -119,7 +119,7 @@ public class PointTreeDropListener extends ViewerDropAdapter {
* @return true if child group node exists.
*/
private boolean childGroupExists(IPointNode parent, String name) {
for (IPointNode child : manager.getChildren(parent)) {
for (IPointNode child : manager.getChildren(parent, true)) {
if (child.isGroup() && name.equals(child.getName())) {
return true;
}

View file

@ -574,7 +574,7 @@ public class PointsMgrDialog extends CaveJFACEDialog implements
}
private boolean groupExists(IPointNode parent, String name) {
for (IPointNode child : dataManager.getChildren(parent)) {
for (IPointNode child : dataManager.getChildren(parent, true)) {
if (child.isGroup() && name.equals(child.getName())) {
return true;
}