Merge branch '11-Collaboration' of ssh://lightning.omaha.us.ray.com:29418/thunder into 11-Collaboration

Former-commit-id: 5bd4a3ccbcb84443eb342670c2a4ea6e083527b7
This commit is contained in:
Max Schenkelberg 2012-04-03 13:15:20 -05:00
commit e78aad4bc5
29 changed files with 962 additions and 184 deletions

View file

@ -21,5 +21,6 @@ Require-Bundle: com.raytheon.viz.ui,
Import-Package: com.raytheon.uf.common.status, Import-Package: com.raytheon.uf.common.status,
com.raytheon.uf.viz.core.maps.display, com.raytheon.uf.viz.core.maps.display,
com.raytheon.uf.viz.core.maps.rsc, com.raytheon.uf.viz.core.maps.rsc,
com.raytheon.uf.viz.drawing com.raytheon.uf.viz.drawing,
com.raytheon.viz.awipstools.ui.display
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

View file

@ -19,6 +19,7 @@
**/ **/
package com.raytheon.uf.viz.collaboration.data; package com.raytheon.uf.viz.collaboration.data;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -34,6 +35,8 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -51,6 +54,7 @@ import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
import com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController; import com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController;
import com.raytheon.uf.viz.collaboration.ui.role.DataProviderEventController; import com.raytheon.uf.viz.collaboration.ui.role.DataProviderEventController;
import com.raytheon.uf.viz.collaboration.ui.role.ParticipantEventController; import com.raytheon.uf.viz.collaboration.ui.role.ParticipantEventController;
import com.raytheon.uf.viz.collaboration.ui.role.SessionLeaderEventController;
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.VizApp;
@ -103,7 +107,7 @@ public class CollaborationDataManager {
*/ */
Map<String, IVenueSession> sessionsMap; Map<String, IVenueSession> sessionsMap;
private Map<String, AbstractRoleEventController> roleEventControllersMap; private Multimap<String, AbstractRoleEventController> roleEventControllersMap;
Map<String, CollaborationEditor> editorsMap; Map<String, CollaborationEditor> editorsMap;
@ -132,7 +136,7 @@ public class CollaborationDataManager {
linkCollaboration = false; linkCollaboration = false;
usersMap = new HashMap<String, DataUser>(); usersMap = new HashMap<String, DataUser>();
sessionsMap = new HashMap<String, IVenueSession>(); sessionsMap = new HashMap<String, IVenueSession>();
roleEventControllersMap = new HashMap<String, AbstractRoleEventController>(); roleEventControllersMap = HashMultimap.create();
editorsMap = new HashMap<String, CollaborationEditor>(); editorsMap = new HashMap<String, CollaborationEditor>();
} }
@ -302,10 +306,12 @@ public class CollaborationDataManager {
} }
} }
AbstractRoleEventController controller = roleEventControllersMap Collection<AbstractRoleEventController> controller = roleEventControllersMap
.remove(sessionId); .removeAll(sessionId);
if (controller != null) { if (controller != null) {
controller.shutdown(); for (AbstractRoleEventController cont : controller) {
cont.shutdown();
}
} }
} }
@ -381,7 +387,11 @@ public class CollaborationDataManager {
DataProviderEventController dpec = new DataProviderEventController( DataProviderEventController dpec = new DataProviderEventController(
displaySession); displaySession);
dpec.startup(); dpec.startup();
SessionLeaderEventController slec = new SessionLeaderEventController(
displaySession);
slec.startup();
roleEventControllersMap.put(sessionId, dpec); roleEventControllersMap.put(sessionId, dpec);
roleEventControllersMap.put(sessionId, slec);
// TODO set displaySession's data provider and session leader. // TODO set displaySession's data provider and session leader.
} }
} catch (CollaborationException e) { } catch (CollaborationException e) {
@ -411,6 +421,9 @@ public class CollaborationDataManager {
public void run() { public void run() {
IQualifiedID inviter = invitation.getInviter(); IQualifiedID inviter = invitation.getInviter();
IQualifiedID room = invitation.getRoomId(); IQualifiedID room = invitation.getRoomId();
if (shell.isDisposed()) {
shell = new Shell(Display.getCurrent());
}
MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION
| SWT.OK | SWT.CANCEL); | SWT.OK | SWT.CANCEL);
box.setText("Invitation"); box.setText("Invitation");

View file

@ -27,10 +27,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.action.IMenuCreator;
@ -98,9 +94,7 @@ import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
import com.raytheon.uf.viz.collaboration.ui.session.SessionView; import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.icon.IconUtil; import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.uf.viz.drawing.PathToolbar;
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
/** /**
@ -193,22 +187,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
if (CollaborationDataManager.getInstance().isConnected() == false) { if (CollaborationDataManager.getInstance().isConnected() == false) {
usersTreeViewer.getTree().setEnabled(false); usersTreeViewer.getTree().setEnabled(false);
} }
Job job = new Job("Opening draw toolbar") {
@Override
protected IStatus run(IProgressMonitor monitor) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
final PathToolbar toolbar = PathToolbar.getToolbar();
toolbar.open();
}
});
return Status.OK_STATUS;
}
};
job.schedule();
} }
/** /**

View file

@ -77,7 +77,8 @@ public class CollaborationEditorInputHandler implements IInputHandler {
protected boolean isSessionLeader() { protected boolean isSessionLeader() {
// TODO does this work? // TODO does this work?
return session.getUserID().equals(session.getCurrentSessionLeader()); // return session.getUserID().equals(session.getCurrentSessionLeader());
return false;
} }
/* /*

View file

@ -75,7 +75,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
.getInstance().getActiveEditor(); .getInstance().getActiveEditor();
SharedEditor se = EditorSetup.extractSharedEditor(editor); SharedEditor se = EditorSetup.extractSharedEditor(editor);
try { try {
session.sendInitData(event.getParticipant(), se); session.sendInitData(event.getParticipant().getQualifiedId(), se);
} catch (CollaborationException e) { } catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Error sending initialization data to new participant " "Error sending initialization data to new participant "

View file

@ -29,7 +29,9 @@ import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditorInputHandler; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditorInputHandler;
import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup; 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.editor.SharedEditor;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority; import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority;
import com.raytheon.uf.viz.drawing.PathToolbar;
/** /**
* Handles the events of a session that are specific to the Participant role. * Handles the events of a session that are specific to the Participant role.
@ -60,14 +62,53 @@ public class ParticipantEventController extends AbstractRoleEventController {
@Subscribe @Subscribe
public void initDataArrived(IInitData initData) { public void initDataArrived(IInitData initData) {
if (initData instanceof SharedEditor) { if (initData instanceof SharedEditor) {
SharedEditor se = (SharedEditor) initData; final SharedEditor se = (SharedEditor) initData;
CollaborationEditor editor = EditorSetup.createEditor(se); VizApp.runAsync(new Runnable() {
editor.registerMouseHandler(new CollaborationEditorInputHandler(
session, editor.getDisplayPanes()[0]), @Override
InputPriority.SYSTEM_RESOURCE); public void run() {
CollaborationDataManager.getInstance().editorCreated( CollaborationEditor editor = EditorSetup.createEditor(se);
session.getSessionId(), editor); editor.registerMouseHandler(
new CollaborationEditorInputHandler(session, editor
.getDisplayPanes()[0]),
InputPriority.SYSTEM_RESOURCE);
CollaborationDataManager.getInstance().editorCreated(
session.getSessionId(), editor);
}
});
} }
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController
* #startup()
*/
@Override
public void startup() {
super.startup();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
PathToolbar toolbar = PathToolbar.getToolbar();
toolbar.open();
}
});
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController
* #shutdown()
*/
@Override
public void shutdown() {
super.shutdown();
PathToolbar.getToolbar().close();
}
} }

View file

@ -0,0 +1,85 @@
/**
* 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.role;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathToolbar;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.drawing.PathToolbar;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 2, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class SessionLeaderEventController extends AbstractRoleEventController {
/**
* @param session
*/
public SessionLeaderEventController(ISharedDisplaySession session) {
super(session);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController
* #startup()
*/
@Override
public void startup() {
super.startup();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
PathToolbar toolbar = CollaborationPathToolbar.getToolbar();
toolbar.open();
}
});
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController
* #shutdown()
*/
@Override
public void shutdown() {
super.shutdown();
PathToolbar.getToolbar().close();
}
}

View file

@ -0,0 +1,151 @@
/**
* 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 java.util.Arrays;
import java.util.Map;
import org.eclipse.swt.graphics.Color;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.core.IGraphicsTarget;
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;
import com.vividsolutions.jts.geom.LineString;
/**
* A layer that extends Drawing Layer but allows other users to have things
* drawn as well
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 3, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationDrawingLayer extends DrawingLayer {
private Multimap<Color, IWireframeShape> collaboratorShapes;
/**
* @param data
* @param props
*/
public CollaborationDrawingLayer(PathDrawingResourceData data,
LoadProperties props) {
super(data, props);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#initInternal(com.raytheon.uf
* .viz.core.IGraphicsTarget)
*/
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
this.collaboratorShapes = HashMultimap.create();
getCapabilities().removeCapability(ColorableCapability.class);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.DrawingLayer#paintInternal(com.raytheon.uf
* .viz.core.IGraphicsTarget,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
super.paintInternal(target, paintProps);
OutlineCapability outline = getCapability(OutlineCapability.class);
// paint the shapes that come over from others
for (Color color : collaboratorShapes.keySet()) {
for (IWireframeShape sh : collaboratorShapes.get(color)) {
target.drawWireframeShape(sh, color.getRGB(),
outline.getOutlineWidth(), outline.getLineStyle());
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.DrawingLayer#disposeInternal()
*/
@Override
protected void disposeInternal() {
super.disposeInternal();
for (IWireframeShape shape : collaboratorShapes.values()) {
shape.dispose();
}
collaboratorShapes.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);
Map<String, IVenueSession> sessions = CollaborationDataManager
.getInstance().getSessions();
TelestratorLine tObject = new TelestratorLine();
// set the coordinates of the TransferLine
tObject.setCoordinates(Arrays.asList(line.getCoordinates()));
// get the color of the user here, before sending it off
tObject.setColor(null);
// for (String str : sessions.keySet()) {
// try {
// ((ISharedDisplaySession) sessions.get(str)).sendEvent(tObject);
// } catch (CollaborationException e) {
// e.printStackTrace();
// }
// }
}
}

View file

@ -0,0 +1,86 @@
/**
* 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.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.uf.viz.drawing.PathDrawingResourceData;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 3, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationPathDrawingResourceData extends
PathDrawingResourceData {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.PathDrawingResourceData#construct(com.raytheon
* .uf.viz.core.rsc.LoadProperties,
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public DrawingLayer construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
CollaborationDrawingLayer layer = new CollaborationDrawingLayer(this,
loadProperties);
return layer;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#setClassT
* (java.lang.String)
*/
@Override
public String getClassT() {
return this.getClass().getCanonicalName();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.awipstools.ui.display.AwipsToolsResourceData#setClassT
* (java.lang.String)
*/
@Override
public void setClassT(String classT) {
}
}

View file

@ -0,0 +1,53 @@
/**
* 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.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.drawing.tools.PathDrawingTool;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 3, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationPathDrawingTool extends PathDrawingTool {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.tools.PathDrawingTool#constructData()
*/
@Override
public AbstractResourceData constructData() {
CollaborationPathDrawingResourceData data = new CollaborationPathDrawingResourceData();
return data;
}
}

View file

@ -0,0 +1,109 @@
/**
* 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 org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.viz.drawing.PathToolbar;
import com.raytheon.uf.viz.drawing.events.DrawingEventBus;
import com.raytheon.uf.viz.drawing.tools.PathDrawingTool;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 3, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class CollaborationPathToolbar extends PathToolbar {
/**
* @param parentShell
*/
protected CollaborationPathToolbar(Shell parentShell) {
super(parentShell);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.drawing.PathToolbar#startTool()
*/
@Override
protected void startTool() {
PathDrawingTool tool = new CollaborationPathDrawingTool();
tool.activate();
}
public static PathToolbar getToolbar() {
if (pathToolbar == null) {
pathToolbar = new CollaborationPathToolbar(new Shell(
Display.getCurrent()));
DrawingEventBus.register(PathToolbar.getToolbar());
}
return pathToolbar;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.drawing.PathToolbar#initializeComponents(org.eclipse
* .swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
// allows for subclasses to add more items to the toolbar, in this case
// allowing the user to turn off other collaborator drawings
super.initializeComponents(shell);
// ToolItem allowOthersItem = new ToolItem(toolbar, SWT.CHECK);
// allowOthersItem.setText("Leader Only");
// allowOthersItem.setImage(IconUtil.getImageDescriptor(
// Activator.getDefault().getBundle(), "multiple_draw.gif")
// .createImage());
// allowOthersItem.setSelection(true);
// allowOthersItem.addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(SelectionEvent e) {
// AbstractEditor editor = EditorUtil
// .getActiveEditorAs(AbstractEditor.class);
// IDescriptor desc = editor.getActiveDisplayPane()
// .getDescriptor();
// for (ResourcePair pair : desc.getResourceList()) {
// if (pair.getResource() instanceof CollaborationDrawingLayer) {
// System.out.println("collaborating");
// }
// }
// }
// });
}
}

View file

@ -17,14 +17,16 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
package com.raytheon.uf.viz.drawing.objects; package com.raytheon.uf.viz.collaboration.ui.telestrator;
import java.util.List; import java.util.List;
import org.eclipse.swt.graphics.Color;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
/** /**
* TODO Add Description * A line for the telestrator
* *
* <pre> * <pre>
* *
@ -40,9 +42,28 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0 * @version 1.0
*/ */
public class TransferLine { public class TelestratorLine extends TelestratorObject {
// the color of the shape to be drawn
private Color color;
// the coordinates to be converted into a wireframe shape
private List<Coordinate> coordinates; private List<Coordinate> coordinates;
/**
* @param color
* the color to set
*/
public void setColor(Color color) {
this.color = color;
}
/**
* @return the color
*/
public Color getColor() {
return color;
}
/** /**
* @param coordinates * @param coordinates
* the coordinates to set * the coordinates to set

View file

@ -17,25 +17,27 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
package com.raytheon.uf.viz.drawing.objects; package com.raytheon.uf.viz.collaboration.ui.telestrator;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
/** /**
* TODO Add Description * TODO Add Description
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 26, 2012 mnash Initial creation * Mar 26, 2012 mnash Initial creation
* *
* </pre> * </pre>
* *
* @author mnash * @author mnash
* @version 1.0 * @version 1.0
*/ */
public class TransferObject { public class TelestratorObject implements IDisplayEvent {
} }

View file

@ -73,7 +73,7 @@ public interface ISharedDisplaySession extends IEventPublisher {
* @param participant * @param participant
* @param initData * @param initData
*/ */
void sendInitData(IChatID participant, IInitData initData) void sendInitData(IQualifiedID participant, IInitData initData)
throws CollaborationException; throws CollaborationException;
/** /**
@ -95,7 +95,7 @@ public interface ISharedDisplaySession extends IEventPublisher {
*/ */
void sendEvent(IDisplayEvent event) throws CollaborationException; void sendEvent(IDisplayEvent event) throws CollaborationException;
void sendEvent(IChatID participant, IDisplayEvent event) void sendEvent(IQualifiedID participant, IDisplayEvent event)
throws CollaborationException; throws CollaborationException;
/** /**

View file

@ -39,5 +39,11 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied;
*/ */
public interface IVenueParticipant extends IChatID, IPropertied { public interface IVenueParticipant extends IChatID, IPropertied {
/**
* Return the identifier as a qualified field. Removes the "domain"
* conference from the host string if found.
* @return The qualified id.
*/
IQualifiedID getQualifiedId();
} }

View file

@ -90,7 +90,8 @@ public abstract class BaseSession implements ISession {
* @param sessionId * @param sessionId
*/ */
protected BaseSession(IContainer container, EventBus externalBus, protected BaseSession(IContainer container, EventBus externalBus,
SessionManager manager, String sessionId) throws CollaborationException { SessionManager manager, String sessionId)
throws CollaborationException {
// Set the session identifier. // Set the session identifier.
this.sessionId = sessionId; this.sessionId = sessionId;
managerEventBus = externalBus; managerEventBus = externalBus;
@ -100,7 +101,7 @@ public abstract class BaseSession implements ISession {
eventSubscribers = new HashMap<Object, Object>(); eventSubscribers = new HashMap<Object, Object>();
setup(); setup();
} }
/** /**
* *
* @throws ECFException * @throws ECFException
@ -240,6 +241,7 @@ public abstract class BaseSession implements ISession {
*/ */
public ID createID(String name) throws IDCreateException { public ID createID(String name) throws IDCreateException {
ID id = null; ID id = null;
name += "/foo"; // TODO fix this in a better way
if (connectionNamespace != null) { if (connectionNamespace != null) {
id = IDFactory.getDefault().createID(connectionNamespace, name); id = IDFactory.getDefault().createID(connectionNamespace, name);
} }

View file

@ -80,7 +80,10 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
// Assume success // Assume success
int status = Errors.NO_ERROR; int status = Errors.NO_ERROR;
if (chatSender != null) { if (chatSender != null) {
ID toID = createID(message.getTo().getName()); // TODO fix this in a better way
String fqName = message.getTo().getFQName()
.replace("conference.", "");
ID toID = createID(fqName);
String subject = message.getSubject(); String subject = message.getSubject();
String body = message.getBody(); String body = message.getBody();
Collection<Property> properties = message.getProperties(); Collection<Property> properties = message.getProperties();
@ -124,10 +127,10 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
return status; return status;
} }
/** /**
* *
* @return * @return
*/ */
@Override @Override
public EventBus getEventPublisher() { public EventBus getEventPublisher() {

View file

@ -129,14 +129,15 @@ public class VenueSession extends BaseSession implements IVenueSession,
private Map<Object, Object> initSubscribers = new HashMap<Object, Object>(); private Map<Object, Object> initSubscribers = new HashMap<Object, Object>();
private String subject; private String subject;
/** /**
* *
* @param container * @param container
* @param eventBus * @param eventBus
*/ */
VenueSession(IContainer container, EventBus externalBus, VenueSession(IContainer container, EventBus externalBus,
SessionManager manager, String sessionId) throws CollaborationException { SessionManager manager, String sessionId)
throws CollaborationException {
super(container, externalBus, manager, sessionId); super(container, externalBus, manager, sessionId);
} }
@ -228,7 +229,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
} }
return venue; return venue;
} }
/** /**
* @return the subject * @return the subject
*/ */
@ -237,7 +238,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
} }
/** /**
* @param subject the subject to set * @param subject
* the subject to set
*/ */
public void setSubject(String subject) { public void setSubject(String subject) {
this.subject = subject; this.subject = subject;
@ -271,7 +273,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
ID userId = IDFactory.getDefault().createID( ID userId = IDFactory.getDefault().createID(
getConnectionNamespace(), id); getConnectionNamespace(), id);
try { try {
sender.sendInvitation(roomId, userId, subject, body); sender.sendInvitation(roomId, userId, subject, body);
} catch (ECFException e) { } catch (ECFException e) {
@ -309,7 +311,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
} }
return status; return status;
} }
/** /**
* *
* @param body * @param body
@ -343,14 +345,18 @@ public class VenueSession extends BaseSession implements IVenueSession,
*/ */
@Override @Override
public void sendInitData( public void sendInitData(
com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant,
IInitData initData) throws CollaborationException { IInitData initData) throws CollaborationException {
PeerToPeerChat session = getP2PSession(); PeerToPeerChat session = getP2PSession();
if (session != null) { if (session != null) {
String message = Tools.marshallData(initData); String message = Tools.marshallData(initData);
if (message != null) { if (message != null) {
session.sendPeerToPeer(participant.getFQName(), message);
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
} }
} }
} }
@ -367,7 +373,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
if (!initSubscribers.containsKey(subscriber)) { if (!initSubscribers.containsKey(subscriber)) {
initSubscribers.put(subscriber, subscriber); initSubscribers.put(subscriber, subscriber);
} }
PeerToPeerChat session = getP2PSession(); PeerToPeerChat session = getP2PSession();
if (session != null) { if (session != null) {
session.registerEventHandler(subscriber); session.registerEventHandler(subscriber);
@ -400,7 +406,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
*/ */
@Override @Override
public void sendEvent( public void sendEvent(
com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant,
IDisplayEvent event) throws CollaborationException { IDisplayEvent event) throws CollaborationException {
PeerToPeerChat session = null; PeerToPeerChat session = null;
@ -408,7 +414,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
if (session != null) { if (session != null) {
String message = Tools.marshallData(event); String message = Tools.marshallData(event);
if (message != null) { if (message != null) {
session.sendPeerToPeer(participant.getFQName(), message);
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
} }
} }
} }
@ -512,7 +521,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
void setSessionLeader(IChatID id) { void setSessionLeader(IChatID id) {
sessionLeader = id; sessionLeader = id;
} }
/** /**
* *
*/ */

View file

@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
/** /**
@ -44,6 +45,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
public class VenueParticipant implements IVenueParticipant { public class VenueParticipant implements IVenueParticipant {
private static String CONF_ID = "conference.";
private Map<String, String> properties; private Map<String, String> properties;
private String name; private String name;
@ -187,4 +190,24 @@ public class VenueParticipant implements IVenueParticipant {
return sb.toString(); return sb.toString();
} }
/**
* Return the identifier as a qualified field. Removes the "domain"
* conference from the host string if found.
* @return The qualified id.
*/
@Override
public IQualifiedID getQualifiedId() {
String hostName = host;
if(hostName != null) {
if(hostName.startsWith(CONF_ID)) {
hostName = hostName.substring(CONF_ID.length());
}
}
UserId id = new UserId(getName(), hostName);
id.setResource(resource);
return id;
}
} }

View file

@ -11,11 +11,13 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0", com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.viz.awipstools;bundle-version="1.12.1174", com.raytheon.viz.awipstools;bundle-version="1.12.1174",
com.raytheon.viz.ui;bundle-version="1.12.1174" com.raytheon.viz.ui;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Import-Package: com.raytheon.uf.common.time, Import-Package: com.raytheon.uf.common.time,
com.raytheon.viz.ui.cmenu, com.raytheon.viz.ui.cmenu,
com.vividsolutions.jts.geom com.vividsolutions.jts.geom
Export-Package: com.raytheon.uf.viz.drawing, Export-Package: com.raytheon.uf.viz.drawing,
com.raytheon.uf.viz.drawing.objects com.raytheon.uf.viz.drawing.events,
com.raytheon.uf.viz.drawing.tools

View file

@ -26,13 +26,12 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.jface.action.Action; import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.action.IMenuManager;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
@ -41,14 +40,16 @@ 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.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.viz.ui.cmenu.IContextMenuContributor; import com.raytheon.uf.viz.drawing.events.DrawingEvent;
import com.raytheon.uf.viz.drawing.events.DrawingEventBus;
import com.raytheon.uf.viz.drawing.events.DrawingListener;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiLineString; import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.TopologyException;
/** /**
* Implements a basic drawing layer * Implements a basic drawing layer
@ -57,8 +58,7 @@ import com.vividsolutions.jts.geom.Point;
* *
*/ */
public class DrawingLayer extends public class DrawingLayer extends
AbstractVizResource<AbstractResourceData, MapDescriptor> implements AbstractVizResource<AbstractResourceData, MapDescriptor> {
IContextMenuContributor {
protected List<Geometry> tempGeometries; protected List<Geometry> tempGeometries;
@ -70,9 +70,6 @@ public class DrawingLayer extends
protected IWireframeShape eraseWireframeShape; protected IWireframeShape eraseWireframeShape;
// TODO take this out
private List<IWireframeShape> erasedShapes;
protected IGraphicsTarget target; protected IGraphicsTarget target;
protected boolean erase = false; protected boolean erase = false;
@ -81,8 +78,21 @@ public class DrawingLayer extends
private boolean needsRefresh = false; private boolean needsRefresh = false;
protected RGB color;
protected OutlineCapability outline;
// allowing for others to get events from the drawing tool, just having to
// subscribe
private EventBus eventBus;
private DrawingListener eventListener = null;
public DrawingLayer(PathDrawingResourceData data, LoadProperties props) { public DrawingLayer(PathDrawingResourceData data, LoadProperties props) {
super(data, props); super(data, props);
eventBus = DrawingEventBus.getEventBus();
eventListener = DrawingEventBus.getDrawingListener();
eventBus.register(eventListener);
} }
/* /*
@ -107,11 +117,9 @@ public class DrawingLayer extends
this.wireframeShapes = new LinkedHashMap<Geometry, IWireframeShape>(); this.wireframeShapes = new LinkedHashMap<Geometry, IWireframeShape>();
this.deletedShapes = new LinkedHashMap<Geometry, IWireframeShape>(); this.deletedShapes = new LinkedHashMap<Geometry, IWireframeShape>();
this.erasedShapes = new ArrayList<IWireframeShape>();
this.target = target; this.target = target;
outline = getCapability(OutlineCapability.class);
getCapability(OutlineCapability.class); color = getCapability(ColorableCapability.class).getColor();
getCapability(ColorableCapability.class);
getCapability(EditableCapability.class); getCapability(EditableCapability.class);
} }
@ -134,46 +142,27 @@ public class DrawingLayer extends
getDescriptor()); getDescriptor());
} }
OutlineCapability outline = getCapability(OutlineCapability.class); outline = getCapability(OutlineCapability.class);
ColorableCapability colorable = getCapability(ColorableCapability.class); color = getCapability(ColorableCapability.class).getColor();
// remove after debugging
// MagnificationCapability magnification =
// getCapability(MagnificationCapability.class);
// for (Geometry ls : wireframeShapes.keySet()) {
// if (ls instanceof LineString) {
// LineString string = (LineString) ls;
// for (int i = 0; i < string.getNumPoints(); i++) {
// target.drawPoint(string.getPointN(i).getX(), string
// .getPointN(i).getY(), 0, colorable.getColor(),
// PointStyle.BOX, magnification.getMagnification()
// .floatValue());
// DrawableString dString = new DrawableString(string
// .getPointN(i).getCoordinate().toString(),
// colorable.getColor());
// dString.basics.x = string.getPointN(i).getX();
// dString.basics.y = string.getPointN(i).getY();
// target.drawStrings(dString);
// }
// }
// }
for (IWireframeShape sh : wireframeShapes.values()) { for (IWireframeShape sh : wireframeShapes.values()) {
target.drawWireframeShape(sh, colorable.getColor(), target.drawWireframeShape(sh, color,
(float) outline.getOutlineWidth(), outline.getLineStyle()); (float) outline.getOutlineWidth(), outline.getLineStyle());
} }
for (Geometry g : this.tempGeometries) { for (Geometry g : this.tempGeometries) {
drawTempLinePrimitive(g, tempWireframeShape); drawTempLinePrimitive(g, tempWireframeShape);
} }
// if (erase) { target.drawWireframeShape(tempWireframeShape, color,
// target.drawWireframeShape(tempWireframeShape, new RGB(255, 0, 0),
// 1.0f);
// } else {
target.drawWireframeShape(tempWireframeShape, colorable.getColor(),
outline.getOutlineWidth(), outline.getLineStyle()); outline.getOutlineWidth(), outline.getLineStyle());
// }
} }
/**
* Add the geometry to the wireframe shape that is passed in
*
* @param shape
* @param wShape
*/
private void drawTempLinePrimitive(Geometry shape, IWireframeShape wShape) { private void drawTempLinePrimitive(Geometry shape, IWireframeShape wShape) {
LineString line = (LineString) shape; LineString line = (LineString) shape;
@ -225,6 +214,8 @@ public class DrawingLayer extends
public void finalizeLine(LineString line, String uuid) { public void finalizeLine(LineString line, String uuid) {
tempWireframeShape.compile(); tempWireframeShape.compile();
wireframeShapes.put(line, tempWireframeShape); wireframeShapes.put(line, tempWireframeShape);
DrawingEvent event = new DrawingEvent(line, null);
eventBus.post(event);
} }
public void addTempDrawLine(LineString line) { public void addTempDrawLine(LineString line) {
@ -232,7 +223,7 @@ public class DrawingLayer extends
} }
public void addTempEraseLine(LineString line) { public void addTempEraseLine(LineString line) {
this.tempGeometries.add(line); // this.tempGeometries.add(line);
Map<Geometry, IWireframeShape> shapes = new HashMap<Geometry, IWireframeShape>(); Map<Geometry, IWireframeShape> shapes = new HashMap<Geometry, IWireframeShape>();
shapes.putAll(wireframeShapes); shapes.putAll(wireframeShapes);
for (Geometry geom : shapes.keySet()) { for (Geometry geom : shapes.keySet()) {
@ -244,7 +235,12 @@ public class DrawingLayer extends
if (line.buffer(size / 2).intersects(geom)) { if (line.buffer(size / 2).intersects(geom)) {
Geometry intersection = line.buffer(size / 2) Geometry intersection = line.buffer(size / 2)
.intersection(geom); .intersection(geom);
Geometry finalGeom = geom.difference(intersection); Geometry finalGeom = null;
try {
finalGeom = geom.difference(intersection);
} catch (TopologyException e) {
continue;
}
deletedShapes.put(geom, wireframeShapes.remove(geom)); deletedShapes.put(geom, wireframeShapes.remove(geom));
Geometry lString = null; Geometry lString = null;
@ -259,7 +255,6 @@ public class DrawingLayer extends
drawTempLinePrimitive(lineString, eraseWireframeShape); drawTempLinePrimitive(lineString, eraseWireframeShape);
this.wireframeShapes.put(lineString, this.wireframeShapes.put(lineString,
eraseWireframeShape); eraseWireframeShape);
erasedShapes.add(eraseWireframeShape);
} }
} }
if (finalGeom instanceof LineString) { if (finalGeom instanceof LineString) {
@ -273,14 +268,8 @@ public class DrawingLayer extends
descriptor); descriptor);
drawTempLinePrimitive(lString, eraseWireframeShape); drawTempLinePrimitive(lString, eraseWireframeShape);
this.wireframeShapes.put(lString, eraseWireframeShape); this.wireframeShapes.put(lString, eraseWireframeShape);
erasedShapes.add(eraseWireframeShape);
} else { } else {
lString = (GeometryCollection) finalGeom; // do nothing
// for (int j = 0; j < lString.getNumGeometries(); j++) {
// System.out.println(lString.getGeometryN(j).getClass());
// }
// System.out.println(finalGeom.getClass() + " has "
// + lString.getNumGeometries() + " geometries");
} }
} }
tempGeometries.clear(); tempGeometries.clear();
@ -293,8 +282,10 @@ public class DrawingLayer extends
issueRefresh(); issueRefresh();
} }
/**
* reset the temporary geometries so that we can start a new line
*/
public void resetTemp() { public void resetTemp() {
// this.tempWireframeShape.dispose();
this.tempGeometries.clear(); this.tempGeometries.clear();
needsRefresh = true; needsRefresh = true;
} }
@ -344,23 +335,7 @@ public class DrawingLayer extends
} }
/** /**
* Add items to the right click menu, in this case just a button to launch * @return are you currently erasing
* the Drawing toolbar
*/
@Override
public void addContextMenuItems(IMenuManager menuManager, int x, int y) {
ResourcePair pair = new ResourcePair();
pair.setResource(this);
Action action = new Action("Draw Toolbar...") {
public void run() {
PathToolbar.getToolbar().open();
};
};
menuManager.add(action);
}
/**
* @return the erase
*/ */
public boolean isErase() { public boolean isErase() {
return erase; return erase;
@ -368,23 +343,39 @@ public class DrawingLayer extends
/** /**
* @param erase * @param erase
* the erase to set * to erase or not to erase
*/ */
public void setErase(boolean erase) { public void setErase(boolean erase) {
this.erase = erase; this.erase = erase;
} }
/** /**
* @return the deletedShapes * @return the deletedShapes, these shapes will get disposed when the clear
* button is selected
*/ */
public Map<Geometry, IWireframeShape> getDeletedShapes() { public Map<Geometry, IWireframeShape> getDeletedShapes() {
return deletedShapes; return deletedShapes;
} }
/** /**
* @return the wireframeShapes * @return the wireframeShapes, these shapes will get disposed when the
* clear button is selected
*/ */
public Map<Geometry, IWireframeShape> getWireframeShapes() { public Map<Geometry, IWireframeShape> getWireframeShapes() {
return wireframeShapes; return wireframeShapes;
} }
}
/**
* @return the eventBus
*/
public EventBus getEventBus() {
return eventBus;
}
/**
* @return the eventListener
*/
public DrawingListener getEventListener() {
return eventListener;
}
}

View file

@ -37,7 +37,8 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.contexts.IContextService;
import com.raytheon.uf.viz.core.IDisplayPane; import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.icon.IconUtil; import com.raytheon.uf.viz.core.icon.IconUtil;
@ -46,12 +47,12 @@ import com.raytheon.uf.viz.drawing.actions.ClearDrawingAction;
import com.raytheon.uf.viz.drawing.actions.EraseObjectsAction; import com.raytheon.uf.viz.drawing.actions.EraseObjectsAction;
import com.raytheon.uf.viz.drawing.actions.RedoAddAction; import com.raytheon.uf.viz.drawing.actions.RedoAddAction;
import com.raytheon.uf.viz.drawing.actions.UndoAddAction; import com.raytheon.uf.viz.drawing.actions.UndoAddAction;
import com.raytheon.uf.viz.drawing.events.DrawingEvent;
import com.raytheon.uf.viz.drawing.events.DrawingEventBus;
import com.raytheon.uf.viz.drawing.tools.PathDrawingTool; import com.raytheon.uf.viz.drawing.tools.PathDrawingTool;
import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.editor.AbstractEditor; import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.editor.ISelectedPanesChangedListener;
import com.raytheon.viz.ui.editor.VizMultiPaneEditor;
/** /**
* TODO Add Description * TODO Add Description
@ -70,13 +71,14 @@ import com.raytheon.viz.ui.editor.VizMultiPaneEditor;
* @version 1.0 * @version 1.0
*/ */
public class PathToolbar extends CaveSWTDialog implements public class PathToolbar extends CaveSWTDialog {
ISelectedPanesChangedListener {
private static PathToolbar toolbar; protected static PathToolbar pathToolbar;
// private Map<AbstractEditor, ResourcePair> layers; // private Map<AbstractEditor, ResourcePair> layers;
protected ToolBar toolbar;
private ToolItem drawItem; private ToolItem drawItem;
private ToolItem eraserItem; private ToolItem eraserItem;
@ -90,10 +92,11 @@ public class PathToolbar extends CaveSWTDialog implements
private IContextActivation drawingContext; private IContextActivation drawingContext;
public static PathToolbar getToolbar() { public static PathToolbar getToolbar() {
if (toolbar == null) { if (pathToolbar == null) {
toolbar = new PathToolbar(new Shell(Display.getCurrent())); pathToolbar = new PathToolbar(new Shell(Display.getCurrent()));
DrawingEventBus.register(PathToolbar.getToolbar());
} }
return toolbar; return pathToolbar;
} }
/** /**
@ -142,7 +145,7 @@ public class PathToolbar extends CaveSWTDialog implements
layout.marginHeight = 0; layout.marginHeight = 0;
layout.marginWidth = 0; layout.marginWidth = 0;
ToolBar toolbar = new ToolBar(comp, SWT.FLAT); toolbar = new ToolBar(comp, SWT.FLAT);
layout = new GridLayout(); layout = new GridLayout();
layout.marginHeight = 0; layout.marginHeight = 0;
@ -169,8 +172,8 @@ public class PathToolbar extends CaveSWTDialog implements
eraserItem.setSelection(false); eraserItem.setSelection(false);
} }
} }
PathDrawingTool tool = new PathDrawingTool();
tool.activate(); startTool();
// ((VizMultiPaneEditor) editor) // ((VizMultiPaneEditor) editor)
// .addSelectedPaneChangedListener(PathToolbar // .addSelectedPaneChangedListener(PathToolbar
// .getToolbar()); // .getToolbar());
@ -234,7 +237,6 @@ public class PathToolbar extends CaveSWTDialog implements
executeAction(action); executeAction(action);
} }
}); });
updateToolbar();
} }
@Override @Override
@ -243,6 +245,7 @@ public class PathToolbar extends CaveSWTDialog implements
.getWorkbench().getService(IContextService.class); .getWorkbench().getService(IContextService.class);
drawingContext = contextService drawingContext = contextService
.activateContext("com.raytheon.uf.viz.drawing.context"); .activateContext("com.raytheon.uf.viz.drawing.context");
updateToolbar();
super.opened(); super.opened();
} }
@ -254,29 +257,14 @@ public class PathToolbar extends CaveSWTDialog implements
} }
} }
/* @AllowConcurrentEvents
* (non-Javadoc) @Subscribe
* public void handleMessage(DrawingEvent event) {
* @see updateToolbar();
* com.raytheon.viz.ui.editor.ISelectedPanesChangedListener#selectedPanesChanged
* (java.lang.String, com.raytheon.uf.viz.core.IDisplayPane[])
*/
@Override
public void selectedPanesChanged(String id, IDisplayPane[] pane) {
AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class);
IDescriptor desc = editor.getActiveDisplayPane().getDescriptor();
((VizMultiPaneEditor) editor)
.addSelectedPaneChangedListener(PathToolbar.getToolbar());
for (ResourcePair pair : desc.getResourceList()) {
if (pair.getResource() instanceof DrawingLayer) {
break;
}
}
} }
private void updateToolbar() { public void updateToolbar() {
if (true) { if (this.isDisposed()) {
return; return;
} }
AbstractEditor editor = EditorUtil AbstractEditor editor = EditorUtil
@ -294,17 +282,13 @@ public class PathToolbar extends CaveSWTDialog implements
} else { } else {
clearItem.setEnabled(true); clearItem.setEnabled(true);
if (layer.getDeletedShapes().isEmpty()) { if (layer.getDeletedShapes().isEmpty()) {
undoItem.setEnabled(true);
redoItem.setEnabled(false); redoItem.setEnabled(false);
} else { } else {
undoItem.setEnabled(false);
redoItem.setEnabled(true); redoItem.setEnabled(true);
} }
if (layer.getWireframeShapes().isEmpty()) { if (layer.getWireframeShapes().isEmpty()) {
redoItem.setEnabled(true);
undoItem.setEnabled(false); undoItem.setEnabled(false);
} else { } else {
redoItem.setEnabled(false);
undoItem.setEnabled(true); undoItem.setEnabled(true);
} }
} }
@ -312,4 +296,11 @@ public class PathToolbar extends CaveSWTDialog implements
} }
} }
/**
*
*/
protected void startTool() {
PathDrawingTool tool = new PathDrawingTool();
tool.activate();
}
} }

View file

@ -26,6 +26,7 @@ import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer; import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.uf.viz.drawing.events.DrawingEvent;
import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor; import com.raytheon.viz.ui.editor.AbstractEditor;
@ -56,6 +57,8 @@ public class RedoAddAction extends AbstractHandler {
for (ResourcePair pair : list) { for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) { if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource()).redoAdd(); ((DrawingLayer) pair.getResource()).redoAdd();
((DrawingLayer) pair.getResource()).getEventBus().post(
new DrawingEvent(null, null));
break; break;
} }
} }

View file

@ -26,6 +26,7 @@ import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.drawing.DrawingLayer; import com.raytheon.uf.viz.drawing.DrawingLayer;
import com.raytheon.uf.viz.drawing.events.DrawingEvent;
import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.AbstractEditor; import com.raytheon.viz.ui.editor.AbstractEditor;
@ -42,7 +43,6 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* *
* </pre> * </pre>
* *
* @author mnash
* @version 1.0 * @version 1.0
*/ */
@ -56,6 +56,8 @@ public class UndoAddAction extends AbstractHandler {
for (ResourcePair pair : list) { for (ResourcePair pair : list) {
if (pair.getResource() instanceof DrawingLayer) { if (pair.getResource() instanceof DrawingLayer) {
((DrawingLayer) pair.getResource()).undoAdd(); ((DrawingLayer) pair.getResource()).undoAdd();
((DrawingLayer) pair.getResource()).getEventBus().post(
new DrawingEvent(null, null));
break; break;
} }
} }

View file

@ -0,0 +1,66 @@
/**
* 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.drawing.events;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.vividsolutions.jts.geom.Geometry;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 2, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class DrawingEvent {
private AbstractEditor editor;
private Geometry geom;
public DrawingEvent(Geometry geom, AbstractEditor editor) {
this.geom = geom;
this.editor = editor;
}
/**
* @return the geom
*/
public Geometry getGeom() {
return geom;
}
/**
* @return the editor
*/
public AbstractEditor getEditor() {
return editor;
}
}

View file

@ -0,0 +1,74 @@
/**
* 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.drawing.events;
import com.google.common.eventbus.EventBus;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 2, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class DrawingEventBus {
private static EventBus eventBus;
private static DrawingListener drawingListener;
/**
* @return the eventBus
*/
public static EventBus getEventBus() {
if (eventBus == null) {
eventBus = new EventBus("DrawingEventBus");
}
return eventBus;
}
/**
* @return the drawingListener
*/
public static DrawingListener getDrawingListener() {
if (drawingListener == null) {
drawingListener = new DrawingListener();
}
return drawingListener;
}
/**
* Send in class to register in the event bus
*
* @param ob
*/
public static void register(Object ob) {
getEventBus().register(ob);
}
}

View file

@ -0,0 +1,46 @@
/**
* 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.drawing.events;
import com.google.common.eventbus.Subscribe;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 2, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class DrawingListener {
@Subscribe
public void handleMessage(DrawingEvent event) {
}
}

View file

@ -52,7 +52,8 @@ public class PathDrawingTool extends AbstractDrawingTool {
protected IInputHandler theHandler; protected IInputHandler theHandler;
public AbstractResourceData constructData() { public AbstractResourceData constructData() {
return new PathDrawingResourceData(); PathDrawingResourceData data = new PathDrawingResourceData();
return data;
} }
/* /*
@ -179,8 +180,26 @@ public class PathDrawingTool extends AbstractDrawingTool {
theDrawingLayer.finalizeLine(ls, null); theDrawingLayer.finalizeLine(ls, null);
} }
} }
// this probably should be put elsewhere or genericized in some
// manner
// PathToolbar.getToolbar().updateToolbar();
editor.refresh(); editor.refresh();
return true; return true;
} }
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.tools.AbstractModalTool#activate()
*/
@Override
public void activate() {
super.activate();
theDrawingLayer.getCapability(EditableCapability.class).setEditable(
true);
theDrawingLayer.issueRefresh();
}
} }