001: /*
002: JSmooth: a VM wrapper toolkit for Windows
003: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
004:
005: This program is free software; you can redistribute it and/or modify
006: it under the terms of the GNU General Public License as published by
007: the Free Software Foundation; either version 2 of the License, or
008: (at your option) any later version.
009:
010: This program is distributed in the hope that it will be useful,
011: but WITHOUT ANY WARRANTY; without even the implied warranty of
012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: GNU General Public License for more details.
014:
015: You should have received a copy of the GNU General Public License
016: along with this program; if not, write to the Free Software
017: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
018:
019: */
020:
021: package net.charabia.jsmoothgen.application.gui.editors;
022:
023: import net.charabia.jsmoothgen.skeleton.*;
024: import net.charabia.jsmoothgen.application.*;
025: import net.charabia.jsmoothgen.application.gui.*;
026: import net.charabia.jsmoothgen.application.gui.util.*;
027: import javax.swing.*;
028: import java.awt.*;
029: import java.util.*;
030: import com.l2fprod.common.swing.*;
031: import com.l2fprod.common.propertysheet.*;
032:
033: public class CurrentDirectory extends Editor {
034: private FileSelectionTextField m_selector = new FileSelectionTextField();
035: private JCheckBox m_forceExePath = new JCheckBox();
036:
037: public CurrentDirectory() {
038: setLayout(new BorderLayout());
039: add(BorderLayout.CENTER, m_selector);
040:
041: JPanel jpc = new JPanel();
042: jpc.setLayout(new BorderLayout());
043: jpc.add(BorderLayout.WEST, m_forceExePath);
044: jpc.add(BorderLayout.CENTER, new HelpButton(Main
045: .local("CURRENTDIR_FORCEEXEPATH_HELP")));
046: add(BorderLayout.SOUTH, jpc);
047:
048: m_forceExePath.setAction(new AbstractAction(Main
049: .local("CURRENTDIR_FORCEEXEPATH")) {
050: public void actionPerformed(java.awt.event.ActionEvent e) {
051: if (m_forceExePath.isSelected())
052: m_selector.setEnabled(false);
053: else
054: m_selector.setEnabled(true);
055: }
056: });
057:
058: m_selector.setFileChooser(new JDirectoryChooser());
059: }
060:
061: public void dataChanged() {
062: // System.out.println("CurDir, basedir=" + getBaseDir());
063: m_selector.setBaseDir(getBaseDir());
064: String dir = m_model.getCurrentDirectory();
065: // System.out.println("Cur Directory data changed: " + dir);
066:
067: if ("${EXECUTABLEPATH}".equals(dir)) {
068: m_selector.setEnabled(false);
069: m_forceExePath.setSelected(true);
070: } else {
071: m_forceExePath.setSelected(false);
072: m_selector.setEnabled(true);
073:
074: if ((dir != null) && (dir.trim().length() > 0)) {
075: m_selector.setFile(new java.io.File(dir));
076: } else {
077: m_selector.setFile(null);
078: }
079: }
080: }
081:
082: public void updateModel() {
083: // System.out.println("UPDATE MODEL: " + m_selector.getFile());
084:
085: if (m_forceExePath.isSelected()) {
086: m_model.setCurrentDirectory("${EXECUTABLEPATH}");
087: } else {
088: if (m_selector.getFile() != null)
089: m_model.setCurrentDirectory(m_selector.getFile()
090: .toString());
091: else
092: m_model.setCurrentDirectory(null);
093: }
094: }
095:
096: public String getLabel() {
097: return "CURRENTDIR_LABEL";
098: }
099:
100: public String getDescription() {
101: return "CURRENTDIR_HELP";
102: }
103:
104: }
|