Author: mareshkau
Date: 2009-02-11 14:01:48 -0500 (Wed, 11 Feb 2009)
New Revision: 13586
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/TextUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3650, problems with selection from visual panel
to source has been resolved
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 2009-02-11
17:28:23 UTC (rev 13585)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2009-02-11
19:01:48 UTC (rev 13586)
@@ -18,6 +18,7 @@
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.document.TextImpl;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
@@ -208,9 +209,11 @@
Point sourceRange = new Point(0, 0);
// converts to source selection
if ((sourceNode != null) && (sourceNode.getNodeValue() != null)) {
- sourceRange.x = TextUtil.sourcePosition(sourceNode.getNodeValue(),
+ //fix for JBIDE-3650
+ TextImpl textImpl = (TextImpl) sourceNode;
+ sourceRange.x = TextUtil.sourcePosition(textImpl.getSource(),
focusedNode.getNodeValue(), selection.getFocusOffset());
- sourceRange.y = TextUtil.sourcePosition(sourceNode.getNodeValue(),
+ sourceRange.y = TextUtil.sourcePosition(textImpl.getSource(),
focusedNode.getNodeValue(), selection.getAnchorOffset())
- sourceRange.x;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2009-02-11
17:28:23 UTC (rev 13585)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2009-02-11
19:01:48 UTC (rev 13586)
@@ -29,7 +29,7 @@
textSet.put(new Character('&'),"&"); //$NON-NLS-1$
textSet.put(new Character('<'),"<"); //$NON-NLS-1$
textSet.put(new Character('>'),">"); //$NON-NLS-1$
-// textSet.put(new Character(' ')," ");
+ textSet.put(new Character('\u00A0')," "); //$NON-NLS-1$
textSet.put(new Character('\u00A1'),"¡"); //$NON-NLS-1$
textSet.put(new Character('\u00A2'),"¢"); //$NON-NLS-1$
textSet.put(new Character('\u00A3'),"£"); //$NON-NLS-1$
@@ -43,6 +43,7 @@
textSet.put(new Character('\u00AB'),"«"); //$NON-NLS-1$
textSet.put(new Character('\u00AC'),"¬"); //$NON-NLS-1$
//textSet.put(new Character('\u00AD'),"­");
+ textSet.put(new Character('\u2022'), "•"); //$NON-NLS-1$
textSet.put(new Character('\u00AE'),"®"); //$NON-NLS-1$
textSet.put(new Character('\u00AF'),"¯"); //$NON-NLS-1$
textSet.put(new Character('\u00B0'),"°"); //$NON-NLS-1$
@@ -135,6 +136,7 @@
}
public static boolean containsKey(char key){
+
return textSet.containsKey(new Character(key));
}
@@ -227,11 +229,9 @@
// }
// return s3.length()+(sourceIndex-visualIndex);
// }
-
public static int sourcePosition(String sourceText, String visualText, int
visualPosition) {
int sourceIndex = 0;
int visualIndex = 0;
-
while (sourceIndex < sourceText.length() && visualIndex < visualPosition)
{
char sourceChar = sourceText.charAt(sourceIndex);
if (sourceChar == '\r') {