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


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * Portions Copyrighted 2007 Sun Microsystems, Inc.
027:         */
028:        package org.netbeans.modules.php.project;
029:
030:        import java.io.File;
031:        import java.text.MessageFormat;
032:        import org.netbeans.api.project.Project;
033:        import org.netbeans.modules.php.rt.spi.providers.Command;
034:        import org.netbeans.modules.php.rt.utils.PhpCommandUtils;
035:        import org.netbeans.modules.php.rt.utils.PhpProjectUtils;
036:        import org.netbeans.spi.project.support.ant.AntProjectHelper;
037:        import org.openide.awt.StatusDisplayer;
038:        import org.openide.filesystems.FileObject;
039:        import org.openide.filesystems.FileUtil;
040:        import org.openide.util.NbBundle;
041:        import org.openide.windows.IOProvider;
042:        import org.openide.windows.InputOutput;
043:        import org.openide.windows.OutputWriter;
044:
045:        /**
046:         *
047:         * @author avk
048:         */
049:        public abstract class AbstractCommand implements  Command {
050:
051:            private static final String LBL_OUT_TAB_TITLE = "LBL_OutputTabTitle";
052:
053:            public AbstractCommand(Project project) {
054:                myProject = project;
055:                initActionFiles();
056:            }
057:
058:            /**
059:             * If true, this action should be performed asynchronously in a private thread.
060:             * If false, it will be performed synchronously as called in the event thread.
061:             * @return true if this action should automatically be performed asynchronously
062:             */
063:            public boolean asynchronous() {
064:                return PhpCommandUtils.defaultAsynchronous();
065:            }
066:
067:            public boolean isEnabled() {
068:                return true;
069:            }
070:
071:            public void setActionFiles(FileObject[] files) {
072:                myFiles = files;
073:            }
074:
075:            @Override
076:            public boolean equals(Object obj) {
077:                if (!(obj instanceof  AbstractCommand)) {
078:                    return false;
079:                }
080:                AbstractCommand command = (AbstractCommand) obj;
081:                return command.getId().equals(this .getId())
082:                        && command.getLabel().equals(this .getLabel());
083:            }
084:
085:            @Override
086:            public int hashCode() {
087:                return this .getId().hashCode() * 37
088:                        + this .getLabel().hashCode();
089:            }
090:
091:            protected FileObject[] getFileObjects() {
092:                return myFiles;
093:            }
094:
095:            protected Project getProject() {
096:                return myProject;
097:            }
098:
099:            /**
100:             * should be called in the beginning of run() method
101:             */
102:            protected void refresh() {
103:                initOutputTabTitle();
104:            }
105:
106:            protected String getRelativeSrcPath(FileObject fileObject) {
107:                return PhpProjectUtils.getRelativeSrcPath(getProject(),
108:                        fileObject);
109:            }
110:
111:            protected AntProjectHelper getAntProjectHelper() {
112:                return getProject().getLookup().lookup(AntProjectHelper.class);
113:            }
114:
115:            protected FileObject[] getSourceObjects(Project phpProject) {
116:                return Utils.getSourceObjects(phpProject);
117:            }
118:
119:            protected FileObject getSourceObject() {
120:                FileObject[] sources = getSourceObjects(getProject());
121:                if (sources == null || sources.length == 0) {
122:                    return null;
123:                }
124:                /*
125:                 * I choose only first source root.
126:                 * TODO: change if we decide to support multiple src roots
127:                 */
128:                return sources[0];
129:            }
130:
131:            protected String getOutputTabTitle() {
132:                return myOutputTabTitle;
133:            }
134:
135:            protected void notifyMsg(String bundleKey, Object... args) {
136:                notifyMsg(bundleKey, getClass(), args);
137:            }
138:
139:            protected void notifyMsg(String bundleKey, Class clazz,
140:                    Object... args) {
141:                String msg = loadFormattedMsg(bundleKey, clazz, args);
142:                logToOutput(getOutputTabTitle(), msg);
143:            }
144:
145:            protected void statusMsg(String bundleKey, Object... args) {
146:                statusMsg(bundleKey, getClass(), args);
147:            }
148:
149:            protected void statusMsg(String bundleKey, Class clazz,
150:                    Object... args) {
151:                String msg = loadFormattedMsg(bundleKey, clazz, args);
152:                StatusDisplayer.getDefault().setStatusText(msg);
153:            }
154:
155:            protected static String loadFormattedMsg(String bundleKey,
156:                    Class clazz, Object... args) {
157:                String msg = NbBundle.getMessage(clazz, bundleKey);
158:                if (args.length > 0) {
159:                    msg = MessageFormat.format(msg, args);
160:                }
161:                return msg;
162:            }
163:
164:            protected boolean isNbProject(File file) {
165:                // moved away from constructor. to prevent NPE on the first init.
166:                if (PROJECT_XML == null) {
167:                    PROJECT_XML = getProject().getLookup().lookup(
168:                            AntProjectHelper.class).resolveFile(
169:                            AntProjectHelper.PROJECT_XML_PATH);
170:                }
171:                File nbProjectFile = PROJECT_XML.getParentFile();
172:                return file.equals(nbProjectFile);
173:            }
174:
175:            private void initActionFiles() {
176:                /*
177:                 * This method should be called in constructor of class because
178:                 * <code>nodes</code> array could be changed while action
179:                 * execution. So one need to initialize fileObjects array once
180:                 * and use it for access to action files.
181:                 */
182:                myFiles = PhpCommandUtils.getActionFiles();
183:            }
184:
185:            private static void logToOutput(String outTabTitle, String msg) {
186:                InputOutput io = IOProvider.getDefault().getIO(outTabTitle,
187:                        false);
188:                io.select();
189:                OutputWriter writer = io.getOut();
190:                writer.println(msg); //write tag to output window
191:                writer.flush();
192:                writer.close();
193:            }
194:
195:            /** sets default output tab title.
196:             * Can't be added to constructor because it causes problems 
197:             * with standard project actions like copy etc.
198:             * <br>
199:             * is now added into refresh() command
200:             */
201:            private void initOutputTabTitle() {
202:                myOutputTabTitle = NbBundle.getMessage(AbstractCommand.class,
203:                        LBL_OUT_TAB_TITLE, getLabel());
204:            }
205:
206:            private final Project myProject;
207:            private FileObject[] myFiles;
208:            private String myOutputTabTitle;
209:            private File PROJECT_XML;
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.