01: /*
02: JSmooth: a VM wrapper toolkit for Windows
03: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
04:
05: This program is free software; you can redistribute it and/or modify
06: it under the terms of the GNU General Public License as published by
07: the Free Software Foundation; either version 2 of the License, or
08: (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18:
19: */
20:
21: package net.charabia.jsmoothgen.application.gui.editors;
22:
23: import net.charabia.jsmoothgen.skeleton.*;
24: import net.charabia.jsmoothgen.application.*;
25: import net.charabia.jsmoothgen.application.gui.*;
26: import net.charabia.jsmoothgen.application.gui.util.*;
27: import javax.swing.*;
28: import java.awt.*;
29: import java.util.*;
30: import java.io.File;
31: import java.util.jar.*;
32:
33: import com.l2fprod.common.swing.*;
34: import com.l2fprod.common.propertysheet.*;
35:
36: public class ClassPath extends Editor {
37: private JFileChooser m_jarLocFileChooser = new JFileChooser();
38: private EditableListFileEditor m_fileeditor = new EditableListFileEditor();
39: private SortedEditableList m_list = new SortedEditableList() {
40: protected void modelChanged() {
41: ClassPath.this .updateModel();
42: }
43: };
44:
45: public ClassPath() {
46: m_jarLocFileChooser
47: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
48: m_jarLocFileChooser.setMultiSelectionEnabled(true);
49: GenericFileFilter filter = new GenericFileFilter(
50: "Zip, Jar, or directories");
51: filter.addSuffix("jar");
52: filter.addSuffix("zip");
53: m_jarLocFileChooser.addChoosableFileFilter(filter);
54: m_fileeditor.setFileChooser(m_jarLocFileChooser);
55: m_list.setEditor(m_fileeditor);
56:
57: setLayout(new BorderLayout());
58: add(BorderLayout.CENTER, m_list);
59: }
60:
61: public void dataChanged() {
62: if (getBaseDir() != null) {
63: m_jarLocFileChooser.setCurrentDirectory(getBaseDir());
64: }
65:
66: String[] cp = m_model.getClassPath();
67: if (cp == null)
68: m_list.setData(new Object[0]);
69: else
70: m_list.setData((Object[]) cp);
71: }
72:
73: public void updateModel() {
74: Object[] cpels = m_list.getData();
75: String[] cp = new String[cpels.length];
76: for (int i = 0; i < cp.length; i++) {
77: cp[i] = cpels[i].toString();
78: }
79: m_model.setClassPath(cp);
80: }
81:
82: public String getLabel() {
83: return "CLASSPATH_LABEL";
84: }
85:
86: public String getDescription() {
87: return "CLASSPATH_HELP";
88: }
89:
90: public boolean needsBigSpace() {
91: return true;
92: }
93:
94: }
|