package com.posture.example.navigator;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.console.IConsoleConstants;
import com.posture.example.navigator.wizards.NewRobinProjectWizard;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
defineActions(layout);
defineLayout(layout);
}
// 定义透视图上的默认行为
private void defineActions(IPageLayout layout) {
layout.addNewWizardShortcut(NewRobinProjectWizard.NEW_ROBIN_PROJECT_ID);
// 添加 新建文件夹
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
// 在当前视图上 window/show view 上的东西
layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS);
layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
}
private void defineLayout(IPageLayout layout) {
IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, IPageLayout.ID_EDITOR_AREA);
topLeft.addView(IPageLayout.ID_PROJECT_EXPLORER);
IFolderLayout bottomLeft = layout.createFolder(
"bottomLeft", IPageLayout.BOTTOM, (float) 0.50,//$NON-NLS-1$
"topLeft");//$NON-NLS-1$
bottomLeft.addView(IConsoleConstants.ID_CONSOLE_VIEW);
layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, 0.25f, IPageLayout.ID_EDITOR_AREA);
}
}
本文介绍了一个Eclipse透视图的创建过程,包括定义快捷操作及布局。通过自定义的Perspective类实现添加新项目的向导、文件和文件夹创建的快捷方式,并设置控制台和编辑器等视图的快捷键。此外,还详细展示了如何组织编辑器区域及其周边的视图布局。
1046

被折叠的 条评论
为什么被折叠?



