KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > ResourcePerspective


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.internal.ide;
12
13 import org.eclipse.ui.IFolderLayout;
14 import org.eclipse.ui.IPageLayout;
15 import org.eclipse.ui.IPerspectiveFactory;
16
17 /**
18  */

19 public class ResourcePerspective implements IPerspectiveFactory {
20     /**
21      * Constructs a new Default layout engine.
22      */

23     public ResourcePerspective() {
24         super();
25     }
26
27     /**
28      * Defines the initial layout for a perspective.
29      *
30      * Implementors of this method may add additional views to a
31      * perspective. The perspective already contains an editor folder
32      * with <code>ID = ILayoutFactory.ID_EDITORS</code>. Add additional views
33      * to the perspective in reference to the editor folder.
34      *
35      * This method is only called when a new perspective is created. If
36      * an old perspective is restored from a persistence file then
37      * this method is not called.
38      *
39      * @param layout the factory used to add views to the perspective
40      */

41     public void createInitialLayout(IPageLayout layout) {
42         defineActions(layout);
43         defineLayout(layout);
44     }
45
46     /**
47      * Defines the initial actions for a page.
48      * @param layout The layout we are filling
49      */

50     public void defineActions(IPageLayout layout) {
51         // Add "new wizards".
52
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
53
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
54

55         // Add "show views".
56
layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
57         layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
58         layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
59         layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
60         layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
61         layout.addShowViewShortcut(IPageLayout.ID_PROGRESS_VIEW);
62         layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
63
64         layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
65     }
66
67     /**
68      * Defines the initial layout for a page.
69      * @param layout The layout we are filling
70      */

71     public void defineLayout(IPageLayout layout) {
72         // Editors are placed for free.
73
String JavaDoc editorArea = layout.getEditorArea();
74
75         // Top left.
76
IFolderLayout topLeft = layout.createFolder(
77                 "topLeft", IPageLayout.LEFT, (float) 0.26, editorArea);//$NON-NLS-1$
78
topLeft.addView(IPageLayout.ID_RES_NAV);
79         topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
80
81         // Bottom left.
82
IFolderLayout bottomLeft = layout.createFolder(
83                 "bottomLeft", IPageLayout.BOTTOM, (float) 0.50,//$NON-NLS-1$
84
"topLeft");//$NON-NLS-1$
85
bottomLeft.addView(IPageLayout.ID_OUTLINE);
86
87         // Bottom right.
88
IFolderLayout bottomRight = layout.createFolder(
89                 "bottomRight", IPageLayout.BOTTOM, (float) 0.66,//$NON-NLS-1$
90
editorArea);
91         
92         bottomRight.addView(IPageLayout.ID_TASK_LIST);
93         
94     }
95 }
96
Popular Tags