Source Code Cross Referenced for DisplayInfoVisitor.java in  » IDE-Netbeans » xml » org » netbeans » modules » xml » schema » refactoring » ui » 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.xml.schema.refactoring.ui 
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-2007 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:
042:        /*
043:         * DisplayInfoVisitor.java
044:         *
045:         * Created on October 27, 2005, 6:51 PM
046:         *
047:         * To change this template, choose Tools | Template Manager
048:         * and open the template in the editor.
049:         */
050:
051:        package org.netbeans.modules.xml.schema.refactoring.ui;
052:
053:        import java.text.MessageFormat;
054:        import java.util.List;
055:        import org.netbeans.modules.xml.schema.model.ComplexContent;
056:        import org.netbeans.modules.xml.schema.model.ComplexContentRestriction;
057:        import org.netbeans.modules.xml.schema.model.ComplexExtension;
058:        import org.netbeans.modules.xml.schema.model.ElementReference;
059:        import org.netbeans.modules.xml.schema.model.GlobalAttribute;
060:        import org.netbeans.modules.xml.schema.model.GlobalAttributeGroup;
061:        import org.netbeans.modules.xml.schema.model.GlobalComplexType;
062:        import org.netbeans.modules.xml.schema.model.GlobalElement;
063:        import org.netbeans.modules.xml.schema.model.GlobalGroup;
064:        import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
065:        import org.netbeans.modules.xml.schema.model.GlobalType;
066:        import org.netbeans.modules.xml.schema.model.LocalAttribute;
067:        import org.netbeans.modules.xml.schema.model.LocalComplexType;
068:        import org.netbeans.modules.xml.schema.model.LocalElement;
069:        import org.netbeans.modules.xml.schema.model.LocalSimpleType;
070:        import org.netbeans.modules.xml.schema.model.Redefine;
071:        import org.netbeans.modules.xml.schema.model.Schema;
072:        import org.netbeans.modules.xml.schema.model.Sequence;
073:        import org.netbeans.modules.xml.schema.model.SimpleContent;
074:        import org.netbeans.modules.xml.schema.model.SimpleContentRestriction;
075:        import org.netbeans.modules.xml.schema.model.SimpleExtension;
076:        import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction;
077:        import org.netbeans.modules.xml.schema.model.Union;
078:        import org.netbeans.modules.xml.schema.model.visitor.DefaultSchemaVisitor;
079:        import org.netbeans.modules.xml.xam.Component;
080:        import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
081:        import org.netbeans.modules.xml.xam.Named;
082:        import org.openide.ErrorManager;
083:        import org.openide.util.NbBundle;
084:
085:        /**
086:         *
087:         * @author Jeri Lockhart
088:         */
089:        public class DisplayInfoVisitor extends DefaultSchemaVisitor {
090:
091:            private DisplayInfo info;
092:            private static final String EMPTY_STRING = ""; // NOI18N
093:
094:            /** Creates a new instance of DisplayInfoVisitor */
095:            public DisplayInfoVisitor() {
096:
097:            }
098:
099:            public DisplayInfo getDisplayInfo(Component comp) {
100:                info = new DisplayInfo();
101:                if (comp instanceof  Named) {
102:                    info.setName(((Named) comp).getName());
103:                }
104:                if (comp instanceof  GlobalSimpleType) {
105:                    visit((GlobalSimpleType) comp);
106:                } else if (comp instanceof  GlobalComplexType) {
107:                    visit((GlobalComplexType) comp);
108:                } else if (comp instanceof  LocalComplexType) {
109:                    visit((LocalComplexType) comp);
110:                } else if (comp instanceof  GlobalElement) {
111:                    visit((GlobalElement) comp);
112:                } else if (comp instanceof  LocalElement) {
113:                    visit((LocalElement) comp);
114:                } else if (comp instanceof  Sequence) {
115:                    visit((Sequence) comp);
116:                } else if (comp instanceof  ComplexContent) {
117:                    visit((ComplexContent) comp);
118:                } else if (comp instanceof  SimpleContentRestriction) {
119:                    visit((SimpleContentRestriction) comp);
120:                } else if (comp instanceof  ComplexContentRestriction) {
121:                    visit((ComplexContentRestriction) comp);
122:                } else if (comp instanceof  SimpleContent) {
123:                    visit((SimpleContent) comp);
124:                } else if (comp instanceof  ComplexExtension) {
125:                    visit((ComplexExtension) comp);
126:                } else if (comp instanceof  SimpleExtension) {
127:                    visit((SimpleExtension) comp);
128:                } else if (comp instanceof  SimpleTypeRestriction) {
129:                    visit((SimpleTypeRestriction) comp);
130:                } else if (comp instanceof  LocalSimpleType) {
131:                    visit((LocalSimpleType) comp);
132:                } else if (comp instanceof  GlobalAttribute) {
133:                    visit((GlobalAttribute) comp);
134:                } else if (comp instanceof  GlobalAttributeGroup) {
135:                    visit((GlobalAttributeGroup) comp);
136:                } else if (comp instanceof  GlobalGroup) {
137:                    visit((GlobalGroup) comp);
138:                } else if (comp instanceof  LocalAttribute) {
139:                    visit((LocalAttribute) comp);
140:                } else if (comp instanceof  ElementReference) {
141:                    visit((ElementReference) comp);
142:                } else if (comp instanceof  Union) {
143:                    visit((Union) comp);
144:                } else if (comp instanceof  Schema) {
145:                    visit((Schema) comp);
146:                } else if (comp instanceof  Redefine) {
147:                    visit((Redefine) comp);
148:                } else {
149:                    ErrorManager.getDefault()
150:                            .log(
151:                                    ErrorManager.WARNING,
152:                                    "DisplayInfoVisitor unrecognized type  "
153:                                            + comp == null ? "" : comp
154:                                            .getClass().toString()); //NOI18N
155:                }
156:                return info;
157:
158:            }
159:
160:            @Override
161:            public void visit(GlobalSimpleType gst) {
162:                super .visit(gst);
163:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
164:                        "LBL_Global_Simple_Type"));
165:            }
166:
167:            @Override
168:            public void visit(GlobalElement ge) {
169:
170:                super .visit(ge);
171:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
172:                        "LBL_Global_Element"));
173:
174:                NamedComponentReference type = ge.getType();
175:                if (type != null) {
176:                    GlobalType gt = ge.getType().get();
177:                    // TODO Replace this workaround for CR 6373793
178:                    info.setElementType(gt == null ? NbBundle.getMessage(
179:                            DisplayInfoVisitor.class, "LBL_Undetermined_Type")
180:                            : gt.getName());
181:                }
182:
183:            }
184:
185:            @Override
186:            public void visit(GlobalComplexType gct) {
187:
188:                super .visit(gct);
189:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
190:                        "LBL_Global_Complex_Type"));
191:            }
192:
193:            @Override
194:            public void visit(LocalElement le) {
195:
196:                super .visit(le);
197:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
198:                        "LBL_Local_Element"));
199:
200:                NamedComponentReference type = le.getType();
201:                if (type != null) {
202:                    GlobalType gt = le.getType().get();
203:                    // TODO Replace this workaround for CR 6373793
204:                    info.setElementType(gt == null ? NbBundle.getMessage(
205:                            DisplayInfoVisitor.class, "LBL_Undetermined_Type")
206:                            : gt.getName());
207:                }
208:            }
209:
210:            @Override
211:            public void visit(Sequence s) {
212:
213:                super .visit(s);
214:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
215:                        "LBL_Sequence"));
216:            }
217:
218:            @Override
219:            public void visit(LocalComplexType type) {
220:
221:                super .visit(type);
222:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
223:                        "LBL_Local_Complex_Type"));
224:            }
225:
226:            @Override
227:            public void visit(ComplexContent cc) {
228:
229:                super .visit(cc);
230:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
231:                        "LBL_ComplexContent"));
232:            }
233:
234:            @Override
235:            public void visit(SimpleContentRestriction scr) {
236:
237:                super .visit(scr);
238:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
239:                        "LBL_SimpleContentRestriction"));
240:            }
241:
242:            @Override
243:            public void visit(ComplexContentRestriction ccr) {
244:
245:                super .visit(ccr);
246:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
247:                        "LBL_ComplexContentRestriction"));
248:            }
249:
250:            @Override
251:            public void visit(SimpleContent sc) {
252:
253:                super .visit(sc);
254:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
255:                        "LBL_SimpleContent"));
256:            }
257:
258:            @Override
259:            public void visit(ComplexExtension ce) {
260:
261:                super .visit(ce);
262:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
263:                        "LBL_ComplexExtension"));
264:            }
265:
266:            @Override
267:            public void visit(SimpleExtension se) {
268:
269:                super .visit(se);
270:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
271:                        "LBL_SimpleExtension"));
272:            }
273:
274:            @Override
275:            public void visit(SimpleTypeRestriction str) {
276:
277:                super .visit(str);
278:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
279:                        "LBL_SimpleTypeRestriction"));
280:            }
281:
282:            @Override
283:            public void visit(LocalSimpleType type) {
284:
285:                super .visit(type);
286:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
287:                        "LBL_LocalSimpleType"));
288:            }
289:
290:            @Override
291:            public void visit(GlobalAttribute ga) {
292:
293:                super .visit(ga);
294:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
295:                        "LBL_GlobalAttribute"));
296:
297:                NamedComponentReference type = ga.getType();
298:                if (type != null) {
299:                    GlobalType gt = ga.getType().get();
300:                    // TODO Replace this workaround for CR 6373793
301:                    info.setElementType(gt == null ? NbBundle.getMessage(
302:                            DisplayInfoVisitor.class, "LBL_Undetermined_Type")
303:                            : gt.getName());
304:                }
305:            }
306:
307:            @Override
308:            public void visit(GlobalAttributeGroup gag) {
309:
310:                super .visit(gag);
311:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
312:                        "LBL_GlobalAttributeGroup"));
313:            }
314:
315:            @Override
316:            public void visit(GlobalGroup gd) {
317:
318:                super .visit(gd);
319:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
320:                        "LBL_GlobalGroup"));
321:            }
322:
323:            @Override
324:            public void visit(LocalAttribute la) {
325:
326:                super .visit(la);
327:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
328:                        "LBL_LocalAttribute"));
329:
330:                NamedComponentReference type = la.getType();
331:                if (type != null) {
332:                    GlobalType gt = la.getType().get();
333:                    // TODO Replace this workaround for CR 6373793
334:                    info.setElementType(gt == null ? NbBundle.getMessage(
335:                            DisplayInfoVisitor.class, "LBL_Undetermined_Type")
336:                            : gt.getName());
337:                }
338:            }
339:
340:            public void visit(ElementReference er) {
341:                super .visit(er);
342:                // has no name
343:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
344:                        "LBL_Local_Element"));
345:
346:                info.setElementType(NbBundle.getMessage(
347:                        DisplayInfoVisitor.class, "LBL_Global_Element"));
348:
349:                NamedComponentReference<GlobalElement> ref = er.getRef();
350:                if (ref != null) {
351:                    info.setName(MessageFormat.format(NbBundle.getMessage(
352:                            DisplayInfoVisitor.class, "LBL_References_Ref"),
353:                            new Object[] { ref.getQName().getLocalPart() }));
354:                }
355:
356:            }
357:
358:            public void visit(Schema schema) {
359:                super .visit(schema);
360:                // has no name
361:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
362:                        "LBL_Schema"));
363:
364:                info.setName(schema.getTargetNamespace());
365:
366:            }
367:
368:            public void visit(Union union) {
369:                super .visit(union);
370:                // has no name
371:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
372:                        "LBL_Union"));
373:
374:                List<NamedComponentReference<GlobalSimpleType>> members = union
375:                        .getMemberTypes();
376:                StringBuffer names = new StringBuffer(NbBundle.getMessage(
377:                        DisplayInfoVisitor.class, "LBL_Union_Members"));
378:                names.append(" "); //NOI18N
379:                if (members.size() < 1) {
380:                    names.append(NbBundle.getMessage(DisplayInfoVisitor.class,
381:                            "LBL_Union_Members_None"));
382:                } else {
383:                    for (NamedComponentReference n : members) {
384:                        names.append(n.getQName().toString());
385:                        names.append(" ");//NOI18N
386:                    }
387:                }
388:                // Named Members: TypeA TypeB TypeC
389:                // Named Members: [none]
390:                info.setName(names.toString());
391:
392:            }
393:
394:            public void visit(Redefine redefine) {
395:                super .visit(redefine);
396:                // has no name
397:                info.setCompType(NbBundle.getMessage(DisplayInfoVisitor.class,
398:                        "LBL_Redefine"));
399:
400:                info.setName(NbBundle.getMessage(DisplayInfoVisitor.class,
401:                        "LBL_Redefinition"));
402:
403:            }
404:
405:            public static class DisplayInfo {
406:
407:                private String name = EMPTY_STRING;
408:                private String compType = EMPTY_STRING;
409:                private String elementType = EMPTY_STRING;
410:
411:                public DisplayInfo() {
412:
413:                }
414:
415:                /**
416:                 * Getter for property name.
417:                 * @return Value of property name.
418:                 */
419:                public String getName() {
420:
421:                    return this .name;
422:                }
423:
424:                /**
425:                 * Setter for property name.
426:                 * @param name New value of property name.
427:                 */
428:                public void setName(String name) {
429:                    if (name == null) {
430:                        name = EMPTY_STRING;
431:                    }
432:
433:                    this .name = name;
434:                }
435:
436:                /**
437:                 * Getter for property compType.
438:                 * @return Value of property compType.
439:                 */
440:                public String getCompType() {
441:
442:                    return this .compType;
443:                }
444:
445:                /**
446:                 * Setter for property compType.
447:                 * @param compType New value of property compType.
448:                 */
449:                public void setCompType(String compType) {
450:                    if (compType == null) {
451:                        compType = EMPTY_STRING;
452:                    }
453:
454:                    this .compType = compType;
455:                }
456:
457:                /**
458:                 * The type of the GlobalElement, LocalElement, GlobalAttribute, or LocalAttribute
459:                 * Getter for property elementType.
460:                 * @return Value of property elementType.
461:                 */
462:                public String getElementType() {
463:
464:                    return this .elementType;
465:                }
466:
467:                /**
468:                 * The type of the GlobalElement, LocalElement, GlobalAttribute, or LocalAttribute
469:                 * @param elementType New value of property elementType.
470:                 */
471:                public void setElementType(String elementType) {
472:                    if (elementType == null) {
473:                        elementType = EMPTY_STRING;
474:                    }
475:
476:                    this.elementType = elementType;
477:                }
478:
479:            }
480:
481:        }
ww__w__.__ja_v__a__2___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.