嘟嘟

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  26 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

1:建立一个视图类需要扩展org.eclipse.ui.part.ViewPart
      public class FirstView extends ViewPart {
      }

2:在视图中添加控件
   主要在方法中createPartControl加入控件,(建议使用designer工具)
      public class FirstView extends ViewPart {
 

       private Text text;
       public static final String ID = "rcpdemo.views.FirstView"; //$NON-NLS-1$

       /**
        * Create contents of the view part
        * @param parent
        */
       public void createPartControl(Composite parent) {
        Composite container = new Composite(parent, SWT.NONE);

        final Label label = new Label(container, SWT.NONE);
        label.setAlignment(SWT.CENTER);
        label.setText("姓名:");
        label.setBounds(84, 65, 58, 24);

        text = new Text(container, SWT.BORDER);
        text.setBounds(144, 62, 80, 25);

        //
        createActions();
        initializeToolBar();
        initializeMenu();
        }


3:配置plugin.xml文件
    <extension
         id="rcpdemo.views.FirstView"
         name="first view"
         point="org.eclipse.ui.views">
      <view
            class="rcpdemo.views.FirstView"
            id="rcpdemo.views.FirstView"
            name="New ViewPart"/>
    </extension>

4:修改透视图的代码
   public class Perspective implements IPerspectiveFactory {

    public void createInitialLayout(IPageLayout layout) {
     //显示视图
     String editorArea = layout.getEditorArea();
     layout.addView("rcpdemo.views.FirstView", IPageLayout.RIGHT, 0.2f, editorArea);
    }
   }
createInitialLayou中,我们可以通过以下几个方法向透视图中添加视图、编辑器和菜单:
addView   ——
添加视图
addActionSet ——
添加菜单和工具栏
createFolder ——
创建一个IForderLayou,可以让多个视图重叠在同一个位置

posted on 2007-06-13 19:52 fyp1210 阅读(831) 评论(0)  编辑  收藏 所属分类: RCP&SWT&JFACE

只有注册用户登录后才能发表评论。


网站导航: