svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourcePanel.java @ 3566
History | View | Annotate | Download (4.74 KB)
1 | 3566 | jorpiell | |
---|---|---|---|
2 | /* gvSIG. Sistema de Informaci??n Geogr??fica de la Generalitat Valenciana
|
||
3 | 3213 | jorpiell | *
|
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 | 3566 | jorpiell | * Av. Blasco Ib????ez, 50
|
25 | 3213 | jorpiell | * 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 | 3566 | jorpiell | import java.util.Collection; |
44 | 3213 | jorpiell | |
45 | import javax.swing.JButton; |
||
46 | import javax.swing.JPanel; |
||
47 | import javax.swing.JScrollPane; |
||
48 | import javax.swing.JTable; |
||
49 | |||
50 | 3509 | jorpiell | import es.gva.cit.catalogClient.schemas.discoverer.Resource; |
51 | 3213 | jorpiell | 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 | 3566 | jorpiell | *
|
57 | *
|
||
58 | *
|
||
59 | 3213 | jorpiell | * @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 | */
|
||
61 | public class ChooseResourcePanel extends JPanel { |
||
62 | 3566 | jorpiell | /**
|
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 | 3213 | jorpiell | super();
|
93 | this.resources = resources;
|
||
94 | this.translator = translator;
|
||
95 | initialize(); |
||
96 | 3566 | jorpiell | } |
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 | 3213 | jorpiell | String[] columnNames = {Translator.getText(translator,"resourceTypeColumn"), |
107 | Translator.getText(translator,"resourceLinkColumn"),
|
||
108 | Translator.getText(translator,"resourceShowColumn")};
|
||
109 | |||
110 | 3566 | jorpiell | 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 | 3213 | jorpiell | } |
116 | |||
117 | return new TableModel(columnValues,columnNames); |
||
118 | 3566 | jorpiell | } |
119 | |||
120 | /**
|
||
121 | *
|
||
122 | *
|
||
123 | *
|
||
124 | * @return
|
||
125 | * @param protocol
|
||
126 | */
|
||
127 | private String getNameButton(String protocol) { |
||
128 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.WCS) >= 0) |
129 | 3463 | jorpiell | return Translator.getText(translator,"wcsColumn"); |
130 | 3213 | jorpiell | |
131 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.WMS) >= 0) |
132 | 3463 | jorpiell | return Translator.getText(translator,"wmsColumn"); |
133 | 3213 | jorpiell | |
134 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.WFS) >= 0) |
135 | 3463 | jorpiell | return Translator.getText(translator,"wfsColumn"); |
136 | 3213 | jorpiell | |
137 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.POSTGIS) >= 0) |
138 | 3463 | jorpiell | return Translator.getText(translator,"postgisColumn"); |
139 | 3213 | jorpiell | |
140 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.WEBSITE) >= 0) |
141 | 3463 | jorpiell | return Translator.getText(translator,"linkColumn"); |
142 | 3213 | jorpiell | |
143 | 3486 | jorpiell | if (protocol.toUpperCase().indexOf(Resource.DOWNLOAD) >= 0) |
144 | return Translator.getText(translator,"downloadColumn"); |
||
145 | 3213 | jorpiell | |
146 | 3486 | jorpiell | return Translator.getText(translator,"unknown"); |
147 | 3566 | jorpiell | } |
148 | |||
149 | /**
|
||
150 | *
|
||
151 | *
|
||
152 | */
|
||
153 | private void initialize() { |
||
154 | 3213 | jorpiell | this.setSize(510, 125); |
155 | this.add(getTablePane(), null); |
||
156 | |||
157 | 3566 | jorpiell | } |
158 | |||
159 | /**
|
||
160 | *
|
||
161 | *
|
||
162 | *
|
||
163 | * @return
|
||
164 | */
|
||
165 | public JScrollPane getTablePane() { |
||
166 | 3213 | jorpiell | if (tablePane == null) { |
167 | tablePane = new JScrollPane(getTable()); |
||
168 | tablePane.setPreferredSize(new java.awt.Dimension(575,100)); |
||
169 | |||
170 | } |
||
171 | return tablePane;
|
||
172 | 3566 | jorpiell | } |
173 | |||
174 | /**
|
||
175 | * This method initializes table
|
||
176 | *
|
||
177 | *
|
||
178 | * @return javax.swing.JTable
|
||
179 | */
|
||
180 | public JTable getTable() { |
||
181 | 3213 | jorpiell | if (table == null) { |
182 | table = new JTable(createTableModel()); |
||
183 | |||
184 | } |
||
185 | return table;
|
||
186 | 3566 | jorpiell | } |
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 | 3213 | jorpiell | buttons[i] = (JButton) getTable().getModel().getValueAt(i,2); |
198 | |||
199 | return buttons;
|
||
200 | 3566 | jorpiell | } |
201 | } |