RCP中视图和视图之间如何共享信息?
1、在plugin.xml里面建多一个视图

2、新建AnotherView视图代码
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)

浙公网安备 33010602011771号