diff --git a/cave/com.raytheon.uf.viz.alertview/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.alertview/META-INF/MANIFEST.MF index 34168add92..14666825ac 100644 --- a/cave/com.raytheon.uf.viz.alertview/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.alertview/META-INF/MANIFEST.MF @@ -14,4 +14,5 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.8.2", Bundle-ActivationPolicy: lazy Bundle-ClassPath: com.raytheon.uf.viz.alertview.jar Service-Component: OSGI-INF/*.xml +Bundle-Activator: com.raytheon.uf.viz.alertview.AlertViewActivator diff --git a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertAutoOpen.xml b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertAutoOpen.xml index 4940db7959..ccb03574d3 100644 --- a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertAutoOpen.xml +++ b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertAutoOpen.xml @@ -1,5 +1,5 @@ - + diff --git a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPopup.xml b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPopup.xml index f4a10538eb..fd2b44773a 100644 --- a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPopup.xml +++ b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPopup.xml @@ -1,5 +1,5 @@ - + diff --git a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPrefs.xml b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPrefs.xml index 4f00810ffc..4819832d66 100644 --- a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPrefs.xml +++ b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertPrefs.xml @@ -1,5 +1,5 @@ - + diff --git a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertStore.xml b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertStore.xml index 5a4d4b51c0..24f121c051 100644 --- a/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertStore.xml +++ b/cave/com.raytheon.uf.viz.alertview/OSGI-INF/alertStore.xml @@ -1,5 +1,5 @@ - + diff --git a/cave/com.raytheon.uf.viz.alertview/plugin.xml b/cave/com.raytheon.uf.viz.alertview/plugin.xml index 06ff5c5fe9..e05ca65c58 100644 --- a/cave/com.raytheon.uf.viz.alertview/plugin.xml +++ b/cave/com.raytheon.uf.viz.alertview/plugin.xml @@ -40,24 +40,4 @@ name="Open AlertView"> - - - - - - - - diff --git a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/AlertViewActivator.java b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/AlertViewActivator.java new file mode 100644 index 0000000000..f9cda9d7cc --- /dev/null +++ b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/AlertViewActivator.java @@ -0,0 +1,136 @@ +/** + * 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.alertview; + +import org.eclipse.jface.preference.PreferenceManager; +import org.eclipse.jface.preference.PreferenceNode; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; + +import com.raytheon.uf.viz.alertview.ui.prefs.AlertViewPreferencePage; +import com.raytheon.uf.viz.alertview.ui.prefs.PopupPreferencePage; +import com.raytheon.uf.viz.alertview.ui.prefs.StylePreferencePage; + +/** + * + * {@link BundleActivator} that is used to only show the preference pages if + * AlertView is being used. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer  Description
+ * ------------- -------- --------- --------------------------
+ * Jun 30, 2015  4474     bsteffen  Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class AlertViewActivator implements BundleActivator { + + + @Override + public void start(BundleContext context) throws InvalidSyntaxException { + /* + * Only show the preferences if this bundle is activated which will + * happen through declarative services if anyone is using the + * destination. + */ + if (PlatformUI.isWorkbenchRunning()) { + addPreferencePages(); + } else { + String workbenchFilter = "(" + Constants.OBJECTCLASS + "=" + + IWorkbench.class.getName() + ")"; + context.addServiceListener(new ServiceListener() { + + @Override + public void serviceChanged(ServiceEvent event) { + if (event.getType() == ServiceEvent.REGISTERED) { + addPreferencePages(); + } + } + }, workbenchFilter); + } + } + + protected void addPreferencePages() { + PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager(); + PreferenceNode alertViewNode = new PreferenceNode( + AlertViewPreferencePage.class.getName(), "Alert View", null, + null) { + + @Override + public void createPage() { + AlertViewPreferencePage page = new AlertViewPreferencePage(); + page.setTitle(getLabelText()); + page.setDescription("Configure AlertView appearance and behavior."); + setPage(page); + } + + }; + PreferenceNode popUpNode = new PreferenceNode( + PopupPreferencePage.class.getName(), "Popup", null, null) { + + @Override + public void createPage() { + PopupPreferencePage page = new PopupPreferencePage(); + page.setTitle(getLabelText()); + page.setDescription("Configure Alert Popup appearance and behavior."); + setPage(page); + } + + }; + PreferenceNode styleNode = new PreferenceNode( + StylePreferencePage.class.getName(), "Style", null, null) { + + @Override + public void createPage() { + StylePreferencePage page = new StylePreferencePage(); + page.setTitle(getLabelText()); + page.setDescription("Configure the way alerts appear in the alert table."); + setPage(page); + } + + }; + + alertViewNode.add(popUpNode); + alertViewNode.add(styleNode); + pm.addToRoot(alertViewNode); + } + + @Override + public void stop(BundleContext context) throws Exception { + if (PlatformUI.isWorkbenchRunning()) { + PreferenceManager pm = PlatformUI.getWorkbench() + .getPreferenceManager(); + pm.remove(AlertViewPreferencePage.class.getName()); + } + } + +} diff --git a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/style/StylePreferences.java b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/style/StylePreferences.java index 7b45c47140..0ac58d3359 100644 --- a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/style/StylePreferences.java +++ b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/style/StylePreferences.java @@ -27,6 +27,9 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.swt.graphics.RGB; + +import com.raytheon.uf.viz.alertview.Alert.Priority; import com.raytheon.uf.viz.alertview.prefs.PreferenceFile; /** @@ -54,6 +57,11 @@ public class StylePreferences { private List styles = new ArrayList<>(); public StylePreferences() { + AlertStyle errorStyle = new AlertStyle(); + errorStyle.setFilter(Priority.ERROR.name().toLowerCase()); + errorStyle.setForegroundColor(StyleManager.formatColor(new RGB(255, 0, + 0))); + styles.add(errorStyle); } public StylePreferences(List styles) { diff --git a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/AlertViewPreferencePage.java b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/AlertViewPreferencePage.java index d06d358b13..b91fdb69b6 100644 --- a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/AlertViewPreferencePage.java +++ b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/AlertViewPreferencePage.java @@ -38,8 +38,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; import com.raytheon.uf.viz.alertview.prefs.AlertViewPreferences; import com.raytheon.uf.viz.alertview.prefs.PreferenceFile; @@ -62,7 +60,7 @@ import com.raytheon.uf.viz.alertview.ui.view.AlertTable; * @version 1.0 */ public class AlertViewPreferencePage extends PreferencePage implements - IWorkbenchPreferencePage, PreferenceFile.Listener { + PreferenceFile.Listener { protected PreferenceFile preferenceFile; @@ -72,14 +70,9 @@ public class AlertViewPreferencePage extends PreferencePage implements protected Table columnTable; - @Override - public void init(IWorkbench workbench) { - setDescription("Configure AlertView appearance and behavior."); - preferenceFile = AlertViewPreferences.load(this); - } - @Override protected Control createContents(Composite parent) { + preferenceFile = AlertViewPreferences.load(this); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); diff --git a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/PopupPreferencePage.java b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/PopupPreferencePage.java index 58250655a7..e4ab1236c8 100644 --- a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/PopupPreferencePage.java +++ b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/PopupPreferencePage.java @@ -32,8 +32,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; import com.raytheon.uf.viz.alertview.prefs.PopUpPreferences; import com.raytheon.uf.viz.alertview.prefs.PopUpPreferences.PopUpCorner; @@ -56,7 +54,7 @@ import com.raytheon.uf.viz.alertview.prefs.PreferenceFile; * @version 1.0 */ public class PopupPreferencePage extends PreferencePage implements - IWorkbenchPreferencePage, PreferenceFile.Listener { + PreferenceFile.Listener { private static final List SIZES = Arrays.asList("Small", "Medium", "Large"); @@ -75,14 +73,9 @@ public class PopupPreferencePage extends PreferencePage implements protected Combo sizeCombo; - @Override - public void init(IWorkbench workbench) { - setDescription("Configure Alert Popup appearance and behavior."); - preferenceFile = PopUpPreferences.load(this); - } - @Override protected Control createContents(Composite parent) { + preferenceFile = PopUpPreferences.load(this); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.NONE).setText("Popup Priority: "); diff --git a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/StylePreferencePage.java b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/StylePreferencePage.java index db365b3572..95cf67a4a8 100644 --- a/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/StylePreferencePage.java +++ b/cave/com.raytheon.uf.viz.alertview/src/com/raytheon/uf/viz/alertview/ui/prefs/StylePreferencePage.java @@ -43,8 +43,6 @@ import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; import com.raytheon.uf.viz.alertview.Alert.Priority; import com.raytheon.uf.viz.alertview.prefs.PreferenceFile; @@ -69,7 +67,7 @@ import com.raytheon.uf.viz.alertview.style.StylePreferences; * @version 1.0 */ public class StylePreferencePage extends PreferencePage implements - IWorkbenchPreferencePage, PreferenceFile.Listener { + PreferenceFile.Listener { protected PreferenceFile preferenceFile; @@ -83,14 +81,9 @@ public class StylePreferencePage extends PreferencePage implements protected Button fontButton; - @Override - public void init(IWorkbench workbench) { - setDescription("Configure the way alerts appear in the alert table."); - preferenceFile = StylePreferences.load(this); - } - @Override protected Control createContents(Composite parent) { + preferenceFile = StylePreferences.load(this); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Composite tableComp = new Composite(composite, SWT.NONE);