Merge "Omaha #3709 Collaboration chat windows need to support changing foreground and background color" into omaha_14.4.1

Former-commit-id: d3d6c9370d [formerly d3d6c9370d [formerly 7c37a9bd7e4fb16feace1d081d85a2b26d471338]]
Former-commit-id: 0c5f1c0f78
Former-commit-id: edef0621f5
This commit is contained in:
Nate Jensen 2014-10-16 10:48:06 -05:00 committed by Gerrit Code Review
commit fe9206aec2
13 changed files with 278 additions and 376 deletions

View file

@ -98,7 +98,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
import com.raytheon.uf.viz.collaboration.ui.actions.AddNotifierAction;
import com.raytheon.uf.viz.collaboration.ui.actions.AddToGroupAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ArchiveViewerAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeBackgroundColorAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeFontAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeForegroundColorAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangePasswordAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeRoleAction;
import com.raytheon.uf.viz.collaboration.ui.actions.ChangeSiteAction;
@ -160,6 +162,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* added static utility method to show view
* May 19, 2014 3180 bclement fixed inviting multiple users to session
* Oct 08, 2014 3705 bclement added room search and bookmarking
* Oct 14, 2014 3709 mapeters Added change background/foreground color actions to menu.
*
* </pre>
*
@ -361,6 +364,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
mgr.add(roomSearchAction);
mgr.add(new Separator());
mgr.add(new ChangeFontAction());
mgr.add(new ChangeForegroundColorAction());
mgr.add(new ChangeBackgroundColorAction());
mgr.add(new Separator());
mgr.add(new ChangeStatusAction());
mgr.add(new ChangeStatusMessageAction());
mgr.add(new ChangePasswordAction());

View file

@ -0,0 +1,73 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
import com.raytheon.uf.viz.core.preferences.PreferenceConverter;
/**
* Open change background color dialog
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 14, 2014 3709 mapeters Initial creation.
*
*
* </pre>
*
* @author mapeters
* @version 1.0
*/
public class ChangeBackgroundColorAction extends Action {
public ChangeBackgroundColorAction() {
super("Change Background Color...");
}
@Override
public void run() {
ColorDialog dialog = new ColorDialog(Display.getCurrent()
.getActiveShell());
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
RGB data = PreferenceConverter.getRGB(store, "bg", "white");
dialog.setRGB(data);
RGB postData = dialog.open();
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (postData != null && connection != null) {
PreferenceConverter.setValue(store, "bg", postData);
connection.postEvent(ChatDisplayChangeEvent.createColorEvent(
ChangeType.BACKGROUND, postData));
}
};
}

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 6, 2012 bsteffen Initial creation
* Oct 14, 2014 3709 mapeters Post event using {@link ChatDisplayChangeEvent}.
*
* </pre>
*
@ -66,7 +67,8 @@ public class ChangeFontAction extends Action {
.getConnection();
if (postData != null && connection != null) {
PreferenceConverter.setValue(store, "font", postData);
connection.postEvent(postData);
connection.postEvent(ChatDisplayChangeEvent
.createFontEvent(postData));
}
};
}

View file

@ -0,0 +1,73 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
import com.raytheon.uf.viz.core.preferences.PreferenceConverter;
/**
* Open change foreground color dialog
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 14, 2014 3709 mapeters Initial creation.
*
*
* </pre>
*
* @author mapeters
* @version 1.0
*/
public class ChangeForegroundColorAction extends Action {
public ChangeForegroundColorAction() {
super("Change Foreground Color...");
}
@Override
public void run() {
ColorDialog dialog = new ColorDialog(Display.getCurrent()
.getActiveShell());
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
RGB data = PreferenceConverter.getRGB(store, "fg", "black");
dialog.setRGB(data);
RGB postData = dialog.open();
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (postData != null && connection != null) {
PreferenceConverter.setValue(store, "fg", postData);
connection.postEvent(ChatDisplayChangeEvent.createColorEvent(
ChangeType.FOREGROUND, postData));
}
};
}

View file

@ -0,0 +1,84 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.ui.actions;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
/**
* Store font/color change information
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 14, 2014 3709 mapeters Initial creation.
*
* </pre>
*
* @author mapeters
* @version 1.0
*/
public class ChatDisplayChangeEvent {
private ChangeType type;
private RGB color;
private FontData font;
public enum ChangeType {
BACKGROUND, FOREGROUND, FONT;
}
private ChatDisplayChangeEvent(ChangeType type, RGB color) {
this.type = type;
this.color = color;
}
private ChatDisplayChangeEvent(ChangeType type, FontData font) {
this.type = type;
this.font = font;
}
public static ChatDisplayChangeEvent createColorEvent(ChangeType type,
RGB color) {
return new ChatDisplayChangeEvent(type, color);
}
public static ChatDisplayChangeEvent createFontEvent(FontData font) {
return new ChatDisplayChangeEvent(ChangeType.FONT, font);
}
public RGB getColor() {
return this.color;
}
public ChangeType getChangeType() {
return this.type;
}
public FontData getFont() {
return this.font;
}
}

View file

@ -30,7 +30,7 @@ import java.util.TimeZone;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@ -61,6 +61,8 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent;
import com.raytheon.uf.viz.collaboration.ui.actions.ChatDisplayChangeEvent.ChangeType;
import com.raytheon.uf.viz.collaboration.ui.actions.CopyTextAction;
import com.raytheon.uf.viz.collaboration.ui.actions.CutTextAction;
import com.raytheon.uf.viz.collaboration.ui.actions.PasteTextAction;
@ -94,6 +96,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* Jun 20, 2014 3281 bclement made sendErrorMessage() public
* Jun 27, 2014 3323 bclement fixed disposed font issue
* Oct 09, 2014 3711 mapeters Display chat text in accordance with preferences.
* Oct 14, 2014 3709 mapeters Support changing foreground/background color.
* </pre>
*
* @author rferrel
@ -212,12 +215,24 @@ public abstract class AbstractSessionView<T extends IUser> extends
}
}
});
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
// here need to grab the font from preferences and use that font
messagesTextFont = new Font(Display.getCurrent(),
PreferenceConverter.getFontData(Activator.getDefault()
.getPreferenceStore(), "font"));
org.eclipse.jface.preference.PreferenceConverter.getFontData(
store, "font"));
messagesText.setFont(messagesTextFont);
// grab the background color from preferences (default to white)
RGB bgColor = com.raytheon.uf.viz.core.preferences.PreferenceConverter
.getRGB(store, "bg", "white");
messagesText.setBackground(new Color(Display.getCurrent(), bgColor));
// grab the foreground color from preferences (default to black)
RGB fgColor = com.raytheon.uf.viz.core.preferences.PreferenceConverter
.getRGB(store, "fg", "black");
messagesText.setForeground(new Color(Display.getCurrent(), fgColor));
searchComp.setSearchText(messagesText);
// adding a menu item so that Paste can be found when clicking on the
@ -576,14 +591,22 @@ public abstract class AbstractSessionView<T extends IUser> extends
}
@Subscribe
public void changeFont(FontData data) {
public void changeChatDisplay(ChatDisplayChangeEvent event) {
ChangeType type = event.getChangeType();
if (type == ChangeType.FOREGROUND) {
messagesText.setForeground(new Color(Display.getCurrent(), event.getColor()));
} else if (type == ChangeType.BACKGROUND) {
messagesText.setBackground(new Color(Display.getCurrent(), event
.getColor()));
} else if (type == ChangeType.FONT) {
Font oldFont = messagesTextFont;
messagesTextFont = new Font(Display.getCurrent(), data);
messagesTextFont = new Font(Display.getCurrent(), event.getFont());
messagesText.setFont(messagesTextFont);
if (oldFont != null) {
oldFont.dispose();
}
}
}
public void setAlertWords(List<AlertWord> words) {
alertWords = words;

View file

@ -84,6 +84,7 @@ import com.raytheon.uf.viz.core.maps.jobs.AbstractMapQueryJob;
import com.raytheon.uf.viz.core.maps.jobs.AbstractMapRequest;
import com.raytheon.uf.viz.core.maps.jobs.AbstractMapResult;
import com.raytheon.uf.viz.core.maps.rsc.AbstractMapResource;
import com.raytheon.uf.viz.core.preferences.PreferenceConverter;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory;
import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory.ResourceOrder;
@ -94,7 +95,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability;
import com.raytheon.uf.viz.gisdatastore.Activator;
import com.raytheon.uf.viz.gisdatastore.ui.PreferenceConverter;
import com.raytheon.viz.core.rsc.jts.JTSCompiler;
import com.raytheon.viz.core.rsc.jts.JTSCompiler.JTSGeometryData;
import com.raytheon.viz.core.rsc.jts.JTSCompiler.PointStyle;

View file

@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.preferences.StringConverter;
/**
* Preference field editor for selecting a color for the DataStoreResource

View file

@ -26,6 +26,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.preferences.StringConverter;
/**
* Preference field editor for selecting a color for the DataStoreResource

View file

@ -24,6 +24,8 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.viz.core.preferences.StringConverter;
/**
* Preference field editor for selecting a line width for DataStoreResource
* highlight

View file

@ -29,6 +29,7 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.viz.core.preferences.StringConverter;
import com.raytheon.viz.ui.dialogs.SetOpacityDialog;
/**

View file

@ -1,201 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.gisdatastore.ui;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.RGBColors;
/**
* Utility for loading and saving GIS Viewer preferences
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 27, 2012 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class PreferenceConverter {
private PreferenceConverter() {
// unused, all methods are static
}
/**
* Get an RGB color preference value. If no preference is stored,
* defaultValue will be returned
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param defaultValue
* the default value
* @return the RGB color
*/
public static RGB getRGB(IPreferenceStore prefs, String key,
String defaultValue) {
String value = prefs.getString(key);
RGB newColor = StringConverter.asRGB(value);
if (newColor == null) {
newColor = StringConverter.asRGB(defaultValue);
}
return newColor;
}
/**
* Store an RGB color preference value.
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param color
* the RGB color to be stored
*/
public static void setValue(IPreferenceStore prefs, String key, RGB color) {
String value = RGBColors.getColorName(color);
prefs.setValue(key, value);
}
/**
* Get a LineStyle value. If no preference is stored, defaultValue will be
* returned
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param defaultValue
* the default value
* @return the LineStyle
*/
public static LineStyle getLineStyle(IPreferenceStore prefs, String key,
String defaultValue) {
String value = prefs.getString(key);
LineStyle style = StringConverter.asLineStyle(value);
if (style == null) {
style = StringConverter.asLineStyle(defaultValue);
}
return style;
}
/**
* Store a LineStyle preference value.
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param opacity
* the LineStyle to be stored
*/
public static void setValue(IPreferenceStore prefs, String key,
LineStyle style) {
String value = style.name();
prefs.setValue(key, value);
}
/**
* Get an integer preference value. If no preference is stored, defaultValue
* will be returned
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param defaultValue
* the default value
* @return the integer value
*/
public static int getInt(IPreferenceStore prefs, String key,
String defaultValue) {
String stringValue = prefs.getString(key);
Integer value = StringConverter.asInteger(stringValue);
if (value == null) {
value = StringConverter.asInteger(defaultValue);
}
return value;
}
/**
* Store an integer preference value.
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param value
* the integer value to be stored
*/
public static void setValue(IPreferenceStore prefs, String key, int value) {
String stringValue = StringConverter.asString(value);
prefs.setValue(key, stringValue);
}
/**
* Get an float preference value. If no preference is stored, defaultValue
* will be returned
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param defaultValue
* the default value
* @return the float value
*/
public static float getFloat(IPreferenceStore prefs, String key,
String defaultValue) {
String stringValue = prefs.getString(key);
Float value = StringConverter.asFloat(stringValue);
if (value == null) {
value = StringConverter.asFloat(defaultValue);
}
return value;
}
/**
* Store an float preference value.
*
* @param prefs
* the preference store
* @param key
* the preference key
* @param value
* the float value to be stored
*/
public static void setValue(IPreferenceStore prefs, String key, float value) {
String stringValue = StringConverter.asString(value);
prefs.setValue(key, stringValue);
}
}

View file

@ -1,163 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.gisdatastore.ui;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.RGBColors;
/**
* Convert GIS Viewer preference types to/from strings
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 27, 2012 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class StringConverter {
private StringConverter() {
// unused, all methods are static
}
/**
* Convert RGB color value to string
*
* @param color
* RGB color value
* @return string String value
*/
public static String asString(RGB color) {
return RGBColors.getColorName(color);
}
/**
* Convert string to RGB color value
*
* @param string
* String value
* @return RGB color value or null if string is not a valid RGB color name
* or hex value of the form "#rrggbb"
*/
public static RGB asRGB(String string) {
RGB rgb = RGBColors.getRGBColor(string);
return rgb;
}
/**
* Convert LineStyle value to string
*
* @param opacity
* LineStyle value
* @return string String value
*/
public static String asString(LineStyle style) {
return style.name();
}
/**
* Convert string to LineStyle value
*
* @param string
* String value
* @return LineStyle value or null if string is not a valid LineStyle name
*/
public static LineStyle asLineStyle(String string) {
LineStyle style = null;
try {
style = LineStyle.valueOf(string);
} catch (Exception e) {
style = null;
}
return style;
}
/**
* Convert integer value to string
*
* @param value
* integer value
* @return string String value
*/
public static String asString(int value) {
return Integer.toString(value);
}
/**
* Convert string to Integer value
*
* @param string
* String Value
* @return Integer value or null if string is not a valid integer
* representation
*/
public static Integer asInteger(String string) {
Integer value = null;
try {
value = Integer.parseInt(string);
} catch (Exception e) {
value = null;
}
return value;
}
/**
* Convert float value to string
*
* @param value
* float value
* @return string String value
*/
public static String asString(float value) {
return Float.toString(value);
}
/**
* Convert string to Float value
*
* @param string
* String Value
* @return Float value or null if string is not a valid float representation
*/
public static Float asFloat(String string) {
Float value = null;
try {
value = Float.parseFloat(string);
} catch (Exception e) {
value = null;
}
return value;
}
}