Changeset 1779

Show
Ignore:
Timestamp:
02/18/09 16:30:56 (4 years ago)
Author:
pvalsecc
Message:

Implemented a crude "limit by condition" and wired the "apply" button

Location:
sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/ClassPropertiesPanel.js

    r1758 r1779  
    11Ext.namespace('Studio', 'Studio.MapfileMgr'); 
    22 
    3 Studio.MapfileMgr.ClassPropertiesPanel = Ext.extend(Studio.MapfileMgr.StylerPanel, { 
     3Studio.MapfileMgr.ClassPropertiesPanel = Ext.extend(Studio.MapfileMgr.StylerForm, { 
    44 
    55    title: 'CLASS object properties', 
     
    2020     */ 
    2121    mapfile: null, 
     22 
     23    /** 
     24     * Property: clazz 
     25     * The MapFile class being edited 
     26     * {Object} 
     27     */ 
     28    clazz: null, 
    2229 
    2330    createAddButton: function(clazz, opts) { 
     
    4451            tooltip: 'Apply modifications', 
    4552            //disabled: true,  // TODO disabled first, enabled when form is modified 
    46             handler: function() { 
    47  
    48                 Ext.getCmp('studio.mm.panel').saveMapFile(); 
    49             }, 
     53            handler: this.apply, 
    5054            scope: this 
    5155        }]; 
     
    203207    //TODO: this must be passed during construction 
    204208    setData: function(mapfile, layerIndex, classIndex) { 
    205         var clazz = mapfile.getClass(layerIndex, classIndex); 
    206  
    207         this.visitStyler(new Studio.MapfileMgr.MapFileToStylerVisitor(clazz, this.mapfile)); 
     209        this.clazz = mapfile.getClass(layerIndex, classIndex); 
     210 
     211        this.visitStyler(new Studio.MapfileMgr.MapFileToStylerVisitor(this.clazz, this.mapfile)); 
    208212        this.doLayout(); 
    209213        this.doLayout(); //have to do it twice for style fieldsets 
     
    272276                this.getStyles().remove(styleFieldSet); 
    273277                this.updateStyleButtons(); 
    274                 this.doLayout();                 
     278                this.doLayout(); 
    275279            }, 
    276280            scope: this 
     
    283287        } 
    284288        return this.styles; 
     289    }, 
     290 
     291    apply: function() { 
     292        this.visitStyler(new Studio.MapfileMgr.StylerToMapFileVisitor(this.clazz)); 
     293        Ext.getCmp('studio.mm.panel').saveMapFile(); 
    285294    } 
    286295}); 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/tools/MapFileToStylerVisitor.js

    r1770 r1779  
    4747                if (json.expression) { 
    4848                    panel.ownerCt.expand(); 
    49                     return new Studio.MapfileMgr.MapFileToStylerVisitor.Simple(json); 
     49                    return new Studio.MapfileMgr.MapFileToStylerVisitor.LimitByCondition(json.expression); 
    5050                } else { 
    5151                    panel.ownerCt.collapse(); 
     
    115115    }; 
    116116}; 
     117 
     118Studio.MapfileMgr.MapFileToStylerVisitor.LimitByCondition = function(expression) { 
     119    var regexp=/^\(\s*\[([^\]]+)\]\s*([!=<>]*)\s*"?([^"]*)"?\)$/; 
     120    var matches=regexp(expression); 
     121    var exploded; 
     122    if(!matches) { 
     123        alert("Cannot parse expression: "+expression); 
     124        exploded={}; 
     125    } else { 
     126        exploded={ 
     127            attribute: matches[1], 
     128            operator: matches[2], 
     129            value: matches[3] 
     130        }; 
     131    } 
     132 
     133    return { 
     134        beginPanel: function(panel) { 
     135            return this; 
     136        }, 
     137 
     138        endPanel: function(panel) { 
     139        }, 
     140 
     141        value: function(component, name, value) { 
     142            return Studio.MapfileMgr.MapFileToStylerVisitor.getValue(exploded, component, name); 
     143        } 
     144    }; 
     145}; 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/tools/StylerPanel.js

    r1778 r1779  
    1818            if (subVisitor) { 
    1919                Studio.MapfileMgr.StylerPanel.visitItems(this, subVisitor); 
     20                if(subVisitor.destroy) subVisitor.destroy(); 
    2021            } 
    2122            visitor.endPanel(this); 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/tools/StylerToMapFileVisitor.js

    r1724 r1779  
    1717            } else if (panelType == 'studio.mm.limitbycondition') { 
    1818                if (!panel.ownerCt.collapsed) { 
    19                     return new Studio.MapfileMgr.StylerToMapFileVisitor.Simple(json); 
     19                    return new Studio.MapfileMgr.StylerToMapFileVisitor.LimitByCondition(json); 
    2020                } else { 
    2121                    delete json.expression; 
     
    5858        delete json[name]; 
    5959 
    60     } else if(component.isXType('gx_colorfield')) { 
    61         var hex=component.getHexValue(); 
     60    } else if (component.isXType('gx_colorfield')) { 
     61        var hex = component.getHexValue(); 
     62 
    6263        function toDec(val, pos) { 
    63             return parseInt(val.substring(pos, pos+2), 16); 
     64            return parseInt(val.substring(pos, pos + 2), 16); 
    6465        } 
     66 
    6567        json[name] = [toDec(hex, 1), toDec(hex, 3), toDec(hex, 5)]; 
    6668 
     
    8587    }; 
    8688}; 
     89 
     90Studio.MapfileMgr.StylerToMapFileVisitor.LimitByCondition = function(json) { 
     91    var exploded = {}; 
     92 
     93    return { 
     94        beginPanel: function(panel) { 
     95            return this; 
     96        }, 
     97 
     98        endPanel: function(panel) { 
     99        }, 
     100 
     101        value: function(component, name, value) { 
     102            return Studio.MapfileMgr.StylerToMapFileVisitor.updateValue(exploded, component, name, value); 
     103        }, 
     104 
     105        destroy: function() { 
     106            if (exploded.attribute !== "" && exploded.operator) { 
     107                json.expression = "([" + exploded.attribute + "]" + exploded.operator + exploded.value + ")"; 
     108            } else { 
     109                delete json.expression; 
     110            } 
     111        } 
     112    }; 
     113}; 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/widgets/FillStylePanel.js

    r1771 r1779  
    2222            xtype: 'studio.mm.colorpickerfield', 
    2323            fieldLabel: 'Color', 
    24             name: 'color' 
     24            name: 'color', 
     25            allowBlank: false 
    2526        },{ 
    2627            xtype: 'studio.mm.symbolcombo', 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/widgets/LimitByConditionPanel.js

    r1724 r1779  
    1313        this.items = [{ 
    1414            xtype: 'textfield', 
    15             fieldLabel: 'Condition', 
    16             name: 'expression' 
     15            fieldLabel: 'Attribute', 
     16            name: 'attribute' 
     17        },{ 
     18            xtype: 'textfield', 
     19            fieldLabel: 'Operator', 
     20            name: 'operator' 
     21        },{ 
     22            xtype: 'textfield', 
     23            fieldLabel: 'Value', 
     24            name: 'value' 
    1725        }]; 
    1826        Studio.MapfileMgr.LimitByConditionPanel.superclass.initComponent.apply(this, arguments); 
  • sandbox/camptocamp/Studio/studio/public/js/Studio/MapfileMgr/styler/widgets/StrokeStylePanel.js

    r1771 r1779  
    2222            xtype: 'studio.mm.colorpickerfield', 
    2323            fieldLabel: 'Color', 
    24             name: "color" 
     24            name: "color", 
     25            allowBlank: false 
    2526        },{ 
    2627            xtype: 'studio.mm.colorpickerfield', 
     
    3031            xtype: 'studio.mm.numberspinner', 
    3132            fieldLabel: 'Size', 
     33            width: 40, 
    3234            name: 'size', 
    3335            minValue: 1