0% found this document useful (0 votes)
43 views

Sanjay Shah Santosh Shah

This document discusses dialogs and wizards in SWT. It provides examples of different types of dialogs like message boxes, input dialogs, and file dialogs. It also explains why wizards are commonly used in Eclipse and provides an example class structure for a wizard with multiple pages.

Uploaded by

parveenkarthi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Sanjay Shah Santosh Shah

This document discusses dialogs and wizards in SWT. It provides examples of different types of dialogs like message boxes, input dialogs, and file dialogs. It also explains why wizards are commonly used in Eclipse and provides an example class structure for a wizard with multiple pages.

Uploaded by

parveenkarthi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1

Sanjay Shah
Santosh Shah

SWT Dialogs
Why Wizards?
Adding Wizards to Application
Creating WizardPages
Adding pages and calling the wizard
Adding Popup menu contribution
Wrap up
2




Why Dialogs?
3
ColorDialogDialog for selecting a color
DirectoryDialogDialog for selecting a
directory in host file system.
FileDialogDialog for selecting a file in host
file system. Supported styles are SWT.OPEN
and SWT.SAVE
FontDialogDialog for selecting text font
MessageBoxDialog for displaying a message.
PrintDialogDialog for selecting printer and
for printer settings
4
Message box
MessageBox box = new
MessageBox(view.getSite().getShell(),SWT.ICON_INFORMATIO
N);
box.setMessage("Hello! You clicked view action!");
box.open()
5
IconAndMessageDialogsuperclass of dialogs
with an icon and a message.
StatusDialogsuperclass for dialogs with
status bar
TitleAreaDialogdialog having a title area.
ErrorDialogA dialog to display errors
MessageDialogdialog class for showing
messages to the user.
ProgressMonitorDialogA modal dialog to
display progress of a operation.
6
WizardDialogA dialog to show a wizard to
the end user.
InputDialogA simple input dialog for getting
an input from the user.
7
InputDialog dialog = new InputDialog(view.getSite().getShell(),"Lets
try!", "Please enter your name","",null); // new input dialog
if( dialog.open()== IStatus.OK){ // open dialog and wait for return
status code. // If user clicks ok display message box
String value = dialog.getValue(); // fetch the value entered by the
user. MessageBox box = new
MessageBox(view.getSite().getShell(),SWT.ICON_INFORMATIO
N);
box.setMessage("Hey there! You entered : " + value); box.open(); }else{
MessageBox box = new
MessageBox(view.getSite().getShell(),SWT.ICON_INFORMATIO
N); box.setMessage("Bye!"); box.open(); }
8


Why Wizards?
9
Most common pattern across Eclipse
Examples :New Project ,Import Project etc.
Interfaces:org.eclipse.jface.wizard.IWizard and
org.eclipse.jface.wizard.IWizardPage
10
public class PersonalInformationPage extends
WizardPage {
public void createControl(Composite parent) {
}
}
11
public class CaptureEmployeeInfomrationWizard
extends Wizard {
public boolean performFinish() { return false;
}

12
//Override the addpages() method in main
Wizard Class.
public void addPages() {
}

13
//Adding Help information
helpAction =
ActionFactory.HELP_CONTENTS.create(wind
ow); register(helpAction);
14

You might also like