KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > IPerspectiveFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13 /**
14  * A perspective factory generates the initial page layout and visible
15  * action set for a page.
16  * <p>
17  * When a new page is created in the workbench a perspective is used to define
18  * the initial page layout. If this is a predefined perspective (based on an extension to
19  * the workbench's perspective extension point) an <code>IPerspectiveFactory</code>
20  * is used to define the initial page layout.
21  * </p><p>
22  * The factory for the perspective is created and passed an <code>IPageLayout</code>
23  * where views can be added. The default layout consists of the editor area with no
24  * additional views. Additional views are added to the layout using
25  * the editor area as the initial point of reference. The factory is used only briefly
26  * while a new page is created; then discarded.
27  * </p><p>
28  * To define a perspective clients should implement this interface and
29  * include the name of their class in an extension to the workbench's perspective
30  * extension point (named <code>"org.eclipse.ui.perspectives"</code>). For example,
31  * the plug-in's XML markup might contain:
32  * <pre>
33  * &LT;extension point="org.eclipse.ui.perspectives"&GT;
34  * &LT;perspective
35  * id="com.example.javaplugin.perspective"
36  * name="Java"
37  * class="com.example.javaplugin.JavaPerspective"&GT;
38  * &LT;/perspective&GT;
39  * &LT;/extension&GT;
40  * </pre>
41  * </p><p>
42  * Example of populating a page with standard workbench views:
43  * <pre>
44  * public void createInitialLayout(IPageLayout layout) {
45  * // Get the editor area.
46  * String editorArea = layout.getEditorArea();
47  *
48  * // Top left: Resource Navigator view and Bookmarks view placeholder
49  * IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f,
50  * editorArea);
51  * topLeft.addView(IPageLayout.ID_RES_NAV);
52  * topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
53  *
54  * // Bottom left: Outline view and Property Sheet view
55  * IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.50f,
56  * "topLeft");
57  * bottomLeft.addView(IPageLayout.ID_OUTLINE);
58  * bottomLeft.addView(IPageLayout.ID_PROP_SHEET);
59  *
60  * // Bottom right: Task List view
61  * layout.addView(IPageLayout.ID_TASK_LIST, IPageLayout.BOTTOM, 0.66f, editorArea);
62  * }
63  * </pre>
64  * </p><p>
65  * Within the workbench a user may override the visible views, layout and
66  * action sets of a predefined perspective to create a custom perspective. In such cases
67  * the layout is persisted by the workbench and the factory is not used.
68  * </p>
69  */

70 public interface IPerspectiveFactory {
71     /**
72      * Creates the initial layout for a page.
73      * <p>
74      * Implementors of this method may add additional views to a
75      * perspective. The perspective already contains an editor folder
76      * identified by the result of <code>IPageLayout.getEditorArea()</code>.
77      * Additional views should be added to the layout using this value as
78      * the initial point of reference.
79      * </p>
80      *
81      * @param layout the page layout
82      */

83     public void createInitialLayout(IPageLayout layout);
84 }
85
Popular Tags