SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.
Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg
by illvoid » Sun Sep 05, 2010 12:44 pm
Hello!
I have a class named MyGridRow, a row that I can add to my owner-drawn grid. In Code I create the row like that:
MyGridRow row = new MyGridRow (myGrid);
In the componenttree the row is displayed as child of the myGrid-instance. I have logging code in the constructor of MyGridRow and I can see that when I open the designer, the constructor is called twice, which is a problem for me because the collection of cells is created in the constructor.
After the code above I create a cell:
MyCell cell = new MyCell(row);
The construction f the objects when opening the designer is like that:
1. MyGridRow is created
2. MyCell is created
3. MyGridRow is created again
What can I do to avoid this?
Thanks and kind regards
Matthias
-
illvoid
-
- Posts: 11
- Joined: Fri Sep 03, 2010 5:05 pm
by Eric Clayberg » Mon Sep 06, 2010 5:43 pm
The widget tree is created and destroyed during initial parsing and then again any time the design view refreshes.
This is expected behavior and can't be changed. It works this way for all components, so it should not make any difference.
-
Eric Clayberg
- Moderator
-
- Posts: 4503
- Joined: Tue Sep 30, 2003 6:39 am
- Location: Boston, MA USA
-
by illvoid » Wed Sep 08, 2010 1:41 am
Hi Eric,
but the lifecacle is definetly wrong. The code is like that:
1. Create MyGridRow with new
2. reate MyGridCell with new MyGridCell(row). In this code the cell is added to the collection of cells for the row.
AFTER that code the constructor for the row I already added and I already added the cell for is called again and of cource the collection of cells if initialized again and is empty in constructor.
Bye
Matthias
-
illvoid
-
- Posts: 11
- Joined: Fri Sep 03, 2010 5:05 pm
by Eric Clayberg » Wed Sep 08, 2010 3:27 am
All widgets in the tree are potentially created and destroyed many times during an editing session, so each instantiation of a widget is logically separate from its predecessor.
It sounds like you might be doing something unusual in the life cycle of your widget or making some invalid assumptions, but we would need to see a complete test case to know for sure.
I would encourage you to compare what you are doing to the existing SWT and Nebula widgets (which all work just fine in SWT Designer).
-
Eric Clayberg
- Moderator
-
- Posts: 4503
- Joined: Tue Sep 30, 2003 6:39 am
- Location: Boston, MA USA
-
Return to SWT Designer
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest