Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setLayout(new BorderLayout());
Panel p = new Panel(new BorderLayout());
Panel pLabel;
Panel pText;
Panel pButton;
Panel pClearButton;
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
pLabel = new Panel(new GridLayout(8, 1, 10, 10));
pText = new Panel(new GridLayout(8, 1, 10, 10));
pButton = new Panel(new GridLayout(1, 2, 10, 10));
pClearButton = new Panel(new GridLayout(8, 1, 10, 10));
} else {
pLabel = new Panel(new GridLayout(8, 1));
pText = new Panel(new GridLayout(8, 1));
pButton = new Panel(new GridLayout(1, 2));
pClearButton = new Panel(new GridLayout(8, 1));
}
p.add("West", pLabel);
p.add("Center", pText);
p.add("South", pButton);
p.add("North", createLabel(""));
p.add("East", pClearButton);
p.setBackground(SystemColor.control);
pText.setBackground(SystemColor.control);
pLabel.setBackground(SystemColor.control);
pButton.setBackground(SystemColor.control);
pLabel.add(createLabel("Recent:"));
recent = new Choice();
try {
settings = ConnectionDialogCommon.loadRecentConnectionSettings();
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
}
recent.add(ConnectionDialogCommon.emptySettingName);
Enumeration en = settings.elements();
while (en.hasMoreElements()) {
recent.add(((ConnectionSetting) en.nextElement()).getName());
}
recent.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String s = (String) e.getItem();
ConnectionSetting setting =
(ConnectionSetting) settings.get(s);
if (setting != null) {
mName.setText(setting.getName());
mDriver.setText(setting.getDriver());
mURL.setText(setting.getUrl());
mUser.setText(setting.getUser());
mPassword.setText(setting.getPassword());
}
}
});
pText.add(recent);
Button b;
b = new Button("Clr");
b.setActionCommand("Clear");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ConnectionDialogCommon.deleteRecentConnectionSettings();
settings = new Hashtable();
recent.removeAll();
recent.add(ConnectionDialogCommon.emptySettingName);
mName.setText(null);
}
});
pClearButton.add(b);
pLabel.add(createLabel("Setting Name:"));
mName = new TextField("");
pText.add(mName);
pLabel.add(createLabel("Type:"));
types = new Choice();
connTypes = ConnectionDialogCommon.getTypes();
for (int i = 0; i < connTypes.length; i++) {
types.add(connTypes[i][0]);
}
types.addItemListener(this);
pText.add(types);
pLabel.add(createLabel("Driver:"));
mDriver = new TextField(connTypes[0][1]);
pText.add(mDriver);
pLabel.add(createLabel("URL:"));
mURL = new TextField(connTypes[0][2]);
mURL.addActionListener(this);
pText.add(mURL);
pLabel.add(createLabel("User:"));
mUser = new TextField("SA");
mUser.addActionListener(this);
pText.add(mUser);
pLabel.add(createLabel("Password:"));
mPassword = new TextField("");
mPassword.addActionListener(this);
mPassword.setEchoChar('*');
pText.add(mPassword);
b = new Button("Ok");
b.setActionCommand("ConnectOk");
b.addActionListener(this);
pButton.add(b);
b = new Button("Cancel");
b.setActionCommand("ConnectCancel");
b.addActionListener(this);
pButton.add(b);
add("East", createLabel(""));
add("West", createLabel(""));
mError = new Label("");
Panel pMessage = createBorderPanel(mError);
add("South", pMessage);
add("North", createLabel(""));
add("Center", p);
doLayout();