Author: mareshkau
Date: 2008-06-10 12:58:32 -0400 (Tue, 10 Jun 2008)
New Revision: 8689
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDisposeException.java
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/VpeVisualDomBuilder.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-675
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-06-10
16:22:52 UTC (rev 8688)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-06-10
16:58:32 UTC (rev 8689)
@@ -449,11 +449,11 @@
notifyChangedInUiThread(eventBean.getNotifier(), eventBean.getEventType(),
eventBean.getFeature(), eventBean.getOldValue(), eventBean.getNewValue(),
eventBean.getPos());
- } catch (NullPointerException ex) {
- //TODO Max Areshkau
- //JBIDE-675 find possability correctly resolve nulpointer
- //exception when we closse editor and job is executed
- VpePlugin.getPluginLog().logError(ex);
+ } catch (VpeDisposeException ex) {
+ //JBIDE-675 we will get this exception if user close editor,
+ //when update visual editor job is running, we shoud ignore this
+ //exception
+ break;
}
getChangeEvents().remove(eventBean);
}
@@ -588,10 +588,17 @@
}
break;
}
- } catch (Exception e) {
- VpePlugin.reportProblem(e);
- } finally {
- switcher.stopActiveEditor();
+ }
+ finally {
+ //fix for jbide-675, swithcer is null when vpecontroller is disposed
+
+ if(switcher!=null) {
+
+ switcher.stopActiveEditor();
+ } else {
+
+ throw new VpeDisposeException("VpeController already disposed");
+ }
}
}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDisposeException.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDisposeException.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDisposeException.java 2008-06-10
16:58:32 UTC (rev 8689)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor;
+
+/**
+ * This exception throws from vpe editor update job,
+ * when editor is disposed, but we trying to update preview
+ *
+ * Fix for JBIDE-675.
+ *
+ * @author mareshkau
+ */
+
+public class VpeDisposeException extends RuntimeException {
+
+ private static final long serialVersionUID = 2984302764077199215L;
+
+ public VpeDisposeException() {
+ super();
+ }
+
+ public VpeDisposeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public VpeDisposeException(String message) {
+ super(message);
+ }
+
+ public VpeDisposeException(Throwable cause) {
+ super(cause);
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-10
16:22:52 UTC (rev 8688)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-10
16:58:32 UTC (rev 8689)
@@ -395,13 +395,20 @@
boolean registerFlag = isCurrentMainDocument();
//reads and dispatch events
+ //JBIDE-675, checks if editor was disposed or not
+ if(getPageContext().getSourceBuilder()==null ||includeDocuments==null) {
+
+ throw new VpeDisposeException();
+}
getPageContext().processDisplayEvents();
+
//check source node can be changed and link can be a null in this case
//we shouldn't process this node
if(sourceNode==null) {
return null;
}
+
switch (sourceNode.getNodeType()) {
case Node.ELEMENT_NODE:
// Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);