Revision 3452

View differences:

org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/LocalChangesController.java
819 819
        return geom;
820 820
    }
821 821
    
822
    private FeatureStore getStoreOfSelectedChange() {
823
        FeatureStore store = null;
824
        int selected = this.tblLocalChanges.getSelectedRow();
825
        if(selected >= 0){
826
            VCSGisWorkspaceChange change = changes.get64(selected);
827
            try {
828
                VCSGisWorkspace ws = getWorkspace();
829
                if(ws!=null) {
830
                    String entityCode = change.getEntityCode();
831
                    VCSGisEntity entity = ws.getEntity(entityCode);
832
                    store = ws.getFeatureStore(entity.getEntityName());
833
                }
834
            } catch (Exception ex){
835
                
836
            }
837
        }
838
        return store;
839
    }
840
    
822 841
    private void doZoomToSelectedChange() {
823 842
        cleanHighligthed();
824 843
        VCSGisManager manager = VCSGisLocator.getVCSGisManager();
825 844
        VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager();
826 845
        VCSGisSwingServices services =swingManager.getDefaultServices();
846
        FeatureStore store = getStoreOfSelectedChange();
827 847
        Geometry geom = getGeometryOfSelectedChange();
828 848
        Geometry originalGeom = getOriginalGeometryOfSelectedChange();
829
        services.zoomActiveViewToGeometry(VCSGisSwingCommons.createBBox(geom, originalGeom));
849
//        services.zoomActiveViewToGeometry(VCSGisSwingCommons.createBBox(geom, originalGeom));
850
        services.zoomViewsHavingAStoreToGeometry(store, VCSGisSwingCommons.createBBox(geom, originalGeom));
830 851
        if(geom != null){
831
            services.highlight(HIGHLIGHT_WORKSPACE, geom);
852
            services.highlight(HIGHLIGHT_WORKSPACE, geom, store);
832 853
        }
833 854
        if(originalGeom != null){
834
            services.highlight(HIGHLIGHT_WORKSPACE_PREVIOUS, originalGeom);
855
            services.highlight(HIGHLIGHT_WORKSPACE_PREVIOUS, originalGeom, store);
835 856
        }
836 857
    }
837 858

  
......
840 861
        VCSGisManager manager = VCSGisLocator.getVCSGisManager();
841 862
        VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager();
842 863
        VCSGisSwingServices services =swingManager.getDefaultServices();
864
        FeatureStore store = getStoreOfSelectedChange();
843 865
        Geometry geom = getGeometryOfSelectedChange();
844 866
        Geometry originalGeom = getOriginalGeometryOfSelectedChange();
845
        services.centerActiveViewToGeometry(VCSGisSwingCommons.createBBox(geom, originalGeom));
867
//        services.centerActiveViewToGeometry(VCSGisSwingCommons.createBBox(geom, originalGeom));
868
        services.centerViewsHavingAStoreToGeometry(store, VCSGisSwingCommons.createBBox(geom, originalGeom));
846 869
        if(geom != null){
847
            services.highlight(HIGHLIGHT_WORKSPACE, geom);
870
            services.highlight(HIGHLIGHT_WORKSPACE, geom, store);
848 871
        }
849 872
        if(originalGeom != null){
850
            services.highlight(HIGHLIGHT_WORKSPACE_PREVIOUS, originalGeom);
873
            services.highlight(HIGHLIGHT_WORKSPACE_PREVIOUS, originalGeom, store);
851 874
        }
852 875

  
853 876
    }
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/RemoteChangesController.java
802 802
        return geom;
803 803
    }
804 804
    
805
    private FeatureStore getWorkspaceStoreOfSelectedChange() {
806
        FeatureStore store = null;
807
        int selected = this.tblRemoteChanges.getSelectedRow();
808
        if(selected >= 0){
809
            VCSGisRepositoryChange change = changes.get64(selected);
810
            
811
            Feature f = getWorkspace().getRelatedFeature(change);
812
            if(f!= null){
813
                store = f.getStore();
814
            }
815
        }
816
        return store;
817
    }
818
    
805 819
    private void doZoomToSelectedChange() {
806 820
        cleanHighligthed();
807 821
        VCSGisManager manager = VCSGisLocator.getVCSGisManager();
808 822
        VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager();
809 823
        VCSGisSwingServices services = swingManager.getDefaultServices();
824
        FeatureStore store = getWorkspaceStoreOfSelectedChange();
810 825
        Geometry repoGeom = getRepositoryGeometryOfSelectedChange();
811 826
        Geometry geom = getWorkspaceGeometryOfSelectedChange();
812
        services.zoomActiveViewToGeometry(VCSGisSwingCommons.createBBox(repoGeom, geom));
827
//        services.zoomActiveViewToGeometry(VCSGisSwingCommons.createBBox(repoGeom, geom));
828
        services.zoomViewsHavingAStoreToGeometry(store, VCSGisSwingCommons.createBBox(repoGeom, geom));
813 829
        if(repoGeom != null){
814
            services.highlight(HIGHLIGHT_REPOSITORY, repoGeom);
830
            services.highlight(HIGHLIGHT_REPOSITORY, repoGeom, store);
815 831
        }
816 832
        if(geom != null){
817
            services.highlight(HIGHLIGHT_WORKSPACE, geom);
833
            services.highlight(HIGHLIGHT_WORKSPACE, geom, store);
818 834
        }
819 835
    }
820 836

  
......
823 839
        VCSGisManager manager = VCSGisLocator.getVCSGisManager();
824 840
        VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager();
825 841
        VCSGisSwingServices services = swingManager.getDefaultServices();
842
        FeatureStore store = getWorkspaceStoreOfSelectedChange();
826 843
        Geometry repoGeom = getRepositoryGeometryOfSelectedChange();
827 844
        Geometry geom = getWorkspaceGeometryOfSelectedChange();
828
        services.centerActiveViewToGeometry(VCSGisSwingCommons.createBBox(repoGeom, geom));
845
//        services.centerActiveViewToGeometry(VCSGisSwingCommons.createBBox(repoGeom, geom));
846
        services.centerViewsHavingAStoreToGeometry(store, VCSGisSwingCommons.createBBox(repoGeom, geom));
829 847
        if(repoGeom != null){
830
            services.highlight(HIGHLIGHT_REPOSITORY, repoGeom);
848
            services.highlight(HIGHLIGHT_REPOSITORY, repoGeom, store);
831 849
        }
832 850
        if(geom != null){
833
            services.highlight(HIGHLIGHT_WORKSPACE, geom);
851
            services.highlight(HIGHLIGHT_WORKSPACE, geom, store);
834 852
        }
835 853
    }
836 854

  
......
934 952
        }
935 953
        return ws.getWorkspaceEntity(entity.getEntityCode())!=null;
936 954
    }
937

  
955
    
938 956
}
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.api/src/main/java/org/gvsig/vcsgis/swing/VCSGisSwingServices.java
5 5
 */
6 6
package org.gvsig.vcsgis.swing;
7 7

  
8
import java.util.List;
8 9
import javax.swing.ComboBoxModel;
9 10
import javax.swing.ListModel;
10 11
import javax.swing.tree.TreeModel;
......
39 40

  
40 41
    public void centerActiveViewToGeometry(Geometry geometry);
41 42

  
43
    public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry);
44

  
42 45
    public void zoomActiveViewToGeometry(Geometry geometry);
43 46

  
47
    public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry);
48

  
44 49
    public void cleanHighligthed();
45 50
    
51
    public void cleanActiveViewHighligthed();
52
    
46 53
    public void refreshDocument(FeatureStore store);
47 54

  
48 55
    public void highlight(int mode, Geometry geometry);
49 56
    
57
    public void highlight(int mode, Geometry geom, FeatureStore store);
58
    
50 59
    public boolean isThereAnyActiveView();
51 60
    
52 61
    public void addTableToProject(VCSGisWorkspace ws, FeatureStore store, String tableName);
62
    
53 63
}
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/pom.xml
9 9
    <parent>
10 10
        <groupId>org.gvsig</groupId>
11 11
        <artifactId>org.gvsig.desktop</artifactId>
12
        <version>2.0.318</version>
12
        <version>2.0.319-SNAPSHOT</version>
13 13
    </parent>
14 14

  
15 15
    <properties>
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisSwingServicesImpl.java
6 6
package org.gvsig.vcsgis.app;
7 7

  
8 8
import java.io.File;
9
import java.util.ArrayList;
9 10
import java.util.HashMap;
10 11
import java.util.Iterator;
11 12
import java.util.List;
......
154 155
    
155 156
    @Override
156 157
    public void highlight(int mode, Geometry geom) {
158
        highlight(mode, geom, null);
159
    }
160

  
161
    @Override
162
    public void highlight(int mode, Geometry geom, FeatureStore store) {
157 163
        if (this.highlightedPointSymbols == null) {
158 164
            this.highlightedPointSymbols = new HashMap<>();
159 165
            this.highlightedLineSymbols = new HashMap<>();
......
201 207
            } catch (Exception ex) {
202 208
            }
203 209
        }
204
        ApplicationManager application = ApplicationLocator.getManager();
205
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
206
        MapContext mapContext = viewdoc.getMapContext();
207
        GraphicLayer gl = mapContext.getGraphicsLayer();
208
        if ( geom!=null ) {
209
            ISymbol symbol = null;
210
            if( geom instanceof Point || geom instanceof MultiPoint) {
211
                symbol = this.highlightedPointSymbols.get(mode);
212
            } else if( geom instanceof Curve || geom instanceof MultiCurve ) {
213
                symbol = this.highlightedLineSymbols.get(mode);
214
            } else if( geom instanceof Surface || geom instanceof MultiSurface ) {
215
                symbol = this.highlightedPolygonSymbols.get(mode);
216
            }
217
            if (symbol != null) {
218
                int symbolid = gl.getSymbolId(symbol);
219
                if (symbolid < 0) {
220
                    gl.addSymbol(symbol);
221
                    symbolid = gl.getSymbolId(symbol);
210
        List<ViewDocument> viewList = null;
211
        if(store == null){
212
            ApplicationManager application = ApplicationLocator.getManager();
213
            ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
214
            viewList = new ArrayList<>();
215
            viewList.add(viewdoc);
216
        } else {
217
            viewList = getViewDocumentsHavingAStore(store);
218
        }
219
        for (ViewDocument viewDoc : viewList) {
220
            MapContext mapContext = viewDoc.getMapContext();
221
            GraphicLayer gl = mapContext.getGraphicsLayer();
222
            if (geom != null) {
223
                ISymbol symbol = null;
224
                if (geom instanceof Point || geom instanceof MultiPoint) {
225
                    symbol = this.highlightedPointSymbols.get(mode);
226
                } else if (geom instanceof Curve || geom instanceof MultiCurve) {
227
                    symbol = this.highlightedLineSymbols.get(mode);
228
                } else if (geom instanceof Surface || geom instanceof MultiSurface) {
229
                    symbol = this.highlightedPolygonSymbols.get(mode);
222 230
                }
223
                gl.addGraphic("vcsgis-highlighted", geom, symbolid);
231
                if (symbol != null) {
232
                    int symbolid = gl.getSymbolId(symbol);
233
                    if (symbolid < 0) {
234
                        gl.addSymbol(symbol);
235
                        symbolid = gl.getSymbolId(symbol);
236
                    }
237
                    gl.addGraphic("vcsgis-highlighted", geom, symbolid);
238
                }
224 239
            }
240
            mapContext.invalidate();
225 241
        }
226
        mapContext.invalidate();
227 242
    }
228 243

  
229 244
    @Override
......
238 253
    }
239 254

  
240 255
    @Override
256
    public void centerViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) {
257
        if(geometry != null){
258
            List<ViewDocument> views = getViewDocumentsHavingAStore(store);
259
            for (ViewDocument view : views) {
260
                if(view != null){
261
                    view.center(geometry.getEnvelope());
262
                }
263
            }
264
        }
265
    }
266

  
267
    @Override
241 268
    public void zoomActiveViewToGeometry(Geometry geometry) {
242 269
        if(geometry != null){
243 270
            IView view = getActiveView();
......
248 275
        }
249 276
    }
250 277

  
278
    @Override
279
    public void zoomViewsHavingAStoreToGeometry(FeatureStore store, Geometry geometry) {
280
        if(geometry != null){
281
            List<ViewDocument> views = getViewDocumentsHavingAStore(store);
282
            for (ViewDocument view : views) {
283
                if(view != null){
284
                    view.getMapContext().getViewPort().setEnvelope(geometry.getEnvelope());
285
                }
286
            }
287
        }
288
    }
289

  
251 290
    private IView getActiveView() {
252 291
        ApplicationManager application = ApplicationLocator.getManager();
253 292
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
......
257 296
    @Override
258 297
    public void cleanHighligthed() {
259 298
        ApplicationManager application = ApplicationLocator.getManager();
299
        ProjectManager projectManager = application.getProjectManager();
300
        Project project = projectManager.getCurrentProject();
301
        List<Document> views = project.getDocuments(ViewManager.TYPENAME);
302
        for (Document doc : views) {
303
            ViewDocument viewdoc = (ViewDocument)doc;
304
            MapContext mapContext = viewdoc.getMapContext();
305
            GraphicLayer gl = mapContext.getGraphicsLayer();
306
            //FIXME: Refrescar el mapContext solo cuando se ha borrado el graphics  
307
            if(gl.removeGraphics("vcsgis-highlighted")) {
308
                mapContext.invalidate();
309
            }
310
        }
311
    }
312
    
313
    @Override
314
    public void cleanActiveViewHighligthed() {
315
        ApplicationManager application = ApplicationLocator.getManager();
260 316
        ViewDocument viewdoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
261 317
        if(viewdoc != null){
262 318
            MapContext mapContext = viewdoc.getMapContext();
......
302 358
        }
303 359
    }
304 360

  
361
    
362
    public List<ViewDocument> getViewDocumentsHavingAStore(FeatureStore store){
363
        if(store == null){
364
            return null;
365
        }
366
        List<ViewDocument> viewList = new ArrayList<>();
367
        
368
        String storeFullName = store.getFullName();
369
        ApplicationManager application = ApplicationLocator.getManager();
370
        ProjectManager projectManager = application.getProjectManager();
371
        Project project = projectManager.getCurrentProject();
372
        List<Document> views = project.getDocuments(ViewManager.TYPENAME);
373
        for (Document doc : views) {
374
            ViewDocument view = (ViewDocument) doc;
375
            for (Iterator<FLayer> it = view.deepiterator(); it.hasNext();) {
376
                FLayer layer = it.next();
377
                if (layer instanceof FLyrVect) {
378
                    if (StringUtils.equals(
379
                            ((FLyrVect) layer).getFeatureStore().getFullName(),
380
                            store.getFullName()
381
                    )) {
382
                        viewList.add(view);
383
                    }
384
                    break;
385
                }
386
            }
387
        }
388
        return viewList;
389
    }
390

  
305 391
    @Override
306 392
    public void addLayerToActiveView(FeatureStore store, String name) {
307 393
        if(store != null && StringUtils.isNotBlank(name)){

Also available in: Unified diff