Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-07-25 05:33:53 +0000
committerTobias Schwarz2014-07-25 05:33:53 +0000
commit3fa84bb548a7479ded66a8d93f7205e838968964 (patch)
treea6584d7f3157a199d391ee73775db4915ffd0c7c
parent8cd5faa27ca924b448ba211780b795ff3658bb71 (diff)
downloadorg.eclipse.tcf-3fa84bb548a7479ded66a8d93f7205e838968964.tar.gz
org.eclipse.tcf-3fa84bb548a7479ded66a8d93f7205e838968964.tar.xz
org.eclipse.tcf-3fa84bb548a7479ded66a8d93f7205e838968964.zip
Target Explorer: rework proxy model refresh
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java131
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java9
5 files changed, 101 insertions, 58 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java
index 08ab3edfe..3c2f9570d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java
@@ -136,7 +136,11 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
List<ILocatorNode> nodes = new ArrayList<ILocatorNode>();
for (ILocatorNode node : locatorNodes) {
- if (agentId.equals(node.getPeer().getAgentID())) {
+ String nodeAgentId = node.getPeer().getAgentID();
+ if (nodeAgentId == null) {
+ nodeAgentId = node.getStringProperty(IPeer.ATTR_AGENT_ID);
+ }
+ if (agentId.equals(nodeAgentId)) {
nodes.add(node);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
index 2a0cbeca2..941f8c0f4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
@@ -29,6 +29,7 @@ import org.eclipse.tcf.core.Command;
import org.eclipse.tcf.core.TransientPeer;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.ILocator;
import org.eclipse.tcf.te.runtime.callback.Callback;
@@ -186,7 +187,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// Get the parent peer model
- ILocatorModel model = getLocatorModel();
+ final ILocatorModel model = getLocatorModel();
// If the parent model is already disposed, the service will drop out immediately
if (model.isDisposed()) {
@@ -230,34 +231,40 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
};
- Tcf.getChannelManager()
- .openChannel(locatorNode.getPeer(), flags, new IChannelManager.DoneOpenChannel() {
- @Override
- public void doneOpenChannel(Throwable error, final IChannel channel) {
- if (error != null || channel == null) {
- locatorNode.removeAll(ILocatorNode.class);
- refreshCtx.setQueryState(QueryType.CONTEXT, QueryState.DONE);
- refreshCtx.setQueryState(QueryType.CHILD_LIST, QueryState.DONE);
- if (channel != null) {
- Tcf.getChannelManager().closeChannel(channel);
- }
- invokeCallback(finCb);
- }
- else {
- onDoneOpenChannelRefreshLocatorNode(channel, locatorNode, new Callback(finCb) {
- @Override
- protected void internalDone(Object caller, org.eclipse.core.runtime.IStatus status) {
- Tcf.getChannelManager().closeChannel(channel);
- }
- });
- }
- }
- });
+ Tcf.getChannelManager().openChannel(locatorNode.getPeer(), flags, new IChannelManager.DoneOpenChannel() {
+ @Override
+ public void doneOpenChannel(Throwable error, final IChannel channel) {
+ if (error != null || channel == null) {
+ locatorNode.removeAll(ILocatorNode.class);
+ refreshCtx.setQueryState(QueryType.CONTEXT, QueryState.DONE);
+ refreshCtx.setQueryState(QueryType.CHILD_LIST, QueryState.DONE);
+ if (channel != null) {
+ Tcf.getChannelManager().closeChannel(channel);
+ }
+ if (locatorNode.isStatic()) {
+ locatorNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, locatorNode.getProperty(ILocatorNode.PROPERTY_STATIC_INSTANCE));
+ }
+ else {
+ ILocatorModelUpdateService update = model.getService(ILocatorModelUpdateService.class);
+ update.remove(locatorNode.getPeer());
+ }
+ invokeCallback(finCb);
+ }
+ else {
+ onDoneOpenChannelRefreshLocatorNode(channel, locatorNode, new Callback(finCb) {
+ @Override
+ protected void internalDone(Object caller, org.eclipse.core.runtime.IStatus status) {
+ Tcf.getChannelManager().closeChannel(channel);
+ }
+ });
+ }
+ }
+ });
}
- protected void onDoneOpenChannelRefreshLocatorNode(IChannel channel, ILocatorNode locatorNode, ICallback callback) {
- ILocator locator = channel.getRemoteService(ILocator.class);
- IAsyncRefreshableCtx refreshCtx = (IAsyncRefreshableCtx) locatorNode
+ protected void onDoneOpenChannelRefreshLocatorNode(final IChannel channel, final ILocatorNode locatorNode, final ICallback callback) {
+ final ILocator locator = channel.getRemoteService(ILocator.class);
+ final IAsyncRefreshableCtx refreshCtx = (IAsyncRefreshableCtx) locatorNode
.getAdapter(IAsyncRefreshableCtx.class);
if (locator == null) {
locatorNode.removeAll(ILocatorNode.class);
@@ -266,8 +273,16 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
invokeCallback(callback);
}
else {
- refreshCtx.setQueryState(QueryType.CONTEXT, QueryState.DONE);
- getPeers(locator, channel, locatorNode, callback);
+ locator.getAgentID(new ILocator.DoneGetAgentID() {
+ @Override
+ public void doneGetAgentID(IToken token, Exception error, String agentID) {
+ if (error == null) {
+ locatorNode.setProperty(IPeer.ATTR_AGENT_ID, agentID);
+ }
+ refreshCtx.setQueryState(QueryType.CONTEXT, QueryState.DONE);
+ getPeers(locator, channel, locatorNode, callback);
+ }
+ });
}
}
@@ -296,12 +311,19 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
ILocatorModelLookupService lkup = getLocatorModel()
.getService(ILocatorModelLookupService.class);
+ String parentAgentId = locatorNode.getPeer().getAgentID();
+ if (parentAgentId == null) {
+ parentAgentId = locatorNode.getStringProperty(IPeer.ATTR_AGENT_ID);
+ }
+ String parentId = normalizeId(locatorNode.getPeer().getID());
+
@SuppressWarnings("unchecked")
Collection<Map<String, String>> peerAttributesList = (Collection<Map<String, String>>) args[1];
for (Map<String, String> attributes : peerAttributesList) {
String agentId = attributes.get(IPeer.ATTR_AGENT_ID);
String id = attributes.get(IPeer.ATTR_ID);
+ String normalizedId = normalizeId(id);
ILocatorNode existing = null;
ILocatorNode[] lkupNodes = agentId != null ? lkup
.lkupLocatorNodeByAgentId(locatorNode, agentId) : new ILocatorNode[0];
@@ -309,15 +331,13 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
lkupNodes = id != null ? lkup.lkupLocatorNodeById(locatorNode, id) : new ILocatorNode[0];
}
for (ILocatorNode node : lkupNodes) {
- if (node.getPeer().getID().equals(id)) {
+ if (normalizeId(node.getPeer().getID()).equals(normalizedId)) {
oldChildren.remove(node);
existing = node;
break;
}
}
- String parentAgentId = locatorNode.getPeer().getAgentID();
- String parentId = locatorNode.getPeer().getID();
if (agentId != null && !agentId.equals(parentAgentId)) {
ILocatorNode parent = locatorNode.getParent(ILocatorNode.class);
ILocatorNode[] parentNodes = lkup
@@ -328,35 +348,44 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
attributes = new HashMap<String, String>(attributes);
+ attributes.put(IPeerProperties.PROP_PROXIES, encProxies);
+ IPeer peer = new TransientPeer(attributes);
- if (parentAgentId == null && id.equals(parentId)) {
- attributes.put(IPeerProperties.PROP_PROXIES, parentProxies);
- IPeer peer = new TransientPeer(attributes);
- locatorNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
+ if (existing == null) {
+ if (parentNodes.length == 0 && !isFiltered(peer)) {
+ locatorNode.add(new LocatorNode(peer));
+ }
}
else {
- attributes.put(IPeerProperties.PROP_PROXIES, encProxies);
- IPeer peer = new TransientPeer(attributes);
- if (existing == null) {
- if (parentNodes.length == 0 && !isFiltered(peer)) {
- locatorNode.add(new LocatorNode(peer));
- }
+ if (parentNodes.length == 0 && !isFiltered(peer)) {
+ existing.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
}
else {
- existing.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
+ locatorNode.remove(existing, true);
}
}
}
+ else if (locatorNode.isStatic()) {
+ attributes = new HashMap<String, String>(attributes);
+ attributes.put(IPeerProperties.PROP_PROXIES, parentProxies);
+ attributes.putAll(((IPeer)locatorNode.getProperty(ILocatorNode.PROPERTY_STATIC_INSTANCE)).getAttributes());
+ IPeer peer = new TransientPeer(attributes);
+ locatorNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
+ }
}
for (ILocatorNode old : oldChildren) {
if (!old.isStatic()) {
locatorNode.remove(old, true);
}
}
- if (locatorNode.isStatic() && locatorNode.getPeer().getAgentID() != null) {
- String parentAgentId = locatorNode.getPeer().getAgentID();
- for (ILocatorNode child : locatorNode.getChildren(ILocatorNode.class)) {
- if (parentAgentId.equals(child.getPeer().getAgentID())) {
+ for (ILocatorNode child : locatorNode.getChildren(ILocatorNode.class)) {
+ String childAgentId = child.getPeer().getAgentID();
+ String childId = child.getPeer().getID();
+ if (parentAgentId.equals(childAgentId)) {
+ locatorNode.remove(child, true);
+ }
+ else if (parentId != null) {
+ if (parentId.equals(normalizeId(childId))) {
locatorNode.remove(child, true);
}
}
@@ -385,6 +414,14 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
+ protected String normalizeId(String id) {
+ if (id != null) {
+ id = id.toLowerCase().replaceAll(":localhost:", "::"); //$NON-NLS-1$ //$NON-NLS-2$
+ id = id.replaceAll(":127\\.0+\\.0+\\.0*1:", "::"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return id;
+ }
+
/**
* Returns if or if not the given peer is filtered.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java
index f5bdeb5b7..7ef406a20 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/PeersByCurrentUserFilter.java
@@ -16,6 +16,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorNode;
/**
* Filter implementation filtering peers not started by the current user.
@@ -28,13 +29,14 @@ public class PeersByCurrentUserFilter extends ViewerFilter {
*/
@Override
public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
- if (element instanceof IPeer) {
+ if (element instanceof IPeer || element instanceof ILocatorNode) {
+ final IPeer peer = element instanceof IPeer ? (IPeer)element : ((ILocatorNode)element).getPeer();
final AtomicReference<String> user = new AtomicReference<String>();
Runnable runnable = new Runnable() {
@Override
public void run() {
- user.set(((IPeer)element).getUserName());
+ user.set(peer.getUserName());
}
};
Assert.isTrue(!Protocol.isDispatchThread());
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
index 10261755f..791a8ff44 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
@@ -60,8 +60,6 @@ import org.eclipse.ui.navigator.INavigatorFilterService;
public class ContentProvider implements ICommonContentProvider, ITreePathContentProvider {
private final static Object[] NO_ELEMENTS = new Object[0];
- // The "Redirected Peers" filter id
- private final static String REDIRECT_PEERS_FILTER_ID = "org.eclipse.tcf.te.tcf.ui.navigator.RedirectPeersFilter"; //$NON-NLS-1$
// The current user filter id
private final static String CURRENT_USER_FILTER_ID = "org.eclipse.tcf.te.tcf.ui.navigator.PeersByCurrentUserFilter"; //$NON-NLS-1$
@@ -506,11 +504,6 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent
}
}
- if (!activeFilderIds.contains(REDIRECT_PEERS_FILTER_ID)) {
- activeFilderIds.add(REDIRECT_PEERS_FILTER_ID);
- activeFiltersChanged = true;
- }
-
if (UIPlugin.getDefault().getPreferenceStore().getBoolean(IPreferenceKeys.PREF_ACTIVATE_CURRENT_USER_FILTER)
&& !navFilterService.isActive(CURRENT_USER_FILTER_ID)) {
IDialogSettings settings = UIPlugin.getDefault().getDialogSettings();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java
index 7738d6335..d89354cc9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java
@@ -193,9 +193,16 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe
public String decorateText(String text, Object element) {
if (element instanceof ILocatorNode) {
String ip = ((ILocatorNode)element).getPeer().getAttributes().get(IPeer.ATTR_IP_HOST);
+ String port = ((ILocatorNode)element).getPeer().getAttributes().get(IPeer.ATTR_IP_PORT);
+ if (port == null || port.trim().equals("1534")) { //$NON-NLS-1$
+ port = ""; //$NON-NLS-1$
+ }
+ else {
+ port = ":" + port.trim(); //$NON-NLS-1$
+ }
if (text != null && ip != null && !text.contains(ip)) {
- text += " (" + ip + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ text += " (" + ip + port + ")"; //$NON-NLS-1$ //$NON-NLS-2$
return text;
}
}

Back to the top