root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / DataLoadingFromActiveView.java @ 10778
History | View | Annotate | Download (3.73 KB)
1 | 8394 | ppiqueras | package com.iver.cit.gvsig.gui.panels; |
---|---|---|---|
2 | |||
3 | import com.hardcode.driverManager.DriverLoadException; |
||
4 | 10627 | caballero | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
5 | 8394 | ppiqueras | import com.iver.andami.PluginServices; |
6 | import com.iver.andami.messages.NotificationManager; |
||
7 | import com.iver.andami.ui.mdiManager.IWindow; |
||
8 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
9 | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
||
10 | import com.iver.cit.gvsig.gui.filter.DefaultExpressionDataSource; |
||
11 | import com.iver.cit.gvsig.project.documents.table.gui.Table; |
||
12 | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
||
13 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
14 | |||
15 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
16 | *
|
||
17 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
18 | *
|
||
19 | * This program is free software; you can redistribute it and/or
|
||
20 | * modify it under the terms of the GNU General Public License
|
||
21 | * as published by the Free Software Foundation; either version 2
|
||
22 | * of the License, or (at your option) any later version.
|
||
23 | *
|
||
24 | * This program is distributed in the hope that it will be useful,
|
||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
27 | * GNU General Public License for more details.
|
||
28 | *
|
||
29 | * You should have received a copy of the GNU General Public License
|
||
30 | * along with this program; if not, write to the Free Software
|
||
31 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
32 | *
|
||
33 | * For more information, contact:
|
||
34 | *
|
||
35 | * Generalitat Valenciana
|
||
36 | * Conselleria d'Infraestructures i Transport
|
||
37 | * Av. Blasco Ib??ez, 50
|
||
38 | * 46010 VALENCIA
|
||
39 | * SPAIN
|
||
40 | *
|
||
41 | * +34 963862235
|
||
42 | * gvsig@gva.es
|
||
43 | * www.gvsig.gva.es
|
||
44 | *
|
||
45 | * or
|
||
46 | *
|
||
47 | * IVER T.I. S.A
|
||
48 | * Salamanca 50
|
||
49 | * 46005 Valencia
|
||
50 | * Spain
|
||
51 | *
|
||
52 | * +34 963163400
|
||
53 | * dac@iver.es
|
||
54 | */
|
||
55 | |||
56 | /**
|
||
57 | * This class has specific code for "WFSFilterPanel" extracted from "FiltroExension" that should be in "WFSFilterPanel" but that has a conflict in the "DriverException" class
|
||
58 | 10627 | caballero | * (because there are 2 classes with the same name "DriverException" but with different code: one in "libFMap" and another in "libGDBMS").
|
59 | *
|
||
60 | 8394 | ppiqueras | * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
61 | */
|
||
62 | public class DataLoadingFromActiveView { |
||
63 | 10627 | caballero | |
64 | 8394 | ppiqueras | /**
|
65 | 10627 | caballero | * This method returns data of the active Window or null if there is no active window or the active window isn't
|
66 | 8394 | ppiqueras | * @return
|
67 | */
|
||
68 | public static DataReturnedOfDataLoadingFromActiveView getDefaultExpressionDataSource() { |
||
69 | DefaultExpressionDataSource ds = null;
|
||
70 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
71 | SelectableDataSource dataSource = null;
|
||
72 | String filterTitle = ""; |
||
73 | |||
74 | if ((window == null) || (!(window instanceof View))) { |
||
75 | return null; |
||
76 | } |
||
77 | else {
|
||
78 | 10627 | caballero | |
79 | 8394 | ppiqueras | // Tryes to acces to the ActivedWindow and get the data from its selected layer
|
80 | try {
|
||
81 | 10627 | caballero | |
82 | 8394 | ppiqueras | if (window instanceof Table) { |
83 | Table vista = (Table) window; |
||
84 | 10627 | caballero | |
85 | 8394 | ppiqueras | dataSource = (SelectableDataSource)vista.getModel().getModelo().getRecordset(); |
86 | 10627 | caballero | |
87 | 8394 | ppiqueras | } else if (window instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
88 | IProjectView pv = ((com.iver.cit.gvsig.project.documents.view.gui.View) window).getModel(); |
||
89 | filterTitle = ((com.iver.cit.gvsig.project.documents.view.gui.View) window).getModel().getName(); |
||
90 | FLayer layer = pv.getMapContext().getLayers().getActives()[0];
|
||
91 | if (layer == null) |
||
92 | return null; |
||
93 | 10627 | caballero | |
94 | 8394 | ppiqueras | dataSource = pv.getProject().getDataSourceByLayer(layer); |
95 | |||
96 | } |
||
97 | 10627 | caballero | } catch (ReadDriverException de) {
|
98 | 8394 | ppiqueras | NotificationManager.addError("Error filtrando", de);
|
99 | return null; |
||
100 | } |
||
101 | 10627 | caballero | |
102 | 8394 | ppiqueras | // Load values for return them
|
103 | 10751 | jaume | |
104 | ds = new DefaultExpressionDataSource();
|
||
105 | ds.setTable(dataSource); |
||
106 | |||
107 | 8394 | ppiqueras | } |
108 | 10627 | caballero | |
109 | 8394 | ppiqueras | return new DataReturnedOfDataLoadingFromActiveView(ds, filterTitle); |
110 | } |
||
111 | } |