Source Code Cross Referenced for MarkElement.java in  » IDE-Eclipse » ui-examples » org » eclipse » ui » examples » readmetool » 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 » ui examples » org.eclipse.ui.examples.readmetool 
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.ui.examples.readmetool;
011:
012:        import java.util.Vector;
013:
014:        import org.eclipse.core.runtime.IAdaptable;
015:        import org.eclipse.jface.resource.ImageDescriptor;
016:        import org.eclipse.ui.model.IWorkbenchAdapter;
017:        import org.eclipse.ui.views.properties.IPropertySource;
018:
019:        /**
020:         * This class represents a marked location in the Readme
021:         * file text.  
022:         *
023:         * TIP: By implementing the <code>IWorkbenchAdapter</code> interface,
024:         * we can easily add objects of this type to viewers and parts in
025:         * the workbench.  When a viewer contains <code>IWorkbenchAdapter</code>,
026:         * the generic <code>WorkbenchContentProvider</code> and
027:         * <code>WorkbenchLabelProvider</code> can be used to provide
028:         * navigation and display for that viewer.
029:         */
030:        public class MarkElement implements  IWorkbenchAdapter, IAdaptable {
031:            private String headingName;
032:
033:            private IAdaptable parent;
034:
035:            private int offset;
036:
037:            private int numberOfLines;
038:
039:            private int length;
040:
041:            private Vector children;
042:
043:            /**
044:             * Creates a new MarkElement and stores parent element and
045:             * location in the text.
046:             *
047:             * @param parent  the parent of this element
048:             * @param heading text corresponding to the heading
049:             * @param offset  the offset into the Readme text
050:             * @param length  the length of the element
051:             */
052:            public MarkElement(IAdaptable parent, String heading, int offset,
053:                    int length) {
054:                this .parent = parent;
055:                if (parent instanceof  MarkElement) {
056:                    ((MarkElement) parent).addChild(this );
057:                }
058:                this .headingName = heading;
059:                this .offset = offset;
060:                this .length = length;
061:            }
062:
063:            /**
064:             * Adds a child to this element
065:             */
066:            private void addChild(MarkElement child) {
067:                if (children == null) {
068:                    children = new Vector();
069:                }
070:                children.add(child);
071:            }
072:
073:            /* (non-Javadoc)
074:             * Method declared on IAdaptable
075:             */
076:            public Object getAdapter(Class adapter) {
077:                if (adapter == IWorkbenchAdapter.class)
078:                    return this ;
079:                if (adapter == IPropertySource.class)
080:                    return new MarkElementProperties(this );
081:                return null;
082:            }
083:
084:            /* (non-Javadoc)
085:             * Method declared on IWorkbenchAdapter
086:             */
087:            public Object[] getChildren(Object object) {
088:                if (children != null) {
089:                    return children.toArray();
090:                }
091:                return new Object[0];
092:            }
093:
094:            /* (non-Javadoc)
095:             * Method declared on IWorkbenchAdapter
096:             */
097:            public ImageDescriptor getImageDescriptor(Object object) {
098:                IWorkbenchAdapter parentElement = (IWorkbenchAdapter) parent
099:                        .getAdapter(IWorkbenchAdapter.class);
100:                if (parentElement != null) {
101:                    return parentElement.getImageDescriptor(object);
102:                }
103:                return null;
104:            }
105:
106:            /* (non-Javadoc)
107:             * Method declared on IWorkbenchAdapter
108:             */
109:            public String getLabel(Object o) {
110:                return headingName;
111:            }
112:
113:            /**
114:             * Returns the number of characters in this section.
115:             */
116:            public int getLength() {
117:                return length;
118:            }
119:
120:            /**
121:             * Returns the number of lines in the element.
122:             *
123:             * @return the number of lines in the element
124:             */
125:            public int getNumberOfLines() {
126:                return numberOfLines;
127:            }
128:
129:            /* (non-Javadoc)
130:             * Method declared on IWorkbenchAdapter
131:             */
132:            public Object getParent(Object o) {
133:                return null;
134:            }
135:
136:            /**
137:             * Returns the offset of this section in the file.
138:             */
139:            public int getStart() {
140:                return offset;
141:            }
142:
143:            /**
144:             * Sets the number of lines in the element
145:             *
146:             * @param newNumberOfLines  the number of lines in the element
147:             */
148:            public void setNumberOfLines(int newNumberOfLines) {
149:                numberOfLines = newNumberOfLines;
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.