This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: properties GUI

 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
i set up three properties GUIs one for serverproperties, one for client properties and one for alone properties. But I guess having three properties GUIs that are quite similar isn't nicely programmed. How did you solve this, did you put intelligence in your GUI that based on the mode it gets, you handle the different fields in the GUI?
Help is appreciated!!
 
Eric Kim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put these into a tabbed panel, so got server property pane, network client property pane and standalone pane. Depends on different start mode, I set selected index to corresponging one, and also disable edit on other panel.
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.
Yes, I used the same GUI for all three modes, just displaying the appropriate fields for the active mode. Worked well.
Enjoy.
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jacques Bosch:
Hi there.
Yes, I used the same GUI for all three modes, just displaying the appropriate fields for the active mode. Worked well.
Enjoy.


How do you decide to display certain fields. Off course based on the mode. But if the user presses "Save" or "Ok" button how do you know which fields to save, etc.
could you help me on the right track??
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly in the same way.
If app was started in server mode, I only show the server settings, and when time to save, I only save the server settings.
Just a switch statement. I defined an int mode flag for my project.
Hope that helps.
Just shout if you need more info.
Enjoy.
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jacques Bosch:
Exactly in the same way.
If app was started in server mode, I only show the server settings, and when time to save, I only save the server settings.
Just a switch statement. I defined an int mode flag for my project.
Hope that helps.
Just shout if you need more info.
Enjoy.

Allright Jacques i'm getting there, one more question though. Let's say you start the propertiesGUI. Do you have the responsibilities in the GUI. For instance startPropertiesGUI(String Mode);
In the GUI if for instance it's the Client GUI :

In the GUI if for instance it's the Server GUI :

In the SaveButtonHandler you make the switch between the different modes and handle accordingly.
Am i correct?
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Allright Jacques i'm getting there, one more question though. Let's say you start the propertiesGUI. Do you have the responsibilities in the GUI. For instance startPropertiesGUI(String Mode);

Not sure what you mean by 'responsibilities', but yes, I pass the mode into the GUI upon creation... Let the GUI handle itself appropriately for the mode it's in.

In the SaveButtonHandler you make the switch between the different modes and handle accordingly.

Yes, that's what I did.
So you basically have a switch in the load, for what to display, and then a switch again in the save for what to persist.
Let me know how it's going.
J
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jacques Bosch:

Yes, that's what I did.
So you basically have a switch in the load, for what to display, and then a switch again in the save for what to persist.
Let me know how it's going.
J

Hi Jacques your help is very appreciated!!
But i still have two more open questions :
1. Do you start the appropiate code in the properties GUI or not? So when i start the propertiesGUI with Client mode do you act accordingly in the save. So persist the properties and start new GUI?
2. Do you you have some sort of PropertyFileHandler in your GUI, where for instance you can ask isPropertyFileAvailable() or createPropertyFile() or saveProperty() etc. ?
Thanks again!!
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, Theo, I don't have time to reply now. Will try to reply later.
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. Do you start the appropiate code in the properties GUI or not? So when i start the propertiesGUI with Client mode do you act accordingly in the save. So persist the properties and start new GUI?

OK, my main class is called Mount. That's where my app starts. The main method gets the mode parameter. I convert that to in int mode flag for ease of use. From there I call the prop / startup GUI as a modal dialog so that the rest of the code only gets run after the prop GUI is hidden. Like this.

As you can see, for some of the props, I get it straight from the prop GUI object before it gets disposed. In the case of the DB file, in my Data class, I just read it directly from the properties file again where the prop GUI saved it.

2. Do you you have some sort of PropertyFileHandler in your GUI, where for instance you can ask isPropertyFileAvailable() or createPropertyFile() or saveProperty() etc. ?

What I do in my loadProperties() method, when the prop GUI starts, is to first try and open the property file and load the settings from there. If it fails, that's fine, because it will get created the first time you click Save or Launch or what ever you click to continue from the prop GUI. If it fails, or if a key is not present, I just display defaults.
Here is a sample of what I did:


I hope that is of help. Let me know how it's going.
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jacques you have been very hepfull!!
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure thing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic