Merge "Omaha #3709 New color dialog, move P2P color actions to menu bar, add actions to contact list" into omaha_14.4.1

Former-commit-id: 28540e441e [formerly 9a4f87fe8f] [formerly 6b346b22e0 [formerly d1e058cfdac1e61119308538eeaab34097f65ba2]]
Former-commit-id: 6b346b22e0
Former-commit-id: 165b3fcb64
This commit is contained in:
Lee Venable 2014-12-09 12:54:03 -06:00 committed by Gerrit Code Review
commit 52aca5c7ab
13 changed files with 522 additions and 317 deletions

View file

@ -17,7 +17,7 @@ import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
/**
* Abstract class collaboration chat coloring configuration managers
* Abstract class for collaboration chat coloring configuration managers
*
* <pre>
*
@ -26,6 +26,7 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 13, 2014 3709 mapeters Initial creation.
* Dec 09, 2014 3709 mapeters setColors() sets foreground and background together.
*
* </pre>
*
@ -38,19 +39,16 @@ public abstract class AbstractColorConfigManager {
.createWithoutException(ColorInfoMap.class);
/**
* Set and store the color type of the given user/site to be the given rgb
* at the given file location. If creating new {@link ColorInfo} and setting
* background, set foreground to defaultForeground to prevent it from
* incorrectly defaulting.
* Set and store the given foreground and background colors for the given
* user/site at the given file location.
*
* @param key
* @param type
* @param rgb
* @param defaultForeground
* @param foreground
* @param background
* @param filePath
*/
protected void setColor(String key, int type, RGB rgb,
RGB defaultForeground, String filePath) {
protected void setColors(String key, RGB foreground, RGB background,
String filePath) {
ColorInfoMap colorInfoMap = this.getColorInfoMap();
if (colorInfoMap == null) {
colorInfoMap = new ColorInfoMap();
@ -64,11 +62,11 @@ public abstract class AbstractColorConfigManager {
ColorInfo colorInfo = colors.get(key);
if (colorInfo != null) {
colorInfo.setColor(type, rgb, defaultForeground);
colorInfo.setColors(foreground, background);
} else {
ColorInfo color = new ColorInfo();
color.setColor(type, rgb, defaultForeground);
colors.put(key, color);
ColorInfo newColorInfo = new ColorInfo();
newColorInfo.setColors(foreground, background);
colors.put(key, newColorInfo);
}
IPathManager pathMgr = PathManagerFactory.getPathManager();
@ -122,8 +120,7 @@ public abstract class AbstractColorConfigManager {
return null;
}
public abstract void setColor(String key, int type, RGB rgb,
RGB defaultForeground);
public abstract void setColors(String key, RGB foreground, RGB background);
public abstract ColorInfo getColor(String key);

View file

@ -104,6 +104,7 @@ import com.raytheon.uf.viz.collaboration.ui.actions.ChangeRoleAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeSiteAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeStatusAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeStatusMessageAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
import com.raytheon.uf.viz.collaboration.ui.actions.CreateSessionAction;
import com.raytheon.uf.viz.collaboration.ui.actions.DeleteGroupAction;
import com.raytheon.uf.viz.collaboration.ui.actions.DisplayFeedAction;
@ -162,6 +163,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* 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.
* Dec 08, 2014 3709 mapeters Added MB3 change user text color actions to contacts list.
*
* </pre>
*
@ -363,7 +365,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
mgr.add(roomSearchAction);
mgr.add(new Separator());
mgr.add(new ChangeFontAction());
mgr.add(new Separator());
mgr.add(new Separator("afterFont"));
mgr.add(new ChangeStatusAction());
mgr.add(new ChangeStatusMessageAction());
mgr.add(new ChangePasswordAction());
@ -461,6 +463,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
manager.add(new SendSubReqAction(entry));
}
manager.add(new AddNotifierAction(this));
manager.add(new Separator());
manager.add(new ChangeTextColorAction(user.getName(), false, false,
null, new UserColorConfigManager()));
} else if (o instanceof UserId) {
// the user
UserId user = (UserId) o;
@ -469,6 +474,9 @@ 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()));
}
} else if (o instanceof RosterGroup || o instanceof SharedGroup) {
Action inviteAction = new InviteAction(getSelectedUsers());

View file

@ -41,6 +41,8 @@ import org.eclipse.swt.graphics.RGB;
* ------------ ---------- ----------- --------------------------
* Nov 13, 2014 3709 mapeters Initial creation.
* Nov 26, 2014 3709 mapeters Renamed from UserColorInformation, added fgSet getter.
* Dec 08, 2014 3709 mapeters Removed fgSet and individual colors' getters/setters,
* set foreground and background together.
*
* </pre>
*
@ -72,12 +74,6 @@ public class ColorInfoMap {
@XmlAccessorType(XmlAccessType.NONE)
public static class ColorInfo {
/**
* tells {@link #setColor()} when to use defaultForeground
*/
@XmlAttribute
private boolean fgSet;
@XmlAttribute
private int fgRed;
@ -87,84 +83,18 @@ public class ColorInfoMap {
@XmlAttribute
private int fgBlue;
/**
* background should default to white
*/
@XmlAttribute
private int bgRed = 255;
private int bgRed;
@XmlAttribute
private int bgGreen = 255;
private int bgGreen;
@XmlAttribute
private int bgBlue = 255;
private int bgBlue;
public ColorInfo() {
}
/**
* @param type
* @return the red
*/
public int getRed(int type) {
return type == SWT.FOREGROUND ? fgRed : bgRed;
}
/**
* @param type
* @param red
* the red to set
*/
public void setRed(int type, int red) {
if (type == SWT.FOREGROUND) {
this.fgRed = red;
} else {
this.bgRed = red;
}
}
/**
* @param type
* @return the green
*/
public int getGreen(int type) {
return type == SWT.FOREGROUND ? fgGreen : bgGreen;
}
/**
* @param type
* @param green
* the green to set
*/
public void setGreen(int type, int green) {
if (type == SWT.FOREGROUND) {
this.fgGreen = green;
} else {
this.bgGreen = green;
}
}
/**
* @param type
* @return the blue
*/
public int getBlue(int type) {
return type == SWT.FOREGROUND ? fgBlue : bgBlue;
}
/**
* @param type
* @param blue
* the blue to set
*/
public void setBlue(int type, int blue) {
if (type == SWT.FOREGROUND) {
this.fgBlue = blue;
} else {
this.bgBlue = blue;
}
}
/**
* @param type
* @return the RGB color of the given type
@ -178,38 +108,17 @@ public class ColorInfoMap {
}
/**
* Set the color of the given type to the given rgb
*
* @param type
* @param rgb
* @param defaultForeground
* @param fg
* @param bg
*/
public void setColor(int type, RGB rgb, RGB defaultForeground) {
if (type == SWT.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(SWT.FOREGROUND, defaultForeground, null);
fgSet = false;
}
}
}
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;
/**
* @return whether the foreground has been set
*/
public boolean isForegroundSet() {
return fgSet;
}
}
}

View file

@ -37,6 +37,7 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
* Oct 10, 2014 3708 bclement Moved color methods from SiteConfigurationManager
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link AbstractColorConfigManager},
* renamed from SiteColorConfigManager.
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
*
* </pre>
*
@ -51,17 +52,16 @@ public class FeedColorConfigManager extends AbstractColorConfigManager {
private static ColorInfoMap colorInfoMap;
/**
* Set and store the color type of the given site to be the given rgb.
* Set and store the given colors for the given site.
*
* @param site
* @param type
* @param rgb
* @param defaultForeground
* @param foreground
* @param background
*/
@Override
public synchronized void setColor(String site, int type, RGB rgb,
RGB defaultForeground) {
super.setColor(site, type, rgb, defaultForeground, FILE_PATH);
public synchronized void setColors(String site, RGB foreground,
RGB background) {
super.setColors(site, foreground, background, FILE_PATH);
}
/**

View file

@ -0,0 +1,291 @@
/**
* 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 org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.colordialog.ColorWheelComp;
import com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange;
/**
* A dialog that displays a label with settable foreground and background colors
* using a color control.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 4, 2014 3709 lvenable Initial creation
*
* </pre>
*
* @author lvenable
* @version 1.0
*/
public class ForegroundBackgroundColorDlg extends CaveSWTDialog implements
IColorWheelChange {
/** Color wheel composite. */
private ColorWheelComp colorWheelComp;
/** Foreground color. */
private Color foregroundClr = null;
/** Background color. */
private Color backgroundClr = null;
/** Foreground/Background label control. */
private Label fgbgLabel = null;
/** Fond for the foreground/background label. */
private Font labelFont = null;
private Button foregroundRdo;
/**
* Constructor.
*
* @param parentShell
* Parent shell.
*/
public ForegroundBackgroundColorDlg(Shell parentShell) {
this(parentShell, null, null);
}
/**
* Constructor.
*
* @param parentShell
* Parent shell.
* @param fgRGB
* Foreground RGB.
* @param bgRGB
* Background RGB.
*/
public ForegroundBackgroundColorDlg(Shell parentShell, RGB fgRGB, RGB bgRGB) {
super(parentShell, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
| CAVE.PERSPECTIVE_INDEPENDENT);
setText("Foreground/Background Color Chooser");
/*
* If the foreground RGB is null then set it to a blue color.
*/
if (fgRGB == null) {
foregroundClr = new Color(parentShell.getDisplay(), new RGB(0, 0,
255));
} else {
foregroundClr = new Color(parentShell.getDisplay(), fgRGB);
}
/*
* If the background RGB is null then set it to a white color.
*/
if (bgRGB == null) {
backgroundClr = new Color(parentShell.getDisplay(), new RGB(255,
255, 255));
} else {
backgroundClr = new Color(parentShell.getDisplay(), bgRGB);
}
}
@Override
protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.verticalSpacing = 3;
return mainLayout;
}
@Override
protected Object constructShellLayoutData() {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
return gd;
}
@Override
protected void disposed() {
if (foregroundClr != null) {
foregroundClr.dispose();
}
if (backgroundClr != null) {
backgroundClr.dispose();
}
if (labelFont != null) {
labelFont.dispose();
}
}
@Override
protected void initializeComponents(Shell shell) {
createColorWheelControl();
createColorControls();
addSeparator();
createBottomButtons();
colorWheelComp.setColor(foregroundClr.getRGB());
}
/**
* Create the color wheel controls.
*/
private void createColorWheelControl() {
colorWheelComp = new ColorWheelComp(shell, this, " Color Chooser: ",
true);
}
/**
* Create the color controls.
*/
private void createColorControls() {
Composite colorControlComp = new Composite(shell, SWT.NONE);
colorControlComp.setLayout(new GridLayout(3, false));
colorControlComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT,
true, false));
/*
* Foreground/background radio buttons.
*/
foregroundRdo = new Button(colorControlComp, SWT.RADIO);
foregroundRdo.setText("Foreground Color");
foregroundRdo.setSelection(true);
foregroundRdo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
colorWheelComp.setColor(foregroundClr.getRGB());
}
});
GridData gd = new GridData();
gd.horizontalIndent = 13;
Button backgroundRdo = new Button(colorControlComp, SWT.RADIO);
backgroundRdo.setText("Background Color");
backgroundRdo.setLayoutData(gd);
backgroundRdo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
colorWheelComp.setColor(backgroundClr.getRGB());
}
});
/*
* Label displaying the foreground/background colors.
*/
gd = new GridData();
gd.horizontalIndent = 13;
fgbgLabel = new Label(colorControlComp, SWT.BORDER);
FontData fd = fgbgLabel.getFont().getFontData()[0];
fd.setHeight(16);
fd.setStyle(SWT.BOLD);
labelFont = new Font(getDisplay(), fd);
fgbgLabel.setFont(labelFont);
fgbgLabel.setText(" Sample Text ");
fgbgLabel.setLayoutData(gd);
fgbgLabel.setForeground(foregroundClr);
fgbgLabel.setBackground(backgroundClr);
}
/**
* Create the bottom OK/Cancel buttons.
*/
private void createBottomButtons() {
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new GridLayout(2, false));
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
int buttonWidth = 70;
GridData gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
Button okBtn = new Button(buttonComp, SWT.PUSH);
okBtn.setText(" OK ");
okBtn.setLayoutData(gd);
okBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RGB[] rgbArray = new RGB[] { foregroundClr.getRGB(),
backgroundClr.getRGB() };
setReturnValue(rgbArray);
close();
}
});
gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
cancelBtn.setText(" Cancel ");
cancelBtn.setLayoutData(gd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setReturnValue(null);
close();
}
});
}
/**
* Add a separator line to the dialog.
*/
private void addSeparator() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
sepLbl.setLayoutData(gd);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.colordialog.IColorWheelChange#colorChange
* (org.eclipse.swt.graphics.RGB, java.lang.String)
*/
@Override
public void colorChange(RGB rgb, String colorWheelTitle) {
if (foregroundRdo.getSelection()) {
foregroundClr.dispose();
foregroundClr = new Color(getDisplay(), rgb);
fgbgLabel.setForeground(foregroundClr);
} else {
backgroundClr.dispose();
backgroundClr = new Color(getDisplay(), rgb);
fgbgLabel.setBackground(backgroundClr);
}
}
}

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
* ------------ ---------- ----------- --------------------------
* Nov 13, 2014 3709 mapeters Initial creation.
* Nov 26, 2014 3709 mapeters Abstracted out code to {@link AbstractColorConfigManager}.
* Dec 08, 2014 3709 mapeters Set foreground and background colors together.
*
* </pre>
*
@ -49,17 +50,16 @@ public class UserColorConfigManager extends AbstractColorConfigManager {
private static ColorInfoMap colorInfoMap;
/**
* Set and store the color type of the given user to be the given rgb.
* Set and store the given colors for the given user.
*
* @param user
* @param type
* @param rgb
* @param defaultForeground
* @param foreground
* @param background
*/
@Override
public synchronized void setColor(String user, int type, RGB rgb,
RGB defaultForeground) {
super.setColor(user, type, rgb, defaultForeground, FILE_PATH);
public synchronized void setColors(String user, RGB foreground,
RGB background) {
super.setColors(user, foreground, background, FILE_PATH);
}
/**

View file

@ -0,0 +1,137 @@
package com.raytheon.uf.viz.collaboration.ui.actions;
/**
* 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.
**/
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
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;
/**
* Action to change the foreground and background chat colors of a selected
* user/site.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 12/02/14 3709 mapeters Initial creation.
* 12/09/14 3709 mapeters Uses {@link ForegroundBackgroundColorDlg}, renamed from
* ChangeUserColorAction, support both user and site colors.
*
* </pre>
*
* @author mapeters
* @version 1.0
*/
public class ChangeTextColorAction extends Action {
private final String key;
private RGB defaultForeground;
private AbstractColorConfigManager colorConfigManager;
/**
* Constructor for changing user colors.
*
* @param user
* @param me
* @param displayName
* @param defaultForeground
* @param colorConfigManager
*/
public ChangeTextColorAction(String user, boolean me, boolean displayName,
RGB defaultForeground, UserColorConfigManager colorConfigManager) {
this("Change " + (displayName ? (me ? "Your" : (user + "'s")) : "User")
+ " Text Colors...", user, defaultForeground,
colorConfigManager);
}
/**
* Constructor for changing site colors.
*
* @param site
* @param defaultForeground
* @param colorConfigManager
*/
public ChangeTextColorAction(String site, RGB defaultForeground,
FeedColorConfigManager colorConfigManager) {
this("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"));
this.key = key;
this.defaultForeground = defaultForeground;
this.colorConfigManager = colorConfigManager;
}
@Override
public void run() {
ColorInfo colorInfo = colorConfigManager.getColor(key);
RGB background;
RGB foreground;
if (colorInfo != null) {
background = colorInfo.getColor(SWT.BACKGROUND);
foreground = colorInfo.getColor(SWT.FOREGROUND);
} else {
/*
* Set dialog to display default colors (if defaultForeground is
* null, ForegroundBackgroundColorDlg uses blue)
*/
background = new RGB(255, 255, 255);
foreground = defaultForeground;
}
ForegroundBackgroundColorDlg dialog = new ForegroundBackgroundColorDlg(
Display.getCurrent().getActiveShell(), foreground, background);
dialog.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue == null) {
return;
}
if (returnValue instanceof RGB[]) {
RGB[] colors = (RGB[]) returnValue;
colorConfigManager.setColors(key, colors[0], colors[1]);
}
}
});
dialog.open();
}
}

View file

@ -1,91 +0,0 @@
package com.raytheon.uf.viz.collaboration.ui.actions;
/**
* 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.
**/
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
import com.raytheon.uf.viz.core.icon.IconUtil;
/**
* Action to change the foreground/background chat color of a selected user.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 12/02/14 3709 mapeters Initial creation.
*
* </pre>
*
* @author mapeters
* @version 1.0
*/
public class ChangeUserColorAction extends Action {
private int type;
private String user;
private RGB defaultForeground;
private UserColorConfigManager colorConfigManager;
public ChangeUserColorAction(int type, String user, boolean me,
RGB defaultForeground, UserColorConfigManager colorConfigManager) {
super("Change " + (me ? "Your " : (user + "'s "))
+ (type == SWT.FOREGROUND ? "Foreground" : "Background")
+ " Color...", IconUtil.getImageDescriptor(Activator
.getDefault().getBundle(), "change_color.gif"));
this.type = type;
this.user = user;
this.defaultForeground = defaultForeground;
this.colorConfigManager = colorConfigManager;
}
@Override
public void run() {
ColorDialog dialog = new ColorDialog(Display.getCurrent()
.getActiveShell());
ColorInfo colorInfo = colorConfigManager.getColor(user);
if (colorInfo != null) {
dialog.setRGB(colorInfo.getColor(type));
} else if (type == SWT.FOREGROUND) {
/*
* set the dialog to display default foreground color as
* currently selected
*/
dialog.setRGB(defaultForeground);
}
RGB rgb = dialog.open();
if (rgb != null) {
colorConfigManager.setColor(user, type, rgb,
defaultForeground);
}
}
}

View file

@ -142,10 +142,9 @@ public class PeerToPeerChatAction extends Action {
if (p2pView.getPeer() == null) {
p2pView.setPeer(user);
/*
* add color change actions to P2P right click menu upon first
* creation of P2P chat.
* once peer is set, add action to change peer text colors
*/
p2pView.addChangeUserColorActions();
p2pView.addChangePeerColorAction();
}
return p2pView;
} catch (PartInitException e) {

View file

@ -98,6 +98,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* Nov 14, 2014 3709 mapeters Changing foreground/background colors no longer
* implemented here, added messagesTextMenuMgr.
* Nov 26, 2014 3709 mapeters Added {@link #getColorFromRGB()}.
* Dec 08, 2014 3709 mapeters Removed messagesTextMenuMgr.
* </pre>
*
* @author rferrel
@ -127,8 +128,6 @@ 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;
@ -230,9 +229,9 @@ public abstract class AbstractSessionView<T extends IUser> extends
// adding a menu item so that Paste can be found when clicking on the
// composeText styledtext
messagesTextMenuMgr = new MenuManager();
messagesTextMenuMgr.add(new CopyTextAction(messagesText));
Menu menu = messagesTextMenuMgr.createContextMenu(messagesText);
MenuManager menuMgr = new MenuManager();
menuMgr.add(new CopyTextAction(messagesText));
Menu menu = menuMgr.createContextMenu(messagesText);
messagesText.setMenu(menu);
}

View file

@ -25,6 +25,7 @@ import java.text.SimpleDateFormat;
import java.util.List;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@ -50,7 +51,7 @@ 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.ColorInfoMap.ColorInfo;
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeUserColorAction;
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.notifier.NotifierTask;
import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools;
@ -73,6 +74,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil;
* Nov 14, 2014 3709 mapeters support foregound/background color
* 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.
*
* </pre>
*
@ -375,23 +377,32 @@ public class PeerToPeerView extends AbstractSessionView<IUser> implements
}
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
createDropDownMenu();
}
/**
* add right-click menu options for changing foreground/background colors
* for each user
* Initialize drop-down menu with action to change user text colors.
*/
public void addChangeUserColorActions() {
private void createDropDownMenu() {
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
String myName = CollaborationConnection.getConnection().getUser()
.getName();
String peerName = peer.getName();
RGB defaultUserForeground = DEFAULT_USER_FOREGROUND_COLOR.getRGB();
mgr.add(new ChangeTextColorAction(myName, true, true,
defaultUserForeground, colorConfigManager));
}
/**
* Add action to change peer text colors to drop-down menu once peer is set.
*/
public void addChangePeerColorAction() {
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
String peerName = peer.getName();
RGB defaultPeerForeground = DEFAULT_PEER_FOREGROUND_COLOR.getRGB();
messagesTextMenuMgr.add(new ChangeUserColorAction(SWT.BACKGROUND,
myName, true, defaultUserForeground, colorConfigManager));
messagesTextMenuMgr.add(new ChangeUserColorAction(SWT.FOREGROUND,
myName, true, defaultUserForeground, colorConfigManager));
messagesTextMenuMgr.add(new ChangeUserColorAction(SWT.BACKGROUND,
peerName, false, defaultPeerForeground, colorConfigManager));
messagesTextMenuMgr.add(new ChangeUserColorAction(SWT.FOREGROUND,
peerName, false, defaultPeerForeground, colorConfigManager));
mgr.add(new ChangeTextColorAction(peerName, false, true,
defaultPeerForeground, colorConfigManager));
}
}

View file

@ -32,9 +32,7 @@ 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.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.jivesoftware.smack.packet.Presence;
import com.google.common.eventbus.Subscribe;
@ -46,8 +44,8 @@ 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.SiteConfigurationManager;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.uf.viz.core.icon.IconUtil;
/**
* Built for the session in which everyone joins
@ -76,6 +74,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
* Apr 22, 2014 3038 bclement added initialized flag to differentiate between roster population and new joins
* 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}.
*
* </pre>
*
@ -93,10 +92,6 @@ public class SessionFeedView extends SessionView {
private Action userRemoveSiteAction;
private Action bgColorChangeAction;
private Action fgColorChangeAction;
private static FeedColorConfigManager colorConfigManager;
private String actingSite;
@ -149,10 +144,6 @@ public class SessionFeedView extends SessionView {
protected void createActions() {
super.createActions();
bgColorChangeAction = new ChangeSiteColorAction(SWT.BACKGROUND);
fgColorChangeAction = new ChangeSiteColorAction(SWT.FOREGROUND);
autoJoinAction = new Action(CollabPrefConstants.AUTO_JOIN, SWT.TOGGLE) {
@Override
public void run() {
@ -207,9 +198,11 @@ public class SessionFeedView extends SessionView {
@Override
protected void fillContextMenu(IMenuManager manager) {
super.fillContextMenu(manager);
manager.add(bgColorChangeAction);
manager.add(fgColorChangeAction);
String site = getSelectedSite();
RGB defaultForeground = colorManager
.getColorForUser(getSelectedParticipant());
manager.add(new ChangeTextColorAction(site, defaultForeground,
colorConfigManager));
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
userAddSiteAction
.setText("Show Messages from " + getSelectedSite());
@ -299,10 +292,7 @@ public class SessionFeedView extends SessionView {
if (site != null) {
ColorInfo siteColor = colorConfigManager.getColor(site);
if (siteColor != null) {
if (siteColor.isForegroundSet()) {
fgColor = getColorFromRGB(siteColor
.getColor(SWT.FOREGROUND));
}
fgColor = getColorFromRGB(siteColor.getColor(SWT.FOREGROUND));
bgColor = getColorFromRGB(siteColor.getColor(SWT.BACKGROUND));
}
}
@ -481,47 +471,4 @@ public class SessionFeedView extends SessionView {
super.participantDeparted(participant, description);
}
}
/*
* action for changing foreground/background color for a selected site
*/
private class ChangeSiteColorAction extends Action {
private int type;
private ChangeSiteColorAction(int type) {
super("Change Site "
+ (type == SWT.FOREGROUND ? "Foreground" : "Background")
+ " Color...", IconUtil.getImageDescriptor(Activator
.getDefault().getBundle(), "change_color.gif"));
this.type = type;
}
@Override
public void run() {
ColorDialog dialog = new ColorDialog(Display.getCurrent()
.getActiveShell());
RGB defaultForeground = colorManager
.getColorForUser(getSelectedParticipant());
String site = getSelectedSite();
ColorInfo colorInfo = colorConfigManager.getColor(site);
if (colorInfo != null
&& (type != SWT.FOREGROUND || colorInfo.isForegroundSet())) {
/*
* don't set dialog from colorInfo if null or type is foreground
* and foreground hasn't been set (use default)
*/
dialog.setRGB(colorInfo.getColor(type));
} else if (type == SWT.FOREGROUND) {
dialog.setRGB(defaultForeground);
}
RGB rgb = dialog.open();
if (rgb != null) {
colorConfigManager.setColor(site, type, rgb,
defaultForeground);
}
usersTable.refresh();
}
}
}

View file

@ -83,7 +83,7 @@ import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.ColorInfoMap.ColorInfo;
import com.raytheon.uf.viz.collaboration.ui.UserColorConfigManager;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeUserColorAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeTextColorAction;
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.prefs.CollabPrefConstants;
@ -237,10 +237,8 @@ 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 ChangeUserColorAction(SWT.BACKGROUND, user,
me, defaultForeground, colorConfigManager));
manager.add(new ChangeUserColorAction(SWT.FOREGROUND, user,
me, defaultForeground, colorConfigManager));
manager.add(new ChangeTextColorAction(user, me, me,
defaultForeground, colorConfigManager));
}
}