[jbosstools-commits] JBoss Tools SVN: r9249 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jul 23 10:59:06 EDT 2008


Author: estherbin
Date: 2008-07-23 10:59:06 -0400 (Wed, 23 Jul 2008)
New Revision: 9249

Modified:
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java
Log:
Fixed no worked selection https://jira.jboss.com:8443/jira/browse/JBIDE-2010

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java	2008-07-23 14:34:11 UTC (rev 9248)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java	2008-07-23 14:59:06 UTC (rev 9249)
@@ -186,4 +186,28 @@
         return rst;
     }
 
+
+    /**
+     * Reverse replace.
+     * 
+     * @param resourceFile the resource file
+     * @param replacedString the replaced string
+     * 
+     * @return the string
+     */
+    public String reverseReplace(IFile resourceFile, String replacedString) {
+        String str = replacedString;
+
+        final ResourceReference[] references = ELReferenceList.getInstance().getAllResources(resourceFile);
+
+        if ((references != null) && (references.length > 0)) {
+            for (ResourceReference rf : references) {
+                if (replacedString.contains(rf.getProperties())) {
+                    str = str.replace(rf.getProperties(), rf.getLocation());
+                }
+            }
+        }
+        return str;
+    }
+
 }

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java	2008-07-23 14:34:11 UTC (rev 9248)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java	2008-07-23 14:59:06 UTC (rev 9249)
@@ -26,6 +26,17 @@
      * @return string where el values was substituted.
      */
     String replaceEl(IFile resourceFile, String resourceString);
+    
+    
+    /**
+     * Reverse replace.
+     * 
+     * @param resourceFile the resource file
+     * @param replacedString the replaced string
+     * 
+     * @return the string
+     */
+    String reverseReplace(IFile resourceFile,String replacedString);
 
     /**
      * Checks if is available.

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-23 14:34:11 UTC (rev 9248)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java	2008-07-23 14:59:06 UTC (rev 9249)
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.swt.graphics.Point;
@@ -75,8 +76,17 @@
 
 		int start = NodesManagingUtil.getStartOffsetNode(node);
 
-		pageContext.getSourceBuilder().getStructuredTextViewer()
-				.setSelectedRange(start + offset, length);
+		//added by estherbin fix bug JBIDE-2010 with selection.
+        if (start == 0 || start == 1) {
+            final IFile file = pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+            
+            if (file != null) {
+                final String findString = ElService.getInstance().reverseReplace(file, node.getNodeValue());
+                
+                start = pageContext.getSourceBuilder().getStructuredTextViewer().getTextWidget().getText().indexOf(findString);
+            }
+        }
+		pageContext.getSourceBuilder().getStructuredTextViewer().setSelectedRange(start + offset, length);
 		pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
 				start + offset, length);
 




More information about the jbosstools-commits mailing list