• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Searching for GUI(?) pattern to display the same set of graphic elements in various ways

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there,

I'm using RCP to create the standalone desktop application. If you're not familiar, RCP uses SWT as graphic engine. But the question is rather about general programming pattern on how to organize the GUI code in readable way (doesn't have to be SWT code). Here we go:


I have a class which implements a composite. A composite is a rectangle that contains:

- Checkbox with text next to it
- Two radio buttons, one under another, each with text next to is; these radio buttons are active only if the checkbox above is checked
- Yet another checkbox with text next to it
- a table with some editable data
- two buttons: "create new" and "delete existing", used to create new row in table and to delete existing row from table.


The point is, the display of this composite depends on the previous user actions.

Sometimes I don't want to display radio buttone, only two checkboxes one under another, and table with buttons

Sometimes I don't want to display the table and buttons, only checkbox, 2 radios and checkbox again

Sometimes I want to display everything: checkbox, 2 radios, checkbox, table and 2 buttons



It's easy to do with lot's of "ifs" in the code but it makes the code much less readable. Maybe you know a pattern which would be useful in this case?


I need to:

- provide the information about display conditions from the outside of class (constructor? flags with setters and getters? others?)
- manage the internal code in the class in a readable way (inheritance? division of class to smaller parts? some "smart" methods for each graphic element? others?)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic