Revision 42248

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/featureform/swing/impl/DefaultJFeatureForm.java
74 74
    private FeatureStore store;
75 75
    private FeaturePagingHelper ph;
76 76
    private DynClass definition = null;
77
    private FeatureQuery currentQuery;
77 78

  
78 79
    /**
79 80
     *
......
93 94
        panel.setPreferredSize(dimension);
94 95
    }
95 96

  
97
    private void updateForm() throws DataException, ServiceException, BaseException {
98
        if (this.formset == null){
99
            this.panel.add(this.getFormset().asJComponent(),BorderLayout.CENTER);
100
        }
101
        this.ph = DALLocator.getDataManager().createFeaturePagingHelper(
102
               store, this.currentQuery, PAGE_SIZE);
103
        if( this.currentQuery != null ) {
104
            List features = ph.asList();
105
            FeatureSelection selection = (FeatureSelection) store.getSelection();
106
            selection.deselectAll();
107
            for (Iterator iterator = features.iterator(); iterator.hasNext();) {
108
                Feature feature = (Feature) iterator.next();
109
                selection.select(feature);
110
            }
111
        }
112
        this.formset.setValues(ph.asListOfDynObjects());
113
        this.formset.setReadOnly(false);        
114
    }
115
    
96 116
    public JComponent asJComponent() {
117
        if (this.ph == null) {
118
            try {
119
                updateForm();
120
            } catch (Exception ex) {
121
                throw new RuntimeException(ex);
122
            }
123
        }        
97 124
        return this.panel;
98 125
    }
99 126

  
......
163 190
                saveChanges(this.formset);
164 191
            }
165 192
        }
166
        if (this.formset == null){
167
            this.formset = getFormset();
168
            this.panel.add(this.formset.asJComponent(),BorderLayout.CENTER);
169
        }
170
        this.ph =
171
            DALLocator.getDataManager().createFeaturePagingHelper(store, query,
172
                PAGE_SIZE);
173
        FeatureSelection selection = (FeatureSelection) store.getSelection();
174
        selection.deselectAll();
175
        List features = ph.asList();
176
        for (Iterator iterator = features.iterator(); iterator.hasNext();) {
177
            Feature feature = (Feature) iterator.next();
178
            selection.select(feature);
179
        }
180
        if (features.size()>0) {
181
            this.showForm(MODE.TOOL);
182
        }
183

  
184
        this.formset.setValues(ph.asListOfDynObjects());
185
        this.formset.setReadOnly(false);
193
        this.currentQuery = query;
194
        updateForm();
186 195
    }
187 196

  
188 197
    /*
......
191 200
     * @see org.gvsig.attributeeditor.swing.JFeatureForm#showForm()
192 201
     */
193 202
    public void showForm(MODE mode) throws ServiceException, DataException {
194
        if (this.formset == null) {
195
            this.formset = getFormset();
196
            this.panel.add(this.formset.asJComponent(),BorderLayout.CENTER);
197
            WindowManager winmgr = ToolsSwingLocator.getWindowManager();
198
            winmgr.showWindow(panel, store.getName(), mode);
199
        }
200
        this.panel.setVisible(true);
201

  
203
        this.panel.add(this.getFormset().asJComponent(), BorderLayout.CENTER);
204
        WindowManager winmgr = ToolsSwingLocator.getWindowManager();
205
        winmgr.showWindow(this.asJComponent(), store.getName(), mode);
202 206
    }
203 207

  
204 208
    public void formMessage(String message) {

Also available in: Unified diff