Author: mareshkau
Date: 2008-07-16 14:21:29 -0400 (Wed, 16 Jul 2008)
New Revision: 9156
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2505
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-16
15:19:39 UTC (rev 9155)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-07-16
18:21:29 UTC (rev 9156)
@@ -14,7 +14,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -142,6 +141,7 @@
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.VpeDndUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.selbar.SelectionBar;
@@ -289,15 +289,8 @@
sourceEditor, visualSelectionController);
keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
- pageContext);
+ pageContext,visualSelectionController);
- // visualKeyHandler = new VpeVisualKeyHandler(sourceEditor, domMapping,
- // pageContext) {
- // public void doSave(IProgressMonitor monitor) {
- // editPart.doSave(monitor);
- // }
- // };
-
// glory
ISelectionProvider provider = sourceEditor.getSelectionProvider();
// Max Areshkau JBIDE-1105 If selection event received after selection
@@ -1026,7 +1019,7 @@
mouseUpSelectionReasonFlag = (reason & nsISelectionListener.MOUSEUP_REASON) >
0;
if (mouseUpSelectionReasonFlag
|| reason == nsISelectionListener.NO_REASON
-// || reason == nsISelectionListener.KEYPRESS_REASON
+ || reason == nsISelectionListener.KEYPRESS_REASON
|| reason == nsISelectionListener.SELECTALL_REASON
|| (reason & nsISelectionListener.MOUSEDOWN_REASON) > 0) {
@@ -1241,7 +1234,7 @@
}
try {
- if (/* visualKeyHandler.keyPressHandler(keyEvent) */keyEventHandler
+ if (keyEventHandler
.handleKeyPress(keyEvent)) {
switcher
.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
@@ -2987,7 +2980,13 @@
}
return includeList;
}
-
+
+ /**
+ * Processed selection events from source editor,
+ * if reason of selection is visial editor,
+ * selection will be stopped processing by
+ * this condition (!switcher.startActiveEditor)
+ */
public void selectionChanged(SelectionChangedEvent event) {
// FIX for JBIDE-2114
if (!isVisualEditorVisible()) {
@@ -3009,6 +3008,7 @@
return;
}
try {
+
if (VpeDebug.PRINT_SOURCE_SELECTION_EVENT) {
System.out
.println(">>>>>>>>>>>>>>
selectionChanged " + event.getSource()); //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-07-16
15:19:39 UTC (rev 9155)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/KeyEventManager.java 2008-07-16
18:21:29 UTC (rev 9156)
@@ -10,10 +10,13 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
+import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.mozilla.interfaces.nsIDOMKeyEvent;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsISelection;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -40,12 +43,18 @@
* page context
*/
private VpePageContext pageContext;
-
+
+ /**
+ * selection controller
+ */
+ private VpeSelectionController selectionController;
+
public KeyEventManager(StructuredTextEditor sourceEditor,
- VpeDomMapping domMapping, VpePageContext pageContext) {
+ VpeDomMapping domMapping, VpePageContext pageContext, VpeSelectionController
selectionController) {
this.sourceEditor = sourceEditor;
this.domMapping = domMapping;
this.pageContext = pageContext;
+ setSelectionController(selectionController);
}
final public boolean handleKeyPress(nsIDOMKeyEvent keyEvent) {
@@ -389,8 +398,16 @@
* @return whether handled event
*/
protected boolean handleRight(nsIDOMKeyEvent keyEvent) {
+
+ getSelectionController().setCaretEnabled(true);
+
+ nsISelection selection = getSelectionController().getSelection((short)1);
+ nsIDOMNode node = selection.getAnchorNode();
+
+ VpeDebugUtil.debugInfo("Node name "+node.getNodeName()+"\n");
+ VpeDebugUtil.debugInfo("Node value "+node.getNodeValue()+"\n");
+
return false;
-
}
/**
@@ -479,4 +496,18 @@
return null;
}
+
+ /**
+ * @return the selectionController
+ */
+ private VpeSelectionController getSelectionController() {
+ return selectionController;
+ }
+
+ /**
+ * @param selectionController the selectionController to set
+ */
+ private void setSelectionController(VpeSelectionController selectionController) {
+ this.selectionController = selectionController;
+ }
}