Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_894 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourcePanel.java @ 10309

History | View | Annotate | Download (4.66 KB)

1 3566 jorpiell
2 3593 jorpiell
/* 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 3593 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 3613 jorpiell
import es.gva.cit.catalogClient.schemas.discoverer.Resource;
44
import es.gva.cit.catalogClient.utils.ResourcesTable.TableModel;
45 3566 jorpiell
import java.util.Collection;
46 3213 jorpiell
import javax.swing.JButton;
47
import javax.swing.JPanel;
48
import javax.swing.JScrollPane;
49
import javax.swing.JTable;
50
51 4713 cesar
import org.gvsig.i18n.Messages;
52
53 3213 jorpiell
/**
54 3566 jorpiell
 *
55
 *
56
 *
57 3213 jorpiell
 * @author Jorge Piera Llodra (piera_jor@gva.es)
58
 */
59
public class ChooseResourcePanel extends JPanel {
60 3566 jorpiell
/**
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 4713 cesar
    public  ChooseResourcePanel(Collection resources) {
85 3213 jorpiell
                super();
86 4713 cesar
                this.resources = resources;
87 3213 jorpiell
                initialize();
88 3566 jorpiell
    }
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 4713 cesar
            String[] columnNames = {Messages.getText("resourceTypeColumn"),
99
                    Messages.getText("resourceLinkColumn"),
100
                    Messages.getText("resourceShowColumn")};
101 3213 jorpiell
102 3566 jorpiell
            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 3213 jorpiell
           }
108
109
            return new TableModel(columnValues,columnNames);
110 3566 jorpiell
    }
111
112
/**
113
 *
114
 *
115
 *
116
 * @return
117
 * @param protocol
118
 */
119
    private String getNameButton(String protocol) {
120 8765 jjdelcerro
            if (protocol.toUpperCase().indexOf(Resource.WCS) >= 0)
121 4713 cesar
                        return  Messages.getText("wcsColumn");
122 3213 jorpiell
123 3486 jorpiell
                if (protocol.toUpperCase().indexOf(Resource.WMS) >= 0)
124 4713 cesar
                        return Messages.getText("wmsColumn");
125 3213 jorpiell
126 3486 jorpiell
                if (protocol.toUpperCase().indexOf(Resource.WFS) >= 0)
127 4713 cesar
                        return Messages.getText("wfsColumn");
128 3213 jorpiell
129 3486 jorpiell
                if (protocol.toUpperCase().indexOf(Resource.POSTGIS) >= 0)
130 4713 cesar
                        return Messages.getText("postgisColumn");
131 3213 jorpiell
132 3486 jorpiell
                if (protocol.toUpperCase().indexOf(Resource.WEBSITE) >= 0)
133 4713 cesar
                    return Messages.getText("linkColumn");
134 3213 jorpiell
135 3486 jorpiell
                if (protocol.toUpperCase().indexOf(Resource.DOWNLOAD) >= 0)
136 4713 cesar
                    return Messages.getText("downloadColumn");
137 3213 jorpiell
138 7400 jorpiell
                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 4713 cesar
                return Messages.getText("unknown");
145 3566 jorpiell
    }
146
147
/**
148
 *
149
 *
150
 */
151
    private void initialize() {
152 3213 jorpiell
            this.setSize(510, 125);
153
        this.add(getTablePane(), null);
154
155 3566 jorpiell
    }
156
157
/**
158
 *
159
 *
160
 *
161
 * @return
162
 */
163
    public JScrollPane getTablePane() {
164 3213 jorpiell
                if (tablePane == null) {
165
                    tablePane = new JScrollPane(getTable());
166
                    tablePane.setPreferredSize(new java.awt.Dimension(575,100));
167
168
                }
169
                return tablePane;
170 3566 jorpiell
    }
171
172
/**
173
 * This method initializes table
174
 *
175
 *
176
 * @return javax.swing.JTable
177
 */
178
    public JTable getTable() {
179 3213 jorpiell
                if (table == null) {
180
                    table = new JTable(createTableModel());
181
182
                }
183
                return table;
184 3566 jorpiell
    }
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 3213 jorpiell
                buttons[i] = (JButton) getTable().getModel().getValueAt(i,2);
196
197
            return buttons;
198 3566 jorpiell
    }
199
 }