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


001:        package org.jsqltool.replication.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 create, edit or delete Data Replication Profiles.
018:         * It also allows to start a Data Replication process.
019:         * </p>
020:         * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
021:         *
022:         * <p> This file is part of JSqlTool project.
023:         * This library is free software; you can redistribute it and/or
024:         * modify it under the terms of the (LGPL) Lesser General Public
025:         * License as published by the Free Software Foundation;
026:         *
027:         *                GNU LESSER GENERAL PUBLIC LICENSE
028:         *                 Version 2.1, February 1999
029:         *
030:         * This library is distributed in the hope that it will be useful,
031:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
032:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
033:         * Library General Public License for more details.
034:         *
035:         * You should have received a copy of the GNU Library General Public
036:         * License along with this library; if not, write to the Free
037:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
038:         *
039:         *       The author may be contacted at:
040:         *           maurocarniel@tin.it</p>
041:         *
042:         * @author Mauro Carniel
043:         * @version 1.0
044:         */
045:        public class ReplicationFrame extends JInternalFrame {
046:
047:            JScrollPane scrollPane = new JScrollPane();
048:            Vector profileNames = new Vector();
049:            JList profileList = new JList(profileNames);
050:            JPanel buttonsPanel = new JPanel();
051:            JButton delButton = new JButton();
052:            JButton newButton = new JButton();
053:            JButton editButton = new JButton();
054:            GridBagLayout gridBagLayout1 = new GridBagLayout();
055:            GridBagLayout gridBagLayout2 = new GridBagLayout();
056:            JButton okButton = new JButton();
057:            JButton cancelButton = new JButton();
058:            JLabel profileLabel = new JLabel();
059:            private ArrayList profiles = new ArrayList();
060:            private MainFrame parent = null;
061:
062:            public ReplicationFrame(MainFrame parent) {
063:                this .parent = parent;
064:                try {
065:                    this .setFrameIcon(ImageLoader.getInstance().getIcon(
066:                            "logo.gif"));
067:                    this .setSize(450, 300);
068:                    jbInit();
069:                    init();
070:                    toFront();
071:                    setSelected(true);
072:                } catch (Exception e) {
073:                    e.printStackTrace();
074:                }
075:            }
076:
077:            public ReplicationFrame() {
078:                this (null);
079:            }
080:
081:            /**
082:             * Load ReplicationProfile objecs e fill in the profile list.
083:             */
084:            private void init() {
085:                loadProfiles();
086:                if (profileList.getModel().getSize() > 0)
087:                    profileList.setSelectedIndex(0);
088:
089:            }
090:
091:            private void jbInit() throws Exception {
092:                this .setIcon(false);
093:                this .setTitle(Options.getInstance().getResource(
094:                        "data replication profiles"));
095:                this .setBorder(BorderFactory.createRaisedBevelBorder());
096:                this .setDebugGraphicsOptions(0);
097:                this .getContentPane().setLayout(gridBagLayout1);
098:                delButton.setMnemonic(Options.getInstance().getResource(
099:                        "deleteprofiles.mnemonic").charAt(0));
100:                delButton.setText(Options.getInstance().getResource(
101:                        "deleteprofile.text"));
102:                delButton
103:                        .addActionListener(new ReplicationFrame_delButton_actionAdapter(
104:                                this ));
105:                newButton.setMnemonic(Options.getInstance().getResource(
106:                        "newprofile.mnemonic").charAt(0));
107:                newButton.setText(Options.getInstance().getResource(
108:                        "newprofile.text"));
109:                newButton
110:                        .addActionListener(new ReplicationFrame_newButton_actionAdapter(
111:                                this ));
112:                editButton.setMnemonic(Options.getInstance().getResource(
113:                        "editprofile.mnemonic").charAt(0));
114:                editButton.setText(Options.getInstance().getResource(
115:                        "editprofile.text"));
116:                editButton
117:                        .addActionListener(new ReplicationFrame_editButton_actionAdapter(
118:                                this ));
119:                buttonsPanel.setLayout(gridBagLayout2);
120:                okButton.setMnemonic(Options.getInstance().getResource(
121:                        "execbutton.mnemonic").charAt(0));
122:                okButton.setText(Options.getInstance().getResource(
123:                        "execbutton.text"));
124:                okButton
125:                        .addActionListener(new ReplicationFrame_okButton_actionAdapter(
126:                                this ));
127:                cancelButton.setMnemonic(Options.getInstance().getResource(
128:                        "cancelbutton.mnemonic").charAt(0));
129:                cancelButton.setText(Options.getInstance().getResource(
130:                        "cancelbutton.text"));
131:                cancelButton
132:                        .addActionListener(new ReplicationFrame_cancelButton_actionAdapter(
133:                                this ));
134:                profileLabel.setText(Options.getInstance().getResource(
135:                        "profiles"));
136:                buttonsPanel.setBorder(BorderFactory.createEtchedBorder());
137:                profileList
138:                        .addMouseListener(new ReplicationFrame_profileList_mouseAdapter(
139:                                this ));
140:                profileList
141:                        .addKeyListener(new ReplicationFrame_profileList_keyAdapter(
142:                                this ));
143:                scrollPane.getViewport().add(profileList, null);
144:                this .getContentPane().add(
145:                        buttonsPanel,
146:                        new GridBagConstraints(1, 0, 1, 2, 1.0, 1.0,
147:                                GridBagConstraints.EAST,
148:                                GridBagConstraints.BOTH,
149:                                new Insets(5, 5, 5, 5), 0, 0));
150:                buttonsPanel.add(okButton, new GridBagConstraints(0, 0, 1, 1,
151:                        0.0, 0.0, GridBagConstraints.CENTER,
152:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
153:                        0, 0));
154:                buttonsPanel.add(delButton, new GridBagConstraints(0, 4, 1, 1,
155:                        0.0, 0.0, GridBagConstraints.NORTH,
156:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
157:                        0, 0));
158:                buttonsPanel.add(newButton, new GridBagConstraints(0, 2, 1, 1,
159:                        0.0, 0.0, GridBagConstraints.CENTER,
160:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
161:                        0, 0));
162:                buttonsPanel.add(editButton, new GridBagConstraints(0, 3, 1, 1,
163:                        0.0, 0.0, GridBagConstraints.CENTER,
164:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
165:                        0, 0));
166:                this .getContentPane().add(
167:                        scrollPane,
168:                        new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
169:                                GridBagConstraints.CENTER,
170:                                GridBagConstraints.BOTH,
171:                                new Insets(0, 5, 5, 5), 0, 0));
172:                this .getContentPane().add(
173:                        profileLabel,
174:                        new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
175:                                GridBagConstraints.WEST,
176:                                GridBagConstraints.NONE,
177:                                new Insets(5, 5, 5, 5), 0, 0));
178:                buttonsPanel.add(cancelButton, new GridBagConstraints(0, 1, 1,
179:                        1, 0.0, 0.0, GridBagConstraints.CENTER,
180:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
181:                        0, 0));
182:            }
183:
184:            void editButton_actionPerformed(ActionEvent e) {
185:                if (profileList.getSelectedIndex() == -1)
186:                    return;
187:                new ReplicationDialog(parent, this ,
188:                        (ReplicationProfile) profiles.get(profileList
189:                                .getSelectedIndex()), ReplicationDialog.EDIT);
190:            }
191:
192:            void newButton_actionPerformed(ActionEvent e) {
193:                new ReplicationDialog(parent, this , new ReplicationProfile(),
194:                        ReplicationDialog.INSERT);
195:            }
196:
197:            void delButton_actionPerformed(ActionEvent e) {
198:                if (profileList.getSelectedIndex() == -1)
199:                    return;
200:                ReplicationProfile p = (ReplicationProfile) profiles
201:                        .remove(profileList.getSelectedIndex());
202:                profileNames.remove(profileList.getSelectedIndex());
203:
204:                scrollPane.getViewport().removeAll();
205:                profileList = new JList(profileNames);
206:                scrollPane.getViewport().add(profileList, null);
207:
208:                new File("profile/" + p.getName().replace(' ', '_') + ".rep")
209:                        .delete();
210:            }
211:
212:            void okButton_actionPerformed(ActionEvent e) {
213:                if (profileList.getSelectedIndex() == -1)
214:                    return;
215:                new Thread() {
216:                    public void run() {
217:                        setVisible(false);
218:                        ReplicationProfile profile = (ReplicationProfile) profiles
219:                                .get(profileList.getSelectedIndex());
220:                        new Replication(parent, profile);
221:                    }
222:                }.start();
223:            }
224:
225:            void cancelButton_actionPerformed(ActionEvent e) {
226:                this .setVisible(false);
227:                this .dispose();
228:            }
229:
230:            void profileList_mouseClicked(MouseEvent e) {
231:                if (profileList.getSelectedIndex() != -1
232:                        && e.getClickCount() == 2
233:                        && SwingUtilities.isLeftMouseButton(e))
234:                    okButton_actionPerformed(null);
235:            }
236:
237:            void profileList_keyTyped(KeyEvent e) {
238:                if (e.getKeyChar() == '\n'
239:                        && profileList.getSelectedIndex() != -1)
240:                    okButton_actionPerformed(null);
241:            }
242:
243:            public void requestFocus() {
244:                profileList.requestFocus();
245:            }
246:
247:            public final void updateList(ReplicationProfile profile,
248:                    boolean isEdit) {
249:                if (!isEdit) {
250:                    profiles.add(profile);
251:                    profileNames.add(profile.getName());
252:                } else {
253:                    profileNames.setElementAt(profile.getName(), profileList
254:                            .getSelectedIndex());
255:                }
256:                profile.saveProfile(parent, isEdit);
257:
258:                scrollPane.getViewport().removeAll();
259:                DefaultListModel model = new DefaultListModel();
260:                for (int i = 0; i < profileNames.size(); i++)
261:                    model.addElement(profileNames.get(i));
262:                profileList.setModel(model);
263:                profileList.revalidate();
264:                profileList.repaint();
265:                scrollPane.getViewport().add(profileList, null);
266:
267:            }
268:
269:            /**
270:             * Load all replication profile files (files profile/*.rep)
271:             */
272:            private void loadProfiles() {
273:                try {
274:                    profiles.clear();
275:                    profileNames.clear();
276:
277:                    // retrieve .ini file list...
278:                    File dir = new File("profile");
279:                    dir.mkdir();
280:                    File[] files = dir.listFiles(new FileFilter() {
281:                        public boolean accept(File pathname) {
282:                            return pathname.getName().endsWith(".rep");
283:                        }
284:                    });
285:
286:                    // load all .rep files...
287:                    ReplicationProfile cProfile = null;
288:                    for (int i = 0; i < files.length; i++) {
289:                        cProfile = new ReplicationProfile();
290:                        cProfile.loadProfile(this , files[i], profiles,
291:                                profileNames);
292:                    }
293:
294:                    profileList.revalidate();
295:                } catch (Exception ex) {
296:                    ex.printStackTrace();
297:                    JOptionPane
298:                            .showMessageDialog(
299:                                    this ,
300:                                    Options
301:                                            .getInstance()
302:                                            .getResource(
303:                                                    "error on loading replication profile files.")
304:                                            + ":\n" + ex.getMessage(),
305:                                    Options.getInstance().getResource("error"),
306:                                    JOptionPane.ERROR_MESSAGE);
307:                }
308:            }
309:
310:        }
311:
312:        class ReplicationFrame_editButton_actionAdapter implements 
313:                java.awt.event.ActionListener {
314:            ReplicationFrame adaptee;
315:
316:            ReplicationFrame_editButton_actionAdapter(ReplicationFrame adaptee) {
317:                this .adaptee = adaptee;
318:            }
319:
320:            public void actionPerformed(ActionEvent e) {
321:                adaptee.editButton_actionPerformed(e);
322:            }
323:        }
324:
325:        class ReplicationFrame_newButton_actionAdapter implements 
326:                java.awt.event.ActionListener {
327:            ReplicationFrame adaptee;
328:
329:            ReplicationFrame_newButton_actionAdapter(ReplicationFrame adaptee) {
330:                this .adaptee = adaptee;
331:            }
332:
333:            public void actionPerformed(ActionEvent e) {
334:                adaptee.newButton_actionPerformed(e);
335:            }
336:        }
337:
338:        class ReplicationFrame_delButton_actionAdapter implements 
339:                java.awt.event.ActionListener {
340:            ReplicationFrame adaptee;
341:
342:            ReplicationFrame_delButton_actionAdapter(ReplicationFrame adaptee) {
343:                this .adaptee = adaptee;
344:            }
345:
346:            public void actionPerformed(ActionEvent e) {
347:                adaptee.delButton_actionPerformed(e);
348:            }
349:        }
350:
351:        class ReplicationFrame_okButton_actionAdapter implements 
352:                java.awt.event.ActionListener {
353:            ReplicationFrame adaptee;
354:
355:            ReplicationFrame_okButton_actionAdapter(ReplicationFrame adaptee) {
356:                this .adaptee = adaptee;
357:            }
358:
359:            public void actionPerformed(ActionEvent e) {
360:                adaptee.okButton_actionPerformed(e);
361:            }
362:        }
363:
364:        class ReplicationFrame_cancelButton_actionAdapter implements 
365:                java.awt.event.ActionListener {
366:            ReplicationFrame adaptee;
367:
368:            ReplicationFrame_cancelButton_actionAdapter(ReplicationFrame adaptee) {
369:                this .adaptee = adaptee;
370:            }
371:
372:            public void actionPerformed(ActionEvent e) {
373:                adaptee.cancelButton_actionPerformed(e);
374:            }
375:        }
376:
377:        class ReplicationFrame_profileList_mouseAdapter extends
378:                java.awt.event.MouseAdapter {
379:            ReplicationFrame adaptee;
380:
381:            ReplicationFrame_profileList_mouseAdapter(ReplicationFrame adaptee) {
382:                this .adaptee = adaptee;
383:            }
384:
385:            public void mouseClicked(MouseEvent e) {
386:                adaptee.profileList_mouseClicked(e);
387:            }
388:        }
389:
390:        class ReplicationFrame_profileList_keyAdapter extends
391:                java.awt.event.KeyAdapter {
392:            ReplicationFrame adaptee;
393:
394:            ReplicationFrame_profileList_keyAdapter(ReplicationFrame adaptee) {
395:                this .adaptee = adaptee;
396:            }
397:
398:            public void keyTyped(KeyEvent e) {
399:                adaptee.profileList_keyTyped(e);
400:            }
401:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.