Source Code Cross Referenced for ContentOutlinePage.java in  » IDE-Eclipse » ui » org » eclipse » ui » views » contentoutline » 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 » org.eclipse.ui.views.contentoutline 
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.views.contentoutline;
011:
012:        import org.eclipse.core.runtime.ListenerList;
013:        import org.eclipse.core.runtime.Platform;
014:        import org.eclipse.jface.util.SafeRunnable;
015:        import org.eclipse.jface.viewers.ISelection;
016:        import org.eclipse.jface.viewers.ISelectionChangedListener;
017:        import org.eclipse.jface.viewers.SelectionChangedEvent;
018:        import org.eclipse.jface.viewers.StructuredSelection;
019:        import org.eclipse.jface.viewers.TreeViewer;
020:        import org.eclipse.swt.SWT;
021:        import org.eclipse.swt.widgets.Composite;
022:        import org.eclipse.swt.widgets.Control;
023:        import org.eclipse.ui.part.IPageSite;
024:        import org.eclipse.ui.part.Page;
025:
026:        /**
027:         * An abstract base class for content outline pages.
028:         * <p>
029:         * Clients who are defining an editor may elect to provide a corresponding
030:         * content outline page. This content outline page will be presented to the
031:         * user via the standard Content Outline View (the user decides whether their
032:         * workbench window contains this view) whenever that editor is active.
033:         * This class should be subclassed.
034:         * </p>
035:         * <p>
036:         * Internally, each content outline page consists of a standard tree viewer; 
037:         * selections made in the tree viewer are reported as selection change events 
038:         * by the page (which is a selection provider). The tree viewer is not created 
039:         * until <code>createPage</code> is called; consequently, subclasses must extend
040:         * <code>createControl</code> to configure the tree viewer with a proper content 
041:         * provider, label provider, and input element.
042:         * </p>
043:         * <p>
044:         * Note that those wanting to use a control other than internally created
045:         * <code>TreeViewer</code> will need to implement 
046:         * <code>IContentOutlinePage</code> directly rather than subclassing this class.
047:         * </p> 
048:         */
049:        public abstract class ContentOutlinePage extends Page implements 
050:                IContentOutlinePage, ISelectionChangedListener {
051:            private ListenerList selectionChangedListeners = new ListenerList();
052:
053:            private TreeViewer treeViewer;
054:
055:            /**
056:             * Create a new content outline page.
057:             */
058:            protected ContentOutlinePage() {
059:                super ();
060:            }
061:
062:            /* (non-Javadoc)
063:             * Method declared on ISelectionProvider.
064:             */
065:            public void addSelectionChangedListener(
066:                    ISelectionChangedListener listener) {
067:                selectionChangedListeners.add(listener);
068:            }
069:
070:            /**
071:             * The <code>ContentOutlinePage</code> implementation of this 
072:             * <code>IContentOutlinePage</code> method creates a tree viewer. Subclasses
073:             * must extend this method configure the tree viewer with a proper content 
074:             * provider, label provider, and input element.
075:             * @param parent
076:             */
077:            public void createControl(Composite parent) {
078:                treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL
079:                        | SWT.V_SCROLL);
080:                treeViewer.addSelectionChangedListener(this );
081:            }
082:
083:            /**
084:             * Fires a selection changed event.
085:             *
086:             * @param selection the new selection
087:             */
088:            protected void fireSelectionChanged(ISelection selection) {
089:                // create an event
090:                final SelectionChangedEvent event = new SelectionChangedEvent(
091:                        this , selection);
092:
093:                // fire the event
094:                Object[] listeners = selectionChangedListeners.getListeners();
095:                for (int i = 0; i < listeners.length; ++i) {
096:                    final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
097:                    Platform.run(new SafeRunnable() {
098:                        public void run() {
099:                            l.selectionChanged(event);
100:                        }
101:                    });
102:                }
103:            }
104:
105:            /* (non-Javadoc)
106:             * Method declared on IPage (and Page).
107:             */
108:            public Control getControl() {
109:                if (treeViewer == null) {
110:                    return null;
111:                }
112:                return treeViewer.getControl();
113:            }
114:
115:            /* (non-Javadoc)
116:             * Method declared on ISelectionProvider.
117:             */
118:            public ISelection getSelection() {
119:                if (treeViewer == null) {
120:                    return StructuredSelection.EMPTY;
121:                }
122:                return treeViewer.getSelection();
123:            }
124:
125:            /**
126:             * Returns this page's tree viewer.
127:             *
128:             * @return this page's tree viewer, or <code>null</code> if 
129:             *   <code>createControl</code> has not been called yet
130:             */
131:            protected TreeViewer getTreeViewer() {
132:                return treeViewer;
133:            }
134:
135:            /*
136:             *  (non-Javadoc)
137:             * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite)
138:             */
139:            public void init(IPageSite pageSite) {
140:                super .init(pageSite);
141:                pageSite.setSelectionProvider(this );
142:            }
143:
144:            /* (non-Javadoc)
145:             * Method declared on ISelectionProvider.
146:             */
147:            public void removeSelectionChangedListener(
148:                    ISelectionChangedListener listener) {
149:                selectionChangedListeners.remove(listener);
150:            }
151:
152:            /* (non-Javadoc)
153:             * Method declared on ISelectionChangeListener.
154:             * Gives notification that the tree selection has changed.
155:             */
156:            public void selectionChanged(SelectionChangedEvent event) {
157:                fireSelectionChanged(event.getSelection());
158:            }
159:
160:            /**
161:             * Sets focus to a part in the page.
162:             */
163:            public void setFocus() {
164:                treeViewer.getControl().setFocus();
165:            }
166:
167:            /* (non-Javadoc)
168:             * Method declared on ISelectionProvider.
169:             */
170:            public void setSelection(ISelection selection) {
171:                if (treeViewer != null) {
172:                    treeViewer.setSelection(selection);
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.