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.
Steps to reproduce: Scenario one: - create a new Sync sample - open it in designer - delete the assign element - delete the root sequence - try to undo your actions - undo will not work - try to close the diagram and reopen it - you will ot be able to do this Scenario 2: - create a new Sync sample - open it in designer - delete the Assign activity - delete the reply activity - try to perform undo - Undo will not work The bug can be reproduced with some other scenarios, the exact reason is unclear now. After pressing Undo-Redo user can also get visible exceptions like javax.swing.CannotUndoException javax.swing.CannotRedoException
Index: org/netbeans/modules/bpel/xpath/view/output/ResultWindow.java =================================================================== RCS file: /cvs/enterprise/bpel/xpatheditor/src/org/netbeans/modules/bpel/xpath/view/output/Attic/ResultWindow.java,v retrieving revision 1.1.2.20 diff -u -r1.1.2.20 ResultWindow.java --- org/netbeans/modules/bpel/xpath/view/output/ResultWindow.java 16 Oct 2006 20:18:16 -0000 1.1.2.20 +++ org/netbeans/modules/bpel/xpath/view/output/ResultWindow.java 20 Oct 2006 10:09:27 -0000 @@ -26,7 +26,6 @@ import java.util.Map; import javax.accessibility.AccessibleContext; import org.netbeans.modules.bpel.core.BPELDataEditorSupport; -import org.netbeans.modules.bpel.core.multiview.spi.MultiviewId; import org.netbeans.modules.bpel.model.api.BpelModel; import org.openide.awt.UndoRedo; import org.openide.util.HelpCtx; @@ -150,8 +149,6 @@ protected void componentDeactivated() { assert EventQueue.isDispatchThread(); super.componentDeactivated(); - - removeUndoManager(); } protected void componentShowing() { @@ -164,8 +161,6 @@ protected void componentHidden() { assert EventQueue.isDispatchThread(); super.componentHidden(); - - removeUndoManager(); } public void addDisplayComponent(TopComponent displayComp) { @@ -252,23 +247,9 @@ BPELDataEditorSupport editorSupport = ((MapperUndoRedo) getUndoRedo()).getEditorSupport(); if (editorSupport != null) { - editorSupport.addUndoManager( MultiviewId.MAPPER ); + editorSupport.addUndoManagerToModel( editorSupport.getUndoManager() ); } } } - /** - * Removes the undo/redo manager undoable edit listener from the - * bpel model, to stop receiving undoable edits. - */ - private void removeUndoManager() { - BpelModel bpelModel = getCurrentBpelModel(); - if (bpelModel != null) { - BPELDataEditorSupport editorSupport = - ((MapperUndoRedo) getUndoRedo()).getEditorSupport(); - if (editorSupport != null) { - editorSupport.removeUndoManager( MultiviewId.MAPPER ); - } - } - } } Index: org/netbeans/modules/bpel/editors/multiview/DesignerMultiViewElement.java =================================================================== RCS file: /cvs/enterprise/bpel/editors/src/org/netbeans/modules/bpel/editors/multiview/Attic/DesignerMultiViewElement.java,v retrieving revision 1.1.2.30 diff -u -r1.1.2.30 DesignerMultiViewElement.java --- org/netbeans/modules/bpel/editors/multiview/DesignerMultiViewElement.java 5 Oct 2006 20:43:51 -0000 1.1.2.30 +++ org/netbeans/modules/bpel/editors/multiview/DesignerMultiViewElement.java 20 Oct 2006 10:10:56 -0000 @@ -55,7 +55,6 @@ import org.netbeans.core.spi.multiview.MultiViewFactory; import org.netbeans.modules.bpel.core.BPELDataEditorSupport; import org.netbeans.modules.bpel.core.BPELDataObject; -import org.netbeans.modules.bpel.core.multiview.spi.MultiviewId; import org.netbeans.modules.bpel.core.validation.BPELValidationController; import org.netbeans.modules.bpel.core.validation.SelectBpelElement; import org.netbeans.modules.bpel.design.DesignView; @@ -117,6 +116,7 @@ import org.netbeans.modules.xml.xam.Model; import org.netbeans.modules.xml.xam.Model.State; import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; +import org.netbeans.modules.xml.xam.ui.undo.QuietUndoManager; import org.openide.awt.UndoRedo; import org.openide.nodes.Node; import org.openide.util.Lookup; @@ -250,7 +250,6 @@ super.componentDeactivated(); // Don't touch undo manager when cpmponent still present showing // but just lost focus.... - removeUndoManager(); } public void componentHidden() { @@ -263,7 +262,6 @@ if (myDesignView != null) { myDesignView.setVisible(false); } - removeUndoManager(); // updateBpelTcGroupVisibility(false); } @@ -560,18 +558,14 @@ * edit listener, so it receives the edits onto the queue. */ private void addUndoManager() { - myDataObject.getEditorSupport().addUndoManager( - MultiviewId.ORCH_DESIGNER ); + BPELDataEditorSupport support = myDataObject.getEditorSupport(); + if ( support!= null ){ + QuietUndoManager undo = support.getUndoManager(); + support.addUndoManagerToModel( undo ); + } } - /** - * Removes the undo/redo manager undoable edit listener from the - * bpel model, to stop receiving undoable edits. - */ - private void removeUndoManager() { - myDataObject.getEditorSupport().removeUndoManager( - MultiviewId.ORCH_DESIGNER ); - } + private BpelModel getBpelModel() { return getDataObject().getEditorSupport().getBpelModel(); cvs server: Diffing org/netbeans/modules/bpel/editors/resources cvs server: Diffing org/netbeans/modules/bpel/navigator Index: org/netbeans/modules/bpel/navigator/BpelModelLogicalBeanTree.java =================================================================== RCS file: /cvs/enterprise/bpel/editors/src/org/netbeans/modules/bpel/navigator/Attic/BpelModelLogicalBeanTree.java,v retrieving revision 1.1.2.13 diff -u -r1.1.2.13 BpelModelLogicalBeanTree.java --- org/netbeans/modules/bpel/navigator/BpelModelLogicalBeanTree.java 5 Oct 2006 20:43:49 -0000 1.1.2.13 +++ org/netbeans/modules/bpel/navigator/BpelModelLogicalBeanTree.java 20 Oct 2006 10:10:56 -0000 @@ -28,7 +28,6 @@ import javax.swing.tree.TreeSelectionModel; import org.netbeans.modules.bpel.core.BPELDataEditorSupport; -import org.netbeans.modules.bpel.core.multiview.spi.MultiviewId; import org.netbeans.modules.bpel.design.nodes.NodeType; import org.netbeans.modules.bpel.model.api.BpelEntity; import org.netbeans.modules.bpel.model.api.BpelModel; @@ -45,6 +44,7 @@ import org.netbeans.modules.bpel.nodes.refactoring.UsageFilterNode; import org.netbeans.modules.bpel.properties.NodeUtils; import org.netbeans.modules.xml.xam.Model; +import org.netbeans.modules.xml.xam.ui.undo.QuietUndoManager; import org.openide.ErrorManager; import org.openide.explorer.ExplorerManager; import org.openide.explorer.view.BeanTreeView; @@ -188,9 +188,6 @@ if (TopComponent.getRegistry().getActivated() == navigatorTopComponent) { addUndoManager(); } - else { - removeUndoManager(); - } } else if (propertyName.equals(TopComponent.Registry.PROP_ACTIVATED_NODES)) { if (TopComponent.getRegistry().getActivated() != navigatorTopComponent) { @@ -296,20 +293,13 @@ * edit listener, so it receives the edits onto the queue. */ private void addUndoManager() { - ((BPELDataEditorSupport) myContextLookup - .lookup(BPELDataEditorSupport.class)) - .addUndoManager(MultiviewId.NAVIGATOR); + BPELDataEditorSupport support = ((BPELDataEditorSupport) myContextLookup + .lookup(BPELDataEditorSupport.class)); + if ( support!= null ){ + QuietUndoManager undo = support.getUndoManager(); + support.addUndoManagerToModel( undo ); + } } - /** - * Removes the undo/redo manager undoable edit listener from the - * schema model, to stop receiving undoable edits. - */ - private void removeUndoManager() { - ((BPELDataEditorSupport) myContextLookup - .lookup(BPELDataEditorSupport.class)) - .removeUndoManager(MultiviewId.NAVIGATOR); - - } } Index: org/netbeans/modules/bpel/core/BPELDataEditorSupport.java =================================================================== RCS file: /cvs/enterprise/bpel/core/src/org/netbeans/modules/bpel/core/Attic/BPELDataEditorSupport.java,v retrieving revision 1.1.2.23 diff -u -r1.1.2.23 BPELDataEditorSupport.java --- org/netbeans/modules/bpel/core/BPELDataEditorSupport.java 5 Oct 2006 20:43:50 -0000 1.1.2.23 +++ org/netbeans/modules/bpel/core/BPELDataEditorSupport.java 20 Oct 2006 10:11:28 -0000 @@ -34,8 +34,7 @@ import org.netbeans.core.spi.multiview.CloseOperationState; import org.netbeans.modules.bpel.core.multiview.BPELSourceMultiViewElementDesc; import org.netbeans.modules.bpel.core.multiview.BpelMultiViewSupport; -import org.netbeans.modules.bpel.core.multiview.spi.MultiviewId; -import org.netbeans.modules.bpel.core.validation.BPELValidationController; +import org.netbeans.modules.bpel.core.validation.BPELValidationController; import org.netbeans.modules.bpel.core.validation.SelectBpelElement; import org.netbeans.modules.bpel.editors.canvas.Canvas; import org.netbeans.modules.bpel.editors.canvas.CanvasManagerAccess; @@ -186,11 +185,42 @@ // The superclass prepareDocument() adds the undo/redo // manager as a listener -- we need to remove it since // the views will add and remove it as needed. - QuietUndoManager qum = (QuietUndoManager) getUndoRedo(); + QuietUndoManager undo = (QuietUndoManager) getUndoRedo(); StyledDocument doc = getDocument(); - doc.removeUndoableEditListener(qum); - // Now that the document is ready, pass it to the manager. - qum.setDocument((AbstractDocument) doc); + synchronized (undo) { + // Now that the document is ready, pass it to the manager. + undo.setDocument((AbstractDocument) doc); + if (!undo.isCompound()) { + // The superclass prepareDocument() adds the undo/redo + // manager as a listener -- we need to remove it since + // we will initially listen to the model instead. + doc.removeUndoableEditListener(undo); + // If not listening to document, then listen to model. + addUndoManagerToModel(undo); + } + } + } + }); + return task; + } + + public Task reloadDocument() { + Task task = super.reloadDocument(); + task.addTaskListener(new TaskListener() { + public void taskFinished(Task task) { + EventQueue.invokeLater(new Runnable() { + public void run() { + QuietUndoManager undo = getUndoManager(); + StyledDocument doc = getDocument(); + // The superclass reloadDocument() adds the undo + // manager as an undoable edit listener. + synchronized (undo) { + if (!undo.isCompound()) { + doc.removeUndoableEditListener(undo); + } + } + } + }); } }); return task; @@ -305,64 +335,85 @@ return true; } + + /** + * Adds the undo/redo manager to the document as an undoable edit + * listener, so it receives the edits onto the queue. The manager + * will be removed from the model as an undoable edit listener. + * + * <p>This method may be called repeatedly.</p> + */ + public void addUndoManagerToDocument() { + // This method may be called repeatedly. + // Stop the undo manager from listening to the model, as it will + // be listening to the document now. + QuietUndoManager undo = getUndoManager(); + StyledDocument doc = getDocument(); + synchronized (undo) { + + removeUndoManagerFromModel(); + + // Document may be null if the cloned views are not behaving + // correctly. + if (doc != null) { + // Ensure the listener is not added twice. + doc.removeUndoableEditListener(undo); + doc.addUndoableEditListener(undo); + // Start the compound mode of the undo manager, such that when + // we are hidden, we will treat all of the edits as a single + // compound edit. This avoids having the user invoke undo + // numerous times when in the model view. + undo.beginCompound(); + } + } + } /** - * Adds the undo/redo manager to the bpel model as an undoable - * edit listener, so it receives the edits onto the queue. - * - * I suppose that those methods are called always in one thread. - * Currently this is true. They are always called from AWT thread. - * - * @param id Id of mutiview element for which we add undo/redo manager. + * Add the undo/redo manager undoable edit listener to the model. + * + * <p>Caller should synchronize on the undo manager prior to calling + * this method, to avoid thread concurrency issues.</p> + * + * @param undo the undo manager. */ - public void addUndoManager( MultiviewId id ) - { + public void addUndoManagerToModel(QuietUndoManager undo) { + System.out.println("added manager to OM"); BpelModel model = getBpelModel(); if (model != null) { - QuietUndoManager undo = getUndoManager(); // Ensure the listener is not added twice. - removeUndoManager(); + removeUndoManagerFromModel(); model.addUndoableEditListener(undo); // Ensure the model is sync'd when undo/redo is invoked, // otherwise the edits are added to the queue and eventually // cause exceptions. undo.setModel(model); - - // keep id of multiview - setId(id); + } } - + /** * Removes the undo/redo manager undoable edit listener from the - * bpel model, to stop receiving undoable edits. - * - * I suppose that those methods are called always in one thread. - * Currently this is true. They are always called from AWT thread. - * - * @param id Id of mutiview element for which we remove undo/redo manager. + * document, to stop receiving undoable edits. The manager will + * be added to the model as an undoable edit listener. + * + * <p>This method may be called repeatedly.</p> */ - public void removeUndoManager( MultiviewId id ) - { - /* - * we prevent deleting undo/redo manager if it was added by multiview - * with different id. - */ - if ( id!= getId()) { - return; - } - - BpelModel model = getBpelModel(); - if (model != null) { - QuietUndoManager undo = getUndoManager(); - model.removeUndoableEditListener(undo); - // Must unset the model when leaving model view. - undo.setModel(null); - - // remove id - setId( null ); + public void removeUndoManagerFromDocument() { + // This method may be called repeatedly. + QuietUndoManager undo = getUndoManager(); + StyledDocument doc = getDocument(); + synchronized (undo) { + // May be null when closing the editor. + if (doc != null) { + doc.removeUndoableEditListener(undo); + undo.endCompound(); + } + // Have the undo manager listen to the model when it is not + // listening to the document. + addUndoManagerToModel(undo); } } + protected CloneableEditorSupport.Pane createPane() { TopComponent multiview = BpelMultiViewSupport @@ -442,7 +493,8 @@ * Removes the undo/redo manager undoable edit listener from the * bpel model, to stop receiving undoable edits. */ - private void removeUndoManager( ) { + private void removeUndoManagerFromModel( ) { + System.out.println("removed from model"); BpelModel model = getBpelModel(); if (model != null) { QuietUndoManager undo = getUndoManager(); @@ -451,15 +503,7 @@ undo.setModel(null); } } - - private void setId( MultiviewId id) { - myMultiviewId = id; - } - - private MultiviewId getId() { - return myMultiviewId; - } - + private List<TopComponent> getAssociatedTopComponents() { // Create a list of TopComponents associated with the // editor's schema data object, starting with the the @@ -574,7 +618,5 @@ /** Used for managing the prepareTask listener. */ private transient Task prepareTask; - - private transient MultiviewId myMultiviewId; } cvs server: Diffing org/netbeans/modules/bpel/core/annotations cvs server: Diffing org/netbeans/modules/bpel/core/annotations/impl cvs server: Diffing org/netbeans/modules/bpel/core/grammar cvs server: Diffing org/netbeans/modules/bpel/core/helper cvs server: Diffing org/netbeans/modules/bpel/core/helper/api cvs server: Diffing org/netbeans/modules/bpel/core/helper/impl cvs server: Diffing org/netbeans/modules/bpel/core/multiview Index: org/netbeans/modules/bpel/core/multiview/BPELSourceMultiViewElement.java =================================================================== RCS file: /cvs/enterprise/bpel/core/src/org/netbeans/modules/bpel/core/multiview/Attic/BPELSourceMultiViewElement.java,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 BPELSourceMultiViewElement.java --- org/netbeans/modules/bpel/core/multiview/BPELSourceMultiViewElement.java 3 Oct 2006 09:22:06 -0000 1.1.2.8 +++ org/netbeans/modules/bpel/core/multiview/BPELSourceMultiViewElement.java 20 Oct 2006 10:11:29 -0000 @@ -278,20 +278,7 @@ */ private void addUndoManager() { BPELDataEditorSupport editor = getDataObject().getEditorSupport(); - QuietUndoManager undo = editor.getUndoManager(); - StyledDocument doc = editor.getDocument(); - // Unlikely to be null, but could be if the cloned views are not - // behaving correctly. - if (doc != null) { - // Ensure the listener is not added twice. - doc.removeUndoableEditListener(undo); - doc.addUndoableEditListener(undo); - // Start the compound mode of the undo manager, such that when - // we are hidden, we will treat all of the edits as a single - // compound edit. This avoids having the user invoke undo - // numerous times when in the model view. - undo.beginCompound(); - } + editor.addUndoManagerToDocument(); } /** @@ -300,13 +287,7 @@ */ private void removeUndoManager() { BPELDataEditorSupport editor = getDataObject().getEditorSupport(); - StyledDocument doc = editor.getDocument(); - // May be null when closing the editor. - if (doc != null) { - QuietUndoManager undo = editor.getUndoManager(); - doc.removeUndoableEditListener(undo); - undo.endCompound(); - } + editor.removeUndoManagerFromDocument(); } cvs server: Diffing org/netbeans/modules/bpel/core/multiview/spi Index: org/netbeans/modules/bpel/core/multiview/spi/MultiviewId.java =================================================================== RCS file: org/netbeans/modules/bpel/core/multiview/spi/MultiviewId.java diff -N org/netbeans/modules/bpel/core/multiview/spi/MultiviewId.java --- org/netbeans/modules/bpel/core/multiview/spi/MultiviewId.java 9 Oct 2006 16:53:13 -0000 1.1.2.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,18 +0,0 @@ -/** - * - */ -package org.netbeans.modules.bpel.core.multiview.spi; - - -/** - * This is enumeration for identifying UI view that needs to - * operate with BPEL OM. - * @author ads - * - */ -public enum MultiviewId { - - ORCH_DESIGNER, // Diagram View - NAVIGATOR, // Navigator View - MAPPER // Mapper View -}
We have reviewed and approved. Please check in fix.
Note, that this fix will be checked in exclusively to release55. It will not be checked into release55_dev at this time because the release55_dev has already been changed in other ways. This bug may be different in release55_dev line and may require different fix, or no fix at all.
Fixed in release55 branch. Also I need to checkin changes in release55_dev branch. They will follow.
Fixed in both branches.
Minor fix that can be done for this issue with lost undo functionality in mapper. ( module xpatheditor ) org.netbeans.modules.bpel.xpath.view.output.ResultWindow.java : Those two methods should be "commented out" ( I mean their body should be commented ): /** * Adds the undo/redo manager to the bpel model as an undoable * edit listener, so it receives the edits onto the queue. */ private void addUndoManager() { BpelModel bpelModel = getCurrentBpelModel(); if (bpelModel != null) { BPELDataEditorSupport editorSupport = ((MapperUndoRedo) getUndoRedo()).getEditorSupport(); if (editorSupport != null) { editorSupport.addUndoManager( MultiviewId.MAPPER ); } } } /** * Removes the undo/redo manager undoable edit listener from the * bpel model, to stop receiving undoable edits. */ private void removeUndoManager() { BpelModel bpelModel = getCurrentBpelModel(); if (bpelModel != null) { BPELDataEditorSupport editorSupport = ((MapperUndoRedo) getUndoRedo()).getEditorSupport(); if (editorSupport != null) { editorSupport.removeUndoManager( MultiviewId.MAPPER ); } } } should become : /** * Adds the undo/redo manager to the bpel model as an undoable * edit listener, so it receives the edits onto the queue. */ private void addUndoManager() { } /** * Removes the undo/redo manager undoable edit listener from the * bpel model, to stop receiving undoable edits. */ private void removeUndoManager() { }
In RC4 build, the two scenarios listed by mikk worked fine. I tried some other scerarios, like edit name of an element, activity, updated the properties, and then Undo or Redo, worked fine too, except the following scenario: 1. Double click an Receive element in a BPEL Design diagram. 2. In the Receive Property Editor window, click the "Correlations" tab. 3. Select an existing Correlation Set. Click Edit button. 4. Modify the name of the Correlation Set in the Edit Correlation Set dialog from "ItineraryCorrelator1" to "ItineraryCorrelator12". (See attached screenshot Picture1.png) 5. Click Ok. Click Ok. 6. In the IDE main menu, select Edit, will see the Undo item is changed to "Undo Undo". (See attched screenshot Picture2.png) 7. Select this "Undo Undo" item, then double click the Receive element again to check the change. Name of the Correlation Set is still "ItineraryCorrelator12", if "undo" works, it should be changed back to "ItineraryCorrelator1". (See attached screenshot Picture3.png) 8. Select "Edit -> Undo Undo" item in the main menu. 9. Select Edit in the main menu again. This time, the Undo item is changed back to normal "Undo", instead of the "Undo Undo". Notice the "Redo" item is changed to "Redo Redo". (See attached screenshot Picture4.png) 10. Double click the Receive element again to check the change. Name of the Correlation Set is undoed, back to "ItineraryCorrelator1". (See attached screenshot Picture5.png)
Created attachment 35428 [details] modify name of correlation set from "ItineraryCorrelator1" to "ItineraryCorrelator12"
Created attachment 35429 [details] "Undo Undo" item in main Edit menu.
Created attachment 35430 [details] "Undo Undo" did not perform undo feature.
Created attachment 35431 [details] Item in main Edit menu is changed back to "Undo"
Created attachment 35432 [details] "Undo" perform undo feature
Same behavior will get on Invoke element.
The workaround for the Correlation Set Undo feature is, to do it "Edit -> Undo" twice. This behavior will be seen on Invoke/Receive/Reply element. Since the issue will be documented, downgrade it from P1 to P2.
This is not a bug for ANY actions with undo/redo. This is absolutley concrete bug related to problems with Mapper. Original bug can be reproduced with various scenarious ONLY WHEN THERE IS ACTIVITY THAT HAVE PROPERTY WITH MAPPER AS EDITOR FOR THIS PROPERTY. The reason of original issue is appearing mapper while actions over activities. Correlations don't have any relation to mapper. The issue mentioned here is absolutely different issue, not related to original issue. I'm absolutey sure that this is NOT REGRESSION. Last described wasn't noticed in testing process. So please: 1) Identify described issue as regression/not regression. 2) Please don't reopen this issue. Because it is unrelated to your issue. 3) Create one more issue with your description. I'm absolutly sure that it is very bad practice to put all problems discovered with undo/redo into the one issue.
Verified