svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / FileList.java @ 2312
History | View | Annotate | Download (4.15 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.JList; |
32 |
import javax.swing.JPanel; |
33 |
import javax.swing.JScrollPane; |
34 |
|
35 |
public class FileList extends JPanel { |
36 |
|
37 |
private JScrollPane jScrollPane = null; |
38 |
private JPanel jPanel = null; |
39 |
private JButton jButton2 = null; |
40 |
private JButton jButton3 = null; |
41 |
|
42 |
private Vector fileNames = null; |
43 |
private JList jList = null; |
44 |
private JPanel jPanel1 = null; |
45 |
/**
|
46 |
* This method initializes jScrollPane
|
47 |
*
|
48 |
* @return javax.swing.JScrollPane
|
49 |
*/
|
50 |
private JScrollPane getJScrollPane() { |
51 |
if (jScrollPane == null) { |
52 |
jScrollPane = new JScrollPane(); |
53 |
jScrollPane.setViewportView(getJList()); |
54 |
} |
55 |
return jScrollPane;
|
56 |
} |
57 |
/**
|
58 |
* This method initializes jPanel
|
59 |
*
|
60 |
* @return javax.swing.JPanel
|
61 |
*/
|
62 |
private JPanel getJPanel() { |
63 |
if (jPanel == null) { |
64 |
FlowLayout flowLayout2 = new FlowLayout(); |
65 |
jPanel = new JPanel(); |
66 |
jPanel.setLayout(flowLayout2); |
67 |
flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT); |
68 |
jPanel.add(getJPanel1(), null);
|
69 |
} |
70 |
return jPanel;
|
71 |
} |
72 |
/**
|
73 |
* This method initializes jButton2
|
74 |
*
|
75 |
* @return javax.swing.JButton
|
76 |
*/
|
77 |
public JButton getJButton2() { |
78 |
if (jButton2 == null) { |
79 |
jButton2 = new JButton("A?adir"); |
80 |
jButton2.setPreferredSize(new java.awt.Dimension(80,25)); |
81 |
} |
82 |
return jButton2;
|
83 |
} |
84 |
/**
|
85 |
* This method initializes jButton3
|
86 |
*
|
87 |
* @return javax.swing.JButton
|
88 |
*/
|
89 |
public JButton getJButton3() { |
90 |
if (jButton3 == null) { |
91 |
jButton3 = new JButton("Eliminar"); |
92 |
jButton3.setPreferredSize(new java.awt.Dimension(80,25)); |
93 |
} |
94 |
return jButton3;
|
95 |
} |
96 |
/**
|
97 |
* This method initializes jList
|
98 |
*
|
99 |
* @return javax.swing.JList
|
100 |
*/
|
101 |
public JList getJList() { |
102 |
if (jList == null) { |
103 |
fileNames = new Vector(); |
104 |
jList = new JList(fileNames); |
105 |
} |
106 |
return jList;
|
107 |
} |
108 |
/**
|
109 |
* This is the default constructor
|
110 |
*/
|
111 |
public FileList() {
|
112 |
super();
|
113 |
initialize(); |
114 |
} |
115 |
/**
|
116 |
* This method initializes this
|
117 |
*
|
118 |
* @return void
|
119 |
*/
|
120 |
private void initialize() { |
121 |
this.setLayout(new BorderLayout()); |
122 |
this.setSize(300, 248); |
123 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
|
124 |
this.add(getJPanel(), java.awt.BorderLayout.EAST);
|
125 |
} |
126 |
/**
|
127 |
* This method initializes jPanel1
|
128 |
*
|
129 |
* @return javax.swing.JPanel
|
130 |
*/
|
131 |
private JPanel getJPanel1() { |
132 |
if (jPanel1 == null) { |
133 |
jPanel1 = new JPanel(); |
134 |
jPanel1.setPreferredSize(new java.awt.Dimension(86,180)); |
135 |
jPanel1.add(getJButton2(), null);
|
136 |
jPanel1.add(getJButton3(), null);
|
137 |
} |
138 |
return jPanel1;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* A?ade el nombre de un fichero a la lista
|
143 |
* @param fName
|
144 |
*/
|
145 |
public void addFName(String fName) { |
146 |
fileNames.add(fName); |
147 |
jList = new JList(fileNames); |
148 |
jScrollPane.setViewportView(jList); |
149 |
jList.show(); |
150 |
} |
151 |
|
152 |
/**
|
153 |
* Elimina un fichero de la lista
|
154 |
* @param fName
|
155 |
*/
|
156 |
public void removeFName(String fName){ |
157 |
for(int i=0;i<fileNames.size();i++){ |
158 |
if(((String)fileNames.get(i)).endsWith(fName)){ |
159 |
fileNames.remove(i); |
160 |
} |
161 |
} |
162 |
jList = new JList(fileNames); |
163 |
jScrollPane.setViewportView(jList); |
164 |
jList.show(); |
165 |
} |
166 |
|
167 |
/**
|
168 |
* Obtiene el n?mero de ficheros en la lista
|
169 |
* @return
|
170 |
*/
|
171 |
public int getNFiles(){ |
172 |
return fileNames.size();
|
173 |
} |
174 |
} // @jve:decl-index=0:visual-constraint="10,10"
|