Merge "Omaha #1798 fixed collaboration drawing issues when leader shares new map" into omaha_14.4.1

Former-commit-id: c0d36e9a69 [formerly c0d36e9a69 [formerly 3d0df846090261417f9c9b2e75cf6c439f9b979f]]
Former-commit-id: 1183c0538e
Former-commit-id: cb9e715aec
This commit is contained in:
Nate Jensen 2014-07-01 10:30:54 -05:00 committed by Gerrit Code Review
commit 10dee29029
4 changed files with 106 additions and 20 deletions

View file

@ -69,6 +69,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Mar 18, 2014 2895 njensen Fix concurrent mod exception on dispose
* May 05, 2014 3076 bclement old CLEAR_ALL is now DISPOSE_ALL,
* added clearLayers() and getAllDrawingLayers()
* Jun 30, 2014 1798 bclement added getManager()
*
* </pre>
*
@ -482,4 +483,12 @@ public class CollaborationDrawingResource extends
// Though I hate this methods exists, it serves its purpose
return false;
}
/**
* @return the manager
*/
public CollaborationDrawingUIManager getManager() {
return manager;
}
}

View file

@ -42,6 +42,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 24, 2012 mschenke Initial creation
* Jun 30, 2014 1798 bclement added getResource(), made fields final
*
* </pre>
*
@ -51,9 +52,9 @@ import com.vividsolutions.jts.geom.Geometry;
public class CollaborationDrawingToolLayer extends DrawingToolLayer {
private CollaborationDrawingResource resource;
private final CollaborationDrawingResource resource;
private List<Coordinate> coordinates = new ArrayList<Coordinate>();
private final List<Coordinate> coordinates = new ArrayList<Coordinate>();
/**
* @param targetGeometry
@ -190,4 +191,12 @@ public class CollaborationDrawingToolLayer extends DrawingToolLayer {
}
return data;
}
/**
* @return the resource
*/
public CollaborationDrawingResource getResource() {
return resource;
}
}

View file

@ -70,6 +70,8 @@ import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDr
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent.CollaborationEventType;
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingResource;
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingResourceData;
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingToolLayer;
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingUIManager;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.core.ContextManager;
import com.raytheon.uf.viz.core.VizApp;
@ -103,6 +105,7 @@ import com.raytheon.viz.ui.input.EditableManager;
* Mar 18, 2014 2895 njensen Fix lockAction enable/disable logic
* Apr 15, 2014 2822 bclement only allow transfer leader if participant is using shared display
* May 05, 2014 3076 bclement added clear all action
* Jun 30, 2014 1798 bclement added disableCurrentLayer()
*
* </pre>
*
@ -765,7 +768,9 @@ public class CollaborationSessionView extends SessionView implements
// TODO this method has more to do with displays than the view,
// would be good to separate it out somehow
/* a null remoteDisplay means DEACTIVATE */
if (remoteDisplay == null) {
disableCurrentLayer();
currentDisplay = null;
VizApp.runAsync(actionUpdater);
return;
@ -826,20 +831,7 @@ public class CollaborationSessionView extends SessionView implements
*/
CollaborationDrawingResource resource = getCurrentDrawingResource();
if (resource != null) {
DrawingToolLayer layer = getCurrentLayer();
if (layer != null) {
switch (layer.getDrawMode()) {
case DRAW:
layer.doneDrawing();
break;
case ERASE:
layer.doneErasing();
break;
default:
// not drawing
}
layer.setDrawMode(DrawMode.NONE);
}
disableCurrentLayer();
}
currentDisplay = display;
@ -864,6 +856,7 @@ public class CollaborationSessionView extends SessionView implements
listener.dispose();
}
if (display == currentDisplay) {
disableCurrentLayer();
currentDisplay = null;
VizApp.runAsync(actionUpdater);
}
@ -872,6 +865,49 @@ public class CollaborationSessionView extends SessionView implements
}
}
/**
* prevent the current layer from drawing/erasing and clear the cursor
*/
private void disableCurrentLayer() {
final DrawingToolLayer layer = getCurrentLayer();
if (layer != null) {
/*
* Set done to handle disabling when the user is currently
* drawing/erasing. Must be done before clearing cursor.
*/
switch (layer.getDrawMode()) {
case DRAW:
layer.doneDrawing();
break;
case ERASE:
layer.doneErasing();
break;
default:
// not drawing
}
/*
* Handles the case where the user has a draw/erase cursor, has the
* mouse over the map, and the layer gets deactivated.
*/
VizApp.runAsync(new Runnable() {
@Override
public void run() {
/* skip if we got a new layer which that updated the cursor */
if (getCurrentLayer() == null
&& layer instanceof CollaborationDrawingToolLayer) {
CollaborationDrawingToolLayer cdtl = (CollaborationDrawingToolLayer) layer;
CollaborationDrawingUIManager manager = cdtl
.getResource().getManager();
if (manager != null) {
manager.clearCursor();
}
}
}
});
layer.setDrawMode(DrawMode.NONE);
}
}
/**
* Listener provides the view with information that the resource has become
* editable or not, which will affect any mouse handlers associated with it

View file

@ -43,6 +43,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 23, 2012 mschenke Initial creation
* Jun 30, 2014 1798 bclement updated clearCursor() to only clear its own cursor
* updateCursor() no longer clears cursor
*
* </pre>
*
@ -137,12 +139,38 @@ public class DrawingToolUIManager extends InputAdapter {
return false;
}
/**
* @see #getCurrentShell()
* @see #clearCursor(Shell)
*/
public void clearCursor() {
clearCursor(currentShell);
}
/**
* Clear cursor from shell if this manager set its current cursor
*
* @param shell
*/
protected void clearCursor(Shell shell) {
if (shell != null) {
shell.setCursor(normal);
Cursor cursor = shell.getCursor();
/*
* Only alternative to checking references is to check if the mouse
* is outside of this layer's map editor. This is to prevent this
* manager from clearing another session's cursor.
*/
if (cursor == erasor || cursor == pencil) {
shell.setCursor(normal);
}
}
}
/**
* Sets cursor icon according to draw mode
*
* @param shell
*/
protected void updateCursor(Shell shell) {
if (shell == null) {
return;
@ -159,9 +187,11 @@ public class DrawingToolUIManager extends InputAdapter {
}
break;
default:
// normal never gets set and thus will always be null, this is
// the desired behavior
shell.setCursor(normal);
/*
* only active layers (draw mode not equal to NONE) need to update
* the cursor. cursor will have already been cleared by
* handleMouseExit()
*/
}
}
@ -218,6 +248,8 @@ public class DrawingToolUIManager extends InputAdapter {
case ERASE:
drawingLayer.doneErasing();
break;
default:
/* no action */
}
container.refresh();
handlingInput = false;