svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / ShowResultsDialogPanel.java @ 3081
History | View | Annotate | Download (7.07 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package es.gva.cit.catalogClient.ui; |
42 |
|
43 |
|
44 |
import es.gva.cit.catalogClient.CatalogClient; |
45 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
46 |
import es.gva.cit.catalogClient.metadataXML.XMLTreeNumberOfRecordsAnswer; |
47 |
import es.gva.cit.catalogClient.parsers.Resource; |
48 |
|
49 |
|
50 |
import java.awt.event.ActionEvent; |
51 |
import java.awt.event.ActionListener; |
52 |
|
53 |
import javax.swing.JButton; |
54 |
import javax.swing.JDialog; |
55 |
import javax.swing.JPanel; |
56 |
|
57 |
|
58 |
/**
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
*/
|
61 |
public class ShowResultsDialogPanel extends JPanel implements ActionListener { |
62 |
//It is needed to close the frame
|
63 |
private JDialog parent; |
64 |
|
65 |
public ShowResultsPanel ppalPanel = null; |
66 |
public XMLNode[] nodes = null; |
67 |
CatalogClient client = null;
|
68 |
int currentRecord = 0; |
69 |
|
70 |
JButton nextButton = null; |
71 |
JButton lastButton = null; |
72 |
JButton descriptionButton = null; |
73 |
JButton mapButton = null; |
74 |
JButton closeButton = null; |
75 |
|
76 |
public ShowResultsDialogPanel(CatalogClient client, XMLNode[] nodes, |
77 |
int currentRecord) {
|
78 |
this.nodes = nodes;
|
79 |
this.client = client;
|
80 |
this.currentRecord = currentRecord;
|
81 |
|
82 |
int numRecords = XMLTreeNumberOfRecordsAnswer.getNumberOfRecords(nodes[0]); |
83 |
ppalPanel = new ShowResultsPanel(nodes[currentRecord],
|
84 |
client.getProtocol(), numRecords,client.getUrl()); |
85 |
ppalPanel = new ShowResultsPanel(nodes[currentRecord],
|
86 |
client.getProtocol(), numRecords,client.getUrl()); |
87 |
|
88 |
setDefaultButtonListeners(); |
89 |
enableMapButton(); |
90 |
|
91 |
add(ppalPanel); |
92 |
} |
93 |
|
94 |
public void enableMapButton(){ |
95 |
getMapButton().setEnabled(false);
|
96 |
Resource[] resources = ppalPanel.getTags().getResources();
|
97 |
if (resources == null) |
98 |
return;
|
99 |
for (int i = 0; i < resources.length; i++) { |
100 |
String protocol = resources[i].getProtocol();
|
101 |
|
102 |
if (protocol != null){ |
103 |
if ((protocol.toLowerCase().indexOf("ogc:wcs") >= 0) || |
104 |
(protocol.toLowerCase().indexOf("ogc:wms") >=0) || |
105 |
(protocol.toLowerCase().indexOf("ogc:wfs") >=0) || |
106 |
(protocol.toLowerCase().indexOf("postgis") >=0) || |
107 |
(protocol.toLowerCase().indexOf("www:link") >=0) || |
108 |
(protocol.toLowerCase().indexOf("www:download") >=0)){ |
109 |
getMapButton().setEnabled(true);
|
110 |
return;
|
111 |
} |
112 |
} |
113 |
} |
114 |
|
115 |
} |
116 |
|
117 |
public void setDefaultButtonListeners() { |
118 |
nextButton = ppalPanel.getNextButton(); |
119 |
lastButton = ppalPanel.getLastButton(); |
120 |
descriptionButton = ppalPanel.getDescriptionButton(); |
121 |
mapButton = ppalPanel.getMapButton(); |
122 |
closeButton = ppalPanel.getCloseButton(); |
123 |
|
124 |
nextButton.addActionListener(this);
|
125 |
lastButton.addActionListener(this);
|
126 |
descriptionButton.addActionListener(this);
|
127 |
mapButton.addActionListener(this);
|
128 |
closeButton.addActionListener(this);
|
129 |
} |
130 |
|
131 |
public JButton getDescriptionButton() { |
132 |
return descriptionButton;
|
133 |
} |
134 |
|
135 |
public JButton getMapButton() { |
136 |
return mapButton;
|
137 |
} |
138 |
|
139 |
public JButton getCloseButton(){ |
140 |
return closeButton;
|
141 |
} |
142 |
|
143 |
public void createNewSearch(int firstRecord) { |
144 |
XMLNode[] nodesRecords = null; |
145 |
|
146 |
nodesRecords = client.getLnkICatalogServerDriver().getRecords(client.getUrl(), |
147 |
null, firstRecord);
|
148 |
|
149 |
this.nodes = nodesRecords;
|
150 |
} |
151 |
|
152 |
public int getCurrentNode() { |
153 |
if ((currentRecord % 10) == 0) { |
154 |
return 10; |
155 |
} else {
|
156 |
return (currentRecord % 10); |
157 |
} |
158 |
} |
159 |
|
160 |
public void actionPerformed(ActionEvent e) { |
161 |
if (e.getActionCommand().equals("Siguiente")) { |
162 |
nextButtonActionPerformed(); |
163 |
} |
164 |
if (e.getActionCommand().equals("Anterior")) { |
165 |
lastButtonActionPerformed(); |
166 |
} |
167 |
if (e.getActionCommand().equals("Descripcion")) { |
168 |
descriptionButtonActionPerformed(); |
169 |
} |
170 |
if (e.getActionCommand().equals("A?adir Capa")) { |
171 |
mapButtonActionPerformed(); |
172 |
} |
173 |
if (e.getActionCommand().equals("Cerrar")) { |
174 |
closeButtonActionPerformed(); |
175 |
} |
176 |
|
177 |
} |
178 |
|
179 |
public void nextButtonActionPerformed() { |
180 |
this.currentRecord = this.currentRecord + 1; |
181 |
|
182 |
if (this.currentRecord == XMLTreeNumberOfRecordsAnswer.getNumberOfRecords( |
183 |
nodes[0])) {
|
184 |
nextButton.setEnabled(false);
|
185 |
} else {
|
186 |
nextButton.setEnabled(true);
|
187 |
} |
188 |
|
189 |
lastButton.setEnabled(true);
|
190 |
|
191 |
if ((this.currentRecord % 10) == 1) { |
192 |
createNewSearch(currentRecord); |
193 |
} |
194 |
|
195 |
ppalPanel.loadTextNewRecord(nodes[getCurrentNode()], |
196 |
client.getProtocol()); |
197 |
ppalPanel.actualizaLabel(currentRecord); |
198 |
|
199 |
enableMapButton(); |
200 |
} |
201 |
|
202 |
public void lastButtonActionPerformed() { |
203 |
this.currentRecord = this.currentRecord - 1; |
204 |
|
205 |
if (this.currentRecord == 1) { |
206 |
lastButton.setEnabled(false);
|
207 |
} else {
|
208 |
lastButton.setEnabled(true);
|
209 |
} |
210 |
|
211 |
nextButton.setEnabled(true);
|
212 |
|
213 |
if ((this.currentRecord % 10) == 0) { |
214 |
createNewSearch(currentRecord - 10 + 1); |
215 |
} |
216 |
|
217 |
ppalPanel.loadTextNewRecord(nodes[getCurrentNode()], |
218 |
client.getProtocol()); |
219 |
ppalPanel.actualizaLabel(currentRecord); |
220 |
|
221 |
enableMapButton(); |
222 |
} |
223 |
|
224 |
public void descriptionButtonActionPerformed() { |
225 |
ShowTreeDialog frame = new ShowTreeDialog(nodes[getCurrentNode()]);
|
226 |
} |
227 |
|
228 |
public void mapButtonActionPerformed() { |
229 |
Resource[] resources = ppalPanel.getTags().getResources();
|
230 |
ChooseResourceDialog dialog = new ChooseResourceDialog(resources);
|
231 |
|
232 |
} |
233 |
|
234 |
public void closeButtonActionPerformed() { |
235 |
parent.setVisible(false);
|
236 |
} |
237 |
/**
|
238 |
* @param parent The parent to set.
|
239 |
*/
|
240 |
public void setParent(JDialog parent) { |
241 |
this.parent = parent;
|
242 |
} |
243 |
} |