Source Code Cross Referenced for SQLPanel.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » panel » dbbrowserwindow » 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 » DBBrowser » org.dbbrowser.ui.panel.dbbrowserwindow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui.panel.dbbrowserwindow;
002:
003:        import infrastructure.internationalization.InternationalizationManager;
004:        import infrastructure.propertymanager.PropertyManager;
005:        import java.awt.Dimension;
006:        import java.awt.event.ActionEvent;
007:        import java.awt.event.ActionListener;
008:        import java.io.BufferedReader;
009:        import java.io.File;
010:        import java.io.FileNotFoundException;
011:        import java.io.FileReader;
012:        import java.io.IOException;
013:        import javax.swing.*;
014:
015:        import org.dbbrowser.ui.UIControllerForQueries;
016:        import org.dbbrowser.ui.UIControllerForRawSQL;
017:
018:        public class SQLPanel extends JPanel implements  ActionListener {
019:            private static final long serialVersionUID = UIControllerForQueries.version;
020:
021:            private static final String TITLE = InternationalizationManager
022:                    .getInstance().getMessage("dbbrowser-ui",
023:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
024:            private static final String OPEN_NEW_SQL_TAB_LABEL = InternationalizationManager
025:                    .getInstance()
026:                    .getMessage(
027:                            "dbbrowser-ui",
028:                            "dbbrowser-ui-dbbrowser-sql-tab-open-new-tab-button-label",
029:                            null);
030:            private static final String REMOVE_SQL_TAB_LABEL = InternationalizationManager
031:                    .getInstance()
032:                    .getMessage(
033:                            "dbbrowser-ui",
034:                            "dbbrowser-ui-dbbrowser-sql-tab-remove-tab-button-label",
035:                            null);
036:            private static final String SELECT_NAME_FOR_TAB_LABEL = InternationalizationManager
037:                    .getInstance()
038:                    .getMessage(
039:                            "dbbrowser-ui",
040:                            "dbbrowser-ui-dbbrowser-sql-tab-select-name-for-tab",
041:                            null);
042:
043:            private static final String OPEN_NEW_SQL_TAB_ICON_FILENAME = PropertyManager
044:                    .getInstance()
045:                    .getProperty(
046:                            "dbbrowser-ui-dbbrowser-window-sql-tab-open-new-sql-tab-button-icon");
047:            private static final String REMOVE_SQL_TAB_ICON_FILENAME = PropertyManager
048:                    .getInstance()
049:                    .getProperty(
050:                            "dbbrowser-ui-dbbrowser-window-sql-tab-remove-sql-tab-button-icon");
051:
052:            private UIControllerForQueries uicontroller = null;
053:            private UIControllerForRawSQL uiControllerForRawSQL = null;
054:
055:            private JPanel topRowPanel = new JPanel();
056:            private JTabbedPane tabbedPanesForSQLStatements = new JTabbedPane();
057:
058:            private RunSQLPanel sqlPanel = null;
059:
060:            public SQLPanel(UIControllerForQueries uicontroller,
061:                    UIControllerForRawSQL uiControllerForRawSQL) {
062:                this .uicontroller = uicontroller;
063:                this .uiControllerForRawSQL = uiControllerForRawSQL;
064:                initialize();
065:            }
066:
067:            public void runBatchFile(File file) {
068:                try {
069:                    StringBuffer buffer = new StringBuffer();
070:                    BufferedReader reader = new BufferedReader(new FileReader(
071:                            file));
072:                    String line = reader.readLine();
073:                    while (line != null) {
074:                        buffer.append(line + "\n");
075:                        line = reader.readLine();
076:                    }
077:
078:                    reader.close();
079:
080:                    //Create a new tab with the contents
081:                    sqlPanel = new RunSQLPanel(this .uicontroller,
082:                            this .uiControllerForRawSQL, buffer.toString());
083:                    tabbedPanesForSQLStatements.addTab(file.getName(), null,
084:                            sqlPanel, file.getAbsolutePath());
085:                    tabbedPanesForSQLStatements.setSelectedComponent(sqlPanel);
086:                } catch (FileNotFoundException exc) {
087:                    String errorMessage = InternationalizationManager
088:                            .getInstance()
089:                            .getMessage(
090:                                    "dbbrowser-ui",
091:                                    "dbbrowser-ui-dbbrowser-window-open-batch-file-failed",
092:                                    null);
093:                    JOptionPane.showMessageDialog(null, errorMessage, TITLE,
094:                            JOptionPane.ERROR_MESSAGE);
095:                } catch (IOException exc) {
096:                    String errorMessage = InternationalizationManager
097:                            .getInstance()
098:                            .getMessage(
099:                                    "dbbrowser-ui",
100:                                    "dbbrowser-ui-dbbrowser-window-open-batch-file-failed",
101:                                    null);
102:                    JOptionPane.showMessageDialog(null, errorMessage, TITLE,
103:                            JOptionPane.ERROR_MESSAGE);
104:                }
105:            }
106:
107:            private void initialize() {
108:                this .tabbedPanesForSQLStatements
109:                        .setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
110:
111:                //Set the layout
112:                this .setLayout(new BoxLayout(this , BoxLayout.PAGE_AXIS));
113:
114:                //Setup the button to add new tab
115:                JButton buttonToAddNewSQLTab = new JButton(
116:                        OPEN_NEW_SQL_TAB_LABEL, new ImageIcon(
117:                                OPEN_NEW_SQL_TAB_ICON_FILENAME));
118:                this .topRowPanel.add(buttonToAddNewSQLTab);
119:                buttonToAddNewSQLTab.addActionListener(this );
120:
121:                //Setup the button to remove current tab
122:                JButton buttonToRemoveSQLTab = new JButton(
123:                        REMOVE_SQL_TAB_LABEL, new ImageIcon(
124:                                REMOVE_SQL_TAB_ICON_FILENAME));
125:                this .topRowPanel.add(buttonToRemoveSQLTab);
126:                buttonToRemoveSQLTab.addActionListener(this );
127:
128:                //Set the size of the top row panel
129:                Dimension d = new Dimension(
130:                        this .topRowPanel.getMaximumSize().width, 50);
131:                this .topRowPanel.setMaximumSize(d);
132:
133:                //Add a tab
134:                sqlPanel = new RunSQLPanel(this .uicontroller,
135:                        this .uiControllerForRawSQL, "");
136:                tabbedPanesForSQLStatements.addTab("SQL", sqlPanel);
137:
138:                //Add the panels
139:                this .add(this .topRowPanel);
140:                this .add(this .tabbedPanesForSQLStatements);
141:            }
142:
143:            public void actionPerformed(ActionEvent e) {
144:                if (e.getActionCommand().equals(OPEN_NEW_SQL_TAB_LABEL)) {
145:                    String tabTitle = (String) JOptionPane.showInputDialog(
146:                            null, SELECT_NAME_FOR_TAB_LABEL, TITLE,
147:                            JOptionPane.QUESTION_MESSAGE, null, null, "SQL");
148:
149:                    if (tabTitle != null) {
150:                        //Add a tab
151:                        sqlPanel = new RunSQLPanel(this .uicontroller,
152:                                this .uiControllerForRawSQL);
153:                        tabbedPanesForSQLStatements.addTab(tabTitle, sqlPanel);
154:                        tabbedPanesForSQLStatements
155:                                .setSelectedComponent(sqlPanel);
156:                    }
157:                }
158:
159:                if (e.getActionCommand().equals(REMOVE_SQL_TAB_LABEL)) {
160:                    //Add a tab
161:                    int selectedTabIndex = tabbedPanesForSQLStatements
162:                            .getSelectedIndex();
163:                    if (selectedTabIndex > -1) {
164:                        tabbedPanesForSQLStatements.remove(selectedTabIndex);
165:                    }
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.