Sponsorzy ECESIS Eclipse Community Education Project An Eclipse

  • Slides: 15
Download presentation
Sponsorzy: ECESIS Eclipse Community Education Project An Eclipse Technology Research Subproject JFace Jak jeszcze

Sponsorzy: ECESIS Eclipse Community Education Project An Eclipse Technology Research Subproject JFace Jak jeszcze szybciej tworzyć interfejsy? Mirosław Ochodek Miroslaw. Ochodek@put. poznan. pl

Plan ▪ JFace and SWT ▪ Rejestry ▪ Dialogi ▪ Przeglądarki ▪ Akcje UCWorkbench

Plan ▪ JFace and SWT ▪ Rejestry ▪ Dialogi ▪ Przeglądarki ▪ Akcje UCWorkbench Team Eclipse Summer School (2)

JFace and SWT ▪ JFace jest nadbudówką dla SWT ▪ Dostarcza klasy wspierające ▪

JFace and SWT ▪ JFace jest nadbudówką dla SWT ▪ Dostarcza klasy wspierające ▪ Umożliwia łatwiejszą separację widoku od modelu JFace SWT JNI Windowing system Operating system UCWorkbench Team Eclipse Summer School (3)

Rejestry ▪ Klasy dla zarządzania zasobami (SWT) ▪ Font. Registry ▪ Image. Registry ▪

Rejestry ▪ Klasy dla zarządzania zasobami (SWT) ▪ Font. Registry ▪ Image. Registry ▪ JFace. Colors ▪ JFace. Resources UCWorkbench Team Eclipse Summer School (4)

Font. Registry font. Registry = JFace. Resources. get. Font. Registry() Font. Data main. Font

Font. Registry font. Registry = JFace. Resources. get. Font. Registry() Font. Data main. Font = new Font. Data("Arial", 18, SWT. NORMAL); font. Registry. put("main. Font", new Font. Data[]{main. Font}); Label label = new Label(parent, SWT. HORIZONTAL); label. set. Text("This is main font"); label. set. Font(font. Registry. get("main. Font")); UCWorkbench Team Eclipse Summer School (5)

Dialogi ▪ Tworzenie dialogów w SWT/JFace • SWT – tworzenie okien dialogowych krok po

Dialogi ▪ Tworzenie dialogów w SWT/JFace • SWT – tworzenie okien dialogowych krok po kroku (kontrolka za kontrolką. . . ) • JFace – szybkie i łatwe tworzenie dialogów ▪ Dialogi to najczęściej proste okna mające dużo wspólnych cech ▪ JFace dostarcza klasy z obszarami gotowymi do wypełniania UCWorkbench Team Eclipse Summer School (6)

Input. Dialog final Input. Dialog input. Dialog = new Input. Dialog(parent. get. Shell(), "Title",

Input. Dialog final Input. Dialog input. Dialog = new Input. Dialog(parent. get. Shell(), "Title", "Message!", "input text here", null); final Button button = new Button(parent, SWT. PUSH); button. add. Selection. Listener(new Selection. Adapter(){ public void widget. Selected(Selection. Event e) { super. widget. Selected(e); if (input. Dialog. open() == Dialog. OK) { button. set. Text(input. Dialog. get. Value()); } } }); UCWorkbench Team Eclipse Summer School (7)

Title. Area. Dialog ▪ Składa się z: • Title line • Message area (jak

Title. Area. Dialog ▪ Składa się z: • Title line • Message area (jak również error area, image) • OK and Cancel buttons ▪ Przed przypisaniem obrazków, tekstu wywołaj metodę create() UCWorkbench Team Eclipse Summer School (8)

Title. Area. Dialog final Title. Area. Dialog title. Area. Dialog = new Title. Area.

Title. Area. Dialog final Title. Area. Dialog title. Area. Dialog = new Title. Area. Dialog(parent. get. Shell()); title. Area. Dialog. create(); title. Area. Dialog. set. Title("Title"); title. Area. Dialog. set. Message("first linensecond line"); final Button button = new Button(parent, SWT. PUSH); button. add. Selection. Listener(new Selection. Adapter(){ public void widget. Selected(Selection. Event e) { super. widget. Selected(e); if (title. Area. Dialog. open() == Dialog. OK){ button. set. Text("OK was pressed!"); } } }); UCWorkbench Team Eclipse Summer School (9)

Twój własny Dialog ▪ Podklasuj jedną z klas JFace Dialogs (zwróć uwagę, że są

Twój własny Dialog ▪ Podklasuj jedną z klas JFace Dialogs (zwróć uwagę, że są także SWT Dialogs) ▪ Przeciąż jedną z metod: • create. Dialog. Area(Composite parent) • create. Button. Bar(Composite parent) • create. Buttons. For. Button. Bar(Composite parent) • create. Button(Composite parent, int id, String label, boolean default. Button) • set. Return. Code(int code) UCWorkbench Team Eclipse Summer School (10)

IAction ▪ W JFace niektóre widget’y mogą być budowane za pomocą akcji (eg. Manus)

IAction ▪ W JFace niektóre widget’y mogą być budowane za pomocą akcji (eg. Manus) ▪ IAction może mieć: • Unikalne ID set. Id() • Tekst wyświetlany w różnych miejscach (np. menu) set. Text() • Tooltip tekst – set. Tool. Tip. Text() • Ikony (set. Image. Descriptor(), set. Disable. Image. Descriptor()) • Akcje można aktywować i dezaktywować • Metoda run(), zawiera kod wykonywalny UCWorkbench Team Eclipse Summer School (11)

Viewers ▪ Jak zarządzać SWT Tree z klasami Person i House jako węzłami: •

Viewers ▪ Jak zarządzać SWT Tree z klasami Person i House jako węzłami: • Person — Name — Surname Czy mogę zamienić osoby z domami? Co jeśli będę chciał wyświetlać tylko imię? — PESEL — Houses • House — Address — Residents UCWorkbench Team Eclipse Summer School (12)

Viewers SWT Tree Content. Provider Label. Provider John Smith (20) UCWorkbench Team Eclipse Summer

Viewers SWT Tree Content. Provider Label. Provider John Smith (20) UCWorkbench Team Eclipse Summer School (13)

Viewers UCWorkbench Team Eclipse Summer School (14)

Viewers UCWorkbench Team Eclipse Summer School (14)

JFace – ale to nie koniec Dziękuje Wizards, Property pages, Text Viewers (editors) Zostaną

JFace – ale to nie koniec Dziękuje Wizards, Property pages, Text Viewers (editors) Zostaną zaprezentowane osobno UCWorkbench Team Eclipse Summer School (15)