Author: yradtsevich
Date: 2011-12-09 11:11:58 -0500 (Fri, 09 Dec 2011)
New Revision: 37175
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/IVpeUpdateListener.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
https://issues.jboss.org/browse/JBIDE-10357 : Add listeners in VpeController to support
full/partial VPE refresh monitoring.
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/IVpeUpdateListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/IVpeUpdateListener.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/IVpeUpdateListener.java 2011-12-09
16:11:58 UTC (rev 37175)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor;
+
+/**
+ * Fired at the end of the VPE update/refresh jobs.
+ *
+ * @since 3.3
+ * @author Maxim Shmidov
+ */
+public interface IVpeUpdateListener {
+ void vpeUpdated();
+}
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-09
16:09:09 UTC (rev 37174)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2011-12-09
16:11:58 UTC (rev 37175)
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.MenuManager;
@@ -241,6 +242,8 @@
// contains vpe update delau time in miliseconds
private int vpeUpdateDelayTime;
+ private ListenerList updateListeners = new ListenerList();
+
public VpeController(VpeEditorPart editPart) {
this.editPart = editPart;
@@ -1403,6 +1406,7 @@
visualRefreshImpl();
monitor.done();
setSynced(true);
+ notifyVpeUpdateListeners();
return Status.OK_STATUS;
}
};
@@ -1596,6 +1600,7 @@
switcher.stopActiveEditor();
}
monitor.done();
+ notifyVpeUpdateListeners();
return Status.OK_STATUS;
}
@@ -2245,5 +2250,26 @@
public VpeDropWindow getDropWindow() {
return dropWindow;
}
-
+
+ /**
+ * Adds an event listener which is notified at the end
+ * of VPE update/refresh jobs. This allows clients to know when
+ * changing of the visual part is completed.
+ *
+ * @since 3.3
+ */
+ public void addVpeRefreshListener(final IVpeUpdateListener listener) {
+ updateListeners.add(listener);
+ }
+
+ /** @since 3.3 */
+ public void removeVpeRefreshListener(final IVpeUpdateListener listener) {
+ updateListeners.remove(listener);
+ }
+
+ private void notifyVpeUpdateListeners() {
+ for (Object listener : updateListeners.getListeners()) {
+ ((IVpeUpdateListener) listener).vpeUpdated();
+ }
+ }
}