Author: mareshkau
Date: 2008-01-18 08:09:48 -0500 (Fri, 18 Jan 2008)
New Revision: 5801
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1479, VpeController.notifyChanged was changed to
start in UIJob and patch which prevent flooding JOB was also applied. The root problem was
that when we trying notify DOM throw mozilla interfaces in no UI thread we have
EXCEPTION_ACCESS_VIOLATION. Another way to fix EXCEPTION_ACCESS_VIOLATION except run (DOM
changes) it in ui thread i haven't founded.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-01-18
13:05:20 UTC (rev 5800)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-01-18
13:09:48 UTC (rev 5801)
@@ -16,6 +16,9 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
@@ -52,6 +55,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent;
import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener;
@@ -184,6 +188,8 @@
private VpeVisualInnerDragInfo innerDragInfo = null;
private FormatControllerManager toolbarFormatControllerManager = null;
private SelectionBar selectionBar = null;
+ //Added by Max Areshkau Fix for JBIDE-1479
+ private UIJob job = null;
Shell tip;
public final static String MODEL_FLAVOR = ModelTransfer.MODEL; //$NON-NLS-1$
@@ -322,8 +328,29 @@
public boolean isAdapterForType(Object type) {
return type == this;
}
+ //FIX Fox JBIDE-1479 added by Max Areshkau
+ public void notifyChanged(final INodeNotifier notifier, final int eventType,final
Object feature,final Object oldValue,final Object newValue, final int pos) {
- public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object
oldValue, Object newValue, int pos) {
+ if(job!=null) {
+ job.cancel();
+ }
+
+ job = new UIJob("NotifyChangedJob"){
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ //we checks is job was canceled and if is it true we cancel job
+ if(monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ } else {
+ notifyChangedInUiThread(notifier, eventType, feature, oldValue, newValue, pos);
+ }
+ return Status.OK_STATUS;
+ }};
+ job.setPriority(Job.LONG);
+ job.schedule(1000L);
+ }
+
+ public void notifyChangedInUiThread(INodeNotifier notifier, int eventType, Object
feature, Object oldValue, Object newValue, int pos) {
if (!switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
return;
}
@@ -381,7 +408,6 @@
visualBuilder.setSelectionRectangle(null);
visualBuilder.updateNode((Node)notifier);
break;
-
case INodeNotifier.CONTENT_CHANGED:
if (!sourceChangeFlag) {
if (feature != null && ((Node)feature).getNodeType() == Node.TEXT_NODE) {
@@ -2262,7 +2288,7 @@
*/
public void onRefresh() {
//when we using separate thread to display selection rectangle
- //it's working more better than without
+ //it's working better than without
/*
* HACK
* We need wait some time while standart event will be handled
@@ -2270,13 +2296,14 @@
* and flasher are not repainted, so we should paint flasher
*/
- Display.getDefault().asyncExec(new Thread(){
- public void run(){
-
- getXulRunnerEditor().showSelectionRectangle();
- }
- });
+ Display.getDefault().asyncExec(new Thread(){
+ public void run(){
+
+ getXulRunnerEditor().showSelectionRectangle();
+ }
+ });
+
}
/**