Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-07-31 09:48:04 +0000
committerTobias Schwarz2013-07-31 09:48:04 +0000
commitd7e09384659f1bd61c8391b79752bdd4e7528b58 (patch)
tree571ccc550b462277b766cbd8478db7936370b1af /target_explorer
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')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/AbstractContextSelectorSection.java91
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java14
4 files changed, 117 insertions, 2 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) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java
index c2a1bacb0..c5c161209 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java
@@ -406,7 +406,7 @@ public abstract class AbstractContextSelectorControl extends AbstractDecoratedDi
public IModelNode[] getCheckedModelContexts() {
// This method does return something useful only if it is a checkable
// tree viewer and the check style is set for the tree.
- if (getViewer() instanceof ContainerCheckedTreeViewer && (getTreeViewerStyle() & SWT.CHECK) != 0) {
+ if (!getViewer().getControl().isDisposed() && getViewer() instanceof ContainerCheckedTreeViewer && (getTreeViewerStyle() & SWT.CHECK) != 0) {
ContainerCheckedTreeViewer viewer = (ContainerCheckedTreeViewer) getViewer();
// Get the list of checked elements. Checked elements includes the grayed elements
List<?> checked = viewer.getCheckedElements() != null ? Arrays.asList(viewer.getCheckedElements()) : Collections.emptyList();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java
index 7c93a6e47..63887629e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java
@@ -61,6 +61,10 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp
}
}
+ protected boolean doShowRefreshAction() {
+ return false;
+ }
+
/**
* Constructor.
*
@@ -122,6 +126,10 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp
*/
protected abstract AbstractContextSelectorControl doCreateContextSelector();
+ public AbstractContextSelectorControl getSelectorControl() {
+ return selector;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#getAdapter(java.lang.Class)
*/
@@ -148,7 +156,9 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp
@Override
protected void createSectionToolbarItems(Section section, FormToolkit toolkit, ToolBarManager tlbMgr) {
super.createSectionToolbarItems(section, toolkit, tlbMgr);
- tlbMgr.add(new RefreshAction());
+ if (doShowRefreshAction()) {
+ tlbMgr.add(new RefreshAction());
+ }
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
index ba842fa1f..fd1bced92 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
@@ -246,6 +246,20 @@ public abstract class AbstractSectionDialog extends CustomTitleAreaDialog implem
}
/* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#dispose()
+ */
+ @Override
+ protected void dispose() {
+ super.dispose();
+ if (sections != null) {
+ // get working data
+ for (AbstractSection section : sections) {
+ section.dispose();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#okPressed()
*/
@Override

Back to the top