Issue #3076 added clear all to shared display sessions

Former-commit-id: 1432aa1302 [formerly 729e717be1 [formerly f545c548cc] [formerly 1432aa1302 [formerly 9e4a518f2ecbe86fed87fbb6dac7fad08ffb33eb]]]
Former-commit-id: 729e717be1 [formerly f545c548cc]
Former-commit-id: 729e717be1
Former-commit-id: 02c921ed12
This commit is contained in:
Brian Clements 2014-05-05 12:52:46 -05:00
parent 363f9c41f5
commit bad8aa9f9a
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
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* May 05, 2014 3076 bclement added DISPOSE_ALL
*
* </pre>
*
@ -48,7 +49,7 @@ import com.vividsolutions.jts.geom.Coordinate;
public class CollaborationDrawingEvent {
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

View file

@ -19,6 +19,9 @@
**/
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.List;
import java.util.Map;
@ -64,6 +67,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* Feb 13, 2014 2751 bclement VenueParticipant refactor
* 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>
*
@ -129,7 +134,7 @@ public class CollaborationDrawingResource extends
CollaborationDrawingEvent event = new CollaborationDrawingEvent(
resourceData.getDisplayId());
event.setUserName(myUser);
event.setType(CollaborationEventType.CLEAR_ALL);
event.setType(CollaborationEventType.DISPOSE_ALL);
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
*/
@ -249,6 +266,23 @@ public class CollaborationDrawingResource extends
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)
*
@ -377,9 +411,12 @@ public class CollaborationDrawingResource extends
case UNDO:
layer.undo();
break;
case CLEAR_ALL:
case DISPOSE_ALL:
disposeLayers();
break;
case CLEAR_ALL:
clearLayers();
break;
case NEW_USER_ARRIVED:
CollaborationDrawingToolLayer myLayer = (CollaborationDrawingToolLayer) getDrawingLayerFor(getMyUser());
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.Collections;
import java.util.IdentityHashMap;
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 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
*
* </pre>
*
@ -140,6 +142,8 @@ public class CollaborationSessionView extends SessionView implements
private ActionContributionItem lockAction;
private ActionContributionItem clearAllAction;
private ControlContribution noEditorAction;
private ISharedDisplaySession session;
@ -181,6 +185,21 @@ public class CollaborationSessionView extends SessionView implements
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)
*
@ -354,7 +373,15 @@ public class CollaborationSessionView extends SessionView implements
lockAction.getAction().setImageDescriptor(
IconUtil.getImageDescriptor(Activator.getDefault().getBundle(),
"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") {
@Override
@ -383,12 +410,30 @@ public class CollaborationSessionView extends SessionView implements
mgr.insert(mgr.getSize() - 1, redoAction);
mgr.insert(mgr.getSize() - 1, clearAction);
mgr.insert(mgr.getSize() - 1, eraseAction);
mgr.insert(mgr.getSize() - 1, new Separator());
mgr.insert(mgr.getSize() - 1, lockAction);
mgr.insert(mgr.getSize() - 1, clearAllAction);
mgr.insert(mgr.getSize() - 1, new Separator());
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) {
if (mode != DrawMode.NONE) {
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() {
ToolBarManager mgr = (ToolBarManager) getViewSite().getActionBars()
.getToolBarManager();
@ -419,24 +478,21 @@ public class CollaborationSessionView extends SessionView implements
mgr.insert(0, noEditorAction);
}
CollaborationDrawingResource currentResource = getCurrentDrawingResource();
DrawingToolLayer layer = null;
if (currentResource != null) {
layer = currentResource.getDrawingLayerFor(currentResource
.getMyUser());
}
DrawingToolLayer layer = getCurrentLayer();
if (layer != null && currentResource.isSessionLeader()) {
lockAction.getAction().setEnabled(true);
clearAllAction.getAction().setEnabled(anyLayerHasDrawing());
} else {
lockAction.getAction().setEnabled(false);
clearAllAction.getAction().setEnabled(false);
}
// enable/disable toolbar buttons based on locked
if (layer != null
&& (locked == false || currentResource.isSessionLeader())) {
drawAction.getAction().setEnabled(true);
undoAction.getAction().setEnabled(layer.canUndo());
redoAction.getAction().setEnabled(layer.canRedo());
clearAction.getAction().setEnabled(layer.canClear());
clearAction.getAction().setEnabled(layer.hasDrawing());
eraseAction.getAction().setEnabled(true);
switch (layer.getDrawMode()) {
case DRAW:

View file

@ -65,6 +65,8 @@ import com.vividsolutions.jts.geom.TopologyException;
* May 23, 2012 mschenke Initial creation
* May 23, 2012 2646 bsteffen Fix NPE in project.
* 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>
*
@ -331,15 +333,7 @@ public class DrawingToolLayer implements IRenderable {
* Disposes the data in the layer
*/
public void dispose() {
synchronized (currentData) {
if (wireframeShape != null) {
wireframeShape.dispose();
}
currentData.geometries.clear();
currentDrawingLine = null;
undoStack.clear();
redoStack.clear();
}
clearAllDrawingData();
}
/**
@ -503,7 +497,7 @@ public class DrawingToolLayer implements IRenderable {
*
* @return
*/
public boolean canClear() {
public boolean hasDrawing() {
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
* puts in currentData
@ -568,6 +576,13 @@ public class DrawingToolLayer implements IRenderable {
StackFrame oldData = new StackFrame(new ArrayList<Geometry>(
currentData.geometries));
stack.push(oldData);
disposeWireframeShape();
}
/**
* disposes and sets wireframeShape to null if not already null
*/
private void disposeWireframeShape() {
if (wireframeShape != null) {
wireframeShape.dispose();
wireframeShape = null;