svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourcePanel.java @ 3566
History | View | Annotate | Download (4.74 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 java.util.Collection; |
44 |
|
45 |
import javax.swing.JButton; |
46 |
import javax.swing.JPanel; |
47 |
import javax.swing.JScrollPane; |
48 |
import javax.swing.JTable; |
49 |
|
50 |
import es.gva.cit.catalogClient.schemas.discoverer.Resource; |
51 |
import es.gva.cit.catalogClient.traductor.ITranslator; |
52 |
import es.gva.cit.catalogClient.traductor.Translator; |
53 |
import es.gva.cit.catalogClient.utils.ResourcesTable.TableModel; |
54 |
|
55 |
/**
|
56 |
*
|
57 |
*
|
58 |
*
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
*/
|
61 |
public class ChooseResourcePanel extends JPanel { |
62 |
/**
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
private JTable table = null; |
67 |
/**
|
68 |
*
|
69 |
*
|
70 |
*/
|
71 |
private JScrollPane tablePane = null; |
72 |
/**
|
73 |
*
|
74 |
*
|
75 |
*/
|
76 |
private ITranslator translator = null; |
77 |
|
78 |
/**
|
79 |
*
|
80 |
*
|
81 |
*/
|
82 |
private java.util.Collection resources = new java.util.ArrayList(); |
83 |
|
84 |
/**
|
85 |
* This method initializes
|
86 |
*
|
87 |
*
|
88 |
* @param resources
|
89 |
* @param translator
|
90 |
*/
|
91 |
public ChooseResourcePanel(Collection resources, ITranslator translator) { |
92 |
super();
|
93 |
this.resources = resources;
|
94 |
this.translator = translator;
|
95 |
initialize(); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* It creates the table model
|
100 |
*
|
101 |
*
|
102 |
* @return
|
103 |
*/
|
104 |
private TableModel createTableModel() { |
105 |
Object[][] columnValues = new Object[resources.size()][3]; |
106 |
String[] columnNames = {Translator.getText(translator,"resourceTypeColumn"), |
107 |
Translator.getText(translator,"resourceLinkColumn"),
|
108 |
Translator.getText(translator,"resourceShowColumn")};
|
109 |
|
110 |
for (int i=0 ; i<resources.size() ; i++){ |
111 |
Resource resource = (Resource)resources.toArray()[i]; |
112 |
columnValues[i][0] = resource.getProtocol();
|
113 |
columnValues[i][1] = resource.getLinkage();
|
114 |
columnValues[i][2] = getNameButton(resource.getProtocol());
|
115 |
} |
116 |
|
117 |
return new TableModel(columnValues,columnNames); |
118 |
} |
119 |
|
120 |
/**
|
121 |
*
|
122 |
*
|
123 |
*
|
124 |
* @return
|
125 |
* @param protocol
|
126 |
*/
|
127 |
private String getNameButton(String protocol) { |
128 |
if (protocol.toUpperCase().indexOf(Resource.WCS) >= 0) |
129 |
return Translator.getText(translator,"wcsColumn"); |
130 |
|
131 |
if (protocol.toUpperCase().indexOf(Resource.WMS) >= 0) |
132 |
return Translator.getText(translator,"wmsColumn"); |
133 |
|
134 |
if (protocol.toUpperCase().indexOf(Resource.WFS) >= 0) |
135 |
return Translator.getText(translator,"wfsColumn"); |
136 |
|
137 |
if (protocol.toUpperCase().indexOf(Resource.POSTGIS) >= 0) |
138 |
return Translator.getText(translator,"postgisColumn"); |
139 |
|
140 |
if (protocol.toUpperCase().indexOf(Resource.WEBSITE) >= 0) |
141 |
return Translator.getText(translator,"linkColumn"); |
142 |
|
143 |
if (protocol.toUpperCase().indexOf(Resource.DOWNLOAD) >= 0) |
144 |
return Translator.getText(translator,"downloadColumn"); |
145 |
|
146 |
return Translator.getText(translator,"unknown"); |
147 |
} |
148 |
|
149 |
/**
|
150 |
*
|
151 |
*
|
152 |
*/
|
153 |
private void initialize() { |
154 |
this.setSize(510, 125); |
155 |
this.add(getTablePane(), null); |
156 |
|
157 |
} |
158 |
|
159 |
/**
|
160 |
*
|
161 |
*
|
162 |
*
|
163 |
* @return
|
164 |
*/
|
165 |
public JScrollPane getTablePane() { |
166 |
if (tablePane == null) { |
167 |
tablePane = new JScrollPane(getTable()); |
168 |
tablePane.setPreferredSize(new java.awt.Dimension(575,100)); |
169 |
|
170 |
} |
171 |
return tablePane;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* This method initializes table
|
176 |
*
|
177 |
*
|
178 |
* @return javax.swing.JTable
|
179 |
*/
|
180 |
public JTable getTable() { |
181 |
if (table == null) { |
182 |
table = new JTable(createTableModel()); |
183 |
|
184 |
} |
185 |
return table;
|
186 |
} |
187 |
|
188 |
/**
|
189 |
* It Return the JButtons array
|
190 |
*
|
191 |
*
|
192 |
* @return
|
193 |
*/
|
194 |
public JButton[] getButtons() { |
195 |
JButton[] buttons = new JButton[resources.size()]; |
196 |
for (int i=0 ; i<resources.size() ; i++) |
197 |
buttons[i] = (JButton) getTable().getModel().getValueAt(i,2); |
198 |
|
199 |
return buttons;
|
200 |
} |
201 |
} |