NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Cush1978
Joined: 15 Sep 2008 Posts: 216
|
Posted: Mon Jun 11, 2012 3:56 pm Post subject: Nodes and data changes! |
|
|
It's me again, and I've got another question relating to Nodes. As some of you know, my Node tree represents a ZIP file that contains XML files. The purpose of this query relates to the XML Node branches.
I'm trying to figure out how to communicate data changes up the Node tree. Here's the scenario:
- I click on a Node and choose "Add/Edit." A UI pops up that allows me to create a new child or edit the clicked node. I make the changes and press "OK" or "Done" or whatever.
The way I'm envisioning this is to register a listener on the data in question. When the UI modifies the data, my listener will tell the Node that it's "dirty"; i.e., unsaved changes have been made. It seems straightforward, but is this the best way to do this or does the platform offer a better solution?
- Now that I've made changes somewhere in the tree, I want to communicate those changes all the way up. At the ZIP file level, I want to flag that changes have been made. This is very similar to how projects communicate errors or SVN changes. An error badge occurs at the file(s) in question and goes all the way up to the "top" level.
I'm not sure how to do this. When I'm creating a Node's children, should I register a listener on them? I'm not sure this would work since a Node's children are (re)created every time they're expanded. I'm at a bit of a loss as to how to achieve this.
I also need to do the opposite; when I press the Save button, I need to "clear" all flagged unsaved changes.
This kind of reflects the Savable example in Geertjan's blog where Save functionality is enabled/disabled based on edits, but I'm looking to flag/unflag changes up and down the Node tree.
So, in short:
- How does one "act" on changes made to data represented by a Node? (I'm assuming a relative data listener.)
- How does one notify it's parents of such changes?
- How does one clear those changes when a qualifying action is performed (clear unsaved changes when Save is pressed)?
I'm looking for the best design pattern here, because this would be used for validation errors, warnings, unsaved changes, etc. |
|
| Back to top |
|
 |
Geertjan Wielenga Posted via mailing list.
|
Posted: Mon Jun 11, 2012 4:02 pm Post subject: [platform-dev] Re: Nodes and data changes! |
|
|
http://platform.netbeans.org/tutorials/nbm-nodesapi.html
Gj
On 06/11/2012 05:56 PM, Cush1978 wrote:
| Quote: | It's me again, and I've got another question relating to Nodes. As some of you know, my Node tree represents a ZIP file that contains XML files. The purpose of this query relates to the XML Node branches.
I'm trying to figure out how to communicate data changes up the Node tree. Here's the scenario:
- I click on a Node and choose "Add/Edit." A UI pops up that allows me to create a new child or edit the clicked node. I make the changes and press "OK" or "Done" or whatever.
The way I'm envisioning this is to register a listener on the data in question. When the UI modifies the data, my listener will tell the Node that it's "dirty"; i.e., unsaved changes have been made. It seems straightforward, but is this the best way to do this or does the platform offer a better solution?
- Now that I've made changes somewhere in the tree, I want to communicate those changes all the way up. At the ZIP file level, I want to flag that changes have been made. This is very similar to how projects communicate errors or SVN changes. An error badge occurs at the file(s) in question and goes all the way up to the "top" level.
I'm not sure how to do this. When I'm creating a Node's children, should I register a listener on them? I'm not sure this would work since a Node's children are (re)created every time they're expanded. I'm at a bit of a loss as to how to achieve this.
I also need to do the opposite; when I press the Save button, I need to "clear" all flagged unsaved changes.
This kind of reflects the Savable example in Geertjan's blog where Save functionality is enabled/disabled based on edits, but I'm looking to flag/unflag changes up and down the Node tree.
So, in short:
- How does one "act" on changes made to data represented by a Node? (I'm assuming a relative data listener.)
- How does one notify it's parents of such changes?
- How does one clear those changes when a qualifying action is performed (clear unsaved changes when Save is pressed)?
I'm looking for the best design pattern here, because this would be used for validation errors, warnings, unsaved changes, etc.
|
|
|
| Back to top |
|
 |
Cush1978
Joined: 15 Sep 2008 Posts: 216
|
Posted: Mon Jun 11, 2012 5:03 pm Post subject: |
|
|
I've got no idea how I missed that. Between the book, the APIs, and the tutorials, there's usually an answer somewhere.
Precisely what I needed, I think...time to experiment!
Thanks again, I've got to improve my searching. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|