/* Open the appropriate dialog type */
String name = dialogCombo.getText();
if (name.equals(ControlExample.getResourceString("ColorDialog"))) {
ColorDialog dialog = new ColorDialog(shell, style);
dialog.setRGB(new RGB(100, 100, 100));
dialog.setText(ControlExample.getResourceString("Title"));
RGB result = dialog.open();
textWidget.append(ControlExample.getResourceString("ColorDialog") + Text.DELIMITER);
textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
+ Text.DELIMITER);
return;
}
if (name.equals(ControlExample.getResourceString("DirectoryDialog"))) {
DirectoryDialog dialog = new DirectoryDialog(shell, style);
dialog.setMessage(ControlExample.getResourceString("Example_string"));
dialog.setText(ControlExample.getResourceString("Title"));
String result = dialog.open();
textWidget.append(ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER);
textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
+ Text.DELIMITER);
return;
}
if (name.equals(ControlExample.getResourceString("FileDialog"))) {
FileDialog dialog = new FileDialog(shell, style);
dialog.setFileName(ControlExample.getResourceString("readme_txt"));
dialog.setFilterNames(DialogTab.FilterNames);
dialog.setFilterExtensions(DialogTab.FilterExtensions);
dialog.setText(ControlExample.getResourceString("Title"));
String result = dialog.open();
textWidget.append(ControlExample.getResourceString("FileDialog") + Text.DELIMITER);
textWidget
.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER);
if ((dialog.getStyle() & SWT.MULTI) != 0) {
String[] files = dialog.getFileNames();
for (int i = 0; i < files.length; i++)
textWidget.append("\t" + files[i] + Text.DELIMITER);
}
textWidget.append(Text.DELIMITER);
return;
}
if (name.equals(ControlExample.getResourceString("FontDialog"))) {
FontDialog dialog = new FontDialog(shell, style);
dialog.setText(ControlExample.getResourceString("Title"));
FontData result = dialog.open();
textWidget.append(ControlExample.getResourceString("FontDialog") + Text.DELIMITER);
textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
+ Text.DELIMITER);
return;
}
if (name.equals(ControlExample.getResourceString("PrintDialog"))) {
PrintDialog dialog = new PrintDialog(shell, style);
dialog.setText(ControlExample.getResourceString("Title"));
PrinterData result = dialog.open();
textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER);
textWidget.append(ControlExample.getResourceString("Result", new String[] { "" + result }) + Text.DELIMITER
+ Text.DELIMITER);
return;
}
if (name.equals(ControlExample.getResourceString("MessageBox"))) {
MessageBox dialog = new MessageBox(shell, style);
dialog.setMessage(ControlExample.getResourceString("Example_string"));
dialog.setText(ControlExample.getResourceString("Title"));
int result = dialog.open();
textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER);
/*
* The resulting integer depends on the original dialog style. Decode the result and display it.
*/
switch (result) {