Author: dgolovin
Date: 2011-12-01 15:21:57 -0500 (Thu, 01 Dec 2011)
New Revision: 36849
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
reverted patch with full document rebuild optimization, because it has problem with
loosing events
applied previous patch which seems to have right behavior without optimization
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java 2011-12-01
20:16:05 UTC (rev 36848)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java 2011-12-01
20:21:57 UTC (rev 36849)
@@ -1,40 +0,0 @@
-package org.jboss.tools.vpe.editor;
-
-public class ActiveEditorSwitcher {
- public static final int ACTIVE_EDITOR_CANNOT = 0;
- public static final int ACTIVE_EDITOR_NONE = 1;
- public static final int ACTIVE_EDITOR_SOURCE = 2;
- public static final int ACTIVE_EDITOR_VISUAL = 3;
-
- private int type = ACTIVE_EDITOR_CANNOT;
- private VpeController vpeController;
- private VpeEditorPart editPart;
-
- public ActiveEditorSwitcher(VpeController vpeController, VpeEditorPart editPart) {
- this.vpeController = vpeController;
- this.editPart = editPart;
- }
-
- public void initActiveEditor() {
- type = ACTIVE_EDITOR_NONE;
- }
-
- public void destroyActiveEditor() {
- type = ACTIVE_EDITOR_CANNOT;
- }
-
- public boolean startActiveEditor(int newType) {
- if (type != ACTIVE_EDITOR_NONE || type == ACTIVE_EDITOR_NONE && newType ==
ACTIVE_EDITOR_SOURCE
- && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
- return false;
- } else {
- type = newType;
- return true;
- }
- }
-
- public void stopActiveEditor() {
- vpeController.onRefresh();
- type = ACTIVE_EDITOR_NONE;
- }
-}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java 2011-12-01
20:21:57 UTC (rev 36849)
@@ -0,0 +1,40 @@
+package org.jboss.tools.vpe.editor;
+
+public class ActiveEditorSwitcher {
+ public static final int ACTIVE_EDITOR_CANNOT = 0;
+ public static final int ACTIVE_EDITOR_NONE = 1;
+ public static final int ACTIVE_EDITOR_SOURCE = 2;
+ public static final int ACTIVE_EDITOR_VISUAL = 3;
+
+ private int type = ACTIVE_EDITOR_CANNOT;
+ private VpeController vpeController;
+ private VpeEditorPart editPart;
+
+ public ActiveEditorSwitcher(VpeController vpeController, VpeEditorPart editPart) {
+ this.vpeController = vpeController;
+ this.editPart = editPart;
+ }
+
+ public void initActiveEditor() {
+ type = ACTIVE_EDITOR_NONE;
+ }
+
+ public void destroyActiveEditor() {
+ type = ACTIVE_EDITOR_CANNOT;
+ }
+
+ public boolean startActiveEditor(int newType) {
+ if (type != ACTIVE_EDITOR_NONE || type == ACTIVE_EDITOR_NONE && newType ==
ACTIVE_EDITOR_SOURCE
+ && editPart.getVisualMode() == VpeEditorPart.SOURCE_MODE) {
+ return false;
+ } else {
+ type = newType;
+ return true;
+ }
+ }
+
+ public void stopActiveEditor() {
+ vpeController.onRefresh();
+ type = ACTIVE_EDITOR_NONE;
+ }
+}
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ActiveEditorSwitcher.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2011-12-01
20:16:05 UTC (rev 36848)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2011-12-01
20:21:57 UTC (rev 36849)
@@ -164,7 +164,6 @@
MozillaContextMenuListener, MozillaResizeListener,
MozillaAfterPaintListener, MozillaScrollListener {
- public static final int DEFAULT_UPDATE_DELAY_TIME = 400;
private boolean visualEditorVisible = true;
private boolean synced = true;
StructuredTextEditor sourceEditor;
Deleted:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java 2011-12-01
20:16:05 UTC (rev 36848)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java 2011-12-01
20:21:57 UTC (rev 36849)
@@ -1,113 +0,0 @@
-package org.jboss.tools.vpe.editor;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.progress.UIJob;
-import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
-import org.jboss.tools.vpe.messages.VpeUIMessages;
-
-public class VpeUpdateJob extends UIJob {
-
- protected boolean execState = false;
-
- protected VpeController vpeController;
- protected ActiveEditorSwitcher switcher;
-
- public VpeUpdateJob(VpeController vpeController, ActiveEditorSwitcher switcher) {
- super(VpeUIMessages.VPE_UPDATE_JOB_TITLE);
- this.vpeController = vpeController;
- this.switcher = switcher;
- }
-
- protected synchronized void setExecState(boolean execState) {
- this.execState = execState;
- }
-
- protected synchronized boolean isExecState() {
- return execState;
- }
-
- public void interrupt() {
- setExecState(false);
- }
-
- public void execute() {
- setExecState(true);
- schedule();
- }
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- IStatus res = Status.OK_STATUS;
- final int totalWork = 10000;
- final int maxQueue4WholeRefresh = 30;
- monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE, totalWork);
- final List<VpeEventBean> changeEvents = vpeController.getChangeEvents();
- while (changeEvents.size() > 0) {
- if (!isExecState()) {
- break;
- }
- if (changeEvents.size() > maxQueue4WholeRefresh) {
- changeEvents.clear();
- monitor.worked((int) (totalWork / 2));
- vpeController.reinitImpl();
- monitor.worked(totalWork);
- break;
- }
- monitor.worked((int) (totalWork / changeEvents.size()));
- VpeEventBean eventBean = changeEvents.remove(0);
- if (monitor.isCanceled()) {
- // Yahor Radtsevich: the following line is commented as fix of JBIDE-3758: VPE
autorefresh is broken in
- // some cases. Now if the change events queue should be cleared, the user have to do
it explicitly.
- // getChangeEvents().clear();
- res = Status.CANCEL_STATUS;
- break;
- }
- try {
- vpeController.notifyChangedInUiThread(eventBean);
- } 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;
- } catch (NullPointerException ex) {
- if (switcher != null) {
- throw ex;
- } else {
- // class was disposed and exception result
- // of that we can't stop
- // refresh job in time, so we just ignore
- // this exception
- }
- } catch (RuntimeException ex) {
- VpePlugin.getPluginLog().logError(ex);
- }
- }
- if (isExecState() && res == Status.OK_STATUS) {
- // cause is to lock calls others events
- if (switcher != null &&
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
- try {
- vpeController.sourceSelectionChanged();
- //
https://jira.jboss.org/jira/browse/JBIDE-3619 VpeViewUpdateJob takes place after
toolbar selection
- // have been updated. New nodes haven't been put into dom mapping thus toolbar
becomes desabled.
- // Updating toolbar state here takes into account updated vpe nodes.
- final FormatControllerManager tfcm =
vpeController.getToolbarFormatControllerManager();
- if (tfcm != null) {
- tfcm.selectionChanged();
- }
- } finally {
- switcher.stopActiveEditor();
- }
- }
- }
- monitor.done();
- return res;
- }
-
-}
\ No newline at end of file
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java 2011-12-01
20:21:57 UTC (rev 36849)
@@ -0,0 +1,113 @@
+package org.jboss.tools.vpe.editor;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.progress.UIJob;
+import org.jboss.tools.vpe.VpePlugin;
+import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
+import org.jboss.tools.vpe.messages.VpeUIMessages;
+
+public class VpeUpdateJob extends UIJob {
+
+ protected boolean execState = false;
+
+ protected VpeController vpeController;
+ protected ActiveEditorSwitcher switcher;
+
+ public VpeUpdateJob(VpeController vpeController, ActiveEditorSwitcher switcher) {
+ super(VpeUIMessages.VPE_UPDATE_JOB_TITLE);
+ this.vpeController = vpeController;
+ this.switcher = switcher;
+ }
+
+ protected synchronized void setExecState(boolean execState) {
+ this.execState = execState;
+ }
+
+ protected synchronized boolean isExecState() {
+ return execState;
+ }
+
+ public void interrupt() {
+ setExecState(false);
+ }
+
+ public void execute() {
+ setExecState(true);
+ schedule();
+ }
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ IStatus res = Status.OK_STATUS;
+ final int totalWork = 10000;
+ final int maxQueue4WholeRefresh = 30;
+ monitor.beginTask(VpeUIMessages.VPE_UPDATE_JOB_TITLE, totalWork);
+ final List<VpeEventBean> changeEvents = vpeController.getChangeEvents();
+ while (changeEvents.size() > 0) {
+ if (!isExecState()) {
+ break;
+ }
+ if (changeEvents.size() > maxQueue4WholeRefresh) {
+ changeEvents.clear();
+ monitor.worked((int) (totalWork / 2));
+ vpeController.reinitImpl();
+ monitor.worked(totalWork);
+ break;
+ }
+ monitor.worked((int) (totalWork / changeEvents.size()));
+ VpeEventBean eventBean = changeEvents.remove(0);
+ if (monitor.isCanceled()) {
+ // Yahor Radtsevich: the following line is commented as fix of JBIDE-3758: VPE
autorefresh is broken in
+ // some cases. Now if the change events queue should be cleared, the user have to do
it explicitly.
+ // getChangeEvents().clear();
+ res = Status.CANCEL_STATUS;
+ break;
+ }
+ try {
+ vpeController.notifyChangedInUiThread(eventBean);
+ } 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;
+ } catch (NullPointerException ex) {
+ if (switcher != null) {
+ throw ex;
+ } else {
+ // class was disposed and exception result
+ // of that we can't stop
+ // refresh job in time, so we just ignore
+ // this exception
+ }
+ } catch (RuntimeException ex) {
+ VpePlugin.getPluginLog().logError(ex);
+ }
+ }
+ if (isExecState() && res == Status.OK_STATUS) {
+ // cause is to lock calls others events
+ if (switcher != null &&
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_SOURCE)) {
+ try {
+ vpeController.sourceSelectionChanged();
+ //
https://jira.jboss.org/jira/browse/JBIDE-3619 VpeViewUpdateJob takes place after
toolbar selection
+ // have been updated. New nodes haven't been put into dom mapping thus toolbar
becomes desabled.
+ // Updating toolbar state here takes into account updated vpe nodes.
+ final FormatControllerManager tfcm =
vpeController.getToolbarFormatControllerManager();
+ if (tfcm != null) {
+ tfcm.selectionChanged();
+ }
+ } finally {
+ switcher.stopActiveEditor();
+ }
+ }
+ }
+ monitor.done();
+ return res;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeUpdateJob.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain