KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > options > SaveBackupOptionPane


1 /*
2  * AutosaveBackupOptionPane.java - Autosave & backup options
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2003 Slava Pestov
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22
23 package org.gjt.sp.jedit.options;
24
25 //{{{ Imports
26
import javax.swing.*;
27 import java.awt.event.*;
28 import java.awt.*;
29 import org.gjt.sp.jedit.*;
30 import org.gjt.sp.jedit.browser.VFSBrowser;
31 //}}}
32

33 /**
34  * The Save and Backup option panel.
35  *
36  * @author Slava Pestov
37  * @author $Id: SaveBackupOptionPane.java 6900 2006-09-07 14:55:34Z kpouer $
38  */

39 public class SaveBackupOptionPane extends AbstractOptionPane
40 {
41     //{{{ SaveBackupOptionPane constructor
42
public SaveBackupOptionPane()
43     {
44         super("save-back");
45     } //}}}
46

47     //{{{ _init() method
48
protected void _init()
49     {
50         /* Two-stage save */
51         twoStageSave = new JCheckBox(jEdit.getProperty(
52             "options.save-back.twoStageSave"));
53         twoStageSave.setSelected(jEdit.getBooleanProperty(
54             "twoStageSave"));
55         addComponent(twoStageSave);
56
57         /* Confirm save all */
58         confirmSaveAll = new JCheckBox(jEdit.getProperty(
59             "options.save-back.confirmSaveAll"));
60         confirmSaveAll.setSelected(jEdit.getBooleanProperty(
61             "confirmSaveAll"));
62         addComponent(confirmSaveAll);
63
64         /* Autosave interval */
65         autosave = new JTextField(jEdit.getProperty("autosave"));
66         addComponent(jEdit.getProperty("options.save-back.autosave"),autosave);
67
68         /* Backup count */
69         backups = new JTextField(jEdit.getProperty("backups"));
70         addComponent(jEdit.getProperty("options.save-back.backups"),backups);
71
72         /* Backup directory */
73         backupDirectory = new JTextField(jEdit.getProperty(
74             "backup.directory"));
75         JButton browseBackupDirectory = new JButton("...");
76         browseBackupDirectory.addActionListener(new MyActionListener());
77         JPanel panel = new JPanel(new BorderLayout());
78         panel.add(backupDirectory);
79         panel.add(browseBackupDirectory, BorderLayout.EAST);
80         addComponent(jEdit.getProperty("options.save-back.backupDirectory"),
81             panel);
82
83         /* Backup filename prefix */
84         backupPrefix = new JTextField(jEdit.getProperty("backup.prefix"));
85         addComponent(jEdit.getProperty("options.save-back.backupPrefix"),
86             backupPrefix);
87
88         /* Backup suffix */
89         backupSuffix = new JTextField(jEdit.getProperty(
90             "backup.suffix"));
91         addComponent(jEdit.getProperty("options.save-back.backupSuffix"),
92             backupSuffix);
93
94         /* Backup on every save */
95         backupEverySave = new JCheckBox(jEdit.getProperty(
96             "options.save-back.backupEverySave"));
97         backupEverySave.setSelected(jEdit.getBooleanProperty("backupEverySave"));
98         addComponent(backupEverySave);
99     } //}}}
100

101     //{{{ _save() method
102
protected void _save()
103     {
104         jEdit.setBooleanProperty("twoStageSave",twoStageSave.isSelected());
105         jEdit.setBooleanProperty("confirmSaveAll",confirmSaveAll.isSelected());
106         jEdit.setProperty("autosave",autosave.getText());
107         jEdit.setProperty("backups",backups.getText());
108         jEdit.setProperty("backup.directory",backupDirectory.getText());
109         jEdit.setProperty("backup.prefix",backupPrefix.getText());
110         jEdit.setProperty("backup.suffix",backupSuffix.getText());
111         jEdit.setBooleanProperty("backupEverySave", backupEverySave.isSelected());
112     } //}}}
113

114     //{{{ Private members
115
private JCheckBox twoStageSave;
116     private JCheckBox confirmSaveAll;
117     private JTextField autosave;
118     private JTextField backups;
119     private JTextField backupDirectory;
120     private JTextField backupPrefix;
121     private JTextField backupSuffix;
122     private JCheckBox backupEverySave;
123     //}}}
124

125     private class MyActionListener implements ActionListener
126     {
127         public void actionPerformed(ActionEvent e)
128         {
129             String JavaDoc[] choosenFolder =
130                 GUIUtilities.showVFSFileDialog(null,
131                                    backupDirectory.getText(),
132                                    VFSBrowser.CHOOSE_DIRECTORY_DIALOG,
133                                    false);
134             if (choosenFolder != null)
135                 backupDirectory.setText(choosenFolder[0]);
136         }
137     }
138 }
139
Popular Tags