Eclipse Plug-in Development SWT/JFace Development Part

23 Slides443.34 KB

Eclipse Plug-in Development SWT/JFace Development Part 5 Dialogs, Wizards and Actions 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

Contents Dialogs in SWT/JFace SWT Dialogs JFace Dialogs Wizards Wizard Page Action Actions Contribution Item Menu Manager ToolBar contribution item 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs ColorDialog ColorDialog dialog new ColorDialog(shell); dialog.setRGB(new RGB(0, 125, 0)); RGB result dialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs DirectoryDialog DirectoryDialog dialog new DirectoryDialog(shell); dialog.setText("Foxes vs. Dogs"); dialog.setMessage("A qiuick brown fox jumps over the laze dog."); dialog.setFilterPath("C:"); String open dialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs FileDialog Open FileDialog openDialog new FileDialog(shell, SWT.OPEN SWT.MULTI); openDialog.setText("Open File Dialog"); openDialog.setFilterExtensions(new String[] { "*.jpg;*.png;*.gif", "*.*" }); openDialog.setFilterPath("C:"); String open openDialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs FileDialog Save FileDialog saveDialog new FileDialog(shell, SWT.SAVE); saveDialog.setText("Save File Dialog"); saveDialog.setFilterExtensions(new String[] { "*.txt" }); saveDialog.setFileName("new file"); saveDialog.setFilterPath("C:"); saveDialog.setOverwrite(true); saveDialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs FontDialog FontDialog dialog new FontDialog(shell); dialog.setEffectsVisible(true); FontData open dialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs PrintDialog PrintDialog dialog new PrintDialog(shell); dialog.setStartPage(1); dialog.setEndPage(3); dialog.setPrintToFile(true); dialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

SWT Dialogs MessageBox ICON ERROR, ICON INFORMATION, ICON QUESTION, ICON WARNING, ICON WORKING OK, OK CANCEL YES NO, YES NO CANCEL RETRY CANCEL ABORT RETRY IGNORE MessageBox box new MessageBox(shell, SWT.RETRY SWT.IGNORE SWT.ABORT SWT.ICON QUESTION); box.setText("Foxes vs. Dogs"); box.setMessage("A quick brown fox jumps over the lazy dog?"); int result box.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs InputDialog InputDialog inputDialog new InputDialog(shell, "Input Dialog Tutorial", "Input value", "Hello World", null); inputDialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs Message Dialog MessageDialog.openConfirm(shell, "Confirm", "Please confirm"); MessageDialog.openError(shell, "Error", "Error occured"); MessageDialog.openInformation(shell, "Info", "Info for you"); MessageDialog.openQuestion(shell, "Question", "Really, really?"); MessageDialog.openWarning(shell, "Warning", "I am warning you!"); MessageDialog dialog new MessageDialog(shell, "My Title", null, "My message", MessageDialog.ERROR, new String[] { "First", "Second", "Third" }, 0); int result dialog.open(); System.out.println(result); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs ErrorDialog ErrorDialog.openError(shell, “title”, “message”, IStatus ); ErrorDialog.openError(shell, “title”, “message”, IStatus, displayMask); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs Extending Dialog public class Dialog1 extends Dialog { } protected Control createDialogArea(Composite parent) { return super.createDialogArea(parent); } protected void configureShell(Shell newShell) { super.configureShell(newShell); } protected Point getInitialSize() { return super.getInitialSize(); } 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs TitleAreaDialog TitleAreaDialog dialog new TitleAreaDialog(shell) { protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("TitleAreaDialog Tutorial"); } protected Control createDialogArea(Composite parent) { Composite dialogArea (Composite) super .createDialogArea(parent); // add your contents here setTitle("Add yout TITLE here"); setMessage("Add your MESSAGE here"); return dialogArea; } }; dialog.open(); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs WizardDialog dialog new WizardDialog(shell, new MyWizard()); dialog.open(); WizardDialog Wizard Wizard Page public class MyWizard extends Wizard { public MyWizard() { setWindowTitle("Wizard Dialog Tutorial"); } public void addPages() { addPage(new WizardPage1()); } public boolean performFinish() { return false; } } public class WizardPage1 extends WizardPage { protected WizardPage1() { super("WizardPage1"); } public void createControl(Composite parent) { Label control new Label(parent, SWT.NONE); control.setText("Page1"); setControl(control); setTitle("Page1 Title"); setMessage("Page1 Message"); } } 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Dialogs WizardDialog Wizard Wizard Page 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Actions Contribution Manager 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Actions Contribution Item 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Actions IAction Styles: AS UNSPECIFIED AS PUSH BUTTON AS CHECK BOX AS DROP DOWN MENU AS RADIO BUTTON text imageDescriptor toolTipText run() 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

JFace Actions Example MenuManager manager new MenuManager(); manager.add(new Action("Push", IAction.AS PUSH BUTTON) { }); manager.add(new Separator()); manager.add(new Action("CheckBox1", IAction.AS CHECK BOX) { }); manager.add(new Action("CheckBox2", IAction.AS CHECK BOX) { }); Menu menu manager.createContextMenu(shell); shell.setMenu(menu); 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

Any Questions? Skype: jin.liu.soyatec Email: [email protected] 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

The end 02/17/2024 Soyatec (http://www.soyatec.com) Jin Liu ([email protected]) Skype: jin.liu.soyatec

Back to top button