Source Code Cross Referenced for ConfigView.java in  » Database-Client » ViennaSQL » uk » co » whisperingwind » vienna » 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 » ViennaSQL » uk.co.whisperingwind.vienna 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ** $Id: ConfigView.java,v 1.13 2000/10/21 14:47:53 mrw Exp $
003:         **
004:         ** Main view of the configuration editor. Has a tab for basic
005:         ** configuration details and a tab for connections.
006:         **
007:         ** Mike Wilson, July 2000, mrw@whisperingwind.co.uk
008:         **
009:         ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
010:         **
011:         ** This program is free software; you can redistribute it and/or modify
012:         ** it under the terms of the GNU General Public License as published by
013:         ** the Free Software Foundation; either version 2 of the License, or
014:         ** (at your option) any later version.
015:         ** 
016:         ** This program is distributed in the hope that it will be useful,
017:         ** but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019:         ** GNU General Public License for more details.
020:         ** 
021:         ** You should have received a copy of the GNU Library General
022:         ** Public License along with this library; if not, write to the
023:         ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
024:         ** Boston, MA  02111-1307  USA.
025:         */
026:
027:        package uk.co.whisperingwind.vienna;
028:
029:        import java.awt.event.MouseAdapter;
030:        import java.awt.event.MouseEvent;
031:        import java.awt.event.MouseListener;
032:        import java.awt.Font;
033:        import java.awt.GridBagConstraints;
034:        import java.awt.GridBagLayout;
035:        import java.awt.Insets;
036:        import javax.swing.event.ListDataEvent;
037:        import javax.swing.event.ListDataListener;
038:        import javax.swing.event.ListSelectionEvent;
039:        import javax.swing.event.ListSelectionListener;
040:        import javax.swing.JButton;
041:        import javax.swing.JCheckBox;
042:        import javax.swing.JFrame;
043:        import javax.swing.JLabel;
044:        import javax.swing.JList;
045:        import javax.swing.JPanel;
046:        import javax.swing.JScrollPane;
047:        import javax.swing.JTextField;
048:        import javax.swing.JToolBar;
049:        import javax.swing.ListModel;
050:        import uk.co.whisperingwind.framework.ActionFactory;
051:        import uk.co.whisperingwind.framework.ModelEvent;
052:        import uk.co.whisperingwind.framework.TabDialogView;
053:
054:        class ConfigView extends TabDialogView {
055:            private GeneralPanel generalPanel = null;
056:            private ConnectionPanel connectionPanel = null;
057:
058:            private JCheckBox checkPassword = new JCheckBox("Save passwords");
059:            private JTextField textMaxRows = new JTextField();
060:
061:            private JButton buttonTableFont = new JButton();
062:            private JButton buttonTextFont = new JButton();
063:
064:            private ActionFactory.DefaultAction okAction = null;
065:            private ActionFactory.DefaultAction cancelAction = null;
066:            private ActionFactory.DefaultAction newAction = null;
067:            private ActionFactory.DefaultAction editAction = null;
068:            private ActionFactory.DefaultAction deleteAction = null;
069:            private ConfigModel configModel = null;
070:
071:            public ConfigView(JFrame parent, ConfigModel theConfigModel,
072:                    boolean modal) {
073:                super (parent, modal);
074:                configModel = theConfigModel;
075:                configModel.addObserver(this );
076:                content.setTitle("ViennaSQL options");
077:
078:                createActions();
079:
080:                generalPanel = new GeneralPanel();
081:                connectionPanel = new ConnectionPanel();
082:
083:                JButton okButton = okAction.toolButtonFactory(buttonPanel);
084:                cancelAction.toolButtonFactory(buttonPanel);
085:
086:                addTab("General", generalPanel);
087:                addTab("Connections", connectionPanel);
088:
089:                populate();
090:                content.pack();
091:                content.setVisible(true);
092:                generalPanel.grabFocus();
093:                content.getRootPane().setDefaultButton(okButton);
094:            }
095:
096:            public String getSelectedConnection() {
097:                return connectionPanel.getSelectedConnection();
098:            }
099:
100:            public boolean getSavePasswords() {
101:                return checkPassword.isSelected();
102:            }
103:
104:            public String getMaxRows() {
105:                return textMaxRows.getText();
106:            }
107:
108:            private void createActions() {
109:                ConfigActionFactory factory = new ConfigActionFactory(
110:                        "/uk/co/whisperingwind/images");
111:
112:                okAction = factory.createAction("ok");
113:                cancelAction = factory.createAction("cancel");
114:                newAction = factory.createAction("new");
115:                editAction = factory.createAction("edit");
116:                deleteAction = factory.createAction("delete");
117:
118:                okAction.addActionListener(actionListener);
119:                cancelAction.addActionListener(actionListener);
120:                newAction.addActionListener(actionListener);
121:                editAction.addActionListener(actionListener);
122:                deleteAction.addActionListener(actionListener);
123:
124:                editAction.setEnabled(false);
125:                deleteAction.setEnabled(false);
126:            }
127:
128:            public void setTextFont(Font font) {
129:                generalPanel.setTextFont(font);
130:            }
131:
132:            public void setTableFont(Font font) {
133:                generalPanel.setTableFont(font);
134:            }
135:
136:            private void populate() {
137:                generalPanel.populate();
138:            }
139:
140:            protected void modelEvent(ModelEvent event) {
141:                Object initiatior = event.getInitiator();
142:                String field = event.getField();
143:
144:                if (initiatior == configModel) {
145:                    if (field.equals("textfont")) {
146:                        setTextFont((Font) event.getValue());
147:                    } else if (field.equals("tablefont")) {
148:                        setTableFont((Font) event.getValue());
149:                    }
150:                }
151:            }
152:
153:            protected void cleanUp() {
154:                configModel.deleteObserver(this );
155:            }
156:
157:            /*
158:             ** Panel contains widgets for general config options: "Save
159:             ** passwords", text and table fonts etc.
160:             */
161:
162:            private class GeneralPanel extends JPanel {
163:                public GeneralPanel() {
164:                    this .setLayout(new GridBagLayout());
165:
166:                    GridBagConstraints constraints = new GridBagConstraints();
167:                    constraints.insets = new Insets(4, 4, 4, 4);
168:                    constraints.fill = GridBagConstraints.HORIZONTAL;
169:                    constraints.anchor = GridBagConstraints.WEST;
170:                    constraints.gridwidth = GridBagConstraints.REMAINDER;
171:                    constraints.weightx = 1.0;
172:                    this .add(checkPassword, constraints);
173:
174:                    constraints.gridwidth = GridBagConstraints.RELATIVE;
175:                    constraints.fill = GridBagConstraints.NONE;
176:                    constraints.weightx = 0.0;
177:                    JLabel label = new JLabel("Maximum rows");
178:                    this .add(label, constraints);
179:
180:                    constraints.gridwidth = GridBagConstraints.REMAINDER;
181:                    constraints.fill = GridBagConstraints.HORIZONTAL;
182:                    constraints.weightx = 1.0;
183:                    this .add(textMaxRows, constraints);
184:
185:                    constraints.gridwidth = GridBagConstraints.RELATIVE;
186:                    constraints.fill = GridBagConstraints.NONE;
187:                    constraints.weightx = 0.0;
188:                    label = new JLabel("Table font");
189:                    this .add(label, constraints);
190:
191:                    constraints.gridwidth = GridBagConstraints.REMAINDER;
192:                    constraints.fill = GridBagConstraints.HORIZONTAL;
193:                    constraints.weightx = 1.0;
194:                    this .add(buttonTableFont, constraints);
195:                    buttonTableFont.addActionListener(actionListener);
196:                    buttonTableFont.setActionCommand("tablefont");
197:
198:                    constraints.gridwidth = GridBagConstraints.RELATIVE;
199:                    constraints.fill = GridBagConstraints.NONE;
200:                    constraints.weightx = 0.0;
201:                    label = new JLabel("Text font");
202:                    this .add(label, constraints);
203:
204:                    constraints.gridwidth = GridBagConstraints.REMAINDER;
205:                    constraints.fill = GridBagConstraints.HORIZONTAL;
206:                    constraints.weightx = 1.0;
207:                    this .add(buttonTextFont, constraints);
208:                    buttonTextFont.addActionListener(actionListener);
209:                    buttonTextFont.setActionCommand("textfont");
210:                }
211:
212:                public void populate() {
213:                    checkPassword.setSelected(configModel.getSavePasswords());
214:                    textMaxRows.setText(new Integer(configModel.getMaxRows())
215:                            .toString());
216:
217:                    setFontTitle(buttonTableFont, configModel.getTableFont());
218:                    setFontTitle(buttonTextFont, configModel.getTextFont());
219:                }
220:
221:                public void setTableFont(Font font) {
222:                    setFontTitle(buttonTableFont, configModel.getTableFont());
223:                }
224:
225:                public void setTextFont(Font font) {
226:                    setFontTitle(buttonTextFont, configModel.getTextFont());
227:                }
228:
229:                private void setFontTitle(JButton button, Font font) {
230:                    String fontTitle = font.getName();
231:                    fontTitle += " ";
232:                    fontTitle += font.getSize();
233:
234:                    if (font.isBold())
235:                        fontTitle += " bold";
236:
237:                    if (font.isItalic())
238:                        fontTitle += " italic";
239:
240:                    button.setText(fontTitle);
241:                }
242:
243:                public void grabFocus() {
244:                    textMaxRows.grabFocus();
245:                }
246:            }
247:
248:            /*
249:             ** Panel contains widgets for editing connections.
250:             */
251:
252:            private class ConnectionPanel extends JPanel implements 
253:                    ListSelectionListener, ListDataListener {
254:                private JList listConnection = null;
255:
256:                public ConnectionPanel() {
257:                    this .setLayout(new GridBagLayout());
258:
259:                    GridBagConstraints constraints = new GridBagConstraints();
260:                    constraints.insets = new Insets(4, 4, 4, 4);
261:                    constraints.fill = GridBagConstraints.BOTH;
262:                    constraints.anchor = GridBagConstraints.WEST;
263:                    constraints.gridx = 0;
264:                    constraints.gridy = 0;
265:                    constraints.weightx = 1.0;
266:                    constraints.weighty = 1.0;
267:                    ListModel model = configModel.getConnectionListModel()
268:                            .getListModel();
269:                    listConnection = new JList(model);
270:                    JScrollPane listScroller = new JScrollPane(listConnection);
271:                    this .add(listScroller, constraints);
272:                    listConnection.setSelectedIndex(0);
273:                    listConnection.addListSelectionListener(this );
274:                    model.addListDataListener(this );
275:
276:                    JToolBar toolBar = new JToolBar(JToolBar.VERTICAL);
277:                    toolBar.setFloatable(false);
278:                    newAction.toolButtonFactory(toolBar);
279:                    editAction.toolButtonFactory(toolBar);
280:                    deleteAction.toolButtonFactory(toolBar);
281:
282:                    constraints.insets = new Insets(4, 0, 4, 0);
283:                    constraints.fill = GridBagConstraints.VERTICAL;
284:                    constraints.anchor = GridBagConstraints.NORTH;
285:                    constraints.gridx = 1;
286:                    constraints.gridy = 0;
287:                    constraints.weightx = 0.0;
288:                    constraints.weighty = 1.0;
289:                    this .add(toolBar, constraints);
290:
291:                    MouseListener mouseListener = new MouseAdapter() {
292:                        public void mouseClicked(MouseEvent event) {
293:                            if (event.getClickCount() == 2) {
294:                                int index = listConnection
295:                                        .locationToIndex(event.getPoint());
296:
297:                                if (index > 0) {
298:                                    fireEvent("edit");
299:                                }
300:                            }
301:                        }
302:                    };
303:
304:                    listConnection.addMouseListener(mouseListener);
305:                }
306:
307:                public String getSelectedConnection() {
308:                    return (String) listConnection.getSelectedValue();
309:                }
310:
311:                public void valueChanged(ListSelectionEvent event) {
312:                    enableButtons();
313:                }
314:
315:                public void contentsChanged(ListDataEvent e) {
316:                    editAction.setEnabled(false);
317:                    deleteAction.setEnabled(false);
318:                }
319:
320:                public void intervalAdded(ListDataEvent e) {
321:                    enableButtons();
322:                }
323:
324:                public void intervalRemoved(ListDataEvent e) {
325:                    editAction.setEnabled(false);
326:                    deleteAction.setEnabled(false);
327:                }
328:
329:                private void enableButtons() {
330:                    int i = listConnection.getSelectedIndex();
331:
332:                    if (i > 0) {
333:                        editAction.setEnabled(true);
334:                        deleteAction.setEnabled(true);
335:                    } else {
336:                        editAction.setEnabled(false);
337:                        deleteAction.setEnabled(false);
338:                    }
339:                }
340:            }
341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.