Source Code Cross Referenced for IJAction.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » ui » actions » 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 DBMS » db derby 10.2 » org.apache.derby.ui.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        	Derby - Class org.apache.derby.ui.actions.IJAction
004:        	
005:        	Licensed to the Apache Software Foundation (ASF) under one or more
006:        	contributor license agreements.  See the NOTICE file distributed with
007:        	this work for additional information regarding copyright ownership.
008:        	The ASF licenses this file to you under the Apache License, Version 2.0
009:        	(the "License"); you may not use this file except in compliance with
010:        	the License.  You may obtain a copy of the License at
011:        	
012:        	   http://www.apache.org/licenses/LICENSE-2.0
013:        	
014:        	Unless required by applicable law or agreed to in writing, software
015:        	distributed under the License is distributed on an "AS IS" BASIS,
016:        	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:        	See the License for the specific language governing permissions and
018:        	limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.ui.actions;
023:
024:        import org.apache.derby.ui.DerbyPlugin;
025:        import org.apache.derby.ui.common.CommonNames;
026:        import org.apache.derby.ui.common.Messages;
027:        import org.apache.derby.ui.util.DerbyUtils;
028:        import org.apache.derby.ui.util.Logger;
029:        import org.eclipse.core.resources.IFile;
030:        import org.eclipse.core.resources.IProject;
031:        import org.eclipse.core.runtime.IStatus;
032:        import org.eclipse.jdt.core.IJavaProject;
033:        import org.eclipse.jface.action.IAction;
034:        import org.eclipse.jface.dialogs.MessageDialog;
035:        import org.eclipse.jface.viewers.ISelection;
036:        import org.eclipse.jface.viewers.IStructuredSelection;
037:        import org.eclipse.swt.widgets.Shell;
038:        import org.eclipse.ui.IActionDelegate;
039:        import org.eclipse.ui.IObjectActionDelegate;
040:        import org.eclipse.ui.IWorkbenchPart;
041:
042:        public class IJAction implements  IObjectActionDelegate {
043:
044:            private IFile currentScript;
045:            private IJavaProject currentJavaProject;
046:            private IProject currentProject;
047:
048:            /**
049:             * Constructor for IJAction.
050:             */
051:            public IJAction() {
052:                super ();
053:            }
054:
055:            /**
056:             * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
057:             */
058:            public void setActivePart(IAction action, IWorkbenchPart targetPart) {
059:            }
060:
061:            /**
062:             * @see IActionDelegate#run(IAction)
063:             */
064:            public void run(IAction action) {
065:
066:                Shell shell = new Shell();
067:                DerbyPlugin plugin = DerbyPlugin.getDefault();
068:                if (plugin == null) {
069:                    MessageDialog.openInformation(shell,
070:                            CommonNames.PLUGIN_NAME, Messages.NO_ACTION);
071:                } else {
072:                    try {
073:                        if (currentJavaProject != null) {
074:                            currentProject = currentJavaProject.getProject();
075:                        }
076:                        if (currentProject
077:                                .isNatureEnabled(CommonNames.DERBY_NATURE)) {
078:                            DerbyUtils.runIJ(currentScript, currentProject);
079:                        } else {
080:                            shell = new Shell();
081:                            MessageDialog.openInformation(shell,
082:                                    CommonNames.PLUGIN_NAME,
083:                                    Messages.NO_DERBY_NATURE + "\n"
084:                                            + Messages.ADD_N_TRY);
085:                        }
086:                    } catch (Exception e) {
087:                        Logger.log("IAction.run() error " + e, IStatus.ERROR);
088:                    }
089:                }
090:            }
091:
092:            /**
093:             * @see IActionDelegate#selectionChanged(IAction, ISelection)
094:             */
095:            public void selectionChanged(IAction action, ISelection selection) {
096:                currentJavaProject = org.apache.derby.ui.util.SelectionUtil
097:                        .findSelectedJavaProject(selection);
098:                if (currentJavaProject == null) {
099:                    currentProject = org.apache.derby.ui.util.SelectionUtil
100:                            .findSelectedProject(selection);
101:                }
102:                currentScript = null;
103:                if (selection != null) {
104:                    if (selection instanceof  IStructuredSelection) {
105:                        IStructuredSelection ss = (IStructuredSelection) selection;
106:                        // get the first element, since selection is for single object
107:                        Object obj = ss.getFirstElement();
108:                        if (obj instanceof  IFile) {
109:                            currentScript = (IFile) obj;
110:                        }
111:                        if (currentScript != null) {
112:                            currentProject = currentScript.getProject();
113:                        }
114:                    }
115:                }
116:                // To turn off the action item if the DERBY nature is not set	
117:                // We decided to go with the pop-up dialog way with the message to 
118:                // add the Derby nature and try.
119:
120:                //		try{
121:                //			if((currentScript!=null)&&(currentProject!=null)){
122:                //				if(currentScript.getName().toLowerCase().endsWith(".sql")&&(!currentProject.isNatureEnabled(CommonNames.DERBY_NATURE))){
123:                //					action.setEnabled(false);
124:                //				}
125:                //			}
126:                //		}catch(CoreException ce){
127:                //			Logger.log("IAction.selectionChanged() method error "+ce,IStatus.ERROR);
128:                //		}
129:            }
130:
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.