Source Code Cross Referenced for LoadFileDialog.java in  » Database-Client » JSqlTool » org » jsqltool » jgraph » 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 » Database Client » JSqlTool » org.jsqltool.jgraph.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jsqltool.jgraph.gui;
002:
003:        import javax.swing.*;
004:        import java.awt.*;
005:        import java.awt.event.*;
006:        import javax.swing.event.*;
007:        import java.io.*;
008:        import java.util.*;
009:
010:        import org.jsqltool.replication.*;
011:        import org.jsqltool.gui.*;
012:        import org.jsqltool.utils.ImageLoader;
013:        import org.jsqltool.utils.Options;
014:
015:        /**
016:         * <p>Title: JSqlTool Project</p>
017:         * <p>Description: Window used to load a database schema profile file.
018:         * </p>
019:         * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
020:         *
021:         * <p> This file is part of JSqlTool project.
022:         * This library is free software; you can redistribute it and/or
023:         * modify it under the terms of the (LGPL) Lesser General Public
024:         * License as published by the Free Software Foundation;
025:         *
026:         *                GNU LESSER GENERAL PUBLIC LICENSE
027:         *                 Version 2.1, February 1999
028:         *
029:         * This library is distributed in the hope that it will be useful,
030:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
031:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
032:         * Library General Public License for more details.
033:         *
034:         * You should have received a copy of the GNU Library General Public
035:         * License along with this library; if not, write to the Free
036:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
037:         *
038:         *       The author may be contacted at:
039:         *           maurocarniel@tin.it</p>
040:         *
041:         * @author Mauro Carniel
042:         * @version 1.0
043:         */
044:        public class LoadFileDialog extends JDialog {
045:            JPanel mainPanel = new JPanel();
046:            BorderLayout borderLayout1 = new BorderLayout();
047:
048:            /** main frame */
049:            private MainFrame frame = null;
050:
051:            /** parent frame */
052:            private SchemaFrame parentFrame = null;
053:            GridBagLayout gridBagLayout1 = new GridBagLayout();
054:            JLabel profilesLabel = new JLabel();
055:            JScrollPane scrollPane = new JScrollPane();
056:            JList profilesList = new JList();
057:            JButton okButton = new JButton();
058:            JButton cancelButton = new JButton();
059:
060:            /** connection name (used as prefix in a profile file name) */
061:            private String dbConnName = null;
062:
063:            public LoadFileDialog(MainFrame frame, SchemaFrame parentFrame,
064:                    String dbConnName) {
065:                super (frame, Options.getInstance().getResource(
066:                        "load database schema profile file"), true);
067:                this .frame = frame;
068:                this .parentFrame = parentFrame;
069:                this .dbConnName = dbConnName;
070:                init();
071:                try {
072:                    jbInit();
073:                    setSize(400, 300);
074:                    Dimension screenSize = Toolkit.getDefaultToolkit()
075:                            .getScreenSize();
076:                    Dimension frameSize = this .getSize();
077:                    if (frameSize.height > screenSize.height) {
078:                        frameSize.height = screenSize.height;
079:                    }
080:                    if (frameSize.width > screenSize.width) {
081:                        frameSize.width = screenSize.width;
082:                    }
083:                    this .setLocation((screenSize.width - frameSize.width) / 2,
084:                            (screenSize.height - frameSize.height) / 2);
085:                    setDefaultCloseOperation(this .DISPOSE_ON_CLOSE);
086:                    setVisible(true);
087:                } catch (Exception ex) {
088:                    ex.printStackTrace();
089:                }
090:            }
091:
092:            /**
093:             * Constructor not supported.
094:             */
095:            public LoadFileDialog() {
096:                try {
097:                    jbInit();
098:                    pack();
099:                } catch (Exception ex) {
100:                    ex.printStackTrace();
101:                }
102:            }
103:
104:            /**
105:             * Fill in the profiles list.
106:             */
107:            private void init() {
108:                // retrieve .ini file list...
109:                File dir = new File("profile");
110:                dir.mkdir();
111:                File[] files = dir.listFiles(new FileFilter() {
112:                    public boolean accept(File pathname) {
113:                        return pathname.getName().startsWith(dbConnName + "_")
114:                                && pathname.getName().endsWith(".sch");
115:                    }
116:                });
117:                DefaultListModel model = new DefaultListModel();
118:                for (int i = 0; i < files.length; i++)
119:                    model.addElement(files[i].getName().substring(
120:                            (dbConnName + "_").length(),
121:                            files[i].getName().length() - 4).replace('_', ' '));
122:                profilesList.setModel(model);
123:                profilesList.revalidate();
124:
125:                profilesList.addMouseListener(new MouseAdapter() {
126:                    public void mouseClicked(MouseEvent e) {
127:                        if (e.getClickCount() == 2
128:                                && profilesList.getSelectedIndex() != -1) {
129:                            parentFrame.loadProfile("profile/"
130:                                    + dbConnName
131:                                    + "_"
132:                                    + profilesList.getSelectedValue()
133:                                            .toString().replace(' ', '_')
134:                                    + ".sch");
135:                            setVisible(false);
136:                        }
137:                    }
138:                });
139:
140:            }
141:
142:            private void jbInit() throws Exception {
143:                mainPanel.setLayout(gridBagLayout1);
144:                profilesLabel.setText(Options.getInstance().getResource(
145:                        "profiles"));
146:                profilesList
147:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
148:                okButton.setToolTipText("");
149:                okButton.setText(Options.getInstance().getResource(
150:                        "okbutton.text"));
151:                okButton
152:                        .addActionListener(new LoadFileDialog_okButton_actionAdapter(
153:                                this ));
154:                okButton.setMnemonic(Options.getInstance().getResource(
155:                        "okbutton.mnemonic").charAt(0));
156:                cancelButton.setText(Options.getInstance().getResource(
157:                        "cancelbutton.text"));
158:                cancelButton
159:                        .addActionListener(new LoadFileDialog_cancelButton_actionAdapter(
160:                                this ));
161:                cancelButton.setMnemonic(Options.getInstance().getResource(
162:                        "cancelbutton.mnemonic").charAt(0));
163:                getContentPane().add(mainPanel);
164:                mainPanel.add(profilesLabel, new GridBagConstraints(0, 0, 1, 1,
165:                        0.0, 0.0, GridBagConstraints.NORTHWEST,
166:                        GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
167:                mainPanel.add(scrollPane, new GridBagConstraints(0, 1, 1, 2,
168:                        1.0, 1.0, GridBagConstraints.NORTHWEST,
169:                        GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
170:                scrollPane.getViewport().add(profilesList, null);
171:                mainPanel.add(okButton, new GridBagConstraints(1, 1, 1, 1, 0.0,
172:                        0.0, GridBagConstraints.NORTHWEST,
173:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
174:                        0, 0));
175:                mainPanel.add(cancelButton, new GridBagConstraints(1, 2, 1, 1,
176:                        0.0, 0.0, GridBagConstraints.NORTHWEST,
177:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
178:                        0, 0));
179:            }
180:
181:            void okButton_actionPerformed(ActionEvent e) {
182:                if (profilesList.getSelectedIndex() != -1) {
183:                    parentFrame.loadProfile("profile/"
184:                            + dbConnName
185:                            + "_"
186:                            + profilesList.getSelectedValue().toString()
187:                                    .replace(' ', '_') + ".sch");
188:                    setVisible(false);
189:                }
190:            }
191:
192:            void cancelButton_actionPerformed(ActionEvent e) {
193:                setVisible(false);
194:            }
195:
196:        }
197:
198:        class LoadFileDialog_okButton_actionAdapter implements 
199:                java.awt.event.ActionListener {
200:            LoadFileDialog adaptee;
201:
202:            LoadFileDialog_okButton_actionAdapter(LoadFileDialog adaptee) {
203:                this .adaptee = adaptee;
204:            }
205:
206:            public void actionPerformed(ActionEvent e) {
207:                adaptee.okButton_actionPerformed(e);
208:            }
209:        }
210:
211:        class LoadFileDialog_cancelButton_actionAdapter implements 
212:                java.awt.event.ActionListener {
213:            LoadFileDialog adaptee;
214:
215:            LoadFileDialog_cancelButton_actionAdapter(LoadFileDialog adaptee) {
216:                this .adaptee = adaptee;
217:            }
218:
219:            public void actionPerformed(ActionEvent e) {
220:                adaptee.cancelButton_actionPerformed(e);
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.