RCP之病人信息系统开发总结(4):MVC模式之View层—透视图

本文介绍了一个基于Eclipse平台的透视图布局实现方法,通过IPerspectiveFactory接口的createInitialLayout方法来定义初始页面布局和可见操作集。文章详细展示了如何使用IFolderLayout创建文件夹并组织视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Perspective 类源代码
通过方法createInitialLayout设置透视图的布局
 
package com.yinger.patientims; 

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

import com.yinger.patientims.util.PluginUtil;

/**
 * A perspective factory generates the initial page layout and visible action set for a page. 
 * 透视图类要实现 IPerspectiveFactory 接口
 * createInitialLayout方法可以对透视图进行布局
 */

public class Perspective implements IPerspectiveFactory {

   //这个方法用来初始化透视图的布局,可以在这里对项目中的视图进行注册
   public void createInitialLayout(IPageLayout layout) {
     //得到编辑区域id
    String editorArea = layout.getEditorArea(); //Returns the special identifier for the editor area in this page layout

     //添加导航视图
     //String viewId, int relationship, float ratio, String refId
    layout.addView(PluginUtil.NavigatorView_ID, IPageLayout.LEFT, 0. 3f, editorArea);

     //添加搜索视图,添加到导航视图的下方
     //An IFolderLayout is used to define the initial views within a folder. The folder itself is contained within an IPageLayout. 
     //IFolderLayout用来给已有的View添加一个folder(文件夹功能),这个folder本身就包含有IPageLayout
    IFolderLayout leftbottom = layout.createFolder( "left", IPageLayout.BOTTOM, 0. 4f, PluginUtil.NavigatorView_ID);
    leftbottom.addView(PluginUtil.SearchView_ID);

     //添加病人信息和费用信息的视图,并实现两个视图叠加的效果
    IFolderLayout rightbottom = layout.createFolder( "rightbottom", IPageLayout.BOTTOM, 0. 7f, editorArea);
    rightbottom.addView(PluginUtil.PatientInfoView_ID);
    rightbottom.addView(PluginUtil.ExpenseInfoView_ID);

  }
}
 
2.总结
(1)对于各个组件的id还是不要放在PluginUtil中进行统一管理比较好,可以放在各个对应的组件实现类中,添加一个static final的String
(2)对于透视图的布局,一般采用左侧导航栏,右侧是编辑器的模式,默认的时候编辑器应该是空的





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值