Author: sdzmitrovich
Date: 2008-08-29 07:54:52 -0400 (Fri, 29 Aug 2008)
New Revision: 9960
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/selbar/SelectionBar.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1972
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-08-29
11:49:07 UTC (rev 9959)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SelectionUtil.java 2008-08-29
11:54:52 UTC (rev 9960)
@@ -62,7 +62,24 @@
}
return null;
}
+
+ /**
+ * select node completely
+ * @param pageContext
+ * @param node
+ */
+ public static void setSourceSelection(VpePageContext pageContext, Node node) {
+ int start = NodesManagingUtil.getStartOffsetNode(node);
+ int length = NodesManagingUtil.getNodeLength(node);
+
+ pageContext.getSourceBuilder().getStructuredTextViewer()
+ .setSelectedRange(start, length);
+ pageContext.getSourceBuilder().getStructuredTextViewer().revealRange(
+ start, length);
+
+ }
+
/**
*
* @param pageContext
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2008-08-29
11:49:07 UTC (rev 9959)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/selbar/SelectionBar.java 2008-08-29
11:54:52 UTC (rev 9960)
@@ -31,7 +31,6 @@
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.attribute.adapter.AdapterFactory;
@@ -42,6 +41,7 @@
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelectionBuilder;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.w3c.dom.Node;
@@ -248,7 +248,7 @@
return;
}
Rectangle r = selBar.getItem(allItems - 1).getBounds();
- int width = r.x + r.width;
+ int width = r.x + r.width +1;
int height = r.height;
if (allItems >= itemCount) {
@@ -300,20 +300,14 @@
public void widgetSelected(SelectionEvent e) {
ToolItem toolItem = (ToolItem) e.widget;
- int offset = ((ElementImpl) toolItem.getData()).getStartOffset();
- setSourceFocus(offset);
+
+ SelectionUtil.setSourceSelection(vpeController.getPageContext(),
+ (Node) toolItem.getData());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
- private void setSourceFocus(int offset) {
- vpeController.getPageContext().getSourceBuilder()
- .getStructuredTextViewer().setSelectedRange(offset, 0);
- vpeController.getPageContext().getSourceBuilder()
- .getStructuredTextViewer().revealRange(offset, 0);
- }
-
/**
* Performs storing model object in the model and xml file.
*