Source Code Cross Referenced for BufferOptionPane.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » options » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jEdit » org.gjt.sp.jedit.options 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BufferOptionPane.java -
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 1998, 2003 Slava Pestov
007:         * Portions copyright (C) 1999 mike dillon
008:         *
009:         * This program is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; either version 2
012:         * of the License, or any later version.
013:         *
014:         * This program is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         * GNU General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU General Public License
020:         * along with this program; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
022:         */
023:
024:        package org.gjt.sp.jedit.options;
025:
026:        import java.awt.event.ActionEvent;
027:        import java.awt.event.ActionListener;
028:        import java.util.Arrays;
029:
030:        import javax.swing.JCheckBox;
031:        import javax.swing.JComboBox;
032:
033:        import org.gjt.sp.jedit.AbstractOptionPane;
034:        import org.gjt.sp.jedit.Buffer;
035:        import org.gjt.sp.jedit.GUIUtilities;
036:        import org.gjt.sp.jedit.MiscUtilities;
037:        import org.gjt.sp.jedit.Mode;
038:        import org.gjt.sp.jedit.jEdit;
039:        import org.gjt.sp.jedit.buffer.FoldHandler;
040:        import org.gjt.sp.jedit.buffer.JEditBuffer;
041:
042:        public class BufferOptionPane extends AbstractOptionPane {
043:            JComboBox encoding;
044:            JComboBox lineSeparator;
045:            JCheckBox gzipped;
046:            Mode[] modes;
047:            JComboBox mode;
048:            JComboBox folding;
049:            JComboBox wrap;
050:            JComboBox maxLineLen;
051:            JComboBox tabSize;
052:            JComboBox indentSize;
053:            JComboBox checkModStatus;
054:            JCheckBox noTabs;
055:            Buffer buffer;
056:
057:            public BufferOptionPane() {
058:                super ("Buffer Options");
059:                init();
060:            }
061:
062:            //{{{ _init() method
063:            protected void _init() {
064:
065:                buffer = jEdit.getActiveView().getBuffer();
066:                String filename = buffer.getName();
067:                setName("Buffer: " + filename);
068:                addComponent(GUIUtilities.createMultilineLabel(jEdit
069:                        .getProperty("buffer-options.caption")));
070:
071:                addSeparator("buffer-options.loading-saving");
072:
073:                //{{{ Line separator
074:                String[] lineSeps = { jEdit.getProperty("lineSep.unix"),
075:                        jEdit.getProperty("lineSep.windows"),
076:                        jEdit.getProperty("lineSep.mac") };
077:                lineSeparator = new JComboBox(lineSeps);
078:                String lineSep = buffer.getStringProperty(JEditBuffer.LINESEP);
079:                if (lineSep == null)
080:                    lineSep = System.getProperty("line.separator");
081:                if ("\n".equals(lineSep))
082:                    lineSeparator.setSelectedIndex(0);
083:                else if ("\r\n".equals(lineSep))
084:                    lineSeparator.setSelectedIndex(1);
085:                else if ("\r".equals(lineSep))
086:                    lineSeparator.setSelectedIndex(2);
087:                addComponent(jEdit.getProperty("buffer-options.lineSeparator"),
088:                        lineSeparator);
089:                //}}}
090:
091:                //{{{ Encoding
092:                String[] encodings = MiscUtilities.getEncodings(true);
093:                Arrays.sort(encodings, new MiscUtilities.StringICaseCompare());
094:                encoding = new JComboBox(encodings);
095:                encoding.setEditable(true);
096:                encoding.setSelectedItem(buffer
097:                        .getStringProperty(JEditBuffer.ENCODING));
098:                addComponent(jEdit.getProperty("buffer-options.encoding"),
099:                        encoding);
100:                //}}}
101:
102:                //{{{ GZipped setting
103:                gzipped = new JCheckBox(jEdit
104:                        .getProperty("buffer-options.gzipped"));
105:                gzipped.setSelected(buffer.getBooleanProperty(Buffer.GZIPPED));
106:                addComponent(gzipped);
107:                //}}}
108:
109:                //{{{ Autoreload settings
110:                /* Check mod status on focus */
111:                String[] modCheckOptions = {
112:                        jEdit
113:                                .getProperty("options.general.checkModStatus.nothing"),
114:                        jEdit
115:                                .getProperty("options.general.checkModStatus.prompt"),
116:                        jEdit
117:                                .getProperty("options.general.checkModStatus.reload"),
118:                        jEdit
119:                                .getProperty("options.general.checkModStatus.silentReload") };
120:                checkModStatus = new JComboBox(modCheckOptions);
121:                if (buffer.getAutoReload()) {
122:                    if (buffer.getAutoReloadDialog())
123:                        // reload and notify
124:                        checkModStatus.setSelectedIndex(2);
125:                    else
126:                        // reload silently
127:                        checkModStatus.setSelectedIndex(3);
128:                } else {
129:                    if (buffer.getAutoReloadDialog())
130:                        // prompt
131:                        checkModStatus.setSelectedIndex(1);
132:                    else
133:                        // do nothing
134:                        checkModStatus.setSelectedIndex(0);
135:                }
136:                addComponent(jEdit
137:                        .getProperty("options.general.checkModStatus"),
138:                        checkModStatus);
139:
140:                // }}}
141:
142:                addSeparator("buffer-options.editing");
143:
144:                //{{{ Edit mode
145:                modes = jEdit.getModes();
146:                Arrays.sort(modes, new MiscUtilities.StringICaseCompare());
147:                mode = new JComboBox(modes);
148:                mode.setSelectedItem(buffer.getMode());
149:                ActionHandler actionListener = new ActionHandler();
150:                mode.addActionListener(actionListener);
151:                addComponent(jEdit.getProperty("buffer-options.mode"), mode);
152:                //}}}
153:
154:                //{{{ Fold mode
155:                String[] foldModes = FoldHandler.getFoldModes();
156:
157:                folding = new JComboBox(foldModes);
158:                folding.setSelectedItem(buffer.getStringProperty("folding"));
159:                addComponent(jEdit.getProperty("options.editing.folding"),
160:                        folding);
161:                //}}}
162:
163:                //{{{ Wrap mode
164:                String[] wrapModes = { "none", "soft", "hard" };
165:
166:                wrap = new JComboBox(wrapModes);
167:                wrap.setSelectedItem(buffer.getStringProperty("wrap"));
168:                addComponent(jEdit.getProperty("options.editing.wrap"), wrap);
169:                //}}}
170:
171:                //{{{ Max line length
172:                String[] lineLengths = { "0", "72", "76", "80" };
173:
174:                maxLineLen = new JComboBox(lineLengths);
175:                maxLineLen.setEditable(true);
176:                maxLineLen.setSelectedItem(buffer
177:                        .getStringProperty("maxLineLen"));
178:                addComponent(jEdit.getProperty("options.editing.maxLineLen"),
179:                        maxLineLen);
180:                //}}}
181:
182:                //{{{ Tab size
183:                String[] tabSizes = { "2", "4", "8" };
184:                tabSize = new JComboBox(tabSizes);
185:                tabSize.setEditable(true);
186:                tabSize.setSelectedItem(buffer.getStringProperty("tabSize"));
187:                addComponent(jEdit.getProperty("options.editing.tabSize"),
188:                        tabSize);
189:                //}}}
190:
191:                //{{{ Indent size
192:                indentSize = new JComboBox(tabSizes);
193:                indentSize.setEditable(true);
194:                indentSize.setSelectedItem(buffer
195:                        .getStringProperty("indentSize"));
196:                addComponent(jEdit.getProperty("options.editing.indentSize"),
197:                        indentSize);
198:                //}}}
199:
200:                //{{{ Soft tabs
201:                noTabs = new JCheckBox(jEdit
202:                        .getProperty("options.editing.noTabs"));
203:                noTabs.setSelected(buffer.getBooleanProperty("noTabs"));
204:                addComponent(noTabs);
205:                //}}}
206:            } //}}}
207:
208:            //{{{ _save() method
209:            protected void _save() {
210:                int index = lineSeparator.getSelectedIndex();
211:                String lineSep;
212:                if (index == 0)
213:                    lineSep = "\n";
214:                else if (index == 1)
215:                    lineSep = "\r\n";
216:                else if (index == 2)
217:                    lineSep = "\r";
218:                else
219:                    throw new InternalError();
220:
221:                String oldLineSep = buffer
222:                        .getStringProperty(JEditBuffer.LINESEP);
223:                if (oldLineSep == null)
224:                    oldLineSep = System.getProperty("line.separator");
225:                if (!oldLineSep.equals(lineSep)) {
226:                    buffer.setStringProperty("lineSeparator", lineSep);
227:                    buffer.setDirty(true);
228:                }
229:
230:                String encoding = (String) this .encoding.getSelectedItem();
231:                String oldEncoding = buffer
232:                        .getStringProperty(JEditBuffer.ENCODING);
233:                if (!oldEncoding.equals(encoding)) {
234:                    buffer.setStringProperty(JEditBuffer.ENCODING, encoding);
235:                    buffer.setDirty(true);
236:                    // Disable auto-detect because user explicitly
237:                    // specify an encoding.
238:                    buffer
239:                            .setBooleanProperty(Buffer.ENCODING_AUTODETECT,
240:                                    false);
241:                }
242:
243:                boolean gzippedValue = gzipped.isSelected();
244:                boolean oldGzipped = buffer.getBooleanProperty(Buffer.GZIPPED);
245:                if (gzippedValue != oldGzipped) {
246:                    buffer.setBooleanProperty(Buffer.GZIPPED, gzippedValue);
247:                    buffer.setDirty(true);
248:                }
249:
250:                buffer.setStringProperty("folding", (String) folding
251:                        .getSelectedItem());
252:
253:                buffer.setStringProperty("wrap", (String) wrap
254:                        .getSelectedItem());
255:
256:                try {
257:                    buffer.setProperty("maxLineLen", new Integer(maxLineLen
258:                            .getSelectedItem().toString()));
259:                } catch (NumberFormatException nf) {
260:                }
261:
262:                try {
263:                    buffer.setProperty("tabSize", new Integer(tabSize
264:                            .getSelectedItem().toString()));
265:                } catch (NumberFormatException nf) {
266:                }
267:
268:                try {
269:                    buffer.setProperty("indentSize", new Integer(indentSize
270:                            .getSelectedItem().toString()));
271:                } catch (NumberFormatException nf) {
272:                }
273:
274:                buffer.setBooleanProperty("noTabs", noTabs.isSelected());
275:
276:                index = mode.getSelectedIndex();
277:                buffer.setMode(modes[index]);
278:                switch (checkModStatus.getSelectedIndex()) {
279:                case 0:
280:                    buffer.setAutoReloadDialog(false);
281:                    buffer.setAutoReload(false);
282:                    break;
283:                case 1:
284:                    buffer.setAutoReloadDialog(true);
285:                    buffer.setAutoReload(false);
286:                    break;
287:                case 2:
288:                    buffer.setAutoReloadDialog(true);
289:                    buffer.setAutoReload(true);
290:                    break;
291:                case 3:
292:                    buffer.setAutoReloadDialog(false);
293:                    buffer.setAutoReload(true);
294:                    break;
295:                }
296:            } //}}}
297:
298:            //{{{ ActionHandler() class
299:            class ActionHandler implements  ActionListener {
300:                //{{{ actionPerformed() method
301:                public void actionPerformed(ActionEvent evt) {
302:                    Object source = evt.getSource();
303:                    if (source == mode) {
304:                        Mode _mode = (Mode) mode.getSelectedItem();
305:                        folding.setSelectedItem(_mode.getProperty("folding"));
306:                        wrap.setSelectedItem(_mode.getProperty("wrap"));
307:                        maxLineLen.setSelectedItem(_mode
308:                                .getProperty("maxLineLen"));
309:                        tabSize.setSelectedItem(_mode.getProperty("tabSize"));
310:                        indentSize.setSelectedItem(_mode
311:                                .getProperty("indentSize"));
312:                        noTabs.setSelected(_mode.getBooleanProperty("noTabs"));
313:                    }
314:                } //}}}
315:            } //}}}
316:
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.