root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / FileList.java @ 2664
History | View | Annotate | Download (5.37 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 |
import java.util.Vector; |
29 |
|
30 |
import javax.swing.JButton; |
31 |
import javax.swing.JComboBox; |
32 |
import javax.swing.JLabel; |
33 |
import javax.swing.JList; |
34 |
import javax.swing.JPanel; |
35 |
import javax.swing.JScrollPane; |
36 |
public class FileList extends JPanel { |
37 |
|
38 |
final private static long serialVersionUID = -3370601314380922368L; |
39 |
private JScrollPane jScrollPane = null; |
40 |
private JPanel jPanel = null; |
41 |
private JButton jButton2 = null; |
42 |
private JButton jButton3 = null; |
43 |
|
44 |
private Vector fileNames = null; |
45 |
private JList jList = null; |
46 |
private JPanel jPanel1 = null; |
47 |
private JComboBox jComboBox = null; |
48 |
private JPanel jPanel2 = null; |
49 |
public JLabel bandasVisibles = null; |
50 |
/**
|
51 |
* This method initializes jScrollPane
|
52 |
*
|
53 |
* @return javax.swing.JScrollPane
|
54 |
*/
|
55 |
private JScrollPane getJScrollPane() { |
56 |
if (jScrollPane == null) { |
57 |
jScrollPane = new JScrollPane(); |
58 |
jScrollPane.setViewportView(getJList()); |
59 |
} |
60 |
return jScrollPane;
|
61 |
} |
62 |
/**
|
63 |
* This method initializes jPanel
|
64 |
*
|
65 |
* @return javax.swing.JPanel
|
66 |
*/
|
67 |
private JPanel getJPanel() { |
68 |
if (jPanel == null) { |
69 |
FlowLayout flowLayout2 = new FlowLayout(); |
70 |
jPanel = new JPanel(); |
71 |
jPanel.setLayout(flowLayout2); |
72 |
flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT); |
73 |
jPanel.add(getJPanel1(), null);
|
74 |
} |
75 |
return jPanel;
|
76 |
} |
77 |
/**
|
78 |
* This method initializes jButton2
|
79 |
*
|
80 |
* @return javax.swing.JButton
|
81 |
*/
|
82 |
public JButton getJButton2() { |
83 |
if (jButton2 == null) { |
84 |
jButton2 = new JButton("A?adir"); |
85 |
jButton2.setPreferredSize(new java.awt.Dimension(80,25)); |
86 |
} |
87 |
return jButton2;
|
88 |
} |
89 |
/**
|
90 |
* This method initializes jButton3
|
91 |
*
|
92 |
* @return javax.swing.JButton
|
93 |
*/
|
94 |
public JButton getJButton3() { |
95 |
if (jButton3 == null) { |
96 |
jButton3 = new JButton("Eliminar"); |
97 |
jButton3.setPreferredSize(new java.awt.Dimension(80,25)); |
98 |
} |
99 |
return jButton3;
|
100 |
} |
101 |
/**
|
102 |
* This method initializes jList
|
103 |
*
|
104 |
* @return javax.swing.JList
|
105 |
*/
|
106 |
public JList getJList() { |
107 |
if (jList == null) { |
108 |
fileNames = new Vector(); |
109 |
jList = new JList(fileNames); |
110 |
} |
111 |
return jList;
|
112 |
} |
113 |
/**
|
114 |
* This is the default constructor
|
115 |
*/
|
116 |
public FileList() {
|
117 |
super();
|
118 |
initialize(); |
119 |
} |
120 |
/**
|
121 |
* This method initializes this
|
122 |
*
|
123 |
* @return void
|
124 |
*/
|
125 |
private void initialize() { |
126 |
this.setLayout(new BorderLayout()); |
127 |
this.setSize(300, 248); |
128 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
|
129 |
this.add(getJPanel(), java.awt.BorderLayout.EAST);
|
130 |
} |
131 |
/**
|
132 |
* This method initializes jPanel1
|
133 |
*
|
134 |
* @return javax.swing.JPanel
|
135 |
*/
|
136 |
private JPanel getJPanel1() { |
137 |
if (jPanel1 == null) { |
138 |
jPanel1 = new JPanel(); |
139 |
jPanel1.setPreferredSize(new java.awt.Dimension(86,180)); |
140 |
jPanel1.add(getJButton2(), null);
|
141 |
jPanel1.add(getJButton3(), null);
|
142 |
jPanel1.add(getJPanel2(), null);
|
143 |
} |
144 |
return jPanel1;
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* A?ade el nombre de un fichero a la lista
|
149 |
* @param fName
|
150 |
*/
|
151 |
public void addFName(String fName) { |
152 |
fileNames.add(fName); |
153 |
jList = new JList(fileNames); |
154 |
jScrollPane.setViewportView(jList); |
155 |
jList.show(); |
156 |
} |
157 |
|
158 |
/**
|
159 |
* Elimina un fichero de la lista
|
160 |
* @param fName
|
161 |
*/
|
162 |
public void removeFName(String fName){ |
163 |
for(int i=0;i<fileNames.size();i++){ |
164 |
if(((String)fileNames.get(i)).endsWith(fName)){ |
165 |
fileNames.remove(i); |
166 |
} |
167 |
} |
168 |
jList = new JList(fileNames); |
169 |
jScrollPane.setViewportView(jList); |
170 |
jList.show(); |
171 |
} |
172 |
|
173 |
/**
|
174 |
* Obtiene el n?mero de ficheros en la lista
|
175 |
* @return
|
176 |
*/
|
177 |
public int getNFiles(){ |
178 |
return fileNames.size();
|
179 |
} |
180 |
|
181 |
/**
|
182 |
* Asigna al combo del n?mero de bandas la lista de ellas
|
183 |
*/
|
184 |
public void setList(String[] list){ |
185 |
if (jComboBox != null){ |
186 |
jComboBox.removeAllItems(); |
187 |
for(int i=0;i<list.length;i++) |
188 |
jComboBox.addItem(list[i]); |
189 |
jComboBox.setSelectedIndex(list.length - 1);
|
190 |
} |
191 |
} |
192 |
|
193 |
/**
|
194 |
* This method initializes jComboBox
|
195 |
*
|
196 |
* @return javax.swing.JComboBox
|
197 |
*/
|
198 |
public JComboBox getJComboBox() { |
199 |
if (jComboBox == null) { |
200 |
String[] list={"1", "2", "3"}; |
201 |
jComboBox = new JComboBox(list); |
202 |
jComboBox.setSelectedIndex(2);
|
203 |
jComboBox.setPreferredSize(new java.awt.Dimension(36,25)); |
204 |
} |
205 |
return jComboBox;
|
206 |
} |
207 |
/**
|
208 |
* This method initializes jPanel2
|
209 |
*
|
210 |
* @return javax.swing.JPanel
|
211 |
*/
|
212 |
private JPanel getJPanel2() { |
213 |
if (jPanel2 == null) { |
214 |
bandasVisibles = new JLabel(); |
215 |
jPanel2 = new JPanel(); |
216 |
bandasVisibles.setText("Bandas");
|
217 |
jPanel2.add(bandasVisibles, null);
|
218 |
jPanel2.add(getJComboBox(), null);
|
219 |
} |
220 |
return jPanel2;
|
221 |
} |
222 |
} // @jve:decl-index=0:visual-constraint="10,10"
|