KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.application;
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     private static String JavaDoc ID_PROJECT_EXPLORER = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$
22
/**
23      * Constructs a new Default layout engine.
24      */

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

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

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

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

73     public void defineLayout(IPageLayout layout) {
74         // Editors are placed for free.
75
String JavaDoc editorArea = layout.getEditorArea();
76
77         // Top left.
78
IFolderLayout topLeft = layout.createFolder(
79                 "topLeft", IPageLayout.LEFT, (float) 0.26, editorArea);//$NON-NLS-1$
80
topLeft.addView(ID_PROJECT_EXPLORER);
81         topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
82
83         // Add a placeholder for the old navigator to maintain compatibility
84
topLeft.addPlaceholder("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$
85

86         // Bottom left.
87
IFolderLayout bottomLeft = layout.createFolder(
88                 "bottomLeft", IPageLayout.BOTTOM, (float) 0.50,//$NON-NLS-1$
89
"topLeft");//$NON-NLS-1$
90
bottomLeft.addView(IPageLayout.ID_OUTLINE);
91
92         // Bottom right.
93
IFolderLayout bottomRight = layout.createFolder(
94                 "bottomRight", IPageLayout.BOTTOM, (float) 0.66,//$NON-NLS-1$
95
editorArea);
96         
97         bottomRight.addView(IPageLayout.ID_TASK_LIST);
98         
99     }
100 }
101
Popular Tags