Source Code Cross Referenced for CloseDialog.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » gui » 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.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CloseDialog.java - Close all buffers dialog
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 1999, 2000 Slava Pestov
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.gui;
024:
025:        //{{{ Imports
026:        import javax.swing.border.*;
027:        import javax.swing.event.*;
028:        import javax.swing.*;
029:        import java.awt.event.*;
030:        import java.awt.*;
031:        import org.gjt.sp.jedit.bufferio.BufferIORequest;
032:        import org.gjt.sp.jedit.io.*;
033:        import org.gjt.sp.jedit.*;
034:
035:        //}}}
036:
037:        public class CloseDialog extends EnhancedDialog {
038:            //{{{ CloseDialog constructor
039:            public CloseDialog(View view) {
040:                super (view, jEdit.getProperty("close.title"), true);
041:
042:                this .view = view;
043:
044:                JPanel content = new JPanel(new BorderLayout(12, 12));
045:                content.setBorder(new EmptyBorder(12, 12, 12, 12));
046:                setContentPane(content);
047:
048:                Box iconBox = new Box(BoxLayout.Y_AXIS);
049:                iconBox.add(new JLabel(UIManager
050:                        .getIcon("OptionPane.warningIcon")));
051:                iconBox.add(Box.createGlue());
052:                content.add(BorderLayout.WEST, iconBox);
053:
054:                JPanel centerPanel = new JPanel(new BorderLayout());
055:
056:                JLabel label = new JLabel(jEdit.getProperty("close.caption"));
057:                label.setBorder(new EmptyBorder(0, 0, 6, 0));
058:                centerPanel.add(BorderLayout.NORTH, label);
059:
060:                bufferList = new JList(bufferModel = new DefaultListModel());
061:                bufferList.setVisibleRowCount(10);
062:                bufferList.addListSelectionListener(new ListHandler());
063:
064:                Buffer[] buffers = jEdit.getBuffers();
065:                for (int i = 0; i < buffers.length; i++) {
066:                    Buffer buffer = buffers[i];
067:                    if (buffer.isDirty()) {
068:                        bufferModel.addElement(buffer.getPath());
069:                    }
070:                }
071:
072:                centerPanel.add(BorderLayout.CENTER,
073:                        new JScrollPane(bufferList));
074:
075:                content.add(BorderLayout.CENTER, centerPanel);
076:
077:                ActionHandler actionListener = new ActionHandler();
078:
079:                Box buttons = new Box(BoxLayout.X_AXIS);
080:                buttons.add(Box.createGlue());
081:                buttons.add(selectAll = new JButton(jEdit
082:                        .getProperty("close.selectAll")));
083:                selectAll.setMnemonic(jEdit.getProperty(
084:                        "close.selectAll.mnemonic").charAt(0));
085:                selectAll.addActionListener(actionListener);
086:                buttons.add(Box.createHorizontalStrut(6));
087:                buttons
088:                        .add(save = new JButton(jEdit.getProperty("close.save")));
089:                save.setMnemonic(jEdit.getProperty("close.save.mnemonic")
090:                        .charAt(0));
091:                save.addActionListener(actionListener);
092:                buttons.add(Box.createHorizontalStrut(6));
093:                buttons.add(discard = new JButton(jEdit
094:                        .getProperty("close.discard")));
095:                discard.setMnemonic(jEdit.getProperty("close.discard.mnemonic")
096:                        .charAt(0));
097:                discard.addActionListener(actionListener);
098:                buttons.add(Box.createHorizontalStrut(6));
099:                buttons.add(cancel = new JButton(jEdit
100:                        .getProperty("common.cancel")));
101:                cancel.addActionListener(actionListener);
102:                buttons.add(Box.createGlue());
103:
104:                bufferList.setSelectedIndex(0);
105:
106:                content.add(BorderLayout.SOUTH, buttons);
107:
108:                GUIUtilities.requestFocus(this , bufferList);
109:
110:                pack();
111:                setLocationRelativeTo(view);
112:                setVisible(true);
113:            } //}}}
114:
115:            //{{{ isOK() method
116:            public boolean isOK() {
117:                return ok;
118:            } //}}}
119:
120:            //{{{ ok() method
121:            public void ok() {
122:                // do nothing
123:            } //}}}
124:
125:            //{{{ cancel() method
126:            public void cancel() {
127:                dispose();
128:            } //}}}
129:
130:            //{{{ Private members
131:            private View view;
132:            private JList bufferList;
133:            private DefaultListModel bufferModel;
134:            private JButton selectAll;
135:            private JButton save;
136:            private JButton discard;
137:            private JButton cancel;
138:
139:            private boolean ok; // only set if all buffers saved/closed
140:
141:            boolean selectAllFlag;
142:
143:            private void updateButtons() {
144:                int index = bufferList.getSelectedIndex();
145:                save.getModel().setEnabled(index != -1);
146:                discard.getModel().setEnabled(index != -1);
147:            } //}}}
148:
149:            //{{{ ActionHandler class
150:            class ActionHandler implements  ActionListener {
151:                public void actionPerformed(ActionEvent evt) {
152:                    Object source = evt.getSource();
153:                    if (source == selectAll) {
154:                        // I'm too tired to think of a better way
155:                        // to handle this right now.
156:                        try {
157:                            selectAllFlag = true;
158:
159:                            bufferList.setSelectionInterval(0, bufferModel
160:                                    .getSize() - 1);
161:                        } finally {
162:                            selectAllFlag = false;
163:                        }
164:                        bufferList.requestFocus();
165:                    } else if (source == save) {
166:                        Object[] paths = bufferList.getSelectedValues();
167:
168:                        for (int i = 0; i < paths.length; i++) {
169:                            String path = (String) paths[i];
170:                            Buffer buffer = jEdit.getBuffer(path);
171:                            if (!buffer.save(view, null, true, true))
172:                                return;
173:                            VFSManager.waitForRequests();
174:                            if (buffer
175:                                    .getBooleanProperty(BufferIORequest.ERROR_OCCURRED))
176:                                return;
177:                            jEdit._closeBuffer(view, buffer);
178:                            bufferModel.removeElement(path);
179:                        }
180:
181:                        if (bufferModel.getSize() == 0) {
182:                            ok = true;
183:                            dispose();
184:                        } else {
185:                            bufferList.setSelectedIndex(0);
186:                            bufferList.requestFocus();
187:                        }
188:                    } else if (source == discard) {
189:                        Object[] paths = bufferList.getSelectedValues();
190:
191:                        for (int i = 0; i < paths.length; i++) {
192:                            String path = (String) paths[i];
193:                            Buffer buffer = jEdit.getBuffer(path);
194:                            jEdit._closeBuffer(view, buffer);
195:                            bufferModel.removeElement(path);
196:                        }
197:
198:                        if (bufferModel.getSize() == 0) {
199:                            ok = true;
200:                            dispose();
201:                        } else {
202:                            bufferList.setSelectedIndex(0);
203:                            bufferList.requestFocus();
204:                        }
205:                    } else if (source == cancel)
206:                        cancel();
207:                }
208:            } //}}}
209:
210:            //{{{ ListHandler class
211:            class ListHandler implements  ListSelectionListener {
212:                public void valueChanged(ListSelectionEvent evt) {
213:                    if (selectAllFlag)
214:                        return;
215:
216:                    int index = bufferList.getSelectedIndex();
217:                    if (index != -1)
218:                        view.goToBuffer(jEdit.getBuffer((String) bufferModel
219:                                .getElementAt(index)));
220:
221:                    updateButtons();
222:                }
223:            } //}}}
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.