Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / FileList.java @ 2669

History | View | Annotate | Download (6.18 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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
 * cresques@gmail.com
23
 */
24
package org.cresques.ui.raster;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.FlowLayout;
28

    
29
import java.util.Vector;
30

    
31
import javax.swing.JButton;
32
import javax.swing.JComboBox;
33
import javax.swing.JLabel;
34
import javax.swing.JList;
35
import javax.swing.JPanel;
36
import javax.swing.JScrollPane;
37

    
38

    
39
public class FileList extends JPanel {
40
    final private static long serialVersionUID = -3370601314380922368L;
41
    private JScrollPane jScrollPane = null;
42
    private JPanel jPanel = null;
43
    private JButton jButton2 = null;
44
    private JButton jButton3 = null;
45
    private Vector fileNames = null;
46
    private JList jList = null;
47
    private JPanel jPanel1 = null;
48
    private JComboBox jComboBox = null;
49
    private JPanel jPanel2 = null;
50
    public JLabel bandasVisibles = null;
51

    
52
    /**
53
    * This is the default constructor
54
    */
55
    public FileList() {
56
        super();
57
        initialize();
58
    }
59

    
60
    /**
61
     * This method initializes jScrollPane
62
     *
63
     * @return javax.swing.JScrollPane
64
     */
65
    private JScrollPane getJScrollPane() {
66
        if (jScrollPane == null) {
67
            jScrollPane = new JScrollPane();
68
            jScrollPane.setViewportView(getJList());
69
        }
70

    
71
        return jScrollPane;
72
    }
73

    
74
    /**
75
     * This method initializes jPanel
76
     *
77
     * @return javax.swing.JPanel
78
     */
79
    private JPanel getJPanel() {
80
        if (jPanel == null) {
81
            FlowLayout flowLayout2 = new FlowLayout();
82
            jPanel = new JPanel();
83
            jPanel.setLayout(flowLayout2);
84
            flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
85
            jPanel.add(getJPanel1(), null);
86
        }
87

    
88
        return jPanel;
89
    }
90

    
91
    /**
92
     * This method initializes jButton2
93
     *
94
     * @return javax.swing.JButton
95
     */
96
    public JButton getJButton2() {
97
        if (jButton2 == null) {
98
            jButton2 = new JButton("A?adir");
99
            jButton2.setPreferredSize(new java.awt.Dimension(80, 25));
100
        }
101

    
102
        return jButton2;
103
    }
104

    
105
    /**
106
     * This method initializes jButton3
107
     *
108
     * @return javax.swing.JButton
109
     */
110
    public JButton getJButton3() {
111
        if (jButton3 == null) {
112
            jButton3 = new JButton("Eliminar");
113
            jButton3.setPreferredSize(new java.awt.Dimension(80, 25));
114
        }
115

    
116
        return jButton3;
117
    }
118

    
119
    /**
120
     * This method initializes jList
121
     *
122
     * @return javax.swing.JList
123
     */
124
    public JList getJList() {
125
        if (jList == null) {
126
            fileNames = new Vector();
127
            jList = new JList(fileNames);
128
        }
129

    
130
        return jList;
131
    }
132

    
133
    /**
134
     * This method initializes this
135
     *
136
     * @return void
137
     */
138
    private void initialize() {
139
        this.setLayout(new BorderLayout());
140
        this.setSize(300, 248);
141
        this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
142
        this.add(getJPanel(), java.awt.BorderLayout.EAST);
143
    }
144

    
145
    /**
146
     * This method initializes jPanel1
147
     *
148
     * @return javax.swing.JPanel
149
     */
150
    private JPanel getJPanel1() {
151
        if (jPanel1 == null) {
152
            jPanel1 = new JPanel();
153
            jPanel1.setPreferredSize(new java.awt.Dimension(86, 180));
154
            jPanel1.add(getJButton2(), null);
155
            jPanel1.add(getJButton3(), null);
156
            jPanel1.add(getJPanel2(), null);
157
        }
158

    
159
        return jPanel1;
160
    }
161

    
162
    /**
163
     * A?ade el nombre de un fichero a la lista
164
     * @param fName
165
     */
166
    public void addFName(String fName) {
167
        fileNames.add(fName);
168
        jList = new JList(fileNames);
169
        jScrollPane.setViewportView(jList);
170
        jList.show();
171
    }
172

    
173
    /**
174
     * Elimina un fichero de la lista
175
     * @param fName
176
     */
177
    public void removeFName(String fName) {
178
        for (int i = 0; i < fileNames.size(); i++) {
179
            if (((String) fileNames.get(i)).endsWith(fName)) {
180
                fileNames.remove(i);
181
            }
182
        }
183

    
184
        jList = new JList(fileNames);
185
        jScrollPane.setViewportView(jList);
186
        jList.show();
187
    }
188

    
189
    /**
190
     * Obtiene el n?mero de ficheros en la lista
191
     * @return
192
     */
193
    public int getNFiles() {
194
        return fileNames.size();
195
    }
196

    
197
    /**
198
     * Asigna al combo del n?mero de bandas la lista de ellas
199
     */
200
    public void setList(String[] list) {
201
        if (jComboBox != null) {
202
            jComboBox.removeAllItems();
203

    
204
            for (int i = 0; i < list.length; i++)
205
                jComboBox.addItem(list[i]);
206

    
207
            jComboBox.setSelectedIndex(list.length - 1);
208
        }
209
    }
210

    
211
    /**
212
     * This method initializes jComboBox
213
     *
214
     * @return javax.swing.JComboBox
215
     */
216
    public JComboBox getJComboBox() {
217
        if (jComboBox == null) {
218
            String[] list = { "1", "2", "3" };
219
            jComboBox = new JComboBox(list);
220
            jComboBox.setSelectedIndex(2);
221
            jComboBox.setPreferredSize(new java.awt.Dimension(36, 25));
222
        }
223

    
224
        return jComboBox;
225
    }
226

    
227
    /**
228
     * This method initializes jPanel2
229
     *
230
     * @return javax.swing.JPanel
231
     */
232
    private JPanel getJPanel2() {
233
        if (jPanel2 == null) {
234
            bandasVisibles = new JLabel();
235
            jPanel2 = new JPanel();
236
            bandasVisibles.setText("Bandas");
237
            jPanel2.add(bandasVisibles, null);
238
            jPanel2.add(getJComboBox(), null);
239
        }
240

    
241
        return jPanel2;
242
    }
243
} //  @jve:decl-index=0:visual-constraint="10,10"