Add WindowBuilder TabItem at Runtime [message #781142] |
Fri, 20 January 2012 17:08  |
Eclipse User |
|
|
|
Excuse my explanation, I am new to Java / SWT. I am attempting to convert a legacy application from Qt.
My application has a number of consists of many 'pages'. Each 'page' holds a variety of controls (tables, buttons, checkboxes etc.).
At startup only a welcome page is shown as TabItem1 of a TabFolder, but by clicking on a list at the left of the screen new pages (TabItems) are added.
To help me organise my code, I would like each page (TabItem) to live in its own pair of files - one is created by WindowBuilder, the other contains the business logic for that page.
I am stuck with two problems:
- How can I separate the WindowBuilder generated code from the business logic? In WindowBuilder when I link an event it just dumps the code in the same class as the code that sets up all the widgets.
- How can I create just a TabItem in WindowBuilder and add it to the TabFolder (and raise it and remove it) from the TabFolder at runtime?
Thanks for any help!
[Updated on: Fri, 20 January 2012 17:09] by Moderator Report message to a moderator
|
|
|
Re: Add WindowBuilder TabItem at Runtime [message #781638 is a reply to message #781142] |
Sat, 21 January 2012 22:10   |
Eclipse User |
|
|
|
Mark Rowe wrote on Fri, 20 January 2012 12:08How can I separate the WindowBuilder generated code from the business logic? In WindowBuilder when I link an event it just dumps the code in the same class as the code that sets up all the widgets.
WindowBuilder does not create your business logic, so you can put that in any class that you want. WindowBuilder only creates the empty event handler for you. What code you call in the event handler or where you put that code is entirely up to you.
Mark Rowe wrote on Fri, 20 January 2012 12:08How can I create just a TabItem in WindowBuilder and add it to the TabFolder (and raise it and remove it) from the TabFolder at runtime?
I would create each tab as a separate Composite subclass. Each composite instance forms the control managed by the tab item. Tab items are then added and removed dynamically at runtime.
|
|
|
Re: Add WindowBuilder TabItem at Runtime [message #781995 is a reply to message #781638] |
Sun, 22 January 2012 23:29  |
Eclipse User |
|
|
|
Thank you for your answers.
Quote:WindowBuilder only creates the empty event handler for you. What code you call in the event handler or where you put that code is entirely up to you.
Okay, this is quite clear. I will just place a single call to the "business logic" class method in each event handler. I was thinking that it might be possible (in WindowBuilder) to bind an event to a method in another class without editing the autogenerated code, but its not a problem.
Quote:Tab items are then added and removed dynamically at runtime.
This I can understand by creating a new TabItem and parenting it to the TabFolder.
Quote:Each composite instance forms the control managed by the tab item
Thanks for the hint. For anyone who hits upon this thread during a search, I think that what Eric is referring to is "17. 72. 3. Pass the Composite to the tab's setControl() method" (sorry can't add the link as I didn't post enough times yet!)
|
|
|
Powered by
FUDForum. Page generated in 0.02736 seconds