Bug 86414 - [Editor] Undo add port wipes out graph view
Summary: [Editor] Undo add port wipes out graph view
Status: CLOSED WORKSFORME
Alias: None
Product: WTP Webservices
Classification: WebTools
Component: wst.wsdl (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Valentin Baciu CLA
QA Contact:
URL:
Whiteboard: reviewed_1.5
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-23 22:01 EST by Keith Chong CLA
Modified: 2006-09-25 12:55 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Chong CLA 2005-02-23 22:01:07 EST
Undo add port wipes out graph view

- all components disappear, and all that is left are the categories
Comment 1 Valentin Baciu CLA 2006-01-25 20:53:41 EST
Here are the results of my investigation. 

There are a few things interacting to cause this bug.

First, the AddPortAction is not playing nice with the undo/redo mechanism (there may be other actions like this). Unlike other actions, it does not extend AddElementAction, and thus does not call the beginRecording()/endRecording() methods on the underlying model. This causes only partial undos, for example instead of undoing the text for the entire port, it would only undo the last action which was adding the port name attribute.

Once this was out of the way, the original problem was still there. I traced the cause as follows:
- the user selects undo
- the underlying editor's undo manager undoes the action by basically removing all the equivalent text changes made when the port was added through the graphical view.
- the text editor notifies the associated DOM model that a text change is taking place
- the DOMModel locates and removes the associated element
- when the element is removed, the parentNode is set to null, basically detaching the node from its parent
- the model then notifies its listeners, among which is the WSDLModelReconcileAdapter
- the adapter attempts to syncronize the WSDL model with the DOMModel
- the first change done is to reconcile the WSDLPort object attributes with the underlying DOM model (basically removing it, since we are undoing)
- the code in WSDLEditorUtil.getInstance().findModelObjectForElement tries to get the PortImpl object based on the underlying Element
- this code fails because of the lack of a way of finding the path to the root (remember the parentNode is already null) and returns the root DocumentImpl instead!!!
- so instead of removing the contents of the PortImpl, the code instead calls DefinitionImpl#handleReconciliation which effectively blows away the entire definition content
- hence, the dissapearing content in the graphical view. The text view still has the service element, so it is out of synch with the graphical view and the internal wsdl model.

I believe this is the end of mistery...
Now a fix for this is a totally different issue :-)
Comment 2 Craig Salter CLA 2006-06-07 23:34:32 EDT
Although bug 86551 makes it difficult to re-test this bug... I can flip to the source view and use undo/redo there.  When I try this it seems like I can undo a 'add port' and all is well.  Valentin, is this problem magically fixed?
Comment 3 Valentin Baciu CLA 2006-06-13 15:48:38 EDT
The way the editor is notified of DOM events seems to have changed, probably as a result of it manipulating the WSDL model directly and not the DOM as we used to. 

The order of events appears to have changed: the attribute node removal is processed while the parent port node still has a parent. Thus I cannot seem to be able to reproduce the original problem.

I propose we close for 1.5.
Comment 4 Valentin Baciu CLA 2006-06-15 15:55:38 EDT
See previous comment.
Comment 5 Keith Chong CLA 2006-09-25 12:15:32 EDT
To undo an add port (with binding and soap protocol), the current behaviour is now to run 5 undo text actions and 1 undo add.   Was the compound command removed?  The graph view doesn't get wiped out.
Comment 6 Keith Chong CLA 2006-09-25 12:55:21 EDT
Will open a separate bug for the compound command.
Comment 7 Keith Chong CLA 2006-09-25 12:55:36 EDT
Closing bug