Source Code Cross Referenced for SchemaNode.java in  » IDE-Netbeans » xml » org » netbeans » modules » xslt » mapper » model » targettree » 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.targettree 
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:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:        package org.netbeans.modules.xslt.mapper.model.targettree;
020:
021:        import java.awt.Image;
022:        import java.util.ArrayList;
023:        import java.util.Collection;
024:        import java.util.List;
025:        import javax.swing.Action;
026:        import javax.swing.JMenu;
027:        import javax.swing.JPopupMenu;
028:        import javax.swing.JSeparator;
029:        import org.netbeans.modules.soa.ui.SoaUiUtil;
030:        import org.netbeans.modules.soa.ui.TooltipTextProvider;
031:        import org.netbeans.modules.soa.ui.axinodes.AxiomUtils;
032:        import org.netbeans.modules.soa.ui.axinodes.NodeType;
033:        import org.netbeans.modules.soa.ui.axinodes.NodeType.BadgeModificator;
034:        import org.netbeans.modules.xml.axi.AXIComponent;
035:        import org.netbeans.modules.xml.axi.AXIType;
036:        import org.netbeans.modules.xml.axi.Attribute;
037:        import org.netbeans.modules.xml.axi.Element;
038:        import org.netbeans.modules.xml.axi.datatype.NumberBase;
039:        import org.netbeans.modules.xml.schema.model.Attribute.Use;
040:        import org.netbeans.modules.xslt.mapper.model.nodes.NodeFactory;
041:        import org.netbeans.modules.xslt.mapper.model.nodes.TreeNode;
042:        import org.netbeans.modules.xslt.mapper.model.nodes.actions.ActionConst;
043:        import org.netbeans.modules.xslt.mapper.model.nodes.actions.AddNestedRulesGroup;
044:        import org.netbeans.modules.xslt.mapper.model.nodes.actions.AddPredicateAction;
045:        import org.netbeans.modules.xslt.mapper.model.nodes.actions.AddThisAxiComponentAction;
046:        import org.netbeans.modules.xslt.mapper.model.nodes.visitor.NodeVisitor;
047:        import org.netbeans.modules.xslt.mapper.view.PredicateManager;
048:        import org.netbeans.modules.xslt.mapper.view.XsltMapper;
049:        import org.openide.util.NbBundle;
050:
051:        /**
052:         *
053:         * @author Alexey
054:         */
055:        public class SchemaNode extends TreeNode implements  TooltipTextProvider {
056:
057:            //    private transient Boolean isSourceViewNode = null;
058:
059:            /** Creates a new instance of PlaceholderNode */
060:            public SchemaNode(AXIComponent component, XsltMapper mapper) {
061:                super (component, mapper);
062:            }
063:
064:            protected SchemaNode(Object dataObject, XsltMapper mapper) {
065:                super (dataObject, mapper);
066:            }
067:
068:            public void accept(NodeVisitor visitor) {
069:                visitor.visit(this );
070:            }
071:
072:            public AXIComponent getType() {
073:                return (AXIComponent) getDataObject();
074:            }
075:
076:            public boolean isMappable() {
077:                return true;
078:            }
079:
080:            public String toString() {
081:                String name = ((AXIType) getType()).getName();
082:                return ((getType() instanceof  Attribute) ? "@" : "") + name;
083:            }
084:
085:            protected List<TreeNode> loadChildren() {
086:                final ArrayList<TreeNode> result = new ArrayList<TreeNode>();
087:
088:                AXIComponent axic = getType();
089:                if (axic instanceof  Element) {
090:                    new AXIUtils.ElementVisitor() {
091:                        public void visit(AXIComponent c) {
092:                            TreeNode newNode = (TreeNode) NodeFactory
093:                                    .createNode(c, getMapper());
094:                            if (newNode != null) {
095:                                newNode.setParent(SchemaNode.this );
096:                                result.add(newNode);
097:                            }
098:                            //
099:                            // Load predicated nodes for source view
100:                            if (isSourceViewNode()) {
101:                                XsltMapper mapper = getMapper();
102:                                PredicateManager pManager = mapper
103:                                        .getPredicateManager();
104:                                Collection<PredicatedSchemaNode> newPNodes = pManager
105:                                        .createPredicatedNodes(newNode);
106:                                for (PredicatedSchemaNode newPNode : newPNodes) {
107:                                    newPNode.setParent(SchemaNode.this );
108:                                    result.add(newPNode);
109:                                }
110:                            }
111:                        }
112:                    }.visitSubelements((Element) axic);
113:                }
114:                return result;
115:
116:            }
117:
118:            public Image getIcon() {
119:                AXIComponent axiComponent = getType();
120:                if (axiComponent instanceof  Element) {
121:                    BadgeModificator mult = AxiomUtils
122:                            .getElementBadge((Element) axiComponent);
123:                    return NodeType.ELEMENT.getImage(mult);
124:                } else if (axiComponent instanceof  Attribute) {
125:                    Use attrUse = ((Attribute) axiComponent).getUse();
126:                    if (attrUse == Use.OPTIONAL) {
127:                        return NodeType.ATTRIBUTE
128:                                .getImage(BadgeModificator.OPTIONAL);
129:                    }
130:                    return NodeType.ATTRIBUTE.getImage(BadgeModificator.SINGLE);
131:                } else {
132:                    return null;
133:                }
134:            }
135:
136:            public String getName() {
137:                AXIComponent axiComponent = getType();
138:                //
139:                String result = null;
140:                if (axiComponent instanceof  Element) {
141:                    result = ((Element) axiComponent).getName();
142:                } else if (axiComponent instanceof  Attribute) {
143:                    result = ((Attribute) axiComponent).getName();
144:                }
145:                //
146:                return result;
147:            }
148:
149:            public String getName(boolean selected) {
150:                String result = getName();
151:                //
152:                if (!selected && !isSourceViewNode()) {
153:                    result = SoaUiUtil.getFormattedHtmlString(true,
154:                            new SoaUiUtil.TextChunk(result,
155:                                    SoaUiUtil.INACTIVE_BLUE));
156:                }
157:                //
158:                return result;
159:            }
160:
161:            public String getTooltipText() {
162:                AXIComponent axiComponent = getType();
163:                //
164:                if (axiComponent instanceof  Element) {
165:                    return AxiomUtils.getElementTooltip((Element) axiComponent);
166:                } else if (axiComponent instanceof  Attribute) {
167:                    return AxiomUtils
168:                            .getAttributeTooltip((Attribute) axiComponent);
169:                }
170:                //
171:                return null;
172:            }
173:
174:            public JPopupMenu constructPopupMenu() {
175:                JPopupMenu rootMenu = null;
176:                Action newAction;
177:                //
178:                if (isSourceViewNode()) {
179:                    // Construct the popup menu for source tree
180:                    //
181:                    AXIComponent sc = getType();
182:                    if (sc instanceof  Element) {
183:                        String max = ((Element) sc).getMaxOccurs();
184:                        boolean isRepeating = false;
185:                        if (NumberBase.UNBOUNDED_STRING.equals(max)) {
186:                            isRepeating = true;
187:                        } else {
188:                            try {
189:                                int maxInt = Integer.parseInt(max);
190:                                if (maxInt > 1) {
191:                                    isRepeating = true;
192:                                }
193:                            } catch (NumberFormatException ex) {
194:                                // DO NOTHING HERE
195:                            }
196:                        }
197:                        //
198:                        if (isRepeating) {
199:                            newAction = new AddPredicateAction(getMapper(),
200:                                    this );
201:                            rootMenu = new JPopupMenu();
202:                            rootMenu.add(newAction);
203:                        }
204:                    }
205:                    //
206:                } else {
207:                    // Construct the popup menu for target tree
208:                    String localizedName = NbBundle.getMessage(
209:                            ActionConst.class, ActionConst.ADD_MENU);
210:                    JMenu addMenu = new JMenu(localizedName);
211:                    //
212:                    newAction = new AddThisAxiComponentAction(getMapper(), this );
213:                    addMenu.add(newAction);
214:                    //
215:                    AddNestedRulesGroup nestedRules = new AddNestedRulesGroup(
216:                            getMapper(), this );
217:                    Action[] addNestedRuleArr = nestedRules.getActions();
218:                    //
219:                    if (addNestedRuleArr != null && addNestedRuleArr.length > 0) {
220:                        addMenu.add(new JSeparator());
221:                    }
222:                    //
223:                    if (addNestedRuleArr != null) {
224:                        for (Action action : addNestedRuleArr) {
225:                            addMenu.add(action);
226:                        }
227:                    }
228:                    // Add menu is added only if it's not empty
229:                    if (addMenu.getMenuComponentCount() != 0) {
230:                        rootMenu = new JPopupMenu();
231:                        rootMenu.add(addMenu);
232:                    }
233:                }
234:                //
235:                return rootMenu;
236:            }
237:
238:        }
w_ww.___j___a___v_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.