Eclipse Plugin Development SWTJFace Development Part 5 Dialogs























- Slides: 23
Eclipse Plug-in Development SWT/JFace Development Part 5 Dialogs, Wizards and Actions 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
Contents § Dialogs in SWT/JFace v SWT Dialogs v JFace Dialogs § Wizards v. Wizard Page § Action v. Actions v. Contribution Item q. Menu Manager q. Tool. Bar contribution item 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § Color. Dialog dialog = new Color. Dialog(shell); dialog. set. RGB(new RGB(0, 125, 0)); RGB result = dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § Directory. Dialog dialog = new Directory. Dialog(shell); dialog. set. Text("Foxes vs. Dogs"); dialog. set. Message("A qiuick brown fox jumps over the laze dog. " ); dialog. set. Filter. Path("C: "); String open = dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § File. Dialog v Open File. Dialog open. Dialog = new File. Dialog(shell, SWT. OPEN | SWT. MULTI); open. Dialog. set. Text("Open File Dialog"); open. Dialog. set. Filter. Extensions(new String[] { "*. jpg; *. png; *. gif", "*. *" }); open. Dialog. set. Filter. Path("C: "); String open = open. Dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § File. Dialog v Save File. Dialog save. Dialog = new File. Dialog(shell, SWT. SAVE); save. Dialog. set. Text("Save File Dialog"); save. Dialog. set. Filter. Extensions(new String[] { "*. txt" }); save. Dialog. set. File. Name("new_file"); save. Dialog. set. Filter. Path("C: "); save. Dialog. set. Overwrite(true); save. Dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § Font. Dialog dialog = new Font. Dialog(shell); dialog. set. Effects. Visible(true); Font. Data open = dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § Print. Dialog dialog = new Print. Dialog(shell); dialog. set. Start. Page(1); dialog. set. End. Page(3); dialog. set. Print. To. File(true); dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
SWT Dialogs § Message. Box v ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING v OK, OK | CANCEL v YES | NO, YES | NO | CANCEL v RETRY | CANCEL v ABORT | RETRY | IGNORE Message. Box box = new Message. Box(shell, SWT. RETRY | SWT. IGNORE | SWT. ABORT | SWT. ICON_QUESTION); box. set. Text("Foxes vs. Dogs"); box. set. Message("A quick brown fox jumps over the lazy dog? " ); int result = box. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Input. Dialog input. Dialog = new Input. Dialog(shell, "Input Dialog Tutorial", "Input value", "Hello World", null); input. Dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Message Dialog v Message. Dialog. open. Confirm(shell, "Confirm", "Please confirm"); v Message. Dialog. open. Error(shell, "Error", "Error occured"); v Message. Dialog. open. Information(shell, "Info", "Info for you"); v Message. Dialog. open. Question(shell, "Question", "Really, really? "); v Message. Dialog. open. Warning(shell, "Warning", "I am warning you!"); Message. Dialog dialog = new Message. Dialog(shell, "My Title", null, "My message", Message. Dialog. ERROR, new String[] { "First", "Second", "Third" }, 0); int result = dialog. open(); System. out. println(result); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Error. Dialog v Error. Dialog. open. Error(shell, “title”, “message”, IStatus ); v Error. Dialog. open. Error(shell, “title”, “message”, IStatus, display. Mask); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Extending Dialog public class Dialog 1 extends Dialog {…} protected Control create. Dialog. Area(Composite parent) { return super. create. Dialog. Area(parent); } protected void configure. Shell(Shell new. Shell) { super. configure. Shell(new. Shell); } protected Point get. Initial. Size() { return super. get. Initial. Size(); } 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Title. Area. Dialog dialog = new Title. Area. Dialog(shell) { protected void configure. Shell(Shell new. Shell) { super. configure. Shell(new. Shell); new. Shell. set. Text("Title. Area. Dialog Tutorial"); } protected Control create. Dialog. Area(Composite parent) { Composite dialog. Area = (Composite) super. create. Dialog. Area(parent); // add your contents here set. Title("Add yout TITLE here"); set. Message("Add your MESSAGE here"); return dialog. Area; } }; dialog. open(); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs Wizard. Dialog dialog = new Wizard. Dialog(shell, new My. Wizard()); dialog. open(); § Wizard. Dialog v Wizard Page public class My. Wizard extends Wizard { public My. Wizard() { set. Window. Title("Wizard Dialog Tutorial"); } public void add. Pages() { add. Page(new Wizard. Page 1()); } public boolean perform. Finish() { return false; } } public class Wizard. Page 1 extends Wizard. Page { protected Wizard. Page 1() { super("Wizard. Page 1"); } public void create. Control(Composite parent) { Label control = new Label(parent, SWT. NONE); control. set. Text("Page 1"); set. Control(control); set. Title("Page 1 Title"); set. Message("Page 1 Message"); } } 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Dialogs § Wizard. Dialog v Wizard Page 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Actions § Contribution Manager 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Actions § Contribution Item 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Actions § IAction v Styles: q AS_UNSPECIFIED q AS_PUSH_BUTTON q AS_CHECK_BOX q AS_DROP_DOWN_MENU q AS_RADIO_BUTTON v text v image. Descriptor v tool. Tip. Text v run() 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
JFace Actions § Example Menu. Manager manager = new Menu. Manager(); manager. add(new Action("Push", IAction. AS_PUSH_BUTTON) { }); manager. add(new Separator()); manager. add(new Action("Check. Box 1", IAction. AS_CHECK_BOX) { }); manager. add(new Action("Check. Box 2", IAction. AS_CHECK_BOX) { }); Menu menu = manager. create. Context. Menu(shell); shell. set. Menu(menu); 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
Any Questions? Skype: jin. liu. soyatec Email: jin. liu@soyatec. com 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec
The end 10/28/2020 Soyatec (http: //www. soyatec. com) Jin Liu (jin. liu@soyatec. com) Skype: jin. liu. soyatec