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.
Build from June 17, 2007. See also 106983. 1. Add two attribute into XML schema. 2. Delete first one from schema with Right click -> Delete. 3. Delete other one from source. 4. Make attempt to undo delete with manu Refactor -> Undo. Followed will appear: java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at org.netbeans.editor.DocumentContent.moveGap(DocumentContent.java:215) at org.netbeans.editor.DocumentContent.insertText(DocumentContent.java:271) at org.netbeans.editor.DocumentContent$Edit.undoOrRedo(DocumentContent.java:423) at org.netbeans.editor.DocumentContent$Edit.undo(DocumentContent.java:400) at org.netbeans.editor.BaseDocumentEvent.undo(BaseDocumentEvent.java:262) at org.netbeans.editor.GuardedDocumentEvent.undo(GuardedDocumentEvent.java:47) at javax.swing.undo.CompoundEdit.undo(CompoundEdit.java:46) at javax.swing.undo.CompoundEdit.undo(CompoundEdit.java:46) at org.netbeans.modules.xml.xam.AbstractModel$ModelUndoableEdit.undo(AbstractModel.java:555) at javax.swing.undo.UndoManager.undoTo(UndoManager.java:320) at javax.swing.undo.UndoManager.undo(UndoManager.java:398) at org.netbeans.modules.xml.refactoring.XMLRefactoringTransaction.rollback(XMLRefactoringTransaction.java:118) at org.netbeans.modules.refactoring.api.RefactoringSession.undoRefactoring(RefactoringSession.java:132) at org.netbeans.modules.refactoring.spi.impl.UndoManager$SessionUndoItem.undo(UndoManager.java:508) at org.netbeans.modules.refactoring.spi.impl.UndoManager.undo(UndoManager.java:174) at org.netbeans.modules.refactoring.spi.impl.UndoAction.performAction(UndoAction.java:74) at org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:96) at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.actionPerformed(ActionsBridge.java:89) at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:82) at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:30) at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.doRun(ActionsBridge.java:80) at org.netbeans.modules.openide.util.ActionsBridge$1.run(ActionsBridge.java:49) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:539) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:964)
In addition after exception one is unable to manipulate Attributes, all items in context menu for Attributes are disabled. Reopening document helps.
One more note: if exception appear, one going to close document and choose "Discard" in saving prompt then after reopening there is one Attribute in source code view and all removed attributes in schema view. In my case I have three attributes with same name newAttribute1.
Created attachment 43880 [details] Screenshot for last note
It's me again... I'm trying to remove "restored" attributes using Context menu -> Delete. First attribute removed successfully, second one doesn't want to be removed: java.lang.AssertionError at org.netbeans.modules.xml.xdm.XDMModel.mutate(XDMModel.java:328) at org.netbeans.modules.xml.xdm.XDMModel.mutate(XDMModel.java:313) at org.netbeans.modules.xml.xdm.XDMModel.remove(XDMModel.java:670) at org.netbeans.modules.xml.xdm.xam.XDMAccess.removeChild(XDMAccess.java:273) at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChild(AbstractDocumentComponent.java:468) at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:280) at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.removeChildQuietly(AbstractDocumentComponent.java:52) at org.netbeans.modules.xml.xam.AbstractComponent._removeChildQuietly(AbstractComponent.java:104) at org.netbeans.modules.xml.xam.AbstractComponent.removeChild(AbstractComponent.java:339) at org.netbeans.modules.xml.schema.model.impl.SchemaImpl.removeAttribute(SchemaImpl.java:147) at org.netbeans.modules.xml.schema.model.impl.xdm.SyncUpdateVisitor.visit(SyncUpdateVisitor.java:99) at org.netbeans.modules.xml.schema.model.impl.GlobalAttributeImpl.accept(GlobalAttributeImpl.java:49) at org.netbeans.modules.xml.schema.model.impl.xdm.SyncUpdateVisitor.update(SyncUpdateVisitor.java:63) at org.netbeans.modules.xml.schema.model.impl.xdm.SyncUpdateVisitor.update(SyncUpdateVisitor.java:51) at org.netbeans.modules.xml.schema.model.impl.xdm.SyncUpdateVisitor.update(SyncUpdateVisitor.java:34) at org.netbeans.modules.xml.xam.dom.AbstractDocumentModel.removeChildComponent(AbstractDocumentModel.java:391) at org.netbeans.modules.xml.refactoring.spi.SharedUtils.deleteTarget(SharedUtils.java:127) at org.netbeans.modules.xml.refactoring.XMLRefactoringTransaction.doRefactorTarget(XMLRefactoringTransaction.java:253) at org.netbeans.modules.xml.refactoring.XMLRefactoringTransaction.process(XMLRefactoringTransaction.java:169) at org.netbeans.modules.xml.refactoring.XMLRefactoringTransaction.commit(XMLRefactoringTransaction.java:93) at org.netbeans.modules.refactoring.api.RefactoringSession.doRefactoring(RefactoringSession.java:91) at org.netbeans.modules.refactoring.spi.impl.ParametersPanel$8.run(ParametersPanel.java:334) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:539) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:964)
*** Issue 107028 has been marked as a duplicate of this issue. ***
*** Issue 107012 has been marked as a duplicate of this issue. ***
*** Issue 106996 has been marked as a duplicate of this issue. ***
The problem is coming that the schema document is changed after doing a Refactor -> Delete . When the Refactor -> undo is called, the Refactoring framework has changes that are no longer valid since their positions in the schema document has changed as the user edited the document. In such cases, the Refactor -> undo and Refactor -> redo should be deleted. Am looking into how to deactivate these options.
*** Issue 106641 has been marked as a duplicate of this issue. ***
Implemented getPositionBounds so that the refactoring framework can attach listeners to documents and deactivate the undo/redo options if document participating in refactoring has changed. Fixed in build #1177
Works. There are still issues with deleting different ways (Refactor + Source Code) so I'll file another issue.