Source Code Cross Referenced for WebModuleExtenderBridge.java in  » IDE-Netbeans » api » org » netbeans » modules » web » webmodule » 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 » api » org.netbeans.modules.web.webmodule 
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:
029:        package org.netbeans.modules.web.webmodule;
030:
031:        import java.awt.Component;
032:        import java.beans.PropertyChangeEvent;
033:        import java.beans.PropertyChangeListener;
034:        import java.util.Map;
035:        import java.util.Set;
036:        import javax.swing.JComponent;
037:        import javax.swing.JPanel;
038:        import javax.swing.event.ChangeListener;
039:        import org.netbeans.modules.web.api.webmodule.ExtenderController;
040:        import org.netbeans.modules.web.api.webmodule.WebModule;
041:        import org.netbeans.modules.web.spi.webmodule.FrameworkConfigurationPanel;
042:        import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider;
043:        import org.netbeans.modules.web.spi.webmodule.WebModuleExtender;
044:        import org.openide.WizardDescriptor;
045:        import org.openide.filesystems.FileObject;
046:        import org.openide.util.HelpCtx;
047:
048:        /**
049:         * This class is a bridge between the deprecated {@link WebFrameworkProvider#getConfigurationPanel}
050:         * and {@link WebFrameworkProvider#extend} methods and the new {@link WebModuleExtender} class
051:         * which replaces them.
052:         *
053:         * @author Andrei Badea
054:         */
055:        @SuppressWarnings("deprecation")
056:        public class WebModuleExtenderBridge extends WebModuleExtender {
057:
058:            private final WebFrameworkProvider framework;
059:            private final WebModule webModule;
060:            private final ExtenderController controller;
061:            private final FrameworkConfigurationPanel configPanel;
062:            private final WizardDescriptor wizard;
063:
064:            private Map<String, Object> oldProps;
065:
066:            public static WebModuleExtenderBridge create(
067:                    WebFrameworkProvider framework, WebModule webModule,
068:                    ExtenderController controller) {
069:                WebModuleExtenderBridge result = new WebModuleExtenderBridge(
070:                        framework, webModule, controller);
071:                result.initialize();
072:                return result;
073:            }
074:
075:            private WebModuleExtenderBridge(WebFrameworkProvider framework,
076:                    WebModule webModule, final ExtenderController controller) {
077:                this .framework = framework;
078:                this .webModule = webModule;
079:                this .controller = controller;
080:                FrameworkConfigurationPanel tmpPanel = framework
081:                        .getConfigurationPanel(webModule);
082:                configPanel = (tmpPanel != null) ? tmpPanel
083:                        : new EmptyConfigPanel();
084:                // we don't want to send configPanel to the wizard descriptor in order to
085:                // keep full control over the methods called on configPanel,
086:                // so we create a special panel for the wizard
087:                @SuppressWarnings("unchecked")
088:                // NOI18N
089:                WizardDescriptor tmpWizard = new WizardDescriptor(
090:                        new WizardDescriptor.Panel[] { new EmptyPanel() });
091:                wizard = tmpWizard;
092:            }
093:
094:            /**
095:             * Not done in the constructor to avoid escaping "this" before the constructor
096:             * has finished executing.
097:             */
098:            private void initialize() {
099:                wizard.addPropertyChangeListener(new PropertyChangeListener() {
100:                    public void propertyChange(PropertyChangeEvent evt) {
101:                        String message = (String) wizard
102:                                .getProperty("WizardPanel_errorMessage");
103:                        if (message != null && message.trim().length() == 0) {
104:                            // many WizardDescriptor clients pass " " for no error message to ensure
105:                            // that it still takes up vertical space
106:                            message = null;
107:                        }
108:                        controller.setErrorMessage(message); // NOI18N
109:                    }
110:                });
111:            }
112:
113:            public void addChangeListener(ChangeListener listener) {
114:                configPanel.addChangeListener(listener);
115:            }
116:
117:            @SuppressWarnings("unchecked")
118:            public Set<FileObject> extend(WebModule webModule) {
119:                configPanel.storeSettings(wizard);
120:                return (Set<FileObject>) framework.extend(webModule);
121:            }
122:
123:            public JComponent getComponent() {
124:                return (JComponent) configPanel.getComponent();
125:            }
126:
127:            public HelpCtx getHelp() {
128:                return configPanel.getHelp();
129:            }
130:
131:            public boolean isValid() {
132:                return configPanel.isValid();
133:            }
134:
135:            public void removeChangeListener(ChangeListener listener) {
136:                configPanel.removeChangeListener(listener);
137:            }
138:
139:            @SuppressWarnings("unchecked")
140:            public void update() {
141:                if (oldProps != null) {
142:                    for (Map.Entry<String, Object> entry : oldProps.entrySet()) {
143:                        wizard.putProperty(entry.getKey(), null);
144:                    }
145:                }
146:                Map<String, Object> newProps = controller.getProperties()
147:                        .getProperties();
148:                for (Map.Entry<String, Object> entry : newProps.entrySet()) {
149:                    wizard.putProperty(entry.getKey(), entry.getValue());
150:                }
151:                oldProps = newProps;
152:                configPanel.readSettings(wizard);
153:            }
154:
155:            private static class EmptyPanel implements  WizardDescriptor.Panel {
156:
157:                private JPanel component;
158:
159:                public void addChangeListener(ChangeListener l) {
160:                }
161:
162:                public Component getComponent() {
163:                    if (component == null) {
164:                        component = new JPanel();
165:                    }
166:                    return component;
167:                }
168:
169:                public HelpCtx getHelp() {
170:                    return null;
171:                }
172:
173:                public boolean isValid() {
174:                    return true;
175:                }
176:
177:                public void readSettings(Object settings) {
178:                }
179:
180:                public void removeChangeListener(ChangeListener l) {
181:                }
182:
183:                public void storeSettings(Object settings) {
184:                }
185:            }
186:
187:            /**
188:             * An empty framework configuration panel to which WebModuleExtenderBridge will delegate
189:             * when the framework doesn't have a framework configuration panel.
190:             */
191:            private final static class EmptyConfigPanel extends EmptyPanel
192:                    implements  FrameworkConfigurationPanel {
193:
194:                @Override
195:                public Component getComponent() {
196:                    return null;
197:                }
198:
199:                public void enableComponents(boolean enable) {
200:                }
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.