root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / gui / results / ResultsPanel.java @ 27756
History | View | Annotate | Download (5.81 KB)
1 |
/*
|
---|---|
2 |
* To change this template, choose Tools | Templates
|
3 |
* and open the template in the editor.
|
4 |
*/
|
5 |
|
6 |
/*
|
7 |
* SettingsPanel.java
|
8 |
*
|
9 |
* Created on 16-mar-2009, 12:41:50
|
10 |
*/
|
11 |
|
12 |
package org.gvsig.geocoding.gui.results; |
13 |
|
14 |
import java.io.File; |
15 |
import java.util.Set; |
16 |
|
17 |
import javax.swing.ImageIcon; |
18 |
import javax.swing.JButton; |
19 |
import javax.swing.JPanel; |
20 |
import javax.swing.JScrollPane; |
21 |
import javax.swing.JTable; |
22 |
|
23 |
import org.gvsig.fmap.geom.primitive.Point2D; |
24 |
import org.gvsig.geocoding.extension.GeocoController; |
25 |
import org.gvsig.geocoding.gui.TableResultsModel; |
26 |
import org.gvsig.geocoding.result.GeocodingResult; |
27 |
import org.gvsig.geocoding.utils.GeocoUtils; |
28 |
import org.slf4j.Logger; |
29 |
import org.slf4j.LoggerFactory; |
30 |
|
31 |
import com.iver.andami.PluginServices; |
32 |
import com.iver.andami.ui.mdiManager.IWindow; |
33 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
34 |
|
35 |
/**
|
36 |
*
|
37 |
* @author vsanjaime
|
38 |
*/
|
39 |
public class ResultsPanel extends JPanel implements IWindow { |
40 |
|
41 |
private static final long serialVersionUID = 1L; |
42 |
private Logger log = LoggerFactory.getLogger(ResultsPanel.class); |
43 |
|
44 |
private GeocoController control = null; |
45 |
|
46 |
private JButton jButUpdate; |
47 |
private JButton jButCancel; |
48 |
private JPanel jPanButtons; |
49 |
private JPanel jPanResults; |
50 |
private JScrollPane jScrollResults; |
51 |
private JTable jTableResults; |
52 |
|
53 |
/**
|
54 |
* Constructor
|
55 |
*/
|
56 |
public ResultsPanel(GeocoController control) {
|
57 |
this.control = control;
|
58 |
initComponents(); |
59 |
|
60 |
setImages(); |
61 |
setMesages(); |
62 |
} |
63 |
|
64 |
/**
|
65 |
* Initialize panel components
|
66 |
*/
|
67 |
private void initComponents() { |
68 |
java.awt.GridBagConstraints gridBagConstraints; |
69 |
|
70 |
jPanResults = new JPanel(); |
71 |
jScrollResults = new JScrollPane(); |
72 |
jTableResults = new JTable(); |
73 |
jPanButtons = new JPanel(); |
74 |
jButUpdate = new JButton(); |
75 |
jButCancel = new JButton(); |
76 |
|
77 |
setLayout(new java.awt.GridBagLayout());
|
78 |
|
79 |
jPanResults.setLayout(new java.awt.GridBagLayout());
|
80 |
|
81 |
jTableResults.setModel(new TableResultsModel(control));
|
82 |
jTableResults |
83 |
.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
|
84 |
public void propertyChange( |
85 |
java.beans.PropertyChangeEvent evt) { |
86 |
evChangeElement(evt); |
87 |
} |
88 |
}); |
89 |
jScrollResults.setViewportView(jTableResults); |
90 |
|
91 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
92 |
gridBagConstraints.gridx = 0;
|
93 |
gridBagConstraints.gridy = 0;
|
94 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
95 |
gridBagConstraints.weightx = 1.0;
|
96 |
gridBagConstraints.weighty = 1.0;
|
97 |
jPanResults.add(jScrollResults, gridBagConstraints); |
98 |
|
99 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
100 |
gridBagConstraints.gridx = 0;
|
101 |
gridBagConstraints.gridy = 0;
|
102 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
103 |
gridBagConstraints.weightx = 1.0;
|
104 |
gridBagConstraints.weighty = 1.0;
|
105 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
106 |
add(jPanResults, gridBagConstraints); |
107 |
|
108 |
jPanButtons.setLayout(new java.awt.GridBagLayout());
|
109 |
|
110 |
jButUpdate.setText("Update");
|
111 |
jButUpdate.addActionListener(new java.awt.event.ActionListener() {
|
112 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
113 |
evUpdate(evt); |
114 |
} |
115 |
}); |
116 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
117 |
gridBagConstraints.gridx = 0;
|
118 |
gridBagConstraints.gridy = 0;
|
119 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 10); |
120 |
jPanButtons.add(jButUpdate, gridBagConstraints); |
121 |
|
122 |
jButCancel.setText("cancel");
|
123 |
jButCancel.addActionListener(new java.awt.event.ActionListener() {
|
124 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
125 |
evCancel(evt); |
126 |
} |
127 |
}); |
128 |
jPanButtons.add(jButCancel, new java.awt.GridBagConstraints());
|
129 |
|
130 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
131 |
gridBagConstraints.gridx = 0;
|
132 |
gridBagConstraints.gridy = 1;
|
133 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
134 |
gridBagConstraints.weightx = 1.0;
|
135 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
136 |
add(jPanButtons, gridBagConstraints); |
137 |
} |
138 |
|
139 |
/**
|
140 |
*
|
141 |
* @param evt
|
142 |
*/
|
143 |
private void evUpdate(java.awt.event.ActionEvent evt) { |
144 |
// TODO add your handling code here:
|
145 |
} |
146 |
|
147 |
/**
|
148 |
*
|
149 |
* @param evt
|
150 |
*/
|
151 |
private void evCancel(java.awt.event.ActionEvent evt) { |
152 |
IWindow[] iws = PluginServices.getMDIManager().getAllWindows();
|
153 |
for (int i = 0; i < iws.length; i++) { |
154 |
if (iws[i] instanceof ResultsPanel) { |
155 |
PluginServices.getMDIManager().closeWindow(iws[i]); |
156 |
} |
157 |
} |
158 |
} |
159 |
|
160 |
/**
|
161 |
*
|
162 |
* @param evt
|
163 |
*/
|
164 |
private void evChangeElement(java.beans.PropertyChangeEvent evt) { |
165 |
int row = jTableResults.getSelectedRow();
|
166 |
TableResultsModel model = (TableResultsModel) jTableResults.getModel(); |
167 |
// zoom to geom
|
168 |
if (row != -1) { |
169 |
Point2D pto = model.getGeometry(row);
|
170 |
|
171 |
try {
|
172 |
control.zoomToPoint(pto.getX(), pto.getY()); |
173 |
} catch (Exception e) { |
174 |
log.error("Doing zoom to point", e);
|
175 |
} |
176 |
} |
177 |
|
178 |
} |
179 |
|
180 |
public void setResuts(Set<GeocodingResult> results) { |
181 |
|
182 |
} |
183 |
|
184 |
/**
|
185 |
*
|
186 |
*/
|
187 |
private void setImages() { |
188 |
PluginServices ps = PluginServices.getPluginServices(this);
|
189 |
if (ps != null) { |
190 |
String baseDir = ps.getClassLoader().getBaseDir();
|
191 |
jButUpdate.setIcon(new ImageIcon(baseDir + File.separator |
192 |
+ "images" + File.separator + "icons16" + File.separator |
193 |
+ "open.png"));
|
194 |
jButCancel.setIcon(new ImageIcon(baseDir + File.separator |
195 |
+ "images" + File.separator + "icons16" + File.separator |
196 |
+ "out.png"));
|
197 |
} |
198 |
} |
199 |
|
200 |
/**
|
201 |
*
|
202 |
*/
|
203 |
private void setMesages() { |
204 |
PluginServices ps = PluginServices.getPluginServices(this);
|
205 |
if (ps != null) { |
206 |
this.jButUpdate.setToolTipText(ps.getText("butloadpattern")); |
207 |
this.jButCancel.setText(ps.getText("exit")); |
208 |
} |
209 |
} |
210 |
|
211 |
/**
|
212 |
* get window info
|
213 |
*/
|
214 |
public WindowInfo getWindowInfo() {
|
215 |
WindowInfo info = new WindowInfo(WindowInfo.RESIZABLE);
|
216 |
info.setMinimumSize(this.getMinimumSize());
|
217 |
info.setWidth(500);
|
218 |
info.setHeight(200);
|
219 |
info.setTitle(PluginServices.getText(this, "geocoding_all_results")); |
220 |
return info;
|
221 |
} |
222 |
|
223 |
public Object getWindowProfile() { |
224 |
|
225 |
return null; |
226 |
} |
227 |
|
228 |
} |