Problems with IDOMDocument [message #155464] |
Mon, 09 January 2006 11:06 |
Eclipse User |
|
|
|
Hello,
I am creating a plugin on top of the WTP-Project. It's really amazing
how many features the project have ;-) Thanks to all the developers...
By testing this plugin I realized following curiosity...
If I open a xml file, close the xml file, open the xml file again and
add a node to the IDOMDocument, the underlying document does not include
the added node.
Does I make something wrong, or is this a bug...
I'am using Eclipse 3.2.0 and WTP 1.0...
I tested it with that code:
IEditorPart editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
IDocument document =
textEditor.getDocumentProvider().getDocument(textEditor.getE ditorInput());
//add node
IStructuredModel model =
StructuredModelManager.getModelManager().getExistingModelFor Edit(document);
if (model==null)
model =
StructuredModelManager.getModelManager().getModelForEdit((IS tructuredDocument)document);
IDOMDocument domDocument = ((IDOMModel)model).getDocument();
Node testNode = domDocument.createElement("test");
domDocument.getDocumentElement().appendChild(testNode);
model.releaseFromEdit();
//get offset of node
IDOMElement testNodeElement = (IDOMElement) testNode;
int start = testNodeElement.getStartOffset();
int end = testNodeElement.getEndOffset();
//test if node is in document
assertEquals(testNodeElement.getSource(), document.get(start, end-start));
|
|
|
Powered by
FUDForum. Page generated in 0.02079 seconds