Revision 47790 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/BaseViewDocument.java

View differences:

BaseViewDocument.java
30 30
import java.util.List;
31 31
import java.util.Map;
32 32
import java.util.Objects;
33

  
34 33
import javax.swing.JOptionPane;
35 34
import javax.swing.JPanel;
36 35
import javax.swing.JScrollPane;
37
import org.apache.commons.lang.StringUtils;
38

  
39 36
import org.cresques.cts.IProjection;
40

  
41 37
import org.gvsig.andami.PluginServices;
42 38
import org.gvsig.andami.ui.mdiManager.IWindow;
43 39
import org.gvsig.andami.ui.mdiManager.WindowInfo;
44 40
import org.gvsig.app.ApplicationLocator;
41
import org.gvsig.app.project.Project;
45 42
import org.gvsig.app.project.documents.AbstractDocument;
46 43
import org.gvsig.app.project.documents.DocumentManager;
47 44
import org.gvsig.app.project.documents.view.info.gui.HTMLInfoToolPanel;
......
99 96
        super(factory);
100 97
    }
101 98

  
99
    @Override
100
    public void setProject(Project project) {
101
        super.setProject(project);
102
        if(mapContext != null) {
103
            mapContext.setSelectionColor(project.getSelectionColor());
104
        }
105
    }
106
    
107
    
108

  
102 109
    /**
103 110
     * Gets the MapContext of the main map in the view.
104 111
     *
105 112
     * @return the main MapContext
106 113
     */
114
    @Override
107 115
    public MapContext getMapContext() {
108 116
        if( this.mapContext!=null && DisposeUtils.isNullOrDisposed(this.mapContext) ) {
109 117
            try {
......
128 136
     *
129 137
     * @return the locator MapContext
130 138
     */
139
    @Override
131 140
    public MapContext getMapOverViewContext() {
132 141
        return mapOverViewContext;
133 142
    }
134 143

  
144
    @Override
135 145
    public void setMapContext(MapContext fmap) {
136 146
        mapContext = fmap;
147
        Project p = this.getProject();
148
        if(p != null){
149
            mapContext.setSelectionColor(p.getSelectionColor());
150
        }
137 151
        fmap.addErrorListener(this);
138 152
    }
139 153

  
154
    @Override
140 155
    public void setMapOverViewContext(MapContext fmap) {
141 156
        mapOverViewContext = fmap;
142 157
        mapOverViewContext.setProjection(mapContext.getProjection());
143 158
    }
144 159

  
145 160
    public void showErrors() {
146
        if (mapContext.getLayersError().size() > 0) {
161
        if (!mapContext.getLayersError().isEmpty()) {
147 162
            String layersError = "";
148 163
            for (int i = 0; i < mapContext.getLayersError().size(); i++) {
149 164
                layersError = layersError + "\n" + (String) mapContext.getLayersError().get(i);
......
159 174
     * atomic MapContext transaction
160 175
     */
161 176
    @SuppressWarnings("rawtypes")
177
    @Override
162 178
    public void reportDriverExceptions(String introductoryText, List driverExceptions) {
163 179
        HtmlWindow htmlPanel = new HtmlWindow(570, 600, PluginServices.getText(this, "driver_error"));
164 180
        String htmlText = "";
......
215 231
            htmlPanel.show(htmlText);
216 232
        }
217 233

  
234
        @Override
218 235
        public WindowInfo getWindowInfo() {
219 236
            return viewInfo;
220 237
        }
221 238

  
239
        @Override
222 240
        public Object getWindowProfile() {
223 241
            return WindowInfo.PROPERTIES_PROFILE;
224 242
        }
225 243

  
226 244
    }
227 245

  
246
    @Override
228 247
    public IProjection getProjection() {
229 248
        if( this.mapContext == null ) {
230 249
            return null;
......
232 251
        return mapContext.getProjection();
233 252
    }
234 253

  
254
    @Override
235 255
    public void setProjection(IProjection proj) {
236 256
        mapContext.setProjection(proj);
237 257
        mapOverViewContext.setProjection(proj);
......
241 261
        return mapOverViewContext.getProjection();
242 262
    }
243 263

  
264
    @Override
244 265
    public void afterRemove() {
245 266
        // FIXME: Parece que no recorre correctamente el arbol de capas
246 267

  
......
250 271
            try {
251 272
                layers.getLayer(i).getParentLayer().removeLayer(layers.getLayer(i));
252 273
            } catch (CancelationException e1) {
253
                e1.printStackTrace();
274
                LOGGER.warn("Can't remove layer");
254 275
            }
255 276
        }
256 277
        getMapContext().dispose();
257 278
        getMapOverViewContext().dispose();
258 279
    }
259 280

  
281
    @Override
260 282
    public void afterAdd() {
261 283
        // Do nothing
262 284
    }
263 285

  
286
    @Override
264 287
    public void setBackColor(Color c) {
265 288
        getMapContext().getViewPort().setBackColor(c);
266 289
    }
267 290

  
291
    @Override
268 292
    public void errorThrown(ErrorEvent e) {
269 293
        JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(),
270 294
                PluginServices.getText(this, "fallo_capas") + " : \n"
......
272 296

  
273 297
    }
274 298

  
299
    @Override
275 300
    public boolean isLocked() {
276 301
        if (super.isLocked()) {
277 302
            return true;
......
286 311
        return false;
287 312
    }
288 313

  
314
    @Override
289 315
    public void saveToState(PersistentState state) throws PersistenceException {
290 316
        super.saveToState(state);
291 317
        state.set("mainMapContext", this.getMapContext());
......
298 324
        state.set("propertiesHelper", propertiesHelper);
299 325
    }
300 326

  
327
    @Override
301 328
    public void loadFromState(PersistentState state) throws PersistenceException {
302 329
        super.loadFromState(state);
303 330
        this.mapContext = (MapContext) state.get("mainMapContext");
......
339 366
        }
340 367
    }
341 368

  
369
    @Override
342 370
    public Object getProperty(Object key) {
343 371
        return this.propertiesHelper.getProperty(key);
344 372
    }
345 373

  
374
    @Override
346 375
    public void setProperty(Object key, Object obj) {
347 376
        this.propertiesHelper.setProperty(key, obj);
348 377
    }
349 378

  
379
    @Override
350 380
    public Map getExtendedProperties() {
351 381
        return this.propertiesHelper.getExtendedProperties();
352 382
    }
......
369 399

  
370 400
    @Override
371 401
    public Iterable<FLayer> layers() {
372
        return new Iterable<FLayer>() {
373
            @Override
374
            public Iterator<FLayer> iterator() {
375
                return deepiterator();
376
            }
377
        };
402
        return () -> deepiterator();
378 403
    }
379 404

  
380 405
    @Override

Also available in: Unified diff