package com.yoursway.ide.rcp.internal; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; import org.eclipse.ui.IPlaceholderFolderLayout; /** */ public class ResourcePerspective implements IPerspectiveFactory { public static final String ID = "com.yoursway.ide.resourcePerspective"; private static String ID_PROJECT_EXPLORER = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$ /** * Constructs a new Default layout engine. */ public ResourcePerspective() { super(); } /** * Defines the initial layout for a perspective. * * Implementors of this method may add additional views to a * perspective. The perspective already contains an editor folder * with <code>ID = ILayoutFactory.ID_EDITORS</code>. Add additional views * to the perspective in reference to the editor folder. * * This method is only called when a new perspective is created. If * an old perspective is restored from a persistence file then * this method is not called. * * @param layout the factory used to add views to the perspective */ public void createInitialLayout(IPageLayout layout) { defineActions(layout); defineLayout(layout); } /** * Defines the initial actions for a page. * @param layout The layout we are filling */ public void defineActions(IPageLayout layout) { // Add "new wizards". layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ // Add "show views". layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS); layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET); layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); layout.addShowViewShortcut(IPageLayout.ID_PROGRESS_VIEW); layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); } /** * Defines the initial layout for a page. * @param layout The layout we are filling */ public void defineLayout(IPageLayout layout) { // Editors are placed for free. String editorArea = layout.getEditorArea(); // Top left. IFolderLayout topLeft = layout.createFolder( "topLeft", IPageLayout.LEFT, (float) 0.26, editorArea);//$NON-NLS-1$ topLeft.addView(ID_PROJECT_EXPLORER); topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS); // Add a placeholder for the old navigator to maintain compatibility topLeft.addPlaceholder("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$ // Bottom left. IPlaceholderFolderLayout bottomLeft = layout.createPlaceholderFolder( "bottomLeft", IPageLayout.BOTTOM, (float) 0.50,//$NON-NLS-1$ "topLeft");//$NON-NLS-1$ bottomLeft.addPlaceholder(IPageLayout.ID_OUTLINE); // Bottom right. IPlaceholderFolderLayout bottomRight = layout.createPlaceholderFolder( "bottomRight", IPageLayout.BOTTOM, (float) 0.66,//$NON-NLS-1$ editorArea); bottomRight.addPlaceholder(IPageLayout.ID_TASK_LIST); } }