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

View differences:

DefaultViewDocument.java
24 24

  
25 25
package org.gvsig.app.project.documents.view;
26 26

  
27
import java.util.logging.Level;
28 27
import javax.swing.JOptionPane;
29 28
import org.gvsig.andami.PluginsLocator;
30 29
import org.gvsig.andami.PluginsManager;
......
68 67

  
69 68
	public static final String PERSISTENCE_DEFINITION_NAME = "DefaultViewDocument";
70 69
	
71
    private class AddLayerListener extends BaseLayerCollectionListener {
70
    private class SetViewPortExtentWhenAddLayerListener extends BaseLayerCollectionListener {
72 71

  
73 72
        private Thread th = null;
73
        private final ViewPort viewPort;
74 74
        
75
        public SetViewPortExtentWhenAddLayerListener(ViewPort viewPort) {
76
            this.viewPort = viewPort;
77
        }
78
        
75 79
        @Override
76 80
        public synchronized void layerAdded(LayerCollectionEvent e) {
77 81
            if( th != null ) {
78 82
                return;
79 83
            }
80
            final ViewPort viewPort = mapContext.getViewPort();
81 84
            if (viewPort.getEnvelope() == null) {
82 85
                final FLayer layer = e.getAffectedLayer();
83 86
                if (layer.isAvailable() )  {
......
164 167
		vp.setBackColor(preferences.getDefaultViewBackColor());
165 168
		this.setMapOverViewContext(overviewMapContext);
166 169
        
167
        this.getMapContext().getLayers().addLayerCollectionListener(new AddLayerListener());
170
        this.getMapContext().getLayers().addLayerCollectionListener(
171
            new SetViewPortExtentWhenAddLayerListener(this.getMapContext().getViewPort())
172
        );
173
        this.getMapOverViewContext().getLayers().addLayerCollectionListener(
174
            new SetViewPortExtentWhenAddLayerListener(this.getMapOverViewContext().getViewPort())
175
        );
168 176
	}
169 177
	
170 178
	/**

Also available in: Unified diff