Author: yradtsevich
Date: 2010-03-12 12:16:20 -0500 (Fri, 12 Mar 2010)
New Revision: 20805
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/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/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.
- registration of Mozilla*Listeners has been moved to VpeController
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-12
15:29:34 UTC (rev 20804)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-03-12
17:16:20 UTC (rev 20805)
@@ -14,6 +14,8 @@
import java.util.LinkedList;
import java.util.List;
+import javax.management.RuntimeErrorException;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -113,6 +115,7 @@
import org.jboss.tools.vpe.editor.menu.VpeMenuCreator;
import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEventAdapter;
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;
@@ -329,7 +332,7 @@
textWidget.addSelectionListener(this);
}
- visualEditor.setEditorDomEventListener(this);
+ registerEventTargets();
switcher.initActiveEditor();
if (optionsListener == null) {
@@ -424,7 +427,7 @@
dropWindow.setEditor(null);
}
if (visualEditor != null) {
- visualEditor.setEditorDomEventListener(null);
+ unregisterEventTargets();
if (visualSelectionController != null) {
// visualSelectionController.Release();
visualSelectionController = null;
@@ -455,6 +458,40 @@
toolbarFormatControllerManager = null;
}
+ private void registerEventTargets() {
+ if (visualEditor != null) {
+ visualEditor.setResizeListener(this);
+ visualEditor.setTooltipListener(this);
+
+ MozillaEventAdapter mozillaEventAdapter
+ = visualEditor.getMozillaEventAdapter();
+ if (mozillaEventAdapter != null) {
+ mozillaEventAdapter.addContextMenuListener(this);
+ mozillaEventAdapter.addDndListener(this);
+ mozillaEventAdapter.addKeyListener(this);
+ mozillaEventAdapter.addMouseListener(this);
+ mozillaEventAdapter.addSelectionListener(this);
+ }
+ }
+ }
+
+ private void unregisterEventTargets() {
+ if (visualEditor != null) {
+ visualEditor.setResizeListener(null);
+ visualEditor.setTooltipListener(null);
+
+ MozillaEventAdapter mozillaEventAdapter
+ = visualEditor.getMozillaEventAdapter();
+ if (mozillaEventAdapter != null) {
+ mozillaEventAdapter.removeContextMenuListener(this);
+ mozillaEventAdapter.removeDndListener(this);
+ mozillaEventAdapter.removeKeyListener(this);
+ mozillaEventAdapter.removeMouseListener(this);
+ mozillaEventAdapter.removeSelectionListener(this);
+ }
+ }
+ }
+
// INodeAdapter implementation
public boolean isAdapterForType(Object type) {
return type == this;
@@ -2870,7 +2907,6 @@
visualEditor.reinitDesignMode();
visualBuilder.setSelectionRectangle(null);
- visualEditor.setEditorDomEventListener(this);
IDOMModel sourceModel = (IDOMModel) getModel();
if (sourceModel != null) {
IDOMDocument sourceDocument = sourceModel.getDocument();
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-12
15:29:34 UTC (rev 20804)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-03-12
17:16:20 UTC (rev 20805)
@@ -61,7 +61,6 @@
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.mozilla.listener.MozillaResizeListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaTooltipListener;
@@ -118,13 +117,13 @@
static String SELECT_BAR = "SELECT_LBAR"; //$NON-NLS-1$
private XulRunnerEditor xulRunnerEditor;
- private nsIDOMEventTarget documentEventTarget;
private nsIDOMElement contentArea;
private nsIDOMNode headNode;
- private MozillaEventAdapter mozillaEventAdapter;
+ private MozillaEventAdapter mozillaEventAdapter
+ = createMozillaEventAdapter();
private EditorLoadWindowListener editorLoadWindowListener;
- private MozillaEventListener mozillaEventListener;
+
private IVpeToolBarManager vpeToolBarManager;
private FormatControllerManager formatControllerManager = new
FormatControllerManager();
private VpeController controller;
@@ -178,6 +177,8 @@
private nsIEditor editor;
private VpeDropDownMenu dropDownMenu = null;
private ToolBar verBar = null;
+ private MozillaResizeListener resizeListener;
+ private MozillaTooltipListener tooltipListener;
public void doSave(IProgressMonitor monitor) {
}
@@ -751,51 +752,27 @@
// removeDomEventListeners();
if(getController()!=null) {
controller.dispose();
- controller=null;
+ controller = null;
}
if (xulRunnerEditor != null) {
xulRunnerEditor.dispose();
xulRunnerEditor = null;
}
- this.controller = null;
formatControllerManager.setVpeController(null);
formatControllerManager=null;
headNode = null;
contentArea = null;
super.dispose();
-
}
public void setEditorLoadWindowListener(EditorLoadWindowListener listener) {
editorLoadWindowListener = 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);
- }
- }
- }
-
public nsIDOMDocument getDomDocument() {
return xulRunnerEditor.getDOMDocument();
}
-
public nsIDOMElement getContentArea() {
return contentArea;
@@ -887,25 +864,27 @@
private void onLoadWindow() {
contentArea = findContentArea();
- addListeners();
+ attachMozillaEventAdapter();
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
}
+
+ protected MozillaEventAdapter createMozillaEventAdapter() {
+ return new MozillaEventAdapter();
+ }
- protected void addListeners() {
+ protected void attachMozillaEventAdapter() {
if (contentArea != null) {
// getContentAreaEventListener().setVisualEditor(xulRunnerEditor);
nsIDOMWindow window = xulRunnerEditor.getWebBrowser().getContentDOMWindow();
- getMozillaEventAdapter().attach(window, (nsIDOMEventTarget)
contentArea.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID));
+ mozillaEventAdapter.attach(window, (nsIDOMEventTarget)
contentArea.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID));
}
}
- protected void removeListeners() {
- getMozillaEventAdapter().detach();
+ void detachMozillaEventAdapter() {
+ mozillaEventAdapter.detach();
// getContentAreaEventListener().setVisualEditor(null);
- mozillaEventAdapter = null;
- documentEventTarget = null;
}
public void setSelectionRectangle(/*nsIDOMElement*/nsIDOMNode element, int
resizerConstrains, boolean scroll) {
@@ -947,13 +926,7 @@
return controller;
}
- /**
- * @return the contentAreaEventListener
- */
- protected MozillaEventAdapter getMozillaEventAdapter() {
- if(mozillaEventAdapter == null) {
- mozillaEventAdapter = new MozillaEventAdapter();
- }
+ public MozillaEventAdapter getMozillaEventAdapter() {
return mozillaEventAdapter;
}
@@ -961,10 +934,10 @@
*
*/
public void onReloadWindow() {
- removeListeners();
+ detachMozillaEventAdapter();
xulRunnerEditor.removeResizerListener();
contentArea = findContentArea();
- addListeners();
+ attachMozillaEventAdapter();
xulRunnerEditor.addResizerListener();
controller.reinit();
}
@@ -1094,16 +1067,24 @@
rotateEditorsAction.setToolTipText(layoutNames.get(prefsOrientation));
}
}
-
+
public void updateShowSelectionBarItem(boolean checked) {
showSelectionBarAction.setChecked(checked);
}
+ public void setResizeListener(MozillaResizeListener resizeListener) {
+ this.resizeListener = resizeListener;
+ }
+
+ public void setTooltipListener(MozillaTooltipListener tooltipListener) {
+ this.tooltipListener = tooltipListener;
+ }
+
public MozillaResizeListener getResizeListener() {
- return mozillaEventListener;
+ return resizeListener;
}
-
+
public MozillaTooltipListener getTooltipListener() {
- return mozillaEventListener;
+ return tooltipListener;
}
}
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-12
15:29:34 UTC (rev 20804)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2010-03-12
17:16:20 UTC (rev 20805)
@@ -40,7 +40,6 @@
private StructuredTextEditor sourceEditor;
private VpeEditorPart editPart;
private IDOMDocument sourceDocument;
- private PreviewDomEventListener contentAreaEventListener;
public MozillaPreview(VpeEditorPart editPart, StructuredTextEditor sourceEditor) {
setTemplateManager(VpeTemplateManager.getInstance());
@@ -96,7 +95,7 @@
*/
public void onLoadWindow() {
setContentArea(findContentArea());
- addListeners();
+ attachMozillaEventAdapter();
if (editorLoadWindowListener != null) {
editorLoadWindowListener.load();
}
@@ -228,7 +227,6 @@
public void dispose() {
setEditorLoadWindowListener(null);
- contentAreaEventListener = null;
if (pageContext != null) {
pageContext.dispose();
pageContext=null;
@@ -244,15 +242,8 @@
super.dispose();
}
- /* (non-Javadoc)
- * @see org.jboss.tools.vpe.editor.mozilla.MozillaEditor#getContentAreaEventListener()
- */
@Override
- protected PreviewDomEventListener getMozillaEventAdapter() {
- if(this.contentAreaEventListener==null){
- contentAreaEventListener = new PreviewDomEventListener();
- }
-
- return contentAreaEventListener;
+ protected MozillaEventAdapter createMozillaEventAdapter() {
+ return new PreviewDomEventListener();
}
-}
\ No newline at end of file
+}
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-12
15:29:34 UTC (rev 20804)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerEditor2.java 2010-03-12
17:16:20 UTC (rev 20805)
@@ -58,7 +58,7 @@
public void onDispose() {
if (mozillaEditor != null) {
mozillaEditor.tearDownEditor();
- mozillaEditor.removeListeners();
+ mozillaEditor.detachMozillaEventAdapter();
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-12
15:29:34 UTC (rev 20804)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/XulRunnerPreview.java 2010-03-12
17:16:20 UTC (rev 20805)
@@ -41,7 +41,7 @@
public void onDispose() {
if (mozillaPreview != null) {
- mozillaPreview.removeListeners();
+ mozillaPreview.detachMozillaEventAdapter();
mozillaPreview = null;
}
super.onDispose();