Author: yradtsevich
Date: 2010-03-05 12:52:57 -0500 (Fri, 05 Mar 2010)
New Revision: 20693
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/EditorLoadWindowListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaContextMenuListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaEventListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaKeyListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaMouseListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaResizeListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaSelectionListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaTooltipListener.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorLoadWindowListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
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/VpeEditorPart.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/PreviewDomEventListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
VPE Refactoring in progress.
- EditorDomEventListener has been splitted to several listeners (Mozilla*Listener).
- MozillaEventAdapter has been introduced (most of the code has been borrowed from former
MozillaDomEventListener).
- Some refactoring actions have been done (methods and calls moving, removing unnecessary
methods and calls).
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -13,8 +13,9 @@
import org.jboss.tools.vpe.editor.VpeController;
import org.jboss.tools.vpe.editor.VpeVisualCaretInfo;
-import org.jboss.tools.vpe.editor.mozilla.EditorDomEventListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaEventListener;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -145,31 +146,31 @@
* Calls when drag over event ocure
* @param event
*/
- public void dragOver(nsIDOMEvent event, EditorDomEventListener editorDomEventListener)
{
+ public void dragOver(nsIDOMEvent event, MozillaEventListener mozillaEventListener) {
final nsIDOMMouseEvent mouseEvent =
(nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- final XulRunnerEditor editor = ((VpeController)
editorDomEventListener).getXulRunnerEditor();
+ final XulRunnerEditor editor = ((VpeController)
mozillaEventListener).getXulRunnerEditor();
new ScrollingSupport(editor).scroll(mouseEvent);
- refreshCanDrop(event, editorDomEventListener);
+ refreshCanDrop(event, mozillaEventListener);
}
private void refreshCanDrop(nsIDOMEvent event,
- EditorDomEventListener editorDomEventListener) {
+ MozillaEventListener mozillaEventListener) {
boolean canDrop = true;
nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
//in this condition early was check for xulelement
- if (editorDomEventListener != null) {
+ if (mozillaEventListener != null) {
if
(getDragService().getCurrentSession().isDataFlavorSupported(VpeController.MODEL_FLAVOR))
{
MozillaDropInfo info;
if(getDragService().getCurrentSession().getSourceNode()==null){
//external drag
- info = editorDomEventListener.canExternalDrop(mouseEvent,
VpeController.MODEL_FLAVOR, ""); //$NON-NLS-1$
+ info = mozillaEventListener.canExternalDrop(mouseEvent,
VpeController.MODEL_FLAVOR, ""); //$NON-NLS-1$
} else {
//internal drag
- info = editorDomEventListener.canInnerDrop(mouseEvent);
+ info = mozillaEventListener.canInnerDrop(mouseEvent);
}
if (info != null) {
canDrop = info.canDrop();
@@ -178,7 +179,7 @@
}
//sets possability to drop current element here
//Added by estherbin fix jbide-1046
- VpeController controller = (VpeController) editorDomEventListener;
+ VpeController controller = (VpeController) mozillaEventListener;
VpeSelectionController selectionController =
controller.getVisualSelectionController();
final VpeVisualCaretInfo visualCaretInfo =
controller.getSelectionBuilder().getVisualCaretInfo(event);
@@ -208,7 +209,7 @@
* @param domEvent
* @param editorDomEventListener
*/
- public void dragDrop(nsIDOMEvent domEvent, EditorDomEventListener
editorDomEventListener) {
+ public void dragDrop(nsIDOMEvent domEvent, MozillaDndListener editorDomEventListener) {
if(editorDomEventListener!=null) {
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 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -13,6 +13,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -86,7 +87,6 @@
import org.jboss.tools.common.model.ui.editors.dnd.IDropCommand;
import org.jboss.tools.common.model.ui.editors.dnd.context.InnerDragBuffer;
import org.jboss.tools.common.model.ui.util.ModelUtilities;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.resref.core.ResourceReferenceListListener;
@@ -111,9 +111,9 @@
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.menu.VpeMenuCreator;
-import org.jboss.tools.vpe.editor.mozilla.EditorDomEventListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaEventListener;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.selection.VpeSelectionHelper;
import org.jboss.tools.vpe.editor.template.IKeyEventHandler;
@@ -152,7 +152,6 @@
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsISupportsCString;
import org.mozilla.interfaces.nsISupportsString;
-import org.mozilla.xpcom.Mozilla;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -160,7 +159,7 @@
public class VpeController implements INodeAdapter, IModelLifecycleListener,
INodeSelectionListener, ITextSelectionListener, SelectionListener,
- EditorDomEventListener, VpeTemplateListener, XModelTreeListener,
+ MozillaEventListener, VpeTemplateListener, XModelTreeListener,
ResourceReferenceListListener, ISelectionChangedListener,
IVisualController {
@@ -951,58 +950,61 @@
}
// EditorDomEventListener implementation
- public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
+// this method is never used
+// public void subtreeModified(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
- public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = mutationEvent.getRelatedNode();
- if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
- sourceBuilder.addNode(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
+// this method is never used
+// public void nodeInserted(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// nsIDOMNode targetNode = mutationEvent.getRelatedNode();
+// if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
+// sourceBuilder.addNode(targetNode);
+// visualBuilder.resetPseudoElement(targetNode);
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
- public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
- if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
- visualBuilder.setSelectionRectangle(null);
- sourceBuilder.removeNode(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
+// this method is never used
+// public void nodeRemoved(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
+// if (!VpeVisualDomBuilder.isAnonElement(targetNode)) {
+// visualBuilder.setSelectionRectangle(null);
+// sourceBuilder.removeNode(targetNode);
+// visualBuilder.resetPseudoElement(targetNode);
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
public void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent) {
if (!switcher
@@ -1017,52 +1019,54 @@
switcher.stopActiveEditor();
}
}
+// this method is never used
+// public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
- public void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
+// this method is never used
+// public void attrModified(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
- public void attrModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
+// this method is never used
+// public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
+// if (!switcher
+// .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
+// return;
+// }
+// try {
+// if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
+// printVisualEvent(mutationEvent);
+// }
+// nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
+// sourceBuilder.setText(targetNode);
+// visualBuilder.resetPseudoElement(targetNode);
+// } finally {
+// switcher.stopActiveEditor();
+// }
+// }
- public void characterDataModified(nsIDOMMutationEvent mutationEvent) {
- if (!switcher
- .startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL)) {
- return;
- }
- try {
- if (VpeDebug.PRINT_VISUAL_MUTATION_EVENT) {
- printVisualEvent(mutationEvent);
- }
- nsIDOMNode targetNode = VisualDomUtil.getTargetNode(mutationEvent);
- sourceBuilder.setText(targetNode);
- visualBuilder.resetPseudoElement(targetNode);
- } finally {
- switcher.stopActiveEditor();
- }
- }
-
public void notifySelectionChanged(nsIDOMDocument doc,
nsISelection selection, short reason) {
if (switcher
@@ -1383,6 +1387,7 @@
// }
}
}
+ onRefresh();
}
private boolean isZoomEvent(nsIDOMKeyEvent keyEvent) {
@@ -1469,6 +1474,7 @@
// true);
new VpeMenuCreator(menuManager, selectedSourceNode).createMenu();
contextMenu.setVisible(true);
+ onRefresh();
}
// VpeTemplateListener implementation
@@ -1985,22 +1991,25 @@
}
}
- public void dragEnter(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
- }
- }
+// this method is never used
+// public void dragEnter(nsIDOMEvent event) {
+// if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+// System.out.println("<<<<<<<<<<<<<<<<<<<<
DragEnter"); //$NON-NLS-1$
+// }
+// }
- public void dragExit(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
- }
- // TODO Sergey Vasilyev figure out with drag caret
- // xulRunnerEditor.hideDragCaret();
- }
+// this method is never used
+// public void dragExit(nsIDOMEvent event) {
+// if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+// System.out.println("<<<<<<<<<<<<<<<<<<<<
dragExit"); //$NON-NLS-1$
+// }
+// // TODO Sergey Vasilyev figure out with drag caret
+// // xulRunnerEditor.hideDragCaret();
+// }
public void dragOver(nsIDOMEvent event) {
visualBuilder.getDnd().dragOver(event, this);
+ onRefresh();
}
public void _dragOver(nsIDOMEvent event) {
@@ -2042,12 +2051,13 @@
}
}
- public void drop(nsIDOMEvent event) {
- if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
- System.out.println("<<< outerDrop"); //$NON-NLS-1$
- }
- event.preventDefault();
- }
+// this method is never used
+// public void drop(nsIDOMEvent event) {
+// if (VpeDebug.PRINT_VISUAL_DRAGDROP_EVENT) {
+// System.out.println("<<< outerDrop"); //$NON-NLS-1$
+// }
+// event.preventDefault();
+// }
public boolean canInnerDrag(nsIDOMMouseEvent event) {
onHideTooltip();
@@ -2677,68 +2687,71 @@
}
}
- // nsIClipboardDragDropHooks implementation
- public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor,
- String data) {
- onHideTooltip();
+// this method is never used
+// // nsIClipboardDragDropHooks implementation
+// public void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor,
+// String data) {
+// onHideTooltip();
+//
+// VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
+// .getInnerDropInfo(mouseEvent);
+// Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
+// visualDropInfo.getDropContainer(), (int) visualDropInfo
+// .getDropOffset());
+// VpeSourceInnerDropInfo sourceDropInfo = null;
+//
+// XModelObject object = PreferenceModelUtilities.getPreferenceModel()
+// .getModelBuffer().source();
+//
+// String tagname = getTagName(object);
+// if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
+// Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
+// .createElement(tagname);
+// if (visualDropInfo.getDropContainer() != null) {
+// sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
+// sourceDragNode, visualDropInfo, true);
+// range = selectionBuilder.getSourceSelectionRange(sourceDropInfo
+// .getContainer(), sourceDropInfo.getOffset());
+// }
+//
+// if (visualDropInfo.getDropContainer() != null) {
+// if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
+// System.out
+// .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
+// }
+// final String finalFlavor = flavor;
+// final String finalData = data;
+// final Point finalRange = range;
+// final Node finalDropContainer = sourceDropInfo == null ? null
+// : sourceDropInfo.getContainer();
+// Display.getDefault().asyncExec(new Runnable() {
+// public void run() {
+// externalDropAny(finalFlavor, finalData, finalRange,
+// finalDropContainer);
+// }
+// });
+// }
+// }
- VpeVisualInnerDropInfo visualDropInfo = selectionBuilder
- .getInnerDropInfo(mouseEvent);
- Point range = selectionBuilder.getSourceSelectionRangeAtVisualNode(
- visualDropInfo.getDropContainer(), (int) visualDropInfo
- .getDropOffset());
- VpeSourceInnerDropInfo sourceDropInfo = null;
-
- XModelObject object = PreferenceModelUtilities.getPreferenceModel()
- .getModelBuffer().source();
-
- String tagname = getTagName(object);
- if (tagname.indexOf("taglib") >= 0)tagname = "taglib";
//$NON-NLS-1$ //$NON-NLS-2$
- Node sourceDragNode = ((Document) getModel().getAdapter(Document.class))
- .createElement(tagname);
- if (visualDropInfo.getDropContainer() != null) {
- sourceDropInfo = visualBuilder.getSourceInnerDropInfo(
- sourceDragNode, visualDropInfo, true);
- range = selectionBuilder.getSourceSelectionRange(sourceDropInfo
- .getContainer(), sourceDropInfo.getOffset());
- }
-
- if (visualDropInfo.getDropContainer() != null) {
- if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" drop! container: " +
visualDropInfo.getDropContainer().getNodeName()); //$NON-NLS-1$
- }
- final String finalFlavor = flavor;
- final String finalData = data;
- final Point finalRange = range;
- final Node finalDropContainer = sourceDropInfo == null ? null
- : sourceDropInfo.getContainer();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- externalDropAny(finalFlavor, finalData, finalRange,
- finalDropContainer);
- }
- });
- }
- }
-
public void drop(Node node, Node parentNode, int offset) {
visualBuilder.innerDrop(node, parentNode, offset);
}
- /*
- * (non-Javadoc)
- *
- * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
- */
- public nsISupports queryInterface(String arg0) {
- return Mozilla.getInstance().queryInterface(this, arg0);
- }
+// this method is never used
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+// */
+// public nsISupports queryInterface(String arg0) {
+// return Mozilla.getInstance().queryInterface(this, arg0);
+// }
+
/**
- * Calls when editor content should be refreshed
+ * Calls when editor content changed, and we should highlight selected element.
*/
- public void onRefresh() {
+ private void onRefresh() {
// when we using separate thread to display selection rectangle
// it's working better than without
/*
@@ -2753,7 +2766,6 @@
getXulRunnerEditor().showSelectionRectangle();
}
});
-
}
/**
@@ -2781,6 +2793,7 @@
public void dragDrop(nsIDOMEvent domEvent) {
visualBuilder.getDnd().dragDrop(domEvent, this);
+ onRefresh();
}
/**
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -76,9 +76,9 @@
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.IVpeHelpContextIds;
import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.mozilla.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.mozilla.MozillaPreview;
+import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.util.ProjectNaturesChecker;
import org.jboss.tools.vpe.editor.xpl.CustomSashForm;
import org.jboss.tools.vpe.editor.xpl.EditorSettings;
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.mozilla;
-
-
-import org.mozilla.interfaces.nsIContextMenuListener;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMMutationEvent;
-import org.mozilla.interfaces.nsISelection;
-
-/**
- * TODO Split it up to several interfaces related to Mouse Events, DOM tree modification
events,
- * Selection events, etc.
- */
-
-public interface EditorDomEventListener extends nsIContextMenuListener {
-
- // nsIDOMMutationListener
- void subtreeModified(nsIDOMMutationEvent mutationEvent);
- void nodeInserted(nsIDOMMutationEvent mutationEvent);
- void nodeRemoved(nsIDOMMutationEvent mutationEvent);
- void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent);
- void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent);
- void attrModified(nsIDOMMutationEvent mutationEvent);
- void characterDataModified(nsIDOMMutationEvent mutationEvent);
- void notifySelectionChanged(nsIDOMDocument domDocument, nsISelection selection, short
reason);
- void mouseDown(nsIDOMMouseEvent mouseEvent);
- void mouseUp(nsIDOMMouseEvent mouseEvent);
- void mouseClick(nsIDOMMouseEvent mouseEvent);
- void mouseDblClick(nsIDOMMouseEvent mouseEvent);
- void mouseMove(nsIDOMMouseEvent mouseEvent);
- void keyPress(nsIDOMKeyEvent keyEvent);
- void elementResized(nsIDOMElement element, int resizerConstrains, int top, int left, int
width, int height);
-
- void dragEnter(nsIDOMEvent event);
- void dragExit(nsIDOMEvent event);
- void dragOver(nsIDOMEvent event);
- void drop(nsIDOMEvent event);
- /**
- * Drag gesture event handler
- * @param event xulrunner drag event
- */
- void dragGesture(nsIDOMEvent event);
-
- boolean canInnerDrag(nsIDOMMouseEvent mouseEvent);
- MozillaDropInfo canInnerDrop(nsIDOMMouseEvent mouseEvent);
- void innerDrop(nsIDOMMouseEvent mouseEvent);
-
- MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String
data);
- void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data);
-
- void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data);
-
- void onShowTooltip(int x, int y, String text);
- void onHideTooltip();
- /**
- * Calls when editor content changed, and we should highlight selected element.
- */
- void onRefresh();
- void startDragSession(nsIDOMEvent domEvent);
-
- /**
- * Calls when drop event occures
- * @param domEvent
- */
- void dragDrop(nsIDOMEvent domEvent);
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorLoadWindowListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorLoadWindowListener.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorLoadWindowListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.mozilla;
-
-public interface EditorLoadWindowListener {
- void load();
-}
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.editor.mozilla;
-
-import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDOMEventListener;
-import org.mozilla.interfaces.nsIDOMKeyEvent;
-import org.mozilla.interfaces.nsIDOMMouseEvent;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDragSession;
-import org.mozilla.interfaces.nsISelection;
-import org.mozilla.interfaces.nsISelectionListener;
-import org.mozilla.interfaces.nsISupports;
-import org.mozilla.interfaces.nsITransferable;
-import org.mozilla.xpcom.Mozilla;
-
-
-class MozillaDomEventListener implements nsIDOMEventListener, nsISelectionListener {
-
- private XulRunnerEditor visualEditor;
-
- private EditorDomEventListener editorDomEventListener;
-
- //possible events
- public static final String MOZAFTERPAINT = "MozAfterPaint"; //$NON-NLS-1$
-
- public static final String SCROLL = "scroll"; //$NON-NLS-1$
-
- public static final String MOUSEMOVEEVENTTYPE="mousemove"; //$NON-NLS-1$
-
- public static final String MOUSEDOWNEVENTTYPE="mousedown"; //$NON-NLS-1$
-
- public static final String MOUSEUPEVENTTYPE="mouseup"; //$NON-NLS-1$
-
- public static final String CLICKEVENTTYPE="click"; //$NON-NLS-1$
-
- public static final String KEYPRESS="keypress"; //$NON-NLS-1$
-
- public static final String DBLCLICK="dblclick"; //$NON-NLS-1$
-
- public static final String CONTEXTMENUEVENTTYPE="contextmenu"; //$NON-NLS-1$
-
- public static final String DRAGGESTUREEVENT = "draggesture"; //$NON-NLS-1$
-
- public static final String DRAGOVEREVENT = "dragover"; //$NON-NLS-1$
-
- public static final String DRAGDROPEVENT = "dragdrop"; //$NON-NLS-1$
-
- public static final String DRAGENTEREVENT = "dragenter"; //$NON-NLS-1$
-
- public static final String DRAGEXITEVENT = "dragexit"; //$NON-NLS-1$
-
-
- void setEditorDomEventListener(EditorDomEventListener listener) {
- editorDomEventListener = listener;
- }
-
-
- /**
- * Returns event handler
- * @return
- */
- private EditorDomEventListener getEditorDomEventListener(){
-
- return editorDomEventListener;
- }
-
-
-
- boolean isXulElement(nsIDOMMouseEvent mouseEvent) {
- // TODO Sergey Vasilyev figure out with getTmpRealOriginalTarget
-// nsIDOMNSEvent nsEvent =
(nsIDOMNSEvent)mouseEvent.queryInterface(nsIDOMNSEvent.NS_IDOMNSEVENT_IID);
-// nsIDOMEventTarget target = nsEvent.getTmpRealOriginalTarget();
-// int aDragNode = target.queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
-// nsIDOMNode originalNode = nsIDOMNode.getNodeAtAddress(aDragNode);
-// String prefix = originalNode.getPrefix();
-// boolean isXul = "XUL".equalsIgnoreCase(prefix);
-// target.Release();
-// nsEvent.Release();
- return false;
- }
-
-
-
- void setVisualEditor(XulRunnerEditor visualEditor) {
- this.visualEditor = visualEditor;
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#onPasteOrDrop(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsITransferable)
- */
- public boolean onPasteOrDrop(nsIDOMEvent event, nsITransferable transferable) {
- nsIDOMMouseEvent mouseEvent =
(nsIDOMMouseEvent)event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
-
- if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
- nsIDragSession dragSession = visualEditor.getCurrentDragSession();
- if (dragSession.isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
- editorDomEventListener.onPasteOrDrop(mouseEvent, VpeController.MODEL_FLAVOR,
""); //$NON-NLS-1$
- }
- }
- mouseEvent.preventDefault();
- mouseEvent.stopPropagation();
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
- */
- public nsISupports queryInterface(String arg0) {
- return Mozilla.queryInterface(this, arg0);
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsIDOMEventListener#handleEvent(org.mozilla.interfaces.nsIDOMEvent)
- */
- public void handleEvent(nsIDOMEvent domEvent) {
-
- if(getEditorDomEventListener() != null) {
- final String eventType = domEvent.getType();
- if(MOUSEMOVEEVENTTYPE.equals(eventType)) {
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseMove(mouseEvent);
- } else if(MOUSEDOWNEVENTTYPE.equals(eventType)) {
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseDown(mouseEvent);
- } else if(MOUSEUPEVENTTYPE.equals(eventType)) {
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseUp(mouseEvent);
- } else if(CLICKEVENTTYPE.equals(eventType)) {
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseClick(mouseEvent);
- } else if(DBLCLICK.equals(eventType)) {
- nsIDOMMouseEvent mouseEvent;
- mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- getEditorDomEventListener().mouseDblClick(mouseEvent);
- } else if(KEYPRESS.equals(eventType)) {
- nsIDOMKeyEvent keyEvent = (nsIDOMKeyEvent)
domEvent.queryInterface(nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID);
- getEditorDomEventListener().keyPress(keyEvent);
- } else if(CONTEXTMENUEVENTTYPE.equals(eventType)) {
- //first param are null 0, because this not used in event handler
- getEditorDomEventListener().onShowContextMenu(0, domEvent, (nsIDOMNode)
domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID));
- } else if(DRAGGESTUREEVENT.equals(eventType)) {
- // fix of JBIDE-4998: since drag events now are implemented by
- // handling CLICKEVENTTYPE, there is no need to handle them here
- // if(getEditorDomEventListener()!=null) {
- // getEditorDomEventListener().dragGesture(domEvent);
- // }
- } else if(DRAGDROPEVENT.equals(eventType)) {
- // calls when drop event occure
- getEditorDomEventListener().dragDrop(domEvent);
- domEvent.stopPropagation();
- domEvent.preventDefault();
- } else if(DRAGENTEREVENT.equals(eventType)) {
- //just ignore this event
- } else if(DRAGEXITEVENT.equals(eventType)) {
- //just ignore this event
- } else if(DRAGOVEREVENT.equals(eventType)) {
- getEditorDomEventListener().dragOver(domEvent);
- }
-
- getEditorDomEventListener().onRefresh();
- }
- }
-
- /* (non-Javadoc)
- * @see
org.mozilla.interfaces.nsISelectionListener#notifySelectionChanged(org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsISelection, short)
- */
- public void notifySelectionChanged(nsIDOMDocument domDocument, nsISelection selection,
short reason) {
- if (editorDomEventListener != null) {
- editorDomEventListener.notifySelectionChanged(domDocument, selection, reason);
- }
- }
-}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -60,6 +61,8 @@
import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaEventListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPage;
import org.jboss.tools.vpe.editor.toolbar.IVpeToolBarManager;
import org.jboss.tools.vpe.editor.toolbar.VpeDropDownMenu;
@@ -116,11 +119,10 @@
private nsIDOMEventTarget documentEventTarget;
private nsIDOMElement contentArea;
private nsIDOMNode headNode;
- private nsIDOMEventTarget contentAreaEventTarget;
- private MozillaDomEventListener contentAreaEventListener;
+ private MozillaEventAdapter mozillaEventAdapter;
private EditorLoadWindowListener editorLoadWindowListener;
- private EditorDomEventListener editorDomEventListener;
+ private MozillaEventListener mozillaEventListener;
private IVpeToolBarManager vpeToolBarManager;
private FormatControllerManager formatControllerManager = new
FormatControllerManager();
private VpeController controller;
@@ -767,11 +769,24 @@
editorLoadWindowListener = listener;
}
- public void setEditorDomEventListener(EditorDomEventListener listener) {
- editorDomEventListener = listener;
- if (contentAreaEventListener != null) {
-
- contentAreaEventListener.setEditorDomEventListener(listener);
+ public void setEditorDomEventListener(MozillaEventListener listener) {
+ if (mozillaEventAdapter != null) {
+ if (mozillaEventListener != null) {
+ mozillaEventAdapter.removeContextMenuListener(mozillaEventListener);
+ mozillaEventAdapter.removeDndListener(mozillaEventListener);
+ mozillaEventAdapter.removeKeyListener(mozillaEventListener);
+ mozillaEventAdapter.removeMouseListener(mozillaEventListener);
+ mozillaEventAdapter.removeContextMenuListener(mozillaEventListener);
+ }
+
+ mozillaEventListener = listener;
+ if (mozillaEventListener != null) {
+ mozillaEventAdapter.addContextMenuListener(mozillaEventListener);
+ mozillaEventAdapter.addDndListener(mozillaEventListener);
+ mozillaEventAdapter.addKeyListener(mozillaEventListener);
+ mozillaEventAdapter.addMouseListener(mozillaEventListener);
+ mozillaEventAdapter.addSelectionListener(mozillaEventListener);
+ }
}
}
@@ -870,105 +885,43 @@
private void onLoadWindow() {
contentArea = findContentArea();
- addDomEventListeners();
- addSelectionListener();
+ addListeners();
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
}
- protected void addDomEventListeners() {
+ protected void addListeners() {
if (contentArea != null) {
- if (getContentAreaEventListener() != null) {
- getContentAreaEventListener().setVisualEditor(xulRunnerEditor);
- setContentAreaEventTarget((nsIDOMEventTarget)
contentArea.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID));
- //add mozilla event handlers
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.CLICKEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.MOUSEDOWNEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.MOUSEUPEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.MOUSEMOVEEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.CONTEXTMENUEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGDROPEVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGENTEREVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGEXITEVENT,getContentAreaEventListener(),
false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGGESTUREEVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DRAGOVEREVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().addEventListener(MozillaDomEventListener.DBLCLICK,
getContentAreaEventListener(), false);
- documentEventTarget = (nsIDOMEventTarget)
xulRunnerEditor.getDOMDocument().queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- documentEventTarget.addEventListener(MozillaDomEventListener.KEYPRESS,
getContentAreaEventListener(), false);
- //as a fix of
https://jira.jboss.org/jira/browse/JBIDE-4022
- //scroll event listener was added for selection border redrawing
- documentEventTarget.addEventListener(MozillaDomEventListener.SCROLL,
getContentAreaEventListener(), false);
- nsIDOMWindow window = xulRunnerEditor.getWebBrowser().getContentDOMWindow();
- nsIDOMEventTarget eventTarget = (nsIDOMEventTarget)
window.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- eventTarget.addEventListener(MozillaDomEventListener.MOZAFTERPAINT,
getContentAreaEventListener(), false);
- } else {
- //baseEventListener = new MozillaBaseEventListener();
- }
+// getContentAreaEventListener().setVisualEditor(xulRunnerEditor);
+ nsIDOMWindow window = xulRunnerEditor.getWebBrowser().getContentDOMWindow();
+ getMozillaEventAdapter().attach(window, (nsIDOMEventTarget)
contentArea.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID));
}
}
- protected void removeDomEventListeners() {
- if (getContentAreaEventTarget() != null && getContentAreaEventListener() !=
null) {
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.CLICKEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.MOUSEDOWNEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.MOUSEUPEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.MOUSEMOVEEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.CONTEXTMENUEVENTTYPE,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DRAGDROPEVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DRAGENTEREVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DRAGEXITEVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DRAGGESTUREEVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DRAGOVEREVENT,
getContentAreaEventListener(), false);
- getContentAreaEventTarget().removeEventListener(MozillaDomEventListener.DBLCLICK,
getContentAreaEventListener(), false);
-
- if (xulRunnerEditor.getDOMDocument() != null && documentEventTarget != null)
{
- documentEventTarget.removeEventListener(MozillaDomEventListener.KEYPRESS,
getContentAreaEventListener(), false);
- documentEventTarget.removeEventListener(MozillaDomEventListener.SCROLL,
getContentAreaEventListener(), false);
- }
- if ((xulRunnerEditor!=null) && (xulRunnerEditor.getWebBrowser()!= null)) {
- nsIDOMWindow window = xulRunnerEditor.getWebBrowser().getContentDOMWindow();
- nsIDOMEventTarget eventTarget = (nsIDOMEventTarget)
window.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
- eventTarget.removeEventListener(MozillaDomEventListener.MOZAFTERPAINT,
getContentAreaEventListener(), false);
- }
- getContentAreaEventListener().setVisualEditor(null);
- getContentAreaEventListener().setEditorDomEventListener(null);
- setContentAreaEventTarget(null);
- setContentAreaEventListener(null);
- documentEventTarget = null;
- }
+ protected void removeListeners() {
+ getMozillaEventAdapter().detach();
+// getContentAreaEventListener().setVisualEditor(null);
+ mozillaEventAdapter = null;
+ documentEventTarget = null;
}
- private void addSelectionListener() {
- if (getContentAreaEventListener() != null&&xulRunnerEditor!=null) {
-
- xulRunnerEditor.addSelectionListener(getContentAreaEventListener());
-
- }
- }
-
public void setSelectionRectangle(/*nsIDOMElement*/nsIDOMNode element, int
resizerConstrains, boolean scroll) {
- if (getContentAreaEventListener() != null) {
- xulRunnerEditor.setSelectionRectangle(element, resizerConstrains, scroll);
- }
+ xulRunnerEditor.setSelectionRectangle(element, resizerConstrains, scroll);
}
/**
* Show resizer markers
*/
public void showResizer() {
- if (getContentAreaEventListener() != null) {
- xulRunnerEditor.showResizer();
- }
+ xulRunnerEditor.showResizer();
}
/**
* Hide resizer markers
*/
public void hideResizer() {
- if (getContentAreaEventListener() != null) {
- xulRunnerEditor.hideResizer();
- }
+ xulRunnerEditor.hideResizer();
}
/**
@@ -993,47 +946,23 @@
}
/**
- * @return the contentAreaEventTarget
- */
- public nsIDOMEventTarget getContentAreaEventTarget() {
- return contentAreaEventTarget;
- }
-
- /**
- * @param contentAreaEventTarget the contentAreaEventTarget to set
- */
- public void setContentAreaEventTarget(nsIDOMEventTarget contentAreaEventTarget) {
- this.contentAreaEventTarget = contentAreaEventTarget;
- }
-
- /**
* @return the contentAreaEventListener
*/
- public MozillaDomEventListener getContentAreaEventListener() {
- if(contentAreaEventListener==null) {
- contentAreaEventListener = new MozillaDomEventListener();
+ protected MozillaEventAdapter getMozillaEventAdapter() {
+ if(mozillaEventAdapter == null) {
+ mozillaEventAdapter = new MozillaEventAdapter();
}
- return contentAreaEventListener;
+ return mozillaEventAdapter;
}
-
- /**
- * @param contentAreaEventListener the contentAreaEventListener to set
- */
- public void setContentAreaEventListener(
- MozillaDomEventListener contentAreaEventListener) {
-
- this.contentAreaEventListener = contentAreaEventListener;
- }
/**
*
*/
public void onReloadWindow() {
- removeDomEventListeners();
+ removeListeners();
xulRunnerEditor.removeResizerListener();
contentArea = findContentArea();
- addDomEventListeners();
- addSelectionListener();
+ addListeners();
xulRunnerEditor.addResizerListener();
controller.reinit();
}
@@ -1168,7 +1097,7 @@
showSelectionBarAction.setChecked(checked);
}
- public EditorDomEventListener getEditorDomEventListener() {
- return editorDomEventListener;
+ public MozillaEventListener getEditorDomEventListener() {
+ return mozillaEventListener;
}
}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEventAdapter.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,340 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla;
+
+import javax.swing.event.EventListenerList;
+
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaContextMenuListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaKeyListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaMouseListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaSelectionListener;
+import org.jboss.tools.vpe.xulrunner.browser.XulRunnerBrowser;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMEventListener;
+import org.mozilla.interfaces.nsIDOMEventTarget;
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMWindow;
+import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsISelectionListener;
+import org.mozilla.interfaces.nsISelectionPrivate;
+import org.mozilla.interfaces.nsISupports;
+import org.mozilla.xpcom.Mozilla;
+import org.mozilla.xpcom.XPCOMException;
+
+/**
+ * Listens to events from Mozilla and transfers them to
+ * {@code org.jboss.tools.vpe.editor.mozilla.listener.*Listener}'s.
+ *
+ * @author Yahor Radtsevich (yradtsevich) and others
+ */
+public class MozillaEventAdapter implements nsIDOMEventListener, nsISelectionListener {
+ public MozillaEventAdapter(){}
+
+ //possible events
+ private static final String MOZAFTERPAINT = "MozAfterPaint"; //$NON-NLS-1$
+ private static final String SCROLL = "scroll"; //$NON-NLS-1$
+ private static final String MOUSEMOVEEVENTTYPE="mousemove"; //$NON-NLS-1$
+ private static final String MOUSEDOWNEVENTTYPE="mousedown"; //$NON-NLS-1$
+ private static final String MOUSEUPEVENTTYPE="mouseup"; //$NON-NLS-1$
+ private static final String CLICKEVENTTYPE="click"; //$NON-NLS-1$
+ private static final String KEYPRESS="keypress"; //$NON-NLS-1$
+ private static final String DBLCLICK="dblclick"; //$NON-NLS-1$
+ private static final String CONTEXTMENUEVENTTYPE="contextmenu"; //$NON-NLS-1$
+ private static final String DRAGGESTUREEVENT = "draggesture"; //$NON-NLS-1$
+ private static final String DRAGOVEREVENT = "dragover"; //$NON-NLS-1$
+ private static final String DRAGDROPEVENT = "dragdrop"; //$NON-NLS-1$
+ private static final String DRAGENTEREVENT = "dragenter"; //$NON-NLS-1$
+ private static final String DRAGEXITEVENT = "dragexit"; //$NON-NLS-1$
+
+ private EventListenerList listeners = new EventListenerList();
+ private nsIDOMEventTarget window;
+ private nsIDOMEventTarget document;
+ private nsIDOMEventTarget contentArea;
+ private nsISelectionPrivate selectionPrivate;
+ private boolean attached = false;
+ // this field is never used
+ // private XulRunnerEditor visualEditor;
+
+ /**
+ * Attach this instance to the specified Mozilla window and content area
+ * event target.
+ *
+ * @throws IllegalStateException if the instance is attached twice.
+ */
+ public void attach(nsIDOMWindow domWindow, nsIDOMEventTarget contentArea) {
+ if (attached) {
+ new IllegalStateException("Instance of the " //$NON-NLS-1$
+ + "MozillaMouseListener cannot be attached twice.");//$NON-NLS-1$
+ }
+ attached = true;
+
+ this.window = (nsIDOMEventTarget) domWindow
+ .queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ this.document = (nsIDOMEventTarget) domWindow.getDocument()
+ .queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
+ this.contentArea = contentArea;
+
+ if (contentArea != null) {
+ contentArea.addEventListener(MozillaEventAdapter.CLICKEVENTTYPE, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.MOUSEDOWNEVENTTYPE, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.MOUSEUPEVENTTYPE, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.MOUSEMOVEEVENTTYPE, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.CONTEXTMENUEVENTTYPE, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DRAGEXITEVENT,this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
+ contentArea.addEventListener(MozillaEventAdapter.DBLCLICK, this, false);
+ }
+ if (window != null) {
+ window.addEventListener(MozillaEventAdapter.MOZAFTERPAINT, this, false);
+
+ nsISelection selection = domWindow.getSelection();
+ selectionPrivate = (nsISelectionPrivate) selection
+ .queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
+ selectionPrivate.addSelectionListener(this);
+ }
+ if (document != null) {
+ document.addEventListener(MozillaEventAdapter.KEYPRESS, this, false);
+ //as a fix of
https://jira.jboss.org/jira/browse/JBIDE-4022
+ //scroll event listener was added for selection border redrawing
+ document.addEventListener(MozillaEventAdapter.SCROLL, this, false);
+ }
+ }
+
+ /**
+ * Detach this instance from all Mozilla event notifiers
+ */
+ public void detach() {
+ attached = false;
+
+ if (contentArea != null) {
+ contentArea.removeEventListener(MozillaEventAdapter.CLICKEVENTTYPE, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.MOUSEDOWNEVENTTYPE, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.MOUSEUPEVENTTYPE, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.MOUSEMOVEEVENTTYPE, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.CONTEXTMENUEVENTTYPE, this,
false);
+ contentArea.removeEventListener(MozillaEventAdapter.DRAGDROPEVENT, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.DRAGENTEREVENT, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.DRAGEXITEVENT, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.DRAGGESTUREEVENT, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.DRAGOVEREVENT, this, false);
+ contentArea.removeEventListener(MozillaEventAdapter.DBLCLICK, this, false);
+ contentArea = null;
+ }
+ if (document != null) {
+ document.removeEventListener(MozillaEventAdapter.KEYPRESS, this, false);
+ document.removeEventListener(MozillaEventAdapter.SCROLL, this, false);
+ document = null;
+ }
+ if (window != null) {
+ window.removeEventListener(MozillaEventAdapter.MOZAFTERPAINT, this, false);
+ window = null;
+ }
+ if (selectionPrivate != null) {
+ try {
+ selectionPrivate.removeSelectionListener(this);
+ } catch (XPCOMException xpcomException) {
+ // this exception throws when progress listener already has been
+ // deleted,
+ // so just ignore if error code NS_ERROR_FAILURE
+ // mareshkau fix for jbide-3155
+ if (xpcomException.errorcode != XulRunnerBrowser.NS_ERROR_FAILURE) {
+ throw xpcomException;
+ }
+ } finally {
+ selectionPrivate = null;
+ }
+ }
+ }
+
+ public void addMouseListener(MozillaMouseListener listener) {
+ listeners.add(MozillaMouseListener.class, listener);
+ }
+
+ public void removeMouseListener(MozillaMouseListener listener) {
+ listeners.remove(MozillaMouseListener.class, listener);
+ }
+
+ public void addKeyListener(MozillaKeyListener listener) {
+ listeners.add(MozillaKeyListener.class, listener);
+ }
+
+ public void removeKeyListener(MozillaKeyListener listener) {
+ listeners.remove(MozillaKeyListener.class, listener);
+ }
+
+ public void addContextMenuListener(MozillaContextMenuListener listener) {
+ listeners.add(MozillaContextMenuListener.class, listener);
+ }
+
+ public void removeContextMenuListener(MozillaContextMenuListener listener) {
+ listeners.remove(MozillaContextMenuListener.class, listener);
+ }
+
+ public void addDndListener(MozillaDndListener listener) {
+ listeners.add(MozillaDndListener.class, listener);
+ }
+
+ public void removeDndListener(MozillaDndListener listener) {
+ listeners.remove(MozillaDndListener.class, listener);
+ }
+
+ public void addSelectionListener(MozillaSelectionListener listener) {
+ listeners.add(MozillaSelectionListener.class, listener);
+ }
+
+ public void removeSelectionListener(MozillaSelectionListener listener) {
+ listeners.remove(MozillaSelectionListener.class, listener);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void notifySelectionChanged(nsIDOMDocument domDocument, nsISelection selection,
short reason) {
+ for (MozillaSelectionListener listener : listeners.getListeners(
+ MozillaSelectionListener.class)) {
+ listener.notifySelectionChanged(domDocument, selection, reason);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void handleEvent(nsIDOMEvent domEvent) {
+ final String eventType = domEvent.getType();
+ if(MOUSEMOVEEVENTTYPE.equals(eventType)) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ for (MozillaMouseListener listener : listeners.getListeners(
+ MozillaMouseListener.class)) {
+ listener.mouseMove(mouseEvent);
+ }
+ } else if(MOUSEDOWNEVENTTYPE.equals(eventType)) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ for (MozillaMouseListener listener : listeners.getListeners(
+ MozillaMouseListener.class)) {
+ listener.mouseDown(mouseEvent);
+ }
+ } else if(MOUSEUPEVENTTYPE.equals(eventType)) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ for (MozillaMouseListener listener : listeners.getListeners(
+ MozillaMouseListener.class)) {
+ listener.mouseUp(mouseEvent);
+ }
+ } else if(CLICKEVENTTYPE.equals(eventType)) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ for (MozillaMouseListener listener : listeners.getListeners(
+ MozillaMouseListener.class)) {
+ listener.mouseClick(mouseEvent);
+ }
+ } else if(DBLCLICK.equals(eventType)) {
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
+ .queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ for (MozillaMouseListener listener : listeners.getListeners(
+ MozillaMouseListener.class)) {
+ listener.mouseDblClick(mouseEvent);
+ }
+ } else if(KEYPRESS.equals(eventType)) {
+ nsIDOMKeyEvent keyEvent = (nsIDOMKeyEvent) domEvent
+ .queryInterface(nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID);
+ for (MozillaKeyListener listener : listeners.getListeners(
+ MozillaKeyListener.class)) {
+ listener.keyPress(keyEvent);
+ }
+ } else if(CONTEXTMENUEVENTTYPE.equals(eventType)) {
+ //first param are null 0, because this not used in event handler
+ nsIDOMNode node = (nsIDOMNode) domEvent.getTarget()
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+ for (MozillaContextMenuListener listener : listeners.getListeners(
+ MozillaContextMenuListener.class)) {
+ listener.onShowContextMenu(0, domEvent, node);
+ }
+ } else if(DRAGGESTUREEVENT.equals(eventType)) {
+ // fix of JBIDE-4998: since drag events now are implemented by
+ // handling CLICKEVENTTYPE, there is no need to handle them here
+ //for (DndDomEventListener listener : dndListeners) {
+ // listener.dragGesture(domEvent);
+ //}
+ } else if(DRAGDROPEVENT.equals(eventType)) {
+ // calls when drop event occure
+ for (MozillaDndListener listener : listeners.getListeners(
+ MozillaDndListener.class)) {
+ listener.dragDrop(domEvent);
+ }
+ domEvent.stopPropagation();
+ domEvent.preventDefault();
+ } else if(DRAGENTEREVENT.equals(eventType)) {
+ //just ignore this event
+ } else if(DRAGEXITEVENT.equals(eventType)) {
+ //just ignore this event
+ } else if(DRAGOVEREVENT.equals(eventType)) {
+ for (MozillaDndListener listener : listeners.getListeners(
+ MozillaDndListener.class)) {
+ listener.dragOver(domEvent);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.mozilla.interfaces.nsISupports#queryInterface(java.lang.String)
+ */
+ public nsISupports queryInterface(String arg0) {
+ return Mozilla.queryInterface(this, arg0);
+ }
+
+ // this method is never used
+// boolean isXulElement(nsIDOMMouseEvent mouseEvent) {
+// // TODO Sergey Vasilyev figure out with getTmpRealOriginalTarget
+//// nsIDOMNSEvent nsEvent =
(nsIDOMNSEvent)mouseEvent.queryInterface(nsIDOMNSEvent.NS_IDOMNSEVENT_IID);
+//// nsIDOMEventTarget target = nsEvent.getTmpRealOriginalTarget();
+//// int aDragNode = target.queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+//// nsIDOMNode originalNode = nsIDOMNode.getNodeAtAddress(aDragNode);
+//// String prefix = originalNode.getPrefix();
+//// boolean isXul = "XUL".equalsIgnoreCase(prefix);
+//// target.Release();
+//// nsEvent.Release();
+// return false;
+// }
+
+// commented, since visualEditor was never used locally
+// if it is needed, the calls to this method should be uncommented
+// (see MozillaEditor)
+// void setVisualEditor(XulRunnerEditor visualEditor) {
+// this.visualEditor = visualEditor;
+// }
+
+// this method is never used
+// /* (non-Javadoc)
+// * @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#onPasteOrDrop(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsITransferable)
+// */
+// public boolean onPasteOrDrop(nsIDOMEvent event, nsITransferable transferable) {
+// nsIDOMMouseEvent mouseEvent =
(nsIDOMMouseEvent)event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+//
+// if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
+// nsIDragSession dragSession = visualEditor.getCurrentDragSession();
+// if (dragSession.isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
+// editorDomEventListener.onPasteOrDrop(mouseEvent, VpeController.MODEL_FLAVOR,
""); //$NON-NLS-1$
+// }
+// }
+// mouseEvent.preventDefault();
+// mouseEvent.stopPropagation();
+//
+// return false;
+// }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -23,6 +23,8 @@
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
+import org.jboss.tools.vpe.editor.mozilla.listener.EditorLoadWindowListener;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -33,7 +35,7 @@
public class MozillaPreview extends MozillaEditor {
private EditorLoadWindowListener editorLoadWindowListener;
- private EditorDomEventListener editorDomEventListener;
+ private MozillaDndListener editorDomEventListener;
private VpeTemplateManager templateManager;
private VpePageContext pageContext;
private StructuredTextEditor sourceEditor;
@@ -95,7 +97,7 @@
*/
public void onLoadWindow() {
setContentArea(findContentArea());
- addDomEventListeners();
+ addListeners();
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
@@ -228,7 +230,7 @@
public void dispose() {
setEditorDomEventListener(null);
setEditorLoadWindowListener(null);
- setContentAreaEventListener(null);
+ contentAreaEventListener = null;
if (pageContext != null) {
pageContext.dispose();
pageContext=null;
@@ -244,35 +246,15 @@
//super.dispose();
}
-
-
/* (non-Javadoc)
* @see org.jboss.tools.vpe.editor.mozilla.MozillaEditor#getContentAreaEventListener()
*/
@Override
- public MozillaDomEventListener getContentAreaEventListener() {
-
+ protected PreviewDomEventListener getMozillaEventAdapter() {
if(this.contentAreaEventListener==null){
-
contentAreaEventListener = new PreviewDomEventListener();
}
-
+
return contentAreaEventListener;
}
-
-
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.vpe.editor.mozilla.MozillaEditor#setContentAreaEventListener(org.jboss.tools.vpe.editor.mozilla.MozillaDomEventListener)
- */
- @Override
- public void setContentAreaEventListener(
- MozillaDomEventListener contentAreaEventListener) {
-
- if(contentAreaEventListener instanceof PreviewDomEventListener) {
-
- this.contentAreaEventListener = (PreviewDomEventListener) contentAreaEventListener;
- }
- }
-
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/PreviewDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/PreviewDomEventListener.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/PreviewDomEventListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -16,7 +16,7 @@
* @author mareshkau
*
*/
-public class PreviewDomEventListener extends MozillaDomEventListener {
+public class PreviewDomEventListener extends MozillaEventAdapter {
/* (non-Javadoc)
* @see
org.jboss.tools.vpe.editor.mozilla.MozillaDomEventListener#handleEvent(org.mozilla.interfaces.nsIDOMEvent)
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -58,7 +58,7 @@
public void onDispose() {
if (mozillaEditor != null) {
mozillaEditor.tearDownEditor();
- mozillaEditor.removeDomEventListeners();
+ mozillaEditor.removeListeners();
mozillaEditor = null;
}
super.onDispose();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -41,7 +41,7 @@
public void onDispose() {
if (mozillaPreview != null) {
- mozillaPreview.removeDomEventListeners();
+ mozillaPreview.removeListeners();
mozillaPreview = null;
}
super.onDispose();
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/EditorLoadWindowListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/EditorLoadWindowListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/EditorLoadWindowListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+public interface EditorLoadWindowListener extends EventListener {
+ void load();
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaContextMenuListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaContextMenuListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaContextMenuListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.mozilla.interfaces.nsIContextMenuListener;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * Listener for context-menu events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaContextMenuListener extends EventListener {
+
+ /**
+ * @see nsIContextMenuListener#onShowContextMenu(long, nsIDOMEvent, nsIDOMNode)
+ */
+ void onShowContextMenu(long aContextFlags, nsIDOMEvent aEvent,
+ nsIDOMNode aNode);
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaDndListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
+import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+
+/**
+ * Listener for Drag&Drop events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaDndListener extends EventListener {
+ void dragOver(nsIDOMEvent event);
+
+ /**
+ * Drag gesture event handler
+ * @param event xulrunner drag event
+ */
+ void dragGesture(nsIDOMEvent event);
+ boolean canInnerDrag(nsIDOMMouseEvent mouseEvent);
+ MozillaDropInfo canInnerDrop(nsIDOMMouseEvent mouseEvent);
+ void innerDrop(nsIDOMMouseEvent mouseEvent);
+ void externalDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data);
+ void startDragSession(nsIDOMEvent domEvent);
+
+ /**
+ * Calls when drop event occurs
+ * @param domEvent
+ */
+ void dragDrop(nsIDOMEvent domEvent);
+
+ MozillaDropInfo canExternalDrop(nsIDOMMouseEvent mouseEvent,
+ String flavor, String data);
+
+
+// these methods are never used
+// void dragEnter(nsIDOMEvent event);
+// void dragExit(nsIDOMEvent event);
+// void drop(nsIDOMEvent event);
+// void onPasteOrDrop(nsIDOMMouseEvent mouseEvent, String flavor, String data);
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaEventListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaEventListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+/**
+ * Listener of Mozilla events. Aggregates several kinds of listeners
+ * in itself (see the declaration).
+ */
+public interface MozillaEventListener extends MozillaDndListener,
+ MozillaMouseListener, MozillaKeyListener,
+ MozillaTooltipListener, MozillaSelectionListener,
+ MozillaContextMenuListener, MozillaResizeListener {
+ //nsIDOMMutationListener
+// these methods are not used
+// void subtreeModified(nsIDOMMutationEvent mutationEvent);
+// void nodeInserted(nsIDOMMutationEvent mutationEvent);
+// void nodeRemoved(nsIDOMMutationEvent mutationEvent);
+// void nodeRemovedFromDocument(nsIDOMMutationEvent mutationEvent);
+// void nodeInsertedIntoDocument(nsIDOMMutationEvent mutationEvent);
+// void attrModified(nsIDOMMutationEvent mutationEvent);
+// void characterDataModified(nsIDOMMutationEvent mutationEvent);
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaKeyListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaKeyListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaKeyListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.mozilla.interfaces.nsIDOMKeyEvent;
+
+/**
+ * Listener for key events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaKeyListener extends EventListener {
+
+ void keyPress(nsIDOMKeyEvent keyEvent);
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaMouseListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaMouseListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaMouseListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.mozilla.interfaces.nsIDOMMouseEvent;
+
+/**
+ * Listener for mouse events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaMouseListener extends EventListener {
+
+ void mouseDown(nsIDOMMouseEvent mouseEvent);
+
+ void mouseUp(nsIDOMMouseEvent mouseEvent);
+
+ void mouseClick(nsIDOMMouseEvent mouseEvent);
+
+ void mouseDblClick(nsIDOMMouseEvent mouseEvent);
+
+ void mouseMove(nsIDOMMouseEvent mouseEvent);
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaResizeListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaResizeListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaResizeListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import org.mozilla.interfaces.nsIDOMElement;
+
+/**
+ * Listener for element resize events,
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public interface MozillaResizeListener {
+
+ void elementResized(nsIDOMElement element, int resizerConstrains, int top,
+ int left, int width, int height);
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaSelectionListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaSelectionListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaSelectionListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsISelection;
+import org.mozilla.interfaces.nsISelectionListener;
+
+/**
+ * Listener for selection events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaSelectionListener extends EventListener {
+
+ /**
+ * @see nsISelectionListener#notifySelectionChanged(nsIDOMDocument, nsISelection, short)
+ */
+ void notifySelectionChanged(nsIDOMDocument domDocument,
+ nsISelection selection, short reason);
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaTooltipListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaTooltipListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/listener/MozillaTooltipListener.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.mozilla.listener;
+
+import java.util.EventListener;
+
+import org.mozilla.interfaces.nsITooltipListener;
+
+/**
+ * Listener for context-menu show/hide events.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface MozillaTooltipListener extends EventListener {
+
+ /**
+ * @see nsITooltipListener#onShowTooltip(int, int, String)
+ */
+ void onShowTooltip(int x, int y, String text);
+
+ /**
+ * @see nsITooltipListener#onHideTooltip()
+ */
+ void onHideTooltip();
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -69,8 +69,8 @@
private static final Mozilla mozilla;
private Browser browser = null;
private nsIWebBrowser webBrowser = null;
- private long chrome_flags = nsIWebBrowserChrome.CHROME_ALL;
- protected static final long NS_ERROR_FAILURE = 0x80004005L;
+ private long chrome_flags = nsIWebBrowserChrome.CHROME_ALL;
+ public static final long NS_ERROR_FAILURE = 0x80004005L;
static {
XULRUNNER_BUNDLE = (new StringBuffer("org.mozilla.xulrunner")) //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2010-03-05
15:30:58 UTC (rev 20692)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2010-03-05
17:52:57 UTC (rev 20693)
@@ -43,7 +43,6 @@
import org.mozilla.interfaces.nsIInterfaceRequestor;
import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsISelectionListener;
-import org.mozilla.interfaces.nsISelectionPrivate;
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsITooltipListener;
@@ -165,7 +164,7 @@
getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
removeProgressListener(XulRunnerEditor.this);
- removeSelectionListener();
+
if (resizeListener != null)
getIXulRunnerVpeResizer().removeResizeListener(
resizeListener);
@@ -681,43 +680,6 @@
}
/**
- * Adds selection listener
- *
- * @param selectionListener
- */
- public void addSelectionListener(nsISelectionListener selectionListener) {
- nsISelection selection = getSelection();
- nsISelectionPrivate selectionPrivate = (nsISelectionPrivate) selection
- .queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
- selectionPrivate.addSelectionListener(selectionListener);
- this.selectionListener = selectionListener;
- }
-
- /**
- * Removes selection listener
- */
- public void removeSelectionListener() {
- if (this.selectionListener != null) {
- nsISelection selection = getSelection();
- nsISelectionPrivate selectionPrivate = (nsISelectionPrivate) selection
- .queryInterface(nsISelectionPrivate.NS_ISELECTIONPRIVATE_IID);
- try {
- selectionPrivate
- .removeSelectionListener(this.selectionListener);
- } catch (XPCOMException xpcomException) {
- // this exception throws when progress listener already has been
- // deleted,
- // so just ignore if error code NS_ERROR_FAILURE
- // mareshkau fix for jbide-3155
- if (xpcomException.errorcode != XulRunnerBrowser.NS_ERROR_FAILURE) {
- throw xpcomException;
- }
- }
- }
- this.selectionListener = null;
- }
-
- /**
* get nsIDomElement from nsIDomNode
*
* if node is nsIDomElement - return it