Issue #1460 - Merge 4.7-GIS_Viewer into AWIPS2_baseline
Former-commit-id:87d0821429
[formerly76fe910606
] [formerly87d0821429
[formerly76fe910606
] [formerly03f108f80b
[formerly 9e0eae1725af06ce834c926a4d70195a075e8152]]] Former-commit-id:03f108f80b
Former-commit-id:7dd7d1cfa7
[formerlybbeb6b5101
] Former-commit-id:74f4811f07
This commit is contained in:
parent
4a3000f19a
commit
2ec11e041a
47 changed files with 6375 additions and 30 deletions
|
@ -272,40 +272,38 @@
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.ncep.perspective.feature" />
|
value="com.raytheon.uf.viz.ncep.perspective.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.nwsauth.feature" />
|
value="com.raytheon.uf.viz.nwsauth.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.thinclient.feature" />
|
value="com.raytheon.uf.viz.thinclient.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.datadelivery.feature" />
|
value="com.raytheon.uf.viz.datadelivery.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.useradmin.feature" />
|
value="com.raytheon.uf.viz.useradmin.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.kml.export.feature" />
|
value="com.raytheon.uf.viz.kml.export.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.npp.feature" />
|
value="com.raytheon.uf.viz.npp.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<antcall target="p2.build.repo">
|
<antcall target="p2.build.repo">
|
||||||
<param name="feature"
|
<param name="feature"
|
||||||
value="com.raytheon.uf.viz.collaboration.feature" />
|
value="com.raytheon.uf.viz.collaboration.feature" />
|
||||||
</antcall>
|
</antcall>
|
||||||
<!--
|
<antcall target="p2.build.repo">
|
||||||
<antcall target="p2.build.repo">
|
<param name="feature"
|
||||||
<param name="feature"
|
value="com.raytheon.uf.viz.gisdatastore.feature" />
|
||||||
value="com.raytheon.uf.viz.gisdatastore.feature" />
|
</antcall>
|
||||||
</antcall>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<antcall target="cleanup.features" />
|
<antcall target="cleanup.features" />
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
28
cave/com.raytheon.uf.viz.gisdatastore.directory/.project
Normal file
28
cave/com.raytheon.uf.viz.gisdatastore.directory/.project
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.raytheon.uf.viz.gisdatastore.directory</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.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,8 @@
|
||||||
|
#Mon Nov 05 11:53:02 CST 2012
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -0,0 +1,21 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: Shapefile support for DataStoreResource
|
||||||
|
Bundle-SymbolicName: com.raytheon.uf.viz.gisdatastore.directory;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0.qualifier
|
||||||
|
Bundle-Activator: com.raytheon.uf.viz.gisdatastore.directory.Activator
|
||||||
|
Bundle-Vendor: RAYTHEON
|
||||||
|
Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.viz.ui
|
||||||
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime,
|
||||||
|
org.geotools,
|
||||||
|
com.raytheon.uf.common.status,
|
||||||
|
com.raytheon.uf.viz.gisdatastore,
|
||||||
|
com.raytheon.uf.viz.core,
|
||||||
|
com.raytheon.viz.core,
|
||||||
|
com.raytheon.viz.ui,
|
||||||
|
com.raytheon.uf.common.util,
|
||||||
|
com.raytheon.uf.viz.core.maps;bundle-version="1.0.0"
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
|
Bundle-ActivationPolicy: lazy
|
||||||
|
Export-Package: com.raytheon.uf.viz.gisdatastore.directory.rsc
|
|
@ -0,0 +1 @@
|
||||||
|
com.raytheon.uf.viz.gisdatastore.directory.rsc.DirectoryDataStoreResourceData
|
|
@ -0,0 +1,5 @@
|
||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
.,\
|
||||||
|
plugin.xml
|
12
cave/com.raytheon.uf.viz.gisdatastore.directory/plugin.xml
Normal file
12
cave/com.raytheon.uf.viz.gisdatastore.directory/plugin.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
<extension
|
||||||
|
point="com.raytheon.uf.viz.gisdatastore.gisDataStore">
|
||||||
|
<gisDataStore
|
||||||
|
class="com.raytheon.uf.viz.gisdatastore.directory.DirectoryDataStorePlugin"
|
||||||
|
name="GIS File">
|
||||||
|
</gisDataStore>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
</plugin>
|
|
@ -0,0 +1,122 @@
|
||||||
|
/**
|
||||||
|
* 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.directory;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||||
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||||
|
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.localization.HierarchicalPreferenceStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The activator class controls the plug-in life cycle
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 12, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Activator extends AbstractUIPlugin {
|
||||||
|
public static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(Activator.class);
|
||||||
|
|
||||||
|
// pref store
|
||||||
|
private HierarchicalPreferenceStore prefs;
|
||||||
|
|
||||||
|
// The plug-in ID
|
||||||
|
public static final String PLUGIN_ID = "com.raytheon.uf.viz.gisdatastore.directory"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// The shared instance
|
||||||
|
private static Activator plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor
|
||||||
|
*/
|
||||||
|
public Activator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPersistentPreferenceStore getPreferenceStore() {
|
||||||
|
try {
|
||||||
|
if (prefs == null) {
|
||||||
|
prefs = new HierarchicalPreferenceStore(this);
|
||||||
|
}
|
||||||
|
} catch (LocalizationException e) {
|
||||||
|
statusHandler.handle(
|
||||||
|
Priority.PROBLEM,
|
||||||
|
"Error reading preference store: "
|
||||||
|
+ e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
/**
|
||||||
|
* 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.directory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.geotools.data.DataStore;
|
||||||
|
import org.geotools.data.directory.DirectoryDataStoreFactory;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.IGisDataStorePlugin;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.directory.rsc.DirectoryDataStoreResourceData;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directory GisDataStorePlugin implementation
|
||||||
|
*
|
||||||
|
* Will load data from any recognized GIS feature file types in a directory
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 6, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DirectoryDataStorePlugin implements IGisDataStorePlugin {
|
||||||
|
private static int DIR_LIST_SIZE = 10;
|
||||||
|
|
||||||
|
private Map<String, Object> connectionParameters;
|
||||||
|
|
||||||
|
private Combo dirCombo;
|
||||||
|
|
||||||
|
private Button browseButton;
|
||||||
|
|
||||||
|
private List<String> dirList;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createControls(final Composite comp) {
|
||||||
|
GridLayout layout = (GridLayout) comp.getLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
|
layout.makeColumnsEqualWidth = false;
|
||||||
|
|
||||||
|
Label label = new Label(comp, SWT.NONE);
|
||||||
|
label.setText("Directory:");
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
|
label.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
browseButton = new Button(comp, SWT.PUSH);
|
||||||
|
layoutData = new GridData(SWT.END, SWT.CENTER, false, false);
|
||||||
|
browseButton.setLayoutData(layoutData);
|
||||||
|
browseButton.setText("Browse...");
|
||||||
|
browseButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
DirectoryDialog dlg = new DirectoryDialog(comp.getShell());
|
||||||
|
dlg.setFilterPath(dirCombo.getText());
|
||||||
|
String dir = dlg.open();
|
||||||
|
if (dir != null) {
|
||||||
|
dirCombo.setText(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dirCombo = new Combo(comp, SWT.DROP_DOWN);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
|
layoutData.widthHint = 300;
|
||||||
|
layoutData.horizontalSpan = 2;
|
||||||
|
dirCombo.setLayoutData(layoutData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getConnectionParameters() {
|
||||||
|
return this.connectionParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFromPreferences() {
|
||||||
|
dirList = new ArrayList<String>(DIR_LIST_SIZE);
|
||||||
|
IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
|
||||||
|
for (int i = 0; i < DIR_LIST_SIZE; i++) {
|
||||||
|
String url = prefs.getString("DirectoryImportPath" + i);
|
||||||
|
dirList.add(url);
|
||||||
|
}
|
||||||
|
dirCombo.setItems(dirList.toArray(new String[dirList.size()]));
|
||||||
|
dirCombo.setText(dirList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveToPreferences() {
|
||||||
|
IPersistentPreferenceStore prefs = Activator.getDefault()
|
||||||
|
.getPreferenceStore();
|
||||||
|
String dir = dirCombo.getText();
|
||||||
|
if (dirList.contains(dir)) {
|
||||||
|
// dir already in list remove it
|
||||||
|
dirList.remove(dir);
|
||||||
|
} else if (dirList.size() == DIR_LIST_SIZE) {
|
||||||
|
// list at max size remove last entry
|
||||||
|
dirList.remove(DIR_LIST_SIZE - 1);
|
||||||
|
}
|
||||||
|
// put dir at front of list
|
||||||
|
dirList.add(0, dir);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (String s : dirList) {
|
||||||
|
prefs.setValue("DirectoryImportPath" + i++, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
prefs.save();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Activator.statusHandler.error(
|
||||||
|
"Unable to save recently used directories", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStore connectToDataStore() throws IOException {
|
||||||
|
String dir = dirCombo.getText();
|
||||||
|
URL url = new File(dir).toURI().toURL();
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
|
params.put(DirectoryDataStoreFactory.URLP.key, url);
|
||||||
|
|
||||||
|
DataStoreResourceData rd = constructResourceData(null, params);
|
||||||
|
DataStore dataStore = rd.getDataStore();
|
||||||
|
|
||||||
|
this.connectionParameters = params;
|
||||||
|
|
||||||
|
return dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataStoreResourceData constructResourceData(String typeName,
|
||||||
|
Map<String, Object> connectionParameters) {
|
||||||
|
DirectoryDataStoreResourceData rd = new DirectoryDataStoreResourceData(
|
||||||
|
typeName, connectionParameters);
|
||||||
|
return rd;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
* 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.directory.rsc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
|
||||||
|
import org.geotools.data.DataStore;
|
||||||
|
import org.geotools.data.directory.DirectoryDataStoreFactory;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataStore resource data class for GIS feature files
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 31, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
|
public class DirectoryDataStoreResourceData extends DataStoreResourceData {
|
||||||
|
public DirectoryDataStoreResourceData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirectoryDataStoreResourceData(String typeName,
|
||||||
|
Map<String, Object> connectionParameters) {
|
||||||
|
super(typeName, connectionParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DataStore constructDataStore() throws IOException {
|
||||||
|
DirectoryDataStoreFactory factory = new DirectoryDataStoreFactory();
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>();
|
||||||
|
for (Entry<String, Object> entry : getConnectionParameters().entrySet()) {
|
||||||
|
if (entry.getValue() instanceof Serializable) {
|
||||||
|
params.put(entry.getKey(), (Serializable) entry.getValue());
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(entry.getKey() + "("
|
||||||
|
+ entry.getValue().getClass().getName()
|
||||||
|
+ ") not an instance of java.io.Serializable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DataStore dataStore = factory.createDataStore(params);
|
||||||
|
return dataStore;
|
||||||
|
}
|
||||||
|
}
|
17
cave/com.raytheon.uf.viz.gisdatastore.feature/.project
Normal file
17
cave/com.raytheon.uf.viz.gisdatastore.feature/.project
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.raytheon.uf.viz.gisdatastore.feature</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1 @@
|
||||||
|
bin.includes = feature.xml
|
41
cave/com.raytheon.uf.viz.gisdatastore.feature/feature.xml
Normal file
41
cave/com.raytheon.uf.viz.gisdatastore.feature/feature.xml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feature
|
||||||
|
id="com.raytheon.uf.viz.gisdatastore.feature"
|
||||||
|
label="GIS Datastore Feature"
|
||||||
|
version="1.0.0.qualifier"
|
||||||
|
provider-name="RAYTHEON">
|
||||||
|
|
||||||
|
<description url="http://www.example.com/description">
|
||||||
|
[Enter Feature Description here.]
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<copyright url="http://www.example.com/copyright">
|
||||||
|
[Enter Copyright Description here.]
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<license url="http://www.example.com/license">
|
||||||
|
[Enter License Description here.]
|
||||||
|
</license>
|
||||||
|
|
||||||
|
<requires>
|
||||||
|
<import feature="com.raytheon.uf.viz.cots.feature" version="1.0.0.qualifier"/>
|
||||||
|
<import feature="com.raytheon.uf.viz.core.feature" version="1.0.0.qualifier"/>
|
||||||
|
<import feature="com.raytheon.uf.viz.eclipse.feature" version="1.0.0.qualifier"/>
|
||||||
|
<import feature="com.raytheon.uf.viz.common.core.feature" version="1.0.0.qualifier"/>
|
||||||
|
</requires>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="com.raytheon.uf.viz.gisdatastore"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"
|
||||||
|
unpack="false"/>
|
||||||
|
|
||||||
|
<plugin
|
||||||
|
id="com.raytheon.uf.viz.gisdatastore.directory"
|
||||||
|
download-size="0"
|
||||||
|
install-size="0"
|
||||||
|
version="0.0.0"
|
||||||
|
unpack="false"/>
|
||||||
|
|
||||||
|
</feature>
|
7
cave/com.raytheon.uf.viz.gisdatastore/.classpath
Normal file
7
cave/com.raytheon.uf.viz.gisdatastore/.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/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
28
cave/com.raytheon.uf.viz.gisdatastore/.project
Normal file
28
cave/com.raytheon.uf.viz.gisdatastore/.project
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.raytheon.uf.viz.gisdatastore</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.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,8 @@
|
||||||
|
#Mon Nov 05 10:48:54 CST 2012
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.6
|
24
cave/com.raytheon.uf.viz.gisdatastore/META-INF/MANIFEST.MF
Normal file
24
cave/com.raytheon.uf.viz.gisdatastore/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: Gisdatastore
|
||||||
|
Bundle-SymbolicName: com.raytheon.uf.viz.gisdatastore;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0.qualifier
|
||||||
|
Bundle-Activator: com.raytheon.uf.viz.gisdatastore.Activator
|
||||||
|
Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.viz.ui
|
||||||
|
Bundle-Vendor: RAYTHEON
|
||||||
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime,
|
||||||
|
org.geotools,
|
||||||
|
com.raytheon.uf.common.serialization,
|
||||||
|
com.raytheon.uf.common.status,
|
||||||
|
com.raytheon.uf.common.geospatial,
|
||||||
|
com.raytheon.uf.viz.core,
|
||||||
|
com.raytheon.uf.viz.core.maps;bundle-version="1.0.0",
|
||||||
|
com.raytheon.viz.core,
|
||||||
|
com.raytheon.viz.ui
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
|
Bundle-ActivationPolicy: lazy
|
||||||
|
Export-Package: com.raytheon.uf.viz.gisdatastore,
|
||||||
|
com.raytheon.uf.viz.gisdatastore.rsc,
|
||||||
|
com.raytheon.uf.viz.gisdatastore.ui
|
||||||
|
Import-Package: com.raytheon.uf.common.dataplugin.gfe.type
|
5
cave/com.raytheon.uf.viz.gisdatastore/build.properties
Normal file
5
cave/com.raytheon.uf.viz.gisdatastore/build.properties
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
.,\
|
||||||
|
plugin.xml
|
7
cave/com.raytheon.uf.viz.gisdatastore/config.xml
Normal file
7
cave/com.raytheon.uf.viz.gisdatastore/config.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<configuration>
|
||||||
|
<HighlightColor>hot pink</HighlightColor>
|
||||||
|
<HighlightStyle>SOLID</HighlightStyle>
|
||||||
|
<HighlightWidth>2</HighlightWidth>
|
||||||
|
<ProductOpacity>0.35</ProductOpacity>
|
||||||
|
</configuration>
|
74
cave/com.raytheon.uf.viz.gisdatastore/plugin.xml
Normal file
74
cave/com.raytheon.uf.viz.gisdatastore/plugin.xml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
<extension-point id="gisDataStore" name="gisDataStore" schema="schema/gisDataStore.exsd"/>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.commands">
|
||||||
|
<command
|
||||||
|
id="com.raytheon.uf.viz.gisdatastore.actions.ImportGis"
|
||||||
|
name="Import GIS">
|
||||||
|
</command>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.handlers">
|
||||||
|
<handler
|
||||||
|
class="com.raytheon.uf.viz.gisdatastore.actions.ImportGisAction"
|
||||||
|
commandId="com.raytheon.uf.viz.gisdatastore.actions.ImportGis">
|
||||||
|
</handler>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.menus">
|
||||||
|
<menuContribution
|
||||||
|
allPopups="false"
|
||||||
|
locationURI="menu:import">
|
||||||
|
<command
|
||||||
|
commandId="com.raytheon.uf.viz.gisdatastore.actions.ImportGis"
|
||||||
|
label="GIS Data..."
|
||||||
|
style="push">
|
||||||
|
</command>
|
||||||
|
</menuContribution>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="com.raytheon.uf.viz.core.resource">
|
||||||
|
<resource
|
||||||
|
class="com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource"
|
||||||
|
name="dataStoreResource"
|
||||||
|
renderingOrderId="MAP_OUTLINE">
|
||||||
|
</resource>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="com.raytheon.viz.ui.contextualMenu">
|
||||||
|
<contextualMenu
|
||||||
|
actionClass="com.raytheon.uf.viz.gisdatastore.actions.DisplayAttributes"
|
||||||
|
capabilityInterface="com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource"
|
||||||
|
name="com.raytheon.uf.viz.gisdatastore.actions.DisplayAttributes"
|
||||||
|
sortID="410">
|
||||||
|
</contextualMenu>
|
||||||
|
<contextualMenu
|
||||||
|
actionClass="com.raytheon.uf.viz.gisdatastore.actions.RenameAction"
|
||||||
|
capabilityInterface="com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource"
|
||||||
|
name="com.raytheon.uf.viz.gisdatastore.actions.RenameAction"
|
||||||
|
sortID="430">
|
||||||
|
</contextualMenu>
|
||||||
|
<contextualMenu
|
||||||
|
actionClass="com.raytheon.uf.viz.gisdatastore.actions.CropAction"
|
||||||
|
capabilityInterface="com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource"
|
||||||
|
name="com.raytheon.uf.viz.gisdatastore.actions.CropAction"
|
||||||
|
sortID="440">
|
||||||
|
</contextualMenu>
|
||||||
|
<contextualMenu
|
||||||
|
actionClass="com.raytheon.uf.viz.gisdatastore.actions.SetSampleAttributeAction"
|
||||||
|
capabilityInterface="com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource"
|
||||||
|
name="com.raytheon.uf.viz.gisdatastore.actions.SetSampleAttributeAction"
|
||||||
|
sortID="450">
|
||||||
|
</contextualMenu>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.preferencePages">
|
||||||
|
<page
|
||||||
|
class="com.raytheon.uf.viz.gisdatastore.ui.GisViewerPreferencePage"
|
||||||
|
id="com.raytheon.uf.viz.gisdatastore.ui.GisViewerPreferencePage"
|
||||||
|
name="GIS Viewer">
|
||||||
|
</page>
|
||||||
|
</extension>
|
||||||
|
</plugin>
|
109
cave/com.raytheon.uf.viz.gisdatastore/schema/gisDataStore.exsd
Normal file
109
cave/com.raytheon.uf.viz.gisdatastore/schema/gisDataStore.exsd
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Schema file written by PDE -->
|
||||||
|
<schema targetNamespace="com.raytheon.uf.viz.gisdatastore" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.schema plugin="com.raytheon.uf.viz.gisdatastore" id="gisDataStore" name="gisDataStore"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
This extension point is used to identify classes that define new GIS DataStore implementations so that they can be found and registered at startup.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.element />
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<element ref="gisDataStore"/>
|
||||||
|
</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="gisDataStore">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="name" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.attribute kind="java" basedOn=":com.raytheon.uf.viz.gisdatastore.IGisDataStorePlugin"/>
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="since"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
13.2.1
|
||||||
|
</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,123 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||||
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||||
|
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.localization.HierarchicalPreferenceStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The activator class controls the plug-in life cycle
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 12, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class Activator extends AbstractUIPlugin {
|
||||||
|
public static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(Activator.class);
|
||||||
|
|
||||||
|
// pref store
|
||||||
|
private HierarchicalPreferenceStore prefs;
|
||||||
|
|
||||||
|
// The plug-in ID
|
||||||
|
public static final String PLUGIN_ID = "com.raytheon.uf.viz.gisdatastore"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// The shared instance
|
||||||
|
private static Activator plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor
|
||||||
|
*/
|
||||||
|
public Activator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPersistentPreferenceStore getPreferenceStore() {
|
||||||
|
try {
|
||||||
|
if (prefs == null) {
|
||||||
|
prefs = new HierarchicalPreferenceStore(this);
|
||||||
|
}
|
||||||
|
} catch (LocalizationException e) {
|
||||||
|
statusHandler.handle(
|
||||||
|
Priority.PROBLEM,
|
||||||
|
"Error reading preference store: "
|
||||||
|
+ e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.raytheon.uf.viz.gisdatastore;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.geotools.data.DataStore;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData;
|
||||||
|
|
||||||
|
public interface IGisDataStorePlugin {
|
||||||
|
|
||||||
|
public void createControls(final Composite comp);
|
||||||
|
|
||||||
|
public Map<String, Object> getConnectionParameters();
|
||||||
|
|
||||||
|
public void loadFromPreferences();
|
||||||
|
|
||||||
|
public void saveToPreferences();
|
||||||
|
|
||||||
|
public DataStore connectToDataStore() throws IOException;
|
||||||
|
|
||||||
|
public DataStoreResourceData constructResourceData(String typeName,
|
||||||
|
Map<String, Object> connectionParameters);
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
* 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.actions;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.PixelExtent;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource.IRubberBandSelectionListener;
|
||||||
|
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crop GIS resource action
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 29, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CropAction extends AbstractRightClickAction {
|
||||||
|
public CropAction() {
|
||||||
|
super(AS_PUSH_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
final DataStoreResource rsc = (DataStoreResource) this
|
||||||
|
.getSelectedRsc();
|
||||||
|
if (rsc.isCropped()) {
|
||||||
|
return "Uncrop Shape";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Crop Shape";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
final DataStoreResource rsc = (DataStoreResource) this
|
||||||
|
.getSelectedRsc();
|
||||||
|
if (rsc.isCropped()) {
|
||||||
|
rsc.uncrop();
|
||||||
|
} else {
|
||||||
|
rsc.addRubberBandSelectionListener(new IRubberBandSelectionListener() {
|
||||||
|
@Override
|
||||||
|
public void rubberBandSelectionChanged(PixelExtent extent) {
|
||||||
|
rsc.removeRubberBandSelectionListener(this);
|
||||||
|
rsc.crop(extent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
rsc.activateRubberBandBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* 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.actions;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.ui.AttributeViewer;
|
||||||
|
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show All Records action
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 29, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DisplayAttributes extends AbstractRightClickAction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DisplayAttributes() {
|
||||||
|
super("Display Attributes", AS_PUSH_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
DataStoreResource rsc = (DataStoreResource) this.getSelectedRsc();
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
|
.getShell();
|
||||||
|
AttributeViewer.openDialog(shell, rsc);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/**
|
||||||
|
* 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.actions;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||||
|
import com.raytheon.uf.viz.core.maps.actions.AbstractMapHandler;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.ui.GisDataStoreParametersDialog;
|
||||||
|
import com.raytheon.viz.ui.EditorUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for Import GIS command
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 6, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ImportGisAction extends AbstractMapHandler {
|
||||||
|
|
||||||
|
private GisDataStoreParametersDialog dlg;
|
||||||
|
|
||||||
|
private IDescriptor descriptor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
|
||||||
|
* ExecutionEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
if (dlg == null || dlg.getShell() == null) {
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
|
.getShell();
|
||||||
|
|
||||||
|
descriptor = EditorUtil.getActiveVizContainer()
|
||||||
|
.getActiveDisplayPane().getRenderableDisplay()
|
||||||
|
.getDescriptor();
|
||||||
|
|
||||||
|
dlg = new GisDataStoreParametersDialog(shell, descriptor);
|
||||||
|
dlg.setBlockOnOpen(false);
|
||||||
|
}
|
||||||
|
dlg.open();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/**
|
||||||
|
* 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.actions;
|
||||||
|
|
||||||
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename Action
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 29, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RenameAction extends AbstractRightClickAction {
|
||||||
|
|
||||||
|
public RenameAction() {
|
||||||
|
super("Rename", AS_PUSH_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
DataStoreResource rsc = (DataStoreResource) this.getSelectedRsc();
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
|
.getShell();
|
||||||
|
|
||||||
|
InputDialog dlg = new InputDialog(shell, "Rename",
|
||||||
|
"Enter new name", rsc.getName(), null);
|
||||||
|
if (dlg.open() == Window.OK) {
|
||||||
|
rsc.setName(dlg.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/**
|
||||||
|
* 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.actions;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.ui.SelectAttributeDialog;
|
||||||
|
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Add Description
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 13, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SetSampleAttributeAction extends AbstractRightClickAction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SetSampleAttributeAction() {
|
||||||
|
super("Select Sample Attribute...", AS_PUSH_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHidden() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
final DataStoreResource rsc = (DataStoreResource) this
|
||||||
|
.getSelectedRsc();
|
||||||
|
return rsc.getProperties().isMapLayer();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (this.getSelectedRsc() instanceof DataStoreResource) {
|
||||||
|
final DataStoreResource rsc = (DataStoreResource) this
|
||||||
|
.getSelectedRsc();
|
||||||
|
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
|
.getShell();
|
||||||
|
SelectAttributeDialog dlg = new SelectAttributeDialog(shell, rsc);
|
||||||
|
dlg.setBlockOnOpen(false);
|
||||||
|
dlg.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,193 @@
|
||||||
|
/**
|
||||||
|
* 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.rsc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
|
||||||
|
import org.geotools.data.DataStore;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||||
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for GeoTools DataStore base resource data classes
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 31, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
|
public abstract class DataStoreResourceData extends AbstractResourceData {
|
||||||
|
private DataStore dataStore;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
@XmlJavaTypeAdapter(XmlGenericMapAdapter.class)
|
||||||
|
private Map<String, Object> connectionParameters;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
private String mapName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DataStoreResourceData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataStoreResourceData(String typeName,
|
||||||
|
Map<String, Object> connectionParameters) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.mapName = typeName;
|
||||||
|
this.connectionParameters = connectionParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon
|
||||||
|
* .uf.viz.core.rsc.LoadProperties,
|
||||||
|
* com.raytheon.uf.viz.core.drawables.IDescriptor)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DataStoreResource construct(LoadProperties loadProperties,
|
||||||
|
IDescriptor descriptor) throws VizException {
|
||||||
|
|
||||||
|
DataStoreResource rsc;
|
||||||
|
try {
|
||||||
|
rsc = new DataStoreResource(this, loadProperties);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new VizException("Error constructing GIS resource", e);
|
||||||
|
}
|
||||||
|
return rsc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void update(Object updateData) {
|
||||||
|
// Default is to do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataStore getDataStore() throws IOException {
|
||||||
|
if (dataStore == null) {
|
||||||
|
dataStore = constructDataStore();
|
||||||
|
}
|
||||||
|
return dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract DataStore constructDataStore() throws IOException;
|
||||||
|
|
||||||
|
public void disposeDataStore() {
|
||||||
|
if (dataStore != null) {
|
||||||
|
dataStore.dispose();
|
||||||
|
dataStore = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof DataStoreResourceData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DataStoreResourceData other = (DataStoreResourceData) obj;
|
||||||
|
if (connectionParameters == null) {
|
||||||
|
if (other.connectionParameters != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!connectionParameters.equals(other.connectionParameters)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mapName == null) {
|
||||||
|
if (other.mapName != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!mapName.equals(other.mapName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (typeName == null) {
|
||||||
|
if (other.typeName != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!typeName.equals(other.typeName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getConnectionParameters() {
|
||||||
|
return connectionParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectionParameters(Map<String, Object> connectionParameters) {
|
||||||
|
this.connectionParameters = connectionParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeName(String typeName) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
if (this.mapName == null) {
|
||||||
|
this.mapName = typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getMapName() {
|
||||||
|
return mapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMapName(String mapName) {
|
||||||
|
this.mapName = mapName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,473 @@
|
||||||
|
package com.raytheon.uf.viz.gisdatastore.rsc;
|
||||||
|
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
|
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.graphics.RGB;
|
||||||
|
import org.geotools.data.DefaultQuery;
|
||||||
|
import org.geotools.data.FeatureSource;
|
||||||
|
import org.geotools.factory.CommonFactoryFinder;
|
||||||
|
import org.geotools.factory.GeoTools;
|
||||||
|
import org.geotools.feature.FeatureCollection;
|
||||||
|
import org.opengis.feature.simple.SimpleFeature;
|
||||||
|
import org.opengis.feature.simple.SimpleFeatureType;
|
||||||
|
import org.opengis.filter.Filter;
|
||||||
|
import org.opengis.filter.FilterFactory2;
|
||||||
|
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
import com.raytheon.uf.viz.core.DrawableString;
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||||
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.Activator;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource.DisplayAttributes;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource.LabelNode;
|
||||||
|
import com.raytheon.viz.core.rsc.jts.JTSCompiler;
|
||||||
|
import com.raytheon.viz.core.rsc.jts.JTSCompiler.PointStyle;
|
||||||
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||||
|
import com.vividsolutions.jts.geom.Point;
|
||||||
|
|
||||||
|
class ReloadJob extends Job {
|
||||||
|
|
||||||
|
private static final int QUEUE_LIMIT = 1;
|
||||||
|
|
||||||
|
private static Random rand = new Random(System.currentTimeMillis());
|
||||||
|
|
||||||
|
private static int requestCounter = 0;
|
||||||
|
|
||||||
|
public class Request {
|
||||||
|
int number;
|
||||||
|
|
||||||
|
IGraphicsTarget target;
|
||||||
|
|
||||||
|
DataStoreResource rsc;
|
||||||
|
|
||||||
|
String geomField;
|
||||||
|
|
||||||
|
String labelField;
|
||||||
|
|
||||||
|
String shadingField;
|
||||||
|
|
||||||
|
Geometry boundingGeom;
|
||||||
|
|
||||||
|
Map<Object, RGB> colorMap;
|
||||||
|
|
||||||
|
boolean isProduct;
|
||||||
|
|
||||||
|
boolean highlightsOnly;
|
||||||
|
|
||||||
|
Request(IGraphicsTarget target, DataStoreResource rsc,
|
||||||
|
Geometry boundingGeom, String geomField, String labelField,
|
||||||
|
String shadingField, Map<Object, RGB> colorMap,
|
||||||
|
boolean isProduct, boolean highlightsOnly) {
|
||||||
|
this.number = requestCounter++;
|
||||||
|
this.target = target;
|
||||||
|
this.rsc = rsc;
|
||||||
|
this.boundingGeom = boundingGeom;
|
||||||
|
this.geomField = geomField;
|
||||||
|
this.labelField = labelField;
|
||||||
|
this.shadingField = shadingField;
|
||||||
|
this.colorMap = colorMap;
|
||||||
|
this.isProduct = isProduct;
|
||||||
|
this.highlightsOnly = highlightsOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGB getColor(Object key) {
|
||||||
|
if (colorMap == null) {
|
||||||
|
colorMap = new HashMap<Object, RGB>();
|
||||||
|
}
|
||||||
|
RGB color = colorMap.get(key);
|
||||||
|
if (color == null) {
|
||||||
|
color = new RGB(rand.nextInt(206) + 50, rand.nextInt(206) + 50,
|
||||||
|
rand.nextInt(206) + 50);
|
||||||
|
colorMap.put(key, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Result {
|
||||||
|
public IWireframeShape outlineShape;
|
||||||
|
|
||||||
|
public List<LabelNode> labels;
|
||||||
|
|
||||||
|
public IShadedShape shadedShape;
|
||||||
|
|
||||||
|
public Map<Object, RGB> colorMap;
|
||||||
|
|
||||||
|
public boolean failed;
|
||||||
|
|
||||||
|
public Throwable cause;
|
||||||
|
|
||||||
|
public IWireframeShape highlightShape;
|
||||||
|
|
||||||
|
public boolean highlightsOnly;
|
||||||
|
|
||||||
|
private Result() {
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
if (outlineShape != null) {
|
||||||
|
outlineShape.dispose();
|
||||||
|
outlineShape = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shadedShape != null) {
|
||||||
|
shadedShape.dispose();
|
||||||
|
shadedShape = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (highlightShape != null) {
|
||||||
|
highlightShape.dispose();
|
||||||
|
highlightShape = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Request pendingRequest = null;
|
||||||
|
|
||||||
|
private ArrayBlockingQueue<Result> resultQueue = new ArrayBlockingQueue<Result>(
|
||||||
|
QUEUE_LIMIT);
|
||||||
|
|
||||||
|
public ReloadJob() {
|
||||||
|
super("Loading ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void request(IGraphicsTarget target, DataStoreResource rsc,
|
||||||
|
Geometry boundingGeom, String geomField, String labelField,
|
||||||
|
String shadingField, Map<Object, RGB> colorMap, boolean isProduct,
|
||||||
|
boolean highlightsOnly) {
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
pendingRequest = new Request(target, rsc, boundingGeom, geomField,
|
||||||
|
labelField, shadingField, colorMap, isProduct,
|
||||||
|
highlightsOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result getLatestResult() {
|
||||||
|
return resultQueue.poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
|
||||||
|
* IProgressMonitor)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
Request req = null;
|
||||||
|
synchronized (this) {
|
||||||
|
req = pendingRequest;
|
||||||
|
pendingRequest = null;
|
||||||
|
}
|
||||||
|
while (req != null) {
|
||||||
|
System.out.println("Processing request: " + req.number);
|
||||||
|
|
||||||
|
Result result = new Result();
|
||||||
|
FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = null;
|
||||||
|
Iterator<SimpleFeature> featureIterator = null;
|
||||||
|
try {
|
||||||
|
if (pendingRequest != null) {
|
||||||
|
System.out.println("Canceling request: " + req.number);
|
||||||
|
result.dispose();
|
||||||
|
result = null;
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> fields = new ArrayList<String>();
|
||||||
|
fields.add(req.geomField);
|
||||||
|
if (req.labelField != null && !fields.contains(req.labelField)) {
|
||||||
|
fields.add(req.labelField);
|
||||||
|
}
|
||||||
|
if (req.shadingField != null
|
||||||
|
&& !fields.contains(req.shadingField)) {
|
||||||
|
fields.add(req.shadingField);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWireframeShape newOutlineShape = req.target
|
||||||
|
.createWireframeShape(false, req.rsc.getDescriptor());
|
||||||
|
|
||||||
|
IWireframeShape newHighlightShape = req.target
|
||||||
|
.createWireframeShape(false, req.rsc.getDescriptor());
|
||||||
|
|
||||||
|
List<LabelNode> newLabels = new ArrayList<LabelNode>();
|
||||||
|
|
||||||
|
IShadedShape newShadedShape = null;
|
||||||
|
if (req.isProduct || req.shadingField != null) {
|
||||||
|
newShadedShape = req.target.createShadedShape(false,
|
||||||
|
req.rsc.getDescriptor().getGridGeometry(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: pass the crs on to JTSCompiler to indicate
|
||||||
|
// projection of shapefile data.
|
||||||
|
SimpleFeatureType schema = req.rsc.getSchema();
|
||||||
|
CoordinateReferenceSystem crs = schema.getGeometryDescriptor()
|
||||||
|
.getCoordinateReferenceSystem();
|
||||||
|
|
||||||
|
JTSCompiler jtsCompiler = new JTSCompiler(newShadedShape,
|
||||||
|
newOutlineShape, req.rsc.getDescriptor(),
|
||||||
|
PointStyle.CROSS);
|
||||||
|
|
||||||
|
JTSCompiler highlightCompiler = new JTSCompiler(null,
|
||||||
|
newHighlightShape, req.rsc.getDescriptor(),
|
||||||
|
PointStyle.CROSS);
|
||||||
|
|
||||||
|
String shapeField = schema.getGeometryDescriptor()
|
||||||
|
.getLocalName();
|
||||||
|
|
||||||
|
DefaultQuery query = new DefaultQuery();
|
||||||
|
|
||||||
|
String typeName = req.rsc.getTypeName();
|
||||||
|
query.setTypeName(typeName);
|
||||||
|
query.setPropertyNames(fields);
|
||||||
|
|
||||||
|
if (req.boundingGeom != null) {
|
||||||
|
FilterFactory2 ff = CommonFactoryFinder
|
||||||
|
.getFilterFactory2(GeoTools.getDefaultHints());
|
||||||
|
|
||||||
|
List<Geometry> geomList = new ArrayList<Geometry>();
|
||||||
|
flattenGeometry(req.boundingGeom, geomList);
|
||||||
|
|
||||||
|
List<Filter> filterList = new ArrayList<Filter>(
|
||||||
|
geomList.size());
|
||||||
|
for (Geometry g : geomList) {
|
||||||
|
Filter filter = ff.intersects(ff.property(shapeField),
|
||||||
|
ff.literal(g));
|
||||||
|
filterList.add(filter);
|
||||||
|
}
|
||||||
|
query.setFilter(ff.or(filterList));
|
||||||
|
}
|
||||||
|
|
||||||
|
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = req.rsc
|
||||||
|
.getDataStore().getFeatureSource(typeName);
|
||||||
|
|
||||||
|
featureCollection = featureSource.getFeatures(query);
|
||||||
|
featureIterator = featureCollection.iterator();
|
||||||
|
|
||||||
|
// TODO: do we need to implement the GeometryCache/gidMap
|
||||||
|
// stuff like in DbMapResource?
|
||||||
|
|
||||||
|
List<Geometry> resultingGeoms = new ArrayList<Geometry>();
|
||||||
|
List<Geometry> highlightGeoms = new ArrayList<Geometry>();
|
||||||
|
int numPoints = 0;
|
||||||
|
while (featureIterator.hasNext()) {
|
||||||
|
if (pendingRequest != null) {
|
||||||
|
System.out.println("Canceling request: " + req.number);
|
||||||
|
result.dispose();
|
||||||
|
result = null;
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleFeature f = featureIterator.next();
|
||||||
|
String id = f.getID();
|
||||||
|
DisplayAttributes da = req.rsc.getDisplayAttributes(id);
|
||||||
|
if (!da.isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Geometry g = (Geometry) f.getAttribute(req.geomField);
|
||||||
|
if (da.isHighlighted()) {
|
||||||
|
highlightGeoms.add((Geometry) g.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.highlightsOnly) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object labelAttr = null;
|
||||||
|
Object shadingAttr = null;
|
||||||
|
for (String name : fields) {
|
||||||
|
if (name.equals(req.labelField)) {
|
||||||
|
labelAttr = f.getAttribute(name);
|
||||||
|
}
|
||||||
|
if (name.equals(req.shadingField)) {
|
||||||
|
shadingAttr = f.getAttribute(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (labelAttr != null && g != null) {
|
||||||
|
String label;
|
||||||
|
if (labelAttr instanceof BigDecimal) {
|
||||||
|
label = Double.toString(((Number) labelAttr)
|
||||||
|
.doubleValue());
|
||||||
|
} else {
|
||||||
|
label = labelAttr.toString();
|
||||||
|
}
|
||||||
|
int numGeometries = g.getNumGeometries();
|
||||||
|
List<Geometry> gList = new ArrayList<Geometry>(
|
||||||
|
numGeometries);
|
||||||
|
for (int polyNum = 0; polyNum < numGeometries; polyNum++) {
|
||||||
|
Geometry poly = g.getGeometryN(polyNum);
|
||||||
|
gList.add(poly);
|
||||||
|
}
|
||||||
|
// Sort polygons in g so biggest comes first.
|
||||||
|
Collections.sort(gList, new Comparator<Geometry>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Geometry g1, Geometry g2) {
|
||||||
|
return (int) Math
|
||||||
|
.signum(g2.getEnvelope().getArea()
|
||||||
|
- g1.getEnvelope().getArea());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (Geometry poly : gList) {
|
||||||
|
Point point = poly.getInteriorPoint();
|
||||||
|
if (point.getCoordinate() != null) {
|
||||||
|
double[] location = req.rsc
|
||||||
|
.getDescriptor()
|
||||||
|
.worldToPixel(
|
||||||
|
new double[] {
|
||||||
|
point.getCoordinate().x,
|
||||||
|
point.getCoordinate().y });
|
||||||
|
|
||||||
|
DrawableString ds = new DrawableString(label,
|
||||||
|
null);
|
||||||
|
ds.font = req.rsc.font;
|
||||||
|
Rectangle2D rect = req.target
|
||||||
|
.getStringsBounds(ds);
|
||||||
|
|
||||||
|
LabelNode node = new LabelNode(label, location,
|
||||||
|
rect);
|
||||||
|
newLabels.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g != null) {
|
||||||
|
numPoints += g.getNumPoints();
|
||||||
|
resultingGeoms.add(g);
|
||||||
|
if (req.shadingField != null) {
|
||||||
|
g.setUserData(shadingAttr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newOutlineShape.allocate(numPoints);
|
||||||
|
RGB outlineColor = req.rsc.getCapability(
|
||||||
|
ColorableCapability.class).getColor();
|
||||||
|
for (Geometry g : resultingGeoms) {
|
||||||
|
if (pendingRequest != null) {
|
||||||
|
System.out.println("Canceling request: " + req.number);
|
||||||
|
result.dispose();
|
||||||
|
result = null;
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGB color = null;
|
||||||
|
Object shadedField = g.getUserData();
|
||||||
|
if (shadedField != null) {
|
||||||
|
color = req.getColor(shadedField);
|
||||||
|
} else {
|
||||||
|
color = outlineColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
jtsCompiler.handle(g, color, true);
|
||||||
|
} catch (VizException e) {
|
||||||
|
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Error reprojecting map outline", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newOutlineShape.compile();
|
||||||
|
|
||||||
|
if (req.isProduct || req.shadingField != null) {
|
||||||
|
newShadedShape.compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Geometry g : highlightGeoms) {
|
||||||
|
if (pendingRequest != null) {
|
||||||
|
System.out.println("Canceling request: " + req.number);
|
||||||
|
result.dispose();
|
||||||
|
result = null;
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
highlightCompiler.handle(g, true);
|
||||||
|
} catch (VizException e) {
|
||||||
|
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Error reprojecting map outline", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// uncomment to see boungingGeom as highlight for debug purposes
|
||||||
|
// highlightCompiler.handle(req.boundingGeom, true);
|
||||||
|
|
||||||
|
newHighlightShape.compile();
|
||||||
|
|
||||||
|
result.outlineShape = newOutlineShape;
|
||||||
|
result.labels = newLabels;
|
||||||
|
result.shadedShape = newShadedShape;
|
||||||
|
result.colorMap = req.colorMap;
|
||||||
|
result.highlightShape = newHighlightShape;
|
||||||
|
result.highlightsOnly = req.highlightsOnly;
|
||||||
|
result.failed = false;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
result.cause = e;
|
||||||
|
} finally {
|
||||||
|
if (featureIterator != null) {
|
||||||
|
featureCollection.close(featureIterator);
|
||||||
|
}
|
||||||
|
if (result != null) {
|
||||||
|
System.out.println("Completed request: " + req.number);
|
||||||
|
if (resultQueue.size() == QUEUE_LIMIT) {
|
||||||
|
resultQueue.poll();
|
||||||
|
}
|
||||||
|
resultQueue.add(result);
|
||||||
|
req.rsc.issueRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
req = pendingRequest;
|
||||||
|
pendingRequest = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively traverse a Geometry and expand all geometry collections into
|
||||||
|
* a list of geometries
|
||||||
|
*
|
||||||
|
* @param geometry
|
||||||
|
* the geometry to flatten
|
||||||
|
* @param geomList
|
||||||
|
* the list of geometries
|
||||||
|
*/
|
||||||
|
private void flattenGeometry(Geometry geometry, List<Geometry> geomList) {
|
||||||
|
if (geometry instanceof GeometryCollection) {
|
||||||
|
GeometryCollection collection = (GeometryCollection) geometry;
|
||||||
|
for (int i = 0; i < collection.getNumGeometries(); i++) {
|
||||||
|
flattenGeometry(collection.getGeometryN(i), geomList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
geomList.add(geometry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,157 @@
|
||||||
|
/**
|
||||||
|
* 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.FieldEditor;
|
||||||
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.DisposeEvent;
|
||||||
|
import org.eclipse.swt.events.DisposeListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract base class for field editors with images.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 11, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public abstract class AbstractFieldEditor extends FieldEditor {
|
||||||
|
|
||||||
|
protected Button fButton;
|
||||||
|
|
||||||
|
protected Point fExtent;
|
||||||
|
|
||||||
|
protected Image fImage;
|
||||||
|
|
||||||
|
public AbstractFieldEditor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
super(name, labelText, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void adjustForNumColumns(int numColumns) {
|
||||||
|
((GridData) getLabelControl().getLayoutData()).horizontalSpan = numColumns - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Point computeImageSize(Control window) {
|
||||||
|
GC gc = new GC(window);
|
||||||
|
Font f = JFaceResources.getFontRegistry().get(
|
||||||
|
JFaceResources.DIALOG_FONT);
|
||||||
|
gc.setFont(f);
|
||||||
|
int height = gc.getFontMetrics().getHeight();
|
||||||
|
gc.dispose();
|
||||||
|
Point p = new Point(64, height);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNumberOfControls() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFillIntoGrid(Composite parent, int numColumns) {
|
||||||
|
Control control = getLabelControl(parent);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||||
|
gd.horizontalSpan = numColumns - 1;
|
||||||
|
control.setLayoutData(gd);
|
||||||
|
|
||||||
|
fButton = new Button(parent, SWT.PUSH);
|
||||||
|
fButton.setLayoutData(new GridData());
|
||||||
|
fExtent = computeImageSize(parent);
|
||||||
|
updateImage();
|
||||||
|
fButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent event) {
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fButton.addDisposeListener(new DisposeListener() {
|
||||||
|
@Override
|
||||||
|
public void widgetDisposed(DisposeEvent event) {
|
||||||
|
if (fImage != null) {
|
||||||
|
fImage.dispose();
|
||||||
|
fImage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base method just removes old image. Subclasses should call super to
|
||||||
|
* dispose old image before updating the image.
|
||||||
|
*/
|
||||||
|
protected void updateImage() {
|
||||||
|
if (fImage != null) {
|
||||||
|
fImage.dispose();
|
||||||
|
fImage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void open();
|
||||||
|
|
||||||
|
protected abstract void setValueFromString(String value);
|
||||||
|
|
||||||
|
protected abstract String getStringFromValue();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLoad() {
|
||||||
|
String value = getPreferenceStore().getString(getPreferenceName());
|
||||||
|
setValueFromString(value);
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLoadDefault() {
|
||||||
|
String value = getPreferenceStore().getDefaultString(
|
||||||
|
getPreferenceName());
|
||||||
|
setValueFromString(value);
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doStore() {
|
||||||
|
getPreferenceStore()
|
||||||
|
.setValue(getPreferenceName(), getStringFromValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,642 @@
|
||||||
|
/**
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.jface.viewers.TableViewerColumn;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ControlAdapter;
|
||||||
|
import org.eclipse.swt.events.ControlEvent;
|
||||||
|
import org.eclipse.swt.events.DisposeEvent;
|
||||||
|
import org.eclipse.swt.events.DisposeListener;
|
||||||
|
import org.eclipse.swt.events.MouseAdapter;
|
||||||
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.dataplugin.gfe.type.Pair;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||||
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.ResourceList.RemoveListener;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource.IDoubleClickSelectionListener;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIS Attribute Viewer
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 30, 2012 #1326 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AttributeViewer extends CaveJFACEDialog implements RemoveListener {
|
||||||
|
private static final String HIGHLIGHT = "HighLight";
|
||||||
|
|
||||||
|
private static final String VISIBLE = "Visible";
|
||||||
|
|
||||||
|
private static Map<DataStoreResource, AttributeViewer> map = new HashMap<DataStoreResource, AttributeViewer>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open attribute viewer for the selected rsc (or bring to top if already
|
||||||
|
* open)
|
||||||
|
*
|
||||||
|
* @param shell
|
||||||
|
* @param rsc
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AttributeViewer openDialog(Shell shell, DataStoreResource rsc) {
|
||||||
|
AttributeViewer dlg = map.get(rsc);
|
||||||
|
if (dlg == null) {
|
||||||
|
|
||||||
|
dlg = new AttributeViewer(shell, rsc);
|
||||||
|
dlg.open();
|
||||||
|
} else {
|
||||||
|
dlg.bringToTop();
|
||||||
|
}
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int DEFAULT_WIDTH = 900;
|
||||||
|
|
||||||
|
private static final int MAX_INITIAL_COLUMN_WIDTH = DEFAULT_WIDTH / 4;
|
||||||
|
|
||||||
|
protected static final int MINIMUM_COLUMN_WIDTH = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides text for the columns in the attribute viewer from the attributes
|
||||||
|
* array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class TableLabelProvider extends LabelProvider implements
|
||||||
|
ITableLabelProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
|
return String.valueOf(((Object[]) element)[columnIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares rows using values from the selected column and direction for
|
||||||
|
* sorting the table in the desired order.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class ColumnComparator extends ViewerComparator {
|
||||||
|
private List<Pair<String, Integer>> sortOrder;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void sort(Viewer viewer, Object[] elements) {
|
||||||
|
Arrays.sort(elements, new Comparator<Object>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Object a, Object b) {
|
||||||
|
List<String> nameList = Arrays.asList(names);
|
||||||
|
int retval = 0;
|
||||||
|
for (Pair<String, Integer> p : sortOrder) {
|
||||||
|
String field = p.getFirst();
|
||||||
|
int column = nameList.indexOf(field);
|
||||||
|
int direction = p.getSecond();
|
||||||
|
|
||||||
|
Object aObj = ((Object[]) a)[column];
|
||||||
|
Object bObj = ((Object[]) b)[column];
|
||||||
|
|
||||||
|
if ((aObj instanceof Comparable)
|
||||||
|
&& (bObj instanceof Comparable)) {
|
||||||
|
retval = ((Comparable<Object>) aObj)
|
||||||
|
.compareTo(bObj);
|
||||||
|
} else {
|
||||||
|
retval = String.valueOf(aObj).compareTo(
|
||||||
|
String.valueOf(bObj));
|
||||||
|
}
|
||||||
|
retval *= direction;
|
||||||
|
|
||||||
|
if (retval != 0) {
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the sort order as a pair of column names and integers
|
||||||
|
* indicating sort direction (1 for ascending, -1 for descending)
|
||||||
|
*
|
||||||
|
* @return the sort order
|
||||||
|
*/
|
||||||
|
public List<Pair<String, Integer>> getSortOrder() {
|
||||||
|
return sortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sort order as a pair of column names and integers indicating
|
||||||
|
* sort direction (1 for ascending, -1 for descending)
|
||||||
|
*
|
||||||
|
* @param sortOrder
|
||||||
|
*/
|
||||||
|
public void setSortOrder(List<Pair<String, Integer>> sortOrder) {
|
||||||
|
this.sortOrder = sortOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColumnComparator comparator;
|
||||||
|
|
||||||
|
private DataStoreResource rsc;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String[] names;
|
||||||
|
|
||||||
|
private Object[][] attributes;
|
||||||
|
|
||||||
|
private Shell parentShell;
|
||||||
|
|
||||||
|
private TableViewer viewer;
|
||||||
|
|
||||||
|
protected String[] selectedColumns;
|
||||||
|
|
||||||
|
SortOrderDialog sortDlg;
|
||||||
|
|
||||||
|
protected ColumnSelectDialog selectDlg;
|
||||||
|
|
||||||
|
private int[] columnWidth;
|
||||||
|
|
||||||
|
private IDoubleClickSelectionListener selectedListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an attribute viewer for the specified DataStoreResource
|
||||||
|
*
|
||||||
|
* @param parentShell
|
||||||
|
* (only used for positioning the dialog)
|
||||||
|
* @param rsc
|
||||||
|
* the DataStoreResource
|
||||||
|
*/
|
||||||
|
public AttributeViewer(Shell parentShell, DataStoreResource rsc) {
|
||||||
|
// TODO: make open centered in parentShell
|
||||||
|
super(null);
|
||||||
|
this.setShellStyle(SWT.SHELL_TRIM | SWT.MENU);
|
||||||
|
this.rsc = rsc;
|
||||||
|
this.title = rsc.getName();
|
||||||
|
this.names = rsc.getAttributeNames();
|
||||||
|
this.selectedColumns = this.names;
|
||||||
|
this.parentShell = parentShell;
|
||||||
|
|
||||||
|
// TODO: may need to deep copy this in case it changes out from under us
|
||||||
|
this.attributes = rsc.getAttributes();
|
||||||
|
|
||||||
|
map.put(rsc, this);
|
||||||
|
rsc.getDescriptor().getResourceList().addPreRemoveListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isResizable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
newShell.setText("Attributes: " + this.title);
|
||||||
|
|
||||||
|
Menu menuBar = new Menu(newShell, SWT.BAR);
|
||||||
|
|
||||||
|
MenuItem annotationMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
|
||||||
|
annotationMenuHeader.setText("Annotation");
|
||||||
|
|
||||||
|
Menu annotationMenu = new Menu(newShell, SWT.DROP_DOWN);
|
||||||
|
annotationMenuHeader.setMenu(annotationMenu);
|
||||||
|
|
||||||
|
MenuItem makeAllVisible = new MenuItem(annotationMenu, SWT.PUSH);
|
||||||
|
makeAllVisible.setText("Make All Visible");
|
||||||
|
makeAllVisible.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
|
makeVisible(true, viewer.getTable().getItems());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuItem clearHighlights = new MenuItem(annotationMenu, SWT.PUSH);
|
||||||
|
clearHighlights.setText("Clear Highlights");
|
||||||
|
clearHighlights.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
|
highlight(false, viewer.getTable().getItems());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuItem dataMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
|
||||||
|
dataMenuHeader.setText("Data");
|
||||||
|
Menu dataMenu = new Menu(newShell, SWT.DROP_DOWN);
|
||||||
|
dataMenuHeader.setMenu(dataMenu);
|
||||||
|
|
||||||
|
MenuItem columnsItem = new MenuItem(dataMenu, SWT.PUSH);
|
||||||
|
columnsItem.setText("Select Columns...");
|
||||||
|
columnsItem.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent arg0) {
|
||||||
|
selectColumns();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuItem sortItem = new MenuItem(dataMenu, SWT.PUSH);
|
||||||
|
sortItem.setText("Sort...");
|
||||||
|
sortItem.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
sortColumns();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newShell.setMenuBar(menuBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite composite = (Composite) super.createDialogArea(parent);
|
||||||
|
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
composite.setLayout(layout);
|
||||||
|
|
||||||
|
viewer = new TableViewer(composite, SWT.MULTI | SWT.BORDER
|
||||||
|
| SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION
|
||||||
|
| SWT.VIRTUAL);
|
||||||
|
Table table = viewer.getTable();
|
||||||
|
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
// table.setLinesVisible(true);
|
||||||
|
table.setSortDirection(SWT.UP);
|
||||||
|
comparator = new ColumnComparator();
|
||||||
|
ArrayList<Pair<String, Integer>> sortOrder = new ArrayList<Pair<String, Integer>>(
|
||||||
|
1);
|
||||||
|
comparator.setSortOrder(sortOrder);
|
||||||
|
viewer.setComparator(comparator);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
GC gc = new GC(table);
|
||||||
|
columnWidth = new int[names.length];
|
||||||
|
int totalWidth = 0;
|
||||||
|
for (String attrName : names) {
|
||||||
|
int index = i++;
|
||||||
|
int alignment = SWT.LEFT;
|
||||||
|
if (this.attributes[0][index] instanceof Integer) {
|
||||||
|
alignment = SWT.RIGHT;
|
||||||
|
}
|
||||||
|
TableViewerColumn tvc = new TableViewerColumn(viewer, alignment,
|
||||||
|
index);
|
||||||
|
final TableColumn column = tvc.getColumn();
|
||||||
|
column.setText(attrName);
|
||||||
|
// column.addSelectionListener(new
|
||||||
|
// ColumnSelectionAdapter(tableViewer,
|
||||||
|
// index));
|
||||||
|
column.pack();
|
||||||
|
int extent = column.getWidth();
|
||||||
|
for (Object[] atts : this.attributes) {
|
||||||
|
int width = gc.stringExtent(String.valueOf(atts[index])).x + 10;
|
||||||
|
|
||||||
|
if (width > MAX_INITIAL_COLUMN_WIDTH) {
|
||||||
|
extent = MAX_INITIAL_COLUMN_WIDTH;
|
||||||
|
break;
|
||||||
|
} else if (width > extent) {
|
||||||
|
extent = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
column.setWidth(extent);
|
||||||
|
columnWidth[index] = extent;
|
||||||
|
column.addControlListener(new ControlAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void controlResized(ControlEvent e) {
|
||||||
|
TableColumn column = (TableColumn) e.widget;
|
||||||
|
int index = viewer.getTable().indexOf(column);
|
||||||
|
int width = column.getWidth();
|
||||||
|
if (width > MINIMUM_COLUMN_WIDTH) {
|
||||||
|
columnWidth[index] = column.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width == 0) {
|
||||||
|
List<String> newSelected = new ArrayList<String>(Arrays
|
||||||
|
.asList(selectedColumns));
|
||||||
|
newSelected.remove(names[index]);
|
||||||
|
selectedColumns = newSelected
|
||||||
|
.toArray(new String[newSelected.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
totalWidth += extent;
|
||||||
|
}
|
||||||
|
gc.dispose();
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
if (totalWidth > DEFAULT_WIDTH) {
|
||||||
|
layoutData.widthHint = DEFAULT_WIDTH;
|
||||||
|
}
|
||||||
|
layoutData.heightHint = table.getItemHeight() * 5;
|
||||||
|
table.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
IContentProvider contentProvider = new ArrayContentProvider();
|
||||||
|
viewer.setLabelProvider(new TableLabelProvider());
|
||||||
|
viewer.setContentProvider(contentProvider);
|
||||||
|
viewer.setInput(this.attributes);
|
||||||
|
|
||||||
|
table.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
Table table = (Table) e.widget;
|
||||||
|
TableItem[] selected = table.getSelection();
|
||||||
|
boolean highlight = (Boolean) selected[0].getData(HIGHLIGHT);
|
||||||
|
if (!highlight) {
|
||||||
|
recenter(selected[0]);
|
||||||
|
}
|
||||||
|
highlight(!highlight, selected);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
table.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDown(MouseEvent e) {
|
||||||
|
Table table = (Table) e.widget;
|
||||||
|
if (e.button == 3) {
|
||||||
|
Point p = new Point(e.x, e.y);
|
||||||
|
TableItem clicked = table.getItem(p);
|
||||||
|
TableItem[] selected = table.getSelection();
|
||||||
|
createPopupMenu(table, clicked, selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Label label = new Label(composite, SWT.NONE);
|
||||||
|
label.setText(this.attributes.length + " rows");
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
label.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
initializeColors();
|
||||||
|
|
||||||
|
selectedListener = new IDoubleClickSelectionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectedFeaturesChanged(List<String> selectedIds) {
|
||||||
|
Table table = viewer.getTable();
|
||||||
|
int i = 0;
|
||||||
|
table.deselectAll();
|
||||||
|
for (TableItem item : table.getItems()) {
|
||||||
|
if (selectedIds.contains(item.getText(0))) {
|
||||||
|
table.select(i);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (table.getSelectionCount() > 0) {
|
||||||
|
table.showItem(table.getSelection()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
table.addDisposeListener(new DisposeListener() {
|
||||||
|
@Override
|
||||||
|
public void widgetDisposed(DisposeEvent e) {
|
||||||
|
rsc.removeDoubleClickSelectionListener(selectedListener);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
rsc.addDoubleClickSelectionListener(selectedListener);
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeColors() {
|
||||||
|
for (TableItem item : viewer.getTable().getItems()) {
|
||||||
|
String id = item.getText(0);
|
||||||
|
item.setData(VISIBLE, rsc.getVisible(id));
|
||||||
|
item.setData(HIGHLIGHT, rsc.getHighlighted(id));
|
||||||
|
setColors(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createPopupMenu(Table table, final TableItem clicked,
|
||||||
|
final TableItem[] selected) {
|
||||||
|
Menu popupMenu = new Menu(table);
|
||||||
|
|
||||||
|
MenuItem visible = new MenuItem(popupMenu, SWT.CHECK);
|
||||||
|
visible.setText("Visible");
|
||||||
|
visible.setSelection((Boolean) clicked.getData(VISIBLE));
|
||||||
|
visible.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
MenuItem item = (MenuItem) e.widget;
|
||||||
|
makeVisible(item.getSelection(), selected);
|
||||||
|
item.getParent().dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MenuItem highLight = new MenuItem(popupMenu, SWT.CHECK);
|
||||||
|
highLight.setText("Highlighted");
|
||||||
|
highLight.setSelection((Boolean) clicked.getData(HIGHLIGHT));
|
||||||
|
highLight.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
MenuItem item = (MenuItem) e.widget;
|
||||||
|
highlight(item.getSelection(), selected);
|
||||||
|
item.getParent().dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createButtonBar(Composite parent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean close() {
|
||||||
|
map.remove(this.rsc);
|
||||||
|
return super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyRemove(ResourcePair rp) throws VizException {
|
||||||
|
AbstractVizResource<?, ?> rsc = rp.getResource();
|
||||||
|
if (rsc instanceof DataStoreResource) {
|
||||||
|
AttributeViewer dlg = map.remove(rsc);
|
||||||
|
if (dlg != null) {
|
||||||
|
dlg.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeVisible(boolean visible, TableItem[] items) {
|
||||||
|
for (TableItem item : items) {
|
||||||
|
item.setData(VISIBLE, visible);
|
||||||
|
setColors(item);
|
||||||
|
rsc.setVisible(item.getText(0), visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void highlight(boolean highlight, TableItem[] items) {
|
||||||
|
for (TableItem item : items) {
|
||||||
|
item.setData(HIGHLIGHT, highlight);
|
||||||
|
setColors(item);
|
||||||
|
rsc.setHighlighted(item.getText(0), highlight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recenter(TableItem item) {
|
||||||
|
rsc.recenter(item.getText(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setColors(TableItem item) {
|
||||||
|
boolean visible = (Boolean) item.getData(VISIBLE);
|
||||||
|
boolean highlight = (Boolean) item.getData(HIGHLIGHT);
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
if (highlight) {
|
||||||
|
item.setBackground(item.getDisplay().getSystemColor(
|
||||||
|
SWT.COLOR_YELLOW));
|
||||||
|
} else {
|
||||||
|
item.setBackground(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
item.setBackground(item.getDisplay().getSystemColor(SWT.COLOR_GRAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectColumns() {
|
||||||
|
if (selectDlg == null) {
|
||||||
|
selectDlg = new ColumnSelectDialog(getShell(), names,
|
||||||
|
selectedColumns);
|
||||||
|
selectDlg.setBlockOnOpen(false);
|
||||||
|
selectDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
int returnCode = (Integer) returnValue;
|
||||||
|
if (returnCode == Window.OK) {
|
||||||
|
String[] selectedColumns = selectDlg
|
||||||
|
.getSelectedColumns();
|
||||||
|
setSelectedColumns(selectedColumns);
|
||||||
|
viewer.refresh();
|
||||||
|
}
|
||||||
|
selectDlg = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
selectDlg.open();
|
||||||
|
} else {
|
||||||
|
selectDlg.bringToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the columns displayed in the desired order.
|
||||||
|
*
|
||||||
|
* @param selectedColumns
|
||||||
|
*/
|
||||||
|
private void setSelectedColumns(String[] selectedColumns) {
|
||||||
|
this.selectedColumns = selectedColumns;
|
||||||
|
List<String> namesList = Arrays.asList(names);
|
||||||
|
List<String> selectedList = Arrays.asList(selectedColumns);
|
||||||
|
List<String> unselected = new ArrayList<String>(namesList);
|
||||||
|
unselected.removeAll(selectedList);
|
||||||
|
List<String> orderedList = new ArrayList<String>(names.length);
|
||||||
|
orderedList.addAll(selectedList);
|
||||||
|
orderedList.addAll(unselected);
|
||||||
|
int[] order = new int[names.length];
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
order[i] = namesList.indexOf(orderedList.get(i));
|
||||||
|
TableColumn column = viewer.getTable().getColumn(i);
|
||||||
|
if (!selectedList.contains(names[i])) {
|
||||||
|
column.setWidth(0);
|
||||||
|
} else {
|
||||||
|
column.setWidth(columnWidth[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewer.getTable().setColumnOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortColumns() {
|
||||||
|
|
||||||
|
if (sortDlg == null) {
|
||||||
|
sortDlg = new SortOrderDialog(getShell(), names,
|
||||||
|
comparator.getSortOrder());
|
||||||
|
sortDlg.setBlockOnOpen(false);
|
||||||
|
sortDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
int returnCode = (Integer) returnValue;
|
||||||
|
if (returnCode == Window.OK) {
|
||||||
|
List<Pair<String, Integer>> sortOrder = sortDlg
|
||||||
|
.getSortOrder();
|
||||||
|
comparator.setSortOrder(sortOrder);
|
||||||
|
viewer.refresh();
|
||||||
|
}
|
||||||
|
sortDlg = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sortDlg.open();
|
||||||
|
} else {
|
||||||
|
sortDlg.bringToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/**
|
||||||
|
* 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.Color;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.widgets.ColorDialog;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.RGBColors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference field editor for selecting a color for the DataStoreResource
|
||||||
|
* highlight
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class ColorFieldEditor extends AbstractFieldEditor {
|
||||||
|
private static final RGB DEFAULT_COLOR = RGBColors.getRGBColor("HotPink");
|
||||||
|
|
||||||
|
private RGB fColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ColorFieldEditor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param labelText
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
public ColorFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
super(name, labelText, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init(String name, String text) {
|
||||||
|
super.init(name, text);
|
||||||
|
this.fColor = DEFAULT_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#updateImage()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void updateImage() {
|
||||||
|
super.updateImage();
|
||||||
|
fImage = new Image(fButton.getDisplay(), fExtent.x, fExtent.y);
|
||||||
|
GC gc = new GC(fImage);
|
||||||
|
Color color = new Color(fButton.getDisplay(), this.fColor);
|
||||||
|
gc.setBackground(color);
|
||||||
|
gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
|
||||||
|
color.dispose();
|
||||||
|
gc.dispose();
|
||||||
|
fButton.setImage(fImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#open()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
ColorDialog colorDialog = new ColorDialog(fButton.getShell());
|
||||||
|
colorDialog.setRGB(fColor);
|
||||||
|
RGB newColor = colorDialog.open();
|
||||||
|
if (newColor != null) {
|
||||||
|
this.fColor = newColor;
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setValueFromString(String value) {
|
||||||
|
RGB newColor = StringConverter.asRGB(value);
|
||||||
|
if (newColor == null) {
|
||||||
|
newColor = DEFAULT_COLOR;
|
||||||
|
}
|
||||||
|
this.fColor = newColor;
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getStringFromValue() {
|
||||||
|
return StringConverter.asString(this.fColor);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
import com.raytheon.viz.ui.widgets.duallist.DualList;
|
||||||
|
import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog to allow user to select the columns to be displayed and the order in
|
||||||
|
* which to display them
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 30, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ColumnSelectDialog extends CaveJFACEDialog {
|
||||||
|
|
||||||
|
private String[] available;
|
||||||
|
|
||||||
|
private List<String> selected;
|
||||||
|
|
||||||
|
private DualList dualList;
|
||||||
|
|
||||||
|
protected ColumnSelectDialog(Shell parentShell, String[] available,
|
||||||
|
String[] selected) {
|
||||||
|
super(parentShell);
|
||||||
|
this.available = available;
|
||||||
|
this.selected = new ArrayList<String>(Arrays.asList(selected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
newShell.setText("Select Columns");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite comp = (Composite) super.createDialogArea(parent);
|
||||||
|
|
||||||
|
DualListConfig config = new DualListConfig();
|
||||||
|
config.setAvailableListLabel("Available");
|
||||||
|
config.setFullList(Arrays.asList(available));
|
||||||
|
config.setSelectedListLabel("Displayed");
|
||||||
|
config.setSelectedList(selected);
|
||||||
|
config.setListHeight(100);
|
||||||
|
config.setListWidth(100);
|
||||||
|
config.setShowUpDownBtns(true);
|
||||||
|
dualList = new DualList(comp, SWT.NONE, config);
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getSelectedColumns() {
|
||||||
|
return dualList.getSelectedListItems();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,455 @@
|
||||||
|
/**
|
||||||
|
* 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 java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
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.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.swt.widgets.List;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.geotools.data.DataStore;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.time.DataTime;
|
||||||
|
import com.raytheon.uf.common.time.SimulatedTime;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
|
||||||
|
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.Activator;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.IGisDataStorePlugin;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData;
|
||||||
|
import com.raytheon.viz.core.ColorUtil;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
import com.raytheon.viz.ui.widgets.TimeRangeEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic GIS Connection Parameters Dialog
|
||||||
|
*
|
||||||
|
* Each GisDataStore implementation will need to provide an implementation of
|
||||||
|
* IParametersComp containing the necessary widgets to enter its specific
|
||||||
|
* connection parameters
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 5, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GisDataStoreParametersDialog extends CaveJFACEDialog {
|
||||||
|
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss'Z'";
|
||||||
|
|
||||||
|
private static final String GIS_DATA_STORE_PLUGIN_PREF = "GisDataStorePlugin";
|
||||||
|
|
||||||
|
private static final String EXTENSION_POINT_ID = "com.raytheon.uf.viz.gisdatastore.gisDataStore";
|
||||||
|
|
||||||
|
private IDescriptor descriptor;
|
||||||
|
|
||||||
|
private DataTime currentFrame;
|
||||||
|
|
||||||
|
private boolean loadAsProduct;
|
||||||
|
|
||||||
|
private Map<String, IGisDataStorePlugin> plugins;
|
||||||
|
|
||||||
|
private String[] pluginNames;
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
private IGisDataStorePlugin gdsPlugin;
|
||||||
|
|
||||||
|
private Composite mainComp;
|
||||||
|
|
||||||
|
private TimeRangeEntry timeRangeEntry;
|
||||||
|
|
||||||
|
private Group connectionGroup;
|
||||||
|
|
||||||
|
private Button connectButton;
|
||||||
|
|
||||||
|
private Button disconnectButton;
|
||||||
|
|
||||||
|
private List tablesList;
|
||||||
|
|
||||||
|
private Button okButton;
|
||||||
|
|
||||||
|
private DataStore dataStore;
|
||||||
|
|
||||||
|
private String selectedPlugin;
|
||||||
|
|
||||||
|
public GisDataStoreParametersDialog(Shell parentShell,
|
||||||
|
IDescriptor descriptor) {
|
||||||
|
super(parentShell);
|
||||||
|
this.descriptor = descriptor;
|
||||||
|
FramesInfo framesInfo = descriptor.getFramesInfo();
|
||||||
|
|
||||||
|
currentFrame = framesInfo.getCurrentFrame();
|
||||||
|
if (currentFrame == null) {
|
||||||
|
currentFrame = new DataTime(SimulatedTime.getSystemTime().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
|
||||||
|
* .Shell)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell shell) {
|
||||||
|
super.configureShell(shell);
|
||||||
|
shell.setText("GIS DataStore Parameters");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc) Method declared on Dialog.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
mainComp = (Composite) super.createDialogArea(parent);
|
||||||
|
Group dsTypeGroup = new Group(mainComp, SWT.NONE);
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
dsTypeGroup.setLayoutData(layoutData);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
dsTypeGroup.setLayout(layout);
|
||||||
|
dsTypeGroup.setText("DataStore Type:");
|
||||||
|
|
||||||
|
Combo typeCombo = new Combo(dsTypeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
typeCombo.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
for (String pluginName : getPluginNames()) {
|
||||||
|
typeCombo.add(pluginName);
|
||||||
|
}
|
||||||
|
|
||||||
|
typeCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
String pluginName = ((Combo) e.widget).getText();
|
||||||
|
selectPlugin(pluginName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connectionGroup = new Group(mainComp, SWT.NONE);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
connectionGroup.setLayoutData(layoutData);
|
||||||
|
layout = new GridLayout();
|
||||||
|
connectionGroup.setLayout(layout);
|
||||||
|
connectionGroup.setText("Connection Parameters:");
|
||||||
|
|
||||||
|
Composite btnComp = new Composite(mainComp, SWT.NONE);
|
||||||
|
layoutData = new GridData(SWT.END, SWT.FILL, true, true);
|
||||||
|
btnComp.setLayoutData(layoutData);
|
||||||
|
layout = new GridLayout(2, false);
|
||||||
|
btnComp.setLayout(layout);
|
||||||
|
|
||||||
|
connectButton = new Button(btnComp, SWT.PUSH);
|
||||||
|
layoutData = new GridData(SWT.END, SWT.CENTER, false, false);
|
||||||
|
connectButton.setLayoutData(layoutData);
|
||||||
|
connectButton.setText("Connect");
|
||||||
|
connectButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
disconnectButton = new Button(btnComp, SWT.PUSH);
|
||||||
|
layoutData = new GridData(SWT.END, SWT.CENTER, false, false);
|
||||||
|
disconnectButton.setLayoutData(layoutData);
|
||||||
|
disconnectButton.setText("Disconnect");
|
||||||
|
disconnectButton.setEnabled(false);
|
||||||
|
disconnectButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Group productGroup = new Group(mainComp, SWT.NONE);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
productGroup.setLayoutData(layoutData);
|
||||||
|
productGroup.setText("Load As:");
|
||||||
|
layout = new GridLayout(2, true);
|
||||||
|
productGroup.setLayout(layout);
|
||||||
|
|
||||||
|
Button mapButton = new Button(productGroup, SWT.RADIO);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
mapButton.setLayoutData(layoutData);
|
||||||
|
mapButton.setText("Map");
|
||||||
|
mapButton.setSelection(!loadAsProduct);
|
||||||
|
|
||||||
|
Button productButton = new Button(productGroup, SWT.RADIO);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
productButton.setLayoutData(layoutData);
|
||||||
|
productButton.setText("Product");
|
||||||
|
productButton.setSelection(loadAsProduct);
|
||||||
|
|
||||||
|
timeRangeEntry = new TimeRangeEntry(productGroup, SWT.HORIZONTAL);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
layoutData.horizontalSpan = 2;
|
||||||
|
timeRangeEntry.setLayoutData(layoutData);
|
||||||
|
timeRangeEntry.setDateFormat(DATE_TIME_FORMAT);
|
||||||
|
timeRangeEntry.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
timeRangeEntry.setTimeRange(currentFrame.getValidPeriod());
|
||||||
|
timeRangeEntry.setEnabled(loadAsProduct);
|
||||||
|
|
||||||
|
productButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
Button button = (Button) e.widget;
|
||||||
|
loadAsProduct = button.getSelection();
|
||||||
|
timeRangeEntry.setEnabled(loadAsProduct);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Group tableGroup = new Group(mainComp, SWT.NONE);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
tableGroup.setLayoutData(layoutData);
|
||||||
|
layout = new GridLayout(1, false);
|
||||||
|
tableGroup.setLayout(layout);
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
tableGroup.setText("Table:");
|
||||||
|
|
||||||
|
tablesList = new List(tableGroup, SWT.SINGLE | SWT.BORDER
|
||||||
|
| SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
layoutData.heightHint = tablesList.getItemHeight() * 12;
|
||||||
|
tablesList.setLayoutData(layoutData);
|
||||||
|
tablesList.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
if (tablesList.getSelectionCount() > 0) {
|
||||||
|
typeName = tablesList.getSelection()[0];
|
||||||
|
GisDataStoreParametersDialog.this.okButton.setEnabled(true);
|
||||||
|
buttonPressed(IDialogConstants.OK_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
if (tablesList.getSelectionCount() > 0) {
|
||||||
|
typeName = tablesList.getSelection()[0];
|
||||||
|
okButton.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
applyDialogFont(mainComp);
|
||||||
|
|
||||||
|
IPersistentPreferenceStore prefs = Activator.getDefault()
|
||||||
|
.getPreferenceStore();
|
||||||
|
String pluginName = prefs.getString(GIS_DATA_STORE_PLUGIN_PREF);
|
||||||
|
if (!Arrays.asList(getPluginNames()).contains(pluginName)) {
|
||||||
|
pluginName = getPluginNames()[0];
|
||||||
|
prefs.setToDefault(GIS_DATA_STORE_PLUGIN_PREF);
|
||||||
|
try {
|
||||||
|
prefs.save();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
Activator.statusHandler
|
||||||
|
.error("Unable to save most recently used GIS Plugin to prefrences",
|
||||||
|
e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typeCombo.setText(pluginName);
|
||||||
|
selectedPlugin = null;
|
||||||
|
selectPlugin(pluginName);
|
||||||
|
return mainComp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createButtonsForButtonBar(Composite parent) {
|
||||||
|
super.createButtonsForButtonBar(parent);
|
||||||
|
okButton = getButton(IDialogConstants.OK_ID);
|
||||||
|
okButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc) Method declared on Dialog.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void buttonPressed(int buttonId) {
|
||||||
|
if (dataStore != null) {
|
||||||
|
dataStore.dispose();
|
||||||
|
}
|
||||||
|
super.buttonPressed(buttonId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void okPressed() {
|
||||||
|
try {
|
||||||
|
DataStoreResourceData rd = gdsPlugin.constructResourceData(
|
||||||
|
typeName, gdsPlugin.getConnectionParameters());
|
||||||
|
DataStoreResource rsc = rd.construct(new LoadProperties(),
|
||||||
|
descriptor);
|
||||||
|
|
||||||
|
if (loadAsProduct) {
|
||||||
|
rsc.setTimeRange(timeRangeEntry.getTimeRange());
|
||||||
|
}
|
||||||
|
|
||||||
|
RGB color = ColorUtil.getNewColor(descriptor);
|
||||||
|
rsc.getCapability(ColorableCapability.class).setColor(color);
|
||||||
|
|
||||||
|
ResourceProperties props = new ResourceProperties();
|
||||||
|
props.setVisible(true);
|
||||||
|
props.setMapLayer(!loadAsProduct);
|
||||||
|
descriptor.getResourceList().add(rsc, props);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Activator.statusHandler.error("Error importing GIS resource: ", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.okPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectPlugin(String pluginName) {
|
||||||
|
if (!pluginName.equals(selectedPlugin)) {
|
||||||
|
gdsPlugin = getPlugin(pluginName);
|
||||||
|
for (Control c : connectionGroup.getChildren()) {
|
||||||
|
c.dispose();
|
||||||
|
}
|
||||||
|
disconnect();
|
||||||
|
gdsPlugin.createControls(connectionGroup);
|
||||||
|
gdsPlugin.loadFromPreferences();
|
||||||
|
connectionGroup.layout();
|
||||||
|
getShell().pack();
|
||||||
|
selectedPlugin = pluginName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connect() {
|
||||||
|
try {
|
||||||
|
dataStore = gdsPlugin.connectToDataStore();
|
||||||
|
disconnectButton.setEnabled(true);
|
||||||
|
connectButton.setEnabled(false);
|
||||||
|
|
||||||
|
IPersistentPreferenceStore prefs = Activator.getDefault()
|
||||||
|
.getPreferenceStore();
|
||||||
|
prefs.setValue(GIS_DATA_STORE_PLUGIN_PREF, selectedPlugin);
|
||||||
|
try {
|
||||||
|
prefs.save();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
Activator.statusHandler
|
||||||
|
.error("Unable to save most recently used GIS Plugin to prefrences",
|
||||||
|
e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
gdsPlugin.saveToPreferences();
|
||||||
|
|
||||||
|
String[] typeNames = dataStore.getTypeNames();
|
||||||
|
Arrays.sort(typeNames);
|
||||||
|
tablesList.setItems(typeNames);
|
||||||
|
if (typeName != null) {
|
||||||
|
int index = tablesList.indexOf(typeName);
|
||||||
|
if (index >= 0) {
|
||||||
|
tablesList.select(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Activator.statusHandler.error(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disconnect() {
|
||||||
|
if (dataStore != null) {
|
||||||
|
dataStore.dispose();
|
||||||
|
}
|
||||||
|
connectButton.setEnabled(true);
|
||||||
|
disconnectButton.setEnabled(false);
|
||||||
|
tablesList.removeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getConnectionParameters() {
|
||||||
|
return gdsPlugin.getConnectionParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IGisDataStorePlugin getPlugin(String pluginName) {
|
||||||
|
getPluginNames(); // ensure plugins are loaded
|
||||||
|
return plugins.get(pluginName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getPluginNames() {
|
||||||
|
if (pluginNames == null) {
|
||||||
|
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||||
|
IExtensionPoint point = registry
|
||||||
|
.getExtensionPoint(EXTENSION_POINT_ID);
|
||||||
|
plugins = new HashMap<String, IGisDataStorePlugin>();
|
||||||
|
if (point != null) {
|
||||||
|
IExtension[] extensions = point.getExtensions();
|
||||||
|
|
||||||
|
for (IExtension ext : extensions) {
|
||||||
|
IConfigurationElement[] config = ext
|
||||||
|
.getConfigurationElements();
|
||||||
|
|
||||||
|
for (IConfigurationElement cfg : config) {
|
||||||
|
try {
|
||||||
|
IGisDataStorePlugin plugin = (IGisDataStorePlugin) cfg
|
||||||
|
.createExecutableExtension("class");
|
||||||
|
String pluginName = cfg.getAttribute("name");
|
||||||
|
plugins.put(pluginName, plugin);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
Activator.statusHandler.error(
|
||||||
|
"Error loading unit registrations for "
|
||||||
|
+ cfg.getAttribute("class"), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pluginNames = plugins.keySet().toArray(new String[plugins.size()]);
|
||||||
|
Arrays.sort(pluginNames);
|
||||||
|
}
|
||||||
|
return pluginNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**
|
||||||
|
* 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.FieldEditorPreferencePage;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.Activator;
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference page for GIS Viewer
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 26, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GisViewerPreferencePage extends FieldEditorPreferencePage
|
||||||
|
implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
|
public GisViewerPreferencePage() {
|
||||||
|
super(FieldEditorPreferencePage.GRID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init(IWorkbench workbench) {
|
||||||
|
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||||
|
setPreferenceStore(store);
|
||||||
|
setDescription("GIS Viewer Preferences");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createFieldEditors() {
|
||||||
|
AbstractFieldEditor colorEditor = new ColorFieldEditor(
|
||||||
|
DataStoreResource.HIGHLIGHT_COLOR_KEY, "Highlight Color",
|
||||||
|
getFieldEditorParent());
|
||||||
|
|
||||||
|
AbstractFieldEditor styleEditor = new LineStyleFieldEditor(
|
||||||
|
DataStoreResource.HIGHLIGHT_STYLE_KEY, "Highlight Style",
|
||||||
|
getFieldEditorParent());
|
||||||
|
|
||||||
|
AbstractFieldEditor widthEditor = new LineWidthFieldEditor(
|
||||||
|
DataStoreResource.HIGHLIGHT_WIDTH_KEY, "Highlight Width",
|
||||||
|
getFieldEditorParent());
|
||||||
|
|
||||||
|
AbstractFieldEditor opacityEditor = new OpacityFieldEditor(
|
||||||
|
DataStoreResource.PRODUCT_OPACITY_KEY, "Product Opacity",
|
||||||
|
getFieldEditorParent());
|
||||||
|
|
||||||
|
addField(colorEditor);
|
||||||
|
addField(styleEditor);
|
||||||
|
addField(widthEditor);
|
||||||
|
addField(opacityEditor);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/**
|
||||||
|
* 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.dialogs.Dialog;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for selecting line opacity
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LineStyleDialog extends Dialog {
|
||||||
|
LineStyle style;
|
||||||
|
|
||||||
|
protected LineStyleDialog(Shell parentShell, LineStyle origStyle) {
|
||||||
|
super(parentShell);
|
||||||
|
this.style = origStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite comp = (Composite) super.createDialogArea(parent);
|
||||||
|
Label label = new Label(comp, SWT.CENTER);
|
||||||
|
label.setText("Double-Click to select");
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
label.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
Display d = comp.getDisplay();
|
||||||
|
Table table = new Table(comp, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
layoutData.heightHint = table.getItemHeight()
|
||||||
|
* Math.min(10, LineStyle.values().length);
|
||||||
|
table.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
for (LineStyle ls : LineStyle.values()) {
|
||||||
|
if (ls.equals(LineStyle.DEFAULT)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TableItem item = new TableItem(table, SWT.NONE);
|
||||||
|
Image image = new Image(d, 128, 10);
|
||||||
|
Rectangle bounds = image.getBounds();
|
||||||
|
int[] dashes = ls.getSWTLineStyle();
|
||||||
|
GC gc = new GC(image);
|
||||||
|
gc.fillRectangle(bounds);
|
||||||
|
gc.setLineDash(dashes);
|
||||||
|
gc.drawLine(bounds.x, bounds.y + bounds.height / 2,
|
||||||
|
bounds.width - 1, bounds.y + bounds.height / 2);
|
||||||
|
|
||||||
|
gc.dispose();
|
||||||
|
item.setImage(image);
|
||||||
|
image.dispose();
|
||||||
|
item.setData(ls);
|
||||||
|
|
||||||
|
if (ls.equals(this.style)) {
|
||||||
|
table.setSelection(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
Table table = (Table) e.widget;
|
||||||
|
TableItem item = table.getSelection()[0];
|
||||||
|
style = (LineStyle) item.getData();
|
||||||
|
okPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createButtonBar(Composite parent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineStyle getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/**
|
||||||
|
* 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.window.Window;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference field editor for selecting a color for the DataStoreResource
|
||||||
|
* highlight
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 26, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LineStyleFieldEditor extends AbstractFieldEditor {
|
||||||
|
|
||||||
|
protected LineStyle fStyle;
|
||||||
|
|
||||||
|
protected LineStyleFieldEditor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a line opacity field editor.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name of the preference this field editor works on
|
||||||
|
* @param labelText
|
||||||
|
* the label text of the field editor
|
||||||
|
* @param parent
|
||||||
|
* the parent of the field editor's control
|
||||||
|
*/
|
||||||
|
public LineStyleFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
super(name, labelText, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init(String name, String text) {
|
||||||
|
super.init(name, text);
|
||||||
|
this.fStyle = LineStyle.SOLID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void adjustForNumColumns(int numColumns) {
|
||||||
|
((GridData) fButton.getLayoutData()).horizontalSpan = numColumns - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getNumberOfControls() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
LineStyleDialog dlg = new LineStyleDialog(fButton.getShell(), fStyle);
|
||||||
|
if (dlg.open() == Window.OK) {
|
||||||
|
this.fStyle = dlg.getStyle();
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateImage() {
|
||||||
|
super.updateImage();
|
||||||
|
fImage = new Image(fButton.getDisplay(), fExtent.x, fExtent.y);
|
||||||
|
GC gc = new GC(fImage);
|
||||||
|
// gc.setBackground(fButton.getBackground());
|
||||||
|
gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
|
||||||
|
int y = fExtent.y / 2;
|
||||||
|
gc.setLineDash(this.fStyle.getSWTLineStyle());
|
||||||
|
gc.drawLine(0, y, fExtent.x, y);
|
||||||
|
gc.dispose();
|
||||||
|
fButton.setImage(fImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setValueFromString(String value) {
|
||||||
|
LineStyle style = StringConverter.asLineStyle(value);
|
||||||
|
if (style == null) {
|
||||||
|
this.fStyle = LineStyle.SOLID;
|
||||||
|
} else {
|
||||||
|
this.fStyle = style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getStringFromValue() {
|
||||||
|
return StringConverter.asString(fStyle);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/**
|
||||||
|
* 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.dialogs.Dialog;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for selecting line width
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LineWidthDialog extends Dialog {
|
||||||
|
int width;
|
||||||
|
|
||||||
|
private int min;
|
||||||
|
|
||||||
|
private int max;
|
||||||
|
|
||||||
|
protected LineWidthDialog(Shell parentShell, int width, int min, int max) {
|
||||||
|
super(parentShell);
|
||||||
|
this.width = width;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite comp = (Composite) super.createDialogArea(parent);
|
||||||
|
Label label = new Label(comp, SWT.CENTER);
|
||||||
|
label.setText("Double-Click to select");
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
label.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
Display d = comp.getDisplay();
|
||||||
|
Table table = new Table(comp, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
|
||||||
|
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
layoutData.heightHint = table.getItemHeight()
|
||||||
|
* Math.min(10, max - min + 1);
|
||||||
|
table.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
for (int w = min; w <= max; w++) {
|
||||||
|
TableItem item = new TableItem(table, SWT.NONE);
|
||||||
|
Image image = new Image(d, 128, 10);
|
||||||
|
Rectangle bounds = image.getBounds();
|
||||||
|
GC gc = new GC(image);
|
||||||
|
gc.fillRectangle(bounds);
|
||||||
|
gc.setLineWidth(w);
|
||||||
|
gc.drawLine(bounds.x, bounds.y + bounds.height / 2,
|
||||||
|
bounds.width - 1, bounds.y + bounds.height / 2);
|
||||||
|
|
||||||
|
gc.dispose();
|
||||||
|
item.setImage(image);
|
||||||
|
image.dispose();
|
||||||
|
item.setData(w);
|
||||||
|
|
||||||
|
if (w == this.width) {
|
||||||
|
table.setSelection(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
Table table = (Table) e.widget;
|
||||||
|
TableItem item = table.getSelection()[0];
|
||||||
|
width = (Integer) item.getData();
|
||||||
|
okPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createButtonBar(Composite parent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/**
|
||||||
|
* 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.window.Window;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference field editor for selecting a line width for DataStoreResource
|
||||||
|
* highlight
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LineWidthFieldEditor extends AbstractFieldEditor {
|
||||||
|
private static final int MAX_WIDTH = 5;
|
||||||
|
|
||||||
|
private static final int MIN_WIDTH = 1;
|
||||||
|
|
||||||
|
private static int DEFAULT_WIDTH = 2;
|
||||||
|
|
||||||
|
private int fWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public LineWidthFieldEditor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param labelText
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
public LineWidthFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
super(name, labelText, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#updateImage()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void updateImage() {
|
||||||
|
super.updateImage();
|
||||||
|
fImage = new Image(fButton.getDisplay(), fExtent.x, fExtent.y);
|
||||||
|
GC gc = new GC(fImage);
|
||||||
|
// gc.setBackground(fButton.getBackground());
|
||||||
|
gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
|
||||||
|
int y = fExtent.y / 2;
|
||||||
|
gc.setLineWidth(this.fWidth);
|
||||||
|
gc.drawLine(0, y, fExtent.x, y);
|
||||||
|
gc.dispose();
|
||||||
|
fButton.setImage(fImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#open()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
LineWidthDialog dlg = new LineWidthDialog(fButton.getShell(), fWidth,
|
||||||
|
MIN_WIDTH, MAX_WIDTH);
|
||||||
|
if (dlg.open() == Window.OK) {
|
||||||
|
this.fWidth = dlg.getWidth();
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#setValueFromString
|
||||||
|
* (java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void setValueFromString(String value) {
|
||||||
|
int width = MIN_WIDTH;
|
||||||
|
Integer i = StringConverter.asInteger(value);
|
||||||
|
if (i != null) {
|
||||||
|
width = i.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width < MIN_WIDTH) {
|
||||||
|
this.fWidth = MIN_WIDTH;
|
||||||
|
} else if (width > MAX_WIDTH) {
|
||||||
|
this.fWidth = MAX_WIDTH;
|
||||||
|
} else {
|
||||||
|
this.fWidth = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#getStringFromValue
|
||||||
|
* ()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String getStringFromValue() {
|
||||||
|
return StringConverter.asString(this.fWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
/**
|
||||||
|
* 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.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.dialogs.SetOpacityDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference field editor for selecting the opacity of a DataStoreResource when
|
||||||
|
* loaded as a product
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 13, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class OpacityFieldEditor extends AbstractFieldEditor {
|
||||||
|
private static final RGB COLOR = new RGB(0, 255, 255);
|
||||||
|
|
||||||
|
protected float fOpacity;
|
||||||
|
|
||||||
|
protected OpacityFieldEditor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a line opacity field editor.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the name of the preference this field editor works on
|
||||||
|
* @param labelText
|
||||||
|
* the label text of the field editor
|
||||||
|
* @param parent
|
||||||
|
* the parent of the field editor's control
|
||||||
|
*/
|
||||||
|
public OpacityFieldEditor(String name, String labelText, Composite parent) {
|
||||||
|
super(name, labelText, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init(String name, String text) {
|
||||||
|
super.init(name, text);
|
||||||
|
this.fOpacity = 0.35f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void adjustForNumColumns(int numColumns) {
|
||||||
|
((GridData) fButton.getLayoutData()).horizontalSpan = numColumns - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getNumberOfControls() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.uf.viz.gisdatastore.ui.AbstractFieldEditor#open()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void open() {
|
||||||
|
SetOpacityDialog dlg = new SetOpacityDialog(fButton.getShell(),
|
||||||
|
fOpacity, COLOR);
|
||||||
|
if (dlg.open() == Window.OK) {
|
||||||
|
this.fOpacity = dlg.getOpacity();
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateImage() {
|
||||||
|
super.updateImage();
|
||||||
|
fImage = new Image(fButton.getDisplay(), fExtent.x, fExtent.y);
|
||||||
|
GC gc = new GC(fImage);
|
||||||
|
|
||||||
|
Rectangle rect1 = fImage.getBounds();
|
||||||
|
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
gc.fillRectangle(rect1);
|
||||||
|
|
||||||
|
int dx = rect1.width / 5;
|
||||||
|
int dy = rect1.height / 5;
|
||||||
|
|
||||||
|
Rectangle rect2 = new Rectangle(rect1.x + dx, rect1.y + dy, rect1.width
|
||||||
|
- 2 * dx, rect1.height - 2 * dy);
|
||||||
|
gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
|
||||||
|
gc.drawRectangle(rect2);
|
||||||
|
|
||||||
|
Color color = new Color(gc.getDevice(), COLOR);
|
||||||
|
gc.setBackground(color);
|
||||||
|
gc.setAlpha((int) (fOpacity * 255));
|
||||||
|
gc.fillRectangle(rect1);
|
||||||
|
color.dispose();
|
||||||
|
|
||||||
|
gc.dispose();
|
||||||
|
fButton.setImage(fImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setValueFromString(String value) {
|
||||||
|
Float opacity = StringConverter.asFloat(value);
|
||||||
|
if (opacity == null) {
|
||||||
|
this.fOpacity = 0.35f;
|
||||||
|
} else {
|
||||||
|
this.fOpacity = opacity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getStringFromValue() {
|
||||||
|
return StringConverter.asString(fOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,201 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.gisdatastore.ui;
|
||||||
|
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
|
import com.raytheon.uf.viz.core.RGBColors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility for loading and saving GIS Viewer preferences
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PreferenceConverter {
|
||||||
|
private PreferenceConverter() {
|
||||||
|
// unused, all methods are static
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an RGB color preference value. If no preference is stored,
|
||||||
|
* defaultValue will be returned
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param defaultValue
|
||||||
|
* the default value
|
||||||
|
* @return the RGB color
|
||||||
|
*/
|
||||||
|
public static RGB getRGB(IPreferenceStore prefs, String key,
|
||||||
|
String defaultValue) {
|
||||||
|
String value = prefs.getString(key);
|
||||||
|
RGB newColor = StringConverter.asRGB(value);
|
||||||
|
|
||||||
|
if (newColor == null) {
|
||||||
|
newColor = StringConverter.asRGB(defaultValue);
|
||||||
|
}
|
||||||
|
return newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store an RGB color preference value.
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param color
|
||||||
|
* the RGB color to be stored
|
||||||
|
*/
|
||||||
|
public static void setValue(IPreferenceStore prefs, String key, RGB color) {
|
||||||
|
String value = RGBColors.getColorName(color);
|
||||||
|
prefs.setValue(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a LineStyle value. If no preference is stored, defaultValue will be
|
||||||
|
* returned
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param defaultValue
|
||||||
|
* the default value
|
||||||
|
* @return the LineStyle
|
||||||
|
*/
|
||||||
|
public static LineStyle getLineStyle(IPreferenceStore prefs, String key,
|
||||||
|
String defaultValue) {
|
||||||
|
String value = prefs.getString(key);
|
||||||
|
LineStyle style = StringConverter.asLineStyle(value);
|
||||||
|
|
||||||
|
if (style == null) {
|
||||||
|
style = StringConverter.asLineStyle(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a LineStyle preference value.
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param opacity
|
||||||
|
* the LineStyle to be stored
|
||||||
|
*/
|
||||||
|
public static void setValue(IPreferenceStore prefs, String key,
|
||||||
|
LineStyle style) {
|
||||||
|
String value = style.name();
|
||||||
|
prefs.setValue(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an integer preference value. If no preference is stored, defaultValue
|
||||||
|
* will be returned
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param defaultValue
|
||||||
|
* the default value
|
||||||
|
* @return the integer value
|
||||||
|
*/
|
||||||
|
public static int getInt(IPreferenceStore prefs, String key,
|
||||||
|
String defaultValue) {
|
||||||
|
String stringValue = prefs.getString(key);
|
||||||
|
Integer value = StringConverter.asInteger(stringValue);
|
||||||
|
if (value == null) {
|
||||||
|
value = StringConverter.asInteger(defaultValue);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store an integer preference value.
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param value
|
||||||
|
* the integer value to be stored
|
||||||
|
*/
|
||||||
|
public static void setValue(IPreferenceStore prefs, String key, int value) {
|
||||||
|
String stringValue = StringConverter.asString(value);
|
||||||
|
prefs.setValue(key, stringValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an float preference value. If no preference is stored, defaultValue
|
||||||
|
* will be returned
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param defaultValue
|
||||||
|
* the default value
|
||||||
|
* @return the float value
|
||||||
|
*/
|
||||||
|
public static float getFloat(IPreferenceStore prefs, String key,
|
||||||
|
String defaultValue) {
|
||||||
|
String stringValue = prefs.getString(key);
|
||||||
|
Float value = StringConverter.asFloat(stringValue);
|
||||||
|
if (value == null) {
|
||||||
|
value = StringConverter.asFloat(defaultValue);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store an float preference value.
|
||||||
|
*
|
||||||
|
* @param prefs
|
||||||
|
* the preference store
|
||||||
|
* @param key
|
||||||
|
* the preference key
|
||||||
|
* @param value
|
||||||
|
* the float value to be stored
|
||||||
|
*/
|
||||||
|
public static void setValue(IPreferenceStore prefs, String key, float value) {
|
||||||
|
String stringValue = StringConverter.asString(value);
|
||||||
|
prefs.setValue(key, stringValue);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**
|
||||||
|
* 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.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.List;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResource;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Add Description
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Dec 13, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SelectAttributeDialog extends CaveJFACEDialog {
|
||||||
|
|
||||||
|
private DataStoreResource rsc;
|
||||||
|
|
||||||
|
private String originalSampleAttribute;
|
||||||
|
|
||||||
|
public SelectAttributeDialog(Shell parentShell, DataStoreResource rsc) {
|
||||||
|
super(parentShell);
|
||||||
|
this.rsc = rsc;
|
||||||
|
this.originalSampleAttribute = rsc.getSampleAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
newShell.setText("Select Sample Attribute");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite comp = (Composite) super.createDialogArea(parent);
|
||||||
|
|
||||||
|
List attrList = new List(comp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL
|
||||||
|
| SWT.H_SCROLL);
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
attrList.setItems(rsc.getAttributeNames());
|
||||||
|
if (attrList.getItemCount() > 20) {
|
||||||
|
layoutData.heightHint = attrList.getItemHeight() * 20;
|
||||||
|
}
|
||||||
|
attrList.setLayoutData(layoutData);
|
||||||
|
|
||||||
|
if (originalSampleAttribute != null) {
|
||||||
|
attrList.setSelection(new String[] { originalSampleAttribute });
|
||||||
|
}
|
||||||
|
attrList.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
List list = (List) e.widget;
|
||||||
|
String attr = list.getSelection()[0];
|
||||||
|
rsc.setSampleAttribute(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
List list = (List) e.widget;
|
||||||
|
String attr = list.getSelection()[0];
|
||||||
|
rsc.setSampleAttribute(attr);
|
||||||
|
okPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void cancelPressed() {
|
||||||
|
rsc.setSampleAttribute(originalSampleAttribute);
|
||||||
|
super.cancelPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,234 @@
|
||||||
|
/**
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.dataplugin.gfe.type.Pair;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog to allow the user to define the sort order for the
|
||||||
|
* {@link AttributeViewer}
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 29, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SortOrderDialog extends CaveJFACEDialog {
|
||||||
|
private class SortField {
|
||||||
|
public static final int ASCENDING_VALUE = 1;
|
||||||
|
|
||||||
|
public static final int DESCENDING_VALUE = -1;
|
||||||
|
|
||||||
|
private static final String ASCENDING_TEXT = "Ascending";
|
||||||
|
|
||||||
|
private static final String DESCENDING_TEXT = "Descending";
|
||||||
|
|
||||||
|
private Group group;
|
||||||
|
|
||||||
|
private Combo columnCombo;
|
||||||
|
|
||||||
|
private Combo orderCombo;
|
||||||
|
|
||||||
|
public SortField(Composite parent) {
|
||||||
|
group = new Group(parent, SWT.DEFAULT);
|
||||||
|
GridData layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true,
|
||||||
|
false);
|
||||||
|
group.setLayoutData(layoutData);
|
||||||
|
GridLayout layout = new GridLayout(2, false);
|
||||||
|
group.setLayout(layout);
|
||||||
|
group.setText("Then by:");
|
||||||
|
|
||||||
|
columnCombo = new Combo(group, SWT.DROP_DOWN);
|
||||||
|
layoutData = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||||
|
columnCombo.setLayoutData(layoutData);
|
||||||
|
columnCombo.add("", 0);
|
||||||
|
columnCombo.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
updateFields();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
orderCombo = new Combo(group, SWT.DROP_DOWN);
|
||||||
|
layoutData = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||||
|
orderCombo.setLayoutData(layoutData);
|
||||||
|
orderCombo.add(ASCENDING_TEXT);
|
||||||
|
orderCombo.add(DESCENDING_TEXT);
|
||||||
|
orderCombo.setText(orderCombo.getItem(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
group.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return columnCombo.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(String field) {
|
||||||
|
this.columnCombo.setText(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return (orderCombo.getText().equals(ASCENDING_TEXT) ? ASCENDING_VALUE
|
||||||
|
: DESCENDING_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(int order) {
|
||||||
|
if (order > 0) {
|
||||||
|
orderCombo.setText(ASCENDING_TEXT);
|
||||||
|
} else if (order < 0) {
|
||||||
|
orderCombo.setText(DESCENDING_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<String> fields) {
|
||||||
|
String currentField = getField();
|
||||||
|
columnCombo.removeAll();
|
||||||
|
columnCombo.add("");
|
||||||
|
for (String f : fields) {
|
||||||
|
columnCombo.add(f);
|
||||||
|
}
|
||||||
|
if (fields.contains(currentField)) {
|
||||||
|
columnCombo.setText(currentField);
|
||||||
|
} else {
|
||||||
|
columnCombo.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
group.setText(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] columns;
|
||||||
|
|
||||||
|
private List<Pair<String, Integer>> initialOrder;
|
||||||
|
|
||||||
|
private Composite mainComp;
|
||||||
|
|
||||||
|
private List<SortField> sortFields;
|
||||||
|
|
||||||
|
protected SortOrderDialog(Shell parentShell, String[] columns,
|
||||||
|
List<Pair<String, Integer>> order) {
|
||||||
|
super(parentShell);
|
||||||
|
this.columns = columns;
|
||||||
|
this.initialOrder = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureShell(Shell newShell) {
|
||||||
|
super.configureShell(newShell);
|
||||||
|
newShell.setText("Sort Order");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
mainComp = (Composite) super.createDialogArea(parent);
|
||||||
|
|
||||||
|
this.sortFields = new ArrayList<SortField>();
|
||||||
|
for (Pair<String, Integer> p : initialOrder) {
|
||||||
|
addField(p.getFirst(), p.getSecond());
|
||||||
|
}
|
||||||
|
updateFields();
|
||||||
|
|
||||||
|
return mainComp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SortField addField(String field, int order) {
|
||||||
|
SortField newField = new SortField(mainComp);
|
||||||
|
newField.setField(field);
|
||||||
|
newField.setOrder(order);
|
||||||
|
sortFields.add(newField);
|
||||||
|
return newField;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeField(SortField field) {
|
||||||
|
sortFields.remove(field);
|
||||||
|
field.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFields() {
|
||||||
|
List<String> availableFields = new ArrayList<String>(
|
||||||
|
Arrays.asList(columns));
|
||||||
|
for (int i = 0; i < sortFields.size(); i++) {
|
||||||
|
SortField sf = sortFields.get(i);
|
||||||
|
sf.setFields(availableFields);
|
||||||
|
String s = sf.getField();
|
||||||
|
if (s.isEmpty()) {
|
||||||
|
if (i < sortFields.size() - 1) {
|
||||||
|
removeField(sf);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
availableFields.remove(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortFields.isEmpty()
|
||||||
|
|| !sortFields.get(sortFields.size() - 1).getField().isEmpty()) {
|
||||||
|
SortField sf = addField("", SortField.ASCENDING_VALUE);
|
||||||
|
sf.setFields(availableFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
sortFields.get(0).setLabel("Sort by:");
|
||||||
|
|
||||||
|
mainComp.getShell().pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Pair<String, Integer>> getSortOrder() {
|
||||||
|
List<Pair<String, Integer>> sortOrder = new ArrayList<Pair<String, Integer>>();
|
||||||
|
for (SortField sf : sortFields) {
|
||||||
|
if (sf.getField().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sortOrder.add(new Pair<String, Integer>(sf.getField(), sf
|
||||||
|
.getOrder()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sortOrder;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.gisdatastore.ui;
|
||||||
|
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||||
|
import com.raytheon.uf.viz.core.RGBColors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert GIS Viewer preference types to/from strings
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Nov 27, 2012 randerso Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author randerso
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class StringConverter {
|
||||||
|
private StringConverter() {
|
||||||
|
// unused, all methods are static
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert RGB color value to string
|
||||||
|
*
|
||||||
|
* @param color
|
||||||
|
* RGB color value
|
||||||
|
* @return string String value
|
||||||
|
*/
|
||||||
|
public static String asString(RGB color) {
|
||||||
|
return RGBColors.getColorName(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string to RGB color value
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* String value
|
||||||
|
* @return RGB color value or null if string is not a valid RGB color name
|
||||||
|
* or hex value of the form "#rrggbb"
|
||||||
|
*/
|
||||||
|
public static RGB asRGB(String string) {
|
||||||
|
RGB rgb = RGBColors.getRGBColor(string);
|
||||||
|
return rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert LineStyle value to string
|
||||||
|
*
|
||||||
|
* @param opacity
|
||||||
|
* LineStyle value
|
||||||
|
* @return string String value
|
||||||
|
*/
|
||||||
|
public static String asString(LineStyle style) {
|
||||||
|
return style.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string to LineStyle value
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* String value
|
||||||
|
* @return LineStyle value or null if string is not a valid LineStyle name
|
||||||
|
*/
|
||||||
|
public static LineStyle asLineStyle(String string) {
|
||||||
|
LineStyle style = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
style = LineStyle.valueOf(string);
|
||||||
|
} catch (Exception e) {
|
||||||
|
style = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert integer value to string
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* integer value
|
||||||
|
* @return string String value
|
||||||
|
*/
|
||||||
|
public static String asString(int value) {
|
||||||
|
return Integer.toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string to Integer value
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* String Value
|
||||||
|
* @return Integer value or null if string is not a valid integer
|
||||||
|
* representation
|
||||||
|
*/
|
||||||
|
public static Integer asInteger(String string) {
|
||||||
|
Integer value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
value = Integer.parseInt(string);
|
||||||
|
} catch (Exception e) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert float value to string
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* float value
|
||||||
|
* @return string String value
|
||||||
|
*/
|
||||||
|
public static String asString(float value) {
|
||||||
|
return Float.toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert string to Float value
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* String Value
|
||||||
|
* @return Float value or null if string is not a valid float representation
|
||||||
|
*/
|
||||||
|
public static Float asFloat(String string) {
|
||||||
|
Float value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
value = Float.parseFloat(string);
|
||||||
|
} catch (Exception e) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue