This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 33553 - Troubles with delete action
Summary: Troubles with delete action
Status: CLOSED INVALID
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P1 blocker (vote)
Assignee: Petr Hrebejk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-13 09:50 UTC by adel
Modified: 2008-12-22 21:54 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Ok here is the complete class node (17.10 KB, text/plain)
2003-05-13 12:43 UTC, adel
Details
The modified code (2.27 KB, text/plain)
2003-05-13 14:33 UTC, adel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adel 2003-05-13 09:50:53 UTC
Hi, im using openide 3.5 dev and ide 3.5 dev build 030410 
platform windows 2000. VM 1.4.0_01. 
I load in memory a structure a hierarchical structure of 
objects  (loaded from XML using jaxb) and i try to create 
nodes from these objects, and display then in an 
ExplorerPanel. Some of the nodes created can be deleted. 
Here a strange thing happened. First, when i try to delete 
a node that is originally loaded from the xml persistance 
the delete confirmation dialog is shown that means 
DeleteActionPerformer in ExplorerActions is invoked but 
the node is not deleted, even that the node can be 
destroyed and the destroy method do a proper clean of the 
internal structure and call the super destroy. I remarked 
that the object presented by this node in the internal 
structure is deleted but not the node itself. The 
strangest thing is that when i create a new node inside 
the hierarchy, and when i invoke the delete action, the 
node is deleted. It seems that delete work only with the 
new nodes that i create in the explorer but not the loaded 
ones. But the most strangest thing is that when i create a 
new node inside a parent and i delete the new node 
created, its deleted from the tree, but when i copy the 
parent inside another one the child node created appear 
again.
Comment 1 Peter Zavadsky 2003-05-13 10:08:26 UTC
Hm, I can't judge from this very much.

But if the destroy method on the node is called, the action is fine.
The rest job is not up to the action itself.

Please let me know whether the destroy method is called. And if you
are able to provide the case here? Thanks
Comment 2 adel 2003-05-13 10:21:16 UTC
I putted some debug log messages in the destroy method and 
it seems that its called.
Comment 3 _ ttran 2003-05-13 12:29:18 UTC
Adel, please post your code snippet, preferrably a working mini
module.  Otherwise it's really hard to understand what's going on here
Comment 4 Peter Zavadsky 2003-05-13 12:32:14 UTC
If that method is called, then the action performer does its job fine.

Problem should be at another place

Did you mention you somehow overwrite that method?
It could happen, if it's your node impl, you could make some mistake
which results to this behaviour. I don't know, just guessing.

Passing to nodes component, maybe they could point out some problems
when subclassing nodes.
Comment 5 adel 2003-05-13 12:43:57 UTC
Created attachment 10277 [details]
Ok here is the complete class node
Comment 6 adel 2003-05-13 12:52:31 UTC
The only difference that i see between the nodes loaded 
from persistance and the nodes newly created in the 
explorer is that the first are added using Children#setKey 
and the seconds are added using Children.Array#add. 
For the attachement sorry Trung it cant run it needs the 
complete objects (especially Assembly and parts objects ) 
to run. But i posted mostly the complete class code.
Comment 7 Petr Hrebejk 2003-05-13 13:34:28 UTC
The problem is you are mixing two kind of functionality in your
AssemblyChildren class. (For historical reasons the Children.Keys
extend the Children.Array) Nodes you add within the explorer
can be deleted because they are added using Children.Array add
method. Loaded nodes can't because the setKeys() method of 
Children.Keys is not called with the new internal data.

You have two possibilities how to implement it.

1) Let your AssemblyChildren extend the Children.Array and add all
nodes using the add method or the Children.Array constructor.

2) (Recommended) Leave AsseblyChildren to be subclass of
Children.Keys. Add a method refresh into it. Which would be
implemented like;

refresh() {
    keys = new ArrayList();
    keys.addAll(parentAssembly.getChildAssemliesList());
    keys.addAll(parentAssembly.getChildPartsList());
    setKeys (keys);
}

when adding or removing parts and assemblies. Just rearange internal
structures (i.e. remove the line crating and adding new node from 
addPart and addAssembly methods) and then call the refresh() method 
on proper children.

Hope this helps.
Comment 8 adel 2003-05-13 14:02:56 UTC
Thanks for help Petr, the first possibility works fine, 
but i tried also the second (recommended one) and it seems 
to not yet working with objects loaded from persistance. I 
think the delete action doesn't work if we add a node 
using setKeys. I'm not sure if i can post it as a bug!
Comment 9 Petr Hrebejk 2003-05-13 14:10:01 UTC
Are you sure you call setKeys after deleting the object from the
internal structures? (on parent of course) I really doubt this is a
bug. There are pretty many Children.Keys subclasses in the whoile 
NetBeans depending on this feature.
Comment 10 adel 2003-05-13 14:18:51 UTC
I know .. especially the fact that there are a lot of 
subclasses of this one .. ill try to check if its really a 
bug.
Comment 11 adel 2003-05-13 14:32:42 UTC
Hi Petr, I tested it and it seems really not working 
here is the modified code with added refresh method 
Note : i called it refresh0 since  refresh exists already 
in Children and is final. 
Comment 12 adel 2003-05-13 14:33:40 UTC
Created attachment 10281 [details]
The modified code
Comment 13 Petr Hrebejk 2003-05-13 14:39:03 UTC
Your attachement only shows implementation of Children. Are you sure 
you call the reresh0 after delting the object. I.e. in the 
node.destroy() method?
Comment 14 adel 2003-05-13 17:13:30 UTC
Sorry, i forget to put the method refresh0 in the destroy 
method. Its working fine now.
Thanks 
Comment 15 Jesse Glick 2003-05-19 13:17:59 UTC
x
Comment 16 Jesse Glick 2003-05-19 13:18:30 UTC
There was no resolution. 'INVALID' OK?
Comment 17 adel 2003-05-19 13:22:28 UTC
Invalid