svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / exportto / swing / impl / panel / ExportFilterPanel.java @ 41537
History | View | Annotate | Download (6.18 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.exportto.swing.impl.panel; |
25 |
|
26 |
import java.awt.event.ActionEvent; |
27 |
import java.awt.event.ActionListener; |
28 |
import java.util.Iterator; |
29 |
import javax.swing.DefaultListModel; |
30 |
import org.gvsig.exportto.ExporttoLocator; |
31 |
import org.gvsig.exportto.ExporttoManager; |
32 |
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel; |
33 |
import org.gvsig.fmap.dal.DALLocator; |
34 |
import org.gvsig.fmap.dal.DataManager; |
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 |
import org.gvsig.tools.ToolsLocator; |
37 |
import org.gvsig.tools.dynobject.DynObject; |
38 |
import org.gvsig.tools.dynobject.DynObjectManager; |
39 |
import org.gvsig.tools.evaluator.Evaluator; |
40 |
import org.gvsig.tools.evaluator.EvaluatorData; |
41 |
|
42 |
/**
|
43 |
* @author gvSIG Team
|
44 |
* @version $Id$
|
45 |
*
|
46 |
*/
|
47 |
public class ExportFilterPanel extends ExportFilterPanelLayout { |
48 |
|
49 |
private FeatureStore store;
|
50 |
|
51 |
public ExportFilterPanel(DefaultJExporttoServicePanel exporttoServicePanel) {
|
52 |
this.store = null; |
53 |
this.initComponents();
|
54 |
} |
55 |
|
56 |
private static class FilterItem { |
57 |
private final String label; |
58 |
private final String value; |
59 |
public FilterItem(String label, String value) { |
60 |
this.label=label;
|
61 |
this.value=value;
|
62 |
} |
63 |
@Override
|
64 |
public String toString() { |
65 |
return this.label; |
66 |
} |
67 |
} |
68 |
|
69 |
private void initComponents() { |
70 |
ExporttoManager manager = ExporttoLocator.getManager(); |
71 |
|
72 |
DefaultListModel model = new DefaultListModel(); |
73 |
Iterator filterNames = manager.getPredefinedFilters();
|
74 |
while( filterNames.hasNext() ) {
|
75 |
String name = (String) filterNames.next(); |
76 |
String expresion = manager.getFilter(name);
|
77 |
model.addElement(new FilterItem(name, expresion));
|
78 |
} |
79 |
this.lstFilters.setModel(model);
|
80 |
if( model.size()<1 ) { |
81 |
this.rdbFilteredRows.setEnabled(false); |
82 |
} |
83 |
this.rdbAllRows.addActionListener(new ActionListener() { |
84 |
public void actionPerformed(ActionEvent e) { |
85 |
doChangeOption(); |
86 |
} |
87 |
}); |
88 |
this.rdbFilteredRows.addActionListener(new ActionListener() { |
89 |
public void actionPerformed(ActionEvent e) { |
90 |
doChangeOption(); |
91 |
} |
92 |
}); |
93 |
this.rdbSelectedRows.addActionListener(new ActionListener() { |
94 |
public void actionPerformed(ActionEvent e) { |
95 |
doChangeOption(); |
96 |
} |
97 |
}); |
98 |
this.rdbAllRows.setSelected(true); |
99 |
this.butTest.addActionListener(new ActionListener() { |
100 |
public void actionPerformed(ActionEvent e) { |
101 |
doTest(); |
102 |
} |
103 |
}); |
104 |
} |
105 |
|
106 |
private static class Data implements EvaluatorData { |
107 |
private final DynObject data; |
108 |
|
109 |
public Data(DynObject data) {
|
110 |
this.data = data;
|
111 |
} |
112 |
public Object getDataValue(String name) { |
113 |
return this.data.getDynValue(name); |
114 |
} |
115 |
|
116 |
public Object getContextValue(String name) { |
117 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
118 |
} |
119 |
|
120 |
public Iterator getDataValues() { |
121 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
122 |
} |
123 |
|
124 |
public Iterator getDataNames() { |
125 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
126 |
} |
127 |
|
128 |
public boolean hasDataValue(String name) { |
129 |
return this.data.hasDynValue(name); |
130 |
} |
131 |
|
132 |
public boolean hasContextValue(String name) { |
133 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
134 |
} |
135 |
} |
136 |
|
137 |
protected void doTest() { |
138 |
String filter = this.getFilter(); |
139 |
if( filter == null ) { |
140 |
return;
|
141 |
} |
142 |
DynObjectManager dynobjmanager = ToolsLocator.getDynObjectManager(); |
143 |
DynObject values = dynobjmanager.createDynObject(this.store.getDefaultFeatureType());
|
144 |
DataManager datamanager = DALLocator.getDataManager(); |
145 |
Evaluator evaluator = datamanager.createExpresion(filter); |
146 |
evaluator.e |
147 |
|
148 |
} |
149 |
|
150 |
protected void doChangeOption(){ |
151 |
if( this.rdbAllRows.isSelected() ) { |
152 |
this.lstFilters.setEnabled(false); |
153 |
this.txtName.setEnabled(false); |
154 |
this.txtExpresion.setEnabled(false); |
155 |
} else if( this.rdbFilteredRows.isSelected() ) { |
156 |
this.lstFilters.setEnabled(true); |
157 |
this.txtName.setEnabled(true); |
158 |
this.txtExpresion.setEnabled(true); |
159 |
} else if( this.rdbSelectedRows.isSelected() ) { |
160 |
this.lstFilters.setEnabled(false); |
161 |
this.txtName.setEnabled(false); |
162 |
this.txtExpresion.setEnabled(false); |
163 |
} |
164 |
} |
165 |
|
166 |
public boolean isFullLayerSelected() { |
167 |
return this.rdbAllRows.isSelected(); |
168 |
} |
169 |
|
170 |
public boolean isSelectedFeaturesSelected() { |
171 |
return this.rdbSelectedRows.isSelected(); |
172 |
} |
173 |
|
174 |
public boolean isPersonalizedFilterSelected() { |
175 |
return this.rdbFilteredRows.isSelected(); |
176 |
} |
177 |
|
178 |
public String getFilter() { |
179 |
} |
180 |
|
181 |
} |