Omaha #3709 Collaboration chat colors for PeerToPeerView
Change-Id: I78a5f13caa685c993a28293f6a110fd52b2b7b08 Former-commit-id:9942ce6961
[formerly10179bb1f4
] [formerly0332e4e693
] [formerly9942ce6961
[formerly10179bb1f4
] [formerly0332e4e693
] [formerly3d43e87374
[formerly0332e4e693
[formerly 341b54d6d23f08499345b8972a77acc9e2ca8c8b]]]] Former-commit-id:3d43e87374
Former-commit-id:74a79abcb3
[formerlya800e0eb0b
] [formerly c7920bfb444c6e3b04db9e13d9c06aefee44d761 [formerly6ff9cdd45b
]] Former-commit-id: b5ba935cd73735cc2ea7e96d9e3927b83baa4884 [formerly80202e6821
] Former-commit-id:0dd5b76917
This commit is contained in:
parent
df5f8cebb7
commit
64ff038b89
10 changed files with 514 additions and 284 deletions
|
@ -98,9 +98,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
|||
import com.raytheon.uf.viz.collaboration.ui.actions.AddNotifierAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.AddToGroupAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ArchiveViewerAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeBackgroundColorAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeFontAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeForegroundColorAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangePasswordAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeRoleAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeSiteAction;
|
||||
|
@ -163,6 +161,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
|||
* May 19, 2014 3180 bclement fixed inviting multiple users to session
|
||||
* Oct 08, 2014 3705 bclement added room search and bookmarking
|
||||
* Oct 14, 2014 3709 mapeters Added change background/foreground color actions to menu.
|
||||
* Nov 14, 2014 3709 mapeters Removed change background/foreground color actions from menu.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -364,8 +363,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
mgr.add(roomSearchAction);
|
||||
mgr.add(new Separator());
|
||||
mgr.add(new ChangeFontAction());
|
||||
mgr.add(new ChangeForegroundColorAction());
|
||||
mgr.add(new ChangeBackgroundColorAction());
|
||||
mgr.add(new Separator());
|
||||
mgr.add(new ChangeStatusAction());
|
||||
mgr.add(new ChangeStatusMessageAction());
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.plaf.synth.ColorType;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
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.viz.collaboration.ui.UserColorInformation.UserColor;
|
||||
|
||||
/**
|
||||
* User coloring configuration manager
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2014 3709 mapeters Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
public class UserColorConfigManager {
|
||||
|
||||
private static UserColorInformation colorInfo;
|
||||
|
||||
private UserColorConfigManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and store the color type of the given user to be the given rgb. If
|
||||
* creating new {@link UserColor} and setting background, set foreground to
|
||||
* defaultForeground to prevent it from incorrectly defaulting.
|
||||
*
|
||||
* @param user
|
||||
* @param type
|
||||
* @param rgb
|
||||
* @param defaultForeground
|
||||
*/
|
||||
public synchronized static void setColorForUser(String user,
|
||||
ColorType type, RGB rgb, RGB defaultForeground) {
|
||||
if (colorInfo == null) {
|
||||
colorInfo = new UserColorInformation();
|
||||
}
|
||||
Map<String, UserColor> colors = colorInfo.getColors();
|
||||
if (colors == null) {
|
||||
colorInfo.setColors(new HashMap<String, UserColor>());
|
||||
colors = colorInfo.getColors();
|
||||
}
|
||||
|
||||
UserColor userColor = colors.get(user);
|
||||
if (userColor != null) {
|
||||
userColor.setColor(type, rgb, null);
|
||||
} else {
|
||||
UserColor color = new UserColor();
|
||||
color.setColor(type, rgb, defaultForeground);
|
||||
colors.put(user, color);
|
||||
}
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lContext = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile file = pathMgr.getLocalizationFile(lContext,
|
||||
"collaboration" + IPathManager.SEPARATOR + "userColorInfo.xml");
|
||||
try {
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(UserColorInformation.class);
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
|
||||
new Boolean(true));
|
||||
marshaller.marshal(colorInfo, file.getFile());
|
||||
file.save();
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.error(
|
||||
"Unable to write color information to file: "
|
||||
+ file.getName() + " in context " + lContext, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link UserColor} for the given user from memory.
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public synchronized static UserColor getColorForUser(String user) {
|
||||
if(colorInfo == null) {
|
||||
IPathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
LocalizationContext locContext = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile file = pm.getLocalizationFile(locContext,
|
||||
"collaboration" + IPathManager.SEPARATOR
|
||||
+ "userColorInfo.xml");
|
||||
|
||||
if (file != null && file.exists()) {
|
||||
try (InputStream in = file.openInputStream()) {
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(UserColorInformation.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
colorInfo = (UserColorInformation) unmarshaller
|
||||
.unmarshal(in);
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.error(
|
||||
"Unable to read color information from file: "
|
||||
+ file.getName() + " in level "
|
||||
+ LocalizationLevel.USER, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(colorInfo != null) {
|
||||
Map<String, UserColor> colors = colorInfo.getColors();
|
||||
if (colors != null) {
|
||||
return colors.get(user);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.plaf.synth.ColorType;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
/**
|
||||
* Contains foreground and background chat colors for a list of users
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2014 3709 mapeters Initial creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class UserColorInformation {
|
||||
|
||||
@XmlElement
|
||||
private Map<String, UserColor> colors;
|
||||
|
||||
/**
|
||||
* @return the colors
|
||||
*/
|
||||
public Map<String, UserColor> getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colors
|
||||
* the colors to set
|
||||
*/
|
||||
public void setColors(Map<String, UserColor> colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public static class UserColor {
|
||||
|
||||
/**
|
||||
* tells {@link #setColor()} when to use defaultForeground
|
||||
*/
|
||||
@XmlAttribute
|
||||
private boolean fgSet;
|
||||
|
||||
@XmlAttribute
|
||||
private int fgRed;
|
||||
|
||||
@XmlAttribute
|
||||
private int fgGreen;
|
||||
|
||||
@XmlAttribute
|
||||
private int fgBlue;
|
||||
|
||||
/**
|
||||
* background should default to white
|
||||
*/
|
||||
@XmlAttribute
|
||||
private int bgRed = 255;
|
||||
|
||||
@XmlAttribute
|
||||
private int bgGreen = 255;
|
||||
|
||||
@XmlAttribute
|
||||
private int bgBlue = 255;
|
||||
|
||||
public UserColor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @return the red
|
||||
*/
|
||||
public int getRed(ColorType type) {
|
||||
return type == ColorType.FOREGROUND ? fgRed : bgRed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param red
|
||||
* the red to set
|
||||
*/
|
||||
public void setRed(ColorType type, int red) {
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
this.fgRed = red;
|
||||
} else {
|
||||
this.bgRed = red;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @return the green
|
||||
*/
|
||||
public int getGreen(ColorType type) {
|
||||
return type == ColorType.FOREGROUND ? fgGreen : bgGreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param green
|
||||
* the green to set
|
||||
*/
|
||||
public void setGreen(ColorType type, int green) {
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
this.fgGreen = green;
|
||||
} else {
|
||||
this.bgGreen = green;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @return the blue
|
||||
*/
|
||||
public int getBlue(ColorType type) {
|
||||
return type == ColorType.FOREGROUND ? fgBlue : bgBlue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param blue
|
||||
* the blue to set
|
||||
*/
|
||||
public void setBlue(ColorType type, int blue) {
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
this.fgBlue = blue;
|
||||
} else {
|
||||
this.bgBlue = blue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @return the RGB color of the given type
|
||||
*/
|
||||
public RGB getColor(ColorType type) {
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
return new RGB(fgRed, fgGreen, fgBlue);
|
||||
} else {
|
||||
return new RGB(bgRed, bgGreen, bgBlue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color of the given type to the given rgb
|
||||
*
|
||||
* @param type
|
||||
* @param rgb
|
||||
* @param defaultForeground
|
||||
*/
|
||||
public void setColor(ColorType type, RGB rgb, RGB defaultForeground) {
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
fgRed = rgb.red;
|
||||
fgGreen = rgb.green;
|
||||
fgBlue = rgb.blue;
|
||||
fgSet = true;
|
||||
} else {
|
||||
bgRed = rgb.red;
|
||||
bgGreen = rgb.green;
|
||||
bgBlue = rgb.blue;
|
||||
if (!fgSet) {
|
||||
/*
|
||||
* if creating new UserColor, set fgColor to default
|
||||
* foreground color, otherwise it defaults to black
|
||||
*/
|
||||
setColor(ColorType.FOREGROUND, defaultForeground, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,73 +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.actions;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.ColorDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
|
||||
import com.raytheon.uf.viz.core.preferences.PreferenceConverter;
|
||||
|
||||
/**
|
||||
* Open change background color dialog
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 14, 2014 3709 mapeters Initial creation.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ChangeBackgroundColorAction extends Action {
|
||||
|
||||
public ChangeBackgroundColorAction() {
|
||||
super("Change Background Color...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ColorDialog dialog = new ColorDialog(Display.getCurrent()
|
||||
.getActiveShell());
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
RGB data = PreferenceConverter.getRGB(store, "bg", "white");
|
||||
dialog.setRGB(data);
|
||||
RGB postData = dialog.open();
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (postData != null && connection != null) {
|
||||
PreferenceConverter.setValue(store, "bg", postData);
|
||||
connection.postEvent(ChatDisplayChangeEvent.createColorEvent(
|
||||
ChangeType.BACKGROUND, postData));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -40,7 +40,8 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 6, 2012 bsteffen Initial creation
|
||||
* Oct 14, 2014 3709 mapeters Post event using {@link ChatDisplayChangeEvent}.
|
||||
* Oct 14, 2014 3709 mapeters Post event using ChatDisplayChangeEvent.
|
||||
* Nov 14, 2014 3709 mapeters Changed back to posting event using FontData.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -67,8 +68,7 @@ public class ChangeFontAction extends Action {
|
|||
.getConnection();
|
||||
if (postData != null && connection != null) {
|
||||
PreferenceConverter.setValue(store, "font", postData);
|
||||
connection.postEvent(ChatDisplayChangeEvent
|
||||
.createFontEvent(postData));
|
||||
connection.postEvent(postData);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,73 +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.actions;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.ColorDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
|
||||
import com.raytheon.uf.viz.core.preferences.PreferenceConverter;
|
||||
|
||||
/**
|
||||
* Open change foreground color dialog
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 14, 2014 3709 mapeters Initial creation.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ChangeForegroundColorAction extends Action {
|
||||
|
||||
public ChangeForegroundColorAction() {
|
||||
super("Change Foreground Color...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ColorDialog dialog = new ColorDialog(Display.getCurrent()
|
||||
.getActiveShell());
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
RGB data = PreferenceConverter.getRGB(store, "fg", "black");
|
||||
dialog.setRGB(data);
|
||||
RGB postData = dialog.open();
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (postData != null && connection != null) {
|
||||
PreferenceConverter.setValue(store, "fg", postData);
|
||||
connection.postEvent(ChatDisplayChangeEvent.createColorEvent(
|
||||
ChangeType.FOREGROUND, postData));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,84 +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.actions;
|
||||
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
/**
|
||||
* Store font/color change information
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 14, 2014 3709 mapeters Initial creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mapeters
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ChatDisplayChangeEvent {
|
||||
|
||||
private ChangeType type;
|
||||
|
||||
private RGB color;
|
||||
|
||||
private FontData font;
|
||||
|
||||
public enum ChangeType {
|
||||
BACKGROUND, FOREGROUND, FONT;
|
||||
}
|
||||
|
||||
private ChatDisplayChangeEvent(ChangeType type, RGB color) {
|
||||
this.type = type;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
private ChatDisplayChangeEvent(ChangeType type, FontData font) {
|
||||
this.type = type;
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public static ChatDisplayChangeEvent createColorEvent(ChangeType type,
|
||||
RGB color) {
|
||||
return new ChatDisplayChangeEvent(type, color);
|
||||
}
|
||||
|
||||
public static ChatDisplayChangeEvent createFontEvent(FontData font) {
|
||||
return new ChatDisplayChangeEvent(ChangeType.FONT, font);
|
||||
}
|
||||
|
||||
public RGB getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public ChangeType getChangeType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public FontData getFont() {
|
||||
return this.font;
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
|||
* Jul 3, 2012 bsteffen Initial creation
|
||||
* Jun 17, 2014 3078 bclement changed user type to IUser, added isAvailable()
|
||||
* Jun 20, 2014 3281 bclement fixed secondary id bug by using user.getClientIndependentId()
|
||||
* Nov 14, 2014 3709 mapeters upon creation of p2p chat, add color change menu actions
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -140,6 +141,11 @@ public class PeerToPeerChatAction extends Action {
|
|||
viewMode);
|
||||
if (p2pView.getPeer() == null) {
|
||||
p2pView.setPeer(user);
|
||||
/*
|
||||
* add color change actions to P2P right click menu upon first
|
||||
* creation of P2P chat.
|
||||
*/
|
||||
p2pView.addChangeUserColorActions();
|
||||
}
|
||||
return p2pView;
|
||||
} catch (PartInitException e) {
|
||||
|
|
|
@ -61,8 +61,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.CopyTextAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.CutTextAction;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.PasteTextAction;
|
||||
|
@ -97,6 +95,8 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
|
|||
* Jun 27, 2014 3323 bclement fixed disposed font issue
|
||||
* Oct 09, 2014 3711 mapeters Display chat text in accordance with preferences.
|
||||
* Oct 14, 2014 3709 mapeters Support changing foreground/background color.
|
||||
* Nov 14, 2014 3709 mapeters Changing foreground/background colors no longer
|
||||
* implemented here, added messagesTextMenuMgr.
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
|
@ -126,6 +126,8 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
/** Font used with the messagesText control. */
|
||||
private Font messagesTextFont;
|
||||
|
||||
protected MenuManager messagesTextMenuMgr;
|
||||
|
||||
private StyledText composeText;
|
||||
|
||||
protected SessionMsgArchive msgArchive;
|
||||
|
@ -223,23 +225,13 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
store, "font"));
|
||||
messagesText.setFont(messagesTextFont);
|
||||
|
||||
// grab the background color from preferences (default to white)
|
||||
RGB bgColor = com.raytheon.uf.viz.core.preferences.PreferenceConverter
|
||||
.getRGB(store, "bg", "white");
|
||||
messagesText.setBackground(new Color(Display.getCurrent(), bgColor));
|
||||
|
||||
// grab the foreground color from preferences (default to black)
|
||||
RGB fgColor = com.raytheon.uf.viz.core.preferences.PreferenceConverter
|
||||
.getRGB(store, "fg", "black");
|
||||
messagesText.setForeground(new Color(Display.getCurrent(), fgColor));
|
||||
|
||||
searchComp.setSearchText(messagesText);
|
||||
|
||||
// adding a menu item so that Paste can be found when clicking on the
|
||||
// composeText styledtext
|
||||
MenuManager menuMgr = new MenuManager();
|
||||
menuMgr.add(new CopyTextAction(messagesText));
|
||||
Menu menu = menuMgr.createContextMenu(messagesText);
|
||||
messagesTextMenuMgr = new MenuManager();
|
||||
messagesTextMenuMgr.add(new CopyTextAction(messagesText));
|
||||
Menu menu = messagesTextMenuMgr.createContextMenu(messagesText);
|
||||
messagesText.setMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -591,20 +583,12 @@ public abstract class AbstractSessionView<T extends IUser> extends
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void changeChatDisplay(ChatDisplayChangeEvent event) {
|
||||
ChangeType type = event.getChangeType();
|
||||
if (type == ChangeType.FOREGROUND) {
|
||||
messagesText.setForeground(new Color(Display.getCurrent(), event.getColor()));
|
||||
} else if (type == ChangeType.BACKGROUND) {
|
||||
messagesText.setBackground(new Color(Display.getCurrent(), event
|
||||
.getColor()));
|
||||
} else if (type == ChangeType.FONT) {
|
||||
Font oldFont = messagesTextFont;
|
||||
messagesTextFont = new Font(Display.getCurrent(), event.getFont());
|
||||
messagesText.setFont(messagesTextFont);
|
||||
if (oldFont != null) {
|
||||
oldFont.dispose();
|
||||
}
|
||||
public void changeFont(FontData data) {
|
||||
Font oldFont = messagesTextFont;
|
||||
messagesTextFont = new Font(Display.getCurrent(), data);
|
||||
messagesText.setFont(messagesTextFont);
|
||||
if (oldFont != null) {
|
||||
oldFont.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,13 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.plaf.synth.ColorType;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IContributionItem;
|
||||
import org.eclipse.jface.action.ToolBarManager;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -31,6 +36,8 @@ import org.eclipse.swt.custom.SashForm;
|
|||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.ColorDialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.jivesoftware.smack.packet.Presence.Type;
|
||||
|
@ -47,9 +54,13 @@ 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.UserId;
|
||||
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.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.UserColorInformation.UserColor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
|
||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTask;
|
||||
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
||||
|
||||
/**
|
||||
|
@ -66,6 +77,8 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* Feb 13, 2014 2751 bclement made parent generic
|
||||
* Feb 28, 2014 2632 mpduff Override appendMessage for notifiers
|
||||
* Jun 17, 2014 3078 bclement changed peer type to IUser
|
||||
* Nov 14, 2014 3709 mapeters support foregound/background color
|
||||
* settings for each user
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,11 +94,16 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
|
||||
public static final String ID = "com.raytheon.uf.viz.collaboration.PeerToPeerView";
|
||||
|
||||
private static Color userColor = null;
|
||||
private static final Color DEFAULT_USER_FOREGROUND_COLOR = Display
|
||||
.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
||||
|
||||
private static Color chatterColor = null;
|
||||
private static final Color DEFAULT_PEER_FOREGROUND_COLOR = Display
|
||||
.getCurrent().getSystemColor(SWT.COLOR_RED);
|
||||
|
||||
private static Color black = null;
|
||||
private static final Color BLACK = Display.getCurrent().getSystemColor(
|
||||
SWT.COLOR_BLACK);
|
||||
|
||||
private Map<RGB, Color> rgbToColor = new HashMap<>();
|
||||
|
||||
private IUser peer;
|
||||
|
||||
|
@ -93,9 +111,6 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
|
||||
public PeerToPeerView() {
|
||||
super();
|
||||
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
||||
chatterColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
|
||||
black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
|
||||
CollaborationConnection.getConnection().registerEventHandler(this);
|
||||
}
|
||||
|
||||
|
@ -113,6 +128,10 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
conn.unregisterEventHandler(this);
|
||||
}
|
||||
super.dispose();
|
||||
|
||||
for (Color color : rgbToColor.values()) {
|
||||
color.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -202,11 +221,11 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
}
|
||||
Color color = null;
|
||||
if (userId == null) {
|
||||
color = black;
|
||||
color = BLACK;
|
||||
} else if (!userId.equals(connection.getUser())) {
|
||||
color = chatterColor;
|
||||
color = DEFAULT_PEER_FOREGROUND_COLOR;
|
||||
} else {
|
||||
color = userColor;
|
||||
color = DEFAULT_USER_FOREGROUND_COLOR;
|
||||
}
|
||||
styleAndAppendText(sb, offset, name, userId, ranges, color);
|
||||
};
|
||||
|
@ -214,22 +233,52 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
@Override
|
||||
public void styleAndAppendText(StringBuilder sb, int offset, String name,
|
||||
IUser userId, List<StyleRange> ranges, Color color) {
|
||||
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
|
||||
color, null, SWT.NORMAL);
|
||||
ranges.add(range);
|
||||
Color fgColor = color;
|
||||
Color bgColor = null;
|
||||
|
||||
if (userId != null) {
|
||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
||||
name.length() + 1, color, null, SWT.BOLD);
|
||||
} else {
|
||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
||||
sb.length() - offset, color, null, SWT.BOLD);
|
||||
// get user colors from config manager
|
||||
UserColor userColor = UserColorConfigManager.getColorForUser(userId
|
||||
.getName());
|
||||
if (userColor != null) {
|
||||
fgColor = getColorFromRGB(userColor
|
||||
.getColor(ColorType.FOREGROUND));
|
||||
bgColor = getColorFromRGB(userColor
|
||||
.getColor(ColorType.BACKGROUND));
|
||||
}
|
||||
}
|
||||
|
||||
StyleRange range = new StyleRange(messagesText.getCharCount(),
|
||||
sb.length(), fgColor, null, SWT.NORMAL);
|
||||
ranges.add(range);
|
||||
range = new StyleRange(messagesText.getCharCount() + offset,
|
||||
(userId != null ? name.length() + 1 : sb.length() - offset),
|
||||
fgColor, null, SWT.BOLD);
|
||||
ranges.add(range);
|
||||
messagesText.append(sb.toString());
|
||||
|
||||
for (StyleRange newRange : ranges) {
|
||||
messagesText.setStyleRange(newRange);
|
||||
}
|
||||
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
||||
|
||||
int lineNumber = messagesText.getLineCount() - 1;
|
||||
messagesText.setLineBackground(lineNumber, 1, bgColor);
|
||||
messagesText.setTopIndex(lineNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get corresponding Color from map using RGB
|
||||
*
|
||||
* @param rgb
|
||||
* @return
|
||||
*/
|
||||
private Color getColorFromRGB(RGB rgb) {
|
||||
Color color = rgbToColor.get(rgb);
|
||||
if (color == null) {
|
||||
color = new Color(Display.getCurrent(), rgb);
|
||||
rgbToColor.put(rgb, color);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -351,4 +400,69 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
return peer.getFQName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add right-click menu options for changing foreground/background colors
|
||||
* for each user
|
||||
*/
|
||||
public void addChangeUserColorActions() {
|
||||
String myName = CollaborationConnection.getConnection().getUser()
|
||||
.getName();
|
||||
String peerName = peer.getName();
|
||||
messagesTextMenuMgr.add(new ChangeUserColorAction(ColorType.BACKGROUND,
|
||||
myName, true));
|
||||
messagesTextMenuMgr.add(new ChangeUserColorAction(ColorType.FOREGROUND,
|
||||
myName, true));
|
||||
messagesTextMenuMgr.add(new ChangeUserColorAction(ColorType.BACKGROUND,
|
||||
peerName, false));
|
||||
messagesTextMenuMgr.add(new ChangeUserColorAction(ColorType.FOREGROUND,
|
||||
peerName, false));
|
||||
}
|
||||
|
||||
/*
|
||||
* action for changing foreground/background color for a given user
|
||||
*/
|
||||
private class ChangeUserColorAction extends Action {
|
||||
|
||||
ColorType type;
|
||||
|
||||
String user;
|
||||
|
||||
boolean me;
|
||||
|
||||
public ChangeUserColorAction(ColorType type, String user, boolean me) {
|
||||
super("Change " + (me ? "Your " : (user + "'s ")) + type.toString()
|
||||
+ " Color...", IconUtil.getImageDescriptor(Activator
|
||||
.getDefault().getBundle(), "change_color.gif"));
|
||||
this.type = type;
|
||||
this.user = user;
|
||||
this.me = me;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ColorDialog dialog = new ColorDialog(Display.getCurrent()
|
||||
.getActiveShell());
|
||||
RGB defaultForeground = null;
|
||||
UserColor userColor = UserColorConfigManager.getColorForUser(user);
|
||||
if (userColor != null) {
|
||||
dialog.setRGB(userColor.getColor(type));
|
||||
} else {
|
||||
defaultForeground = me ? DEFAULT_USER_FOREGROUND_COLOR.getRGB()
|
||||
: DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
|
||||
if (type == ColorType.FOREGROUND) {
|
||||
/*
|
||||
* set the dialog to display default foreground color as
|
||||
* currently selected
|
||||
*/
|
||||
dialog.setRGB(defaultForeground);
|
||||
}
|
||||
}
|
||||
RGB rgb = dialog.open();
|
||||
if (rgb != null) {
|
||||
UserColorConfigManager.setColorForUser(user, type, rgb,
|
||||
defaultForeground);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue