Author: mareshkau
Date: 2008-07-21 09:09:37 -0400 (Mon, 21 Jul 2008)
New Revision: 9193
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
Log:
JBIDE-2219
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-07-21
13:00:18 UTC (rev 9192)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-07-21
13:09:37 UTC (rev 9193)
@@ -2,6 +2,8 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -232,6 +234,13 @@
*/
final public void refreshVisualSelection() {
//TODO Max Areshkau Adjust for restoring cursor position
+ IStructuredModel model = null;
+
+ try {
+ //gets source model for read, model should be released see JBIDE-2219
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(getSourceEditor().getTextViewer().getDocument());
+
Point range = SelectionUtil.getSourceSelectionRange(getSourceEditor());
ISelection selection = getSourceEditor().getTextViewer().getSelection();
@@ -245,8 +254,7 @@
// get element mapping
VpeNodeMapping nodeMapping = SelectionUtil
- .getNodeMappingBySourceSelection(NodesManagingUtil
- .getStructuredModel(getSourceEditor()),
+ .getNodeMappingBySourceSelection(model,
getDomMapping(), focusOffcetInSourceDocument, anchorOffcetInSourceDocument);
if (nodeMapping == null)
@@ -255,8 +263,7 @@
// visual node which will be selected
nsIDOMNode targetVisualNode;
- IndexedRegion targetSourceNode = (IndexedRegion)
SelectionUtil.getSourceNodeByPosition(NodesManagingUtil
- .getStructuredModel(getSourceEditor()), focusOffcetInSourceDocument);
+ IndexedRegion targetSourceNode = (IndexedRegion)
SelectionUtil.getSourceNodeByPosition(model, focusOffcetInSourceDocument);
int offcetReferenceToSourceNode =
focusOffcetInSourceDocument-targetSourceNode.getStartOffset();
@@ -278,6 +285,11 @@
//here we restore only highlight
getPageContext().getVisualBuilder().setSelectionRectangle(
targetVisualNode);
+ } finally {
+ if(model!=null) {
+ model.releaseFromRead();
+ }
+ }
// //TODO Max Areshkau now it's workd only for simple text, and should be adjusted
// targetVisualNode = targetVisualNode.getFirstChild();
// int visualNodeOffcet =
TextUtil.visualPosition(((Node)targetSourceNode).getNodeValue(),offcetReferenceToSourceNode);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2008-07-21
13:00:18 UTC (rev 9192)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2008-07-21
13:09:37 UTC (rev 9193)
@@ -219,21 +219,25 @@
static private IDOMDocument getDocument(IFile file) {
IDOMDocument document = null;
-
+
+ IDOMModel model = null;
+
if (file != null) {
try {
// get model
- IDOMModel model = (IDOMModel) StructuredModelManager
- .getModelManager().getModelForRead(file);
+ model = (IDOMModel) StructuredModelManager
+ .getModelManager().getExistingModelForRead(file);
if (model != null)
document = model.getDocument();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (CoreException e) {
- e.printStackTrace();
+ } finally {
+ //see JBIDE-2219
+ if(model!=null) {
+
+ model.releaseFromRead();
+ }
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-07-21
13:00:18 UTC (rev 9192)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-07-21
13:09:37 UTC (rev 9193)
@@ -1,10 +1,6 @@
package org.jboss.tools.vpe.editor.util;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
@@ -58,20 +54,6 @@
/**
*
- * @param sourceEditor
- * @return
- */
- public static IStructuredModel getStructuredModel(
- StructuredTextEditor sourceEditor) {
-
- IDocument document = sourceEditor.getTextViewer().getDocument();
-
- return StructuredModelManager.getModelManager()
- .getExistingModelForEdit(document);
- }
-
- /**
- *
* @param node
* @return
*/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2008-07-21
13:00:18 UTC (rev 9192)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2008-07-21
13:09:37 UTC (rev 9193)
@@ -192,10 +192,13 @@
Point range = sourceEditor.getTextViewer().getSelectedRange();
IDocument document = sourceEditor.getTextViewer().getDocument();
+
+ IStructuredModel model =null;
+
+ try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
- IStructuredModel model = StructuredModelManager.getModelManager()
- .getExistingModelForEdit(document);
-
int anchor = range.x;
int focus = range.x + range.y;
@@ -222,6 +225,14 @@
return NodesManagingUtil.getNodeMapping(domMapping, focusNode);
}
+ } finally {
+
+ if(model!=null) {
+
+ model.releaseFromRead();
+ }
+ }
+
return null;
}
@@ -238,7 +249,6 @@
* @return sourceSelectionRange
*/
static public Point getSourceSelectionRange(StructuredTextEditor sourceEditor) {
-
ITextViewer textViewer = sourceEditor.getTextViewer();
if (textViewer != null)
Show replies by date