[Commits] r1700 - in sandbox/cmoullet/ux/LayerManager: examples ux/data ux/widgets
commits at geoext.org
commits at geoext.org
Sun Jan 10 20:21:22 CET 2010
Author: cmoullet
Date: 2010-01-10 20:21:21 +0100 (Sun, 10 Jan 2010)
New Revision: 1700
Modified:
sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch
sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportWindow.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js
Log:
Documentation !
Modified: sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/examples/KML.js.patch 2010-01-10 19:21:21 UTC (rev 1700)
@@ -1097,7 +1097,7 @@
+ }
+
+ // Get the poly style
-+ if (feature.style.fillColor && feature.style.fillOpacity) {
++ if (feature.style.fillColor && (feature.style.fillColor != "none") && feature.style.fillOpacity) {
+ var polystyleNode = this.createElementNS(this.kmlns, "PolyStyle");
+ // Stroke color and opacity
+ if (feature.style.fillColor && feature.style.fillOpacity) {
@@ -1252,7 +1252,7 @@
point = points[i];
parts[i] = point.x + "," + point.y;
}
-@@ -1238,12 +1364,45 @@
+@@ -1238,12 +1364,46 @@
// Point
path = geometry.x + "," + geometry.y;
}
@@ -1284,6 +1284,7 @@
+ var matches = (color_code.toString()).match(this.regExes.color);
+
+ return opacityHex.toString() + matches[3].toString() + matches[2].toString() + matches[1].toString();
++
+ },
+
+ /**
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -8,8 +8,16 @@
Ext.namespace("GeoExt.ux.data");
-// layers: optional {Array(<OpenLayers.Layer>)}
-// features: optional: {Array(<OpenLayers.Feature.Vector>)}
+/** static: method[GeoExt.ux.data.Export]
+ * Export the data
+ *
+ * :param map ``OpenLayers.Map`` Map.
+ * :param format ``String`` Output format. Supported: KML, GeoJSON, GeoRSS, GML
+ * :param layers ``Array(OpenLayers.Layer)`` (Optional) Array of layers. Supported: 'OpenLayers.Layer.Vector','OpenLayers.Layer.WFS','OpenLayers.Layer.GML','OpenLayers.Layer.GeoRSS'. If null, all supported layers of thd map are exported.
+ * :param features ``Array(OpenLayers.Feature.Vector)`` (Optional) Array of features. If null, all features of the layers are exported.
+ *
+ * :return: ``String`` Exported data.
+ */
GeoExt.ux.data.Export = function(map, format, layers, features) {
var exportLayers = [];
var exportFeatures = [];
@@ -57,12 +65,24 @@
}
};
+/** static: property[GeoExt.ux.data.Export.content]
+* ``String`` Export content
+*/
GeoExt.ux.data.Export.content = null;
+/** static: property[GeoExt.ux.data.Export.format]
+* ``String`` Export format
+*/
GeoExt.ux.data.Export.format = null;
+/** static: property[GeoExt.ux.data.Export.format]
+* ``GeoExt.ux.LayerManagerExportWindow`` Export window
+*/
GeoExt.ux.data.Export.exportWindow = null;
+/** static: property[GeoExt.ux.data.Export.SupportedLayerType]
+* ``Array(String)`` Array of supported layer type: 'OpenLayers.Layer.Vector','OpenLayers.Layer.WFS','OpenLayers.Layer.GML','OpenLayers.Layer.GeoRSS'
+*/
GeoExt.ux.data.Export.SupportedLayerType = [
['OpenLayers.Layer.Vector'],
['OpenLayers.Layer.WFS'],
@@ -70,6 +90,13 @@
['OpenLayers.Layer.GeoRSS']
];
+/** static: method[GeoExt.ux.data.Export.isLayerSupported]
+ * Defines if a layer class is supported
+ *
+ * :param className ``String`` OpenLayers class name.
+ *
+ * :return: ``Boolean``
+ */
GeoExt.ux.data.Export.isLayerSupported = function(className) {
for (var i = 0; i < GeoExt.ux.data.Export.SupportedLayerType.length; i++) {
if (GeoExt.ux.data.Export.SupportedLayerType[i][0] === className) {
@@ -79,14 +106,26 @@
return false;
};
+/** static: method[GeoExt.ux.data.Export.OpenWindowDownloadify]
+ * Open an export window with downloadify flash add-in
+ *
+ */
GeoExt.ux.data.Export.OpenWindowDownloadify = function() {
- var exportWindow = new GeoExt.ux.LayerManagerExportWindow({
+ GeoExt.ux.data.Export.exportWindow = new GeoExt.ux.LayerManagerExportWindow({
filename: 'export.' + GeoExt.ux.data.Export.format.toLowerCase(),
filecontent: GeoExt.ux.data.Export.content.replace(/</g, '<').replace(/>/g, '>')
});
- exportWindow.show();
+ GeoExt.ux.data.Export.exportWindow.show();
};
+/** static: method[GeoExt.ux.data.Export.KMLExport]
+ * Shortcut to export as KML
+ *
+ * :param map ``OpenLayers.Map`` Map.
+ * :param layers ``Array(OpenLayers.Layer)`` (Optional) Array of layers. Supported: 'OpenLayers.Layer.Vector','OpenLayers.Layer.WFS','OpenLayers.Layer.GML','OpenLayers.Layer.GeoRSS'. If null, all supported layers of thd map are exported.
+ * :param features ``Array(OpenLayers.Feature.Vector)`` (Optional) Array of features. If null, all features of the layers are exported.
+ *
+ */
GeoExt.ux.data.Export.KMLExport = function(map, layers, features) {
GeoExt.ux.data.Export.format = 'KML';
GeoExt.ux.data.Export.content = GeoExt.ux.data.Export(map, GeoExt.ux.data.Export.format, layers, features);
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -8,6 +8,9 @@
Ext.namespace("GeoExt.ux.data");
+/** static: property[GeoExt.ux.data.formats]
+ * ``Array(Array(String))`` Array of format desctiption with shortName, OpenLayers class and format config
+ */
GeoExt.ux.data.formats = [
['KML', 'OpenLayers.Format.KML', {
extractStyles: true,
@@ -19,17 +22,26 @@
['GML', 'OpenLayers.Format.GML',{}]
];
+/** static: method[GeoExt.ux.data.formats.getFormatConfig]
+ * Get the format config object
+ *
+ * :param format ``String`` Format short name.
+ *
+ * :return: ``Object`` Config object
+ */
GeoExt.ux.data.formats.getFormatConfig = function(format) {
for (var i = 0; i < GeoExt.ux.data.formats.length; i++) {
if (GeoExt.ux.data.formats[i][0] == format) {
return GeoExt.ux.data.formats[i][2];
}
}
-
};
+/** static: property[GeoExt.ux.data.FormatStore]
+ * ``Ext.data.SimpleStore`` Store containing the formats. Three attributes: 'shortName', 'openLayersClass' and 'formatConfig'
+ */
GeoExt.ux.data.FormatStore = new Ext.data.SimpleStore({
- fields: ['shortName', 'openLayersClass', 'formatExportConfig'],
+ fields: ['shortName', 'openLayersClass', 'formatConfig'],
data: GeoExt.ux.data.formats
});
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Import.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Import.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -10,8 +10,17 @@
GeoExt.ux.data.importFeatures = null;
-// layer: optional {<OpenLayers.Layer>}
-// features: optional: {Array(<OpenLayers.Feature.Vector>)}
+/** static: method[GeoExt.ux.data.Import]
+ * Import the data
+ *
+ * :param map ``OpenLayers.Map`` Map.
+ * :param layer ``OpenLayers.Layer.Vector`` (Optional) Layer. If null, a layer named Import is created in the map.
+ * :param format ``String`` Input format. Supported: KML, GML, GeoJSON and GeoRSS. Mandatory together with filecontent.
+ * :param filecontent ``String`` The information contained in the import file. Mandatory together with format.
+ * :param features ``Array(OpenLayers.Feature.Vector)`` (Optional) Array of features.
+ *
+ * :return: ``String`` Exported data.
+ */
GeoExt.ux.data.Import = function(map, layer, format, filecontent, features) {
GeoExt.ux.data.Import.importFeatures = [];
@@ -19,6 +28,15 @@
if (format == 'KML') {
var kmlReader = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
GeoExt.ux.data.importFeatures = kmlReader.read(filecontent);
+ } else if (format == 'GML') {
+ var gmlReader = new OpenLayers.Format.GML(GeoExt.ux.data.formats.getFormatConfig(format));
+ GeoExt.ux.data.importFeatures = gmlReader.read(filecontent);
+ } else if (format == 'GeoJSON') {
+ var geojsonReader = new OpenLayers.Format.GeoJSON(GeoExt.ux.data.formats.getFormatConfig(format));
+ GeoExt.ux.data.importFeatures = geojsonReader.read(filecontent);
+ } else if (format == 'GeoRSS') {
+ var georssReader = new OpenLayers.Format.GeoRSS(GeoExt.ux.data.formats.getFormatConfig(format));
+ GeoExt.ux.data.importFeatures = georssReader.read(filecontent);
} else {
return 'Format ' + format + ' not supported. Patch welcome !';
}
@@ -27,6 +45,7 @@
if (features) {
GeoExt.ux.data.importFeatures = features;
}
+
if (!layer) {
layer = new OpenLayers.Layer.Vector("Import", {
projection: map.displayProjection
@@ -37,6 +56,13 @@
layer.addFeatures(GeoExt.ux.data.importFeatures);
};
+/** static: method[GeoExt.ux.data.Import.KMLImport]
+ * Shortcut to import as KML
+ *
+ * :param map ``OpenLayers.Map`` Map.
+ * :param layer ``OpenLayers.Layer.Vector`` (Optional) Layer. If null, a layer named Import is created in the map.
+ *
+ */
GeoExt.ux.data.Import.KMLImport = function(map, layer) {
GeoExt.ux.data.Export.format = 'KML';
var importPanel = new GeoExt.ux.LayerManagerImportPanel({
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportPanel.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -204,4 +204,5 @@
}
});
+/** api: xtype = gxux_layermanagerexportpanel */
Ext.reg('gxux_layermanagerexportpanel', GeoExt.ux.LayerManagerExportPanel);
\ No newline at end of file
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportWindow.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportWindow.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerExportWindow.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -8,22 +8,100 @@
Ext.namespace('GeoExt.ux');
+/** private: property[scriptSource]
+ * ``String`` Source of this script: complete URL
+ */
+var scriptSource = (function() {
+ var scripts = document.getElementsByTagName('script'),
+ script = scripts[scripts.length - 1];
+
+ if (script.getAttribute.length !== undefined) {
+ return script.src;
+ }
+
+ return script.getAttribute('src', -1);
+}());
+
+/** api: (define)
+ * module = GeoExt.ux
+ * class = LayerManagerExportWindow
+ * base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Window>`_
+ */
+
GeoExt.ux.LayerManagerExportWindow = Ext.extend(Ext.Window, {
+ /** private: property[id]
+ * ``String`` id set to layermanagerexportwindow (don't change it)
+ */
id: 'layermanagerexportwindow',
+
+ /** private: property[modal]
+ * ``Boolean`` Define the window as modal.
+ */
modal: true,
+
+ /** private: property[title]
+ * ``String`` Define the title of the window: OpenLayers.i18n('Export Window')
+ */
title: OpenLayers.i18n('Export Window'),
+
+ /** private: property[width]
+ * ``Number`` Width of the window: 500
+ */
width: 500,
+
+ /** private: property[height]
+ * ``Number`` Height of the window: 300
+ */
height:300,
+
+ /** private: property[minWidth]
+ * ``Number`` Minimal width of the window: 300
+ */
minWidth: 300,
+
+ /** private: property[minHeight]
+ * ``Number`` Minimal height of the window: 200
+ */
minHeight: 200,
+
+ /** private: property[layout]
+ * ``String`` Layout set to absolute
+ */
layout:'absolute',
+
+ /** private: property[plain]
+ * ``Boolean`` Plain set to true
+ */
plain:true,
+
+ /** private: property[bodyStyle]
+ * ``String`` Body style set to 'padding:5px;'
+ */
bodyStyle:'padding:5px;',
+
+ /** private: property[filename]
+ * ``String`` Export filename set by the window
+ */
filename: null,
+
+ /** private: property[filecontent]
+ * ``String`` Export filecontent
+ */
filecontent: null,
+
+ /** private: property[downloadifyBox]
+ * ``Ext.BoxComponent`` Box use to present the downloadify button
+ */
downloadifyBox: null,
+
+ /** private: property[downloadifyLoaded]
+ * ``Boolean`` Flag used to check that downloadify has been used
+ */
downloadifyLoaded: false,
+ /** private: method[initComponent]
+ * Private initComponent override.
+ */
initComponent: function() {
this.downloadifyBox = new Ext.BoxComponent({
x: 405,
@@ -65,7 +143,7 @@
this.on(
'afterlayout', function() {
var el = Ext.get('downloadify');
- var baseUrl = scriptSource.replace('/widgets/LayerManagerExportWindow.js','');
+ var baseUrl = scriptSource.replace('/widgets/LayerManagerExportWindow.js', '');
if (el && !this.downloadifyLoaded && GetFlashVersion() >= 10.00) {
Downloadify.create('downloadify', {
filename: function() {
@@ -97,13 +175,5 @@
}
});
-var scriptSource = (function() {
- var scripts = document.getElementsByTagName('script'),
- script = scripts[scripts.length - 1];
-
- if (script.getAttribute.length !== undefined) {
- return script.src
- }
-
- return script.getAttribute('src', -1)
-}());
\ No newline at end of file
+/** api: xtype = gxux_layermanagerexportwindow */
+Ext.reg('gxux_layermanagerexportwindow', GeoExt.ux.LayerManagerExportWindow);
\ No newline at end of file
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -8,12 +8,48 @@
Ext.namespace('GeoExt.ux');
+/** api: (define)
+ * module = GeoExt.ux
+ * class = LayerManagerImportPanel
+ * base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Panel>`_
+ */
+
GeoExt.ux.LayerManagerImportPanel = Ext.extend(Ext.Panel, {
+ /** api: config[map]
+ * ``OpenLayers.Map`` A configured map
+ */
+ /** private: property[map]
+ * ``OpenLayers.Map`` The map object.
+ */
+ map: null,
+
+ /** api: config[border]
+ * ``Boolean`` Default to false
+ */
+ /** private: property[border]
+ * ``Boolean`` Default to false
+ */
border: false,
- formatCombo: null,
+
+ /** api: config[defaultFormat]
+ * ``String`` Default export format. Default: KML
+ */
+ /** private: property[defaultFormat]
+ * ``String`` Default export format. Default: KML
+ */
defaultFormat: 'KML',
+
layer: null,
+ /** private: property[formatCombo]
+ * ``Ext.form.ComboBox`` Combo box with format information
+ */
+ formatCombo: null,
+
+
+ /** private: method[initComponent]
+ * Private initComponent override.
+ */
initComponent: function() {
this.formatCombo = new Ext.form.ComboBox({
@@ -108,27 +144,24 @@
if (Ext.isIE) {
try {
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
+ if (objFSO.FileExists(document.getElementById('fileselector').value)) {
+ filecontent = objFSO.OpenTextFile(document.getElementById('fileselector').value, 1).ReadAll();
+ }
}
catch (e)
{
alert('Dear IE user. Add this site in the list of trusted site and activate the ActiveX. ' + e.description);
return;
}
- if (objFSO.FileExists(document.getElementById('fileselector').value)) {
- filecontent = objFSO.OpenTextFile(document.getElementById('fileselector').value, 1).ReadAll();
- }
- this.fireEvent('beforedataimported', this, this.formatCombo.getValue(), filecontent);
- GeoExt.ux.data.Import(this.map, this.layer, this.formatCombo.getValue(), filecontent, null);
- this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent, GeoExt.ux.data.importFeatures);
} else if (Ext.isGecko) {
filecontent = document.getElementById('fileselector').files.item(0).getAsText('UTF-8');
- this.fireEvent('beforedataimported', this, this.formatCombo.getValue(), filecontent);
- GeoExt.ux.data.Import(this.map, this.layer, this.formatCombo.getValue(), filecontent, null);
- this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent, GeoExt.ux.data.importFeatures);
} else {
alert('Your browser is not supported. Patch welcome !');
+ return;
}
- //alert(document.getElementById('fileselector').value);
+ this.fireEvent('beforedataimported', this, this.formatCombo.getValue(), filecontent);
+ GeoExt.ux.data.Import(this.map, this.layer, this.formatCombo.getValue(), filecontent, null);
+ this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent, GeoExt.ux.data.importFeatures);
}
},
scope: this
@@ -161,8 +194,8 @@
*/
'beforedataimported');
GeoExt.ux.LayerManagerImportPanel.superclass.initComponent.call(this);
- },
- onRender: function(container, position) {
- GeoExt.ux.LayerManagerImportPanel.superclass.onRender.apply(this, arguments);
}
-});
\ No newline at end of file
+});
+
+/** api: xtype = gxux_layermanagerimportpanel */
+Ext.reg('gxux_layermanagerimportpanel', GeoExt.ux.LayerManagerImportPanel);
\ No newline at end of file
Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js 2010-01-10 17:05:41 UTC (rev 1699)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerWindow.js 2010-01-10 19:21:21 UTC (rev 1700)
@@ -8,18 +8,77 @@
Ext.namespace('GeoExt.ux');
+/** api: (define)
+ * module = GeoExt.ux
+ * class = LayerManagerWindow
+ * base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Window>`_
+ */
+
GeoExt.ux.LayerManagerWindow = Ext.extend(Ext.Window, {
+ /** api: config[map]
+ * ``OpenLayers.Map`` A configured map
+ */
+ /** private: property[map]
+ * ``OpenLayers.Map`` The map object.
+ */
+ map: null,
+
+ /** api: config[downloadService]
+ * ``String`` URL used in order to use a server download service. The attributes "format", "content" are sent (POST) to this service.
+ */
+ /** private: property[defaultFormat]
+ * ``String`` URL used in order to use a server download service. The attributes "format", "content" are sent (POST) to this service.
+ */
+ downloadService: null,
+
+ /** private: property[id]
+ * ``String`` id set to layermanagerwindow (don't change it)
+ */
id: 'layermanagerwindow',
+
+ /** private: property[modal]
+ * ``Boolean`` Define the window as modal.
+ */
modal: true,
+
+ /** private: property[title]
+ * ``String`` Define the title of the window: OpenLayers.i18n('Layer Manager')
+ */
title: OpenLayers.i18n('Layer Manager'),
+
+ /** private: property[width]
+ * ``Number`` Width of the window: 275
+ */
+ width: 275,
+
+ /** private: property[height]
+ * ``Number`` Height of the window: 400
+ */
height: 400,
- width: 275,
+
+ /** private: property[layout]
+ * ``String`` Layout set to accordion
+ */
layout: 'accordion',
+
+ /** private: property[layoutConfig]
+ * ``Object`` Layout config set to animate:true
+ */
layoutConfig: {animate:true},
- downloadService: null,
- importPanel: null,
+
+ /** property[exportPanel]
+ * ``GeoExt.ux.LayerManagerExportPanel`` Export panel
+ */
exportPanel: null,
+ /** property[importPanel]
+ * ``GeoExt.ux.LayerManagerImportPanel`` Import panel
+ */
+ importPanel: null,
+
+ /** private: method[initComponent]
+ * Private initComponent override.
+ */
initComponent: function() {
this.exportPanel = new GeoExt.ux.LayerManagerExportPanel({
@@ -49,4 +108,7 @@
];
GeoExt.ux.LayerManagerWindow.superclass.initComponent.call(this);
}
-});
\ No newline at end of file
+});
+
+/** api: xtype = gxux_layermanagerwindow */
+Ext.reg('gxux_layermanagerwindow', GeoExt.ux.LayerManagerWindow);
\ No newline at end of file
More information about the Commits
mailing list