### Eclipse Workspace Patch 1.0
#P org.jboss.tools.jsf.vpe.jsf
Index: src/org/jboss/tools/jsf/vpe/jsf/template/selectitem/AbstractCheckboxSelectItemTemplate.java
===================================================================
--- src/org/jboss/tools/jsf/vpe/jsf/template/selectitem/AbstractCheckboxSelectItemTemplate.java	(revision 41883)
+++ src/org/jboss/tools/jsf/vpe/jsf/template/selectitem/AbstractCheckboxSelectItemTemplate.java	(working copy)
@@ -28,10 +28,6 @@
 abstract public class AbstractCheckboxSelectItemTemplate extends AbstractSelectItemTemplate {
 
 	private static final String TYPE_CHECKBOX = "checkbox"; //$NON-NLS-1$
-
-	// style of span
-	private static final String SPAN_STYLE_VALUE = "-moz-user-modify: read-write;"; //$NON-NLS-1$
-
 	private String dir;
 	private String disabled;
 	private String enabledClass;
@@ -51,38 +47,33 @@
 			nsIDOMDocument visualDocument) {
 
 		readParentAttributes(sourceNode.getParentNode());
-
 		Element element = (Element) sourceNode;
 
 		nsIDOMElement input = visualDocument.createElement(HTML.TAG_INPUT);
 		nsIDOMElement label = visualDocument.createElement(HTML.TAG_LABEL);
-		// create span element
-		nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+		/*
+		 * https://issues.jboss.org/browse/JBIDE-8062
+		 * Put into DIV to allow focus in it's itemLabel
+		 */
+		nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+		VpeCreationData creationData = new VpeCreationData(div);
 
-		VpeCreationData creationData = new VpeCreationData(span);
-
-		// add title attribute to span
-		span.setAttribute(HTML.ATTR_TITLE, getTitle(sourceNode));
-		span.setAttribute(HTML.ATTR_STYLE, SPAN_STYLE_VALUE);
-
+		// add title attribute to div
+		div.setAttribute(HTML.ATTR_TITLE, getTitle(sourceNode));
 		input.setAttribute(HTML.ATTR_TYPE, TYPE_CHECKBOX);
 
 		if (attrPresents(dir)) {
 			input.setAttribute(HTML.ATTR_DIR, dir);
 		}
-
 		if (attrPresents(disabled) && Constants.TRUE.equalsIgnoreCase(disabled)) { 
 			label.setAttribute(HTML.ATTR_CLASS, disabledClass);
 		} else if (attrPresents(enabledClass)) {
 			label.setAttribute(HTML.ATTR_CLASS, enabledClass);
 		}
+		div.appendChild(input);
+		div.appendChild(label);
 
-		span.appendChild(input);
-		span.appendChild(label);
-
-		processOutputAttribute(pageContext, visualDocument, element, label,
-				creationData);
-
+		processOutputAttribute(pageContext, visualDocument, element, label, creationData);
 		return creationData;
 	}
 
#P org.jboss.tools.vpe
Index: src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- src/org/jboss/tools/vpe/editor/VpeController.java	(revision 41883)
+++ src/org/jboss/tools/vpe/editor/VpeController.java	(working copy)
@@ -146,6 +146,7 @@
 import org.mozilla.interfaces.nsIDOMMutationEvent;
 import org.mozilla.interfaces.nsIDOMNSUIEvent;
 import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMRange;
 import org.mozilla.interfaces.nsIDOMWindow;
 import org.mozilla.interfaces.nsIDOMWindowInternal;
 import org.mozilla.interfaces.nsISelection;
@@ -884,7 +885,30 @@
 				VpeDebugUtil.printVisualEvent(mutationEvent);
 			}
 	}
-
+	
+	private String getVisualSelectionText(nsISelection selection) {
+		String result = null;
+		if (selection != null && selection.getRangeCount() > 0) {
+			nsIDOMRange firstSelectedRange = selection.getRangeAt(0);
+			nsIDOMNode selectedNode = selection.getFocusNode();
+			if (selectedNode.getNodeName().equals("#text")) { //$NON-NLS-1$
+				int startOffset = firstSelectedRange.getStartOffset();
+				int endOffset = firstSelectedRange.getEndOffset();
+				int beginIndex, endIndex;
+				if (startOffset > endOffset) {
+					beginIndex = endOffset;
+					endIndex = startOffset;
+				} else {
+					beginIndex = startOffset;
+					endIndex = endOffset;
+				}
+				result = selectedNode.getNodeValue()
+						.substring(beginIndex, endIndex);  
+			}
+		}
+		return result;
+	}
+	
 	public void notifySelectionChanged(nsIDOMDocument doc,
 		nsISelection selection, short reason) {
 		if (!visualSelectionIsAlreadyInProgress) {
@@ -911,8 +935,19 @@
 				 * <select> node to be selected on the first click.
 				 */
 				if (node != null) {
+					int anchorOffset = selection.getAnchorOffset();
+					int focusOffset = selection.getFocusOffset();
+					/*
+					 * https://issues.jboss.org/browse/JBIDE-8062
+					 * Correct automatic selection after several clicks
+					 * in the mozilla editor.
+					 */
+					String text = getVisualSelectionText(selection);
+					if (text == null || text.length() == 0) {
+						focusOffset = anchorOffset;
+					}
 					selectionManager.setSelection(SelectionUtil.getSelectedNode(selection),
-							selection.getFocusOffset(), selection.getAnchorOffset());
+							focusOffset, anchorOffset);
 				}
 			}
 			// enables cursor on selection event
@@ -1764,13 +1799,13 @@
 					visualBuilder.rebuildDom(null);
 				}
 				// reinits selection controller+ controller
-				visualSelectionController = new VpeSelectionController(visualEditor
-						.getEditor().getSelectionController());
-	
+				visualSelectionController = new VpeSelectionController(
+						visualEditor.getEditor().getSelectionController());	
+				
 				visualSelectionController.setSelectionFlags(nsISelectionDisplay.DISPLAY_ALL);
-	
-				selectionManager = new SelectionManager(pageContext, sourceEditor,
-						visualSelectionController);
+				
+				selectionManager = new SelectionManager(
+						pageContext, sourceEditor, visualSelectionController);
 				// selection should be restored after full refresh
 				selectionManager.refreshVisualSelection();
 	
Index: src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
--- src/org/jboss/tools/vpe/editor/template/SelectionManager.java	(revision 41883)
+++ src/org/jboss/tools/vpe/editor/template/SelectionManager.java	(working copy)
@@ -125,7 +125,7 @@
 		refreshVisualNodeSelection();
 		setUpdateSelectionEventFlag(false);
 	}
-
+	
 	private SelectionData getSelectionData(nsIDOMNode visualNode) {
 		// get element mapping
 		VpeNodeMapping nodeMapping = VpeNodesManagingUtil.getNodeMapping(
@@ -227,9 +227,9 @@
 		if (range == null) {
 			return;
 		}
-		
 		VpeNodeMapping nodeMapping = SelectionUtil
-				.getNodeMappingBySourceSelection(getSourceEditor(),	getDomMapping());
+				.getNodeMappingBySourceSelection(
+						getSourceEditor(), getDomMapping());
 		if (nodeMapping == null) {
 			return;
 		}
