Merge "Omaha #3709 Add icon that displays text colors next to color change menu items" into omaha_14.4.1
Former-commit-id: 2baba567db90a6f3fe4f9cbf440798454d88fbaf
This commit is contained in:
commit
6812dc291c
6 changed files with 217 additions and 39 deletions
|
@ -61,13 +61,11 @@ public abstract class AbstractColorConfigManager {
|
|||
}
|
||||
|
||||
ColorInfo colorInfo = colors.get(key);
|
||||
if (colorInfo != null) {
|
||||
colorInfo.setColors(foreground, background);
|
||||
} else {
|
||||
ColorInfo newColorInfo = new ColorInfo();
|
||||
newColorInfo.setColors(foreground, background);
|
||||
colors.put(key, newColorInfo);
|
||||
if (colorInfo == null) {
|
||||
colorInfo = new ColorInfo();
|
||||
colors.put(key, colorInfo);
|
||||
}
|
||||
colorInfo.setColors(foreground, background);
|
||||
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lContext = pathMgr.getContext(
|
||||
|
|
|
@ -22,7 +22,9 @@ package com.raytheon.uf.viz.collaboration.ui;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
|
@ -57,6 +59,7 @@ import org.eclipse.swt.events.MouseTrackAdapter;
|
|||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -164,6 +167,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
|||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -204,6 +208,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
|
||||
private Action roomSearchAction;
|
||||
|
||||
private Map<String, ChangeTextColorAction> userColorActions;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
|
@ -278,6 +284,10 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
inactiveImage.dispose();
|
||||
activeImage.dispose();
|
||||
pressedImage.dispose();
|
||||
|
||||
for (ChangeTextColorAction userColorAction : userColorActions.values()) {
|
||||
userColorAction.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,6 +297,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
Bundle bundle = Activator.getDefault().getBundle();
|
||||
final IUserSelector userSelector = this;
|
||||
|
||||
userColorActions = new HashMap<>();
|
||||
|
||||
createSessionAction = new CreateSessionAction(userSelector);
|
||||
|
||||
aliasAction = new Action("Alias", IconUtil.getImageDescriptor(Activator
|
||||
|
@ -464,8 +476,15 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
}
|
||||
manager.add(new AddNotifierAction(this));
|
||||
manager.add(new Separator());
|
||||
manager.add(new ChangeTextColorAction(user.getName(), false, false,
|
||||
null, new UserColorConfigManager()));
|
||||
String name = user.getName();
|
||||
ChangeTextColorAction userColorAction = userColorActions.get(name);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, false, new RGB(
|
||||
0, 0, 255), new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
}
|
||||
manager.add(userColorAction);
|
||||
} else if (o instanceof UserId) {
|
||||
// the user
|
||||
UserId user = (UserId) o;
|
||||
|
@ -474,9 +493,17 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
UserId me = connection.getUser();
|
||||
if (me.isSameUser(user)) {
|
||||
createMenu(manager);
|
||||
manager.insertBefore("afterFont", new ChangeTextColorAction(
|
||||
user.getName(), true, true, null,
|
||||
new UserColorConfigManager()));
|
||||
String name = user.getName();
|
||||
ChangeTextColorAction userColorAction = userColorActions
|
||||
.get(name);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(name, true,
|
||||
new RGB(0, 0, 255),
|
||||
new UserColorConfigManager());
|
||||
userColorActions.put(name, userColorAction);
|
||||
}
|
||||
manager.insertBefore("afterFont", userColorAction);
|
||||
}
|
||||
} else if (o instanceof RosterGroup || o instanceof SharedGroup) {
|
||||
Action inviteAction = new InviteAction(getSelectedUsers());
|
||||
|
|
|
@ -19,18 +19,25 @@ package com.raytheon.uf.viz.collaboration.ui.actions;
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Device;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.AbstractColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
|
||||
import com.raytheon.uf.viz.collaboration.ui.FeedColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ForegroundBackgroundColorDlg;
|
||||
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
|
@ -46,6 +53,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* 12/02/14 3709 mapeters Initial creation.
|
||||
* 12/09/14 3709 mapeters Uses {@link ForegroundBackgroundColorDlg}, renamed from
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,59 +69,85 @@ public class ChangeTextColorAction extends Action {
|
|||
|
||||
private AbstractColorConfigManager colorConfigManager;
|
||||
|
||||
private Image icon;
|
||||
|
||||
/**
|
||||
* Constructor for changing user colors.
|
||||
* Create and return new action for changing user colors.
|
||||
*
|
||||
* @param user
|
||||
* @param me
|
||||
* @param displayName
|
||||
* @param defaultForeground
|
||||
* @param colorConfigManager
|
||||
* @return
|
||||
*/
|
||||
public ChangeTextColorAction(String user, boolean me, boolean displayName,
|
||||
RGB defaultForeground, UserColorConfigManager colorConfigManager) {
|
||||
this("Change " + (displayName ? (me ? "Your" : (user + "'s")) : "User")
|
||||
+ " Text Colors...", user, defaultForeground,
|
||||
public static ChangeTextColorAction createChangeUserTextColorAction(
|
||||
String user, 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";
|
||||
}
|
||||
text += " Text Colors...";
|
||||
|
||||
return new ChangeTextColorAction(text, user, defaultForeground,
|
||||
colorConfigManager);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for changing site colors.
|
||||
* Create and return new action for changing site colors.
|
||||
*
|
||||
* @param site
|
||||
* @param defaultForeground
|
||||
* @param colorConfigManager
|
||||
* @return
|
||||
*/
|
||||
public ChangeTextColorAction(String site, RGB defaultForeground,
|
||||
public static ChangeTextColorAction createChangeSiteTextColorAction(
|
||||
String site, RGB defaultForeground,
|
||||
FeedColorConfigManager colorConfigManager) {
|
||||
this("Change Site Text Colors...", site, defaultForeground,
|
||||
colorConfigManager);
|
||||
return new ChangeTextColorAction("Change Site Text Colors...", site,
|
||||
defaultForeground, colorConfigManager);
|
||||
}
|
||||
|
||||
private ChangeTextColorAction(String text, String key,
|
||||
RGB defaultForeground, AbstractColorConfigManager colorConfigManager) {
|
||||
super(text, IconUtil.getImageDescriptor(Activator.getDefault()
|
||||
.getBundle(), "change_color.gif"));
|
||||
super(text);
|
||||
this.key = key;
|
||||
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);
|
||||
|
||||
CollaborationConnection.getConnection().registerEventHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ColorInfo colorInfo = colorConfigManager.getColor(key);
|
||||
RGB background;
|
||||
RGB foreground;
|
||||
RGB background;
|
||||
if (colorInfo != null) {
|
||||
background = colorInfo.getColor(SWT.BACKGROUND);
|
||||
foreground = colorInfo.getColor(SWT.FOREGROUND);
|
||||
background = colorInfo.getColor(SWT.BACKGROUND);
|
||||
} else {
|
||||
/*
|
||||
* Set dialog to display default colors (if defaultForeground is
|
||||
* null, ForegroundBackgroundColorDlg uses blue)
|
||||
* Set dialog to display default colors
|
||||
*/
|
||||
background = new RGB(255, 255, 255);
|
||||
foreground = defaultForeground;
|
||||
background = new RGB(255, 255, 255);
|
||||
}
|
||||
|
||||
ForegroundBackgroundColorDlg dialog = new ForegroundBackgroundColorDlg(
|
||||
|
@ -129,9 +164,72 @@ public class ChangeTextColorAction extends Action {
|
|||
if (returnValue instanceof RGB[]) {
|
||||
RGB[] colors = (RGB[]) returnValue;
|
||||
colorConfigManager.setColors(key, colors[0], colors[1]);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
connection.postEvent(new ChangeIconEvent(key, colors[0],
|
||||
colors[1]));
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void changeIcon(ChangeIconEvent event) {
|
||||
if (event.key.equals(this.key)) {
|
||||
setIconColors(event.foreground, event.background);
|
||||
}
|
||||
}
|
||||
|
||||
private void setIconColors(RGB foreground, RGB background) {
|
||||
Device device = Display.getCurrent();
|
||||
Color fg = new Color(device, foreground);
|
||||
Color bg = new Color(device, background);
|
||||
|
||||
Image oldIcon = icon;
|
||||
icon = new Image(device, 15, 15);
|
||||
Rectangle bounds = icon.getBounds();
|
||||
|
||||
GC gc = new GC(icon);
|
||||
gc.setForeground(fg);
|
||||
gc.setBackground(bg);
|
||||
gc.fillRectangle(bounds);
|
||||
gc.drawText("A", 4, 0);
|
||||
|
||||
setImageDescriptor(ImageDescriptor.createFromImage(icon));
|
||||
|
||||
gc.dispose();
|
||||
fg.dispose();
|
||||
bg.dispose();
|
||||
if (oldIcon != null) {
|
||||
oldIcon.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (connection != null) {
|
||||
connection.unregisterEventHandler(this);
|
||||
}
|
||||
|
||||
if (icon != null) {
|
||||
icon.dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,6 +75,8 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* settings for each user
|
||||
* Nov 26, 2014 3709 mapeters add colorConfigManager, use parent's colors map
|
||||
* Dec 08, 2014 3709 mapeters move color change actions to menu bar.
|
||||
* Dec 12, 2014 3709 mapeters Store {@link ChangeTextColorAction}s as fields,
|
||||
* dispose them.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -105,6 +107,10 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
|
||||
private static UserColorConfigManager colorConfigManager;
|
||||
|
||||
private ChangeTextColorAction userColorAction;
|
||||
|
||||
private ChangeTextColorAction peerColorAction;
|
||||
|
||||
public PeerToPeerView() {
|
||||
super();
|
||||
CollaborationConnection.getConnection().registerEventHandler(this);
|
||||
|
@ -123,6 +129,10 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
if (conn != null) {
|
||||
conn.unregisterEventHandler(this);
|
||||
}
|
||||
|
||||
userColorAction.dispose();
|
||||
peerColorAction.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -391,8 +401,10 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
String myName = CollaborationConnection.getConnection().getUser()
|
||||
.getName();
|
||||
RGB defaultUserForeground = DEFAULT_USER_FOREGROUND_COLOR.getRGB();
|
||||
mgr.add(new ChangeTextColorAction(myName, true, true,
|
||||
defaultUserForeground, colorConfigManager));
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(myName, true,
|
||||
defaultUserForeground, colorConfigManager);
|
||||
mgr.add(userColorAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -402,7 +414,9 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
|
|||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||
String peerName = peer.getName();
|
||||
RGB defaultPeerForeground = DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
|
||||
mgr.add(new ChangeTextColorAction(peerName, false, true,
|
||||
defaultPeerForeground, colorConfigManager));
|
||||
peerColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(peerName, true,
|
||||
defaultPeerForeground, colorConfigManager);
|
||||
mgr.add(peerColorAction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
**/
|
||||
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 org.eclipse.jface.action.Action;
|
||||
|
@ -75,6 +77,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
|||
* Oct 10, 2014 3708 bclement SiteConfigurationManager refactor
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -103,6 +106,8 @@ public class SessionFeedView extends SessionView {
|
|||
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
private Map<String, ChangeTextColorAction> siteColorActions;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -127,6 +132,8 @@ public class SessionFeedView extends SessionView {
|
|||
|
||||
colorConfigManager = new FeedColorConfigManager();
|
||||
usersTable.refresh();
|
||||
|
||||
siteColorActions = new HashMap<>();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -201,8 +208,14 @@ public class SessionFeedView extends SessionView {
|
|||
String site = getSelectedSite();
|
||||
RGB defaultForeground = colorManager
|
||||
.getColorForUser(getSelectedParticipant());
|
||||
manager.add(new ChangeTextColorAction(site, defaultForeground,
|
||||
colorConfigManager));
|
||||
ChangeTextColorAction siteColorAction = siteColorActions.get(site);
|
||||
if(siteColorAction == null) {
|
||||
siteColorAction = ChangeTextColorAction
|
||||
.createChangeSiteTextColorAction(site, defaultForeground,
|
||||
colorConfigManager);
|
||||
siteColorActions.put(site, siteColorAction);
|
||||
}
|
||||
manager.add(siteColorAction);
|
||||
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
|
||||
userAddSiteAction
|
||||
.setText("Show Messages from " + getSelectedSite());
|
||||
|
@ -471,4 +484,13 @@ public class SessionFeedView extends SessionView {
|
|||
super.participantDeparted(participant, description);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
for (ChangeTextColorAction siteColorAction : siteColorActions.values()) {
|
||||
siteColorAction.dispose();
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
|||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jface.action.IContributionItem;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
|
@ -119,6 +121,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
|
|||
* Nov 26, 2014 3709 mapeters added styleAndAppendText() taking fg and bg colors,
|
||||
* use parent's colors map.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -154,6 +157,8 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
|
||||
private static UserColorConfigManager colorConfigManager;
|
||||
|
||||
private Map<String, ChangeTextColorAction> userColorActions;
|
||||
|
||||
protected boolean enableUserColors = true;
|
||||
|
||||
public SessionView() {
|
||||
|
@ -179,6 +184,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
super.initComponents(parent);
|
||||
if (enableUserColors) {
|
||||
colorConfigManager = new UserColorConfigManager();
|
||||
userColorActions = new HashMap<>();
|
||||
}
|
||||
|
||||
// unfortunately this code cannot be a part of createToolbarButton
|
||||
|
@ -237,8 +243,14 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
// add color actions if in group chat room without shared display
|
||||
String user = entry.getName();
|
||||
RGB defaultForeground = colorManager.getColorForUser(entry);
|
||||
manager.add(new ChangeTextColorAction(user, me, me,
|
||||
defaultForeground, colorConfigManager));
|
||||
ChangeTextColorAction userColorAction = userColorActions.get(user);
|
||||
if (userColorAction == null) {
|
||||
userColorAction = ChangeTextColorAction
|
||||
.createChangeUserTextColorAction(user, me,
|
||||
defaultForeground, colorConfigManager);
|
||||
userColorActions.put(user, userColorAction);
|
||||
}
|
||||
manager.add(userColorAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,6 +440,13 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
|
|||
colorManager.clearColors();
|
||||
}
|
||||
|
||||
if (userColorActions != null) {
|
||||
for (ChangeTextColorAction userColorAction : userColorActions
|
||||
.values()) {
|
||||
userColorAction.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// clean up event handlers
|
||||
session.unregisterEventHandler(this);
|
||||
session.close();
|
||||
|
|
Loading…
Add table
Reference in a new issue