001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 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.internal.ide.application;
011:
012: import org.eclipse.ui.IFolderLayout;
013: import org.eclipse.ui.IPageLayout;
014: import org.eclipse.ui.IPerspectiveFactory;
015:
016: /**
017: */
018: public class ResourcePerspective implements IPerspectiveFactory {
019:
020: private static String ID_PROJECT_EXPLORER = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$
021:
022: /**
023: * Constructs a new Default layout engine.
024: */
025: public ResourcePerspective() {
026: super ();
027: }
028:
029: /**
030: * Defines the initial layout for a perspective.
031: *
032: * Implementors of this method may add additional views to a
033: * perspective. The perspective already contains an editor folder
034: * with <code>ID = ILayoutFactory.ID_EDITORS</code>. Add additional views
035: * to the perspective in reference to the editor folder.
036: *
037: * This method is only called when a new perspective is created. If
038: * an old perspective is restored from a persistence file then
039: * this method is not called.
040: *
041: * @param layout the factory used to add views to the perspective
042: */
043: public void createInitialLayout(IPageLayout layout) {
044: defineActions(layout);
045: defineLayout(layout);
046: }
047:
048: /**
049: * Defines the initial actions for a page.
050: * @param layout The layout we are filling
051: */
052: public void defineActions(IPageLayout layout) {
053: // Add "new wizards".
054: layout
055: .addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
056: layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
057:
058: // Add "show views".
059: layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
060: layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
061: layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
062: layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
063: layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
064: layout.addShowViewShortcut(IPageLayout.ID_PROGRESS_VIEW);
065: layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
066:
067: layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
068: }
069:
070: /**
071: * Defines the initial layout for a page.
072: * @param layout The layout we are filling
073: */
074: public void defineLayout(IPageLayout layout) {
075: // Editors are placed for free.
076: String editorArea = layout.getEditorArea();
077:
078: // Top left.
079: IFolderLayout topLeft = layout.createFolder(
080: "topLeft", IPageLayout.LEFT, (float) 0.26, editorArea);//$NON-NLS-1$
081: topLeft.addView(ID_PROJECT_EXPLORER);
082: topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
083:
084: // Add a placeholder for the old navigator to maintain compatibility
085: topLeft
086: .addPlaceholder("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$
087:
088: // Bottom left.
089: IFolderLayout bottomLeft = layout.createFolder(
090: "bottomLeft", IPageLayout.BOTTOM, (float) 0.50,//$NON-NLS-1$
091: "topLeft");//$NON-NLS-1$
092: bottomLeft.addView(IPageLayout.ID_OUTLINE);
093:
094: // Bottom right.
095: IFolderLayout bottomRight = layout.createFolder(
096: "bottomRight", IPageLayout.BOTTOM, (float) 0.66,//$NON-NLS-1$
097: editorArea);
098:
099: bottomRight.addView(IPageLayout.ID_TASK_LIST);
100:
101: }
102: }
|