@@ -35,6 +35,7 @@ Ext.namespace("gxp");
35
35
* that originate from a WFS or local OpenLayers Features from upload or drawing.
36
36
*/
37
37
gxp . VectorStylesDialog = Ext . extend ( gxp . StylesDialog , {
38
+ attributeStore : null ,
38
39
39
40
/** private: method[initComponent]
40
41
*/
@@ -47,6 +48,7 @@ gxp.VectorStylesDialog = Ext.extend(gxp.StylesDialog, {
47
48
// this.items.get(0).setDisabled(true);
48
49
this . items . get ( 1 ) . setDisabled ( true ) ;
49
50
51
+
50
52
this . on ( {
51
53
"styleselected" : function ( cmp , style ) {
52
54
var index = this . stylesStore . findExact ( "name" , style . name ) ;
@@ -89,55 +91,13 @@ gxp.VectorStylesDialog = Ext.extend(gxp.StylesDialog, {
89
91
var rule = this . selectedRule ;
90
92
var origRule = rule . clone ( ) ;
91
93
92
- // Attribute types: either from WFS or local features
93
- var attributeStore ;
94
- if ( this . layerDescription ) {
95
- // WFS Layer: use DescribeFeatureType to get attribute-names/types
96
- attributeStore = new GeoExt . data . AttributeStore ( {
97
- url : this . layerDescription . owsURL ,
98
- baseParams : {
99
- "SERVICE" : "WFS" ,
100
- "REQUEST" : "DescribeFeatureType" ,
101
- "TYPENAME" : this . layerDescription . typeName
102
- } ,
103
- method : "GET" ,
104
- disableCaching : false
105
- } ) ;
106
- } else {
107
- // Attribute store will be derived from local features
108
- attributeStore = new Ext . data . Store ( {
109
- // explicitly create reader
110
- // id for each record will be the first element }
111
- reader : new Ext . data . ArrayReader (
112
- { idIndex : 0 } ,
113
- Ext . data . Record . create ( [
114
- { name : 'name' }
115
- ] )
116
- )
117
- } ) ;
118
-
119
- // Create attribute meta data from feature-attributes
120
- var myData = [ ] ;
121
- var layer = this . layerRecord . data . layer ;
122
- if ( layer && layer . features && layer . features . length > 0 ) {
123
- var attrs = layer . features [ 0 ] . attributes ;
124
- for ( var attr in attrs ) {
125
- myData . push ( [ attr ] ) ;
126
- }
127
- }
128
- attributeStore . loadData ( myData ) ;
129
- // Silence the proxy (must be better way...)
130
- attributeStore . proxy = { request : function ( ) {
131
- } } ;
132
- }
133
-
134
94
var ruleDlg = new this . dialogCls ( {
135
95
title : String . format ( this . ruleWindowTitle ,
136
96
rule . title || rule . name || this . newRuleText ) ,
137
97
shortTitle : rule . title || rule . name || this . newRuleText ,
138
98
layout : "fit" ,
139
99
width : 320 ,
140
- height : 450 ,
100
+ height : 490 ,
141
101
pageX : 150 ,
142
102
pageY : 100 ,
143
103
modal : true ,
@@ -155,7 +115,7 @@ gxp.VectorStylesDialog = Ext.extend(gxp.StylesDialog, {
155
115
ref : "rulePanel" ,
156
116
symbolType : rule . symbolType ? rule . symbolType : this . symbolType ,
157
117
rule : rule ,
158
- attributes : attributeStore ,
118
+ attributes : this . attributeStore ,
159
119
autoScroll : true ,
160
120
border : false ,
161
121
defaults : {
@@ -189,6 +149,28 @@ gxp.VectorStylesDialog = Ext.extend(gxp.StylesDialog, {
189
149
}
190
150
} ]
191
151
} ) ;
152
+
153
+ // Remove all text symbolizer-related tabs when no attributes exist
154
+ var removeItems , i ;
155
+ if ( this . attributeStore . data . getCount ( ) == 0 ) {
156
+ var rulePanel = ruleDlg . findByType ( 'gxp_rulepanel' ) [ 0 ] ;
157
+ removeItems = rulePanel . items . getRange ( 1 , 2 ) ;
158
+ for ( i = 0 ; i < removeItems . length ; i ++ ) {
159
+ rulePanel . remove ( removeItems [ i ] ) ;
160
+ }
161
+
162
+ }
163
+
164
+ // Remove advanced Label symbolizer widget
165
+ // items not or hard to support via OL Symbolizers and Printing
166
+ var textSymbolizers = ruleDlg . findByType ( 'gxp_textsymbolizer' ) ;
167
+ if ( textSymbolizers && textSymbolizers . length == 1 ) {
168
+ var textSymbolizer = textSymbolizers [ 0 ] ;
169
+ removeItems = textSymbolizer . items . getRange ( 3 , 7 ) ;
170
+ for ( i = 0 ; i < removeItems . length ; i ++ ) {
171
+ textSymbolizer . remove ( removeItems [ i ] ) ;
172
+ }
173
+ }
192
174
this . showDlg ( ruleDlg ) ;
193
175
} ,
194
176
@@ -351,14 +333,77 @@ gxp.VectorStylesDialog = Ext.extend(gxp.StylesDialog, {
351
333
*/
352
334
describeLayer : function ( callback ) {
353
335
336
+ if ( this . layerDescription ) {
337
+ // always return before calling callback
338
+ callback . call ( this ) ;
339
+ }
340
+
354
341
var layer = this . layerRecord . getLayer ( ) ;
355
342
if ( layer . protocol && layer . protocol . CLASS_NAME . indexOf ( '.WFS' ) > 0 ) {
356
- this . layerDescription = { } ;
357
- this . layerDescription . owsURL = layer . protocol . url . replace ( '?' , '' ) ;
358
- this . layerDescription . owsType = 'WFS' ;
359
- this . layerDescription . typeName = layer . protocol . featureType ;
343
+ this . wfsLayer = { } ;
344
+ this . wfsLayer . owsURL = layer . protocol . url . replace ( '?' , '' ) ;
345
+ this . wfsLayer . owsType = 'WFS' ;
346
+ this . wfsLayer . typeName = layer . protocol . featureType ;
360
347
}
361
- this . editRule ( ) ;
348
+
349
+ // Attribute types: either from WFS or local features
350
+ var self = this ;
351
+ if ( this . wfsLayer ) {
352
+ // WFS Layer: use DescribeFeatureType to get attribute-names/types
353
+ this . attributeStore = new GeoExt . data . AttributeStore ( {
354
+ url : this . wfsLayer . owsURL ,
355
+ baseParams : {
356
+ "SERVICE" : "WFS" ,
357
+ "VERSION" : "1.1.0" ,
358
+ "REQUEST" : "DescribeFeatureType" ,
359
+ "TYPENAME" : this . wfsLayer . typeName
360
+ } ,
361
+ // method: "GET",
362
+ // disableCaching: false,
363
+ autoLoad : true ,
364
+ listeners : {
365
+ 'load' : function ( store ) {
366
+ self . layerDescription = self . attributeStore ;
367
+ // The TextSymbolizer calls load() as well, leading to loop
368
+ // when we would call editRule() again...
369
+ // prevent by makin load() function empty...
370
+ // We should fix this in TextSymbolizer but there is a risk to break other stuff...
371
+ store . load = function ( ) { } ;
372
+ callback . call ( self ) ;
373
+ } ,
374
+ scope : this
375
+ }
376
+ } ) ;
377
+ } else {
378
+ // Attribute store will be derived from local features
379
+ this . attributeStore = new Ext . data . Store ( {
380
+ // explicitly create reader
381
+ // id for each record will be the first element }
382
+ reader : new Ext . data . ArrayReader (
383
+ { idIndex : 0 } ,
384
+ Ext . data . Record . create ( [
385
+ { name : 'name' }
386
+ ] )
387
+ )
388
+ } ) ;
389
+
390
+ // Create attribute meta data from feature-attributes
391
+ var myData = [ ] ;
392
+ if ( layer && layer . features && layer . features . length > 0 ) {
393
+ var attrs = layer . features [ 0 ] . attributes ;
394
+ for ( var attr in attrs ) {
395
+ myData . push ( [ attr ] ) ;
396
+ }
397
+ }
398
+ this . attributeStore . loadData ( myData ) ;
399
+ // Silence the proxy (must be better way...)
400
+ this . attributeStore . proxy = { request : function ( ) {
401
+ } } ;
402
+ this . layerDescription = this . attributeStore ;
403
+
404
+ callback . call ( this ) ;
405
+ }
406
+
362
407
} ,
363
408
364
409
/** private: method[addStylesCombo]
0 commit comments