Source Code Cross Referenced for CollabProjectAction.java in  » IDE-Netbeans » collab » org » netbeans » modules » collab » channel » filesharing » 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 » IDE Netbeans » collab » org.netbeans.modules.collab.channel.filesharing.ui.actions 
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:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.collab.channel.filesharing.ui.actions;
042:
043:        import org.openide.ErrorManager;
044:        import org.openide.nodes.Node;
045:        import org.openide.util.*;
046:
047:        import java.awt.event.*;
048:
049:        import java.beans.PropertyChangeListener;
050:
051:        import java.util.ArrayList;
052:        import java.util.HashMap;
053:        import java.util.List;
054:
055:        import javax.swing.Action;
056:
057:        import org.netbeans.api.project.Project;
058:        import org.netbeans.api.project.ProjectUtils;
059:
060:        import org.netbeans.modules.collab.channel.filesharing.FilesharingConstants;
061:        import org.netbeans.modules.collab.channel.filesharing.FilesharingContext;
062:        import org.netbeans.modules.collab.channel.filesharing.context.ProjectContext;
063:        import org.netbeans.modules.collab.channel.filesharing.event.ProjectPerformActionEvent;
064:        import org.netbeans.modules.collab.channel.filesharing.eventlistener.FilesharingTimerTask;
065:        import org.netbeans.modules.collab.channel.filesharing.eventlistener.ProjectPerformActionTimerTask;
066:        import org.netbeans.modules.collab.channel.filesharing.mdc.EventContext;
067:        import org.netbeans.modules.collab.channel.filesharing.ui.ProjectsRootNode.ProjectNode;
068:        import org.netbeans.modules.collab.core.Debug;
069:
070:        import org.netbeans.spi.project.ui.LogicalViewProvider;
071:
072:        /**
073:         * SyncAction
074:         *
075:         * @author  Ayub Khan
076:         * @version 1.0
077:         */
078:        public class CollabProjectAction //extends SystemAction
079:                implements  Action, FilesharingConstants {
080:            ////////////////////////////////////////////////////////////////////////////
081:            // Class variables
082:            ////////////////////////////////////////////////////////////////////////////
083:            public static String COMMAND_BUILD = "build";
084:            public static String COMMAND_INSTALL = "install";
085:            public static String COMMAND_REBUILD = "rebuild";
086:            public static String COMMAND_RUN = "run";
087:            private String name;
088:            private Action projectAction;
089:            private Project project;
090:            private FilesharingContext context;
091:            private Node projectNode;
092:
093:            ////////////////////////////////////////////////////////////////////////////
094:            // Instant variables
095:            ////////////////////////////////////////////////////////////////////////////
096:            private HashMap prop = new HashMap();
097:            private List listeners = new ArrayList();
098:            private boolean enabled;
099:
100:            public CollabProjectAction(String name, Project project,
101:                    Action projectAction, FilesharingContext context,
102:                    Node projectNode) {
103:                this .name = name;
104:                this .project = project;
105:                this .projectAction = projectAction;
106:                this .context = context;
107:                this .projectNode = projectNode;
108:                putValue(Action.NAME, name);
109:            }
110:
111:            public String getName() {
112:                return name;
113:            }
114:
115:            protected String iconResource() {
116:                return "org/openide/resources/actions/empty.gif";
117:            }
118:
119:            public HelpCtx getHelpCtx() {
120:                return HelpCtx.DEFAULT_HELP;
121:            }
122:
123:            protected boolean asynchronous() {
124:                return true;
125:            }
126:
127:            private FilesharingContext getContext() {
128:                return this .context;
129:            }
130:
131:            public String getProjectName() {
132:                if (this .projectNode != null) {
133:                    return ((ProjectNode) this .projectNode).getName();
134:                } else {
135:                    return null;
136:                }
137:            }
138:
139:            public String getProjectOwner() {
140:                if (this .projectNode != null) {
141:                    return ((ProjectNode) this .projectNode).getParentNode()
142:                            .getName();
143:                } else {
144:                    return null;
145:                }
146:            }
147:
148:            public void actionPerformed(ActionEvent actionEvent) {
149:                Debug.out.println(name + ", actionPerformed"); //NoI18n
150:
151:                if ((project != null) && (projectAction != null)) {
152:                    LogicalViewProvider lvp = (LogicalViewProvider) project
153:                            .getLookup().lookup(LogicalViewProvider.class);
154:                    Node[] nodes = new Node[] { lvp.createLogicalView() };
155:                    Debug.log("ProjectsRootNode",
156:                            "ProjectsRootNode, PRN createNodes length: "
157:                                    + nodes.length);
158:
159:                    if (nodes[0].getLookup().lookup(Project.class) != project) {
160:                        // Various actions, badging, etc. are not going to work.
161:                        ErrorManager
162:                                .getDefault()
163:                                .log(
164:                                        ErrorManager.WARNING,
165:                                        "Warning - project1 "
166:                                                + ProjectUtils.getInformation(
167:                                                        project).getName()
168:                                                + " failed to supply itself in the lookup of the "
169:                                                + "root node of its own logical view"); // NOI18N
170:                    }
171:
172:                    if (projectAction instanceof  ContextAwareAction) {
173:                        projectAction = ((ContextAwareAction) projectAction)
174:                                .createContextAwareInstance(nodes[0]
175:                                        .getLookup());
176:                    }
177:
178:                    if (projectAction != null) {
179:                        projectAction.actionPerformed(new ActionEvent(nodes[0],
180:                                ActionEvent.ACTION_PERFORMED, "")); // NOI18N
181:                    }
182:                } else //remote action
183:                {
184:                    sendMessageProjectPerformAction();
185:                }
186:            }
187:
188:            private boolean sendMessageProjectPerformAction() {
189:                EventContext evContext = new ProjectContext(
190:                        ProjectPerformActionEvent.getEventID(),
191:                        getProjectOwner(), getProjectName(),
192:                        new Action[] { this  });
193:
194:                /* send projectActionList message after a delay */
195:                ProjectPerformActionTimerTask sendProjectPerformActionTimerTask = new ProjectPerformActionTimerTask(
196:                        getContext().getChannelEventNotifier(),
197:                        new ProjectPerformActionEvent(evContext), getContext());
198:                getContext().addTimerTask(SEND_PROJECTPERFORMACTION_TIMER_TASK,
199:                        sendProjectPerformActionTimerTask);
200:                sendProjectPerformActionTimerTask
201:                        .schedule(FilesharingTimerTask.PERIOD);
202:
203:                return true;
204:            }
205:
206:            /**
207:             * Adds a listener
208:             *
209:             * @param listener a listener to add
210:             *
211:             */
212:            public void addPropertyChangeListener(
213:                    PropertyChangeListener listener) {
214:                listeners.add(listener);
215:            }
216:
217:            /**
218:             * Removes a listener.
219:             * @param listener a listener to remove
220:             */
221:            public void removePropertyChangeListener(
222:                    PropertyChangeListener listener) {
223:                listeners.remove(listener);
224:            }
225:
226:            public boolean isEnabled() {
227:                return enabled;
228:            }
229:
230:            public void putValue(String key, Object value) {
231:                prop.put(key, value);
232:            }
233:
234:            public Object getValue(String key) {
235:                return prop.get(key);
236:            }
237:
238:            public void setEnabled(boolean b) {
239:                enabled = b;
240:            }
241:        }
w__w___w__._jav__a2__s._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.