This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

A better structure for the classes

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have some experience with Java "classic" web applications, some with console apps, but almost none regarding desktop, event based, GUI applications.

I am working on a web application using GWT and Ext GWT, which is "event based" instead of "request based". So it looks more like a desktop application than a web application.

I have a window that contains a lot of components. This is the component structure (not all of them) and the attachment shows it all:



The problem is that the components interact with each other, for example:
- A button in the ToolBar modifies the right ContentPanel by adding the proper FormPanel to it. It may possible alter the TreePanel too.
- By selecting something from the TreePanel, it modifies the buttons in the ToolBar behaviour. At the same time, it modifies the right ContentPanel by adding the proper FormPanel to it.
- A FormPanel modifies the TreePanel structure.

So the problem is organizing the components in the class. This is the current class structure:



As you can see, I have to keep a reference to the window on each component that needs to interact with another. There has to be a better way.
The source file is already over 500 lines of code long and it's not finished yet.
Component-layout.PNG
[Thumbnail for Component-layout.PNG]
 
Marshal
Posts: 74354
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you use the getParent() method on each Component?
 
Nick White Ro
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the parent Widget.
To get the parent window from the tree, I have to call
 
Campbell Ritchie
Marshal
Posts: 74354
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . And what about the getAncestors() method?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic