Omaha #3709 unify collaboration color management
group chat session colors controlled by session color manager color config persistence moved to utility shared display uses same action to change colors as other sessions Change-Id: I8ba4a3fb4842e3f96f05ee6d16b7e81e9567f6d7 Former-commit-id:1c2d8e01d0
[formerly1c2d8e01d0
[formerly c0cd560fb1b6e8c04047c0d7b7d407e9072f0cec]] Former-commit-id:8cc1aa9f33
Former-commit-id:9a87cf77c5
This commit is contained in:
parent
4b253097a1
commit
61b3b6389e
25 changed files with 829 additions and 922 deletions
|
@ -38,6 +38,7 @@ import org.jivesoftware.smackx.muc.Occupant;
|
||||||
* Jan 30, 2014 2698 bclement reworked convertFromRoom for venue participants
|
* Jan 30, 2014 2698 bclement reworked convertFromRoom for venue participants
|
||||||
* Feb 3, 2014 2699 bclement fixed room id parsing when handle has special characters
|
* Feb 3, 2014 2699 bclement fixed room id parsing when handle has special characters
|
||||||
* Feb 13, 2014 2751 bclement VenueParticipant refactor
|
* Feb 13, 2014 2751 bclement VenueParticipant refactor
|
||||||
|
* Jan 13, 2015 3709 bclement added convertFromRoom that doesn't reference MUC
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -72,6 +73,24 @@ public class IDConverter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static VenueParticipant convertFromRoom(MultiUserChat room, String id) {
|
public static VenueParticipant convertFromRoom(MultiUserChat room, String id) {
|
||||||
|
VenueParticipant rval = convertFromRoom(id);
|
||||||
|
Occupant occupant;
|
||||||
|
if (room != null && (occupant = room.getOccupant(id)) != null) {
|
||||||
|
if (occupant.getJid() != null) {
|
||||||
|
// get actual user name
|
||||||
|
rval.setUserid(convertFrom(occupant.getJid()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse userId from room id string "room@host/handle".
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static VenueParticipant convertFromRoom(String id) {
|
||||||
String handle = StringUtils.parseResource(id);
|
String handle = StringUtils.parseResource(id);
|
||||||
if (handle == null || handle.trim().isEmpty()) {
|
if (handle == null || handle.trim().isEmpty()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -81,13 +100,6 @@ public class IDConverter {
|
||||||
String host = StringUtils.parseServer(cleanId);
|
String host = StringUtils.parseServer(cleanId);
|
||||||
String roomName = StringUtils.parseName(id);
|
String roomName = StringUtils.parseName(id);
|
||||||
VenueParticipant rval = new VenueParticipant(roomName, host, handle);
|
VenueParticipant rval = new VenueParticipant(roomName, host, handle);
|
||||||
Occupant occupant;
|
|
||||||
if (room != null && (occupant = room.getOccupant(id)) != null) {
|
|
||||||
if (occupant.getJid() != null) {
|
|
||||||
// get actual user name
|
|
||||||
rval.setUserid(convertFrom(occupant.getJid()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,15 @@
|
||||||
* 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.collaboration.ui.colors;
|
package com.raytheon.uf.viz.collaboration.display.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains foreground and background chat colors for a list of users or sites
|
* Contains foreground and background chat colors for a list of users or sites
|
||||||
*
|
*
|
||||||
|
@ -43,6 +39,8 @@ import org.eclipse.swt.graphics.RGB;
|
||||||
* Nov 26, 2014 3709 mapeters Renamed from UserColorInformation, added fgSet getter.
|
* Nov 26, 2014 3709 mapeters Renamed from UserColorInformation, added fgSet getter.
|
||||||
* Dec 08, 2014 3709 mapeters Removed fgSet and individual colors' getters/setters,
|
* Dec 08, 2014 3709 mapeters Removed fgSet and individual colors' getters/setters,
|
||||||
* set foreground and background together.
|
* set foreground and background together.
|
||||||
|
* Jan 13, 2015 3709 bclement moved from collaboration.ui to collaboration.display
|
||||||
|
* moved ColorInfo class to UserColorInfo
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -54,12 +52,25 @@ import org.eclipse.swt.graphics.RGB;
|
||||||
public class ColorInfoMap {
|
public class ColorInfoMap {
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
private Map<String, ColorInfo> colors;
|
private Map<String, UserColorInfo> colors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ColorInfoMap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param colors
|
||||||
|
*/
|
||||||
|
public ColorInfoMap(Map<String, UserColorInfo> colors) {
|
||||||
|
this.colors = colors;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the colors
|
* @return the colors
|
||||||
*/
|
*/
|
||||||
public Map<String, ColorInfo> getColors() {
|
public Map<String, UserColorInfo> getColors() {
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,58 +78,8 @@ public class ColorInfoMap {
|
||||||
* @param colors
|
* @param colors
|
||||||
* the colors to set
|
* the colors to set
|
||||||
*/
|
*/
|
||||||
public void setColors(Map<String, ColorInfo> colors) {
|
public void setColors(Map<String, UserColorInfo> colors) {
|
||||||
this.colors = colors;
|
this.colors = colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
|
||||||
public static class ColorInfo {
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int fgRed;
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int fgGreen;
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int fgBlue;
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int bgRed;
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int bgGreen;
|
|
||||||
|
|
||||||
@XmlAttribute
|
|
||||||
private int bgBlue;
|
|
||||||
|
|
||||||
public ColorInfo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type
|
|
||||||
* @return the RGB color of the given type
|
|
||||||
*/
|
|
||||||
public RGB getColor(int type) {
|
|
||||||
if (type == SWT.FOREGROUND) {
|
|
||||||
return new RGB(fgRed, fgGreen, fgBlue);
|
|
||||||
} else {
|
|
||||||
return new RGB(bgRed, bgGreen, bgBlue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fg
|
|
||||||
* @param bg
|
|
||||||
*/
|
|
||||||
public void setColors(RGB fg, RGB bg) {
|
|
||||||
fgRed = fg.red;
|
|
||||||
fgGreen = fg.green;
|
|
||||||
fgBlue = fg.blue;
|
|
||||||
bgRed = bg.red;
|
|
||||||
bgGreen = bg.green;
|
|
||||||
bgBlue = bg.blue;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -17,16 +17,13 @@
|
||||||
* 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.collaboration.ui.colors;
|
package com.raytheon.uf.viz.collaboration.display.data;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for color configuration managers to keep track of custom color
|
* Interface for color managers that keep track of color settings for users in a
|
||||||
* settings for users. Colors are tracked by a string key which could be the
|
* session or chat.
|
||||||
* user name or attribute (eg site name).
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -34,35 +31,39 @@ import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 08, 2015 3709 bclement Initial creation
|
* Jan 13, 2015 3709 bclement Initial creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bclement
|
* @author bclement
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public interface IColorConfigManager {
|
public interface IColorManager<T extends IUser> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set display colors
|
* Get assigned color for user
|
||||||
*
|
*
|
||||||
* @param key
|
* @param user
|
||||||
* @param foreground
|
|
||||||
* @param background
|
|
||||||
*/
|
|
||||||
public void setColors(String key, RGB foreground, RGB background);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get display colors
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ColorInfo getColor(String key);
|
public UserColorInfo getColorForUser(T user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign color to user
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param color
|
||||||
|
*/
|
||||||
|
public void setColorForUser(T user, UserColorInfo color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear color assignments
|
||||||
|
*/
|
||||||
|
public void clearColors();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return human readable description of color management
|
* @return human readable description of color management
|
||||||
*/
|
*/
|
||||||
public String getDescription(String key);
|
public String getDescription(T user);
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.viz.collaboration.display.data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ import com.raytheon.viz.core.ColorUtil;
|
||||||
* Mar 06, 2014 2848 bclement synchronized color access
|
* Mar 06, 2014 2848 bclement synchronized color access
|
||||||
* Jul 02, 2014 1255 bclement collaboration specific RGB presets
|
* Jul 02, 2014 1255 bclement collaboration specific RGB presets
|
||||||
* falls back to ColorUtil resource color presets
|
* falls back to ColorUtil resource color presets
|
||||||
|
* Jan 13, 2015 3709 bclement implements IColorManager, uses UserColorInfo
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -53,94 +55,129 @@ import com.raytheon.viz.core.ColorUtil;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SessionColorManager {
|
public class SessionColorManager implements IColorManager<VenueParticipant> {
|
||||||
|
|
||||||
public static final String SESSION_COLOR_PREFERENCE_KEY = "collaborationParticipantColor";
|
public static final String SESSION_COLOR_PREFERENCE_KEY = "collaborationParticipantColor";
|
||||||
|
|
||||||
private final Map<VenueParticipant, RGB> colors = new HashMap<VenueParticipant, RGB>();
|
protected final Map<VenueParticipant, UserColorInfo> colors = new HashMap<>();
|
||||||
|
|
||||||
private static final RGB[] rgbPresets;
|
private static final RGB[] foregroundPresets;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HierarchicalPreferenceStore prefs = (HierarchicalPreferenceStore) Activator
|
HierarchicalPreferenceStore prefs = (HierarchicalPreferenceStore) Activator
|
||||||
.getDefault().getPreferenceStore();
|
.getDefault().getPreferenceStore();
|
||||||
String[] names = prefs.getStringArray(SESSION_COLOR_PREFERENCE_KEY);
|
String[] names = prefs.getStringArray(SESSION_COLOR_PREFERENCE_KEY);
|
||||||
if (names.length > 0) {
|
if (names.length > 0) {
|
||||||
rgbPresets = new RGB[names.length];
|
foregroundPresets = new RGB[names.length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
rgbPresets[i++] = RGBColors.getRGBColor(name);
|
foregroundPresets[i++] = RGBColors.getRGBColor(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rgbPresets = ColorUtil.getResourceColorPresets();
|
foregroundPresets = ColorUtil.getResourceColorPresets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a map of venue participants to their assigned colors used for
|
* Get a map of venue participants to their assigned foreground colors
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<VenueParticipant, RGB> getColors() {
|
public Map<VenueParticipant, RGB> getForegroundColors() {
|
||||||
|
/*
|
||||||
|
* TODO the foreground specific methods are required since the shared
|
||||||
|
* display protocol doesn't support changing the background color as
|
||||||
|
* this would cause compatibility issues.
|
||||||
|
*/
|
||||||
Map<VenueParticipant, RGB> rval;
|
Map<VenueParticipant, RGB> rval;
|
||||||
synchronized (colors) {
|
synchronized (colors) {
|
||||||
rval = new HashMap<VenueParticipant, RGB>(colors);
|
rval = new HashMap<VenueParticipant, RGB>(colors.size());
|
||||||
|
for (Entry<VenueParticipant, UserColorInfo> entry : colors
|
||||||
|
.entrySet()) {
|
||||||
|
rval.put(entry.getKey(), entry.getValue().getForeground());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear color assignments and repopulate with supplied map
|
* Reassign foreground colors specified by map
|
||||||
*
|
*
|
||||||
* @param map
|
* @param map
|
||||||
*/
|
*/
|
||||||
public void setColors(Map<VenueParticipant, RGB> map) {
|
public void setForegroundColors(Map<VenueParticipant, RGB> map) {
|
||||||
synchronized (colors) {
|
synchronized (colors) {
|
||||||
colors.clear();
|
for (Entry<VenueParticipant, RGB> entry : map.entrySet()) {
|
||||||
colors.putAll(map);
|
VenueParticipant participant = entry.getKey();
|
||||||
|
UserColorInfo colorInfo = getColorInternal(participant);
|
||||||
|
RGB foreground = entry.getValue();
|
||||||
|
if (colorInfo != null) {
|
||||||
|
colorInfo.setForeground(foreground);
|
||||||
|
} else {
|
||||||
|
setColorInternal(participant, new UserColorInfo(foreground));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Get participant's assigned color
|
public UserColorInfo getColorForUser(VenueParticipant user) {
|
||||||
*
|
UserColorInfo rval;
|
||||||
* @param user
|
rval = getColorInternal(user);
|
||||||
* @return
|
if (rval == null) {
|
||||||
*/
|
synchronized (colors) {
|
||||||
public RGB getColorForUser(VenueParticipant user) {
|
|
||||||
RGB rval;
|
|
||||||
synchronized (colors) {
|
|
||||||
rval = colors.get(user);
|
|
||||||
if (rval == null) {
|
|
||||||
int count = colors.size();
|
int count = colors.size();
|
||||||
if (rgbPresets.length <= count) {
|
if (foregroundPresets.length <= count) {
|
||||||
count = count % rgbPresets.length;
|
count = count % foregroundPresets.length;
|
||||||
}
|
}
|
||||||
rval = rgbPresets[count];
|
rval = new UserColorInfo(foregroundPresets[count]);
|
||||||
colors.put(user, rval);
|
setColorInternal(user, rval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign color to participant
|
* @param user
|
||||||
*
|
* @return null if user isn't found
|
||||||
* @param id
|
|
||||||
* @param rgb
|
|
||||||
*/
|
*/
|
||||||
public void setColorForUser(VenueParticipant id, RGB rgb) {
|
protected UserColorInfo getColorInternal(VenueParticipant user) {
|
||||||
synchronized (colors) {
|
UserColorInfo rval = null;
|
||||||
colors.put(id, rgb);
|
if (user != null) {
|
||||||
|
synchronized (colors) {
|
||||||
|
rval = colors.get(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear color assignments
|
* @param user
|
||||||
|
* @param color
|
||||||
*/
|
*/
|
||||||
|
protected void setColorInternal(VenueParticipant user, UserColorInfo color) {
|
||||||
|
synchronized (colors) {
|
||||||
|
colors.put(user, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColorForUser(VenueParticipant user, UserColorInfo color) {
|
||||||
|
setColorInternal(user, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void clearColors() {
|
public void clearColors() {
|
||||||
synchronized (colors) {
|
synchronized (colors) {
|
||||||
colors.clear();
|
colors.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription(VenueParticipant user) {
|
||||||
|
return "Color changes will apply to the user " + user.getName()
|
||||||
|
+ " only in the " + user.getRoom() + " room. "
|
||||||
|
+ "\nColor changes will be discarded when you leave the room.";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.viz.core.VizApp;
|
||||||
* Feb 11, 2014 2751 njensen Added leaderChanged() and listeners
|
* Feb 11, 2014 2751 njensen Added leaderChanged() and listeners
|
||||||
* Mar 07, 2014 2848 bclement made colorManager final, added modifyColors() listeners
|
* Mar 07, 2014 2848 bclement made colorManager final, added modifyColors() listeners
|
||||||
* Mar 18, 2014 2895 njensen Improved javadoc
|
* Mar 18, 2014 2895 njensen Improved javadoc
|
||||||
|
* Jan 13, 2015 3709 bclement SessionColorManager API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -72,7 +73,13 @@ public class SessionContainer {
|
||||||
/** subscribes to events related to the session based on role **/
|
/** subscribes to events related to the session based on role **/
|
||||||
private IRoleEventController roleEventController;
|
private IRoleEventController roleEventController;
|
||||||
|
|
||||||
private final SessionColorManager colorManager = new SessionColorManager();
|
private final SessionColorManager colorManager = new SessionColorManager() {
|
||||||
|
@Override
|
||||||
|
public String getDescription(VenueParticipant user) {
|
||||||
|
return super.getDescription(user)
|
||||||
|
+ "\nColor changes will be seen by all participants in the session.";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private IRemoteDisplayContainer displayContainer;
|
private IRemoteDisplayContainer displayContainer;
|
||||||
|
|
||||||
|
@ -178,12 +185,13 @@ public class SessionContainer {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void modifyColors(ColorPopulator populator) {
|
public void modifyColors(ColorPopulator populator) {
|
||||||
colorManager.setColors(populator.getColors());
|
colorManager.setForegroundColors(populator.getColors());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void modifyColors(ColorChangeEvent event) {
|
public void modifyColors(ColorChangeEvent event) {
|
||||||
colorManager.setColorForUser(event.getUserName(), event.getColor());
|
UserColorInfo color = new UserColorInfo(event.getColor());
|
||||||
|
colorManager.setColorForUser(event.getUserName(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
/**
|
||||||
|
* 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.display.data;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color information for a collaboration user which is used when styling text
|
||||||
|
* and telestration
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Jan 12, 2015 3709 bclement Initial creation, moved from ColorInfoMap
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author bclement
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
|
public class UserColorInfo {
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int fgRed;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int fgGreen;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int fgBlue;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int bgRed;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int bgGreen;
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
private int bgBlue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public UserColorInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param foreground
|
||||||
|
*/
|
||||||
|
public UserColorInfo(RGB foreground) {
|
||||||
|
this(foreground, new RGB(255, 255, 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param foreground
|
||||||
|
* @param background
|
||||||
|
*/
|
||||||
|
public UserColorInfo(RGB foreground, RGB background) {
|
||||||
|
setForeground(foreground);
|
||||||
|
setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the background
|
||||||
|
*/
|
||||||
|
public RGB getBackground() {
|
||||||
|
return new RGB(bgRed, bgGreen, bgBlue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param background
|
||||||
|
* the background to set
|
||||||
|
*/
|
||||||
|
public void setBackground(RGB background) {
|
||||||
|
if (background != null) {
|
||||||
|
this.bgRed = background.red;
|
||||||
|
this.bgGreen = background.green;
|
||||||
|
this.bgBlue = background.blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the foreground
|
||||||
|
*/
|
||||||
|
public RGB getForeground() {
|
||||||
|
return new RGB(fgRed, fgGreen, fgBlue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param foreground
|
||||||
|
* the foreground to set
|
||||||
|
*/
|
||||||
|
public void setForeground(RGB foreground) {
|
||||||
|
if (foreground != null) {
|
||||||
|
this.fgRed = foreground.red;
|
||||||
|
this.fgGreen = foreground.green;
|
||||||
|
this.fgBlue = foreground.blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,8 +19,6 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.display.roles;
|
package com.raytheon.uf.viz.collaboration.display.roles;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -33,6 +31,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.invite.ColorPopulator;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.ColorChangeEvent;
|
import com.raytheon.uf.viz.collaboration.display.data.ColorChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.display.editor.ActivateRemoteDisplay;
|
import com.raytheon.uf.viz.collaboration.display.editor.ActivateRemoteDisplay;
|
||||||
import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.SharedEditorsManager;
|
import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.SharedEditorsManager;
|
||||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||||
|
@ -56,6 +55,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||||
* Feb 13, 2014 2751 bclement VenueParticipant refactor
|
* Feb 13, 2014 2751 bclement VenueParticipant refactor
|
||||||
* Feb 13, 2014 2751 njensen Renamed container to displayContainer
|
* Feb 13, 2014 2751 njensen Renamed container to displayContainer
|
||||||
* Mar 06, 2014 2848 bclement removed check for self from participantChanged
|
* Mar 06, 2014 2848 bclement removed check for self from participantChanged
|
||||||
|
* Jan 13, 2015 3709 bclement SessionColorManager API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -98,12 +98,13 @@ public class DataProviderEventController extends
|
||||||
SessionColorManager scm = SharedDisplaySessionMgr
|
SessionColorManager scm = SharedDisplaySessionMgr
|
||||||
.getSessionContainer(session.getSessionId())
|
.getSessionContainer(session.getSessionId())
|
||||||
.getColorManager();
|
.getColorManager();
|
||||||
RGB color = scm.getColorForUser(event.getParticipant());
|
UserColorInfo color = scm.getColorForUser(event
|
||||||
|
.getParticipant());
|
||||||
|
|
||||||
ColorChangeEvent cce = new ColorChangeEvent(
|
ColorChangeEvent cce = new ColorChangeEvent(
|
||||||
event.getParticipant(), color);
|
event.getParticipant(), color.getForeground());
|
||||||
session.sendObjectToPeer(event.getParticipant(),
|
session.sendObjectToPeer(event.getParticipant(),
|
||||||
new ColorPopulator(scm.getColors()));
|
new ColorPopulator(scm.getForegroundColors()));
|
||||||
session.sendObjectToVenue(cce);
|
session.sendObjectToVenue(cce);
|
||||||
} catch (CollaborationException e) {
|
} catch (CollaborationException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.raytheon.uf.viz.collaboration.display.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.display.editor.ReprojectRemoteDisplay;
|
import com.raytheon.uf.viz.collaboration.display.editor.ReprojectRemoteDisplay;
|
||||||
import com.raytheon.uf.viz.core.DrawableString;
|
import com.raytheon.uf.viz.core.DrawableString;
|
||||||
import com.raytheon.uf.viz.core.IExtent;
|
import com.raytheon.uf.viz.core.IExtent;
|
||||||
|
@ -60,6 +61,7 @@ import com.raytheon.uf.viz.remote.graphics.DispatchGraphicsTarget;
|
||||||
* Mar 06, 2014 2848 bclement get subject dynamically from session
|
* Mar 06, 2014 2848 bclement get subject dynamically from session
|
||||||
* May 16, 2014 3163 bsteffen Remove references to deprecated
|
* May 16, 2014 3163 bsteffen Remove references to deprecated
|
||||||
* {@link DrawableString} field.
|
* {@link DrawableString} field.
|
||||||
|
* Jan 13, 2015 3709 bclement SessionColorManager API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -103,10 +105,12 @@ public class DataProviderRsc extends
|
||||||
}
|
}
|
||||||
target.clearClippingPlane();
|
target.clearClippingPlane();
|
||||||
IExtent extent = paintProps.getView().getExtent();
|
IExtent extent = paintProps.getView().getExtent();
|
||||||
RGB color = colorManager.getColorForUser(session.getUserID());
|
UserColorInfo colors = colorManager
|
||||||
target.drawRect(extent, color, 3.0f, 1.0f);
|
.getColorForUser(session.getUserID());
|
||||||
|
RGB foreground = colors.getForeground();
|
||||||
|
target.drawRect(extent, foreground, 3.0f, 1.0f);
|
||||||
|
|
||||||
DrawableString string = new DrawableString(getName(), color);
|
DrawableString string = new DrawableString(getName(), foreground);
|
||||||
string.horizontalAlignment = HorizontalAlignment.CENTER;
|
string.horizontalAlignment = HorizontalAlignment.CENTER;
|
||||||
string.verticallAlignment = VerticalAlignment.BOTTOM;
|
string.verticallAlignment = VerticalAlignment.BOTTOM;
|
||||||
string.setCoordinates(extent.getMinX() + extent.getWidth() / 2,
|
string.setCoordinates(extent.getMinX() + extent.getWidth() / 2,
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
import com.raytheon.uf.viz.collaboration.display.Activator;
|
import com.raytheon.uf.viz.collaboration.display.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent.CollaborationEventType;
|
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent.CollaborationEventType;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
|
@ -70,6 +71,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* May 05, 2014 3076 bclement old CLEAR_ALL is now DISPOSE_ALL,
|
* May 05, 2014 3076 bclement old CLEAR_ALL is now DISPOSE_ALL,
|
||||||
* added clearLayers() and getAllDrawingLayers()
|
* added clearLayers() and getAllDrawingLayers()
|
||||||
* Jun 30, 2014 1798 bclement added getManager()
|
* Jun 30, 2014 1798 bclement added getManager()
|
||||||
|
* Jan 13, 2015 3709 bclement SessionColorManager API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -180,8 +182,9 @@ public class CollaborationDrawingResource extends
|
||||||
layer.setEraserWidth(16); // Configure?
|
layer.setEraserWidth(16); // Configure?
|
||||||
layer.setLineStyle(outline.getLineStyle());
|
layer.setLineStyle(outline.getLineStyle());
|
||||||
layer.setLineWidth(outline.getOutlineWidth());
|
layer.setLineWidth(outline.getOutlineWidth());
|
||||||
layer.setColor(container.getColorManager().getColorForUser(
|
UserColorInfo colorInfo = container.getColorManager()
|
||||||
user));
|
.getColorForUser(user);
|
||||||
|
layer.setColor(colorInfo.getForeground());
|
||||||
layer.paint(target, paintProps);
|
layer.paint(target, paintProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ import org.eclipse.swt.events.MouseTrackAdapter;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -89,6 +88,7 @@ import com.google.common.eventbus.Subscribe;
|
||||||
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.IRosterChangeEvent;
|
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
|
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.BookmarkEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.BookmarkEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent;
|
||||||
|
@ -170,6 +170,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
||||||
* Dec 08, 2014 3709 mapeters Added MB3 change user text color actions to contacts list.
|
* Dec 08, 2014 3709 mapeters Added MB3 change user text color actions to contacts list.
|
||||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
|
* Jan 13, 2015 3709 bclement ChangeTextColorAction API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -210,7 +211,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
||||||
|
|
||||||
private Action roomSearchAction;
|
private Action roomSearchAction;
|
||||||
|
|
||||||
private Map<String, ChangeTextColorAction> userColorActions;
|
private Map<String, ChangeTextColorAction<?>> userColorActions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent
|
* @param parent
|
||||||
|
@ -287,7 +288,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
||||||
activeImage.dispose();
|
activeImage.dispose();
|
||||||
pressedImage.dispose();
|
pressedImage.dispose();
|
||||||
|
|
||||||
for (ChangeTextColorAction userColorAction : userColorActions.values()) {
|
for (ChangeTextColorAction<?> userColorAction : userColorActions
|
||||||
|
.values()) {
|
||||||
userColorAction.dispose();
|
userColorAction.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,13 +481,11 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
||||||
manager.add(new AddNotifierAction(this));
|
manager.add(new AddNotifierAction(this));
|
||||||
manager.add(new Separator());
|
manager.add(new Separator());
|
||||||
String colorActionKey = user.getFQName();
|
String colorActionKey = user.getFQName();
|
||||||
ChangeTextColorAction userColorAction = userColorActions
|
ChangeTextColorAction<?> userColorAction = userColorActions
|
||||||
.get(colorActionKey);
|
.get(colorActionKey);
|
||||||
if (userColorAction == null) {
|
if (userColorAction == null) {
|
||||||
userColorAction = ChangeTextColorAction
|
userColorAction = new ChangeTextColorAction<IUser>(user, false,
|
||||||
.createChangeUserTextColorAction(user, false, false,
|
false, false, UserColorConfigManager.getInstance());
|
||||||
new RGB(0, 0, 255),
|
|
||||||
UserColorConfigManager.getInstance());
|
|
||||||
userColorActions.put(colorActionKey, userColorAction);
|
userColorActions.put(colorActionKey, userColorAction);
|
||||||
}
|
}
|
||||||
manager.add(userColorAction);
|
manager.add(userColorAction);
|
||||||
|
@ -498,13 +498,12 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
||||||
if (me.isSameUser(user)) {
|
if (me.isSameUser(user)) {
|
||||||
createMenu(manager);
|
createMenu(manager);
|
||||||
String colorActionKey = user.getFQName();
|
String colorActionKey = user.getFQName();
|
||||||
ChangeTextColorAction userColorAction = userColorActions
|
ChangeTextColorAction<?> userColorAction = userColorActions
|
||||||
.get(colorActionKey);
|
.get(colorActionKey);
|
||||||
if (userColorAction == null) {
|
if (userColorAction == null) {
|
||||||
userColorAction = ChangeTextColorAction
|
userColorAction = new ChangeTextColorAction<IUser>(user,
|
||||||
.createChangeUserTextColorAction(user, true, true,
|
true, true, false,
|
||||||
new RGB(0, 0, 255),
|
UserColorConfigManager.getInstance());
|
||||||
UserColorConfigManager.getInstance());
|
|
||||||
userColorActions.put(colorActionKey, userColorAction);
|
userColorActions.put(colorActionKey, userColorAction);
|
||||||
}
|
}
|
||||||
manager.insertBefore("afterFont", userColorAction);
|
manager.insertBefore("afterFont", userColorAction);
|
||||||
|
|
|
@ -22,22 +22,19 @@ package com.raytheon.uf.viz.collaboration.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Device;
|
import org.eclipse.swt.graphics.Device;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
import com.raytheon.uf.viz.collaboration.display.data.IColorManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.FeedColorConfigManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundBackgroundColorDlg;
|
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundBackgroundColorDlg;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager;
|
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundColorDlg;
|
||||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,40 +54,47 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* current foreground and background colors.
|
* current foreground and background colors.
|
||||||
* Jan 05, 2015 3709 mapeters Added getTextColors(), added me param to createChangeUserTextColorAction().
|
* Jan 05, 2015 3709 mapeters Added getTextColors(), added me param to createChangeUserTextColorAction().
|
||||||
* Jan 09, 2015 3709 bclement color change manager API changes
|
* Jan 09, 2015 3709 bclement color change manager API changes
|
||||||
|
* Jan 12, 2015 3709 bclement removed event handler for icon changes, added ChangeTextColorCallback
|
||||||
|
* Jan 13, 2015 3709 bclement unified color management, simplified construction, added foregroundOnly mode
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mapeters
|
* @author mapeters
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ChangeTextColorAction extends Action {
|
public class ChangeTextColorAction<T extends IUser> extends Action {
|
||||||
|
|
||||||
private final String key;
|
private final T user;
|
||||||
|
|
||||||
private RGB defaultForeground;
|
private IColorManager<T> colorManager;
|
||||||
|
|
||||||
private IColorConfigManager colorConfigManager;
|
private boolean foregroundOnly;
|
||||||
|
|
||||||
private Image icon;
|
private Image icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return new action for changing user colors.
|
* Callback that receives new color information when the action results in a
|
||||||
|
* new color selection for a user
|
||||||
|
*/
|
||||||
|
public static interface ChangeTextColorCallback {
|
||||||
|
public void newColor(IUser user, UserColorInfo colors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChangeTextColorCallback actionCallback = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate display text string according to provided options
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* the user whose colors may be changed by this action
|
|
||||||
* @param me
|
* @param me
|
||||||
* whether the selected user is the current user
|
* true if user represents the currently logged in user
|
||||||
* @param displayName
|
* @param displayName
|
||||||
* whether to display the user's name or simply "User"
|
* true if the user's name should be used or false if a generic
|
||||||
* @param defaultForeground
|
* display text should be used
|
||||||
* the foreground color to use if none is stored
|
|
||||||
* @param colorConfigManager
|
|
||||||
* manager to store/retrieve user colors
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ChangeTextColorAction createChangeUserTextColorAction(
|
public static String getDisplayText(IUser user, boolean me,
|
||||||
IUser user, boolean me, boolean displayName,
|
boolean displayName) {
|
||||||
RGB defaultForeground, IColorConfigManager colorConfigManager) {
|
|
||||||
String name = user.getName();
|
String name = user.getName();
|
||||||
String text = "Change ";
|
String text = "Change ";
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
|
@ -100,47 +104,43 @@ public class ChangeTextColorAction extends Action {
|
||||||
}
|
}
|
||||||
text += " Text Colors...";
|
text += " Text Colors...";
|
||||||
|
|
||||||
return new ChangeTextColorAction(text, user.getFQName(),
|
return text;
|
||||||
defaultForeground, colorConfigManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and return new action for changing site colors.
|
* @param user
|
||||||
*
|
* @param me
|
||||||
* @param site
|
* true if user represents the currently logged in user
|
||||||
* the site whose colors may be changed by this action
|
* @param displayName
|
||||||
* @param defaultForeground
|
* true if the user's name should be used or false if a generic
|
||||||
* the foreground color to use if none is stored
|
* display text should be used
|
||||||
|
* @param foregroundOnly
|
||||||
|
* true if only the option to change the foreground should be
|
||||||
|
* provided
|
||||||
* @param colorConfigManager
|
* @param colorConfigManager
|
||||||
* manager to store/retrieve site colors
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static ChangeTextColorAction createChangeSiteTextColorAction(
|
public ChangeTextColorAction(T user, boolean me, boolean displayName,
|
||||||
String site, RGB defaultForeground,
|
boolean foregroundOnly, IColorManager<T> colorConfigManager) {
|
||||||
FeedColorConfigManager colorConfigManager) {
|
super(getDisplayText(user, me, displayName));
|
||||||
return new ChangeTextColorAction("Change Site Text Colors...", site,
|
this.user = user;
|
||||||
defaultForeground, colorConfigManager);
|
this.colorManager = colorConfigManager;
|
||||||
}
|
this.foregroundOnly = foregroundOnly;
|
||||||
|
UserColorInfo colors = getTextColors();
|
||||||
private ChangeTextColorAction(String text, String key,
|
setIconColors(colors);
|
||||||
RGB defaultForeground, IColorConfigManager colorConfigManager) {
|
|
||||||
super(text);
|
|
||||||
this.key = key;
|
|
||||||
this.defaultForeground = defaultForeground;
|
|
||||||
this.colorConfigManager = colorConfigManager;
|
|
||||||
|
|
||||||
RGB[] colors = getTextColors();
|
|
||||||
setIconColors(colors[0], colors[1]);
|
|
||||||
|
|
||||||
CollaborationConnection.getConnection().registerEventHandler(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
RGB[] colors = getTextColors();
|
UserColorInfo colors = getTextColors();
|
||||||
ForegroundBackgroundColorDlg dialog = new ForegroundBackgroundColorDlg(
|
ForegroundColorDlg dialog;
|
||||||
Display.getCurrent().getActiveShell(),
|
Shell shell = Display.getCurrent().getActiveShell();
|
||||||
colorConfigManager.getDescription(key), colors[0], colors[1]);
|
String desc = colorManager.getDescription(user);
|
||||||
|
if (foregroundOnly) {
|
||||||
|
dialog = new ForegroundColorDlg(shell, desc, colors.getForeground());
|
||||||
|
} else {
|
||||||
|
dialog = new ForegroundBackgroundColorDlg(shell, desc,
|
||||||
|
colors.getForeground(), colors.getBackground());
|
||||||
|
}
|
||||||
|
|
||||||
dialog.setCloseCallback(new ICloseCallback() {
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ public class ChangeTextColorAction extends Action {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnValue instanceof RGB[]) {
|
if (returnValue instanceof UserColorInfo) {
|
||||||
RGB[] colors = (RGB[]) returnValue;
|
UserColorInfo colors = (UserColorInfo) returnValue;
|
||||||
colorConfigManager.setColors(key, colors[0], colors[1]);
|
colorManager.setColorForUser(user, colors);
|
||||||
CollaborationConnection connection = CollaborationConnection
|
setIconColors(colors);
|
||||||
.getConnection();
|
if (actionCallback != null) {
|
||||||
connection.postEvent(new ChangeIconEvent(key, colors[0],
|
actionCallback.newColor(user, colors);
|
||||||
colors[1]));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -164,36 +164,24 @@ public class ChangeTextColorAction extends Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the stored colors (or default colors) of this action's user/site
|
* Get the stored colors (or default colors) of this action's user
|
||||||
*
|
*
|
||||||
* @return RGB array of length 2 with foreground color in index 0 and
|
* @return color selected by color manager or default color if none found
|
||||||
* background color in index 1
|
|
||||||
*/
|
*/
|
||||||
private RGB[] getTextColors() {
|
private UserColorInfo getTextColors() {
|
||||||
ColorInfo colorInfo = colorConfigManager.getColor(key);
|
return colorManager.getColorForUser(user);
|
||||||
RGB foreground;
|
|
||||||
RGB background;
|
|
||||||
if (colorInfo != null) {
|
|
||||||
foreground = colorInfo.getColor(SWT.FOREGROUND);
|
|
||||||
background = colorInfo.getColor(SWT.BACKGROUND);
|
|
||||||
} else {
|
|
||||||
foreground = defaultForeground;
|
|
||||||
background = new RGB(255, 255, 255);
|
|
||||||
}
|
|
||||||
return new RGB[] { foreground, background };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
/**
|
||||||
public void changeIcon(ChangeIconEvent event) {
|
* Change colors in menu icon which represents the user's text color
|
||||||
if (event.key.equals(this.key)) {
|
* settings
|
||||||
setIconColors(event.foreground, event.background);
|
*
|
||||||
}
|
* @param colors
|
||||||
}
|
*/
|
||||||
|
private void setIconColors(UserColorInfo colors) {
|
||||||
private void setIconColors(RGB foreground, RGB background) {
|
|
||||||
Device device = Display.getCurrent();
|
Device device = Display.getCurrent();
|
||||||
Color fg = new Color(device, foreground);
|
Color fg = new Color(device, colors.getForeground());
|
||||||
Color bg = new Color(device, background);
|
Color bg = new Color(device, colors.getBackground());
|
||||||
|
|
||||||
Image oldIcon = icon;
|
Image oldIcon = icon;
|
||||||
icon = new Image(device, 15, 15);
|
icon = new Image(device, 15, 15);
|
||||||
|
@ -215,31 +203,18 @@ public class ChangeTextColorAction extends Action {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChangeIconEvent {
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
private RGB foreground;
|
|
||||||
|
|
||||||
private RGB background;
|
|
||||||
|
|
||||||
private ChangeIconEvent(String key, RGB foreground, RGB background) {
|
|
||||||
this.key = key;
|
|
||||||
this.foreground = foreground;
|
|
||||||
this.background = background;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
CollaborationConnection connection = CollaborationConnection
|
|
||||||
.getConnection();
|
|
||||||
if (connection != null) {
|
|
||||||
connection.unregisterEventHandler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
icon.dispose();
|
icon.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @param actionCallback
|
||||||
|
* the actionCallback to set
|
||||||
|
*/
|
||||||
|
public void setActionCallback(ChangeTextColorCallback actionCallback) {
|
||||||
|
this.actionCallback = actionCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,101 +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.ui.colors;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration manager for reading/writing colors for each site to/from a
|
|
||||||
* user-localized file
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Oct 10, 2014 3708 bclement Moved color methods from SiteConfigurationManager
|
|
||||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link PersistentColorConfigManager},
|
|
||||||
* renamed from SiteColorConfigManager.
|
|
||||||
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
|
|
||||||
* Jan 09, 2015 3709 bclement made into a true singleton, moved colorInfoMap to super
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author bclement
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class FeedColorConfigManager extends PersistentColorConfigManager {
|
|
||||||
|
|
||||||
private static final String FILE_PATH = CONFIG_DIR_NAME
|
|
||||||
+ IPathManager.SEPARATOR + "siteColorInfo.xml";
|
|
||||||
|
|
||||||
private static FeedColorConfigManager instance;
|
|
||||||
|
|
||||||
public static synchronized FeedColorConfigManager getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new FeedColorConfigManager();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FeedColorConfigManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set and store the given colors for the given site.
|
|
||||||
*
|
|
||||||
* @param site
|
|
||||||
* @param foreground
|
|
||||||
* @param background
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void setColors(String site, RGB foreground,
|
|
||||||
RGB background) {
|
|
||||||
super.setColors(site, foreground, background, FILE_PATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the {@link ColorInfo} for the given site from memory.
|
|
||||||
*
|
|
||||||
* @param site
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized ColorInfo getColor(String site) {
|
|
||||||
return super.getColor(site, FILE_PATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
|
||||||
* getDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getDescription(String key) {
|
|
||||||
return "Color changes will apply to all users from site " + key
|
|
||||||
+ " in the feed room.";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -33,6 +33,8 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialog that displays a label with settable foreground and background colors
|
* A dialog that displays a label with settable foreground and background colors
|
||||||
* using a color control.
|
* using a color control.
|
||||||
|
@ -43,8 +45,9 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Dec 04, 2014 3709 lvenable Initial creation
|
* Dec 04, 2014 3709 lvenable Initial creation
|
||||||
* Jan 09, 2015 3709 bclement moved primary logic to new super class
|
* Jan 09, 2015 3709 bclement moved primary logic to new super class
|
||||||
|
* Jan 13, 2015 3709 bclement return UserColorInfo instead of RGB[]
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -156,9 +159,9 @@ public class ForegroundBackgroundColorDlg extends ForegroundColorDlg {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void collectReturnValue() {
|
protected void collectReturnValue() {
|
||||||
RGB[] rgbArray = new RGB[] { foregroundClr.getRGB(),
|
UserColorInfo colors = new UserColorInfo(foregroundClr.getRGB(),
|
||||||
backgroundClr.getRGB() };
|
backgroundClr.getRGB());
|
||||||
setReturnValue(rgbArray);
|
setReturnValue(colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Layout;
|
import org.eclipse.swt.widgets.Layout;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
import com.raytheon.viz.ui.dialogs.colordialog.ColorWheelComp;
|
import com.raytheon.viz.ui.dialogs.colordialog.ColorWheelComp;
|
||||||
import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
|
import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
|
||||||
|
@ -49,6 +50,7 @@ import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 09, 2015 3709 bclement Initial creation, logic from ForegroundBackgroundColorDlg
|
* Jan 09, 2015 3709 bclement Initial creation, logic from ForegroundBackgroundColorDlg
|
||||||
|
* Jan 13, 2015 3709 bclement return UserColorInfo instead of RGB
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -225,7 +227,7 @@ public class ForegroundColorDlg extends CaveSWTDialog implements
|
||||||
* button.
|
* button.
|
||||||
*/
|
*/
|
||||||
protected void collectReturnValue() {
|
protected void collectReturnValue() {
|
||||||
setReturnValue(foregroundClr.getRGB());
|
setReturnValue(new UserColorInfo(foregroundClr.getRGB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
|
||||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
|
||||||
import com.raytheon.uf.common.localization.PathManager;
|
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
|
||||||
import com.raytheon.uf.common.serialization.SerializationException;
|
|
||||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract class for collaboration chat coloring configuration managers
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Nov 13, 2014 3709 mapeters Initial creation.
|
|
||||||
* Dec 09, 2014 3709 mapeters setColors() sets foreground and background together.
|
|
||||||
* Jan 09, 2015 3709 bclement renamed from AbstractColorConfigManager
|
|
||||||
* moved colorInfoMap from subclasses to here
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author mapeters
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public abstract class PersistentColorConfigManager implements
|
|
||||||
IColorConfigManager {
|
|
||||||
|
|
||||||
protected static final String CONFIG_DIR_NAME = "collaboration";
|
|
||||||
|
|
||||||
private static final SingleTypeJAXBManager<ColorInfoMap> jaxb = SingleTypeJAXBManager
|
|
||||||
.createWithoutException(ColorInfoMap.class);
|
|
||||||
|
|
||||||
private ColorInfoMap colorInfoMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set and store the given foreground and background colors for the given
|
|
||||||
* user/site at the given file location.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param foreground
|
|
||||||
* @param background
|
|
||||||
* @param filePath
|
|
||||||
*/
|
|
||||||
protected void setColors(String key, RGB foreground, RGB background,
|
|
||||||
String filePath) {
|
|
||||||
ColorInfoMap colorInfoMap = this.getColorInfoMap();
|
|
||||||
if (colorInfoMap == null) {
|
|
||||||
colorInfoMap = new ColorInfoMap();
|
|
||||||
this.setColorInfoMap(colorInfoMap);
|
|
||||||
}
|
|
||||||
Map<String, ColorInfo> colors = colorInfoMap.getColors();
|
|
||||||
if (colors == null) {
|
|
||||||
colorInfoMap.setColors(new HashMap<String, ColorInfo>());
|
|
||||||
colors = colorInfoMap.getColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorInfo colorInfo = colors.get(key);
|
|
||||||
if (colorInfo == null) {
|
|
||||||
colorInfo = new ColorInfo();
|
|
||||||
colors.put(key, colorInfo);
|
|
||||||
}
|
|
||||||
colorInfo.setColors(foreground, background);
|
|
||||||
|
|
||||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
|
||||||
LocalizationContext lContext = pathMgr.getContext(
|
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
|
||||||
LocalizationFile file = pathMgr.getLocalizationFile(lContext, filePath);
|
|
||||||
try {
|
|
||||||
jaxb.marshalToXmlFile(colorInfoMap, file.getFile().getPath());
|
|
||||||
file.save();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Activator.statusHandler.error(
|
|
||||||
"Unable to write color information to file: "
|
|
||||||
+ file.getName() + " in context " + lContext, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the {@link ColorInfo} for the given user/site from memory.
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* @param filePath
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected ColorInfo getColor(String key, String filePath) {
|
|
||||||
ColorInfoMap colorInfoMap = this.getColorInfoMap();
|
|
||||||
if (colorInfoMap == null) {
|
|
||||||
IPathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
|
||||||
LocalizationContext locContext = pm.getContext(
|
|
||||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
|
||||||
LocalizationFile file = pm
|
|
||||||
.getLocalizationFile(locContext, filePath);
|
|
||||||
|
|
||||||
if (file != null && file.exists()) {
|
|
||||||
try {
|
|
||||||
colorInfoMap = jaxb.unmarshalFromXmlFile(file.getFile());
|
|
||||||
this.setColorInfoMap(colorInfoMap);
|
|
||||||
} catch (SerializationException e) {
|
|
||||||
Activator.statusHandler.error(
|
|
||||||
"Unable to read color information from file: "
|
|
||||||
+ file.getName() + " in level "
|
|
||||||
+ LocalizationLevel.USER, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (colorInfoMap != null) {
|
|
||||||
Map<String, ColorInfo> colors = colorInfoMap.getColors();
|
|
||||||
if (colors != null) {
|
|
||||||
return colors.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ColorInfoMap getColorInfoMap() {
|
|
||||||
return colorInfoMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setColorInfoMap(ColorInfoMap colorInfo) {
|
|
||||||
this.colorInfoMap = colorInfo;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
|
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||||
|
import com.raytheon.uf.common.localization.PathManager;
|
||||||
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
|
import com.raytheon.uf.common.serialization.SerializationException;
|
||||||
|
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.ColorInfoMap;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for persisting user color configuration to localization
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 13, 2014 3709 mapeters Initial creation.
|
||||||
|
* Dec 09, 2014 3709 mapeters setColors() sets foreground and background together.
|
||||||
|
* Jan 09, 2015 3709 bclement renamed from AbstractColorConfigManager
|
||||||
|
* moved colorInfoMap from subclasses to here
|
||||||
|
* Jan 13, 2015 3709 bclement renamed to PersistentColorConfigStorage, now a utility
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mapeters
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public abstract class PersistentColorConfigStorage<T extends IUser> {
|
||||||
|
|
||||||
|
protected static final String CONFIG_DIR_NAME = "collaboration";
|
||||||
|
|
||||||
|
private static final SingleTypeJAXBManager<ColorInfoMap> jaxb = SingleTypeJAXBManager
|
||||||
|
.createWithoutException(ColorInfoMap.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persist color mapping configuration to localization file
|
||||||
|
*
|
||||||
|
* @param colorInfoMap
|
||||||
|
* @param filePath
|
||||||
|
*/
|
||||||
|
public void persistColors(Map<T, UserColorInfo> map, String filePath) {
|
||||||
|
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||||
|
LocalizationContext lContext = pathMgr.getContext(
|
||||||
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
|
LocalizationFile file = pathMgr.getLocalizationFile(lContext, filePath);
|
||||||
|
try {
|
||||||
|
jaxb.marshalToXmlFile(createStorageMap(map), file.getFile()
|
||||||
|
.getPath());
|
||||||
|
file.save();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Activator.statusHandler.error(
|
||||||
|
"Unable to write color information to file: "
|
||||||
|
+ file.getName() + " in context " + lContext, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert runtime map to a map that can be serialized to storage
|
||||||
|
*
|
||||||
|
* @param colorInfoMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ColorInfoMap createStorageMap(Map<T, UserColorInfo> colorInfoMap) {
|
||||||
|
Map<String, UserColorInfo> rval = new HashMap<>(colorInfoMap.size());
|
||||||
|
for (Entry<T, UserColorInfo> entry : colorInfoMap.entrySet()) {
|
||||||
|
rval.put(convert(entry.getKey()), entry.getValue());
|
||||||
|
}
|
||||||
|
return new ColorInfoMap(rval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert map from storage to runtime map
|
||||||
|
*
|
||||||
|
* @param persisted
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<T, UserColorInfo> unpackStorageMap(
|
||||||
|
Map<String, UserColorInfo> persisted) {
|
||||||
|
Map<T, UserColorInfo> rval = new HashMap<>(persisted.size());
|
||||||
|
for (Entry<String, UserColorInfo> entry : persisted.entrySet()) {
|
||||||
|
rval.put(convert(entry.getKey()), entry.getValue());
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert user object to string key for storage
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected String convert(T user) {
|
||||||
|
return user.getClientIndependentId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert persisted key to user object
|
||||||
|
*
|
||||||
|
* @param persisted
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract T convert(String persisted);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the color mapping configuration from localization
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @return empty map if file does not exists in localization
|
||||||
|
*/
|
||||||
|
public Map<T, UserColorInfo> getColors(String filePath) {
|
||||||
|
IPathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||||
|
LocalizationContext locContext = pm.getContext(
|
||||||
|
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||||
|
LocalizationFile file = pm.getLocalizationFile(locContext, filePath);
|
||||||
|
Map<String, UserColorInfo> rval = null;
|
||||||
|
if (file != null && file.exists()) {
|
||||||
|
try {
|
||||||
|
ColorInfoMap map = jaxb.unmarshalFromXmlFile(file.getFile());
|
||||||
|
if (map != null) {
|
||||||
|
rval = map.getColors();
|
||||||
|
}
|
||||||
|
} catch (SerializationException e) {
|
||||||
|
Activator.statusHandler.error(
|
||||||
|
"Unable to read color information from file: "
|
||||||
|
+ file.getName() + " in level "
|
||||||
|
+ LocalizationLevel.USER, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rval == null) {
|
||||||
|
rval = new HashMap<>();
|
||||||
|
}
|
||||||
|
return unpackStorageMap(rval);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,17 +19,16 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of custom user color configurations for users in a particular
|
* Session color manager that persists colors to localization
|
||||||
* chat room
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -37,20 +36,24 @@ import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 08, 2015 3709 bclement Initial creation
|
* Jan 13, 2015 3709 bclement Initial creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bclement
|
* @author bclement
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class RoomSpecificColorConfigManager extends
|
public class PersistentSessionColorManager extends SessionColorManager {
|
||||||
PersistentColorConfigManager {
|
|
||||||
|
|
||||||
private static final String ROOM_CONFIG_DIR = CONFIG_DIR_NAME
|
private static final String ROOM_CONFIG_DIR = PersistentColorConfigStorage.CONFIG_DIR_NAME
|
||||||
+ IPathManager.SEPARATOR + "roomColors";
|
+ IPathManager.SEPARATOR + "roomColors";
|
||||||
|
|
||||||
private final String roomId;
|
private final PersistentColorConfigStorage<VenueParticipant> storage = new PersistentColorConfigStorage<VenueParticipant>() {
|
||||||
|
@Override
|
||||||
|
protected VenueParticipant convert(String persisted) {
|
||||||
|
return IDConverter.convertFromRoom(persisted);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final String configFilePath;
|
private final String configFilePath;
|
||||||
|
|
||||||
|
@ -58,62 +61,46 @@ public class RoomSpecificColorConfigManager extends
|
||||||
* @param roomId
|
* @param roomId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static RoomSpecificColorConfigManager getManagerForRoom(String roomId) {
|
public static PersistentSessionColorManager getManagerForRoom(String roomId) {
|
||||||
/*
|
/*
|
||||||
* if multiple managers are created for the same room, it could cause
|
* if multiple managers are created for the same room, it could cause
|
||||||
* concurrency issues with writing to localization. This could be solved
|
* concurrency issues with writing to localization. This could be solved
|
||||||
* with a soft reference cache here. However, since there *should* only
|
* with a soft reference cache here. However, since there *should* only
|
||||||
* be one of these per room id, it might be overkill
|
* be one of these per room id, it might be overkill
|
||||||
*/
|
*/
|
||||||
return new RoomSpecificColorConfigManager(roomId);
|
return new PersistentSessionColorManager(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param roomId
|
* @param roomId
|
||||||
*/
|
*/
|
||||||
protected RoomSpecificColorConfigManager(String roomId) {
|
protected PersistentSessionColorManager(String roomId) {
|
||||||
this.roomId = roomId;
|
|
||||||
this.configFilePath = ROOM_CONFIG_DIR + IPathManager.SEPARATOR + roomId;
|
this.configFilePath = ROOM_CONFIG_DIR + IPathManager.SEPARATOR + roomId;
|
||||||
|
Map<VenueParticipant, UserColorInfo> persistedColors = storage
|
||||||
|
.getColors(configFilePath);
|
||||||
|
colors.putAll(persistedColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager#setColors
|
|
||||||
* (java.lang.String, org.eclipse.swt.graphics.RGB,
|
|
||||||
* org.eclipse.swt.graphics.RGB)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setColors(String participant, RGB foreground,
|
public String getDescription(VenueParticipant participant) {
|
||||||
RGB background) {
|
return "Color changes will apply to the user " + participant.getName()
|
||||||
super.setColors(participant, foreground, background, configFilePath);
|
+ " only in the " + participant.getRoom() + " room.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager#getColor
|
|
||||||
* (java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized ColorInfo getColor(String participant) {
|
protected void setColorInternal(VenueParticipant user, UserColorInfo color) {
|
||||||
return super.getColor(participant, configFilePath);
|
synchronized (storage) {
|
||||||
|
super.setColorInternal(user, color);
|
||||||
|
storage.persistColors(colors, configFilePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
|
||||||
* getDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(String key) {
|
public void clearColors() {
|
||||||
VenueParticipant id = IDConverter.convertFromRoom(null, key);
|
synchronized (storage) {
|
||||||
VenueId venue = VenueId.fromString(roomId);
|
super.clearColors();
|
||||||
return "Color changes will apply to the user " + id.getName()
|
storage.persistColors(colors, configFilePath);
|
||||||
+ " only in the " + venue.getName() + " room.";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,103 +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.ui.colors;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Non-persistent color configuration manager
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Jan 08, 2015 3709 bclement Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author bclement
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class TemporaryColorConfigManager implements IColorConfigManager {
|
|
||||||
|
|
||||||
private final Map<String, ColorInfo> map = new HashMap<String, ColorInfoMap.ColorInfo>();
|
|
||||||
|
|
||||||
private final String roomId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public TemporaryColorConfigManager(String roomId) {
|
|
||||||
this.roomId = roomId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#setColors
|
|
||||||
* (java.lang.String, org.eclipse.swt.graphics.RGB,
|
|
||||||
* org.eclipse.swt.graphics.RGB)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setColors(String key, RGB foreground, RGB background) {
|
|
||||||
ColorInfo info = new ColorInfo();
|
|
||||||
info.setColors(foreground, background);
|
|
||||||
map.put(key, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#getColor
|
|
||||||
* (java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ColorInfo getColor(String key) {
|
|
||||||
return map.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
|
||||||
* getDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getDescription(String key) {
|
|
||||||
VenueParticipant id = IDConverter.convertFromRoom(null, key);
|
|
||||||
VenueId venue = VenueId.fromString(roomId);
|
|
||||||
return "Color changes will apply to the user " + id.getName()
|
|
||||||
+ " only in the " + venue.getName() + " room. "
|
|
||||||
+ "\nColor changes will be discarded when you leave the room.";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,12 +19,16 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.ui.colors;
|
package com.raytheon.uf.viz.collaboration.ui.colors;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.display.data.IColorManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom user coloring configuration manager for use where the user's true
|
* Custom user coloring configuration manager for use where the user's true
|
||||||
|
@ -37,20 +41,29 @@ import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Nov 13, 2014 3709 mapeters Initial creation.
|
* Nov 13, 2014 3709 mapeters Initial creation.
|
||||||
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link PersistentColorConfigManager}.
|
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link PersistentColorConfigStorage}.
|
||||||
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
|
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
|
||||||
* Jan 09, 2015 3709 bclement made into a true singleton, moved colorInfoMap to super
|
* Jan 09, 2015 3709 bclement made into a true singleton, moved colorInfoMap to super
|
||||||
|
* Jan 13, 2015 3709 bclement refactored to use PersistentColorConfigStorage utility
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mapeters
|
* @author mapeters
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class UserColorConfigManager extends PersistentColorConfigManager {
|
public class UserColorConfigManager implements IColorManager<IUser> {
|
||||||
|
|
||||||
private static final String FILE_PATH = CONFIG_DIR_NAME
|
private static final String FILE_PATH = PersistentColorConfigStorage.CONFIG_DIR_NAME
|
||||||
+ IPathManager.SEPARATOR + "userColorInfo.xml";
|
+ IPathManager.SEPARATOR + "userColorInfo.xml";
|
||||||
|
|
||||||
|
/* dark blue */
|
||||||
|
private static final UserColorInfo DEFAULT_USER_COLORS = new UserColorInfo(
|
||||||
|
new RGB(0, 0, 191));
|
||||||
|
|
||||||
|
/* red */
|
||||||
|
private static final UserColorInfo DEFAULT_PEER_COLORS = new UserColorInfo(
|
||||||
|
new RGB(255, 0, 0));
|
||||||
|
|
||||||
private static UserColorConfigManager instance;
|
private static UserColorConfigManager instance;
|
||||||
|
|
||||||
public static synchronized UserColorConfigManager getInstance() {
|
public static synchronized UserColorConfigManager getInstance() {
|
||||||
|
@ -60,44 +73,70 @@ public class UserColorConfigManager extends PersistentColorConfigManager {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final PersistentColorConfigStorage<IUser> storage = new PersistentColorConfigStorage<IUser>() {
|
||||||
|
@Override
|
||||||
|
protected IUser convert(String persisted) {
|
||||||
|
return IDConverter.convertFrom(persisted);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private Map<IUser, UserColorInfo> _colors;
|
||||||
|
|
||||||
protected UserColorConfigManager() {
|
protected UserColorConfigManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set and store the given colors for the given user.
|
|
||||||
*
|
|
||||||
* @param user
|
|
||||||
* @param foreground
|
|
||||||
* @param background
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setColors(String user, RGB foreground,
|
public String getDescription(IUser user) {
|
||||||
RGB background) {
|
return "Color changes will apply to one-on-one chat sessions with user "
|
||||||
super.setColors(user, foreground, background, FILE_PATH);
|
+ user.getName() + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserColorInfo getColorForUser(IUser user) {
|
||||||
|
Map<IUser, UserColorInfo> colorMap = getColorMap();
|
||||||
|
UserColorInfo rval = colorMap.get(user);
|
||||||
|
if (rval == null) {
|
||||||
|
CollaborationConnection conn = CollaborationConnection
|
||||||
|
.getConnection();
|
||||||
|
if (conn.getUser().isSameUser(user)) {
|
||||||
|
rval = DEFAULT_USER_COLORS;
|
||||||
|
} else {
|
||||||
|
rval = DEFAULT_PEER_COLORS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link ColorInfo} for the given user from memory.
|
* Get color mappings, goes to storage if not initialized
|
||||||
*
|
*
|
||||||
* @param user
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
private Map<IUser, UserColorInfo> getColorMap() {
|
||||||
public synchronized ColorInfo getColor(String user) {
|
synchronized (storage) {
|
||||||
return super.getColor(user, FILE_PATH);
|
if (_colors == null) {
|
||||||
|
_colors = storage.getColors(FILE_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager#
|
|
||||||
* getDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(String key) {
|
public void setColorForUser(IUser user, UserColorInfo color) {
|
||||||
UserId id = IDConverter.convertFrom(key);
|
synchronized (storage) {
|
||||||
return "Color changes will apply to one-on-one chat sessions with user "
|
Map<IUser, UserColorInfo> colorMap = getColorMap();
|
||||||
+ id.getName() + ".";
|
colorMap.put(user, color);
|
||||||
|
storage.persistColors(colorMap, FILE_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearColors() {
|
||||||
|
synchronized (storage) {
|
||||||
|
Map<IUser, UserColorInfo> colorMap = getColorMap();
|
||||||
|
colorMap.clear();
|
||||||
|
storage.persistColors(colorMap, FILE_PATH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
|
||||||
* implemented here, added messagesTextMenuMgr.
|
* implemented here, added messagesTextMenuMgr.
|
||||||
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
|
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
|
||||||
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
|
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
|
||||||
|
* Jan 13, 2015 3709 bclement styleAndAppendText() takes foreground and background
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author rferrel
|
* @author rferrel
|
||||||
|
@ -366,8 +367,8 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
sb.append("(").append(time).append(") ");
|
sb.append("(").append(time).append(") ");
|
||||||
int offset = sb.length();
|
int offset = sb.length();
|
||||||
|
|
||||||
boolean newLine = Activator.getDefault()
|
boolean newLine = Activator.getDefault().getPreferenceStore()
|
||||||
.getPreferenceStore().getBoolean("chatLines");
|
.getBoolean("chatLines");
|
||||||
String displayPreference = newLine ? ("\n ") : (": ");
|
String displayPreference = newLine ? ("\n ") : (": ");
|
||||||
|
|
||||||
sb.append(name).append(displayPreference).append(body);
|
sb.append(name).append(displayPreference).append(body);
|
||||||
|
@ -470,7 +471,8 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
String name, T userId, String subject, List<StyleRange> ranges);
|
String name, T userId, String subject, List<StyleRange> ranges);
|
||||||
|
|
||||||
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, T userId, List<StyleRange> ranges, Color color);
|
String name, T userId, List<StyleRange> ranges, Color foreground,
|
||||||
|
Color background);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find keys words in body of message starting at offset.
|
* Find keys words in body of message starting at offset.
|
||||||
|
@ -586,7 +588,7 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
oldFont.dispose();
|
oldFont.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlertWords(List<AlertWord> words) {
|
public void setAlertWords(List<AlertWord> words) {
|
||||||
alertWords = words;
|
alertWords = words;
|
||||||
}
|
}
|
||||||
|
@ -636,14 +638,17 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
||||||
builder.insert(0, "\n");
|
builder.insert(0, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Color color = Display.getCurrent().getSystemColor(swtColor);
|
Color foreground = Display.getCurrent().getSystemColor(
|
||||||
|
swtColor);
|
||||||
|
Color background = Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_WHITE);
|
||||||
StyleRange range = new StyleRange(messagesText
|
StyleRange range = new StyleRange(messagesText
|
||||||
.getCharCount(), builder.length(), color, null,
|
.getCharCount(), builder.length(), foreground,
|
||||||
SWT.BOLD);
|
null, SWT.BOLD);
|
||||||
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
styleAndAppendText(builder, 0, builder.toString(), null,
|
styleAndAppendText(builder, 0, builder.toString(), null,
|
||||||
ranges, color);
|
ranges, foreground, background);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Archive the message
|
// Archive the message
|
||||||
|
|
|
@ -33,10 +33,8 @@ import org.eclipse.jface.action.Separator;
|
||||||
import org.eclipse.jface.action.ToolBarManager;
|
import org.eclipse.jface.action.ToolBarManager;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.ToolItem;
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
import org.eclipse.ui.IPartListener;
|
import org.eclipse.ui.IPartListener;
|
||||||
|
@ -53,6 +51,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
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.invite.ColorPopulator;
|
import com.raytheon.uf.viz.collaboration.comm.identity.invite.ColorPopulator;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.LeaderChangeEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.LeaderChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
|
@ -64,6 +63,7 @@ import com.raytheon.uf.viz.collaboration.display.data.ColorChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer.IDisplayContainerChangedListener;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer.IDisplayContainerChangedListener;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.SelfAddingSystemResourceListener;
|
import com.raytheon.uf.viz.collaboration.display.rsc.SelfAddingSystemResourceListener;
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent;
|
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent.CollaborationEventType;
|
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingEvent.CollaborationEventType;
|
||||||
|
@ -72,7 +72,8 @@ import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDr
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingToolLayer;
|
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingToolLayer;
|
||||||
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingUIManager;
|
import com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingUIManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ForegroundColorDlg;
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||||
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction.ChangeTextColorCallback;
|
||||||
import com.raytheon.uf.viz.core.ContextManager;
|
import com.raytheon.uf.viz.core.ContextManager;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||||
|
@ -82,7 +83,6 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
||||||
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
|
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
|
||||||
import com.raytheon.uf.viz.drawing.DrawingToolLayer;
|
import com.raytheon.uf.viz.drawing.DrawingToolLayer;
|
||||||
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
|
import com.raytheon.uf.viz.drawing.DrawingToolLayer.DrawMode;
|
||||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|
||||||
import com.raytheon.viz.ui.input.EditableManager;
|
import com.raytheon.viz.ui.input.EditableManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,6 +109,7 @@ import com.raytheon.viz.ui.input.EditableManager;
|
||||||
* Jun 30, 2014 1798 bclement added disableCurrentLayer()
|
* Jun 30, 2014 1798 bclement added disableCurrentLayer()
|
||||||
* Dev 02, 2014 3709 mapeters added {@link #initComponents()} override
|
* Dev 02, 2014 3709 mapeters added {@link #initComponents()} override
|
||||||
* Jan 09, 2015 3709 bclement now uses ForegroundColorDlg for consistency
|
* Jan 09, 2015 3709 bclement now uses ForegroundColorDlg for consistency
|
||||||
|
* Jan 13, 2015 3709 bclement now uses ChangeTextColorAction for consistency
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -132,8 +133,6 @@ public class CollaborationSessionView extends SessionView implements
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Action colorChangeAction;
|
|
||||||
|
|
||||||
private Action leaderChangeAction;
|
private Action leaderChangeAction;
|
||||||
|
|
||||||
private ActionContributionItem drawAction;
|
private ActionContributionItem drawAction;
|
||||||
|
@ -237,58 +236,10 @@ public class CollaborationSessionView extends SessionView implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.collaboration.ui.session.SessionView#initComponents
|
|
||||||
* (org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void initComponents(Composite parent) {
|
|
||||||
enableUserColors = false;
|
|
||||||
super.initComponents(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback used in the change color action. Gets the new color from the
|
|
||||||
* dialog and sends a color change event to the session
|
|
||||||
*/
|
|
||||||
private final ICloseCallback colorChangeCallback = new ICloseCallback() {
|
|
||||||
public void dialogClosed(Object returnValue) {
|
|
||||||
if (returnValue != null && returnValue instanceof RGB) {
|
|
||||||
RGB rgb = (RGB) returnValue;
|
|
||||||
IStructuredSelection selection = (IStructuredSelection) usersTable
|
|
||||||
.getSelection();
|
|
||||||
VenueParticipant entry = (VenueParticipant) selection
|
|
||||||
.getFirstElement();
|
|
||||||
ColorChangeEvent event = new ColorChangeEvent(entry, rgb);
|
|
||||||
try {
|
|
||||||
session.sendObjectToVenue(event);
|
|
||||||
} catch (CollaborationException e) {
|
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
|
||||||
"Unable to send color change to venue", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createActions() {
|
protected void createActions() {
|
||||||
super.createActions();
|
super.createActions();
|
||||||
Bundle bundle = Activator.getDefault().getBundle();
|
Bundle bundle = Activator.getDefault().getBundle();
|
||||||
colorChangeAction = new Action("Change Color...",
|
|
||||||
IconUtil.getImageDescriptor(bundle, "change_color.gif")) {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
ForegroundColorDlg dlg = new ForegroundColorDlg(Display
|
|
||||||
.getCurrent().getActiveShell(),
|
|
||||||
"Color changes will be seen by all participants of the "
|
|
||||||
+ session.getVenueName() + " session.");
|
|
||||||
dlg.setCloseCallback(colorChangeCallback);
|
|
||||||
dlg.open();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
leaderChangeAction = new Action("Transfer Leadership",
|
leaderChangeAction = new Action("Transfer Leadership",
|
||||||
IconUtil.getImageDescriptor(bundle, "leader_transfer.gif")) {
|
IconUtil.getImageDescriptor(bundle, "leader_transfer.gif")) {
|
||||||
|
@ -623,7 +574,7 @@ public class CollaborationSessionView extends SessionView implements
|
||||||
|| session.hasRole(SharedDisplayRole.SESSION_LEADER)) {
|
|| session.hasRole(SharedDisplayRole.SESSION_LEADER)) {
|
||||||
if (session.hasRole(SharedDisplayRole.SESSION_LEADER)) {
|
if (session.hasRole(SharedDisplayRole.SESSION_LEADER)) {
|
||||||
manager.add(new Separator());
|
manager.add(new Separator());
|
||||||
manager.add(colorChangeAction);
|
|
||||||
IStructuredSelection selection = (IStructuredSelection) usersTable
|
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||||
.getSelection();
|
.getSelection();
|
||||||
VenueParticipant entry = (VenueParticipant) selection
|
VenueParticipant entry = (VenueParticipant) selection
|
||||||
|
@ -636,6 +587,55 @@ public class CollaborationSessionView extends SessionView implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used in the change color action. Gets the new color from the
|
||||||
|
* dialog and sends a color change event to the session
|
||||||
|
*/
|
||||||
|
private final ChangeTextColorCallback sendColorEventCallback = new ChangeTextColorCallback() {
|
||||||
|
@Override
|
||||||
|
public void newColor(IUser user, UserColorInfo colors) {
|
||||||
|
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||||
|
.getSelection();
|
||||||
|
VenueParticipant entry = (VenueParticipant) selection
|
||||||
|
.getFirstElement();
|
||||||
|
ColorChangeEvent event = new ColorChangeEvent(entry,
|
||||||
|
colors.getForeground());
|
||||||
|
try {
|
||||||
|
session.sendObjectToVenue(event);
|
||||||
|
} catch (CollaborationException e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to send color change to venue", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.collaboration.ui.session.SessionView#addColorAction
|
||||||
|
* (org.eclipse.jface.action.IMenuManager,
|
||||||
|
* com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant,
|
||||||
|
* boolean)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addColorAction(IMenuManager manager, VenueParticipant user,
|
||||||
|
boolean me) {
|
||||||
|
if (session.hasRole(SharedDisplayRole.SESSION_LEADER)) {
|
||||||
|
String colorActionKey = user.getFQName();
|
||||||
|
|
||||||
|
ChangeTextColorAction<VenueParticipant> userColorAction = userColorActions
|
||||||
|
.get(colorActionKey);
|
||||||
|
if (userColorAction == null) {
|
||||||
|
userColorAction = new ChangeTextColorAction<VenueParticipant>(
|
||||||
|
user, me, me, true, colorManager);
|
||||||
|
userColorAction.setActionCallback(sendColorEventCallback);
|
||||||
|
userColorActions.put(colorActionKey, userColorAction);
|
||||||
|
}
|
||||||
|
manager.add(userColorAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void modifyColors(ColorPopulator populator) {
|
public void modifyColors(ColorPopulator populator) {
|
||||||
VizApp.runAsync(new Runnable() {
|
VizApp.runAsync(new Runnable() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.SharedDisplaySess
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
|
import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||||
* Feb 13, 2014 2751 njensen Added leader icons
|
* Feb 13, 2014 2751 njensen Added leader icons
|
||||||
* Feb 18, 2014 2751 bclement changed tooltip from JID to UserId
|
* Feb 18, 2014 2751 bclement changed tooltip from JID to UserId
|
||||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes, added actingSite
|
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes, added actingSite
|
||||||
|
* Jan 13, 2015 3709 bclement added support for foreground and background colors
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -71,10 +73,13 @@ public class ParticipantsLabelProvider extends
|
||||||
protected String sessionId = null;
|
protected String sessionId = null;
|
||||||
|
|
||||||
private String actingSite;
|
private String actingSite;
|
||||||
|
|
||||||
|
private static final RGB DEFAULT_FOREGROUND = new RGB(0,0,0);
|
||||||
|
private static final RGB DEFAULT_BACKGROUND = new RGB(255,255,255);
|
||||||
|
|
||||||
protected Map<RGB, Color> colors = new HashMap<RGB, Color>();
|
protected Map<RGB, Color> colors = new HashMap<RGB, Color>();
|
||||||
|
|
||||||
private SessionColorManager manager;
|
private SessionColorManager sessionColorManager;
|
||||||
|
|
||||||
private Font boldFont;
|
private Font boldFont;
|
||||||
|
|
||||||
|
@ -160,9 +165,34 @@ public class ParticipantsLabelProvider extends
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
VenueParticipant user = ((VenueParticipant) element);
|
VenueParticipant user = ((VenueParticipant) element);
|
||||||
RGB rgb = manager.getColorForUser(user);
|
|
||||||
|
UserColorInfo colors = sessionColorManager.getColorForUser(user);
|
||||||
|
RGB rgb = colors.getForeground();
|
||||||
|
return getTextColor(rgb, DEFAULT_FOREGROUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color getBackground(Object element) {
|
||||||
|
if (!(element instanceof VenueParticipant)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
VenueParticipant user = ((VenueParticipant) element);
|
||||||
|
|
||||||
|
UserColorInfo colors = sessionColorManager.getColorForUser(user);
|
||||||
|
RGB rgb = colors.getBackground();
|
||||||
|
return getTextColor(rgb, DEFAULT_BACKGROUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets text coloring for participant.
|
||||||
|
*
|
||||||
|
* @param rgb
|
||||||
|
* @param defaultColor
|
||||||
|
* @return default if rgb is null
|
||||||
|
*/
|
||||||
|
private Color getTextColor(RGB rgb, RGB defaultColor) {
|
||||||
if (rgb == null) {
|
if (rgb == null) {
|
||||||
rgb = new RGB(0, 0, 0);
|
rgb = defaultColor;
|
||||||
}
|
}
|
||||||
Color color = colors.get(rgb);
|
Color color = colors.get(rgb);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
|
@ -252,8 +282,8 @@ public class ParticipantsLabelProvider extends
|
||||||
* @param manager
|
* @param manager
|
||||||
* the manager to set
|
* the manager to set
|
||||||
*/
|
*/
|
||||||
public void setManager(SessionColorManager manager) {
|
public void setSessionColorManager(SessionColorManager manager) {
|
||||||
this.manager = manager;
|
this.sessionColorManager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.swt.custom.SashForm;
|
||||||
import org.eclipse.swt.custom.StyleRange;
|
import org.eclipse.swt.custom.StyleRange;
|
||||||
import org.eclipse.swt.custom.StyledText;
|
import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.jivesoftware.smack.packet.Presence.Type;
|
import org.jivesoftware.smack.packet.Presence.Type;
|
||||||
|
@ -49,9 +48,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterItem;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterItem;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.UserColorConfigManager;
|
import com.raytheon.uf.viz.collaboration.ui.colors.UserColorConfigManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTask;
|
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTask;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools;
|
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools;
|
||||||
|
@ -78,6 +77,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s as fields,
|
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s as fields,
|
||||||
* dispose them.
|
* dispose them.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
|
* Jan 13, 2015 3709 bclement ChangeTextColorAction API changes
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -93,24 +93,21 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
|
|
||||||
public static final String ID = "com.raytheon.uf.viz.collaboration.PeerToPeerView";
|
public static final String ID = "com.raytheon.uf.viz.collaboration.PeerToPeerView";
|
||||||
|
|
||||||
private static final Color DEFAULT_USER_FOREGROUND_COLOR = Display
|
|
||||||
.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
|
||||||
|
|
||||||
private static final Color DEFAULT_PEER_FOREGROUND_COLOR = Display
|
|
||||||
.getCurrent().getSystemColor(SWT.COLOR_RED);
|
|
||||||
|
|
||||||
private static final Color BLACK = Display.getCurrent().getSystemColor(
|
private static final Color BLACK = Display.getCurrent().getSystemColor(
|
||||||
SWT.COLOR_BLACK);
|
SWT.COLOR_BLACK);
|
||||||
|
|
||||||
|
private static final Color WHITE = Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_WHITE);
|
||||||
|
|
||||||
private IUser peer;
|
private IUser peer;
|
||||||
|
|
||||||
private boolean online = true;
|
private boolean online = true;
|
||||||
|
|
||||||
private static UserColorConfigManager colorConfigManager;
|
private static UserColorConfigManager colorManager;
|
||||||
|
|
||||||
private ChangeTextColorAction userColorAction;
|
private ChangeTextColorAction<IUser> userColorAction;
|
||||||
|
|
||||||
private ChangeTextColorAction peerColorAction;
|
private ChangeTextColorAction<IUser> peerColorAction;
|
||||||
|
|
||||||
public PeerToPeerView() {
|
public PeerToPeerView() {
|
||||||
super();
|
super();
|
||||||
|
@ -222,48 +219,40 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Color color = null;
|
Color foreground;
|
||||||
|
Color background;
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
color = BLACK;
|
foreground = BLACK;
|
||||||
} else if (!userId.equals(connection.getUser())) {
|
background = WHITE;
|
||||||
color = DEFAULT_PEER_FOREGROUND_COLOR;
|
|
||||||
} else {
|
} else {
|
||||||
color = DEFAULT_USER_FOREGROUND_COLOR;
|
UserColorInfo colors = colorManager.getColorForUser(userId);
|
||||||
|
foreground = getColorFromRGB(colors.getForeground());
|
||||||
|
background = getColorFromRGB(colors.getBackground());
|
||||||
}
|
}
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges, color);
|
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
||||||
|
background);
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void styleAndAppendText(StringBuilder sb, int offset, String name,
|
public void styleAndAppendText(StringBuilder sb, int offset, String name,
|
||||||
IUser userId, List<StyleRange> ranges, Color color) {
|
IUser userId, List<StyleRange> ranges, Color foreground,
|
||||||
Color fgColor = color;
|
Color background) {
|
||||||
Color bgColor = null;
|
|
||||||
|
|
||||||
if (userId != null) {
|
|
||||||
// get user colors from config manager
|
|
||||||
ColorInfo userColor = colorConfigManager.getColor(userId
|
|
||||||
.getFQName());
|
|
||||||
if (userColor != null) {
|
|
||||||
fgColor = getColorFromRGB(userColor.getColor(SWT.FOREGROUND));
|
|
||||||
bgColor = getColorFromRGB(userColor.getColor(SWT.BACKGROUND));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
||||||
sb.length(), fgColor, null, SWT.NORMAL);
|
sb.length(), foreground, null, SWT.NORMAL);
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
range = new StyleRange(messagesText.getCharCount() + offset,
|
||||||
(userId != null ? name.length() + 1 : sb.length() - offset),
|
(userId != null ? name.length() + 1 : sb.length() - offset),
|
||||||
fgColor, null, SWT.BOLD);
|
foreground, null, SWT.BOLD);
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
messagesText.append(sb.toString());
|
messagesText.append(sb.toString());
|
||||||
|
|
||||||
for (StyleRange newRange : ranges) {
|
for (StyleRange newRange : ranges) {
|
||||||
messagesText.setStyleRange(newRange);
|
messagesText.setStyleRange(newRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lineNumber = messagesText.getLineCount() - 1;
|
int lineNumber = messagesText.getLineCount() - 1;
|
||||||
messagesText.setLineBackground(lineNumber, 1, bgColor);
|
messagesText.setLineBackground(lineNumber, 1, background);
|
||||||
messagesText.setTopIndex(lineNumber);
|
messagesText.setTopIndex(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +319,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
@Override
|
@Override
|
||||||
protected void initComponents(Composite parent) {
|
protected void initComponents(Composite parent) {
|
||||||
super.initComponents(parent);
|
super.initComponents(parent);
|
||||||
colorConfigManager = UserColorConfigManager.getInstance();
|
colorManager = UserColorConfigManager.getInstance();
|
||||||
|
|
||||||
// unfortunately this code cannot be a part of createToolbarButton
|
// unfortunately this code cannot be a part of createToolbarButton
|
||||||
// because I cannot instantiate the ACI until after the messagesText
|
// because I cannot instantiate the ACI until after the messagesText
|
||||||
|
@ -400,10 +389,8 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
private void createDropDownMenu() {
|
private void createDropDownMenu() {
|
||||||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||||
UserId myUser = CollaborationConnection.getConnection().getUser();
|
UserId myUser = CollaborationConnection.getConnection().getUser();
|
||||||
RGB defaultUserForeground = DEFAULT_USER_FOREGROUND_COLOR.getRGB();
|
userColorAction = new ChangeTextColorAction<IUser>(myUser, true, true,
|
||||||
userColorAction = ChangeTextColorAction
|
false, colorManager);
|
||||||
.createChangeUserTextColorAction(myUser, true, true,
|
|
||||||
defaultUserForeground, colorConfigManager);
|
|
||||||
mgr.add(userColorAction);
|
mgr.add(userColorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,10 +399,8 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
||||||
*/
|
*/
|
||||||
public void addChangePeerColorAction() {
|
public void addChangePeerColorAction() {
|
||||||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||||
RGB defaultPeerForeground = DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
|
peerColorAction = new ChangeTextColorAction<IUser>(peer, false, true,
|
||||||
peerColorAction = ChangeTextColorAction
|
false, colorManager);
|
||||||
.createChangeUserTextColorAction(peer, false, true,
|
|
||||||
defaultPeerForeground, colorConfigManager);
|
|
||||||
mgr.add(peerColorAction);
|
mgr.add(peerColorAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
|
@ -31,9 +28,6 @@ import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.StyleRange;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
|
|
||||||
|
@ -45,8 +39,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.FeedColorConfigManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,6 +72,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||||
* Jan 05, 2015 3709 mapeters Use both site and user name as key in siteColorActions map.
|
* Jan 05, 2015 3709 mapeters Use both site and user name as key in siteColorActions map.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
|
* Jan 12, 2015 3709 bclement use parent object's session color manager, colors now based on user, not site
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -97,8 +90,6 @@ public class SessionFeedView extends SessionView {
|
||||||
|
|
||||||
private Action userRemoveSiteAction;
|
private Action userRemoveSiteAction;
|
||||||
|
|
||||||
private static FeedColorConfigManager colorConfigManager;
|
|
||||||
|
|
||||||
private String actingSite;
|
private String actingSite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,16 +99,13 @@ public class SessionFeedView extends SessionView {
|
||||||
|
|
||||||
private volatile boolean initialized = false;
|
private volatile boolean initialized = false;
|
||||||
|
|
||||||
private Map<String, ChangeTextColorAction> siteColorActions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public SessionFeedView() {
|
public SessionFeedView() {
|
||||||
super();
|
super();
|
||||||
actingSite = CollaborationConnection.getConnection()
|
actingSite = CollaborationConnection.getConnection().getPresence()
|
||||||
.getPresence().getProperty(SiteConfigInformation.SITE_NAME)
|
.getProperty(SiteConfigInformation.SITE_NAME).toString();
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -129,13 +117,8 @@ public class SessionFeedView extends SessionView {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initComponents(Composite parent) {
|
protected void initComponents(Composite parent) {
|
||||||
enableUserColors = false;
|
|
||||||
super.initComponents(parent);
|
super.initComponents(parent);
|
||||||
|
|
||||||
colorConfigManager = FeedColorConfigManager.getInstance();
|
|
||||||
usersTable.refresh();
|
usersTable.refresh();
|
||||||
|
|
||||||
siteColorActions = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -208,17 +191,6 @@ public class SessionFeedView extends SessionView {
|
||||||
protected void fillContextMenu(IMenuManager manager) {
|
protected void fillContextMenu(IMenuManager manager) {
|
||||||
super.fillContextMenu(manager);
|
super.fillContextMenu(manager);
|
||||||
String site = getSelectedSite();
|
String site = getSelectedSite();
|
||||||
VenueParticipant user = getSelectedParticipant();
|
|
||||||
String mapKey = site + " " + user.getName();
|
|
||||||
RGB defaultForeground = colorManager.getColorForUser(user);
|
|
||||||
ChangeTextColorAction siteColorAction = siteColorActions.get(mapKey);
|
|
||||||
if (siteColorAction == null) {
|
|
||||||
siteColorAction = ChangeTextColorAction
|
|
||||||
.createChangeSiteTextColorAction(site, defaultForeground,
|
|
||||||
colorConfigManager);
|
|
||||||
siteColorActions.put(mapKey, siteColorAction);
|
|
||||||
}
|
|
||||||
manager.add(siteColorAction);
|
|
||||||
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
|
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
|
||||||
userAddSiteAction
|
userAddSiteAction
|
||||||
.setText("Show Messages from " + getSelectedSite());
|
.setText("Show Messages from " + getSelectedSite());
|
||||||
|
@ -272,50 +244,12 @@ public class SessionFeedView extends SessionView {
|
||||||
|
|
||||||
// should we append?
|
// should we append?
|
||||||
if (site == null
|
if (site == null
|
||||||
|| SiteConfigurationManager
|
|| SiteConfigurationManager.isVisible(actingSite,
|
||||||
.isVisible(actingSite, site.toString())) {
|
site.toString())) {
|
||||||
appendMessage(msg);
|
appendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get site's foreground/background colors from colorConfigManager to pass
|
|
||||||
* to parent method.
|
|
||||||
*
|
|
||||||
* @param sb
|
|
||||||
* @param offset
|
|
||||||
* @param name
|
|
||||||
* @param userId
|
|
||||||
* @param ranges
|
|
||||||
* @param fgColor
|
|
||||||
* @param bgColor
|
|
||||||
* @param subject
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
|
||||||
String name, VenueParticipant userId, List<StyleRange> ranges,
|
|
||||||
Color fgColor, Color bgColor, String subject) {
|
|
||||||
String site = null;
|
|
||||||
if (subject != null) {
|
|
||||||
site = subject;
|
|
||||||
} else if (userId != null) {
|
|
||||||
Presence presence = session.getVenue().getPresence(userId);
|
|
||||||
if (presence != null) {
|
|
||||||
site = String.valueOf(presence
|
|
||||||
.getProperty(SiteConfigInformation.SITE_NAME));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (site != null) {
|
|
||||||
ColorInfo siteColor = colorConfigManager.getColor(site);
|
|
||||||
if (siteColor != null) {
|
|
||||||
fgColor = getColorFromRGB(siteColor.getColor(SWT.FOREGROUND));
|
|
||||||
bgColor = getColorFromRGB(siteColor.getColor(SWT.BACKGROUND));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.styleAndAppendText(sb, offset, name, userId, ranges, fgColor,
|
|
||||||
bgColor, subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the selected user
|
* Get the selected user
|
||||||
*
|
*
|
||||||
|
@ -488,12 +422,4 @@ public class SessionFeedView extends SessionView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
for (ChangeTextColorAction siteColorAction : siteColorActions.values()) {
|
|
||||||
siteColorAction.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.eclipse.swt.events.MouseTrackAdapter;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
@ -82,14 +81,13 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||||
|
import com.raytheon.uf.viz.collaboration.display.data.UserColorInfo;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
|
||||||
|
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction.ChangeTextColorCallback;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction;
|
import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.ColorInfoMap.ColorInfo;
|
import com.raytheon.uf.viz.collaboration.ui.colors.PersistentSessionColorManager;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.IColorConfigManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.RoomSpecificColorConfigManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.colors.TemporaryColorConfigManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||||
|
@ -125,6 +123,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||||
* Dec 02, 2014 3709 mapeters added color actions for group chats without shared display.
|
* Dec 02, 2014 3709 mapeters added color actions for group chats without shared display.
|
||||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s in map, dispose them.
|
||||||
* Jan 09, 2015 3709 bclement color config manager API changes
|
* Jan 09, 2015 3709 bclement color config manager API changes
|
||||||
|
* Jan 12, 2015 3709 bclement unified color management into SessionColorManager
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -158,11 +157,17 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
|
|
||||||
protected SessionColorManager colorManager;
|
protected SessionColorManager colorManager;
|
||||||
|
|
||||||
private IColorConfigManager colorConfigManager;
|
protected Map<String, ChangeTextColorAction<VenueParticipant>> userColorActions = new HashMap<>();
|
||||||
|
|
||||||
private Map<String, ChangeTextColorAction> userColorActions;
|
/*
|
||||||
|
* callback used to refresh participant list when the user adds/changes a
|
||||||
protected boolean enableUserColors = true;
|
* custom color configuration for a participant
|
||||||
|
*/
|
||||||
|
protected final ChangeTextColorCallback refreshCallback = new ChangeTextColorCallback() {
|
||||||
|
public void newColor(IUser user, UserColorInfo colors) {
|
||||||
|
refreshParticipantList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public SessionView() {
|
public SessionView() {
|
||||||
super();
|
super();
|
||||||
|
@ -185,17 +190,6 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
protected void initComponents(Composite parent) {
|
protected void initComponents(Composite parent) {
|
||||||
initColorManager();
|
initColorManager();
|
||||||
super.initComponents(parent);
|
super.initComponents(parent);
|
||||||
if (enableUserColors) {
|
|
||||||
IVenue venue = session.getVenue();
|
|
||||||
if (venue.isPersistent()) {
|
|
||||||
colorConfigManager = RoomSpecificColorConfigManager
|
|
||||||
.getManagerForRoom(venue.getId());
|
|
||||||
} else {
|
|
||||||
colorConfigManager = new TemporaryColorConfigManager(
|
|
||||||
venue.getId());
|
|
||||||
}
|
|
||||||
userColorActions = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// unfortunately this code cannot be a part of createToolbarButton
|
// unfortunately this code cannot be a part of createToolbarButton
|
||||||
// because I cannot instantiate the ACI until after the messagesText
|
// because I cannot instantiate the ACI until after the messagesText
|
||||||
|
@ -249,20 +243,22 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
if (!me) {
|
if (!me) {
|
||||||
manager.add(new PeerToPeerChatAction(entry));
|
manager.add(new PeerToPeerChatAction(entry));
|
||||||
}
|
}
|
||||||
if (enableUserColors) {
|
addColorAction(manager, entry, me);
|
||||||
// add color actions if in group chat room without shared display
|
}
|
||||||
String colorActionKey = entry.getFQName();
|
|
||||||
RGB defaultForeground = colorManager.getColorForUser(entry);
|
protected void addColorAction(IMenuManager manager, VenueParticipant user,
|
||||||
ChangeTextColorAction userColorAction = userColorActions
|
boolean me) {
|
||||||
.get(colorActionKey);
|
String colorActionKey = user.getFQName();
|
||||||
if (userColorAction == null) {
|
|
||||||
userColorAction = ChangeTextColorAction
|
ChangeTextColorAction<VenueParticipant> userColorAction = userColorActions
|
||||||
.createChangeUserTextColorAction(entry, me, me,
|
.get(colorActionKey);
|
||||||
defaultForeground, colorConfigManager);
|
if (userColorAction == null) {
|
||||||
userColorActions.put(colorActionKey, userColorAction);
|
userColorAction = new ChangeTextColorAction<VenueParticipant>(user,
|
||||||
}
|
me, me, false, colorManager);
|
||||||
manager.add(userColorAction);
|
userColorAction.setActionCallback(refreshCallback);
|
||||||
|
userColorActions.put(colorActionKey, userColorAction);
|
||||||
}
|
}
|
||||||
|
manager.add(userColorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -281,7 +277,13 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initColorManager() {
|
protected void initColorManager() {
|
||||||
colorManager = new SessionColorManager();
|
IVenue venue = session.getVenue();
|
||||||
|
if (venue.isPersistent()) {
|
||||||
|
colorManager = PersistentSessionColorManager
|
||||||
|
.getManagerForRoom(venue.getId());
|
||||||
|
} else {
|
||||||
|
colorManager = new SessionColorManager();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createUsersComp(final Composite parent) {
|
protected void createUsersComp(final Composite parent) {
|
||||||
|
@ -383,7 +385,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
usersTable.getTable().setLayout(layout);
|
usersTable.getTable().setLayout(layout);
|
||||||
usersTable.getTable().setLayoutData(data);
|
usersTable.getTable().setLayoutData(data);
|
||||||
|
|
||||||
ParticipantsLabelProvider labelProvider = new ParticipantsLabelProvider();
|
ParticipantsLabelProvider labelProvider = createParticipantsLabelProvider();
|
||||||
setParticipantValues(labelProvider);
|
setParticipantValues(labelProvider);
|
||||||
usersTable.setContentProvider(ArrayContentProvider.getInstance());
|
usersTable.setContentProvider(ArrayContentProvider.getInstance());
|
||||||
|
|
||||||
|
@ -434,9 +436,13 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
((GridData) usersComp.getLayoutData()).exclude = true;
|
((GridData) usersComp.getLayoutData()).exclude = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ParticipantsLabelProvider createParticipantsLabelProvider() {
|
||||||
|
return new ParticipantsLabelProvider();
|
||||||
|
}
|
||||||
|
|
||||||
protected void setParticipantValues(ParticipantsLabelProvider labelProvider) {
|
protected void setParticipantValues(ParticipantsLabelProvider labelProvider) {
|
||||||
labelProvider.setSessionId(sessionId);
|
labelProvider.setSessionId(sessionId);
|
||||||
labelProvider.setManager(colorManager);
|
labelProvider.setSessionColorManager(colorManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -447,12 +453,8 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
disposeArrow(downArrow);
|
disposeArrow(downArrow);
|
||||||
disposeArrow(rightArrow);
|
disposeArrow(rightArrow);
|
||||||
|
|
||||||
if (colorManager != null) {
|
|
||||||
colorManager.clearColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userColorActions != null) {
|
if (userColorActions != null) {
|
||||||
for (ChangeTextColorAction userColorAction : userColorActions
|
for (ChangeTextColorAction<?> userColorAction : userColorActions
|
||||||
.values()) {
|
.values()) {
|
||||||
userColorAction.dispose();
|
userColorAction.dispose();
|
||||||
}
|
}
|
||||||
|
@ -510,9 +512,10 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, VenueParticipant userId, String subject,
|
String name, VenueParticipant userId, String subject,
|
||||||
List<StyleRange> ranges) {
|
List<StyleRange> ranges) {
|
||||||
RGB rgb = colorManager.getColorForUser(userId);
|
UserColorInfo colors = colorManager.getColorForUser(userId);
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges,
|
styleAndAppendText(sb, offset, name, userId, ranges,
|
||||||
getColorFromRGB(rgb), null, subject);
|
getColorFromRGB(colors.getForeground()),
|
||||||
|
getColorFromRGB(colors.getBackground()), subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -526,22 +529,14 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
||||||
@Override
|
@Override
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, VenueParticipant userId, List<StyleRange> ranges,
|
String name, VenueParticipant userId, List<StyleRange> ranges,
|
||||||
Color color) {
|
Color foreground, Color background) {
|
||||||
styleAndAppendText(sb, offset, name, userId, ranges, color, null, null);
|
styleAndAppendText(sb, offset, name, userId, ranges, foreground,
|
||||||
|
background, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void styleAndAppendText(StringBuilder sb, int offset,
|
protected void styleAndAppendText(StringBuilder sb, int offset,
|
||||||
String name, VenueParticipant userId, List<StyleRange> ranges,
|
String name, VenueParticipant userId, List<StyleRange> ranges,
|
||||||
Color fgColor, Color bgColor, String subject) {
|
Color fgColor, Color bgColor, String subject) {
|
||||||
if (enableUserColors && userId != null) {
|
|
||||||
// Color text by user if in group chat room without shared display
|
|
||||||
ColorInfo userColor = colorConfigManager.getColor(userId
|
|
||||||
.getFQName());
|
|
||||||
if (userColor != null) {
|
|
||||||
fgColor = getColorFromRGB(userColor.getColor(SWT.FOREGROUND));
|
|
||||||
bgColor = getColorFromRGB(userColor.getColor(SWT.BACKGROUND));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
||||||
sb.length(), fgColor, null, SWT.NORMAL);
|
sb.length(), fgColor, null, SWT.NORMAL);
|
||||||
ranges.add(range);
|
ranges.add(range);
|
||||||
|
|
Loading…
Add table
Reference in a new issue