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