Omaha #4474 Only show AlertView preferences when AlertView is being used.

Former-commit-id: 4e730f7344dcf8ddc40953aeb2f122c469b62da5
This commit is contained in:
Ben Steffensmeier 2015-06-30 10:06:26 -05:00
parent ceb159f889
commit 780a7e249c
11 changed files with 155 additions and 51 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="com.raytheon.uf.viz.alertview.ui.view.AlertViewAutoOpen" enabled="true" immediate="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<component name="com.raytheon.uf.viz.alertview.ui.view.AlertViewAutoOpen" enabled="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.raytheon.uf.viz.alertview.ui.view.AlertViewAutoOpen" />
<service>
<provide interface="com.raytheon.uf.viz.alertview.AlertDestination" />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="com.raytheon.uf.viz.alertview.ui.popup.AlertPopup" enabled="true" immediate="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<component name="com.raytheon.uf.viz.alertview.ui.popup.AlertPopup" enabled="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.raytheon.uf.viz.alertview.ui.popup.AlertPopup" />
<service>
<provide interface="com.raytheon.uf.viz.alertview.AlertDestination" />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="com.raytheon.uf.viz.alertview.prefs.RCPPrefStore" enabled="true" immediate="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<component name="com.raytheon.uf.viz.alertview.prefs.RCPPrefStore" enabled="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.raytheon.uf.viz.alertview.prefs.RCPPrefStore" />
<service>
<provide interface="com.raytheon.uf.viz.alertview.AlertViewPrefStore" />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="com.raytheon.uf.viz.alertview.store.MemoryAlertStore" enabled="true" immediate="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<component name="com.raytheon.uf.viz.alertview.store.MemoryAlertStore" enabled="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">
<implementation class="com.raytheon.uf.viz.alertview.store.MemoryAlertStore" />
<service>
<provide interface="com.raytheon.uf.viz.alertview.AlertDestination" />

View file

@ -40,24 +40,4 @@
name="Open AlertView">
</command>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="com.raytheon.uf.viz.alertview.ui.prefs.AlertViewPreferencePage"
id="com.raytheon.uf.viz.alertview.ui.prefs.AlertViewPreferencePage"
name="Alert View">
</page>
<page
class="com.raytheon.uf.viz.alertview.ui.prefs.PopupPreferencePage"
id="com.raytheon.uf.viz.alertview.ui.prefs.PopupPreferencePage"
category="com.raytheon.uf.viz.alertview.ui.prefs.AlertViewPreferencePage"
name="Popup">
</page>
<page
class="com.raytheon.uf.viz.alertview.ui.prefs.StylePreferencePage"
id="com.raytheon.uf.viz.alertview.ui.prefs.StylePreferencePage"
category="com.raytheon.uf.viz.alertview.ui.prefs.AlertViewPreferencePage"
name="Style">
</page>
</extension>
</plugin>

View file

@ -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.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- --------- --------------------------
* Jun 30, 2015 4474 bsteffen Initial creation
*
* </pre>
*
* @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());
}
}
}

View file

@ -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<AlertStyle> 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<AlertStyle> styles) {

View file

@ -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<AlertViewPreferences> {
PreferenceFile.Listener<AlertViewPreferences> {
protected PreferenceFile<AlertViewPreferences> 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));

View file

@ -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<PopUpPreferences> {
PreferenceFile.Listener<PopUpPreferences> {
private static final List<String> 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: ");

View file

@ -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<StylePreferences> {
PreferenceFile.Listener<StylePreferences> {
protected PreferenceFile<StylePreferences> 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);