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

How to show/hide application buttons with SWT RowLayout

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

I am working on an SWT application in which I would like to allow users to customize to show only selected application buttons. I have created a Composite object (the "button area") and set a RowLayout as follows:


The "button area" contains 4 buttons, each with a unique RowData object as follows:

Everything works fine until I attempt to show or hide a button. I attempt to do so by setting the rowData.exclude flag and invoking layout on the parent button area object. A button is always shown or hidden but the button shown or hidden is not necessarily the correct one. I have noticed that if I hide the buttons IN ORDER from left to right, e.g. button 1, button 2, button 3, button 4, the buttons are hidden correctly. Conversely, if I show the buttons in order from right to left, e.g. button 4, button 3, button 2, button 1, the buttons are shown correctly.

However, If I attempt to hide a button that is not the leftmost button shown, I observe unpredictable results. For example, if I attempt to hide button 4, button 2 may be hidden even though the application status message clearly states button 4 has been hidden. Similar results are observed when attempt to show a button that is not the rightmost one not shown.

I have tried working with GridLayout and GridData but have observed similar results. I have debugged thru the code and I am certain the correct button exclude flag is being set prior to layout being invoked. I am also certain unique RowData objects are being created for each button. The SWT button object references cannot change because they are declared final.

Am I attempting to do this incorrectly? Any suggestions would be appreciated!

 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently setting "exclude" for GridData or RowData is not enough. If I also invoke the button's setVisible method with the correct parameter (as shown in the code snippet below), showing/hiding buttons in the button area works as I would expect it to.

Would someone care to explain the difference between setting "exclude" and invoking setVisible and why you have to do both?
 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After some additional testing, if appears that setting both "exclude" plus "setVisible" is like setting the CSS "display" attribute for an element whereas setting "setVisible" ONLY is like setting the CSS "visibility" attribute. Can anyone confirm this?
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic