Issue #427 send input events back as session leader

Change-Id: Ib1dacebdd94892bd9837b9bd91463bc6646fbccb

Former-commit-id: f881116fe4 [formerly 9d3c8321e5] [formerly 9885949b27] [formerly f881116fe4 [formerly 9d3c8321e5] [formerly 9885949b27] [formerly 2d822df43f [formerly 9885949b27 [formerly 16af3874c9416b75edc00b4ad928de8a30e47abf]]]]
Former-commit-id: 2d822df43f
Former-commit-id: 8e29ac4298 [formerly 09b67f9d5d] [formerly e612e2e02f64061e5327cbe2800fd693686911d0 [formerly 1b0975e7fa]]
Former-commit-id: 3a774bc55dab7360d249ad2214d77d072e8bbfae [formerly bdd6e1d211]
Former-commit-id: 4a010704a5
This commit is contained in:
Nate Jensen 2012-04-17 17:26:49 -05:00
parent c1dcff8853
commit 8361c24243
8 changed files with 39 additions and 169 deletions

View file

@ -162,6 +162,16 @@ public class EditorSetup {
"Cannot share a CollaborationEditor"); "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() IDescriptor desc = editor.getActiveDisplayPane().getRenderableDisplay()
.getDescriptor(); .getDescriptor();
GenericResourceData grd = new GenericResourceData( GenericResourceData grd = new GenericResourceData(
@ -176,13 +186,6 @@ public class EditorSetup {
.getVenueDescription()); .getVenueDescription());
rsc.setSubject(((IVenueSession) session).getVenue().getInfo() rsc.setSubject(((IVenueSession) session).getVenue().getInfo()
.getVenueSubject()); .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.collaboration.ui.rsc.CollaborationWrapperResourceData;
import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer; 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.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.core.rsc.ResourceList;
@ -104,10 +105,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
@Subscribe @Subscribe
public void roleTransferred(TransferRoleCommand cmd) { public void roleTransferred(TransferRoleCommand cmd) {
if (cmd.getRole() == ParticipantRole.SESSION_LEADER) { if (cmd.getRole() == ParticipantRole.SESSION_LEADER) {
System.out.println("Current session's username: " session.setCurrentSessionLeader(cmd.getUser());
+ session.getUserID().getFQName());
System.out.println("Command received username: "
+ cmd.getUser().getFQName());
if (cmd.getUser().getFQName() if (cmd.getUser().getFQName()
.equals(session.getUserID().getFQName())) { .equals(session.getUserID().getFQName())) {
// this cave should assume session leader control // this cave should assume session leader control
@ -125,11 +123,12 @@ public class DataProviderEventController extends AbstractRoleEventController {
@Subscribe @Subscribe
public void sessionLeaderInput(InputEvent event) { public void sessionLeaderInput(InputEvent event) {
// TODO needs to be based on the editor that is both shared and active // 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() .getSessionContainer(session.getSessionId()).getSharedEditors()
.get(0); .get(0);
IDisplayPane pane = editor.getDisplayPanes()[0]; IDisplayPane pane = editor.getDisplayPanes()[0];
Event swtEvent = new Event(); final Event swtEvent = new Event();
swtEvent.display = editor.getActiveDisplayPane().getDisplay();
// translate event type // translate event type
switch (event.getType()) { switch (event.getType()) {
@ -170,7 +169,7 @@ public class DataProviderEventController extends AbstractRoleEventController {
case MOUSE_WHEEL: case MOUSE_WHEEL:
case DOUBLE_CLICK: case DOUBLE_CLICK:
double[] screen = pane.gridToScreen(new double[] { event.getX(), double[] screen = pane.gridToScreen(new double[] { event.getX(),
event.getY() }); event.getY(), 0.0 });
swtEvent.x = (int) Math.round(screen[0]); swtEvent.x = (int) Math.round(screen[0]);
swtEvent.y = (int) Math.round(screen[1]); swtEvent.y = (int) Math.round(screen[1]);
break; break;
@ -193,7 +192,13 @@ public class DataProviderEventController extends AbstractRoleEventController {
break; 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 @Subscribe
public void roleTransferred(TransferRoleCommand cmd) { public void roleTransferred(TransferRoleCommand cmd) {
if (cmd.getRole() == ParticipantRole.SESSION_LEADER) { if (cmd.getRole() == ParticipantRole.SESSION_LEADER) {
System.out.println("Current session's username: " session.setCurrentSessionLeader(cmd.getUser());
+ session.getUserID().getFQName());
System.out.println("Command received username: "
+ cmd.getUser().getFQName());
if (cmd.getUser().getFQName() if (cmd.getUser().getFQName()
.equals(session.getUserID().getFQName())) { .equals(session.getUserID().getFQName())) {
// this cave should assume session leader control // 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), VenueParticipant vp = new VenueParticipant(Tools.parseName(fqname),
Tools.parseHost(fqname)); Tools.parseHost(fqname));
trc.setUser(vp); trc.setUser(vp);
session.setCurrentSessionLeader(vp);
trc.setRole(ParticipantRole.SESSION_LEADER); trc.setRole(ParticipantRole.SESSION_LEADER);
try { try {
session.sendObjectToVenue(trc); session.sendObjectToVenue(trc);
@ -174,7 +175,7 @@ public class CollaborationSessionView extends SessionView {
boolean isSessionLeader = Tools.parseName(user.getId()).equals( boolean isSessionLeader = Tools.parseName(user.getId()).equals(
session.getCurrentSessionLeader().getName()); session.getCurrentSessionLeader().getName());
boolean isDataProvider = Tools.parseName(user.getId()).equals( boolean isDataProvider = Tools.parseName(user.getId()).equals(
session.getCurrentSessionLeader().getName()); session.getCurrentDataProvider().getName());
if (isSessionLeader || isDataProvider) { if (isSessionLeader || isDataProvider) {
builder.append("-- Roles --"); builder.append("-- Roles --");
if (isSessionLeader) { 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.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider; import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image; 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.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; 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, public class ParticipantsLabelProvider implements ITableColorProvider,
ITableFontProvider, ITableLabelProvider { 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 List<ILabelProviderListener> listeners;
private String sessionId = null; private String sessionId = null;
@ -207,26 +200,6 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
if (image == null) { if (image == null) {
image = CollaborationUtils.getNodeImage(user); image = CollaborationUtils.getNodeImage(user);
// original image is 16x16 // 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(); image.getImageData();
imageMap.put(modKey.toString(), image); 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.IDisplayEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; 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.event.IRenderable;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; 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;
@ -66,16 +65,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
public interface ISharedDisplaySession extends IEventPublisher { 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 * @param event
@ -128,6 +117,10 @@ public interface ISharedDisplaySession extends IEventPublisher {
*/ */
public IVenueParticipant getCurrentSessionLeader(); public IVenueParticipant getCurrentSessionLeader();
public void setCurrentDataProvider(IVenueParticipant participant);
public void setCurrentSessionLeader(IVenueParticipant participant);
/** /**
* *
* @param role * @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.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; 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.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.IRenderable;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
@ -329,32 +328,6 @@ public class VenueSession extends BaseSession implements IVenueSession,
// ISharedDisplaySession // 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 * @param participant
@ -473,6 +446,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
&& !this.getUserID().equals(this.getCurrentSessionLeader())) { && !this.getUserID().equals(this.getCurrentSessionLeader())) {
result = false; result = false;
} }
System.out
.println(this.getUserID() + " hasRole " + role + " " + result);
return result; return result;
} }
@ -503,21 +478,13 @@ public class VenueSession extends BaseSession implements IVenueSession,
} }
} }
// *************************** @Override
// Internal methods public void setCurrentSessionLeader(IVenueParticipant id) {
// ***************************
/**
*
*/
protected void setCurrentSessionLeader(IVenueParticipant id) {
sessionLeader = id; sessionLeader = id;
} }
/** @Override
* public void setCurrentDataProvider(IVenueParticipant id) {
*/
protected void setCurrentDataProvider(IVenueParticipant id) {
dataProvider = id; dataProvider = id;
} }
@ -582,6 +549,9 @@ public class VenueSession extends BaseSession implements IVenueSession,
errorStatus = Errors.CANNOT_CONNECT; // is this correct? errorStatus = Errors.CANNOT_CONNECT; // is this correct?
} }
} catch (Exception e) { } 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)); System.out.println(String.format("createVenue(%s)", venueName));
e.printStackTrace(); e.printStackTrace();
errorStatus = Errors.BAD_NAME; errorStatus = Errors.BAD_NAME;