Source Code Cross Referenced for JavaNode.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » compare » 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 Eclipse » jdt » org.eclipse.jdt.internal.ui.compare 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.ui.compare;
011:
012:        import org.eclipse.swt.graphics.Image;
013:
014:        import org.eclipse.jface.resource.ImageDescriptor;
015:
016:        import org.eclipse.jface.text.IDocument;
017:
018:        import org.eclipse.compare.ITypedElement;
019:        import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
020:
021:        import org.eclipse.jdt.core.IJavaElement;
022:
023:        import org.eclipse.jdt.internal.ui.JavaPlugin;
024:
025:        /**
026:         * Comparable Java elements are represented as JavaNodes.
027:         * Extends the DocumentRangeNode with method signature information.
028:         */
029:        class JavaNode extends DocumentRangeNode implements  ITypedElement {
030:
031:            public static final int CU = 0;
032:            public static final int PACKAGE = 1;
033:            public static final int IMPORT_CONTAINER = 2;
034:            public static final int IMPORT = 3;
035:            public static final int INTERFACE = 4;
036:            public static final int CLASS = 5;
037:            public static final int ENUM = 6;
038:            public static final int ANNOTATION = 7;
039:            public static final int FIELD = 8;
040:            public static final int INIT = 9;
041:            public static final int CONSTRUCTOR = 10;
042:            public static final int METHOD = 11;
043:
044:            private int fInitializerCount = 1;
045:
046:            /**
047:             * Creates a JavaNode under the given parent.
048:             * @param parent the parent node
049:             * @param type the Java elements type. Legal values are from the range CU to METHOD of this class.
050:             * @param name the name of the Java element
051:             * @param start the starting position of the java element in the underlying document
052:             * @param length the number of characters of the java element in the underlying document
053:             */
054:            public JavaNode(JavaNode parent, int type, String name, int start,
055:                    int length) {
056:                super (parent, type, JavaCompareUtilities.buildID(type, name),
057:                        parent.getDocument(), start, length);
058:                parent.addChild(this );
059:            }
060:
061:            /**
062:             * Creates a JavaNode for a CU. It represents the root of a
063:             * JavaNode tree, so its parent is null.
064:             * @param document the document which contains the Java element
065:             */
066:            public JavaNode(IDocument document) {
067:                super (
068:                        CU,
069:                        JavaCompareUtilities.buildID(CU, "root"), document, 0, document.getLength()); //$NON-NLS-1$
070:            }
071:
072:            public String getInitializerCount() {
073:                return Integer.toString(fInitializerCount++);
074:            }
075:
076:            /**
077:             * Extracts the method name from the signature.
078:             * Used for smart matching.
079:             */
080:            public String extractMethodName() {
081:                String id = getId();
082:                int pos = id.indexOf('(');
083:                if (pos > 0)
084:                    return id.substring(1, pos);
085:                return id.substring(1);
086:            }
087:
088:            /**
089:             * Extracts the method's arguments name the signature.
090:             * Used for smart matching.
091:             */
092:            public String extractArgumentList() {
093:                String id = getId();
094:                int pos = id.indexOf('(');
095:                if (pos >= 0)
096:                    return id.substring(pos + 1);
097:                return id.substring(1);
098:            }
099:
100:            /**
101:             * Returns a name which is presented in the UI.
102:             * @see ITypedElement#getName()
103:             */
104:            public String getName() {
105:
106:                switch (getTypeCode()) {
107:                case INIT:
108:                    return CompareMessages.JavaNode_initializer;
109:                case IMPORT_CONTAINER:
110:                    return CompareMessages.JavaNode_importDeclarations;
111:                case CU:
112:                    return CompareMessages.JavaNode_compilationUnit;
113:                case PACKAGE:
114:                    return CompareMessages.JavaNode_packageDeclaration;
115:                }
116:                return getId().substring(1); // we strip away the type character
117:            }
118:
119:            /*
120:             * @see ITypedElement#getType()
121:             */
122:            public String getType() {
123:                return "java2"; //$NON-NLS-1$
124:            }
125:
126:            /**
127:             * Returns a shared image for this Java element.
128:             *
129:             * see ITypedInput.getImage
130:             */
131:            public Image getImage() {
132:
133:                ImageDescriptor id = null;
134:
135:                switch (getTypeCode()) {
136:                case CU:
137:                    id = JavaCompareUtilities
138:                            .getImageDescriptor(IJavaElement.COMPILATION_UNIT);
139:                    break;
140:                case PACKAGE:
141:                    id = JavaCompareUtilities
142:                            .getImageDescriptor(IJavaElement.PACKAGE_DECLARATION);
143:                    break;
144:                case IMPORT:
145:                    id = JavaCompareUtilities
146:                            .getImageDescriptor(IJavaElement.IMPORT_DECLARATION);
147:                    break;
148:                case IMPORT_CONTAINER:
149:                    id = JavaCompareUtilities
150:                            .getImageDescriptor(IJavaElement.IMPORT_CONTAINER);
151:                    break;
152:                case CLASS:
153:                    id = JavaCompareUtilities.getTypeImageDescriptor(true);
154:                    break;
155:                case INTERFACE:
156:                    id = JavaCompareUtilities.getTypeImageDescriptor(false);
157:                    break;
158:                case INIT:
159:                    id = JavaCompareUtilities
160:                            .getImageDescriptor(IJavaElement.INITIALIZER);
161:                    break;
162:                case CONSTRUCTOR:
163:                case METHOD:
164:                    id = JavaCompareUtilities
165:                            .getImageDescriptor(IJavaElement.METHOD);
166:                    break;
167:                case FIELD:
168:                    id = JavaCompareUtilities
169:                            .getImageDescriptor(IJavaElement.FIELD);
170:                    break;
171:                case ENUM:
172:                    id = JavaCompareUtilities.getEnumImageDescriptor();
173:                    break;
174:                case ANNOTATION:
175:                    id = JavaCompareUtilities.getAnnotationImageDescriptor();
176:                    break;
177:                }
178:                return JavaPlugin.getImageDescriptorRegistry().get(id);
179:            }
180:
181:            /*
182:             * @see java.lang.Object#toString()
183:             */
184:            public String toString() {
185:                return getType()
186:                        + ": " + getName() //$NON-NLS-1$
187:                        + "[" + getRange().offset + "+" + getRange().length + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.