Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » InputDialog Problem.!!!
InputDialog Problem.!!! [message #437705] Mon, 03 October 2005 09:40 Go to next message
Eclipse UserFriend
Originally posted by: gkurien.icope.com

How do i write a InputDialog which has more than one Text Box and labels
and when i click the Ok Button i need to get the values of all the three
text fields.....



i had tried overiding the methods of InputDialog , but as i click the Ok
Button the DialogBox get closed ..and i cant get the text from the text
box as the widget is already disposed ..
Re: InputDialog Problem.!!! [message #437707 is a reply to message #437705] Mon, 03 October 2005 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: morincer.gmail.com

03.10.2005 13:40:55
Genu George <gkurien@icope.com> wrote in message
<59bae14e62c7003b95239b4e7b2d7906$1@www.eclipse.org>

> How do i write a InputDialog which has more than one Text Box and
labels
> and when i click the Ok Button i need to get the values of all the
three
> text fields.....
>
>
>
> i had tried overiding the methods of InputDialog , but as i click
the Ok
> Button the DialogBox get closed ..and i cant get the text from the
text
> box as the widget is already disposed ..

As far as I know, the InputDialog is to be used when you need to fill
up exactly one value. Here is the class I wrote for me - it gets
Properties object on input. However, you may re-write it to get i.e.
Hashtable. And no validators now.
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class DynamicPropertyDialog extends Dialog {
private Properties properties;
private Hashtable controls;
public Properties getProperties() {
return properties;
}
public DynamicPropertyDialog(Shell parentShell, Properties props) {
super(parentShell);
this.properties = props;
this.controls = new Hashtable();
}
protected void okPressed() {
Enumeration keys = this.properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
Text text = (Text) controls.get(key);
this.properties.setProperty(key, text.getText());
}
super.okPressed();
}
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);

if (this.controls == null || this.controls.size() == 0)
return;

Text first = (Text) controls.values().toArray()[0];
first.selectAll();
}
protected Control createDialogArea(Composite parent) {
Composite contentsComposite = new Composite(parent, SWT.NONE);
contentsComposite.setLayout(new GridLayout(2, false));
GridData gridData = new GridData(GridData.FILL_HORIZONTAL,
GridData.FILL_VERTICAL, true, true);
gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.
MINIMUM_MESSAGE_AREA_WIDTH);
contentsComposite.setLayoutData(gridData);
Enumeration keys = this.properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = this.properties.getProperty(key);
Label lbl = new Label(contentsComposite, SWT.NONE);
lbl.setText(key);
Text text = new Text(contentsComposite, SWT.BORDER);
text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
text.setText(value);
this.controls.put(key, text);
}
return contentsComposite;
}
}
Re: InputDialog Problem.!!! [message #437709 is a reply to message #437705] Mon, 03 October 2005 13:48 Go to previous message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Genu George wrote:
> How do i write a InputDialog which has more than one Text Box and labels
> and when i click the Ok Button i need to get the values of all the three
> text fields.....
>
>
>
> i had tried overiding the methods of InputDialog , but as i click the Ok
> Button the DialogBox get closed ..and i cant get the text from the text
> box as the widget is already disposed ..
>

I have been using wizards because they sized better than dialogs..


CL
Previous Topic:Action does not work after deployment: "The chosen operation is not currently available"
Next Topic:How to make columns fill the table area.
Goto Forum:
  


Current Time: Sat Dec 14 10:22:59 GMT 2024

Powered by FUDForum. Page generated in 0.03190 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top