unknowIfGuestInDream / tlstudio

Currently includes SWT examples, and will support jface and other examples in the future
Eclipse Public License 2.0
2 stars 0 forks source link

[Feature Request] Perspective 透视图快捷方式栏中同时显示多个透视图 #156

Closed unknowIfGuestInDream closed 2 months ago

unknowIfGuestInDream commented 2 months ago

Checklist

Describe the feature

1、在切换栏中显示


public class PIMWorkbenchAdvisor extends WorkbenchAdvisor {
    @Override
    public void postStartup() {
        super.postStartup();
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        //2007.01.11 设置同时显示多个透视图标
        PerspectiveBarManager barManager=((WorkbenchWindow)activeWorkbenchWindow).getPerspectiveBar();
        if(barManager != null){
            IPerspectiveDescriptor mailPerspective = WorkbenchPlugin.getDefault().getPerspectiveRegistry   ().findPerspectiveWithId("MyWork_mail.perspective");
            PerspectiveBarContributionItem item=new PerspectiveBarContributionItem(mailPerspective,activeWorkbenchWindow.getActivePage());
            barManager.addItem(item);
        }
}

Additional context

No response

unknowIfGuestInDream commented 2 months ago

在下拉框中(shortcut)显示


public class UiPerspective implements IPerspectiveFactory
{
    public void createInitialLayout(IPageLayout layout){
....
        //增加透视图
        layout.addPerspectiveShortcut("net.sf.pim.plugin.UiPerspective");
        layout.addPerspectiveShortcut("MyWork_mail.perspective");
       }
}
unknowIfGuestInDream commented 2 months ago

透视图切换工具位置 透视图切换工具位于窗口左上角,在Eclipse里可以通过Window->Preferences-> Workbench->Appearance改变它的位置,那么怎样用程序控制它呢?有两个方法,第一个是使用如下代码设置 IPreferenceStore中的变量: IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore(); apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT); 另一个方法是在plugin所在目录建一个名为plugin_customization.ini的文件,里面写如下内容: your.plugin.id/DOCK_PERSPECTIVE_BAR=topRight

Update:在最新的Eclipse 3.1M5a版本中,对RCP应用程序菜单和工具条的定制方法有所改变,应该使用新加入的ActionBarAdvisor类来完成此项工作。

unknowIfGuestInDream commented 2 months ago

加入垃圾回收器


public void initialize(IWorkbenchConfigurer configurer) {
    configurer.setSaveAndRestore(true);
    PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, true);
}
unknowIfGuestInDream commented 2 months ago

控制“最近打开文档”的个数

RCP中在继承ActionBarAdvisor的类中定义:
       private IContributionItem reOpenAction = ContributionItemFactory.REOPEN_EDITORS.create(window);
       然后在fillMenuBar(IMenuManager menuBar)方法中添加上面的aciton
       运行时“最近打开的文档”只有4个,如果想自己控制“最近打开的文档”的数量,则设置一下Workbench中的初始化首选项时RECENT_FILES的默认参数值如:
WorkbenchPlugin.getDefault().getPreferenceStore().setDefault(IPreferenceConstants.RECENT_FILES,10);