创建RCP Viewer

1. 控制窗口ApplicationWorkbenchWindowAdvisor

public void preWindowOpen() {

       IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

       //窗口大小,它会自动记录上次关闭时的大小,下次打开时按保存的大小

       configurer.setInitialSize(newPoint(400, 300));

       configurer.setShowCoolBar(false);

       configurer.setShowStatusLine(true);//状态栏

       configurer.setTitle("Hello RCPViewer"); //窗口标题

}

CoolBar是一大块区域,包含一个个的toolBar,toolBar里是一个个的小工具按钮。

2. 创建View类

public class MyLabelView extends ViewPart {

   public staticfinal String ID="com.gathershell.view.MyLabelView";

   private Label label;

   public MyLabelView() {

      // TODO Auto-generated constructor stub

   }

 

   @Override

   public voidcreatePartControl(Composite parent) {

      label=newLabel(parent,SWT.VERTICAL);

      label.setText("HelloView!");

 

   }

 

   @Override

   public voidsetFocus() {

      // TODO Auto-generated method stub

 

   }

 

}

ID是一个惟一标识,一般用全路径类名。

3. 在plugin.xml中配置

<extension

         point="org.eclipse.ui.views">

      <view

            name="Label View"

            allowMultiple="true"

            icon="icons/sample2.gif"

            class="com.gathershell.view.MyLabelView"

            id="com.gathershell.view.MyLabelView">

      </view>

   </extension>

4. 控件布局

public class Perspective implements IPerspectiveFactory {

 

   public voidcreateInitialLayout(IPageLayout layout) {

      StringeditorArea = layout.getEditorArea();

      layout.setEditorAreaVisible(false);

     

      layout.addStandaloneView(MyLabelView.IDfalse, IPageLayout.LEFT,0.25f, editorArea);

   }

}

然后运行即可。有时作了修改,却看不到变化。这可能是由于某种原因,没有将修改同步过去。这时到与工作空间同级的目录下,删除runtime-RCPViewLearn.application这个文件件即可。RCPViewLearn这个是我所创建的project名字。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值