KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > gui > BufferOptions


1 /*
2
3  * BufferOptions.java - Buffer-specific options dialog
4
5  * :tabSize=8:indentSize=8:noTabs=false:
6
7  * :folding=explicit:collapseFolds=1:
8
9  *
10
11  * Copyright (C) 1999, 2004 Slava Pestov
12
13  *
14
15  * This program is free software; you can redistribute it and/or
16
17  * modify it under the terms of the GNU General Public License
18
19  * as published by the Free Software Foundation; either version 2
20
21  * of the License, or any later version.
22
23  *
24
25  * This program is distributed in the hope that it will be useful,
26
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
31  * GNU General Public License for more details.
32
33  *
34
35  * You should have received a copy of the GNU General Public License
36
37  * along with this program; if not, write to the Free Software
38
39  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40
41  */

42
43
44
45 package org.gjt.sp.jedit.gui;
46
47
48
49 //{{{ Imports
50

51 import javax.swing.border.EmptyBorder JavaDoc;
52 import javax.swing.*;
53 import java.awt.*;
54 import java.awt.event.*;
55
56 import java.util.Arrays JavaDoc;
57
58 import org.gjt.sp.jedit.buffer.FoldHandler;
59 import org.gjt.sp.jedit.buffer.JEditBuffer;
60 import org.gjt.sp.jedit.options.BufferOptionPane;
61
62 import org.gjt.sp.jedit.*;
63
64 //}}}
65

66 /**
67
68  * Buffer-specific options dialog.
69  * @author Slava Pestov
70  * @version $Id: BufferOptions.java 7627 2006-10-20 17:13:12Z hertzhaft $
71  *
72  */

73
74 public class BufferOptions extends EnhancedDialog
75 {
76     //{{{ BufferOptions constructor
77

78     public BufferOptions(View view, Buffer buffer)
79     {
80         super(view,jEdit.getProperty("buffer-options.title"),true);
81         this.view = view;
82         this.buffer = buffer;
83
84         JPanel content = new JPanel(new BorderLayout());
85         content.setBorder(new EmptyBorder JavaDoc(12,12,12,12));
86         setContentPane(content);
87
88         ActionHandler actionListener = new ActionHandler();
89         panel = new BufferOptionPane();
90
91         content.add(BorderLayout.NORTH,panel);
92
93         //{{{ Buttons
94

95         JPanel buttons = new JPanel();
96         buttons.setLayout(new BoxLayout(buttons,BoxLayout.X_AXIS));
97         buttons.setBorder(new EmptyBorder JavaDoc(12,0,0,0));
98         buttons.add(Box.createGlue());
99
100         ok = new JButton(jEdit.getProperty("common.ok"));
101         ok.addActionListener(actionListener);
102         getRootPane().setDefaultButton(ok);
103         buttons.add(ok);
104
105         buttons.add(Box.createHorizontalStrut(6));
106
107         cancel = new JButton(jEdit.getProperty("common.cancel"));
108         cancel.addActionListener(actionListener);
109         buttons.add(cancel);
110
111         buttons.add(Box.createGlue());
112         content.add(BorderLayout.SOUTH,buttons);
113
114         //}}}
115

116         pack();
117         setLocationRelativeTo(view);
118         setVisible(true);
119     } //}}}
120

121
122
123     //{{{ ok() method
124

125     public void ok()
126     {
127         panel.save();
128         dispose();
129     } //}}}
130

131     //{{{ cancel() method
132

133     public void cancel()
134     {
135         dispose();
136     } //}}}
137

138         //{{{ Private members
139

140     private View view;
141     private Buffer buffer;
142     private BufferOptionPane panel;
143     private JButton ok;
144     private JButton cancel;
145
146     //{{{ ActionHandler class
147

148     class ActionHandler implements ActionListener
149     {
150         //{{{ actionPerformed() method
151
public void actionPerformed(ActionEvent evt)
152         {
153             Object JavaDoc source = evt.getSource();
154             if(source == ok)
155                 ok();
156             else if(source == cancel)
157                 cancel();
158         } //}}}
159

160     } //}}}
161

162 }
163
164
Popular Tags