Source Code Cross Referenced for AddBookmarkCommand.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » sqlbookmark » 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 » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.sqlbookmark 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2003 Joseph Mocker
003:         * mock-sf@misfit.dhs.org
004:         *
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License
007:         * as published by the Free Software Foundation; either version 2
008:         * of the License, or any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License
016:         * along with this program; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:         */
019:
020:        package net.sourceforge.squirrel_sql.plugins.sqlbookmark;
021:
022:        import java.awt.Frame;
023:
024:        import javax.swing.JOptionPane;
025:
026:        import net.sourceforge.squirrel_sql.client.gui.session.SQLInternalFrame;
027:        import net.sourceforge.squirrel_sql.client.gui.session.SessionInternalFrame;
028:        import net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel;
029:        import net.sourceforge.squirrel_sql.client.session.ISession;
030:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
031:        import net.sourceforge.squirrel_sql.fw.util.ICommand;
032:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
033:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
034:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
035:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
036:
037:        /**
038:         * Initiate the addition of a new SQL Bookmark.
039:         *
040:         * The SQL for the bookmark is taken from the current SQL Edit buffer.
041:         * The user is prompted for a name for the bookmark.
042:         *
043:         * @author      Joseph Mocker
044:         **/
045:        public class AddBookmarkCommand implements  ICommand {
046:
047:            private static final StringManager s_stringMgr = StringManagerFactory
048:                    .getStringManager(AddBookmarkCommand.class);
049:
050:            private static ILogger logger = LoggerController
051:                    .createLogger(AddBookmarkCommand.class);
052:
053:            /** Parent frame. */
054:            private final Frame frame;
055:
056:            /** The session that we are saving a script for. */
057:            private final ISession session;
058:
059:            /** The current plugin. */
060:            private SQLBookmarkPlugin plugin;
061:
062:            /**
063:             * Ctor.
064:             *
065:             * @param   frame   Parent Frame.
066:             * @param   session The session that we are saving a script for.
067:             * @param   plugin  The current plugin.
068:             *
069:             * @throws  IllegalArgumentException
070:             *          Thrown if a <TT>null</TT> <TT>ISession</TT> or <TT>IPlugin</TT>
071:             *          passed.
072:             */
073:            public AddBookmarkCommand(Frame frame, ISession session,
074:                    SQLBookmarkPlugin plugin) throws IllegalArgumentException {
075:                super ();
076:                if (session == null) {
077:                    throw new IllegalArgumentException("Null ISession passed");
078:                }
079:                if (plugin == null) {
080:                    throw new IllegalArgumentException("Null IPlugin passed");
081:                }
082:                this .frame = frame;
083:                this .session = session;
084:                this .plugin = plugin;
085:            }
086:
087:            /**
088:             * Execute the addition of the bookmark.
089:             */
090:            public void execute() {
091:                if (session == null) {
092:                    return;
093:                }
094:
095:                ISQLEntryPanel sqlEntryPanel;
096:
097:                if (session.getActiveSessionWindow() instanceof  SessionInternalFrame) {
098:                    sqlEntryPanel = ((SessionInternalFrame) session
099:                            .getActiveSessionWindow()).getSQLPanelAPI()
100:                            .getSQLEntryPanel();
101:                } else if (session.getActiveSessionWindow() instanceof  SQLInternalFrame) {
102:                    sqlEntryPanel = ((SQLInternalFrame) session
103:                            .getActiveSessionWindow()).getSQLPanelAPI()
104:                            .getSQLEntryPanel();
105:                } else {
106:                    return;
107:                }
108:
109:                String sql = sqlEntryPanel.getSQLToBeExecuted();
110:                if (null == sql || 0 == sql.trim().length()) {
111:                    // i18n[sqlbookmark.noAdd=No text to be added.]
112:                    JOptionPane.showMessageDialog(frame, s_stringMgr
113:                            .getString("sqlbookmark.noAdd"));
114:                    return;
115:                }
116:
117:                AddBookmarkDialog abd = new AddBookmarkDialog(frame, plugin);
118:                GUIUtils.centerWithinParent(abd);
119:                abd.setVisible(true);
120:
121:                if (false == abd.isOK())
122:                    return;
123:
124:                Bookmark bookmark = new Bookmark(abd.getBookmarkName(), abd
125:                        .getDescription(), sql);
126:
127:                if (!plugin.getBookmarkManager().add(bookmark)) {
128:                    plugin.addBookmarkItem(bookmark);
129:                }
130:
131:                plugin.getBookmarkManager().save();
132:            }
133:
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.