Я создал мастера.
имеет 3
pages-
@Override
public void addPages() {
super.addPages();
addPage(firstPage);
addPage(secondPage);
addPage(thirdPage);
}
Для первой страницы у меня есть простое label
с полем input
для собрать введенное пользователем значение -
@Override
public void createControl(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
setControl(page);
setPageComplete(false);
// page.setLayout(new GridLayout(2, false));
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = false;
page.setLayout(gridLayout);
page.setLayoutData(new GridData(GridData.FILL_BOTH));
Label label = new Label(page, SWT.NONE);
label.setText("Interface Id : ");
interfaceId = new Text(page, SWT.BORDER);
GridData interfaceIdGridData = new GridData(GridData.FILL_HORIZONTAL);
interfaceId.setLayoutData(interfaceIdGridData);
}
Когда пользователь нажимает кнопку «Далее», показанную на приведенной выше странице мастера, происходит вызов некоторые детали из внешней системы в пределах getNextPage
той же страницы мастера.
Затем пользователь попадает на страницу мастера 2
, и сведения, которые были извлечены в step1
, отображаются здесь на странице мастера 2-
public class InterfaceDetailsPage extends WizardPage {
private Composite top;
private ScrolledComposite scrolledComposite;
private Composite page;
private Label responseCode;
private Label responseMsg;
private Label interfaceName;
private Label sourceSystem;
private Label targetSystem;
private Label domainName;
private Label serviceName;
private SelectedServerNode iServer;
private volatile boolean activityCancelled;
private CreateSkeletonResponseModel model;
private CreateSkeletonDisplayResultModel resultModel;
protected InterfaceDetailsPage(SelectedServerNode iServer) {
super("InterfaceDetailsPage");
this.iServer = iServer;
setTitle("Component Details");
setMessage("The requested Interface details are shown below : ");
}
@Override
public void createControl(Composite parent) {
top = new Composite(parent, SWT.NONE);
top.setLayout(new FillLayout());
setControl(top);
setPageComplete(false);
scrolledComposite = new ScrolledComposite(top, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
page = new Composite(scrolledComposite, SWT.NONE);
//setControl(page);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
//gridLayout.makeColumnsEqualWidth = true;
gridLayout.makeColumnsEqualWidth = false;
page.setLayout(gridLayout);
page.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
scrolledComposite.setContent(page);
scrolledComposite.setSize(page.computeSize(SWT.DEFAULT, SWT.DEFAULT));
GridData gridData = null;
// Deals with the label response code and its value
Label responseCodeLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//responseCodeLbl.setLayoutData(gridData);
responseCodeLbl.setText("Response Code : ");
responseCode = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
responseCode.setLayoutData(gridData);
// Deals with the label response message and its value
Label responseMsgLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//responseMsgLbl.setLayoutData(gridData);
responseMsgLbl.setText("Response Message : ");
responseMsg = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
responseMsg.setLayoutData(gridData);
}
@Override
public void setVisible(boolean visible) {
if (visible) {
InterfacePage interfacePage = (InterfacePage) (getWizard().getPage("InterfacePage"));
ModelObject model = interfacePage.getModelObject();
GridData gridData = null;
// Deals with the label interface name and its value
Label interfaceNameLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//interfaceNameLbl.setLayoutData(gridData);
interfaceNameLbl.setText("Interface Id : ");
interfaceName = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
interfaceName.setLayoutData(gridData);
// Deals with the label source system and its value
Label sourceSystemLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//sourceSystemLbl.setLayoutData(gridData);
sourceSystemLbl.setText("Source System : ");
sourceSystem = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
sourceSystem.setLayoutData(gridData);
// Deals with the label target system and its value
Label targetSystemLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//targetSystemLbl.setLayoutData(gridData);
targetSystemLbl.setText("Target System : ");
targetSystem = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
targetSystem.setLayoutData(gridData);
// Deals with the label domain name and its value
Label domainNameLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//domainNameLbl.setLayoutData(gridData);
domainNameLbl.setText("Domain Name : ");
domainName = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
domainName.setLayoutData(gridData);
// Deals with the label service name and its value
Label serviceNameLbl = new Label(page, SWT.NONE);
//gridData = new GridData(GridData.FILL_HORIZONTAL);
//serviceNameLbl.setLayoutData(gridData);
serviceNameLbl.setText("Service Name : ");
serviceName = new Label(page, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
serviceName.setLayoutData(gridData);
interfaceName.setText(null != model.getInterfaceName() ? model.getInterfaceName() : "");
// setTitle(model.getInterfaceID1() +" details");
sourceSystem.setText(null != model.getSourceSystem() ? model.getSourceSystem() : "");
targetSystem.setText(null != model.getTargetSystem() ? model.getTargetSystem() : "");
domainName.setText(null != model.getDomainName() ? model.getDomainName() : "");
serviceName.setText(null != model.getServiceName() ? model.getServiceName() : "");
responseCode.setText(String.valueOf(model.getResponseCode()));
responseMsg.setText(null != model.getResponseMessage() ? model.getResponseMessage() : "");
page.layout();
scrolledComposite.layout(true, true);
scrolledComposite.setMinSize(page.computeSize(SWT.DEFAULT, SWT.DEFAULT));
top.layout();
setPageComplete(true);
}
super.setVisible(visible);
} ...
Как видно, последние 5 отображаемых меток были сгенерированы в методе setVisible
. нажимая кнопку Back
и затем нажимая Next
, я вижу, что новые метки добавляются под предыдущими строками и, таким образом, отображаются дважды. Как я могу предотвратить это поведение?