Issue #429 telestrator allows all users to draw

Former-commit-id: 09c022bda8 [formerly f200e37a36 [formerly ed59b0803da528f391db3c71aac1184581cc353d]]
Former-commit-id: f200e37a36
Former-commit-id: 916b8428e4
This commit is contained in:
Matt Nash 2012-04-05 10:27:10 -05:00
parent 85b6b8a196
commit 31f63e0cd0
10 changed files with 412 additions and 182 deletions

View file

@ -22,7 +22,6 @@ package com.raytheon.uf.viz.collaboration.ui.role;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
@ -31,14 +30,13 @@ import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup;
import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditor;
import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationResource;
import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationResourceData;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathDrawingResourceData;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathDrawingTool;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathToolbar;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.drawing.PathDrawingResourceData;
import com.raytheon.uf.viz.drawing.PathToolbar;
import com.raytheon.uf.viz.drawing.tools.PathDrawingTool;
/**
* Handles the events of a session that are specific to the Participant role.
@ -83,23 +81,9 @@ public class ParticipantEventController extends AbstractRoleEventController {
session.getSessionId(), editor);
// activate the drawing tool by default for participants
PathDrawingResourceData data = new CollaborationPathDrawingResourceData();
try {
editor.getActiveDisplayPane()
.getDescriptor()
.getResourceList()
.add(data.construct(new LoadProperties(),
editor.getActiveDisplayPane()
.getDescriptor()));
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
// PathDrawingTool tool = new
// CollaborationPathDrawingTool();
// tool.activate();
PathDrawingTool tool = new CollaborationPathDrawingTool();
tool.activate();
}
});
}
}
@ -123,13 +107,13 @@ public class ParticipantEventController extends AbstractRoleEventController {
@Override
public void startup() {
super.startup();
// VizApp.runAsync(new Runnable() {
// @Override
// public void run() {
// PathToolbar toolbar = CollaborationPathToolbar.getToolbar();
// toolbar.open();
// }
// });
VizApp.runAsync(new Runnable() {
@Override
public void run() {
PathToolbar toolbar = CollaborationPathToolbar.getToolbar();
toolbar.open();
}
});
}
/*

View file

@ -25,7 +25,7 @@ import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.eventbus.Subscribe;
@ -36,12 +36,14 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.ClearDrawingEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.RedoDrawingEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.UndoDrawingEvent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.uf.viz.drawing.PathDrawingResourceData;
@ -72,7 +74,9 @@ public class CollaborationDrawingLayer extends DrawingLayer {
private Multimap<RGB, IWireframeShape> collaboratorShapes;
private List<IWireframeShape> deletedCollaboratorShapes;
private List<ShapeContainer> deletedCollaboratorShapes;
private IWireframeShape tempRemoteShape = null;
private RGB officialColor = null;
@ -87,43 +91,10 @@ public class CollaborationDrawingLayer extends DrawingLayer {
.getActiveEditorAs(AbstractEditor.class);
CollaborationDataManager mgr = CollaborationDataManager.getInstance();
for (String str : mgr.getSessions().keySet()) {
if (editor.equals(mgr.getEditor(str))) {
mgr.getSession(str).registerEventHandler(this);
break;
}
}
}
@Subscribe
public void handle(IDisplayEvent event) {
if (event instanceof ClearDrawingEvent) {
resetTemp();
disposeInternal();
issueRefresh();
} else if (event instanceof CollaborationDrawingEvent) {
CollaborationDrawingEvent collEvent = (CollaborationDrawingEvent) event;
addCollaborationShape(collEvent.getGeom(),
getCapability(ColorableCapability.class).getColor());
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.DrawingLayer#reset()
*/
@Override
public void reset() {
super.reset();
ClearDrawingEvent event = new ClearDrawingEvent();
Map<String, IVenueSession> sessions = CollaborationDataManager
.getInstance().getSessions();
for (String str : sessions.keySet()) {
try {
((ISharedDisplaySession) sessions.get(str)).sendEvent(event);
} catch (CollaborationException e) {
e.printStackTrace();
}
// if (editor.equals(mgr.getEditor(str))) {
mgr.getSession(str).registerEventHandler(this);
break;
// }
}
}
@ -137,10 +108,10 @@ public class CollaborationDrawingLayer extends DrawingLayer {
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
this.collaboratorShapes = HashMultimap.create();
this.collaboratorShapes = LinkedHashMultimap.create();
this.collaboratorShapes = Multimaps
.synchronizedMultimap(this.collaboratorShapes);
this.deletedCollaboratorShapes = new ArrayList<IWireframeShape>();
this.deletedCollaboratorShapes = new ArrayList<ShapeContainer>();
TelestratorColorManager colorManager = TelestratorColorManager
.getColorManager();
officialColor = colorManager.getColorFromUser(CollaborationDataManager
@ -172,14 +143,129 @@ public class CollaborationDrawingLayer extends DrawingLayer {
}
}
public void addCollaborationShape(Geometry geom, RGB color) {
IWireframeShape shape = target.createWireframeShape(false,
getDescriptor());
drawTempLinePrimitive(geom, shape);
synchronized (collaboratorShapes) {
collaboratorShapes.put(color, shape);
@Subscribe
public void handle(IDisplayEvent event) {
if (event instanceof ClearDrawingEvent) {
resetTemp();
// TODO check if session leader, otherwise only remove my wireframe
// shapes
disposeInternal();
issueRefresh();
} else if (event instanceof UndoDrawingEvent) {
for (RGB rgb : collaboratorShapes.keySet()) {
IWireframeShape lastShape = null;
for (IWireframeShape shape : collaboratorShapes.get(rgb)) {
lastShape = shape;
}
collaboratorShapes.values().remove(lastShape);
}
issueRefresh();
} else if (event instanceof RedoDrawingEvent) {
} else if (event instanceof CollaborationDrawingEvent) {
CollaborationDrawingEvent collEvent = (CollaborationDrawingEvent) event;
addCollaborationShape(collEvent.getContainer());
issueRefresh();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#addTempDrawLine(com.vividsolutions
* .jts.geom.LineString)
*/
@Override
public void addTempDrawLine(LineString line) {
super.addTempDrawLine(line);
// for showing the line on the fly...
// sendDrawEvent(line);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#finalizeLine(com.vividsolutions
* .jts.geom.LineString, java.lang.String)
*/
@Override
public void finalizeLine(LineString line, String uuid) {
super.finalizeLine(line, uuid);
// for showing the line only after the artist lets up on the mouse
sendDrawEvent(line);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.DrawingLayer#undoAdd()
*/
@Override
public void undoAdd() {
super.undoAdd();
UndoDrawingEvent event = new UndoDrawingEvent();
sendGenericEvent(event);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.DrawingLayer#redoAdd()
*/
@Override
public void redoAdd() {
super.redoAdd();
RedoDrawingEvent event = new RedoDrawingEvent();
sendGenericEvent(event);
}
private void sendDrawEvent(LineString line) {
ShapeContainer container = new ShapeContainer();
String color = RGBColors.getColorName(officialColor);
container.setRgb(color);
container.setGeom(line);
CollaborationDrawingEvent tObject = new CollaborationDrawingEvent();
tObject.setContainer(container);
sendGenericEvent(tObject);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.DrawingLayer#reset()
*/
@Override
public void reset() {
super.reset();
if (/* is session leader */false) {
ClearDrawingEvent event = new ClearDrawingEvent();
sendGenericEvent(event);
}
}
private void sendGenericEvent(IDisplayEvent event) {
Map<String, IVenueSession> sessions = CollaborationDataManager
.getInstance().getSessions();
for (String str : sessions.keySet()) {
try {
((ISharedDisplaySession) sessions.get(str)).sendEvent(event);
} catch (CollaborationException e) {
e.printStackTrace();
}
}
}
public void addCollaborationShape(ShapeContainer container) {
// if (tempRemoteShape == null){
tempRemoteShape = target.createWireframeShape(false, getDescriptor());
// }
drawTempLinePrimitive(container.getGeom(), tempRemoteShape);
synchronized (collaboratorShapes) {
RGB color = RGBColors.getRGBColor(container.getRgb());
collaboratorShapes.put(color, tempRemoteShape);
}
issueRefresh();
}
public void removeCollaborationShape(Geometry geom, RGB color) {
@ -197,60 +283,19 @@ public class CollaborationDrawingLayer extends DrawingLayer {
@Override
protected void disposeInternal() {
super.disposeInternal();
synchronized (collaboratorShapes) {
for (IWireframeShape shape : collaboratorShapes.values()) {
shape.dispose();
if (/* is session leader */false) {
synchronized (collaboratorShapes) {
for (IWireframeShape shape : collaboratorShapes.values()) {
shape.dispose();
}
}
}
for (IWireframeShape shape : deletedCollaboratorShapes) {
shape.dispose();
}
collaboratorShapes.clear();
deletedCollaboratorShapes.clear();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#finalizeLine(com.vividsolutions
* .jts.geom.LineString, java.lang.String)
*/
@Override
public void finalizeLine(LineString line, String uuid) {
super.finalizeLine(line, uuid);
sendDrawEvent(line);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#addTempDrawLine(com.vividsolutions
* .jts.geom.LineString)
*/
@Override
public void addTempDrawLine(LineString line) {
super.addTempDrawLine(line);
// sendDrawEvent(line);
}
private void sendDrawEvent(LineString line) {
Map<String, IVenueSession> sessions = CollaborationDataManager
.getInstance().getSessions();
CollaborationDrawingEvent tObject = new CollaborationDrawingEvent(line,
officialColor);
// get the color of the user here, before sending it off
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
for (String str : sessions.keySet()) {
try {
((ISharedDisplaySession) sessions.get(str)).sendEvent(tObject);
} catch (CollaborationException e) {
e.printStackTrace();
for (ShapeContainer cont : deletedCollaboratorShapes) {
cont.shape.dispose();
}
collaboratorShapes.clear();
deletedCollaboratorShapes.clear();
}
}
}

View file

@ -106,4 +106,13 @@ public class CollaborationPathToolbar extends PathToolbar {
// });
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.PathToolbar#updateToolbar()
*/
@Override
public void updateToolbar() {
super.updateToolbar();
}
}

View file

@ -0,0 +1,106 @@
/**
* 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.collaboration.ui.telestrator;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.vividsolutions.jts.geom.Geometry;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 4, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class ShapeContainer {
public IWireframeShape shape;
@DynamicSerializeElement
public String rgb;
// public LineStyle lineStyle;
// public float lineWidth;
@DynamicSerializeElement
private Geometry geom;
public ShapeContainer() {
}
/**
* @return the shape
*/
public IWireframeShape getShape() {
return shape;
}
/**
* @param shape
* the shape to set
*/
public void setShape(IWireframeShape shape) {
this.shape = shape;
}
/**
* @return the rgb
*/
public String getRgb() {
return rgb;
}
/**
* @param rgb
* the rgb to set
*/
public void setRgb(String rgb) {
this.rgb = rgb;
}
/**
* @return the geom
*/
public Geometry getGeom() {
return geom;
}
/**
* @param geom
* the geom to set
*/
public void setGeom(Geometry geom) {
this.geom = geom;
}
}

View file

@ -19,13 +19,11 @@
**/
package com.raytheon.uf.viz.collaboration.ui.telestrator.event;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.ShapeContainer;
import com.raytheon.uf.viz.drawing.events.DrawingEvent;
import com.vividsolutions.jts.geom.Geometry;
/**
* TODO Add Description
@ -49,47 +47,28 @@ public class CollaborationDrawingEvent extends DrawingEvent implements
IDisplayEvent {
@DynamicSerializeElement
private Geometry geom;
// @DynamicSerializeElement
// private RGB color;
private ShapeContainer container;
public CollaborationDrawingEvent() {
}
public CollaborationDrawingEvent(Geometry geom, RGB color) {
this.geom = geom;
// this.color = color;
}
// /**
// * @return the color
// */
// public RGB getColor() {
// return color;
// }
//
// /**
// * @param color
// * the color to set
// */
// public void setColor(RGB color) {
// this.color = color;
// }
/**
* @return the geom
*/
public Geometry getGeom() {
return geom;
public CollaborationDrawingEvent(ShapeContainer cont) {
this.container = cont;
}
/**
* @param geom
* the geom to set
* @return the container
*/
public void setGeom(Geometry geom) {
this.geom = geom;
public ShapeContainer getContainer() {
return container;
}
}
/**
* @param container
* the container to set
*/
public void setContainer(ShapeContainer container) {
this.container = container;
}
}

View file

@ -0,0 +1,44 @@
/**
* 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.collaboration.ui.telestrator.event;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 4, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class RedoDrawingEvent extends CollaborationDrawingEvent {
}

View file

@ -0,0 +1,43 @@
/**
* 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.collaboration.ui.telestrator.event;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 4, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class UndoDrawingEvent extends CollaborationDrawingEvent {
}

View file

@ -26,9 +26,11 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.ui.tools.AbstractModalTool;
/**
* Describes a basic drawing tool.
*
@ -95,7 +97,8 @@ public abstract class AbstractDrawingTool extends AbstractModalTool {
}
this.handlerRegistered = getMouseHandler();
editor.registerMouseHandler(this.handlerRegistered);
editor.registerMouseHandler(this.handlerRegistered,
InputPriority.SYSTEM_RESOURCE);
}
/**

View file

@ -87,7 +87,7 @@ public class PathToolbar extends CaveSWTDialog {
private ToolItem redoItem;
private ToolItem clearItem;
protected ToolItem clearItem;
private IContextActivation drawingContext;
@ -273,23 +273,25 @@ public class PathToolbar extends CaveSWTDialog {
.getResourceList();
for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) {
DrawingLayer layer = (DrawingLayer) pair.getResource();
if (layer.getDeletedShapes().isEmpty()
&& layer.getWireframeShapes().isEmpty()) {
undoItem.setEnabled(false);
redoItem.setEnabled(false);
clearItem.setEnabled(false);
} else {
clearItem.setEnabled(true);
if (layer.getDeletedShapes().isEmpty()) {
redoItem.setEnabled(false);
} else {
redoItem.setEnabled(true);
}
if (layer.getWireframeShapes().isEmpty()) {
if (toolbar != null && !toolbar.isDisposed()) {
DrawingLayer layer = (DrawingLayer) pair.getResource();
if (layer.getDeletedShapes().isEmpty()
&& layer.getWireframeShapes().isEmpty()) {
undoItem.setEnabled(false);
redoItem.setEnabled(false);
clearItem.setEnabled(false);
} else {
undoItem.setEnabled(true);
clearItem.setEnabled(true);
if (layer.getDeletedShapes().isEmpty()) {
redoItem.setEnabled(false);
} else {
redoItem.setEnabled(true);
}
if (layer.getWireframeShapes().isEmpty()) {
undoItem.setEnabled(false);
} else {
undoItem.setEnabled(true);
}
}
}
}

View file

@ -202,4 +202,19 @@ public class PathDrawingTool extends AbstractDrawingTool {
true);
theDrawingLayer.issueRefresh();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.tools.AbstractModalTool#deactivate()
*/
@Override
public void deactivate() {
super.deactivate();
// change the cursor back
Cursor cursor = new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW);
Display.getCurrent().getActiveShell().setCursor(cursor);
cursor.dispose();
}
}