root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / DataLoadingFromActiveView.java @ 10627
History | View | Annotate | Download (3.8 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import com.hardcode.driverManager.DriverLoadException; |
4 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
5 |
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 |
* (because there are 2 classes with the same name "DriverException" but with different code: one in "libFMap" and another in "libGDBMS").
|
59 |
*
|
60 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
61 |
*/
|
62 |
public class DataLoadingFromActiveView { |
63 |
|
64 |
/**
|
65 |
* This method returns data of the active Window or null if there is no active window or the active window isn't
|
66 |
* @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 |
|
79 |
// Tryes to acces to the ActivedWindow and get the data from its selected layer
|
80 |
try {
|
81 |
|
82 |
if (window instanceof Table) { |
83 |
Table vista = (Table) window; |
84 |
|
85 |
dataSource = (SelectableDataSource)vista.getModel().getModelo().getRecordset(); |
86 |
|
87 |
} 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 |
|
94 |
dataSource = pv.getProject().getDataSourceByLayer(layer); |
95 |
|
96 |
} |
97 |
} catch (ReadDriverException de) {
|
98 |
NotificationManager.addError("Error filtrando", de);
|
99 |
return null; |
100 |
} |
101 |
|
102 |
// Load values for return them
|
103 |
try {
|
104 |
ds = new DefaultExpressionDataSource();
|
105 |
ds.setTable(dataSource); |
106 |
} catch (DriverLoadException e) {
|
107 |
e.printStackTrace(); |
108 |
} |
109 |
} |
110 |
|
111 |
return new DataReturnedOfDataLoadingFromActiveView(ds, filterTitle); |
112 |
} |
113 |
} |