Author: mareshkau
Date: 2009-11-25 06:09:30 -0500 (Wed, 25 Nov 2009)
New Revision: 18816
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
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/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
Log:
https://jira.jboss.org/jira/browse/JBIDE-5184, patch from Snjezana Peco has been applied
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -564,6 +564,7 @@
visualEditor.dispose();
}
site.dispose();
+ site = null;
outlinePage = null;
XModelObject o = getModelObject();
if (o != null) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -31,6 +31,7 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.KeyBindingService;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PopupMenuExtender;
import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -54,7 +55,7 @@
private ISelectionChangedListener fSelChangeListener = null;
- private IKeyBindingService fParentService = null;
+ //private IKeyBindingService fParentService = null;
private IKeyBindingService fService = null;
@@ -104,14 +105,19 @@
INestableKeyBindingService nestableParent = (INestableKeyBindingService)
parentService;
nestableParent.removeKeyBindingService(this);
}
+ if (fService instanceof KeyBindingService) {
+ ((KeyBindingService) fService).dispose();
+ }
fService = null;
}
- //fEditor = null;
- //fEditorPart = null;
if (fSelChangeListener != null) {
getSelectionProvider().removeSelectionChangedListener(fSelChangeListener);
fSelChangeListener = null;
}
+
+ if (serviceLocator != null) {
+ serviceLocator.dispose();
+ }
}
public IEditorActionBarContributor getActionBarContributor() {
@@ -139,7 +145,7 @@
if (fService == null) {
fService = getMultiPageEditor().getEditorSite()
.getKeyBindingService();
- fParentService = fService;
+ //fParentService = fService;
if (fService instanceof INestableKeyBindingService) {
INestableKeyBindingService nestableService = (INestableKeyBindingService) fService;
fService = nestableService.getKeyBindingService(this);
@@ -149,7 +155,7 @@
.log("MultiPageEditorSite.getKeyBindingService() Parent key binding fService
was not an instance of INestableKeyBindingService. It was an instance of " +
fService.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- return fParentService;
+ return fService;
}
public JSPMultiPageEditorPart getMultiPageEditor() {
@@ -272,5 +278,23 @@
return this.serviceLocator.hasService(api);
}
+ /**
+ * Notifies the multi page editor service that the component within which it
+ * exists has become active.
+ *
+ * @since 3.2
+ */
+ public final void activate() {
+ serviceLocator.activate();
+ }
+ /**
+ * Notifies the multi page editor service that the component within which it
+ * exists has been deactived.
+ *
+ * @since 3.2
+ */
+ public final void deactivate() {
+ serviceLocator.deactivate();
+ }
}
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 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -594,6 +594,7 @@
public void widgetDisposed(DisposeEvent e) {
parent.removeControlListener(controlListener);
parent.removeDisposeListener(this);
+ controlListener = null;
}
});
@@ -876,6 +877,11 @@
/*
* Reinit listeners on the new container.
*/
+ if (controlListener != null) {
+ if (cmpEdTl != null && !cmpEdTl.isDisposed()) {
+ cmpEdTl.getParent().removeControlListener(controlListener);
+ }
+ }
controlListener = new ControlListener() {
public void controlMoved(ControlEvent event) {}
public void controlResized(ControlEvent event) {
@@ -883,6 +889,9 @@
}
};
+ if (cmpEdTl != null && !cmpEdTl.isDisposed()) {
+ cmpEdTl.getParent().addControlListener(controlListener);
+ }
/*
* Layout the parent container for CustomSashForm, Selection Bar.
*/
@@ -944,6 +953,19 @@
@Override
public void dispose() {
+ deactivateServices();
+ sourceActivation = null;
+ sourceMaxmin = null;
+ visualActivation = null;
+ visualMaxmin = null;
+ jumpingActivation = null;
+ jumping = null;
+ if (verticalToolbarEmpty != null) {
+ if (!verticalToolbarEmpty.isDisposed()) {
+ verticalToolbarEmpty.dispose();
+ }
+ verticalToolbarEmpty = null;
+ }
if (optionsObject != null) {
optionsObject.getModel().removeModelTreeListener(listener);
listener=null;
@@ -1023,23 +1045,7 @@
public void partDeactivated(IWorkbenchPart part) {
fActivePart = null;
if (part == multiPageEditor) {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (fContextActivation != null) {
- IContextService contextService = (IContextService) workbench
- .getAdapter(IContextService.class);
- contextService.deactivateContext(fContextActivation);
- }
-
- IHandlerService handlerService = (IHandlerService) workbench
- .getService(IHandlerService.class);
- if (handlerService != null) {
- if (sourceActivation != null)
- handlerService.deactivateHandler(sourceActivation);
- if (visualActivation != null)
- handlerService.deactivateHandler(visualActivation);
- if (jumpingActivation != null)
- handlerService.deactivateHandler(jumpingActivation);
- }
+ deactivateServices();
}
}
@@ -1245,5 +1251,25 @@
VpePlugin.getDefault().logError("VPE Selection Bar is not initialized.");
//$NON-NLS-1$
}
}
+
+ private void deactivateServices() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (fContextActivation != null) {
+ IContextService contextService = (IContextService) workbench
+ .getAdapter(IContextService.class);
+ contextService.deactivateContext(fContextActivation);
+ }
+
+ IHandlerService handlerService = (IHandlerService) workbench
+ .getService(IHandlerService.class);
+ if (handlerService != null) {
+ if (sourceActivation != null)
+ handlerService.deactivateHandler(sourceActivation);
+ if (visualActivation != null)
+ handlerService.deactivateHandler(visualActivation);
+ if (jumpingActivation != null)
+ handlerService.deactivateHandler(jumpingActivation);
+ }
+ }
}
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 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -34,6 +34,8 @@
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Color;
@@ -205,7 +207,7 @@
}
public ToolBar createVisualToolbar(Composite parent) {
- ToolBarManager toolBarManager = new ToolBarManager(SWT.VERTICAL | SWT.FLAT);
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.VERTICAL | SWT.FLAT);
verBar = toolBarManager.createControl(parent);
/*
@@ -441,6 +443,22 @@
updateToolbarItemsAccordingToPreferences();
toolBarManager.update(true);
+ parent.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ toolBarManager.dispose();
+ toolBarManager.removeAll();
+ openVPEPreferencesAction = null;
+ visualRefreshAction = null;
+ showResouceDialogAction = null;
+ rotateEditorsAction = null;;
+ showBorderAction = null;
+ showNonVisualTagsAction = null;
+ showSelectionBarAction = null;
+ showTextFormattingAction = null;
+ showBundleAsELAction = null;
+ }
+ });
return verBar;
}
@@ -515,7 +533,7 @@
cmpEd.setBackground(buttonDarker);
try {
- xulRunnerEditor = new XulRunnerEditor(cmpEd) {
+ /*xulRunnerEditor = new XulRunnerEditor(cmpEd) {
public void onLoadWindow() {
// if the first load page
if (!isRefreshPage()) {
@@ -546,10 +564,14 @@
}
}
public void onDispose() {
+ tearDownEditor();
removeDomEventListeners();
+ headNode = null;
+ contentArea = null;
super.onDispose();
}
- };
+ };*/
+ xulRunnerEditor = new XulRunnerEditor2(cmpEd, this);
xulRunnerEditor.getBrowser().addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
@@ -692,6 +714,8 @@
this.controller = null;
formatControllerManager.setVpeController(null);
formatControllerManager=null;
+ headNode = null;
+ contentArea = null;
super.dispose();
}
@@ -702,9 +726,9 @@
public void setEditorDomEventListener(EditorDomEventListener listener) {
editorDomEventListener = listener;
- if (getContentAreaEventListener() != null) {
+ if (contentAreaEventListener != null) {
- getContentAreaEventListener().setEditorDomEventListener(listener);
+ contentAreaEventListener.setEditorDomEventListener(listener);
}
}
@@ -961,7 +985,7 @@
/**
*
*/
- private void onReloadWindow() {
+ public void onReloadWindow() {
removeDomEventListeners();
xulRunnerEditor.removeResizerListener();
contentArea = findContentArea();
@@ -985,7 +1009,7 @@
* Initialized design mode in visual refresh
*/
public void initDesingMode() {
- editor=null;
+ tearDownEditor();
getEditor();
}
@@ -996,7 +1020,7 @@
return doctype;
}
- private boolean isRefreshPage() {
+ public boolean isRefreshPage() {
return isRefreshPage;
}
@@ -1005,9 +1029,21 @@
}
public void reinitDesignMode() {
- editor=null;
+ tearDownEditor();
getEditor();
}
+
+ public void tearDownEditor() {
+ if (editor != null) {
+ nsIEditingSession iEditingSession = (nsIEditingSession) getXulRunnerEditor().
+ getComponentManager().createInstanceByContractID(XPCOM.NS_EDITINGSESSION_CONTRACTID,
null, nsIEditingSession.NS_IEDITINGSESSION_IID);
+ nsIDOMWindow window = getXulRunnerEditor().getWebBrowser().getContentDOMWindow();
+ iEditingSession.detachFromWindow(window);
+ iEditingSession.tearDownEditorOnWindow(window);
+ editor = null;
+ }
+ }
+
/**
* Returns Editor for This Document
* @return
@@ -1088,4 +1124,8 @@
public void updateShowSelectionBarItem(boolean checked) {
showSelectionBarAction.setChecked(checked);
}
+
+ public EditorDomEventListener getEditorDomEventListener() {
+ return editorDomEventListener;
+ }
}
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 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -55,7 +55,7 @@
@Override
public void createPartControl(final Composite parent) {
try {
- setXulRunnerEditor(new XulRunnerEditor(parent) {
+ /*setXulRunnerEditor(new XulRunnerEditor(parent) {
public void onLoadWindow() {
super.onLoadWindow();
MozillaPreview.this.onLoadWindow();
@@ -75,7 +75,8 @@
removeDomEventListeners();
super.onDispose();
}
- });
+ });*/
+ setXulRunnerEditor(new XulRunnerPreview(parent, this));
setInitialContent();
getXulRunnerEditor().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
} catch (Throwable e) {
@@ -92,7 +93,7 @@
/**
*
*/
- private void onLoadWindow() {
+ public void onLoadWindow() {
setContentArea(findContentArea());
addDomEventListeners();
if (editorLoadWindowListener != null) {
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 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -442,7 +442,7 @@
}
protected void onDispose() {
-
+ webBrowser = null;
}
public void setText(String html) {
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 2009-11-25
08:21:44 UTC (rev 18815)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/XulRunnerEditor.java 2009-11-25
11:09:30 UTC (rev 18816)
@@ -48,6 +48,7 @@
import org.mozilla.interfaces.nsISupports;
import org.mozilla.interfaces.nsITooltipListener;
import org.mozilla.interfaces.nsITransferable;
+import org.mozilla.interfaces.nsIWebProgress;
import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.XPCOMException;
@@ -164,6 +165,10 @@
}
getWebBrowser().removeWebBrowserListener(XulRunnerEditor.this,
nsITooltipListener.NS_ITOOLTIPLISTENER_IID);
+ nsIWebProgress webProgress = (nsIWebProgress) getServiceManager()
+ .getServiceByContractID("(a)mozilla.org/docloaderservice;1",
//$NON-NLS-1$
+ nsIWebProgress.NS_IWEBPROGRESS_IID);
+ webProgress.removeProgressListener(XulRunnerEditor.this);
removeSelectionListener();
if (resizeListener != null)
getIXulRunnerVpeResizer().removeResizeListener(
@@ -188,7 +193,7 @@
paintListener = new VisualPaintListener();
getBrowser().getParent().addPaintListener(paintListener);
// addListener(SWT.Activate, eventListenet);
- addListener(SWT.Paint, eventListenet);
+ // addListener(SWT.Paint, eventListenet);
/*
*
https://jira.jboss.org/jira/browse/JBIDE-3917 Resizer and selection
* rectangle should be updated after eclipse window resizing. Need to
@@ -805,6 +810,13 @@
// }
// }
+ @Override
+ protected void onDispose() {
+ lastSelectedNode = null;
+ iFlasher = null;
+ super.onDispose();
+ }
+
private class VisualPaintListener implements PaintListener{
public void paintControl(PaintEvent e) {
@@ -813,4 +825,5 @@
}
+
}