• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing GUI according to projects

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If I have a panel that changes according to projects, how should I implement it? Assuming the amount of changes is unknown.
Lets say I have a panel having a,b,c,d,e text fields for project A and a,b,c,x,y,z for Project B, a,b,m,n for Project C.
Here, a,b is common for all projects, c is common for projects A,B. d,e is specific to Project A... etc. Also my panels have some methods like
createGUIComponents(), guiLayout(), refresh(), save(), getErrorMessages()...

Question is: how should I design my panel? Possible approaches I thought are as follows:

1) define a common base class MyAbstractPanelBase containing (a,b) and methods listed above for these two fields. Then extend MyPanelBase, add (m,n) for Project C, override methods(for m,n).
Extend MyPanelBase, add (c) and name it MyAbstractPanelBase2 and override methods (for c). Extend MyAbstractPanelBase2, add (d,e) for Project A and override methods (for d,e). Extend MyAbstractPanelBase2, add(x,y,z) for Project B and override methods (for x,y,z)

2) Define one panel. Define all fields, layout all fields. Set visibilities of the fields (a,b,c,d,e,x,y,z,m,n) according to some contstructor arguments... This means use IF statements almost every methods of the panels. For example in refresh method some code like this: if(a.isVisible()) {....}

3) Define one panel, define all fields as in the case 2. But extract IF statements to external customizer classes such as MyPanelCustomizerForProjectA. In that classes write methods like customizeGuiLayout(), customizeSave().... and call these from myPanel. For example in guiLayout: customizer.guiLayout is called....

4) ???

Any suggestion is welcome. thank you much....
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Define base abstract class. This should have logic for all common fields/methods. Break down this class into logical chunks and chain them accordingly. e.g. Construtor invokes say initComponents(), registerListeners(), buildUI() etc. in this sequence. Make required methods abstract.
2) Define panels as per project. This would extend the abstract class above and provide full implementation
3) Have a factory which returns the proper project panel based on some differentiating parameter which tells the factory which panel implementation to return.
 
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic