Source Code Cross Referenced for NewJDBCTableAction.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » mashup » db » wizard » 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 » IDE Netbeans » etl.project » org.netbeans.modules.mashup.db.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.netbeans.modules.mashup.db.wizard;
002:
003:        import java.awt.Component;
004:        import java.awt.Dialog;
005:        import java.sql.Connection;
006:        import java.sql.SQLException;
007:        import java.sql.Statement;
008:        import java.text.MessageFormat;
009:        import java.util.Iterator;
010:        import java.util.List;
011:        import javax.swing.JComponent;
012:        import net.java.hulp.i18n.Logger;
013:        import org.axiondb.ExternalConnectionProvider;
014:        import org.netbeans.modules.etl.logger.Localizer;
015:        import org.netbeans.modules.etl.logger.LogUtil;
016:        import org.netbeans.modules.mashup.db.common.FlatfileDBConnectionFactory;
017:        import org.netbeans.modules.mashup.db.ui.wizard.SelectDatabasePanel;
018:        import org.netbeans.modules.mashup.tables.wizard.JDBCTablePanel;
019:        import org.netbeans.modules.sql.framework.ui.utils.AxionExternalConnectionProvider;
020:        import org.openide.DialogDisplayer;
021:        import org.openide.NotifyDescriptor;
022:        import org.openide.WizardDescriptor;
023:        import org.openide.util.HelpCtx;
024:        import org.openide.util.actions.CallableSystemAction;
025:
026:        public final class NewJDBCTableAction extends CallableSystemAction {
027:            private static transient final Logger mLogger = LogUtil
028:                    .getLogger(NewJDBCTableAction.class.getName());
029:            private static transient final Localizer mLoc = Localizer.get();
030:            public String nbBundle1 = mLoc.t("PRSR001: Add JDBC Table(s)");
031:            private WizardDescriptor.Panel[] panels;
032:            public static final String DEFAULT_FLATFILE_JDBC_URL_PREFIX = "jdbc:axiondb:";
033:
034:            public void performAction() {
035:                WizardDescriptor wizardDescriptor = new WizardDescriptor(
036:                        getPanels());
037:                // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
038:                wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
039:                wizardDescriptor.setTitle(Localizer.parse(nbBundle1));
040:                Dialog dialog = DialogDisplayer.getDefault().createDialog(
041:                        wizardDescriptor);
042:                dialog
043:                        .getAccessibleContext()
044:                        .setAccessibleDescription(
045:                                "This dialog lets user to create flatfile tables from jdbc sources");
046:                dialog.setVisible(true);
047:                dialog.toFront();
048:                boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
049:                if (!cancelled) {
050:                    boolean status = false;
051:                    try {
052:                        Thread.currentThread().getContextClassLoader()
053:                                .loadClass(
054:                                        AxionExternalConnectionProvider.class
055:                                                .getName());
056:                        System
057:                                .setProperty(
058:                                        ExternalConnectionProvider.EXTERNAL_CONNECTION_PROVIDER_PROPERTY_NAME,
059:                                        AxionExternalConnectionProvider.class
060:                                                .getName());
061:                    } catch (ClassNotFoundException ex) {
062:                        //ignore
063:                    }
064:                    String jdbcUrl = (String) wizardDescriptor
065:                            .getProperty("url");
066:                    List<String> dblinks = (List<String>) wizardDescriptor
067:                            .getProperty("dblinks");
068:                    List<String> statements = (List<String>) wizardDescriptor
069:                            .getProperty("statements");
070:                    Connection conn = null;
071:                    Statement stmt = null;
072:                    try {
073:                        conn = FlatfileDBConnectionFactory.getInstance()
074:                                .getConnection(jdbcUrl);
075:                        if (conn != null) {
076:                            conn.setAutoCommit(true);
077:                            stmt = conn.createStatement();
078:                        }
079:
080:                        Iterator it = dblinks.iterator();
081:                        while (it.hasNext()) {
082:                            String sql = (String) it.next();
083:                            stmt.execute(sql);
084:                        }
085:
086:                        it = statements.iterator();
087:                        while (it.hasNext()) {
088:                            String sql = (String) it.next();
089:                            stmt.execute(sql);
090:                        }
091:                        status = true;
092:                    } catch (Exception ex) {
093:
094:                    } finally {
095:                        if (conn != null) {
096:                            try {
097:                                if (stmt != null) {
098:                                    stmt.execute("shutdown");
099:                                }
100:                                conn.close();
101:                            } catch (SQLException ex) {
102:                                conn = null;
103:                            }
104:                        }
105:                    }
106:                    if (status) {
107:                        String nbBundle2 = mLoc
108:                                .t("PRSR001: Tables successfully created.");
109:                        NotifyDescriptor d = new NotifyDescriptor.Message(
110:                                Localizer.parse(nbBundle2),
111:                                NotifyDescriptor.INFORMATION_MESSAGE);
112:                        DialogDisplayer.getDefault().notify(d);
113:                    } else {
114:                        String nbBundle3 = mLoc
115:                                .t("PRSR001: Tables creation failed.");
116:                        NotifyDescriptor d = new NotifyDescriptor.Message(
117:                                Localizer.parse(nbBundle3),
118:                                NotifyDescriptor.WARNING_MESSAGE);
119:                        DialogDisplayer.getDefault().notify(d);
120:                    }
121:                }
122:            }
123:
124:            /**
125:             * Initialize panels representing individual wizard's steps and sets
126:             * various properties for them influencing wizard appearance.
127:             */
128:            private WizardDescriptor.Panel[] getPanels() {
129:                if (panels == null) {
130:                    panels = new WizardDescriptor.Panel[] {
131:                            new SelectDatabasePanel(), new JDBCTablePanel() };
132:                    String[] steps = new String[panels.length];
133:                    for (int i = 0; i < panels.length; i++) {
134:                        Component c = panels[i].getComponent();
135:                        // Default step name to component name of panel. Mainly useful
136:                        // for getting the name of the target chooser to appear in the
137:                        // list of steps.
138:                        steps[i] = c.getName();
139:                        if (c instanceof  JComponent) { // assume Swing components
140:                            JComponent jc = (JComponent) c;
141:                            // Sets step number of a component
142:                            jc.putClientProperty(
143:                                    "WizardPanel_contentSelectedIndex",
144:                                    new Integer(i));
145:                            // Sets steps names for a panel
146:                            jc.putClientProperty("WizardPanel_contentData",
147:                                    steps);
148:                            // Turn on subtitle creation on each step
149:                            jc.putClientProperty("WizardPanel_autoWizardStyle",
150:                                    Boolean.TRUE);
151:                            // Show steps on the left side with the image on the background
152:                            jc.putClientProperty(
153:                                    "WizardPanel_contentDisplayed",
154:                                    Boolean.TRUE);
155:                            // Turn on numbering of all steps
156:                            jc.putClientProperty("WizardPanel_contentNumbered",
157:                                    Boolean.TRUE);
158:                        }
159:                    }
160:                }
161:                return panels;
162:            }
163:
164:            public String getName() {
165:                return Localizer.parse(nbBundle1);
166:            }
167:
168:            @Override
169:            public String iconResource() {
170:                return null;
171:            }
172:
173:            public HelpCtx getHelpCtx() {
174:                return HelpCtx.DEFAULT_HELP;
175:            }
176:
177:            @Override
178:            protected boolean asynchronous() {
179:                return false;
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.