RCP中视图和视图之间如何共享信息?

1、在plugin.xml里面建多一个视图

2、新建AnotherView视图代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package myviewrcp2;
 
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
 
public class AnotherView extends ViewPart{
 
    private Text text;//文本框
    public static final String ID = "myviewrcp2.AnotherView";
     
    public AnotherView() {
        super();
    }
    @Override
    public void createPartControl(Composite parent) {
        // TODO Auto-generated method stub
        text = new Text(parent,SWT.NONE);
    }
 
    @Override
    public void setFocus() {
        // TODO Auto-generated method stub
        this.setFocus();
    }
     
    //设置文本框的内容
    public void setContent(String content) {
        text.setText(content);
    }
 
}

3、旧视图加一个选择事件

  

4、在透视图中加上新视图(发现,如把1f改成0.x,该透视图,就会出现3个视图,要改成1f出现的才是1个视图)

5、效果如下:

 

项目代码:RCP/MyViewRCP2.zip at main · guozhizhongqi/RCP (github.com)

 

posted @   信铁寒胜  阅读(44)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示