在JFace向导页面之间传递数据 [英] Passing data between JFace wizard pages

查看:112
本文介绍了在JFace向导页面之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在公司开发新项目类型插件。我所面临的问题是,我想将在其中一个向导页面上选择的数据传递到下一个向导页面。考虑有两个向导 wizard1 wizard2 。在 wizard1 中有几个复选框,我需要将这些值传递给 wizard2 。我如何才能实现这一点?



我搜索了很多,发现了这两个问题这个这个。 a>但在这两个链接中,它们最初创建数据,然后将其传递给构造函数中的所有其他向导。但是我的情况是,用户在 wizard1 中选择了几个复选框,我需要 wizard2 中的这些值。任何人都可以指导我如何实现这一点?任何指针都将不胜感激。



注意:我是Eclipse插件开发中的初学者,而不是要求完整的代码,而是一个想法有没有内置的方法来传递页面之间的值等等)



我正在创建这样的向导:

  public void addPages(){
addPage(new Wizard1(Wizard1)); //用户选中复选框
addPage(new Wizard2(Wizard2)); //我需要访问这个向导中的这些值
}


解决方案

您需要在共享对象中捕获向导页面数据。

 示例代码:

new WizardPage1(sharedObject)

new WizardPage2 (sharedObject)

WizardPage1:

checkBtn.addListener(SWT.Selection,new Listener(){

public void handleEvent(Event e){

sharedObject.setCheck(true);

}

});


I am developing a "New Project type" plugin in our company. The problem I am facing is, I want to pass data selected on one of the wizard page to next wizard page. Consider there are two wizards wizard1 and wizard2. In wizard1 there are few checkboxes, and I need to pass these values to wizard2. How can I achieve this?

I searched a lot and found these two questions this and this. But in those two links, they are creating data initially and then passing it to all of other wizards in constructor. But my situation is, user selects few checkboxes in wizard1 and I need those values in wizard2. Can anyone guide me how can I achieve this? Any pointers would be appreciated.

Note: I am very beginner in Eclipse Plugin Development, and not asking complete code, but an idea (like is there any built in method to pass values between pages etc etc)

I am creating Wizards like this:

public void addPages() {
   addPage(new Wizard1("Wizard1")); //User selects checkbox here
   addPage(new Wizard2("Wizard2")); //I need to access those values in this wizard
}

解决方案

You need to capture wizard page data in a shared Object.

example code:

new WizardPage1(sharedObject)

new WizardPage2(sharedObject)

WizardPage1:

checkBtn.addListener(SWT.Selection, new Listener(){

public void handleEvent(Event e){

   sharedObject.setCheck(true);

}

});

这篇关于在JFace向导页面之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆