Issue #427 send input events back as session leader

Change-Id: Ib1dacebdd94892bd9837b9bd91463bc6646fbccb

Former-commit-id: 2d822df43f [formerly 9885949b27 [formerly 16af3874c9416b75edc00b4ad928de8a30e47abf]]
Former-commit-id: 9885949b27
Former-commit-id: 9d3c8321e5
This commit is contained in:
Nate Jensen 2012-04-17 17:26:49 -05:00
parent ee7595c10b
commit f881116fe4
8 changed files with 39 additions and 169 deletions

View file

@ -162,6 +162,16 @@ public class EditorSetup {
"Cannot share a CollaborationEditor");
}
addIndicator(editor, session);
// TODO this method should be called by the ShareEditorAction
// TODO should max's target injection be over here too?
}
private static void addIndicator(AbstractEditor editor,
ISharedDisplaySession session) {
IDescriptor desc = editor.getActiveDisplayPane().getRenderableDisplay()
.getDescriptor();
GenericResourceData grd = new GenericResourceData(
@ -176,13 +186,6 @@ public class EditorSetup {
.getVenueDescription());
rsc.setSubject(((IVenueSession) session).getVenue().getInfo()
.getVenueSubject());
// TODO we need to track editors associated with a session
// TODO this method should be called by the ShareEditorAction
// TODO should max's target injection be over here too?
}
}

View file

@ -41,6 +41,7 @@ import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationWrapperResource;
import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationWrapperResourceData;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.ResourceList;
@ -104,10 +105,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
@Subscribe
public void roleTransferred(TransferRoleCommand cmd) {
if (cmd.getRole() == ParticipantRole.SESSION_LEADER) {
System.out.println("Current session's username: "
+ session.getUserID().getFQName());
System.out.println("Command received username: "
+ cmd.getUser().getFQName());
session.setCurrentSessionLeader(cmd.getUser());
if (cmd.getUser().getFQName()
.equals(session.getUserID().getFQName())) {
// this cave should assume session leader control
@ -125,11 +123,12 @@ public class DataProviderEventController extends AbstractRoleEventController {
@Subscribe
public void sessionLeaderInput(InputEvent event) {
// TODO needs to be based on the editor that is both shared and active
AbstractEditor editor = SharedDisplaySessionMgr
final AbstractEditor editor = SharedDisplaySessionMgr
.getSessionContainer(session.getSessionId()).getSharedEditors()
.get(0);
IDisplayPane pane = editor.getDisplayPanes()[0];
Event swtEvent = new Event();
final Event swtEvent = new Event();
swtEvent.display = editor.getActiveDisplayPane().getDisplay();
// translate event type
switch (event.getType()) {
@ -170,7 +169,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
case MOUSE_WHEEL:
case DOUBLE_CLICK:
double[] screen = pane.gridToScreen(new double[] { event.getX(),
event.getY() });
event.getY(), 0.0 });
swtEvent.x = (int) Math.round(screen[0]);
swtEvent.y = (int) Math.round(screen[1]);
break;
@ -193,7 +192,13 @@ public class DataProviderEventController extends AbstractRoleEventController {
break;
}
editor.getMouseManager().handleEvent(swtEvent);
VizApp.runAsync(new Runnable() {
@Override
public void run() {
editor.getMouseManager().handleEvent(swtEvent);
}
});
}
/*

View file

@ -154,10 +154,7 @@ public class ParticipantEventController extends AbstractRoleEventController {
@Subscribe
public void roleTransferred(TransferRoleCommand cmd) {
if (cmd.getRole() == ParticipantRole.SESSION_LEADER) {
System.out.println("Current session's username: "
+ session.getUserID().getFQName());
System.out.println("Command received username: "
+ cmd.getUser().getFQName());
session.setCurrentSessionLeader(cmd.getUser());
if (cmd.getUser().getFQName()
.equals(session.getUserID().getFQName())) {
// this cave should assume session leader control

View file

@ -152,6 +152,7 @@ public class CollaborationSessionView extends SessionView {
VenueParticipant vp = new VenueParticipant(Tools.parseName(fqname),
Tools.parseHost(fqname));
trc.setUser(vp);
session.setCurrentSessionLeader(vp);
trc.setRole(ParticipantRole.SESSION_LEADER);
try {
session.sendObjectToVenue(trc);
@ -174,7 +175,7 @@ public class CollaborationSessionView extends SessionView {
boolean isSessionLeader = Tools.parseName(user.getId()).equals(
session.getCurrentSessionLeader().getName());
boolean isDataProvider = Tools.parseName(user.getId()).equals(
session.getCurrentSessionLeader().getName());
session.getCurrentDataProvider().getName());
if (isSessionLeader || isDataProvider) {
builder.append("-- Roles --");
if (isSessionLeader) {

View file

@ -28,12 +28,9 @@ import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
@ -62,10 +59,6 @@ import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
public class ParticipantsLabelProvider implements ITableColorProvider,
ITableFontProvider, ITableLabelProvider {
private static int COLOR_SESSION_LEADER = SWT.COLOR_GREEN;
private static int COLOR_DATA_PROVIDER = SWT.COLOR_RED;
private List<ILabelProviderListener> listeners;
private String sessionId = null;
@ -207,26 +200,6 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
if (image == null) {
image = CollaborationUtils.getNodeImage(user);
// original image is 16x16
GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
int topColor = -1;
int bottomColor = -1;
if (roleCnt == 1) {
if (roles.contains(ParticipantRole.SESSION_LEADER)) {
topColor = COLOR_SESSION_LEADER;
bottomColor = COLOR_SESSION_LEADER;
} else {
topColor = COLOR_DATA_PROVIDER;
bottomColor = COLOR_DATA_PROVIDER;
}
} else {
topColor = COLOR_SESSION_LEADER;
bottomColor = COLOR_DATA_PROVIDER;
}
gc.setBackground(Display.getCurrent().getSystemColor(topColor));
gc.fillRectangle(0, 0, 16, 8);
gc.setBackground(Display.getCurrent().getSystemColor(bottomColor));
gc.fillRectangle(0, 8, 8, 8);
gc.dispose();
image.getImageData();
imageMap.put(modKey.toString(), image);
}

View file

@ -21,7 +21,6 @@ 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.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
@ -66,16 +65,6 @@ 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.
*
* @param participant
* @param initData
*/
void sendInitData(IQualifiedID participant, IInitData initData)
throws CollaborationException;
/**
*
* @param event
@ -128,6 +117,10 @@ public interface ISharedDisplaySession extends IEventPublisher {
*/
public IVenueParticipant getCurrentSessionLeader();
public void setCurrentDataProvider(IVenueParticipant participant);
public void setCurrentSessionLeader(IVenueParticipant participant);
/**
*
* @param role

View file

@ -1,72 +0,0 @@
/**
* 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.provider.session;
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.comm.identity.event.IInitData;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
@DynamicSerialize
public class InitData implements IInitData {
@DynamicSerializeElement
private String name;
public InitData() {
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View file

@ -48,7 +48,6 @@ 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;
@ -329,32 +328,6 @@ public class VenueSession extends BaseSession implements IVenueSession,
// ISharedDisplaySession
// ***************************
/**
*
* @param participant
* @param initData
* @throws CollaborationException
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendInitData(com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID,
* com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData)
*/
@Override
public void sendInitData(
com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant,
IInitData initData) throws CollaborationException {
PeerToPeerChat session = getP2PSession();
if (session != null) {
String message = Tools.marshallData(initData);
if (message != null) {
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
}
}
}
/**
*
* @param participant
@ -473,6 +446,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
&& !this.getUserID().equals(this.getCurrentSessionLeader())) {
result = false;
}
System.out
.println(this.getUserID() + " hasRole " + role + " " + result);
return result;
}
@ -503,21 +478,13 @@ public class VenueSession extends BaseSession implements IVenueSession,
}
}
// ***************************
// Internal methods
// ***************************
/**
*
*/
protected void setCurrentSessionLeader(IVenueParticipant id) {
@Override
public void setCurrentSessionLeader(IVenueParticipant id) {
sessionLeader = id;
}
/**
*
*/
protected void setCurrentDataProvider(IVenueParticipant id) {
@Override
public void setCurrentDataProvider(IVenueParticipant id) {
dataProvider = id;
}
@ -582,6 +549,9 @@ public class VenueSession extends BaseSession implements IVenueSession,
errorStatus = Errors.CANNOT_CONNECT; // is this correct?
}
} catch (Exception e) {
// TODO this is bad, we assume it's a bad venue name but it might
// not be
// and we'd give a poor error message
System.out.println(String.format("createVenue(%s)", venueName));
e.printStackTrace();
errorStatus = Errors.BAD_NAME;