svn-gvsig-desktop / tags / v1_1_Build_1008 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourcePanel.java @ 12520
History | View | Annotate | Download (4.66 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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 2
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Ib??ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* IVER T.I. S.A
|
35 |
* Salamanca 50
|
36 |
* 46005 Valencia
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 963163400
|
40 |
* dac@iver.es
|
41 |
*/
|
42 |
package es.gva.cit.catalogClient.ui.chooseResource; |
43 |
import es.gva.cit.catalogClient.schemas.discoverer.Resource; |
44 |
import es.gva.cit.catalogClient.utils.ResourcesTable.TableModel; |
45 |
import java.util.Collection; |
46 |
import javax.swing.JButton; |
47 |
import javax.swing.JPanel; |
48 |
import javax.swing.JScrollPane; |
49 |
import javax.swing.JTable; |
50 |
|
51 |
import org.gvsig.i18n.Messages; |
52 |
|
53 |
/**
|
54 |
*
|
55 |
*
|
56 |
*
|
57 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
58 |
*/
|
59 |
public class ChooseResourcePanel extends JPanel { |
60 |
/**
|
61 |
*
|
62 |
*
|
63 |
*/
|
64 |
private JTable table = null; |
65 |
/**
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
private JScrollPane tablePane = null; |
70 |
|
71 |
/**
|
72 |
*
|
73 |
*
|
74 |
*/
|
75 |
private java.util.Collection resources = new java.util.ArrayList(); |
76 |
|
77 |
/**
|
78 |
* This method initializes
|
79 |
*
|
80 |
*
|
81 |
* @param resources
|
82 |
* @param translator
|
83 |
*/
|
84 |
public ChooseResourcePanel(Collection resources) { |
85 |
super();
|
86 |
this.resources = resources;
|
87 |
initialize(); |
88 |
} |
89 |
|
90 |
/**
|
91 |
* It creates the table model
|
92 |
*
|
93 |
*
|
94 |
* @return
|
95 |
*/
|
96 |
private TableModel createTableModel() { |
97 |
Object[][] columnValues = new Object[resources.size()][3]; |
98 |
String[] columnNames = {Messages.getText("resourceTypeColumn"), |
99 |
Messages.getText("resourceLinkColumn"),
|
100 |
Messages.getText("resourceShowColumn")};
|
101 |
|
102 |
for (int i=0 ; i<resources.size() ; i++){ |
103 |
Resource resource = (Resource)resources.toArray()[i]; |
104 |
columnValues[i][0] = resource.getProtocol();
|
105 |
columnValues[i][1] = resource.getLinkage();
|
106 |
columnValues[i][2] = getNameButton(resource.getProtocol());
|
107 |
} |
108 |
|
109 |
return new TableModel(columnValues,columnNames); |
110 |
} |
111 |
|
112 |
/**
|
113 |
*
|
114 |
*
|
115 |
*
|
116 |
* @return
|
117 |
* @param protocol
|
118 |
*/
|
119 |
private String getNameButton(String protocol) { |
120 |
if (protocol.toUpperCase().indexOf(Resource.WCS) >= 0) |
121 |
return Messages.getText("wcsColumn"); |
122 |
|
123 |
if (protocol.toUpperCase().indexOf(Resource.WMS) >= 0) |
124 |
return Messages.getText("wmsColumn"); |
125 |
|
126 |
if (protocol.toUpperCase().indexOf(Resource.WFS) >= 0) |
127 |
return Messages.getText("wfsColumn"); |
128 |
|
129 |
if (protocol.toUpperCase().indexOf(Resource.POSTGIS) >= 0) |
130 |
return Messages.getText("postgisColumn"); |
131 |
|
132 |
if (protocol.toUpperCase().indexOf(Resource.WEBSITE) >= 0) |
133 |
return Messages.getText("linkColumn"); |
134 |
|
135 |
if (protocol.toUpperCase().indexOf(Resource.DOWNLOAD) >= 0) |
136 |
return Messages.getText("downloadColumn"); |
137 |
|
138 |
if (protocol.toUpperCase().indexOf(Resource.ARCIMS_IMAGE) >= 0) |
139 |
return Messages.getText("arcims_image_resource"); |
140 |
|
141 |
if (protocol.toUpperCase().indexOf(Resource.ARCIMS_VECTORIAL) >= 0) |
142 |
return Messages.getText("arcims_vect_resource"); |
143 |
|
144 |
return Messages.getText("unknown"); |
145 |
} |
146 |
|
147 |
/**
|
148 |
*
|
149 |
*
|
150 |
*/
|
151 |
private void initialize() { |
152 |
this.setSize(510, 125); |
153 |
this.add(getTablePane(), null); |
154 |
|
155 |
} |
156 |
|
157 |
/**
|
158 |
*
|
159 |
*
|
160 |
*
|
161 |
* @return
|
162 |
*/
|
163 |
public JScrollPane getTablePane() { |
164 |
if (tablePane == null) { |
165 |
tablePane = new JScrollPane(getTable()); |
166 |
tablePane.setPreferredSize(new java.awt.Dimension(575,100)); |
167 |
|
168 |
} |
169 |
return tablePane;
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* This method initializes table
|
174 |
*
|
175 |
*
|
176 |
* @return javax.swing.JTable
|
177 |
*/
|
178 |
public JTable getTable() { |
179 |
if (table == null) { |
180 |
table = new JTable(createTableModel()); |
181 |
|
182 |
} |
183 |
return table;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* It Return the JButtons array
|
188 |
*
|
189 |
*
|
190 |
* @return
|
191 |
*/
|
192 |
public JButton[] getButtons() { |
193 |
JButton[] buttons = new JButton[resources.size()]; |
194 |
for (int i=0 ; i<resources.size() ; i++) |
195 |
buttons[i] = (JButton) getTable().getModel().getValueAt(i,2); |
196 |
|
197 |
return buttons;
|
198 |
} |
199 |
} |