Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-07-31 05:48:04 -0400
committerTobias Schwarz2013-07-31 05:48:04 -0400
commitd7e09384659f1bd61c8391b79752bdd4e7528b58 (patch)
tree571ccc550b462277b766cbd8478db7936370b1af /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parent4bf05d213f6f7385216aeca4fd0546e1024de649 (diff)
downloadorg.eclipse.tcf-d7e09384659f1bd61c8391b79752bdd4e7528b58.tar.gz
org.eclipse.tcf-d7e09384659f1bd61c8391b79752bdd4e7528b58.tar.xz
org.eclipse.tcf-d7e09384659f1bd61c8391b79752bdd4e7528b58.zip
Target Explorer: add context selector auto refresh
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java
index 09876be77..1d0c9ee31 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java
@@ -10,18 +10,29 @@
package org.eclipse.tcf.te.tcf.ui.sections;
import java.util.ArrayList;
+import java.util.EventObject;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
/**
* Locator model context selector section implementation.
@@ -31,6 +42,27 @@ public abstract class AbstractContextSelectorSection extends org.eclipse.tcf.te.
// Reference to a copy of the original data
private IPropertiesContainer odc = null;
+ private boolean disposed = false;
+
+ final IModelListener modelListener = new IModelListener() {
+ @Override
+ public void locatorModelDisposed(ILocatorModel model) {
+ refreshSelectorControl();
+ }
+ @Override
+ public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added) {
+ refreshSelectorControl();
+ }
+ };
+ final IEventListener eventListener = new IEventListener() {
+ @Override
+ public void eventFired(EventObject event) {
+ if (event.getSource() instanceof IPeer || event.getSource() instanceof IPeerModel) {
+ refreshSelectorControl();
+ }
+ }
+ };
+
/**
* Constructor.
* @param form The managed form.
@@ -38,6 +70,7 @@ public abstract class AbstractContextSelectorSection extends org.eclipse.tcf.te.
*/
public AbstractContextSelectorSection(IManagedForm form, Composite parent) {
super(form, parent);
+ addListener();
}
/**
@@ -48,6 +81,64 @@ public abstract class AbstractContextSelectorSection extends org.eclipse.tcf.te.
*/
public AbstractContextSelectorSection(IManagedForm form, Composite parent, int style) {
super(form, parent, style);
+ addListener();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createClient(Section section, FormToolkit toolkit) {
+ super.createClient(section, toolkit);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection#dispose()
+ */
+ @Override
+ public void dispose() {
+ disposed = true;
+ super.dispose();
+ if (modelListener != null) {
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ Model.getModel().removeListener(modelListener);
+ }
+ });
+ }
+ if (eventListener != null) {
+ EventManager.getInstance().removeEventListener(eventListener);
+ }
+ }
+
+ protected void addListener() {
+ if (disposed) return;
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Model.getModel().addListener(modelListener);
+ }
+ });
+ EventManager.getInstance().addEventListener(eventListener, ChangeEvent.class);
+ }
+
+ protected void refreshSelectorControl() {
+ if (disposed) return;
+ if (getSelectorControl() != null) {
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ ExecutorsUtil.executeInUI(new Runnable() {
+ @Override
+ public void run() {
+ getSelectorControl().refresh();
+ getManagedForm().dirtyStateChanged();
+ }
+ });
+ }
+ });
+ }
}
public static final String encode(IModelNode[] contexts) {

Back to the top