diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/AbstractColorConfigManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/AbstractColorConfigManager.java index 3ead12b763..1c7e5028d6 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/AbstractColorConfigManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/AbstractColorConfigManager.java @@ -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 * *
* @@ -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. * ** @@ -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); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index ddd132411b..9b190c3a3b 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -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. * * * @@ -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()); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ColorInfoMap.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ColorInfoMap.java index db8ee65808..9fca15f040 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ColorInfoMap.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ColorInfoMap.java @@ -37,10 +37,12 @@ import org.eclipse.swt.graphics.RGB; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Nov 13, 2014 3709 mapeters Initial creation. - * Nov 26, 2014 3709 mapeters Renamed from UserColorInformation, added fgSet getter. + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * 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. * * * @@ -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; } } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/FeedColorConfigManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/FeedColorConfigManager.java index a06045d2d8..276427ddce 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/FeedColorConfigManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/FeedColorConfigManager.java @@ -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. * * * @@ -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); } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ForegroundBackgroundColorDlg.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ForegroundBackgroundColorDlg.java new file mode 100644 index 0000000000..006f66942b --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ForegroundBackgroundColorDlg.java @@ -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. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Dec 4, 2014 3709 lvenable Initial creation + * + *+ * + * @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); + } + + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserColorConfigManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserColorConfigManager.java index 9afedaa3d0..ea36998790 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserColorConfigManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserColorConfigManager.java @@ -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. * * * @@ -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); } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeTextColorAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeTextColorAction.java new file mode 100644 index 0000000000..0539b9b70d --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeTextColorAction.java @@ -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. + * + *
+ * + * 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. + * + *+ * + * @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(); + } +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeUserColorAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeUserColorAction.java deleted file mode 100644 index 11e5b9331e..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeUserColorAction.java +++ /dev/null @@ -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. - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 12/02/14 3709 mapeters Initial creation. - * - *- * - * @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); - } - } -} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/PeerToPeerChatAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/PeerToPeerChatAction.java index 161d6b2030..861b7b12a0 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/PeerToPeerChatAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/PeerToPeerChatAction.java @@ -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) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java index b8b8f506f6..15749d7ca2 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java @@ -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. * * * @author rferrel @@ -127,8 +128,6 @@ public abstract class AbstractSessionView