Statistics
| Revision:

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

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 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 == null){
121
                    return Messages.getText("unknown");
122
            }
123
            if (protocol.toUpperCase().indexOf(Resource.WCS) >= 0)
124
                        return  Messages.getText("wcsColumn");
125
                
126
                if (protocol.toUpperCase().indexOf(Resource.WMS) >= 0)
127
                        return Messages.getText("wmsColumn");
128
                
129
                if (protocol.toUpperCase().indexOf(Resource.WFS) >= 0)
130
                        return Messages.getText("wfsColumn");
131
                
132
                if (protocol.toUpperCase().indexOf(Resource.POSTGIS) >= 0)
133
                        return Messages.getText("postgisColumn");
134
                
135
                if (protocol.toUpperCase().indexOf(Resource.WEBSITE) >= 0)
136
                    return Messages.getText("linkColumn");
137
                
138
                if (protocol.toUpperCase().indexOf(Resource.DOWNLOAD) >= 0)
139
                    return Messages.getText("downloadColumn");
140
                
141
                if (protocol.toUpperCase().indexOf(Resource.ARCIMS_IMAGE) >= 0)
142
                    return Messages.getText("arcims_image_resource");
143
                
144
                if (protocol.toUpperCase().indexOf(Resource.ARCIMS_VECTORIAL) >= 0)
145
                    return Messages.getText("arcims_vect_resource");
146
                
147
                return Messages.getText("unknown");
148
    } 
149

    
150
/**
151
 * 
152
 * 
153
 */
154
    private void initialize() {        
155
            this.setSize(510, 125);
156
        this.add(getTablePane(), null);
157
                        
158
    } 
159

    
160
/**
161
 * 
162
 * 
163
 * 
164
 * @return 
165
 */
166
    public JScrollPane getTablePane() {        
167
                if (tablePane == null) {
168
                    tablePane = new JScrollPane(getTable());
169
                    tablePane.setPreferredSize(new java.awt.Dimension(575,100));
170
                    
171
                }
172
                return tablePane;
173
    } 
174

    
175
/**
176
 * This method initializes table
177
 * 
178
 * 
179
 * @return javax.swing.JTable
180
 */
181
    public JTable getTable() {        
182
                if (table == null) {
183
                    table = new JTable(createTableModel());
184
                    
185
                }
186
                return table;
187
    } 
188

    
189
/**
190
 * It Return the JButtons array
191
 * 
192
 * 
193
 * @return 
194
 */
195
    public JButton[] getButtons() {        
196
            JButton[] buttons = new JButton[resources.size()];
197
            for (int i=0 ; i<resources.size() ; i++)
198
                buttons[i] = (JButton) getTable().getModel().getValueAt(i,2); 
199
            
200
            return buttons;
201
    } 
202
 }