Home » Eclipse Projects » Rich Client Platform (RCP) » Cannot get the updated content of Text.getText() value
Cannot get the updated content of Text.getText() value [message #525002] |
Mon, 05 April 2010 09:16 |
czetsuya Messages: 9 Registered: March 2010 Location: Philippines |
Junior Member |
|
|
Hi,
I have 3 classes, controller (wizarddialog), wizard and composite
In the composite class I have defined a Text control, I added this composite in the wizard. And I want to get the Text's value in the wizard dialog. Unfortunately, I'm always getting the default value I assigned to textbox.
It's like:
Composite.add(textbox)
Wizard.add(Composite)
WizardDialog.get(Wizard).get(Composite).get(Text).getText
//Controller
@Override
protected void nextPressed() {
String currentPageTitle = getCurrentPage().getName();
boolean isContinueNextPage = true;
if(currentPageTitle.equals("page_1")) {
DatabaseSelectPage currentWizardPage = (DatabaseSelectPage)getCurrentPage();
//always returns the default value - xxxxx; even though I've already changed it
System.out.println(currentWizardPage.getContainerPart().getLocalConnectionString().toString());
String err = "";
if(err == "") {
System.out.println("here");
} else { //invalid connection string
System.out.println("there");
isContinueNextPage = false;
currentWizardPage.setErrorMessage(err);
}
}
if(isContinueNextPage) {
super.nextPressed();
}
}
//wizardpage
public class DatabaseSelectPage extends WizardPage {
public DatabaseSelect container;
public DatabaseSelectPage() {
super("page_1"); //$NON-NLS-1$
}
@Override
public void createControl(Composite parent) {
container = new DatabaseSelect(this, parent, SWT.NONE);
setControl(container);
setPageComplete(false);
}
public DatabaseSelect getContainerPart() {
return container;
}
}
//composite
public class DatabaseSelect extends Composite {
public Text textLocalOdbc;
private Text textUsername;
private Text textPassword;
private WizardPage wpage;
public DatabaseSelect(WizardPage wpage, Composite parent, int style) {
super(parent, style);
this.wpage = wpage;
this.setLayout(new FormLayout());
Group grpLocalOdbc = new Group(this, SWT.NONE);
grpLocalOdbc.setText(Messages.DatabaseSelect_0);
FormData formData = new FormData();
formData.top = new FormAttachment(0, 10);
formData.left = new FormAttachment(0, 10);
formData.right = new FormAttachment(50, -5);
formData.bottom = new FormAttachment(100, -10);
grpLocalOdbc.setLayoutData(formData);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.marginHeight = 10;
grpLocalOdbc.setLayout(gridLayout);
Label lblOdbcString = new Label(grpLocalOdbc, SWT.NONE);
lblOdbcString.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblOdbcString.setText(Messages.DatabaseSelect_1);
textLocalOdbc = new Text(grpLocalOdbc, SWT.BORDER);
textLocalOdbc.setText("xxxxx"); //default value here: xxxxx
textLocalOdbc.setToolTipText(Messages.DatabaseSelect_2);
textLocalOdbc.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
handleEvents();
}
private void handleEvents() {
textLocalOdbc.addKeyListener(new KeyAdapter() { //$NON-NLS-1$
@Override
//in this part the code can detect that the value of textLocalOdbc is updating
public void keyReleased(KeyEvent e) {
if( !getLocalConnectionString().getDns().isEmpty() &&
!getCentralConnectionString().getDns().isEmpty()) {
wpage.setPageComplete(true);
} else {
wpage.setPageComplete(false);
}
}
});
textCentralOdbc.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if( !getLocalConnectionString().getDns().isEmpty() &&
!getCentralConnectionString().getDns().isEmpty()) {
wpage.setPageComplete(true);
} else {
wpage.setPageComplete(false);
}
}
});
}
public ConnectionString getLocalConnectionString() {
System.out.println("apple: " + textLocalOdbc.getText());
ConnectionString cs = new ConnectionString();
cs.setDns(textLocalOdbc.getText().trim());
cs.setUsername(textUsername.getText().trim());
cs.setPassword(textPassword.getText().trim());
return cs;
}
}
Thanks,
czetsuya
http://czetsuya-tech.blogspot.com
[Updated on: Mon, 05 April 2010 09:33] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 15:24:14 GMT 2024
Powered by FUDForum. Page generated in 0.02764 seconds
|