parent
93bc0e3be6
commit
3348208fcc
20 changed files with 1717 additions and 0 deletions
7
unidata/edu.ucar.unidata.uf.viz.radarbrowser/.classpath
Normal file
7
unidata/edu.ucar.unidata.uf.viz.radarbrowser/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry excluding="com/raytheon/uf/viz/productbrowser/AbstractNonRequestableProductBrowser.java|com/raytheon/uf/viz/productbrowser/bookmarks/RequestableBookmark.java" kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
30
unidata/edu.ucar.unidata.uf.viz.radarbrowser/.project
Normal file
30
unidata/edu.ucar.unidata.uf.viz.radarbrowser/.project
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>edu.ucar.unidata.uf.viz.radarbrowser</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,15 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: RadarBrowser Plug-in
|
||||
Bundle-SymbolicName: edu.ucar.unidata.uf.viz.radarbrowser;singleton:=true
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Activator: edu.ucar.unidata.uf.viz.radarbrowser.Activator
|
||||
Bundle-Vendor: Unidata
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Export-Package: edu.ucar.unidata.uf.viz.radarbrowser
|
||||
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
|
||||
com.raytheon.viz.ui;bundle-version="1.14.0",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.14.3",
|
||||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.viz.productbrowser;bundle-version="1.14.0"
|
|
@ -0,0 +1,6 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
icons/
|
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/browser.gif
Normal file
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/browser.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 B |
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/help.gif
Normal file
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/help.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 259 B |
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/refresh.gif
Normal file
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/refresh.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 327 B |
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/run.gif
Normal file
BIN
unidata/edu.ucar.unidata.uf.viz.radarbrowser/icons/run.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 379 B |
68
unidata/edu.ucar.unidata.uf.viz.radarbrowser/plugin.xml
Normal file
68
unidata/edu.ucar.unidata.uf.viz.radarbrowser/plugin.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension-point id="dataDefinition" name="dataDefinition" schema="schema/dataDefinition.exsd"/>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<view
|
||||
allowMultiple="false"
|
||||
category="com.raytheon.viz.ui"
|
||||
class="edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView"
|
||||
id="edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView"
|
||||
icon="icons/browser.gif"
|
||||
name="Radar Browser"
|
||||
restorable="true"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
class="edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserPreferencesPage"
|
||||
id="edu.ucar.unidata.uf.viz.radarbrowser.radarbrowserpreferencespage"
|
||||
name="Radar Browser"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
allPopups="false"
|
||||
locationURI="menu:CAVE?after=group1">
|
||||
<command
|
||||
commandId="edu.ucar.unidata.uf.viz.radarbrowser.radarBrowser"
|
||||
label="Radar Browser"
|
||||
style="push">
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
id="edu.ucar.unidata.uf.viz.radarbrowser.radarBrowser"
|
||||
name="Radar Browser">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.handlers">
|
||||
<handler
|
||||
class="edu.ucar.unidata.uf.viz.radarbrowser.actions.RadarBrowserAction"
|
||||
commandId="edu.ucar.unidata.uf.viz.radarbrowser.radarBrowser">
|
||||
</handler>
|
||||
</extension>
|
||||
</plugin>
|
|
@ -0,0 +1,109 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="edu.ucar.unidata.uf.viz.radarbrowser" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="edu.ucar.unidata.uf.viz.radarbrowser" id="uradarBrowserDataDefinition" name="uradarBrowserDataDefinition"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="dataDefinition"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="dataDefinition">
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="edu.ucar.unidata.uf.viz.radarbrowser.AbstractRadarBrowserDataDefinition:"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -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 edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "edu.ucar.unidata.uf.viz.radarbrowser";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
|
||||
* )
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
|
||||
* )
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
/**
|
||||
* 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 edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.ListEditor;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition;
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference;
|
||||
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference.PreferenceType;
|
||||
|
||||
/**
|
||||
* Builds each data type's preference specifically for product browser
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 16, 2011 mnash Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataTypePreferencePage extends FieldEditorPreferencePage implements
|
||||
IWorkbenchPreferencePage {
|
||||
|
||||
private static IExtension[] extensions;
|
||||
|
||||
private List<AbstractProductBrowserDataDefinition<?>> prods = null;
|
||||
|
||||
private List<FieldEditor> editors = null;
|
||||
|
||||
private static boolean saved = false;
|
||||
|
||||
public DataTypePreferencePage() {
|
||||
super(GRID);
|
||||
prods = new ArrayList<AbstractProductBrowserDataDefinition<?>>();
|
||||
editors = new ArrayList<FieldEditor>();
|
||||
setDescription("Specify Product Browser Settings...");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||
*/
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
saved = false;
|
||||
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
||||
setDescription("Data Type Preferences");
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry
|
||||
.getExtensionPoint(RadarBrowserUtils.DATA_DEFINITION_ID);
|
||||
if (point != null) {
|
||||
extensions = point.getExtensions();
|
||||
} else {
|
||||
extensions = new IExtension[0];
|
||||
}
|
||||
|
||||
for (IExtension ext : extensions) {
|
||||
IConfigurationElement[] config = ext.getConfigurationElements();
|
||||
for (IConfigurationElement element : config) {
|
||||
try {
|
||||
AbstractProductBrowserDataDefinition<?> prod = (AbstractProductBrowserDataDefinition<?>) element
|
||||
.createExecutableExtension("class");
|
||||
prods.add(prod);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
|
||||
*/
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
boolean tf = super.performOk();
|
||||
for (IViewReference reference : PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage().getViewReferences()) {
|
||||
if (!saved) {
|
||||
if (RadarBrowserView.ID.equals(reference.getId())) {
|
||||
((RadarBrowserView) reference.getPart(true))
|
||||
.populateInitialProductTree();
|
||||
saved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.preference.PreferencePage#performApply()
|
||||
*/
|
||||
@Override
|
||||
protected void performApply() {
|
||||
for (FieldEditor editor : editors) {
|
||||
editor.store();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
String[][] fields = new String[prods.size()][2];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
for (int j = 0; j < fields[i].length; j++) {
|
||||
fields[i][j] = prods.get(i).displayName;
|
||||
}
|
||||
}
|
||||
|
||||
getPreferences(getProduct(getTitle()));
|
||||
for (FieldEditor editor : editors) {
|
||||
this.addField(editor);
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractProductBrowserDataDefinition<?> getProduct(String name) {
|
||||
for (AbstractProductBrowserDataDefinition<?> prod : prods) {
|
||||
if (name.equals(prod.displayName)) {
|
||||
return prod;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Per each type of product, goes in and decides what preferences it needs
|
||||
* to display
|
||||
*
|
||||
* @param prod
|
||||
*/
|
||||
private void getPreferences(
|
||||
final AbstractProductBrowserDataDefinition<?> prod) {
|
||||
List<ProductBrowserPreference> prefs = prod.getPreferences();
|
||||
for (ProductBrowserPreference pref : prefs) {
|
||||
if (pref.getPreferenceType() == PreferenceType.EDITABLE_STRING) {
|
||||
StringFieldEditor editor = new StringFieldEditor(
|
||||
pref.getLabel() + prod.displayName, pref.getLabel(),
|
||||
getFieldEditorParent());
|
||||
editors.add(editor);
|
||||
} else if (pref.getPreferenceType() == PreferenceType.BOOLEAN) {
|
||||
BooleanFieldEditor editor = new BooleanFieldEditor(
|
||||
pref.getLabel() + prod.displayName, pref.getLabel(),
|
||||
getFieldEditorParent());
|
||||
editors.add(editor);
|
||||
} else if (pref.getPreferenceType() == PreferenceType.STRING_ARRAY) {
|
||||
final String[] values = ((String[]) pref.getValue());
|
||||
ListEditor editor = new ListEditor(pref.getLabel()
|
||||
+ prod.displayName, pref.getLabel(),
|
||||
getFieldEditorParent()) {
|
||||
|
||||
@Override
|
||||
protected String[] parseString(String stringList) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNewInputObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String createList(String[] items) {
|
||||
String temp = "";
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (temp.isEmpty()) {
|
||||
temp += items[i];
|
||||
} else {
|
||||
temp += "," + items[i];
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFillIntoGrid(Composite parent,
|
||||
int numColumns) {
|
||||
super.doFillIntoGrid(parent, numColumns);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
getList().add(values[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
editor.getButtonBoxControl(getFieldEditorParent())
|
||||
.getChildren()[0].setVisible(false);
|
||||
editor.getButtonBoxControl(getFieldEditorParent())
|
||||
.getChildren()[1].setVisible(false);
|
||||
editor.getButtonBoxControl(getFieldEditorParent()).layout();
|
||||
editors.add(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
/**
|
||||
* 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 edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition;
|
||||
|
||||
/**
|
||||
* Generic class for sending back information from the data definition classes
|
||||
* to the product browser tree
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 21, 2010 mnash Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RadarBrowserLabel implements Comparable<RadarBrowserLabel>,
|
||||
Comparator<RadarBrowserLabel> {
|
||||
|
||||
public RadarBrowserLabel() {
|
||||
}
|
||||
|
||||
public RadarBrowserLabel(String name, String data) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
private String data;
|
||||
|
||||
private boolean product;
|
||||
|
||||
private AbstractProductBrowserDataDefinition<?> definition;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean isProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(boolean product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the definition
|
||||
*/
|
||||
public AbstractProductBrowserDataDefinition<?> getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param definition
|
||||
* the definition to set
|
||||
*/
|
||||
public void setDefinition(AbstractProductBrowserDataDefinition<?> definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(RadarBrowserLabel o1, RadarBrowserLabel o2) {
|
||||
if (o1.getName() != null && o2.getName() != null) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(RadarBrowserLabel that) {
|
||||
return this.compare(this, that);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((data == null) ? 0 : data.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RadarBrowserLabel other = (RadarBrowserLabel) obj;
|
||||
if (data == null) {
|
||||
if (other.data != null)
|
||||
return false;
|
||||
} else if (!data.equals(other.data))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -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 edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 10, 2011 mnash Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RadarBrowserPreferencesPage extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage {
|
||||
|
||||
public RadarBrowserPreferencesPage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||
*/
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
||||
setDescription("Specify Product Browser Settings...\n\nFor each plugin, set different options.");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 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 edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
/**
|
||||
* Utilities to be used by the product browser
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 2, 2010 mnash Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RadarBrowserUtils {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RadarBrowserUtils.class);
|
||||
|
||||
public static final String DATA_DEFINITION_ID = "edu.ucar.unidata.uf.viz.radarbrowser.dataDefinition";
|
||||
|
||||
/**
|
||||
* Gets the image descriptor so an image can be displayed (for icons)
|
||||
*
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String string) {
|
||||
String iconPath = "icons" + File.separator;
|
||||
URL url = FileLocator.find(Activator.getDefault().getBundle(),
|
||||
new Path(iconPath + string), null);
|
||||
if (url != null && url.getFile() == null) {
|
||||
url = FileLocator.find(Activator.getDefault().getBundle(),
|
||||
new Path(".." + File.separator + iconPath + string), null);
|
||||
}
|
||||
return ImageDescriptor.createFromURL(url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,427 @@
|
|||
package edu.ucar.unidata.uf.viz.radarbrowser;
|
||||
|
||||
/**
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.rsc.DisplayType;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceType;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.DisplayTypeCapability;
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition;
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractRequestableProductBrowserDataDefinition;
|
||||
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.jobs.RadarBrowserInitializeJob;
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.jobs.RadarBrowserQueryJob;
|
||||
|
||||
/**
|
||||
* Product browser view implementation
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* May 03, 2010 mnash Initial creation
|
||||
* May 02, 2013 1949 bsteffen Switch Product Browser from uengine to
|
||||
* DbQueryRequest.
|
||||
* May 13, 2014 3135 bsteffen Make all queries async.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RadarBrowserView extends ViewPart {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RadarBrowserView.class);
|
||||
|
||||
public static final String ID = "edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView";
|
||||
|
||||
public static final String LABEL_DATA_KEY = "label";
|
||||
|
||||
public static final String DEF_DATA_KEY = "defintion";
|
||||
|
||||
private static IExtension[] extensions;
|
||||
|
||||
private Tree productTree;
|
||||
|
||||
private Action loadProductAction;
|
||||
|
||||
private Action productInfoAction;
|
||||
|
||||
private Action refreshAction;
|
||||
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
Composite fullComp = new Composite(parent, SWT.FILL);
|
||||
fullComp.setLayout(new GridLayout(1, true));
|
||||
getDataTypes();
|
||||
createActions();
|
||||
createToolbar();
|
||||
createProductTree(fullComp);
|
||||
createProductBrowserContextMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the actions available to the product tree
|
||||
*/
|
||||
private void createActions() {
|
||||
refreshAction = new Action("Refresh Browser") {
|
||||
@Override
|
||||
public void run() {
|
||||
populateInitialProductTree();
|
||||
}
|
||||
};
|
||||
refreshAction.setId("refreshAction");
|
||||
refreshAction.setImageDescriptor(RadarBrowserUtils
|
||||
.getImageDescriptor("refresh.gif"));
|
||||
|
||||
productInfoAction = new Action("Product Info") {
|
||||
@Override
|
||||
public void run() {
|
||||
displayInfo();
|
||||
}
|
||||
};
|
||||
productInfoAction.setId("productInfoAction");
|
||||
productInfoAction.setImageDescriptor(RadarBrowserUtils
|
||||
.getImageDescriptor("help.gif"));
|
||||
|
||||
loadProductAction = new Action("Load Product") {
|
||||
@Override
|
||||
public void run() {
|
||||
loadProduct(null);
|
||||
}
|
||||
};
|
||||
loadProductAction.setId("loadProductAction");
|
||||
loadProductAction.setImageDescriptor(RadarBrowserUtils
|
||||
.getImageDescriptor("run.gif"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the product browser that spans the entire view...
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void createProductTree(final Composite parent) {
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
productTree = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
|
||||
| SWT.BORDER);
|
||||
productTree.setLayoutData(gridData);
|
||||
productTree.addListener(SWT.MouseDoubleClick, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if (event.button == 1) {
|
||||
loadProductAction.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
productTree.addListener(SWT.Expand, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
RadarBrowserQueryJob.startJob((TreeItem) event.item);
|
||||
}
|
||||
});
|
||||
|
||||
productTree.addListener(SWT.MouseMove, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
productTree.setToolTipText("");
|
||||
}
|
||||
});
|
||||
populateInitialProductTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the toolbar at the top of the view
|
||||
*/
|
||||
private void createToolbar() {
|
||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
||||
mgr.add(refreshAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating the right click menu, for the product tree
|
||||
*/
|
||||
private void createProductBrowserContextMenu() {
|
||||
MenuManager menuMgr = new MenuManager();
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
menuMgr.addMenuListener(new IMenuListener() {
|
||||
@Override
|
||||
public void menuAboutToShow(IMenuManager mgr) {
|
||||
fillProductBrowserContextMenu(mgr);
|
||||
}
|
||||
});
|
||||
|
||||
Menu menu = menuMgr.createContextMenu(productTree);
|
||||
productTree.setMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes the menu during the right click and fills it with actions pertinent
|
||||
* to the product tree and pertinent to the item that is selected
|
||||
*
|
||||
* @param mgr
|
||||
*/
|
||||
protected void fillProductBrowserContextMenu(IMenuManager mgr) {
|
||||
TreeItem[] selection = productTree.getSelection();
|
||||
if (selection != null && selection.length > 0) {
|
||||
RadarBrowserLabel label = getLabel(selection[0]);
|
||||
if (label == null) {
|
||||
return;
|
||||
}
|
||||
// if not a product, do not give opportunity to load things
|
||||
if (label.isProduct()) {
|
||||
AbstractProductBrowserDataDefinition<?> def = getDataDef(selection[0]);
|
||||
Map<ResourceType, List<DisplayType>> displayTypes = def
|
||||
.getDisplayTypes();
|
||||
if (displayTypes != null && displayTypes.isEmpty() == false) {
|
||||
MenuManager menuMgr = new MenuManager("Load As...",
|
||||
RadarBrowserUtils.getImageDescriptor("run.gif"),
|
||||
"");
|
||||
for (ResourceType type : displayTypes.keySet()) {
|
||||
if (displayTypes.keySet().size() <= 1) {
|
||||
for (DisplayType types : displayTypes.get(type)) {
|
||||
menuMgr.add(getDisplayTypeAction(types));
|
||||
}
|
||||
}
|
||||
}
|
||||
mgr.add(menuMgr);
|
||||
} else {
|
||||
mgr.add(loadProductAction);
|
||||
}
|
||||
}
|
||||
mgr.add(productInfoAction);
|
||||
}
|
||||
}
|
||||
|
||||
private Action getDisplayTypeAction(final DisplayType type) {
|
||||
char[] name = type.name().toLowerCase().toCharArray();
|
||||
name[0] = Character.toUpperCase(name[0]);
|
||||
Action action = new Action((String.valueOf(name))) {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
loadProduct(type);
|
||||
}
|
||||
};
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the initial plugins available and populate them if they have any
|
||||
* data. This function does not populate the tree with the data, just the
|
||||
* plugin names.
|
||||
*
|
||||
* @param popData
|
||||
*/
|
||||
public void populateInitialProductTree() {
|
||||
productTree.removeAll();
|
||||
for (IExtension ext : extensions) {
|
||||
IConfigurationElement[] config = ext.getConfigurationElements();
|
||||
for (IConfigurationElement element : config) {
|
||||
AbstractProductBrowserDataDefinition<?> prod = null;
|
||||
try {
|
||||
prod = (AbstractProductBrowserDataDefinition<?>) element
|
||||
.createExecutableExtension("class");
|
||||
} catch (CoreException e) {
|
||||
statusHandler
|
||||
.error("A product browser data definition has failed to load.",
|
||||
e);
|
||||
continue;
|
||||
}
|
||||
String displayText = "Checking Availability of "
|
||||
+ prod.displayName + "...";
|
||||
/* Sort alphabetically. */
|
||||
int index = 0;
|
||||
for (TreeItem items : productTree.getItems()) {
|
||||
if (items.getText().compareToIgnoreCase(displayText) > 0) {
|
||||
break;
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
TreeItem ti = new TreeItem(productTree, SWT.NONE, index);
|
||||
ti.setText(displayText);
|
||||
RadarBrowserLabel label = new RadarBrowserLabel(
|
||||
prod.displayName, prod.displayName);
|
||||
if (prod instanceof AbstractRequestableProductBrowserDataDefinition<?>) {
|
||||
AbstractRequestableProductBrowserDataDefinition<?> arpbdd = (AbstractRequestableProductBrowserDataDefinition<?>) prod;
|
||||
label.setData(arpbdd.productName);
|
||||
label.setProduct(arpbdd.order.length == 0);
|
||||
}
|
||||
ti.setData(LABEL_DATA_KEY, label);
|
||||
ti.setData(DEF_DATA_KEY, prod);
|
||||
Font font = ti.getFont();
|
||||
FontData fontData = font.getFontData()[0];
|
||||
fontData = new FontData(fontData.getName(),
|
||||
fontData.getHeight(), SWT.BOLD);
|
||||
font = new Font(ti.getDisplay(), fontData);
|
||||
ti.setFont(font);
|
||||
new RadarBrowserInitializeJob(ti).schedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Using reflection and the eclipse registry, agnostically finds the
|
||||
* available types to populate the tree
|
||||
*/
|
||||
private void getDataTypes() {
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry
|
||||
.getExtensionPoint(RadarBrowserUtils.DATA_DEFINITION_ID);
|
||||
if (point != null) {
|
||||
extensions = point.getExtensions();
|
||||
} else {
|
||||
extensions = new IExtension[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void loadProduct(DisplayType type) {
|
||||
TreeItem[] selection = productTree.getSelection();
|
||||
if (selection != null) {
|
||||
for (TreeItem item : selection) {
|
||||
RadarBrowserLabel label = getLabel(selection[0]);
|
||||
if (label == null) {
|
||||
return;
|
||||
}
|
||||
// if not a product, do not give opportunity to load things
|
||||
if (label.isProduct()) {
|
||||
AbstractProductBrowserDataDefinition<?> def = getDataDef(item);
|
||||
String[] path = getProductURI(item, false);
|
||||
if (type != null) {
|
||||
def.loadProperties
|
||||
.getCapabilities()
|
||||
.getCapability(def.resourceData,
|
||||
DisplayTypeCapability.class)
|
||||
.setDisplayType(type);
|
||||
}
|
||||
def.constructResource(path, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tooltip text to the tree with information about the selected item
|
||||
*/
|
||||
private void displayInfo() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (TreeItem ti : productTree.getSelection()) {
|
||||
if (stringBuilder.length() > 0) {
|
||||
stringBuilder.append("\n---------------\n");
|
||||
}
|
||||
AbstractProductBrowserDataDefinition<?> prod = getDataDef(ti);
|
||||
String[] info = getProductURI(ti, false);
|
||||
if (prod instanceof AbstractRequestableProductBrowserDataDefinition<?>) {
|
||||
AbstractRequestableProductBrowserDataDefinition<?> aProd = (AbstractRequestableProductBrowserDataDefinition<?>) prod;
|
||||
stringBuilder.append(aProd.PLUGIN_NAME + " = "
|
||||
+ aProd.productName);
|
||||
} else {
|
||||
stringBuilder.append(prod.displayName);
|
||||
}
|
||||
for (int i = 1; i < info.length; i++) {
|
||||
stringBuilder.append("\n");
|
||||
if (prod instanceof AbstractRequestableProductBrowserDataDefinition<?>) {
|
||||
stringBuilder
|
||||
.append(((AbstractRequestableProductBrowserDataDefinition<?>) prod).order[i - 1]
|
||||
+ " = " + info[i]);
|
||||
} else {
|
||||
stringBuilder.append(info[i]);
|
||||
}
|
||||
}
|
||||
productTree.setToolTipText(stringBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
productTree.setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Using the tree item, gets the URI based on where it is within the tree
|
||||
*
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public static String[] getProductURI(TreeItem item, boolean isName) {
|
||||
List<String> data = new ArrayList<String>();
|
||||
while (item != null) {
|
||||
RadarBrowserLabel label = getLabel(item);
|
||||
if (isName || label.getData() == null) {
|
||||
data.add(label.getName());
|
||||
} else {
|
||||
data.add(label.getData());
|
||||
}
|
||||
item = item.getParentItem();
|
||||
}
|
||||
Collections.reverse(data);
|
||||
return data.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static RadarBrowserLabel getLabel(TreeItem item) {
|
||||
return (RadarBrowserLabel) item.getData(LABEL_DATA_KEY);
|
||||
}
|
||||
|
||||
public static AbstractProductBrowserDataDefinition<?> getDataDef(
|
||||
TreeItem item) {
|
||||
return (AbstractProductBrowserDataDefinition<?>) item
|
||||
.getData(DEF_DATA_KEY);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package edu.ucar.unidata.uf.viz.radarbrowser.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.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.status.StatusConstants;
|
||||
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.Activator;
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView;
|
||||
|
||||
public class RadarBrowserAction extends AbstractHandler {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(RadarBrowserAction.class);
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// this opens the product browser view
|
||||
try {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().showView(RadarBrowserView.ID);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open product browser", e);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
* 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 edu.ucar.unidata.uf.viz.radarbrowser.jobs;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition;
|
||||
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView;
|
||||
|
||||
/**
|
||||
*
|
||||
* Job for initializing {@link TreeItem}s for the {@link RadarBrowserView}.
|
||||
* The tree items are assumed to be initially in a loading state and this job
|
||||
* asynchronously calls
|
||||
* {@link AbstractRadarBrowserDataDefinition#populateInitial()} to determine
|
||||
* if the item should be expandable and then removes or configures the item on
|
||||
* the UI thread.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* May 13, 2014 3135 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RadarBrowserInitializeJob extends Job implements Runnable {
|
||||
|
||||
protected final TreeItem item;
|
||||
|
||||
protected final AbstractProductBrowserDataDefinition<?> def;
|
||||
|
||||
protected String displayName;
|
||||
|
||||
/**
|
||||
* Create a new Job for the provided item, this constructor must be called
|
||||
* on the UI thread.
|
||||
*
|
||||
* @param item
|
||||
* a TreeItem from the {@link RadarBrowserView}
|
||||
*/
|
||||
public RadarBrowserInitializeJob(TreeItem item) {
|
||||
super(item.getText());
|
||||
this.item = item;
|
||||
/*
|
||||
* Def must be pulled out of item on the UI thread so it can be accessed
|
||||
* off the UI thread.
|
||||
*/
|
||||
this.def = RadarBrowserView.getDataDef(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable method inherited from {@link Job} for running in the background.
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
displayName = def.populateInitial();
|
||||
if (!item.isDisposed()) {
|
||||
item.getDisplay().syncExec(this);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable method inherited from {@link Runnable}. This will be run on the
|
||||
* UI thread.
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (item.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
if (displayName == null) {
|
||||
item.dispose();
|
||||
} else {
|
||||
item.setText(displayName);
|
||||
if (!RadarBrowserView.getLabel(item).isProduct()) {
|
||||
/*
|
||||
* gives the tree the ability to be opened by adding a "fake"
|
||||
* tree item that will be disposed of later
|
||||
*/
|
||||
TreeItem fake = new TreeItem(item, SWT.NONE);
|
||||
fake.setText("Loading...");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* 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 edu.ucar.unidata.uf.viz.radarbrowser.jobs;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractProductBrowserDataDefinition;
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserLabel;
|
||||
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserLabel;
|
||||
import edu.ucar.unidata.uf.viz.radarbrowser.RadarBrowserView;
|
||||
|
||||
/**
|
||||
*
|
||||
* Job for performing the population of the {@link RadarBrowserView} tree
|
||||
* asynchronously. To avoid querying multiple times on the same item all
|
||||
* instances of this class should be started with {@link #startJob(TreeItem)}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* May 13, 2014 3135 bsteffen Initial creation
|
||||
* Jun 24, 2014 3279 bclement added error handling and item.clearAll()
|
||||
* to run methods to fix eternal 'Loading...' problem
|
||||
* Jul 07, 2014 3135 bsteffen Remove child nodes when there are no results.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RadarBrowserQueryJob extends Job implements Runnable {
|
||||
|
||||
private static final IUFStatusHandler log = UFStatus
|
||||
.getHandler(RadarBrowserQueryJob.class);
|
||||
|
||||
protected static final String JOB_DATA_KEY = "queryJob";
|
||||
|
||||
protected TreeItem item;
|
||||
|
||||
protected final AbstractProductBrowserDataDefinition<?> def;
|
||||
|
||||
protected final String[] selection;
|
||||
|
||||
protected List<ProductBrowserLabel> results;
|
||||
|
||||
protected RadarBrowserQueryJob(TreeItem item) {
|
||||
super(extractName(item));
|
||||
this.item = item;
|
||||
/*
|
||||
* Fields must be pulled off the item on the UI thread.
|
||||
*/
|
||||
this.def = RadarBrowserView.getDataDef(item);
|
||||
this.selection = RadarBrowserView.getProductURI(item, false);
|
||||
item.setData(JOB_DATA_KEY, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable method inherited from {@link Job} for running in the background.
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
IStatus rval = Status.OK_STATUS;
|
||||
try {
|
||||
results = def.populateData(selection);
|
||||
if (!item.isDisposed()) {
|
||||
item.getDisplay().syncExec(this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
/* something has gone very wrong */
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
rval = Status.CANCEL_STATUS;
|
||||
/* clean up tree */
|
||||
if (!item.isDisposed()) {
|
||||
item.getDisplay().syncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (TreeItem child : item.getItems()) {
|
||||
child.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable method inherited from {@link Runnable}. This will be run on the
|
||||
* UI thread.
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (item.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
List<ProductBrowserLabel> results = this.results;
|
||||
if (results == null) {
|
||||
results = Collections.emptyList();
|
||||
}
|
||||
/*
|
||||
* If all children are disposed it can cause expand to disable so make
|
||||
* sure we re enable it.
|
||||
*/
|
||||
boolean expanded = item.getExpanded();
|
||||
/*
|
||||
* Attempt to merge any existing nodes with the labels returned from the
|
||||
* query. If the order is the same then this should only perform simple
|
||||
* additions/removals. If the order has changed for some reason this
|
||||
* will copy some items to try to make the UI as consistent as possible.
|
||||
*/
|
||||
for (int i = 0; i < results.size(); i += 1) {
|
||||
boolean create = true;
|
||||
ProductBrowserLabel label = results.get(i);
|
||||
while (i < item.getItemCount()) {
|
||||
TreeItem childItem = item.getItem(i);
|
||||
RadarBrowserLabel childLabel = RadarBrowserView
|
||||
.getLabel(childItem);
|
||||
if (childLabel != null && childLabel.equals(label)) {
|
||||
create = false;
|
||||
break;
|
||||
} else if (results.contains(childLabel)) {
|
||||
for (int j = i + 1; j < item.getItemCount(); j += 1) {
|
||||
childItem = item.getItem(j);
|
||||
childLabel = RadarBrowserView.getLabel(childItem);
|
||||
if (childLabel.equals(label)) {
|
||||
TreeItem child = new TreeItem(item, SWT.NONE, i);
|
||||
copyItem(childItem, child);
|
||||
childItem.dispose();
|
||||
create = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
childItem.dispose();
|
||||
}
|
||||
}
|
||||
if (create) {
|
||||
TreeItem child = new TreeItem(item, SWT.NONE, i);
|
||||
child.setText(label.getName());
|
||||
child.setData(RadarBrowserView.LABEL_DATA_KEY, label);
|
||||
child.setData(RadarBrowserView.DEF_DATA_KEY, def);
|
||||
if (!label.isProduct()) {
|
||||
TreeItem loading = new TreeItem(child, SWT.NONE);
|
||||
loading.setText("Loading...");
|
||||
loading.setGrayed(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!results.isEmpty()) {
|
||||
item.setExpanded(expanded);
|
||||
} else {
|
||||
for (TreeItem child : item.getItems()) {
|
||||
child.dispose();
|
||||
}
|
||||
}
|
||||
item.setData(JOB_DATA_KEY, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively copy an item. This is only needed if a query is repeated and
|
||||
* returns items in a new order.
|
||||
*
|
||||
* @param oldItem
|
||||
* @param newItem
|
||||
*/
|
||||
protected void copyItem(TreeItem oldItem, TreeItem newItem) {
|
||||
newItem.setText(oldItem.getText());
|
||||
for (TreeItem oldChild : oldItem.getItems()) {
|
||||
TreeItem newChild = new TreeItem(newItem, SWT.NONE);
|
||||
if (newItem.getItemCount() == 1) {
|
||||
/*
|
||||
* For recursive expansion to work newItem must be expanded
|
||||
* after newChild is created but before newChild is expanded.
|
||||
*/
|
||||
newItem.setExpanded(oldItem.getExpanded());
|
||||
}
|
||||
copyItem(oldChild, newChild);
|
||||
}
|
||||
newItem.setData(RadarBrowserView.LABEL_DATA_KEY,
|
||||
RadarBrowserView
|
||||
.getLabel(oldItem));
|
||||
newItem.setData(RadarBrowserView.DEF_DATA_KEY,
|
||||
RadarBrowserView.getDataDef(oldItem));
|
||||
RadarBrowserQueryJob job = (RadarBrowserQueryJob) oldItem
|
||||
.getData(JOB_DATA_KEY);
|
||||
if (job != null) {
|
||||
job.setItem(newItem);
|
||||
newItem.setData(JOB_DATA_KEY, job);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setItem(TreeItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
protected static String extractName(TreeItem item) {
|
||||
StringBuilder name = new StringBuilder();
|
||||
if (item.getItemCount() == 1) {
|
||||
name.append("Querying");
|
||||
} else {
|
||||
name.append("Refreshing");
|
||||
}
|
||||
for (String label : RadarBrowserView.getProductURI(item, true)) {
|
||||
name.append(" ").append(label);
|
||||
}
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new query job for the provided item only if there is not
|
||||
* currently a job running.
|
||||
*
|
||||
* @param item
|
||||
* a TreeItem from the {@link RadarBrowserView}
|
||||
*/
|
||||
public static void startJob(TreeItem item) {
|
||||
if (item.getData(JOB_DATA_KEY) == null) {
|
||||
new RadarBrowserQueryJob(item).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue