diff options
Diffstat (limited to 'target_explorer')
4 files changed, 241 insertions, 246 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/CategorizableAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/CategorizableAdapter.java index 1ac1d3c55..29a9a91a8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/CategorizableAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/CategorizableAdapter.java @@ -1,79 +1,79 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.ui.internal.adapters;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.launch.ui.model.LaunchModel;
-import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
-import org.eclipse.tcf.te.ui.views.Managers;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
-
-/**
- * Categorizable launch config node adapter implementation
- */
-public class CategorizableAdapter implements ICategorizable {
- // Reference to the adapted element
- private final LaunchNode node;
-
- /**
- * Constructor.
- *
- * @param node The adapted launch config node. Must not be <code>null</code>.
- */
- public CategorizableAdapter(LaunchNode node) {
- Assert.isNotNull(node);
- this.node = node;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#getId()
- */
- @Override
- public String getId() {
- return LaunchModel.getCategoryId(node.getLaunchConfiguration());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#isValid(org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable.OPERATION, org.eclipse.tcf.te.ui.views.interfaces.ICategory, org.eclipse.tcf.te.ui.views.interfaces.ICategory)
- */
- @Override
- public boolean isValid(OPERATION operation, ICategory parentCategory, ICategory category) {
- Assert.isNotNull(operation);
- Assert.isNotNull(category);
-
- if (OPERATION.REMOVE.equals(operation) && parentCategory != null && IUIConstants.ID_CAT_FAVORITES.equals(parentCategory.getId())) {
- return true;
- }
- if (OPERATION.ADD.equals(operation) && category != null && IUIConstants.ID_CAT_FAVORITES.equals(category.getId())) {
- return true;
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#isEnabled(org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable.OPERATION, org.eclipse.tcf.te.ui.views.interfaces.ICategory)
- */
- @Override
- public boolean isEnabled(OPERATION operation, ICategory category) {
- Assert.isNotNull(operation);
- Assert.isNotNull(category);
-
- if (OPERATION.REMOVE.equals(operation)) {
- return Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, getId());
- }
- if (OPERATION.ADD.equals(operation)) {
- return !Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, getId());
- }
- return false;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are 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 + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.adapters; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.launch.ui.model.LaunchModel; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.ui.views.Managers; +import org.eclipse.tcf.te.ui.views.interfaces.ICategory; +import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; +import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable; + +/** + * Categorizable launch config node adapter implementation + */ +public class CategorizableAdapter implements ICategorizable { + // Reference to the adapted element + private final LaunchNode node; + + /** + * Constructor. + * + * @param node The adapted launch config node. Must not be <code>null</code>. + */ + public CategorizableAdapter(LaunchNode node) { + Assert.isNotNull(node); + this.node = node; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#getId() + */ + @Override + public String getId() { + return LaunchModel.getCategoryId(node.getLaunchConfiguration()); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#isValid(org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable.OPERATION, org.eclipse.tcf.te.ui.views.interfaces.ICategory, org.eclipse.tcf.te.ui.views.interfaces.ICategory) + */ + @Override + public boolean isValid(OPERATION operation, ICategory parentCategory, ICategory category) { + Assert.isNotNull(operation); + Assert.isNotNull(category); + + if (OPERATION.REMOVE.equals(operation) && parentCategory != null && IUIConstants.ID_CAT_FAVORITES.equals(parentCategory.getId())) { + return true; + } + if (OPERATION.ADD.equals(operation) && IUIConstants.ID_CAT_FAVORITES.equals(category.getId())) { + return true; + } + + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable#isEnabled(org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable.OPERATION, org.eclipse.tcf.te.ui.views.interfaces.ICategory) + */ + @Override + public boolean isEnabled(OPERATION operation, ICategory category) { + Assert.isNotNull(operation); + Assert.isNotNull(category); + + if (OPERATION.REMOVE.equals(operation)) { + return Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, getId()); + } + if (OPERATION.ADD.equals(operation)) { + return !Managers.getCategoryManager().belongsTo(IUIConstants.ID_CAT_FAVORITES, getId()); + } + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java index 3e70051a3..323554aac 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/handler/AbstractDiagnosticsCommandHandler.java @@ -49,7 +49,6 @@ import org.eclipse.tcf.te.tcf.launch.ui.editor.AbstractTcfLaunchTabContainerEdit import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; /** @@ -165,7 +164,7 @@ public abstract class AbstractDiagnosticsCommandHandler extends AbstractHandler Assert.isNotNull(label); Assert.isNotNull(bar); - final Display display = shell != null ? shell.getDisplay() : PlatformUI.getWorkbench().getDisplay(); + final Display display = shell.getDisplay(); final TCFTestSuite.TestListener done = new TCFTestSuite.TestListener() { /* default */ String last_text = ""; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java index 548a7dda7..e232a048e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java @@ -344,82 +344,80 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { // The same applies to agent being discovered. If you don't ask for discovered peers // here too, we may miss some routes. if (ip != null && !"".equals(ip)) { //$NON-NLS-1$ - if (model != null) { - // Use the open channel to ask the remote peer what other peers it knows - ILocator locator = channel.getRemoteService(ILocator.class); - if (locator != null) { - // Channel must be kept open as long as the command runs - keepOpen = true; - // Issue the command - new Command(channel, locator, "getPeers", null) { //$NON-NLS-1$ - @Override - public void done(Exception error, Object[] args) { - if (error == null) { - Assert.isTrue(args.length == 2); - error = toError(args[0]); - } - // If the error is still null here, process the returned peers - if (error == null && args[1] != null) { - // Get the parent peer - IPeer parentPeer = channel.getRemotePeer(); - // Get the old child list - List<IPeerModel> oldChildren = new ArrayList<IPeerModel>(model.getChildren(parentPeer.getID())); - - // "getPeers" returns a collection of peer attribute maps - @SuppressWarnings("unchecked") - Collection<Map<String,String>> peerAttributesList = (Collection<Map<String,String>>)args[1]; - for (Map<String,String> attributes : peerAttributesList) { - // Don't process value-add's - String value = attributes.get("ValueAdd"); //$NON-NLS-1$ - boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ - - if (isValueAdd) continue; - - // Get the peer id - String peerId = attributes.get(IPeer.ATTR_ID); - // Create a peer instance - IPeer peer = new PeerRedirector(parentPeer, attributes); - // Try to find an existing peer node first - IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId); - if (peerNode == null) { - // Not yet known -> add it - peerNode = new PeerModel(model, peer); - peerNode.setParent(ScannerRunnable.this.peerNode); - peerNode.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, true); - // Validate the peer node before adding - peerNode = model.validateChildPeerNodeForAdd(peerNode); - if (peerNode != null) { - // Add the child peer node to model - model.getService(ILocatorModelUpdateService.class).addChild(peerNode); - } - } else { - // The parent node should be set and match - Assert.isTrue(peerNode.getParent(IPeerModel.class) != null && peerNode.getParent(IPeerModel.class).equals(ScannerRunnable.this.peerNode)); - // Peer node found, update the peer instance - peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); - // And remove it from the old child list - oldChildren.remove(peerNode); + // Use the open channel to ask the remote peer what other peers it knows + ILocator locator = channel.getRemoteService(ILocator.class); + if (locator != null) { + // Channel must be kept open as long as the command runs + keepOpen = true; + // Issue the command + new Command(channel, locator, "getPeers", null) { //$NON-NLS-1$ + @Override + public void done(Exception error, Object[] args) { + if (error == null) { + Assert.isTrue(args.length == 2); + error = toError(args[0]); + } + // If the error is still null here, process the returned peers + if (error == null && args[1] != null) { + // Get the parent peer + IPeer parentPeer = channel.getRemotePeer(); + // Get the old child list + List<IPeerModel> oldChildren = new ArrayList<IPeerModel>(model.getChildren(parentPeer.getID())); + + // "getPeers" returns a collection of peer attribute maps + @SuppressWarnings("unchecked") + Collection<Map<String,String>> peerAttributesList = (Collection<Map<String,String>>)args[1]; + for (Map<String,String> attributes : peerAttributesList) { + // Don't process value-add's + String value = attributes.get("ValueAdd"); //$NON-NLS-1$ + boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ + + if (isValueAdd) continue; + + // Get the peer id + String peerId = attributes.get(IPeer.ATTR_ID); + // Create a peer instance + IPeer peer = new PeerRedirector(parentPeer, attributes); + // Try to find an existing peer node first + IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId); + if (peerNode == null) { + // Not yet known -> add it + peerNode = new PeerModel(model, peer); + peerNode.setParent(ScannerRunnable.this.peerNode); + peerNode.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, true); + // Validate the peer node before adding + peerNode = model.validateChildPeerNodeForAdd(peerNode); + if (peerNode != null) { + // Add the child peer node to model + model.getService(ILocatorModelUpdateService.class).addChild(peerNode); } + } else { + // The parent node should be set and match + Assert.isTrue(peerNode.getParent(IPeerModel.class) != null && peerNode.getParent(IPeerModel.class).equals(ScannerRunnable.this.peerNode)); + // Peer node found, update the peer instance + peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer); + // And remove it from the old child list + oldChildren.remove(peerNode); } + } - // Everything left in the old child list is not longer known to the remote peer - // However, the child list may include manual redirected static peers. Do not - // remove them here. - for (IPeerModel child : oldChildren) { - if (!child.isStatic()) { - // Remove the child peer node from the model - model.getService(ILocatorModelUpdateService.class).removeChild(child); - } + // Everything left in the old child list is not longer known to the remote peer + // However, the child list may include manual redirected static peers. Do not + // remove them here. + for (IPeerModel child : oldChildren) { + if (!child.isStatic()) { + // Remove the child peer node from the model + model.getService(ILocatorModelUpdateService.class).removeChild(child); } } - - // Once everything is processed, close the channel - if (!sharedChannel) channel.close(); - // Invoke the callback - callback.done(ScannerRunnable.this, Status.OK_STATUS); } - }; - } + + // Once everything is processed, close the channel + if (!sharedChannel) channel.close(); + // Invoke the callback + callback.done(ScannerRunnable.this, Status.OK_STATUS); + } + }; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java index 7eff5a6c3..6ab1cd797 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/MapPersistableURIProvider.java @@ -1,95 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.locator.internal.adapters;
-
-import java.net.URI;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider;
-import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
-
-/**
- * Persistable implementation handling peer attributes.
- */
-public class MapPersistableURIProvider implements IPersistableURIProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object)
- */
- @SuppressWarnings("unchecked")
- @Override
- public URI getURI(final Object context) {
- Assert.isNotNull(context);
-
- Assert.isNotNull(null);
-
- URI uri = null;
-
- // Only map objects are supported
- if (context instanceof Map) {
- // Get the name of the peer and make it a valid
- // file system name (no spaces etc).
- String name = ((Map<String, String>) context).get(IPeer.ATTR_NAME);
- if (name == null) {
- name = ((Map<String, String>) context).get(IPeer.ATTR_ID);
- }
- name = makeValidFileSystemName(name);
- // Get the URI from the name
- uri = getRoot().append(name).toFile().toURI();
- }
-
- return uri;
- }
-
- /**
- * Make a valid file system name from the given name.
- *
- * @param name The original name. Must not be <code>null</code>.
- * @return The valid file system name.
- */
- private String makeValidFileSystemName(String name) {
- Assert.isNotNull(name);
- return name.replaceAll("\\W", "_"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Returns the root location.
- *
- * @return The root location or <code>null</code> if it cannot be determined.
- */
- protected IPath getRoot() {
- IPath location = null;
-
- // Try the bundles state location first (not available if launched with -data @none).
- try {
- IPath path = CoreBundleActivator.getDefault().getStateLocation().append(".peers"); //$NON-NLS-1$
- boolean exists = path.toFile().exists();
- if (!exists) exists = path.toFile().mkdirs();
- if (exists && path.toFile().canRead() && path.toFile().isDirectory()) {
- location = path;
- }
- } catch (IllegalStateException e) {
- // Workspace less environments (-data @none)
- // The users local peers lookup directory is $HOME/.tcf/.peers.
- IPath path = new Path(System.getProperty("user.home")).append(".tcf/.peers"); //$NON-NLS-1$ //$NON-NLS-2$
- boolean exists = path.toFile().exists();
- if (!exists) exists = path.toFile().mkdirs();
- if (exists && path.toFile().canRead() && path.toFile().isDirectory()) {
- location = path;
- }
- }
-
- return location;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are 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 + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.locator.internal.adapters; + +import java.net.URI; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider; +import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; + +/** + * Persistable implementation handling peer attributes. + */ +public class MapPersistableURIProvider implements IPersistableURIProvider { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object) + */ + @SuppressWarnings("unchecked") + @Override + public URI getURI(final Object context) { + Assert.isNotNull(context); + + URI uri = null; + + // Only map objects are supported + if (context instanceof Map) { + // Get the name of the peer and make it a valid + // file system name (no spaces etc). + String name = ((Map<String, String>) context).get(IPeer.ATTR_NAME); + if (name == null) { + name = ((Map<String, String>) context).get(IPeer.ATTR_ID); + } + name = makeValidFileSystemName(name); + // Get the URI from the name + uri = getRoot().append(name).toFile().toURI(); + } + + return uri; + } + + /** + * Make a valid file system name from the given name. + * + * @param name The original name. Must not be <code>null</code>. + * @return The valid file system name. + */ + private String makeValidFileSystemName(String name) { + Assert.isNotNull(name); + return name.replaceAll("\\W", "_"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Returns the root location. + * + * @return The root location or <code>null</code> if it cannot be determined. + */ + protected IPath getRoot() { + IPath location = null; + + // Try the bundles state location first (not available if launched with -data @none). + try { + IPath path = CoreBundleActivator.getDefault().getStateLocation().append(".peers"); //$NON-NLS-1$ + boolean exists = path.toFile().exists(); + if (!exists) exists = path.toFile().mkdirs(); + if (exists && path.toFile().canRead() && path.toFile().isDirectory()) { + location = path; + } + } catch (IllegalStateException e) { + // Workspace less environments (-data @none) + // The users local peers lookup directory is $HOME/.tcf/.peers. + IPath path = new Path(System.getProperty("user.home")).append(".tcf/.peers"); //$NON-NLS-1$ //$NON-NLS-2$ + boolean exists = path.toFile().exists(); + if (!exists) exists = path.toFile().mkdirs(); + if (exists && path.toFile().canRead() && path.toFile().isDirectory()) { + location = path; + } + } + + return location; + } +} |