From 54a3e8d2eb4366fa992cbeaa0bf23bae8aa3da6f Mon Sep 17 00:00:00 2001 From: Mark Peters Date: Thu, 16 Oct 2014 10:28:34 -0500 Subject: [PATCH] Omaha #3709 Collaboration chat windows need to support changing foreground and background color Change-Id: I1f208c3e12e0fe989ae395423ad28454be3589f7 Former-commit-id: 8e00cd23205c4ab3f83c5594373f3736afe7fe83 --- .../ui/CollaborationGroupView.java | 6 + .../actions/ChangeBackgroundColorAction.java | 73 +++++++ .../ui/actions/ChangeFontAction.java | 4 +- .../actions/ChangeForegroundColorAction.java | 73 +++++++ .../ui/actions/ChatDisplayChangeEvent.java | 84 ++++++++ .../ui/session/AbstractSessionView.java | 43 +++- .../gisdatastore/rsc/DataStoreResource.java | 2 +- .../viz/gisdatastore/ui/ColorFieldEditor.java | 1 + .../gisdatastore/ui/LineStyleFieldEditor.java | 1 + .../gisdatastore/ui/LineWidthFieldEditor.java | 2 + .../gisdatastore/ui/OpacityFieldEditor.java | 1 + .../gisdatastore/ui/PreferenceConverter.java | 201 ------------------ .../viz/gisdatastore/ui/StringConverter.java | 163 -------------- 13 files changed, 278 insertions(+), 376 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeBackgroundColorAction.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeForegroundColorAction.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatDisplayChangeEvent.java delete mode 100644 cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/PreferenceConverter.java delete mode 100644 cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/StringConverter.java 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 ea3fa4323d..c38acd40ac 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 @@ -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. * * * @@ -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()); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeBackgroundColorAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeBackgroundColorAction.java new file mode 100644 index 0000000000..9037465081 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeBackgroundColorAction.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Oct 14, 2014 3709        mapeters    Initial creation.
+ * 
+ * 
+ * 
+ * + * @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)); + } + }; +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeFontAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeFontAction.java index f6ac11196e..92c0bffc81 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeFontAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeFontAction.java @@ -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}. * * * @@ -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)); } }; } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeForegroundColorAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeForegroundColorAction.java new file mode 100644 index 0000000000..426171ffbf --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChangeForegroundColorAction.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Oct 14, 2014 3709        mapeters    Initial creation.
+ * 
+ * 
+ * 
+ * + * @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)); + } + }; +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatDisplayChangeEvent.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatDisplayChangeEvent.java new file mode 100644 index 0000000000..bf2344d5cf --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatDisplayChangeEvent.java @@ -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 + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#     Engineer    Description
+ * ------------ ----------  ----------- --------------------------
+ * Oct 14, 2014 3709        mapeters    Initial creation.
+ * 
+ * 
+ * + * @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; + } +} 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 11990c7c8f..f7e0582e1f 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 @@ -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. * * * @author rferrel @@ -212,12 +215,24 @@ public abstract class AbstractSessionView 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,15 +591,23 @@ public abstract class AbstractSessionView extends } @Subscribe - public void changeFont(FontData data) { - Font oldFont = messagesTextFont; - messagesTextFont = new Font(Display.getCurrent(), data); - messagesText.setFont(messagesTextFont); - if (oldFont != null) { - oldFont.dispose(); + 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(), event.getFont()); + messagesText.setFont(messagesTextFont); + if (oldFont != null) { + oldFont.dispose(); + } } } - + public void setAlertWords(List words) { alertWords = words; } diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java index d9f97242af..75eb8a426d 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java @@ -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; diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/ColorFieldEditor.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/ColorFieldEditor.java index d8a5ba059d..5f0352eac4 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/ColorFieldEditor.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/ColorFieldEditor.java @@ -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 diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineStyleFieldEditor.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineStyleFieldEditor.java index 14c4a12454..3259ea22f8 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineStyleFieldEditor.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineStyleFieldEditor.java @@ -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 diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineWidthFieldEditor.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineWidthFieldEditor.java index 665ca34877..4dd7396831 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineWidthFieldEditor.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/LineWidthFieldEditor.java @@ -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 diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/OpacityFieldEditor.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/OpacityFieldEditor.java index 27f740c314..157378770e 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/OpacityFieldEditor.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/OpacityFieldEditor.java @@ -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; /** diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/PreferenceConverter.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/PreferenceConverter.java deleted file mode 100644 index a22c53370a..0000000000 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/PreferenceConverter.java +++ /dev/null @@ -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 - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 27, 2012            randerso     Initial creation
- * 
- * 
- * - * @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); - } -} diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/StringConverter.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/StringConverter.java deleted file mode 100644 index d9bf269a24..0000000000 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/ui/StringConverter.java +++ /dev/null @@ -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 - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 27, 2012            randerso     Initial creation
- * 
- * 
- * - * @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; - } -}