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 @ 37171
History | View | Annotate | Download (3.67 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.installer.swing.api.SwingInstallerLocator; |
38 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
39 |
|
40 |
/**
|
41 |
* @author gvSIG Team
|
42 |
* @version $Id$
|
43 |
*
|
44 |
*/
|
45 |
public class SelectSymbolsFolderInstallPanel extends JPanel { |
46 |
|
47 |
private static final long serialVersionUID = 948949741432221418L; |
48 |
|
49 |
protected SwingInstallerManager swingInstallerManager = null; |
50 |
|
51 |
private JList folderJList; |
52 |
private File symbolsDirectory = null; |
53 |
private ArrayList<String> folders = null; |
54 |
|
55 |
public SelectSymbolsFolderInstallPanel() {
|
56 |
super();
|
57 |
swingInstallerManager = |
58 |
SwingInstallerLocator.getSwingInstallerManager(); |
59 |
initComponents(); |
60 |
} |
61 |
|
62 |
private String getText(String string) { |
63 |
return string;
|
64 |
} |
65 |
|
66 |
private void initComponents() { |
67 |
|
68 |
JLabel symbolsFolderLabel =
|
69 |
new JLabel( |
70 |
getText("_please_select_the_folder_to_create_the_package_with:")
|
71 |
+ ":");
|
72 |
|
73 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
74 |
symbolsDirectory = |
75 |
new File(pluginManager.getApplicationHomeFolder() + File.separator |
76 |
+ "Symbols");
|
77 |
|
78 |
String[] itemsArray = symbolsDirectory.list(); |
79 |
folders = new ArrayList<String>(); |
80 |
|
81 |
for (int i = 0; i < itemsArray.length; i++) { |
82 |
File f = new File(symbolsDirectory, itemsArray[i]); |
83 |
if (f.isDirectory()) {
|
84 |
folders.add(itemsArray[i]); |
85 |
} |
86 |
} |
87 |
|
88 |
folderJList = new JList(folders.toArray()); |
89 |
|
90 |
folderJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
91 |
|
92 |
//TODO: actionEvent should be added
|
93 |
folderJList.setSelectedIndex(0);
|
94 |
|
95 |
setLayout(new BorderLayout()); |
96 |
setBounds(2, 2, 2, 2); |
97 |
|
98 |
add(symbolsFolderLabel, BorderLayout.NORTH);
|
99 |
|
100 |
JScrollPane scroller = new JScrollPane(folderJList); |
101 |
add(scroller); |
102 |
// add(folderJList);
|
103 |
} |
104 |
|
105 |
public File getSelectedFolder() { |
106 |
String folderName = folders.get(folderJList.getSelectedIndex());
|
107 |
return new File(symbolsDirectory + "/" + folderName.toString()); |
108 |
} |
109 |
|
110 |
public void setSelectedFolder(File selectedFile) { |
111 |
folderJList.setSelectedValue(selectedFile, true);
|
112 |
// folderTextField.setSelectedFile(selectedFile);
|
113 |
} |
114 |
|
115 |
public void actionPerformed(ActionEvent arg0) { |
116 |
// TODO Auto-generated method stub
|
117 |
|
118 |
} |
119 |
|
120 |
} |