Merge "Issue #3076 added clear all to shared display sessions" into omaha_14.3.1

Former-commit-id: 8f8ea5d014 [formerly a583493711 [formerly 26eb2500104f7afe3fb07ddd66299aa1486375d2]]
Former-commit-id: a583493711
Former-commit-id: 26f47e3b00
This commit is contained in:
Nate Jensen 2014-05-06 16:15:41 -05:00 committed by Gerrit Code Review
commit 0b046a18e1
5 changed files with 130 additions and 21 deletions

View file

@ -37,6 +37,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 3, 2012 mnash Initial creation * Apr 3, 2012 mnash Initial creation
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant * Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* May 05, 2014 3076 bclement added DISPOSE_ALL
* *
* </pre> * </pre>
* *
@ -48,7 +49,7 @@ import com.vividsolutions.jts.geom.Coordinate;
public class CollaborationDrawingEvent { public class CollaborationDrawingEvent {
public static enum CollaborationEventType { public static enum CollaborationEventType {
DRAW, ERASE, REDO, UNDO, CLEAR, LOCK_USERS, UNLOCK_USERS, CLEAR_ALL, NEW_USER_ARRIVED; DRAW, ERASE, REDO, UNDO, CLEAR, CLEAR_ALL, LOCK_USERS, UNLOCK_USERS, DISPOSE_ALL, NEW_USER_ARRIVED;
} }
@DynamicSerializeElement @DynamicSerializeElement

View file

@ -19,6 +19,9 @@
**/ **/
package com.raytheon.uf.viz.collaboration.display.rsc.telestrator; package com.raytheon.uf.viz.collaboration.display.rsc.telestrator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -64,6 +67,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant * Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* Feb 13, 2014 2751 bclement VenueParticipant refactor * Feb 13, 2014 2751 bclement VenueParticipant refactor
* Mar 18, 2014 2895 njensen Fix concurrent mod exception on dispose * 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()
* *
* </pre> * </pre>
* *
@ -129,7 +134,7 @@ public class CollaborationDrawingResource extends
CollaborationDrawingEvent event = new CollaborationDrawingEvent( CollaborationDrawingEvent event = new CollaborationDrawingEvent(
resourceData.getDisplayId()); resourceData.getDisplayId());
event.setUserName(myUser); event.setUserName(myUser);
event.setType(CollaborationEventType.CLEAR_ALL); event.setType(CollaborationEventType.DISPOSE_ALL);
sendEvent(event); sendEvent(event);
} }
@ -205,6 +210,18 @@ public class CollaborationDrawingResource extends
} }
} }
/**
* Clear all drawing layers. Does not generate any collaboration events.
* This is not "undoable".
*/
private void clearLayers() {
synchronized (layerMap) {
for (DrawingToolLayer layer : layerMap.values()) {
layer.clearAllDrawingData();
}
}
}
/** /**
* @return the myUser * @return the myUser
*/ */
@ -249,6 +266,23 @@ public class CollaborationDrawingResource extends
return null; return null;
} }
/**
* A collection of drawing layers for resource
*
* @return empty collection if there are no layers
*/
public Collection<DrawingToolLayer> getAllDrawingLayers() {
Collection<DrawingToolLayer> rval;
if (layerMap != null) {
synchronized (layerMap) {
rval = new ArrayList<DrawingToolLayer>(layerMap.values());
}
} else {
rval = Collections.emptyList();
}
return rval;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -377,9 +411,12 @@ public class CollaborationDrawingResource extends
case UNDO: case UNDO:
layer.undo(); layer.undo();
break; break;
case CLEAR_ALL: case DISPOSE_ALL:
disposeLayers(); disposeLayers();
break; break;
case CLEAR_ALL:
clearLayers();
break;
case NEW_USER_ARRIVED: case NEW_USER_ARRIVED:
CollaborationDrawingToolLayer myLayer = (CollaborationDrawingToolLayer) getDrawingLayerFor(getMyUser()); CollaborationDrawingToolLayer myLayer = (CollaborationDrawingToolLayer) getDrawingLayerFor(getMyUser());
InitialCollaborationData dataBundle = new InitialCollaborationData( InitialCollaborationData dataBundle = new InitialCollaborationData(

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.collaboration.ui.session;
**/ **/
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
@ -101,6 +102,7 @@ import com.raytheon.viz.ui.input.EditableManager;
* Mar 11, 2014 2865 lvenable Added null checks in threads * Mar 11, 2014 2865 lvenable Added null checks in threads
* Mar 18, 2014 2895 njensen Fix lockAction enable/disable logic * 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 * Apr 15, 2014 2822 bclement only allow transfer leader if participant is using shared display
* May 05, 2014 3076 bclement added clear all action
* *
* </pre> * </pre>
* *
@ -140,6 +142,8 @@ public class CollaborationSessionView extends SessionView implements
private ActionContributionItem lockAction; private ActionContributionItem lockAction;
private ActionContributionItem clearAllAction;
private ControlContribution noEditorAction; private ControlContribution noEditorAction;
private ISharedDisplaySession session; private ISharedDisplaySession session;
@ -181,6 +185,21 @@ public class CollaborationSessionView extends SessionView implements
return null; return null;
} }
/**
* @see CollaborationDrawingResource#getAllDrawingLayers()
* @return empty collection if no layers are found
*/
private Collection<DrawingToolLayer> getAllLayers() {
Collection<DrawingToolLayer> rval;
CollaborationDrawingResource resource = getCurrentDrawingResource();
if (resource != null) {
rval = resource.getAllDrawingLayers();
} else {
rval = Collections.emptyList();
}
return rval;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -354,7 +373,15 @@ public class CollaborationSessionView extends SessionView implements
lockAction.getAction().setImageDescriptor( lockAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(Activator.getDefault().getBundle(), IconUtil.getImageDescriptor(Activator.getDefault().getBundle(),
"lock.gif")); "lock.gif"));
clearAllAction = new ActionContributionItem(new Action("Clear All") {
@Override
public void run() {
clearAllDrawingLayers();
}
});
clearAllAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(Activator.getDefault().getBundle(),
"clear_all.gif"));
noEditorAction = new ControlContribution("noEditorAction") { noEditorAction = new ControlContribution("noEditorAction") {
@Override @Override
@ -383,12 +410,30 @@ public class CollaborationSessionView extends SessionView implements
mgr.insert(mgr.getSize() - 1, redoAction); mgr.insert(mgr.getSize() - 1, redoAction);
mgr.insert(mgr.getSize() - 1, clearAction); mgr.insert(mgr.getSize() - 1, clearAction);
mgr.insert(mgr.getSize() - 1, eraseAction); mgr.insert(mgr.getSize() - 1, eraseAction);
mgr.insert(mgr.getSize() - 1, new Separator());
mgr.insert(mgr.getSize() - 1, lockAction); mgr.insert(mgr.getSize() - 1, lockAction);
mgr.insert(mgr.getSize() - 1, clearAllAction);
mgr.insert(mgr.getSize() - 1, new Separator()); mgr.insert(mgr.getSize() - 1, new Separator());
updateToolItems(); updateToolItems();
} }
/**
* Clear all drawing layers and send clear all event
*/
private void clearAllDrawingLayers() {
for (DrawingToolLayer layer : getAllLayers()) {
layer.clearAllDrawingData();
}
CollaborationDrawingResource resource = getCurrentDrawingResource();
CollaborationDrawingEvent event = new CollaborationDrawingEvent(
resource.getResourceData().getDisplayId());
event.setType(CollaborationEventType.CLEAR_ALL);
event.setUserName(resource.getMyUser());
resource.sendEvent(event);
updateToolItems();
}
private void toggleDrawMode(DrawMode mode) { private void toggleDrawMode(DrawMode mode) {
if (mode != DrawMode.NONE) { if (mode != DrawMode.NONE) {
CollaborationDrawingResource resource = getCurrentDrawingResource(); CollaborationDrawingResource resource = getCurrentDrawingResource();
@ -411,6 +456,20 @@ public class CollaborationSessionView extends SessionView implements
} }
} }
/**
* @return true if any drawing layer has been drawn on
*/
private boolean anyLayerHasDrawing() {
boolean anyCanClear = false;
for (DrawingToolLayer dtl : getAllLayers()) {
if (dtl.hasDrawing()) {
anyCanClear = true;
break;
}
}
return anyCanClear;
}
public void updateToolItems() { public void updateToolItems() {
ToolBarManager mgr = (ToolBarManager) getViewSite().getActionBars() ToolBarManager mgr = (ToolBarManager) getViewSite().getActionBars()
.getToolBarManager(); .getToolBarManager();
@ -419,24 +478,21 @@ public class CollaborationSessionView extends SessionView implements
mgr.insert(0, noEditorAction); mgr.insert(0, noEditorAction);
} }
CollaborationDrawingResource currentResource = getCurrentDrawingResource(); CollaborationDrawingResource currentResource = getCurrentDrawingResource();
DrawingToolLayer layer = null; DrawingToolLayer layer = getCurrentLayer();
if (currentResource != null) {
layer = currentResource.getDrawingLayerFor(currentResource
.getMyUser());
}
if (layer != null && currentResource.isSessionLeader()) { if (layer != null && currentResource.isSessionLeader()) {
lockAction.getAction().setEnabled(true); lockAction.getAction().setEnabled(true);
clearAllAction.getAction().setEnabled(anyLayerHasDrawing());
} else { } else {
lockAction.getAction().setEnabled(false); lockAction.getAction().setEnabled(false);
clearAllAction.getAction().setEnabled(false);
} }
// enable/disable toolbar buttons based on locked // enable/disable toolbar buttons based on locked
if (layer != null if (layer != null
&& (locked == false || currentResource.isSessionLeader())) { && (locked == false || currentResource.isSessionLeader())) {
drawAction.getAction().setEnabled(true); drawAction.getAction().setEnabled(true);
undoAction.getAction().setEnabled(layer.canUndo()); undoAction.getAction().setEnabled(layer.canUndo());
redoAction.getAction().setEnabled(layer.canRedo()); redoAction.getAction().setEnabled(layer.canRedo());
clearAction.getAction().setEnabled(layer.canClear()); clearAction.getAction().setEnabled(layer.hasDrawing());
eraseAction.getAction().setEnabled(true); eraseAction.getAction().setEnabled(true);
switch (layer.getDrawMode()) { switch (layer.getDrawMode()) {
case DRAW: case DRAW:

View file

@ -65,6 +65,8 @@ import com.vividsolutions.jts.geom.TopologyException;
* May 23, 2012 mschenke Initial creation * May 23, 2012 mschenke Initial creation
* May 23, 2012 2646 bsteffen Fix NPE in project. * May 23, 2012 2646 bsteffen Fix NPE in project.
* Apr 03, 2014 2967 njensen Fix error when erasing the last part of a line * Apr 03, 2014 2967 njensen Fix error when erasing the last part of a line
* May 05, 2014 3076 bclement added clearAllDrawingData() and disposeWireframeShape()
* renamed canClear() to hasDrawing()
* *
* </pre> * </pre>
* *
@ -331,15 +333,7 @@ public class DrawingToolLayer implements IRenderable {
* Disposes the data in the layer * Disposes the data in the layer
*/ */
public void dispose() { public void dispose() {
synchronized (currentData) { clearAllDrawingData();
if (wireframeShape != null) {
wireframeShape.dispose();
}
currentData.geometries.clear();
currentDrawingLine = null;
undoStack.clear();
redoStack.clear();
}
} }
/** /**
@ -503,7 +497,7 @@ public class DrawingToolLayer implements IRenderable {
* *
* @return * @return
*/ */
public boolean canClear() { public boolean hasDrawing() {
return currentData.geometries.size() > 0 || redoStack.size() > 0; return currentData.geometries.size() > 0 || redoStack.size() > 0;
} }
@ -535,6 +529,20 @@ public class DrawingToolLayer implements IRenderable {
} }
} }
/**
* Clears the current display and the undo and redo stacks. This operation
* is not "undoable"
*/
public void clearAllDrawingData() {
synchronized (currentData) {
disposeWireframeShape();
currentData.geometries.clear();
currentDrawingLine = null;
undoStack.clear();
redoStack.clear();
}
}
/** /**
* Pushes currentData on pushStack and pops next frame from popStack and * Pushes currentData on pushStack and pops next frame from popStack and
* puts in currentData * puts in currentData
@ -568,6 +576,13 @@ public class DrawingToolLayer implements IRenderable {
StackFrame oldData = new StackFrame(new ArrayList<Geometry>( StackFrame oldData = new StackFrame(new ArrayList<Geometry>(
currentData.geometries)); currentData.geometries));
stack.push(oldData); stack.push(oldData);
disposeWireframeShape();
}
/**
* disposes and sets wireframeShape to null if not already null
*/
private void disposeWireframeShape() {
if (wireframeShape != null) { if (wireframeShape != null) {
wireframeShape.dispose(); wireframeShape.dispose();
wireframeShape = null; wireframeShape = null;