Issue #427 initial role based event handling

Change-Id: I73d4df3f09c7cfa60025142ec5a4dccdad4423bb

Former-commit-id: e76039c56e [formerly bac31f3613] [formerly 4d7a53c583] [formerly 619d19e24c [formerly 4d7a53c583 [formerly b752ced02d726771a6e11a9982967a892d2e55f3]]]
Former-commit-id: 619d19e24c
Former-commit-id: 4440838cbe883a84c237cc8d0f49c75f814df106 [formerly 62b16fef0d]
Former-commit-id: 998c9df260
This commit is contained in:
Nate Jensen 2012-03-26 13:05:01 -05:00
parent c442754471
commit 0e9194429e
10 changed files with 354 additions and 51 deletions

View file

@ -131,4 +131,13 @@
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor"
default="true"
id="com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor"
name="Map">
</editor>
</extension>
</plugin>

View file

@ -104,7 +104,8 @@ public class EditorSetup {
return se;
}
public static void createEditor(SharedEditor sharedEditor) {
public static CollaborationEditor createEditor(SharedEditor sharedEditor) {
CollaborationEditor editor = null;
AbstractRenderableDisplay[] displays = new AbstractRenderableDisplay[1];
try {
// TODO make it work with any IDescriptor and
@ -133,12 +134,12 @@ public class EditorSetup {
disp.setExtent(extent);
displays[0] = disp;
UiUtil.createEditor(CollaborationEditor.EDITOR_ID, displays);
editor = (CollaborationEditor) UiUtil.createEditor(
CollaborationEditor.EDITOR_ID, displays);
} catch (VizException e) {
// TODO Auto-generated catch block. Please revise as appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return editor;
}
// TODO delete

View file

@ -32,6 +32,7 @@ import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.adapters.GridGeometryAdapter;
import com.raytheon.uf.common.serialization.adapters.JTSEnvelopeAdapter;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.vividsolutions.jts.geom.Envelope;
@ -55,7 +56,7 @@ import com.vividsolutions.jts.geom.Envelope;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class SharedEditor implements ISerializableObject {
public class SharedEditor implements ISerializableObject, IInitData {
/** The geometry of the descriptor */
private GeneralGridGeometry geometry;

View file

@ -0,0 +1,60 @@
/**
* 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.provider.session.VenueSession;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public abstract class AbstractRoleEventController implements
IRoleEventController {
protected VenueSession session;
protected AbstractRoleEventController(VenueSession session) {
this.session = session;
}
@Override
public void startup() {
session.registerEventHandler(this);
}
@Override
public void shutdown() {
session.unRegisterEventHandler(this);
}
}

View file

@ -0,0 +1,82 @@
/**
* 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.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.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession;
import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup;
import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditor;
import com.raytheon.viz.ui.VizWorkbenchManager;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* Handles the events of a session that are specific to the Data Provider role.
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class DataProviderEventController extends AbstractRoleEventController {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DataProviderEventController.class);
private VenueSession session;
public DataProviderEventController(VenueSession session) {
super(session);
}
@Subscribe
public void participantChanged(VenueParticipantEvent event) {
if (event.getEventType().equals(ParticipantEventType.ARRIVED)) {
// TODO instead of going to active editor, should get ones
// specifically shared with this session
AbstractEditor editor = (AbstractEditor) VizWorkbenchManager
.getInstance().getActiveEditor();
SharedEditor se = EditorSetup.extractSharedEditor(editor);
try {
session.sendInitData(event.getParticipant(), se);
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM,
"Error sending initialization data to new participant "
+ event.getParticipant().getName(), e);
}
}
}
}

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.collaboration.ui.role;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public interface IRoleEventController {
public void startup();
public void shutdown();
}

View file

@ -0,0 +1,67 @@
/**
* 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.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData;
import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession;
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.editor.EditorSetup;
import com.raytheon.uf.viz.collaboration.ui.editor.SharedEditor;
/**
* Handles the events of a session that are specific to the Participant role.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class ParticipantEventController extends AbstractRoleEventController {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ParticipantEventController.class);
public ParticipantEventController(VenueSession session) {
super(session);
}
@Subscribe
public void initDataArrived(IInitData initData) {
if (initData instanceof SharedEditor) {
SharedEditor se = (SharedEditor) initData;
CollaborationEditor editor = EditorSetup.createEditor(se);
// TODO need to send the editor somewhere so it can be tied to the
// session for the link to editor capability
}
}
}

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.collaboration.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
@ -38,8 +39,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
* venue.</li>
* <li><strong>TextMessage</strong> : Text messages send between users. Meant to
* be displayed as conversation.</li>
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE
* events</li>
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE events</li>
* <li><strong>IRenderable</strong> : These messages are CAVE to CAVE
* display......</li>
*
@ -61,33 +61,35 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
*/
public interface ISharedDisplaySession extends IEventPublisher {
/**
* Send a single initialization object to a participant who has joined an
* in-progress collaboration session.
* in-progress collaboration session.
*
* @param participant
* @param initData
*/
void sendInitData(IChatID participant, Object initData) throws CollaborationException;
void sendInitData(IChatID participant, IInitData initData)
throws CollaborationException;
/**
*
* @param event
*/
void sendEvent(IDisplayEvent event) throws CollaborationException;
/**
*
*/
void sendRenderableObject(IRenderable renderable) throws CollaborationException;
void sendRenderableObject(IRenderable renderable)
throws CollaborationException;
/**
*
* @return
*/
IChatID getCurrentDataProvider();
/**
*
* @return
@ -100,22 +102,24 @@ public interface ISharedDisplaySession extends IEventPublisher {
* @return
*/
boolean hasRole(ParticipantRole role);
/**
*
* @return
*/
IQualifiedID getUserID();
/**
* Gets the connection status of the session.
*
* @return The connection status.
*/
boolean isConnected();
/**
* Get the session identifier.
* @return The session identifier.
*
* @return The session identifier.
*/
String getSessionId();

View file

@ -0,0 +1,41 @@
/**
* 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.comm.identity.event;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public interface IInitData {
}

View file

@ -20,24 +20,19 @@
package com.raytheon.uf.viz.collaboration.comm.provider.session;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.presence.IIMMessageEvent;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.IPresenceSender;
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationSender;
@ -46,7 +41,6 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomMessage;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageEvent;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageSender;
import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
import org.eclipse.ecf.presence.im.IChatMessage;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import com.google.common.eventbus.EventBus;
@ -57,6 +51,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
@ -65,7 +60,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.listener.IInvitation;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IPresenceListener;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IVenueParticipantListener;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
@ -231,22 +225,23 @@ public class VenueSession extends BaseSession implements IVenueSession,
} finally {
initListeners();
}
Runnable r = new Runnable() {
@Override
public void run() {
for(int i = 0;i < 10;i++) {
for (int i = 0; i < 10; i++) {
IRenderable r = new TestObject("Test1");
((TestObject) r).setValue(i);
try {
System.out.println("Sending renderable " + i);
sendRenderableObject(r);
if(i == 5) {
sendTextMessage(Tools.marshallData("This is a text message as a String"));
if (i == 5) {
sendTextMessage(Tools
.marshallData("This is a text message as a String"));
}
} catch (CollaborationException ce) {
ce.printStackTrace();
}
@ -259,18 +254,20 @@ public class VenueSession extends BaseSession implements IVenueSession,
};
Thread t = new Thread(r);
t.start();
registerEventHandler(this);
}
@Subscribe
public void handle(IRenderable renderable) {
System.out.println("IRenderable " + renderable.getClass().getName() + " was received");
System.out.println("IRenderable " + renderable.getClass().getName()
+ " was received");
}
@Subscribe
public void handle(IDisplayEvent event) {
System.out.println("IDisplayEvent " + event.getClass().getName() + " was received");
System.out.println("IDisplayEvent " + event.getClass().getName()
+ " was received");
}
@Subscribe
@ -280,9 +277,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
@Subscribe
public void handle(IVenueParticipantEvent event) {
System.out.println("IVenueParticipantEvent " + event.getEventType() + " was received");
System.out.println("IVenueParticipantEvent " + event.getEventType()
+ " was received");
}
/**
*
* @throws ECFException
@ -630,18 +628,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
// ISharedDisplaySession
// ***************************
/**
*
* @param
* @param
* @throws CollaborationException
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendInitData(com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID,
* java.lang.Object)
*/
@Override
public void sendInitData(
com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant,
Object initData) throws CollaborationException {
IInitData initData) throws CollaborationException {
PeerToPeerChat session = null;
session = getP2PSession();
@ -663,7 +653,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
public void sendEvent(IDisplayEvent event) throws CollaborationException {
if (event != null) {
String message = Tools.marshallData(event);
if(message != null) {
if (message != null) {
sendTextMessage(message);
}
}
@ -679,7 +669,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
throws CollaborationException {
if (renderable != null) {
String message = Tools.marshallData(renderable);
if(message != null) {
if (message != null) {
sendTextMessage(message);
}
}
@ -687,7 +677,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
/**
* Get the identification of the user who is the DataProvider.
* @return The DataProvider user identification.
*
* @return The DataProvider user identification.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentDataProvider()
*/
@Override
@ -697,6 +688,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
/**
* Get the identification of the user who is the Session Leader.
*
* @return The Session Leader user identification.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentSessionLeader()
*/
@ -773,10 +765,10 @@ public class VenueSession extends BaseSession implements IVenueSession,
Object o = null;
try {
o = Tools.unMarshallData(body);
if(o != null) {
if (o != null) {
getEventPublisher().post(o);
}
} catch(CollaborationException ce) {
} catch (CollaborationException ce) {
// TODO : more robust!!
ce.printStackTrace();
}