root / branches / v2_0_0_prep / extensions / org.gvsig.symbology.app / org.gvsig.symbology.app.symbolinstaller / src / main / java / org / gvsig / symbology / app / symbolinstaller / creation / panel / SelectSymbolsFolderInstallPanel.java @ 37186
History | View | Annotate | Download (3.34 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.symbology.app.symbolinstaller.creation.panel; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.event.ActionEvent; |
26 |
import java.io.File; |
27 |
import java.util.ArrayList; |
28 |
|
29 |
import javax.swing.JLabel; |
30 |
import javax.swing.JList; |
31 |
import javax.swing.JPanel; |
32 |
import javax.swing.JScrollPane; |
33 |
import javax.swing.ListSelectionModel; |
34 |
|
35 |
import org.gvsig.andami.PluginsLocator; |
36 |
import org.gvsig.andami.PluginsManager; |
37 |
import org.gvsig.i18n.Messages; |
38 |
|
39 |
/**
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*
|
43 |
*/
|
44 |
public class SelectSymbolsFolderInstallPanel extends JPanel { |
45 |
|
46 |
private static final long serialVersionUID = 948949741432221418L; |
47 |
|
48 |
private JList folderJList; |
49 |
private File symbolsDirectory = null; |
50 |
private ArrayList<String> folders = null; |
51 |
|
52 |
public SelectSymbolsFolderInstallPanel() {
|
53 |
super();
|
54 |
initComponents(); |
55 |
} |
56 |
|
57 |
private String getText(String string) { |
58 |
return Messages.getText(string);
|
59 |
} |
60 |
|
61 |
private void initComponents() { |
62 |
|
63 |
JLabel symbolsFolderLabel =
|
64 |
new JLabel( |
65 |
getText("_select_the_folder_to_create_the_package_with")
|
66 |
+ ":");
|
67 |
|
68 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
69 |
symbolsDirectory = |
70 |
new File(pluginManager.getApplicationHomeFolder() + File.separator |
71 |
+ "Symbols");
|
72 |
|
73 |
String[] itemsArray = symbolsDirectory.list(); |
74 |
folders = new ArrayList<String>(); |
75 |
|
76 |
for (int i = 0; i < itemsArray.length; i++) { |
77 |
File f = new File(symbolsDirectory, itemsArray[i]); |
78 |
if (f.isDirectory()) {
|
79 |
folders.add(itemsArray[i]); |
80 |
} |
81 |
} |
82 |
|
83 |
folderJList = new JList(folders.toArray()); |
84 |
folderJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
85 |
|
86 |
// TODO: actionEvent should be added
|
87 |
folderJList.setSelectedIndex(0);
|
88 |
|
89 |
setLayout(new BorderLayout(2, 2)); |
90 |
setBounds(2, 2, 2, 2); |
91 |
|
92 |
add(symbolsFolderLabel, BorderLayout.NORTH);
|
93 |
|
94 |
JScrollPane scroller = new JScrollPane(folderJList); |
95 |
|
96 |
add(scroller); |
97 |
} |
98 |
|
99 |
public File getSelectedFolder() { |
100 |
String folderName = folders.get(folderJList.getSelectedIndex());
|
101 |
return new File(symbolsDirectory + "/" + folderName.toString()); |
102 |
} |
103 |
|
104 |
public void setSelectedFolder(File selectedFile) { |
105 |
folderJList.setSelectedValue(selectedFile, true);
|
106 |
} |
107 |
|
108 |
public void actionPerformed(ActionEvent arg0) { |
109 |
// TODO Auto-generated method stub
|
110 |
} |
111 |
|
112 |
} |