Omaha #3709 Fix some minor issues with collaboration colors.
Change-Id: I07fbcd6db21c3ee3b5fa404ad1c004af7e3ac057 Former-commit-id: f028c5040e50d3a2c96294d5c4d7ddd0e360defb
This commit is contained in:
parent
bdc8b9e8c0
commit
530b52d7db
5 changed files with 52 additions and 43 deletions
|
@ -480,8 +480,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
ChangeTextColorAction userColorAction = userColorActions.get(name);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, false, new RGB(
|
||||
0, 0, 255), new UserColorConfigManager());
|
||||
.createChangeUserTextColorAction(name, false, false,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
}
|
||||
manager.add(userColorAction);
|
||||
|
@ -498,9 +499,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
.get(name);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, true,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
.createChangeUserTextColorAction(name, true, true,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
}
|
||||
manager.insertBefore("afterFont", userColorAction);
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* ChangeUserColorAction, support both user and site colors.
|
||||
* 12/12/14 3709 mapeters Use static methods to call constructor, icon displays
|
||||
* current foreground and background colors.
|
||||
* 01/05/15 3709 mapeters Added getTextColors(), added me param to createChangeUserTextColorAction().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,18 +76,22 @@ public class ChangeTextColorAction extends Action {
|
|||
* Create and return new action for changing user colors.
|
||||
*
|
||||
* @param user
|
||||
* the user whose colors may be changed by this action
|
||||
* @param me
|
||||
* whether the selected user is the current user
|
||||
* @param displayName
|
||||
* whether to display the user's name or simply "User"
|
||||
* @param defaultForeground
|
||||
* the foreground color to use if none is stored
|
||||
* @param colorConfigManager
|
||||
* manager to store/retrieve user colors
|
||||
* @return
|
||||
*/
|
||||
public static ChangeTextColorAction createChangeUserTextColorAction(
|
||||
String user, boolean displayName, RGB defaultForeground,
|
||||
UserColorConfigManager colorConfigManager) {
|
||||
String user, boolean me, boolean displayName,
|
||||
RGB defaultForeground, UserColorConfigManager colorConfigManager) {
|
||||
String text = "Change ";
|
||||
if (displayName) {
|
||||
boolean me = CollaborationConnection.getConnection().getUser()
|
||||
.getName().equals(user);
|
||||
text += me ? "Your" : (user + "'s");
|
||||
} else {
|
||||
text += "User";
|
||||
|
@ -101,8 +106,11 @@ public class ChangeTextColorAction extends Action {
|
|||
* Create and return new action for changing site colors.
|
||||
*
|
||||
* @param site
|
||||
* the site whose colors may be changed by this action
|
||||
* @param defaultForeground
|
||||
* the foreground color to use if none is stored
|
||||
* @param colorConfigManager
|
||||
* manager to store/retrieve site colors
|
||||
* @return
|
||||
*/
|
||||
public static ChangeTextColorAction createChangeSiteTextColorAction(
|
||||
|
@ -119,39 +127,17 @@ public class ChangeTextColorAction extends Action {
|
|||
this.defaultForeground = defaultForeground;
|
||||
this.colorConfigManager = colorConfigManager;
|
||||
|
||||
ColorInfo colorInfo = colorConfigManager.getColor(key);
|
||||
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);
|
||||
}
|
||||
setIconColors(foreground, background);
|
||||
RGB[] colors = getTextColors();
|
||||
setIconColors(colors[0], colors[1]);
|
||||
|
||||
CollaborationConnection.getConnection().registerEventHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ColorInfo colorInfo = colorConfigManager.getColor(key);
|
||||
RGB foreground;
|
||||
RGB background;
|
||||
if (colorInfo != null) {
|
||||
foreground = colorInfo.getColor(SWT.FOREGROUND);
|
||||
background = colorInfo.getColor(SWT.BACKGROUND);
|
||||
} else {
|
||||
/*
|
||||
* Set dialog to display default colors
|
||||
*/
|
||||
foreground = defaultForeground;
|
||||
background = new RGB(255, 255, 255);
|
||||
}
|
||||
|
||||
RGB[] colors = getTextColors();
|
||||
ForegroundBackgroundColorDlg dialog = new ForegroundBackgroundColorDlg(
|
||||
Display.getCurrent().getActiveShell(), foreground, background);
|
||||
Display.getCurrent().getActiveShell(), colors[0], colors[1]);
|
||||
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
|
@ -174,6 +160,26 @@ public class ChangeTextColorAction extends Action {
|
|||
dialog.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stored colors (or default colors) of this action's user/site
|
||||
*
|
||||
* @return RGB array of length 2 with foreground color in index 0 and
|
||||
* background color in index 1
|
||||
*/
|
||||
private RGB[] getTextColors() {
|
||||
ColorInfo colorInfo = colorConfigManager.getColor(key);
|
||||
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) {
|
||||
if (event.key.equals(this.key)) {
|
||||
|
|
|
@ -402,7 +402,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
.getName();
|
||||
RGB defaultUserForeground = DEFAULT_USER_FOREGROUND_COLOR.getRGB();
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(myName, true,
|
||||
.createChangeUserTextColorAction(myName, true, true,
|
||||
defaultUserForeground, colorConfigManager);
|
||||
mgr.add(userColorAction);
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
String peerName = peer.getName();
|
||||
RGB defaultPeerForeground = DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
|
||||
peerColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(peerName, true,
|
||||
.createChangeUserTextColorAction(peerName, false, true,
|
||||
defaultPeerForeground, colorConfigManager);
|
||||
mgr.add(peerColorAction);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
|||
* Nov 26, 2014 3709 mapeters support foreground/background color preferences for each site
|
||||
* Dec 08, 2014 3709 mapeters Removed ChangeSiteColorAction, uses {@link ChangeTextColorAction}.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -206,14 +207,15 @@ public class SessionFeedView extends SessionView {
|
|||
protected void fillContextMenu(IMenuManager manager) {
|
||||
super.fillContextMenu(manager);
|
||||
String site = getSelectedSite();
|
||||
RGB defaultForeground = colorManager
|
||||
.getColorForUser(getSelectedParticipant());
|
||||
ChangeTextColorAction siteColorAction = siteColorActions.get(site);
|
||||
if(siteColorAction == null) {
|
||||
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(site, siteColorAction);
|
||||
siteColorActions.put(mapKey, siteColorAction);
|
||||
}
|
||||
manager.add(siteColorAction);
|
||||
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
|
||||
|
|
|
@ -246,7 +246,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
ChangeTextColorAction userColorAction = userColorActions.get(user);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(user, me,
|
||||
.createChangeUserTextColorAction(user, me, me,
|
||||
defaultForeground, colorConfigManager);
|
||||
userColorActions.put(user, userColorAction);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue