Source Code Cross Referenced for EditWindow.java in  » Database-Client » SQL-Workbench » workbench » gui » components » 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 » Database Client » SQL Workbench » workbench.gui.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * EditWindow.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2008, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.gui.components;
013:
014:        import java.awt.BorderLayout;
015:        import java.awt.Dialog;
016:        import java.awt.Dimension;
017:        import java.awt.FlowLayout;
018:        import java.awt.Frame;
019:        import java.awt.event.ActionEvent;
020:        import java.awt.event.ActionListener;
021:        import java.awt.event.WindowListener;
022:        import javax.swing.JButton;
023:        import javax.swing.JComponent;
024:        import javax.swing.JDialog;
025:        import javax.swing.JPanel;
026:        import workbench.WbManager;
027:        import workbench.gui.WbSwingUtilities;
028:        import workbench.gui.actions.EscAction;
029:        import workbench.gui.sql.EditorPanel;
030:        import workbench.interfaces.Restoreable;
031:        import workbench.interfaces.TextContainer;
032:        import workbench.resource.ResourceMgr;
033:        import workbench.resource.Settings;
034:
035:        /**
036:         *
037:         * @author support@sql-workbench.net
038:         */
039:        public class EditWindow extends JDialog implements  ActionListener,
040:                WindowListener {
041:            private TextContainer textContainer;
042:            private JComponent editor;
043:            private Restoreable componentSettings;
044:            private JButton okButton = new WbButton(ResourceMgr
045:                    .getString("LblOK"));
046:            private JButton cancelButton = new WbButton(ResourceMgr
047:                    .getString("LblCancel"));
048:            private boolean isCancelled = true;
049:            private String settingsId = null;
050:
051:            public EditWindow(Frame owner, String title, String text) {
052:                this (owner, title, text, "workbench.data.edit.window");
053:            }
054:
055:            public EditWindow(Frame owner, String title, String text,
056:                    boolean createSqlEditor, boolean showCloseButtonOnly) {
057:                this (owner, title, text, "workbench.data.edit.window",
058:                        createSqlEditor, true, showCloseButtonOnly);
059:            }
060:
061:            public EditWindow(Frame owner, String title, String text,
062:                    String settingsId) {
063:                this (owner, title, text, settingsId, false);
064:            }
065:
066:            public EditWindow(Frame owner, String title, String text,
067:                    String settingsId, boolean createSqlEditor) {
068:                this (owner, title, text, settingsId, createSqlEditor, true,
069:                        false);
070:            }
071:
072:            public EditWindow(Frame owner, String title, String text,
073:                    String settingsId, boolean createSqlEditor, boolean modal) {
074:                this (owner, title, text, settingsId, createSqlEditor, modal,
075:                        false);
076:            }
077:
078:            public EditWindow(final Frame owner, final String title,
079:                    final String text, final String settingsId,
080:                    final boolean createSqlEditor, final boolean modal,
081:                    final boolean showCloseButtonOnly) {
082:                super (owner, title, modal);
083:                init(text, settingsId, createSqlEditor, showCloseButtonOnly);
084:                WbSwingUtilities.center(this , owner);
085:            }
086:
087:            public EditWindow(final Dialog owner, final String title,
088:                    final String text, final String settingsId,
089:                    final boolean createSqlEditor) {
090:                super (owner, title, true);
091:                init(text, settingsId, createSqlEditor, false);
092:                WbSwingUtilities.center(this , WbManager.getInstance()
093:                        .getCurrentWindow());
094:            }
095:
096:            public EditWindow(final Dialog owner, final String title,
097:                    final String text, final boolean createSqlEditor,
098:                    final boolean showCloseButtonOnly) {
099:                super (owner, title, true);
100:                init(text, "workbench.data.edit.window", createSqlEditor,
101:                        showCloseButtonOnly);
102:                WbSwingUtilities.center(this , WbManager.getInstance()
103:                        .getCurrentWindow());
104:            }
105:
106:            public void setReadOnly() {
107:                this .textContainer.setEditable(false);
108:            }
109:
110:            private void init(String text, String id, boolean createSqlEditor,
111:                    boolean showCloseButtonOnly) {
112:                this .settingsId = id;
113:                setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
114:                this .getContentPane().setLayout(new BorderLayout());
115:                if (createSqlEditor) {
116:                    EditorPanel panel = EditorPanel.createSqlEditor();
117:                    panel.showFindOnPopupMenu();
118:                    panel.showFormatSql();
119:                    this .editor = panel;
120:                    this .textContainer = panel;
121:                } else {
122:                    if (Settings.getInstance().getUsePlainEditorForData()) {
123:                        PlainEditor ed = new PlainEditor(this );
124:                        ed.restoreSettings();
125:                        this .componentSettings = ed;
126:                        this .textContainer = ed;
127:                        this .editor = ed;
128:                    } else {
129:                        EditorPanel panel = EditorPanel.createTextEditor();
130:                        panel.showFindOnPopupMenu();
131:                        this .editor = panel;
132:                        this .textContainer = panel;
133:                    }
134:                }
135:
136:                this .getContentPane().add(editor, BorderLayout.CENTER);
137:                JPanel buttonPanel = new JPanel();
138:                buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
139:                if (!showCloseButtonOnly) {
140:                    buttonPanel.add(this .okButton);
141:                } else {
142:                    this .cancelButton
143:                            .setText(ResourceMgr.getString("LblClose"));
144:                }
145:                buttonPanel.add(this .cancelButton);
146:                this .getContentPane().add(buttonPanel, BorderLayout.SOUTH);
147:
148:                this .textContainer.setText(text);
149:                this .editor.setMinimumSize(new Dimension(100, 100));
150:                this .editor.setPreferredSize(new Dimension(300, 200));
151:                this .textContainer.setCaretPosition(0);
152:
153:                this .okButton.addActionListener(this );
154:                this .cancelButton.addActionListener(this );
155:
156:                WbTraversalPolicy pol = new WbTraversalPolicy();
157:                pol.setDefaultComponent(editor);
158:                pol.addComponent(editor);
159:                pol.addComponent(this .okButton);
160:                pol.addComponent(this .cancelButton);
161:                this .setFocusTraversalPolicy(pol);
162:                this .setFocusCycleRoot(false);
163:
164:                EscAction escAction = new EscAction(this );
165:                escAction.addToInputMap(getRootPane().getInputMap(
166:                        JComponent.WHEN_IN_FOCUSED_WINDOW), getRootPane()
167:                        .getActionMap());
168:
169:                if (!Settings.getInstance().restoreWindowSize(this , settingsId)) {
170:                    this .setSize(500, 400);
171:                }
172:
173:                this .addWindowListener(this );
174:            }
175:
176:            public void setInfoText(String text) {
177:                if (this .editor instanceof  PlainEditor) {
178:                    ((PlainEditor) editor).setInfoText(text);
179:                }
180:            }
181:
182:            public void hideCancelButton() {
183:                this .cancelButton.removeActionListener(this );
184:                this .cancelButton.setVisible(false);
185:            }
186:
187:            public void actionPerformed(ActionEvent e) {
188:                if (e.getSource() == this .okButton) {
189:                    this .isCancelled = false;
190:                } else if (e.getSource() == this .cancelButton) {
191:                    this .isCancelled = true;
192:                }
193:                closeWindow();
194:            }
195:
196:            private void closeWindow() {
197:                setVisible(false);
198:                dispose();
199:            }
200:
201:            public boolean isCancelled() {
202:                return this .isCancelled;
203:            }
204:
205:            public String getText() {
206:                return this .textContainer.getText();
207:            }
208:
209:            public void windowActivated(java.awt.event.WindowEvent e) {
210:            }
211:
212:            public void windowClosed(java.awt.event.WindowEvent e) {
213:                Settings.getInstance().storeWindowSize(this , this .settingsId);
214:                if (componentSettings != null)
215:                    componentSettings.saveSettings();
216:            }
217:
218:            public void windowClosing(java.awt.event.WindowEvent e) {
219:            }
220:
221:            public void windowDeactivated(java.awt.event.WindowEvent e) {
222:            }
223:
224:            public void windowDeiconified(java.awt.event.WindowEvent e) {
225:            }
226:
227:            public void windowIconified(java.awt.event.WindowEvent e) {
228:            }
229:
230:            public void windowOpened(java.awt.event.WindowEvent e) {
231:                editor.requestFocusInWindow();
232:                WbSwingUtilities.repaintLater(editor);
233:            }
234:
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.