Issue #429 color fixes
Former-commit-id: 819a0b037d49993e56dc77207809dbf3903ea6ec
This commit is contained in:
parent
fdddff1957
commit
1b9c4320fc
12 changed files with 102 additions and 53 deletions
|
@ -25,8 +25,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.role.DataProviderEventController;
|
||||
import com.raytheon.uf.viz.collaboration.ui.role.IRoleEventController;
|
||||
import com.raytheon.uf.viz.collaboration.ui.role.ParticipantEventController;
|
||||
|
@ -64,7 +67,7 @@ public class SharedDisplaySessionMgr {
|
|||
}
|
||||
|
||||
protected static void joinSession(ISharedDisplaySession session,
|
||||
SharedDisplayRole initialRole) {
|
||||
SharedDisplayRole initialRole, Map<UserId, RGB> colors) {
|
||||
SessionContainer container = new SessionContainer();
|
||||
container.setSessionId(session.getSessionId());
|
||||
container.setSession(session);
|
||||
|
@ -92,6 +95,9 @@ public class SharedDisplaySessionMgr {
|
|||
"ParticipantRole must be DataProvider or Participant for initialization");
|
||||
}
|
||||
container.setRoleEventController(rec);
|
||||
if (colors != null) {
|
||||
container.getColorManager().setColors(colors);
|
||||
}
|
||||
sharedDisplaySessionMap.put(session.getSessionId(), container);
|
||||
|
||||
rec.startup();
|
||||
|
|
|
@ -117,10 +117,12 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||
gd.horizontalSpan = 2;
|
||||
publicCollaboration.setLayoutData(gd);
|
||||
publicCollaboration.setSelection(true);
|
||||
publicCollaboration.setText("Create Collaboration");
|
||||
|
||||
if (showInvite) {
|
||||
inviteUsers = new Button(body, SWT.CHECK);
|
||||
inviteUsers.setSelection(true);
|
||||
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||
gd.horizontalSpan = 2;
|
||||
inviteUsers.setLayoutData(gd);
|
||||
|
@ -134,7 +136,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
inviteLabel.setText("Message: ");
|
||||
inviteLabel.setToolTipText("Message to send to invited users");
|
||||
inviteMessageTF = new StyledText(body, SWT.BORDER | SWT.MULTI
|
||||
| SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
| SWT.WRAP | SWT.V_SCROLL);
|
||||
inviteMessageTF.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
inviteMessageTF.pack();
|
||||
inviteMessageTF.setToolTipText("Message to send to invited users");
|
||||
|
@ -158,8 +160,8 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
|
||||
}
|
||||
});
|
||||
inviteLabel.setVisible(false);
|
||||
inviteMessageTF.setVisible(false);
|
||||
inviteLabel.setVisible(true);
|
||||
inviteMessageTF.setVisible(true);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ public class SessionColorManager {
|
|||
colors.put(user, rgbPresets[count]);
|
||||
}
|
||||
|
||||
public void addColor(UserId id, RGB color) {
|
||||
colors.put(id, color);
|
||||
}
|
||||
|
||||
public void clearColors() {
|
||||
colors.clear();
|
||||
}
|
||||
|
|
|
@ -215,14 +215,14 @@ public abstract class AbstractSessionView extends ViewPart implements
|
|||
* @param message
|
||||
*/
|
||||
public void appendMessage(IMessage message) {
|
||||
String fqName = message.getFrom().getFQName();
|
||||
UserId userId = (UserId) message.getFrom();
|
||||
String name = message.getFrom().getName();
|
||||
long timestamp = message.getTimeStamp();
|
||||
String body = message.getBody();
|
||||
appendMessage(fqName, name, timestamp, body);
|
||||
appendMessage(userId, name, timestamp, body);
|
||||
}
|
||||
|
||||
public void appendMessage(String fqName, String name, long timestamp,
|
||||
public void appendMessage(UserId userId, String name, long timestamp,
|
||||
String body) {
|
||||
IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
|
||||
.getAdapter(IWorkbenchSiteProgressService.class);
|
||||
|
@ -231,7 +231,8 @@ public abstract class AbstractSessionView extends ViewPart implements
|
|||
// String fqName = message.getFrom().getFQName();
|
||||
// String name = message.getFrom().getName();
|
||||
if (name == null) {
|
||||
name = fqName.substring(0, fqName.indexOf("@"));
|
||||
name = userId.getFQName().substring(0,
|
||||
userId.getFQName().indexOf("@"));
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(timestamp);
|
||||
|
@ -263,13 +264,13 @@ public abstract class AbstractSessionView extends ViewPart implements
|
|||
}
|
||||
}
|
||||
|
||||
styleAndAppendText(sb, offset, name, fqName, ranges);
|
||||
styleAndAppendText(sb, offset, name, userId, ranges);
|
||||
// room for other fun things here, such as sounds and such
|
||||
executeSightsSounds();
|
||||
}
|
||||
|
||||
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
||||
String name, String fqName, List<StyleRange> ranges);
|
||||
String name, UserId userId, List<StyleRange> ranges);
|
||||
|
||||
/**
|
||||
* Find keys words in body of message starting at offset. /**
|
||||
|
|
|
@ -28,7 +28,6 @@ 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.Image;
|
||||
|
@ -36,6 +35,7 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
|
||||
|
@ -67,7 +67,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
|||
|
||||
protected Map<String, Image> imageMap;
|
||||
|
||||
protected Map<String, Color> colors;
|
||||
protected Map<UserId, Color> colors;
|
||||
|
||||
public ParticipantsLabelProvider() {
|
||||
listeners = new ArrayList<ILabelProviderListener>();
|
||||
|
@ -141,19 +141,30 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
|||
@Override
|
||||
public Color getForeground(Object element, int columnIndex) {
|
||||
if (colors == null) {
|
||||
colors = new HashMap<String, Color>();
|
||||
colors = new HashMap<UserId, Color>();
|
||||
}
|
||||
// String host = ((CollaborationUser) element).
|
||||
String id = ((CollaborationUser) element).getId();
|
||||
String[] uid = null;
|
||||
if (id != null) {
|
||||
uid = ((CollaborationUser) element).getId().split("@");
|
||||
}
|
||||
UserId userId = new UserId(uid[0], uid[1]);
|
||||
RGB color = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager().getColors().get(id);
|
||||
.getColorManager().getColors().get(userId);
|
||||
if (color == null) {
|
||||
userId.setHost("conference." + uid[1]);
|
||||
color = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager().getColors().get(userId);
|
||||
}
|
||||
|
||||
// add to map so we can dispose
|
||||
if (color == null) {
|
||||
colors.put(id, Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
|
||||
colors.put(userId, new Color(Display.getCurrent(), 0, 0, 0));
|
||||
} else {
|
||||
colors.put(id, new Color(Display.getCurrent(), color));
|
||||
colors.put(userId, new Color(Display.getCurrent(), color));
|
||||
}
|
||||
return colors.get(id);
|
||||
return colors.get(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
|
||||
/**
|
||||
|
@ -180,7 +181,7 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
IPeerToPeer p2p = (IPeerToPeer) manager.getSessionManager()
|
||||
.getPeerToPeerSession();
|
||||
p2p.sendPeerToPeer(peer, message);
|
||||
appendMessage(manager.getLoginId(), null,
|
||||
appendMessage((UserId) peer, manager.getLoginId(),
|
||||
System.currentTimeMillis(), message);
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
|
@ -192,9 +193,10 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
}
|
||||
|
||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||
String name, String fqName, List<StyleRange> ranges) {
|
||||
String name, UserId userId, List<StyleRange> ranges) {
|
||||
Color color = null;
|
||||
if (!fqName.equals(CollaborationDataManager.getInstance().getLoginId())) {
|
||||
if (!userId.getFQName().equals(
|
||||
CollaborationDataManager.getInstance().getLoginId())) {
|
||||
color = userColor;
|
||||
} else {
|
||||
color = chatterColor;
|
||||
|
|
|
@ -79,6 +79,7 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
|||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
|
||||
/**
|
||||
|
@ -121,7 +122,7 @@ public class SessionView extends AbstractSessionView {
|
|||
|
||||
protected Action chatAction;
|
||||
|
||||
protected Map<UserId, RGB> colors;
|
||||
protected SessionColorManager manager;
|
||||
|
||||
protected Map<RGB, Color> mappedColors;
|
||||
|
||||
|
@ -136,8 +137,8 @@ public class SessionView extends AbstractSessionView {
|
|||
createContextMenu();
|
||||
SharedDisplaySessionMgr.getSessionContainer(sessionId).getSession()
|
||||
.getEventPublisher().register(this);
|
||||
colors = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager().getColors();
|
||||
manager = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager();
|
||||
mappedColors = new HashMap<RGB, Color>();
|
||||
}
|
||||
|
||||
|
@ -418,9 +419,6 @@ public class SessionView extends AbstractSessionView {
|
|||
}
|
||||
mappedColors.clear();
|
||||
}
|
||||
if (colors != null) {
|
||||
colors.clear();
|
||||
}
|
||||
SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager().clearColors();
|
||||
super.dispose();
|
||||
|
@ -462,10 +460,12 @@ public class SessionView extends AbstractSessionView {
|
|||
*/
|
||||
@Override
|
||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||
String name, String fqName, List<StyleRange> ranges) {
|
||||
int index = fqName.indexOf("/");
|
||||
RGB rgb = colors.get(fqName.substring(0, index));
|
||||
String name, UserId userId, List<StyleRange> ranges) {
|
||||
RGB rgb = manager.getColorFromUser(userId);
|
||||
if (mappedColors.get(rgb) == null) {
|
||||
if (rgb == null) {
|
||||
rgb = new RGB(0, 0, 0);
|
||||
}
|
||||
Color col = new Color(Display.getCurrent(), rgb);
|
||||
mappedColors.put(rgb, col);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.collaboration.ui.telestrator;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
|
@ -38,6 +37,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorChangeEvent;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
|
||||
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent;
|
||||
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent.CollaborationEventType;
|
||||
|
@ -89,7 +89,7 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
|
||||
private String sessionId;
|
||||
|
||||
private Map<UserId, RGB> colors;
|
||||
private SessionColorManager colorManager;
|
||||
|
||||
private IWireframeShape tempRemoteShape = null;
|
||||
|
||||
|
@ -132,11 +132,11 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
this.deletedCollaboratorShapes = LinkedHashMultimap.create();
|
||||
this.deletedCollaboratorShapes = Multimaps
|
||||
.synchronizedMultimap(this.deletedCollaboratorShapes);
|
||||
colors = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager().getColors();
|
||||
colorManager = SharedDisplaySessionMgr.getSessionContainer(sessionId)
|
||||
.getColorManager();
|
||||
LoginData data = CollaborationDataManager.getInstance().getLoginData();
|
||||
UserId id = new UserId(data.getUser(), data.getServer());
|
||||
color = colors.get(id);
|
||||
color = colorManager.getColors().get(id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -164,7 +164,7 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
for (UserId userName : collaboratorShapes.keySet()) {
|
||||
for (ShapeContainer sh : collaboratorShapes.get(userName)) {
|
||||
if (sh != null) {
|
||||
color = colors.get(userName);
|
||||
color = colorManager.getColors().get(userName);
|
||||
if (color == null) {
|
||||
color = new RGB(255, 0, 0);
|
||||
}
|
||||
|
@ -179,11 +179,8 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
|
||||
@Subscribe
|
||||
public void setColorEvent(ColorChangeEvent event) {
|
||||
if (CollaborationDataManager.getInstance().getLoginId()
|
||||
.equals(event.getUserName())) {
|
||||
this.color = event.getColor();
|
||||
}
|
||||
colors.put(event.getUserName(), event.getColor());
|
||||
this.color = event.getColor();
|
||||
colorManager.addUser(event.getUserName());
|
||||
issueRefresh();
|
||||
}
|
||||
|
||||
|
@ -299,9 +296,18 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
* @param userName
|
||||
*/
|
||||
private void clearSelfShapes(UserId userName) {
|
||||
for (ShapeContainer cont : collaboratorShapes.get(userName)) {
|
||||
cont.getShape().dispose();
|
||||
// TODO, fix this
|
||||
for (UserId cont : collaboratorShapes.keySet()) {
|
||||
if (cont.getFQName().equals(userName.getFQName())) {
|
||||
for (ShapeContainer shape : collaboratorShapes.get(cont)) {
|
||||
shape.getShape().dispose();
|
||||
}
|
||||
collaboratorShapes.removeAll(cont);
|
||||
}
|
||||
}
|
||||
// for (ShapeContainer cont : collaboratorShapes.get(userName)) {
|
||||
// cont.getShape().dispose();
|
||||
// }
|
||||
collaboratorShapes.removeAll(userName);
|
||||
}
|
||||
|
||||
|
@ -423,8 +429,9 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
super.reset();
|
||||
CollaborationDrawingEvent event = new CollaborationDrawingEvent();
|
||||
event.setType(CollaborationEventType.CLEAR);
|
||||
// TODO, fix
|
||||
// event.setUserName(CollaborationDataManager.getInstance().getLoginId());
|
||||
LoginData data = CollaborationDataManager.getInstance().getLoginData();
|
||||
UserId userId = new UserId(data.getUser(), data.getServer());
|
||||
event.setUserName(userId);
|
||||
sendGenericEvent(event);
|
||||
}
|
||||
|
||||
|
@ -455,10 +462,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
|
|||
// }
|
||||
}
|
||||
|
||||
public void addColor(UserId userName, RGB color) {
|
||||
colors.put(userName, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the allowDraw
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.comm.provider.event;
|
||||
package com.raytheon.uf.viz.collaboration.comm.identity.invite;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
|
@ -19,10 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.collaboration.comm.identity.invite;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
|
||||
|
@ -43,6 +45,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class SharedDisplayVenueInvite extends VenueInvite {
|
||||
|
||||
@DynamicSerializeElement
|
||||
|
@ -52,7 +55,7 @@ public class SharedDisplayVenueInvite extends VenueInvite {
|
|||
private UserId dataProvider;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Map<UserId, RGB> colors;
|
||||
private ColorPopulator colors;
|
||||
|
||||
public UserId getSessionLeader() {
|
||||
return sessionLeader;
|
||||
|
@ -73,7 +76,7 @@ public class SharedDisplayVenueInvite extends VenueInvite {
|
|||
/**
|
||||
* @return the colors
|
||||
*/
|
||||
public Map<UserId, RGB> getColors() {
|
||||
public ColorPopulator getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
@ -81,7 +84,22 @@ public class SharedDisplayVenueInvite extends VenueInvite {
|
|||
* @param colors
|
||||
* the colors to set
|
||||
*/
|
||||
public void setColors(Map<UserId, RGB> colors) {
|
||||
public void setColors(ColorPopulator colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public Map<UserId, RGB> getRGBColors() {
|
||||
Map<UserId, RGB> map = new HashMap<UserId, RGB>();
|
||||
for (int i = 0; i < colors.getUserName().size(); i++) {
|
||||
RGB rgb = new RGB(colors.getRed().get(i), colors.getGreen().get(i),
|
||||
colors.getBlue().get(i));
|
||||
map.put(colors.getUserName().get(i), rgb);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setRGBColors(Map<UserId, RGB> colors) {
|
||||
ColorPopulator pop = new ColorPopulator(colors);
|
||||
this.colors = pop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,8 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
getConnectionNamespace(), id);
|
||||
|
||||
try {
|
||||
sender.sendInvitation(roomId, userId, subject, msgBody);
|
||||
sender.sendInvitation(roomId, userId, invite.getSubject(),
|
||||
msgBody);
|
||||
} catch (ECFException e) {
|
||||
throw new CollaborationException("Error sending invitation", e);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ public class DrawingLayer extends
|
|||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
this.paintProps = paintProps;
|
||||
color = getCapability(ColorableCapability.class).getColor();
|
||||
if (tempWireframeShape == null || needsRefresh) {
|
||||
tempWireframeShape = target.createWireframeShape(true,
|
||||
getDescriptor());
|
||||
|
|
Loading…
Add table
Reference in a new issue