Source Code Cross Referenced for ModelBridge.java in  » IDE-Netbeans » xml » org » netbeans » modules » xslt » mapper » model » 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 » xml » org.netbeans.modules.xslt.mapper.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         *
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         *
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         *
015:         * Portions Copyrighted 2007 Sun Microsystems, Inc.
016:         */
017:        package org.netbeans.modules.xslt.mapper.model;
018:
019:        import java.awt.event.ActionEvent;
020:        import java.awt.event.ActionListener;
021:        import org.netbeans.modules.xml.xam.ComponentListener;
022:        import java.beans.PropertyChangeEvent;
023:        import java.beans.PropertyChangeListener;
024:        import java.util.List;
025:        import javax.swing.Timer;
026:        import javax.swing.JTree;
027:        import javax.swing.tree.TreePath;
028:        import org.netbeans.modules.xml.axi.AXIComponent;
029:        import org.netbeans.modules.xml.xam.ComponentEvent;
030:        import org.netbeans.modules.xml.xam.Model;
031:        import org.netbeans.modules.xslt.mapper.model.nodes.TreeNode;
032:        import org.netbeans.modules.xslt.mapper.view.XsltMapper;
033:        import org.netbeans.modules.xslt.model.Stylesheet;
034:        import org.netbeans.modules.xslt.model.Template;
035:        import org.netbeans.modules.xslt.model.XslModel;
036:        import org.openide.util.NbBundle;
037:
038:        /**
039:         *
040:         * @author Alexey
041:         */
042:        public abstract class ModelBridge implements  ComponentListener,
043:                PropertyChangeListener {
044:
045:            private UpdateTimer updateTimer = new UpdateTimer();
046:            private XsltMapper mapper;
047:
048:            public ModelBridge(XsltMapper mapper) {
049:                this .mapper = mapper;
050:            }
051:
052:            public XsltMapper getMapper() {
053:                return this .mapper;
054:            }
055:
056:            protected void subscribe(Model model) {
057:                if (model != null) {
058:                    model.addComponentListener(this );
059:                    model.addPropertyChangeListener(this );
060:                }
061:            }
062:
063:            private class UpdateTimer {
064:
065:                private Timer timer;
066:
067:                public UpdateTimer() {
068:                    timer = new Timer(100, new ActionListener() {
069:
070:                        public void actionPerformed(ActionEvent e) {
071:                            onModelChanged();
072:                        }
073:                    });
074:                    timer.setRepeats(false);
075:                }
076:
077:                public void onEvent() {
078:                    if (timer.isRunning()) {
079:                        timer.restart();
080:                    } else {
081:                        timer.start();
082:                    }
083:                }
084:            }
085:
086:            /**
087:             * This method is called whenever the model is change.
088:             */
089:            protected abstract void onModelChanged();
090:
091:            protected boolean checkErrors() {
092:                String errorMessages = "";
093:                if (getMapper().getContext() != null) {
094:                    String valMessage = getMapper().getContext()
095:                            .getValidationMessage();
096:                    if (valMessage != null) {
097:                        errorMessages += valMessage;
098:                    }
099:
100:                    XslModel xslModel = getMapper().getContext().getXSLModel();
101:                    if (xslModel == null
102:                            || xslModel.getState() != XslModel.State.VALID) {
103:                        errorMessages += NbBundle.getMessage(
104:                                XsltModelBridge.class, "MSG_Error_BadXSL"); // NOI18N
105:                    } else {
106:                        Stylesheet stylesheet = xslModel.getStylesheet();
107:                        if (stylesheet == null) {
108:                            errorMessages += NbBundle.getMessage(
109:                                    XsltModelBridge.class,
110:                                    "MSG_Error_NoStylesheet"); // NOI18N
111:                        } else {
112:                            List<Template> templates = stylesheet
113:                                    .getChildren(Template.class);
114:                            boolean templateFound = false;
115:                            for (Template t : templates) {
116:                                if (t.getMatch().equals("/")) {
117:                                    templateFound = true;
118:                                    break;
119:                                }
120:                            }
121:                            //
122:                            if (!templateFound) {
123:                                errorMessages += NbBundle.getMessage(
124:                                        XsltModelBridge.class,
125:                                        "MSG_Error_NoRootTemplate"); // NOI18N
126:                            }
127:                        }
128:                    }
129:                    //
130:                    AXIComponent typeIn = getMapper().getContext()
131:                            .getSourceType();
132:                    if (typeIn == null
133:                            || typeIn.getModel() == null
134:                            || typeIn.getModel().getState() != XslModel.State.VALID) {
135:                        //                errorMessages += NbBundle.getMessage(XsltModelBridge.class, "MSG_Error_BadInputSchema"); // NOI18N
136:                    }
137:                    AXIComponent typeOut = getMapper().getContext()
138:                            .getTargetType();
139:                    if (typeOut == null
140:                            || typeOut.getModel() == null
141:                            || typeOut.getModel().getState() != XslModel.State.VALID) {
142:                        //                errorMessages += NbBundle.getMessage(XsltModelBridge.class, "MSG_Error_BadOutputSchema"); // NOI18N
143:                    }
144:                } else {
145:                    errorMessages += NbBundle.getMessage(XsltModelBridge.class,
146:                            "MSG_Error_BadXSLTMAP"); // NOI18N
147:                }
148:
149:                //         if (!errorMessages.isEmpty()){
150:                if (errorMessages != null && !"".equals(errorMessages)) {
151:                    // NOI18N
152:                    mapper.setError(NbBundle.getMessage(XsltModelBridge.class,
153:                            "MSG_Error_Diagram", errorMessages)); // NOI18N);
154:                    return false;
155:                } else {
156:                    mapper.setError(null);
157:                    return true;
158:                }
159:            }
160:
161:            protected void reloadTree(JTree tree) {
162:
163:                TreeExpandedState expandedState = new TreeExpandedState(tree);
164:                expandedState.save();
165:
166:                XsltNodesTreeModel treeModel = (XsltNodesTreeModel) tree
167:                        .getModel();
168:
169:                treeModel.resetRoot();
170:
171:                TreeNode treeRoot = (TreeNode) tree.getModel().getRoot();
172:
173:                TreePath startFrom_tp = TreeNode.getTreePath(treeRoot);
174:
175:                /*
176:                 * trigger tree reload
177:                 * TreeNode.reload() implementation shoukd try to keep old nodes as much as possible
178:                 * to be able to restore selection state and preserve links on diagram
179:                 */
180:
181:                treeRoot.reload();
182:
183:                ((XsltNodesTreeModel) tree.getModel())
184:                        .fireTreeChanged(startFrom_tp);
185:
186:                expandedState.restore();
187:            }
188:
189:            public void valueChanged(ComponentEvent componentEvent) {
190:                updateDiagram();
191:            }
192:
193:            public void childrenAdded(ComponentEvent componentEvent) {
194:                updateDiagram();
195:            }
196:
197:            public void childrenDeleted(ComponentEvent componentEvent) {
198:                updateDiagram();
199:            }
200:
201:            public void propertyChange(PropertyChangeEvent evt) {
202:                updateDiagram();
203:            }
204:
205:            public void updateDiagram() {
206:                updateTimer.onEvent();
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.