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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.text.java;
011:
012:        import java.io.IOException;
013:        import java.io.Reader;
014:        import java.io.StringReader;
015:
016:        import org.eclipse.core.runtime.IProgressMonitor;
017:
018:        import org.eclipse.jdt.core.IJavaElement;
019:        import org.eclipse.jdt.core.IMember;
020:        import org.eclipse.jdt.core.JavaModelException;
021:
022:        import org.eclipse.jdt.ui.JavadocContentAccess;
023:
024:        import org.eclipse.jdt.internal.ui.JavaPlugin;
025:        import org.eclipse.jdt.internal.ui.text.javadoc.JavaDoc2HTMLTextReader;
026:
027:        public class ProposalInfo {
028:
029:            private boolean fJavadocResolved = false;
030:            private String fJavadoc = null;
031:
032:            protected IJavaElement fElement;
033:
034:            public ProposalInfo(IMember member) {
035:                fElement = member;
036:            }
037:
038:            protected ProposalInfo() {
039:                fElement = null;
040:            }
041:
042:            public IJavaElement getJavaElement() throws JavaModelException {
043:                return fElement;
044:            }
045:
046:            /**
047:             * Gets the text for this proposal info formatted as HTML, or
048:             * <code>null</code> if no text is available.
049:             *
050:             * @param monitor a progress monitor
051:             * @return the additional info text
052:             */
053:            public final String getInfo(IProgressMonitor monitor) {
054:                if (!fJavadocResolved) {
055:                    fJavadocResolved = true;
056:                    fJavadoc = computeInfo(monitor);
057:                }
058:                return fJavadoc;
059:            }
060:
061:            /**
062:             * Gets the text for this proposal info formatted as HTML, or
063:             * <code>null</code> if no text is available.
064:             *
065:             * @param monitor a progress monitor
066:             * @return the additional info text
067:             */
068:            private String computeInfo(IProgressMonitor monitor) {
069:                try {
070:                    final IJavaElement javaElement = getJavaElement();
071:                    if (javaElement instanceof  IMember) {
072:                        IMember member = (IMember) javaElement;
073:                        return extractJavadoc(member, monitor);
074:                    }
075:                } catch (JavaModelException e) {
076:                    JavaPlugin.log(e);
077:                } catch (IOException e) {
078:                    JavaPlugin.log(e);
079:                }
080:                return null;
081:            }
082:
083:            /**
084:             * Extracts the javadoc for the given <code>IMember</code> and returns it
085:             * as HTML.
086:             *
087:             * @param member the member to get the documentation for
088:             * @param monitor a progress monitor
089:             * @return the javadoc for <code>member</code> or <code>null</code> if
090:             *         it is not available
091:             * @throws JavaModelException if accessing the javadoc fails
092:             * @throws IOException if reading the javadoc fails
093:             */
094:            private String extractJavadoc(IMember member,
095:                    IProgressMonitor monitor) throws JavaModelException,
096:                    IOException {
097:                if (member != null) {
098:                    Reader reader = getHTMLContentReader(member, monitor);
099:                    if (reader != null)
100:                        return getString(reader);
101:                }
102:                return null;
103:            }
104:
105:            private Reader getHTMLContentReader(IMember member,
106:                    IProgressMonitor monitor) throws JavaModelException {
107:                Reader contentReader = JavadocContentAccess.getContentReader(
108:                        member, true);
109:                if (contentReader != null)
110:                    return new JavaDoc2HTMLTextReader(contentReader);
111:
112:                if (true && member.getOpenable().getBuffer() == null) { // only if no source available
113:                    String s = member.getAttachedJavadoc(monitor);
114:                    if (s != null)
115:                        return new StringReader(s);
116:                }
117:                return null;
118:            }
119:
120:            /**
121:             * Gets the reader content as a String
122:             * 
123:             * @param reader the reader 
124:             * @return the reader content as string
125:             */
126:            private static String getString(Reader reader) {
127:                StringBuffer buf = new StringBuffer();
128:                char[] buffer = new char[1024];
129:                int count;
130:                try {
131:                    while ((count = reader.read(buffer)) != -1)
132:                        buf.append(buffer, 0, count);
133:                } catch (IOException e) {
134:                    return null;
135:                }
136:                return buf.toString();
137:            }
138:        }
w__w_w_.j_a_v_a__2___s___.___co___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.