Source Code Cross Referenced for NewFlatfileDatabaseWizardAction.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.io.File;
006:        import java.sql.Connection;
007:        import java.sql.SQLException;
008:        import java.text.MessageFormat;
009:        import java.io.FileInputStream;
010:        import java.io.FileNotFoundException;
011:        import java.io.IOException;
012:        import java.util.Properties;
013:        import javax.swing.JComponent;
014:
015:        import net.java.hulp.i18n.Logger;
016:        import org.netbeans.modules.etl.logger.Localizer;
017:        import org.netbeans.modules.etl.logger.LogUtil;
018:        import org.netbeans.modules.etl.ui.ETLEditorSupport;
019:        import org.netbeans.modules.mashup.db.ui.AxionDBConfiguration;
020:        import org.netbeans.modules.mashup.tables.wizard.MashupTableWizardIterator;
021:        import org.netbeans.modules.sql.framework.common.utils.DBExplorerUtil;
022:        import org.openide.DialogDisplayer;
023:        import org.openide.NotifyDescriptor;
024:        import org.openide.WizardDescriptor;
025:        import org.openide.util.HelpCtx;
026:        import org.openide.util.actions.CallableSystemAction;
027:
028:        public final class NewFlatfileDatabaseWizardAction extends
029:                CallableSystemAction {
030:
031:            private WizardDescriptor.Panel[] panels;
032:            public static final String DEFAULT_FLATFILE_JDBC_URL_PREFIX = "jdbc:axiondb:";
033:            private static transient final Logger mLogger = LogUtil
034:                    .getLogger(NewFlatfileDatabaseWizardAction.class.getName());
035:            private static transient final Localizer mLoc = Localizer.get();
036:            public String nbBundle1 = mLoc.t("PRSR001: Create Mashup Database");
037:
038:            public void performAction() {
039:                WizardDescriptor wizardDescriptor = new WizardDescriptor(
040:                        getPanels());
041:                // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
042:                wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
043:                wizardDescriptor.setTitle(Localizer.parse(nbBundle1));
044:                Dialog dialog = DialogDisplayer.getDefault().createDialog(
045:                        wizardDescriptor);
046:                dialog
047:                        .getAccessibleContext()
048:                        .setAccessibleDescription(
049:                                "This is the Dialog which lets the user create a mashup database");
050:                dialog.setSize(630, 334);
051:                dialog.setVisible(true);
052:                dialog.toFront();
053:                boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
054:                if (!cancelled) {
055:                    String dbName = (String) wizardDescriptor
056:                            .getProperty("dbName");
057:                    boolean status = handle(dbName);
058:                    if (status) {
059:                        String nbBundle2 = mLoc.t(
060:                                "PRSR001: Database {0} successfully created.",
061:                                dbName);
062:                        NotifyDescriptor d = new NotifyDescriptor.Message(
063:                                Localizer.parse(nbBundle2),
064:                                NotifyDescriptor.INFORMATION_MESSAGE);
065:                        DialogDisplayer.getDefault().notify(d);
066:                    }
067:                }
068:            }
069:
070:            /**
071:             * Initialize panels representing individual wizard's steps and sets
072:             * various properties for them influencing wizard appearance.
073:             */
074:            private WizardDescriptor.Panel[] getPanels() {
075:                if (panels == null) {
076:                    panels = new WizardDescriptor.Panel[] { new NewFlatfileDatabaseWizardPanel() };
077:                    String[] steps = new String[panels.length];
078:                    for (int i = 0; i < panels.length; i++) {
079:                        Component c = panels[i].getComponent();
080:                        // Default step name to component name of panel. Mainly useful
081:                        // for getting the name of the target chooser to appear in the
082:                        // list of steps.
083:                        steps[i] = c.getName();
084:                        if (c instanceof  JComponent) { // assume Swing components
085:                            JComponent jc = (JComponent) c;
086:                            // Sets step number of a component
087:                            jc.putClientProperty(
088:                                    "WizardPanel_contentSelectedIndex",
089:                                    new Integer(i));
090:                            // Sets steps names for a panel
091:                            jc.putClientProperty("WizardPanel_contentData",
092:                                    steps);
093:                            // Turn on subtitle creation on each step
094:                            jc.putClientProperty("WizardPanel_autoWizardStyle",
095:                                    Boolean.TRUE);
096:                            // Show steps on the left side with the image on the background
097:                            jc.putClientProperty(
098:                                    "WizardPanel_contentDisplayed",
099:                                    Boolean.TRUE);
100:                            // Turn on numbering of all steps
101:                            jc.putClientProperty("WizardPanel_contentNumbered",
102:                                    Boolean.TRUE);
103:                        }
104:                    }
105:                }
106:                return panels;
107:            }
108:
109:            public String getName() {
110:                return Localizer.parse(nbBundle1);
111:            }
112:
113:            @Override
114:            public String iconResource() {
115:                return null;
116:            }
117:
118:            public HelpCtx getHelpCtx() {
119:                return HelpCtx.DEFAULT_HELP;
120:            }
121:
122:            @Override
123:            protected boolean asynchronous() {
124:                return false;
125:            }
126:
127:            private String getDefaultWorkingFolder() {
128:                File conf = AxionDBConfiguration.getConfigFile();
129:                Properties prop = new Properties();
130:                try {
131:                    FileInputStream in = new FileInputStream(conf);
132:                    prop.load(in);
133:                } catch (FileNotFoundException ex) {
134:                    //ignore
135:                } catch (IOException ex) {
136:                    //ignore
137:                }
138:                String loc = prop.getProperty(AxionDBConfiguration.PROP_DB_LOC);
139:                File db = new File(loc);
140:                if (!db.exists()) {
141:                    db.mkdir();
142:                }
143:                return loc;
144:            }
145:
146:            private boolean handle(String name) {
147:                String location = null;
148:                if (MashupTableWizardIterator.IS_PROJECT_CALL) {
149:                    location = ETLEditorSupport.PRJ_PATH
150:                            + "\\nbproject\\private\\databases";
151:                } else {
152:                    location = getDefaultWorkingFolder();
153:                }
154:                MashupTableWizardIterator.IS_PROJECT_CALL = false;
155:                boolean status = false;
156:                String url = DEFAULT_FLATFILE_JDBC_URL_PREFIX + name + ":"
157:                        + location + "\\" + name;
158:                File f = new File(location + name);
159:                char[] ch = name.toCharArray();
160:                if (ch == null) {
161:                    String nbBundle3 = mLoc
162:                            .t("PRSR001: No Database name specified.");
163:                    NotifyDescriptor d = new NotifyDescriptor.Message(Localizer
164:                            .parse(nbBundle3),
165:                            NotifyDescriptor.INFORMATION_MESSAGE);
166:                    DialogDisplayer.getDefault().notify(d);
167:                } else if (f.exists()) {
168:                    String nbBundle4 = mLoc.t(
169:                            "PRSR001: Database {0} already exists.", name);
170:                    NotifyDescriptor d = new NotifyDescriptor.Message(Localizer
171:                            .parse(nbBundle4),
172:                            NotifyDescriptor.INFORMATION_MESSAGE);
173:                    DialogDisplayer.getDefault().notify(d);
174:                } else {
175:                    Connection conn = null;
176:                    try {
177:                        conn = DBExplorerUtil
178:                                .createConnection(
179:                                        "org.axiondb.jdbc.AxionDriver", url,
180:                                        "sa", "sa");
181:                        if (conn != null) {
182:                            status = true;
183:                        }
184:                    } catch (Exception ex) {
185:                        String nbBundle5 = mLoc
186:                                .t("PRSR001: Axion driver could not be loaded.");
187:                        NotifyDescriptor d = new NotifyDescriptor.Message(
188:                                Localizer.parse(nbBundle5),
189:                                NotifyDescriptor.INFORMATION_MESSAGE);
190:                        DialogDisplayer.getDefault().notify(d);
191:                    } finally {
192:                        try {
193:                            if (conn != null) {
194:                                conn.createStatement().execute("shutdown");
195:                                conn.close();
196:                            }
197:                        } catch (SQLException ex) {
198:                            conn = null;
199:                        }
200:                    }
201:                }
202:                return status;
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.