KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > part > Page


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.part;
12
13 import org.eclipse.jface.action.IMenuManager;
14 import org.eclipse.jface.action.IStatusLineManager;
15 import org.eclipse.jface.action.IToolBarManager;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.ui.IActionBars;
19
20 /**
21  * Abstract base superclass for pages in a pagebook view.
22  * <p>
23  * This class should be subclassed by clients wishing to define new types
24  * of pages for multi-page views.
25  * </p>
26  * <p>
27  * Subclasses must implement the following methods:
28  * <ul>
29  * <li><code>createControl</code> - to create the page's control</li>
30  * <li><code>getControl</code> - to retrieve the page's control</li>
31  * </ul>
32  * </p>
33  * <p>
34  * Subclasses may extend or reimplement the following methods as required:
35  * <ul>
36  * <li><code>dispose</code> - extend to provide additional cleanup</li>
37  * <li><code>setFocus</code> - reimplement to accept focus</li>
38  * <li><code>setActionBars</code> - reimplement to make contributions</li>
39  * <li><code>makeContributions</code> - this method exists to support previous versions</li>
40  * <li><code>setActionBars</code> - this method exists to support previous versions</li>
41  * <li><code>init</code> - extend to provide additional setup</li>
42  * </ul>
43  * </p>
44  *
45  * @see PageBookView
46  */

47 public abstract class Page implements IPageBookViewPage {
48     /**
49      * The site which contains this page
50      */

51     private IPageSite site;
52
53     /*
54      * Creates a new page for a pagebook view.
55      */

56     protected Page() {
57     }
58
59     /* (non-Javadoc)
60      * Method declared on IPage.
61      */

62     public abstract void createControl(Composite parent);
63
64     /**
65      * The <code>Page</code> implementation of this <code>IPage</code> method
66      * disposes of this page's control (if it has one and it has not already
67      * been disposed). Subclasses may extend.
68      */

69     public void dispose() {
70         Control ctrl = getControl();
71         if (ctrl != null && !ctrl.isDisposed()) {
72             ctrl.dispose();
73         }
74     }
75
76     /**
77      * The <code>Page</code> implementation of this <code>IPage</code> method returns
78      * <code>null</code>. Subclasses must reimplement.
79      */

80     public abstract Control getControl();
81
82     /* (non-Javadoc)
83      * This method exists for backward compatibility.
84      * Subclasses should reimplement <code>init</code>.
85      */

86     public void makeContributions(IMenuManager menuManager,
87             IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
88     }
89
90     /* (non-Javadoc)
91      * This method exists for backward compatibility.
92      * Subclasses should reimplement <code>init</code>.
93      */

94     public void setActionBars(IActionBars actionBars) {
95         makeContributions(actionBars.getMenuManager(), actionBars
96                 .getToolBarManager(), actionBars.getStatusLineManager());
97     }
98
99     /**
100      * The <code>Page</code> implementation of this <code>IPageBookViewPage</code> method
101      * stores a reference to the supplied site (the site which contains this
102      * page).
103      * <p>
104      * Subclasses may extend.
105      * </p>
106      *
107      * @since 2.0
108      */

109     public void init(IPageSite pageSite) {
110         site = pageSite;
111     }
112
113     /**
114      * Returns the site which contains this page.
115      *
116      * @return the site which contains this page
117      */

118     public IPageSite getSite() {
119         return site;
120     }
121
122     /**
123      * The <code>Page</code> implementation of this <code>IPage</code> method
124      * does nothing. Subclasses must implement.
125      */

126     public abstract void setFocus();
127 }
128
Popular Tags