diff options
author | Uwe Stieber | 2013-07-10 08:48:26 +0000 |
---|---|---|
committer | Uwe Stieber | 2013-07-10 08:48:26 +0000 |
commit | f02b03ca0ec5b1055c5896cbadb9f2b2ece2b0bb (patch) | |
tree | f2ecd2b7d4a1090451e6c6e21e8edf99868d544f | |
parent | 1463305593bde20a65523d3fbd91cc34b803c522 (diff) | |
download | org.eclipse.tcf-f02b03ca0ec5b1055c5896cbadb9f2b2ece2b0bb.tar.gz org.eclipse.tcf-f02b03ca0ec5b1055c5896cbadb9f2b2ece2b0bb.tar.xz org.eclipse.tcf-f02b03ca0ec5b1055c5896cbadb9f2b2ece2b0bb.zip |
Target Explorer: Fix remote file system issues
13 files changed, 796 insertions, 860 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java index a3da6f82a..38bc25596 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java @@ -69,20 +69,20 @@ public class ExecutableExtension extends PlatformObject implements IExecutableEx // Initialize the id field by reading the <id> extension attribute. // Throws an exception if the id is empty or null. - id = config != null ? config.getAttribute("id") : null; //$NON-NLS-1$ + id = config.getAttribute("id"); //$NON-NLS-1$ if (id == null || "".equals(id.trim())) { //$NON-NLS-1$ throw createMissingMandatoryAttributeException("id", config.getContributor().getName()); //$NON-NLS-1$ } // Try the "label" attribute first - label = config != null ? config.getAttribute("label") : null; //$NON-NLS-1$ + label = config.getAttribute("label"); //$NON-NLS-1$ // If "label" is not found or empty, try the "name" attribute as fallback if (label == null || "".equals(label.trim())) { //$NON-NLS-1$ - label = config != null ? config.getAttribute("name") : null; //$NON-NLS-1$ + label = config.getAttribute("name"); //$NON-NLS-1$ } // Read the description text from the "<description>" child element - IConfigurationElement[] children = config != null ? config.getChildren("description") : null; //$NON-NLS-1$ + IConfigurationElement[] children = config.getChildren("description"); //$NON-NLS-1$ // Only one description element is allow. All other will be ignored if (children != null && children.length > 0) { IConfigurationElement element = children[0]; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/BindingExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/BindingExtensionPointManager.java index b8a90ab56..d06c74000 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/BindingExtensionPointManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/internal/BindingExtensionPointManager.java @@ -1,181 +1,175 @@ -/*******************************************************************************
- * 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.tcf.core.va.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator;
-
-
-/**
- * Value-add bindings extension point manager implementation.
- */
-public class BindingExtensionPointManager extends AbstractExtensionPointManager<Binding> {
-
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstance {
- public static BindingExtensionPointManager instance = new BindingExtensionPointManager();
- }
-
- /**
- * Constructor.
- */
- BindingExtensionPointManager() {
- super();
- }
-
- /**
- * Returns the singleton instance of the extension point manager.
- */
- public static BindingExtensionPointManager getInstance() {
- return LazyInstance.instance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.tcf.core.valueaddBindings"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "binding"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement)
- */
- @Override
- protected ExecutableExtensionProxy<Binding> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
- return new ExecutableExtensionProxy<Binding>(element) {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy#newInstance()
- */
- @Override
- public Binding newInstance() {
- Binding instance = new Binding();
- try {
- instance.setInitializationData(getConfigurationElement(), null, null);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- return instance;
- }
- };
- }
-
- /**
- * Returns the applicable value-add bindings for the given delegate context.
- *
- * @param peer The peer. Must not be <code>null</code>.
- *
- * @return The list of applicable value-add bindings or an empty array.
- */
- public Binding[] getApplicableBindings(IPeer peer) {
- Assert.isNotNull(peer);
-
- List<Binding> applicable = new ArrayList<Binding>();
-
- for (Binding binding : getBindings()) {
- Expression enablement = binding.getEnablement();
-
- // The binding is *not* applicable by default if no expression is specified.
- boolean isApplicable = false;
-
- if (enablement != null) {
- if (peer != null) {
- // Set the default variable to the peer.
- EvaluationContext evalContext = new EvaluationContext(null, peer);
- evalContext.addVariable("peer", peer); //$NON-NLS-1$
- // Allow plugin activation
- evalContext.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- isApplicable = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- e.getLocalizedMessage(), e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- } else {
- // The enablement is false by definition if no peer is given.
- isApplicable = false;
- }
- }
-
- // Add the binding if applicable
- if (isApplicable) {
- applicable.add(binding);
- }
- }
-
- return applicable.toArray(new Binding[applicable.size()]);
- }
-
- /**
- * Returns the list of all contributed value-add bindings.
- *
- * @return The list of contributed value-add bindings, or an empty array.
- */
- public Binding[] getBindings() {
- List<Binding> contributions = new ArrayList<Binding>();
- Collection<ExecutableExtensionProxy<Binding>> bindings = getExtensions().values();
- for (ExecutableExtensionProxy<Binding> binding : bindings) {
- Binding instance = binding.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
-
- return contributions.toArray(new Binding[contributions.size()]);
- }
-
- /**
- * Returns the value-add binding identified by its unique id. If no value
- * add binding with the specified id is registered, <code>null</code> is returned.
- *
- * @param id The unique id of the value-add binding or <code>null</code>
- *
- * @return The value-add binding instance or <code>null</code>.
- */
- public Binding getBinding(String id) {
- Binding contribution = null;
- if (getExtensions().containsKey(id)) {
- ExecutableExtensionProxy<Binding> proxy = getExtensions().get(id);
- // Get the extension instance
- contribution = proxy.getInstance();
- }
-
- return contribution;
- }
-}
+/******************************************************************************* + * 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.tcf.core.va.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.expressions.EvaluationContext; +import org.eclipse.core.expressions.EvaluationResult; +import org.eclipse.core.expressions.Expression; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager; +import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy; +import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator; + + +/** + * Value-add bindings extension point manager implementation. + */ +public class BindingExtensionPointManager extends AbstractExtensionPointManager<Binding> { + + /* + * Thread save singleton instance creation. + */ + private static class LazyInstance { + public static BindingExtensionPointManager instance = new BindingExtensionPointManager(); + } + + /** + * Constructor. + */ + BindingExtensionPointManager() { + super(); + } + + /** + * Returns the singleton instance of the extension point manager. + */ + public static BindingExtensionPointManager getInstance() { + return LazyInstance.instance; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId() + */ + @Override + protected String getExtensionPointId() { + return "org.eclipse.tcf.te.tcf.core.valueaddBindings"; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName() + */ + @Override + protected String getConfigurationElementName() { + return "binding"; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement) + */ + @Override + protected ExecutableExtensionProxy<Binding> doCreateExtensionProxy(IConfigurationElement element) throws CoreException { + return new ExecutableExtensionProxy<Binding>(element) { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy#newInstance() + */ + @Override + public Binding newInstance() { + Binding instance = new Binding(); + try { + instance.setInitializationData(getConfigurationElement(), null, null); + } catch (CoreException e) { + IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), + e.getLocalizedMessage(), e); + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + } + return instance; + } + }; + } + + /** + * Returns the applicable value-add bindings for the given delegate context. + * + * @param peer The peer. Must not be <code>null</code>. + * + * @return The list of applicable value-add bindings or an empty array. + */ + public Binding[] getApplicableBindings(IPeer peer) { + Assert.isNotNull(peer); + + List<Binding> applicable = new ArrayList<Binding>(); + + for (Binding binding : getBindings()) { + Expression enablement = binding.getEnablement(); + + // The binding is *not* applicable by default if no expression is specified. + boolean isApplicable = false; + + if (enablement != null) { + // Set the default variable to the peer. + EvaluationContext evalContext = new EvaluationContext(null, peer); + evalContext.addVariable("peer", peer); //$NON-NLS-1$ + // Allow plugin activation + evalContext.setAllowPluginActivation(true); + // Evaluate the expression + try { + isApplicable = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE); + } catch (CoreException e) { + IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), e.getLocalizedMessage(), e); + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + } + } + + // Add the binding if applicable + if (isApplicable) { + applicable.add(binding); + } + } + + return applicable.toArray(new Binding[applicable.size()]); + } + + /** + * Returns the list of all contributed value-add bindings. + * + * @return The list of contributed value-add bindings, or an empty array. + */ + public Binding[] getBindings() { + List<Binding> contributions = new ArrayList<Binding>(); + Collection<ExecutableExtensionProxy<Binding>> bindings = getExtensions().values(); + for (ExecutableExtensionProxy<Binding> binding : bindings) { + Binding instance = binding.getInstance(); + if (instance != null && !contributions.contains(instance)) { + contributions.add(instance); + } + } + + return contributions.toArray(new Binding[contributions.size()]); + } + + /** + * Returns the value-add binding identified by its unique id. If no value + * add binding with the specified id is registered, <code>null</code> is returned. + * + * @param id The unique id of the value-add binding or <code>null</code> + * + * @return The value-add binding instance or <code>null</code>. + */ + public Binding getBinding(String id) { + Binding contribution = null; + if (getExtensions().containsKey(id)) { + ExecutableExtensionProxy<Binding> proxy = getExtensions().get(id); + // Get the extension instance + contribution = proxy.getInstance(); + } + + return contribution; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java index d4dd8b2aa..88ad44f73 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpParsePath.java @@ -12,12 +12,14 @@ package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.utils.Host; import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException; import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester; @@ -63,7 +65,22 @@ public class OpParsePath extends Operation { if (slash != -1) { String peerId = filePath.substring(0, slash); peerId = peerId.replace(CacheManager.PATH_ESCAPE_CHAR, ':'); - peer = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId); + + final AtomicReference<IPeerModel> peerModel = new AtomicReference<IPeerModel>(); + final String finPeerId = peerId; + + Runnable runnable = new Runnable() { + + @Override + public void run() { + peerModel.set(Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(finPeerId)); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + + this.peer = peerModel.get(); if (peer != null) { boolean hostWindows = Host.isWindowsHost(); boolean windows = TargetPropertyTester.isWindows(peer); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java index 667bbf492..33fc6a3f1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/url/TcfURLConnection.java @@ -15,6 +15,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; +import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.Assert; import org.eclipse.osgi.util.NLS; @@ -105,13 +106,28 @@ public class TcfURLConnection extends URLConnection { * @param peerId The target peer's ID. * @return The peer with this ID or null if not found. */ - private IPeer findPeer(String peerId) { - IPeer peer = Protocol.getLocator().getPeers().get(peerId); - if(peer == null) { - IPeerModel peerNode = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId); - if(peerNode != null) peer = peerNode.getPeer(); - } - return peer; + private IPeer findPeer(final String peerId) { + Assert.isNotNull(peerId); + + final AtomicReference<IPeer> peer = new AtomicReference<IPeer>(); + + Runnable runnable = new Runnable() { + + @Override + public void run() { + IPeer p = Protocol.getLocator().getPeers().get(peerId); + if (p == null) { + IPeerModel peerNode = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(peerId); + if (peerNode != null) p = peerNode.getPeer(); + } + peer.set(p); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); + + return peer.get(); } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java index 472aeda25..d0172ba98 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/AbstractTreeNode.java @@ -1,329 +1,319 @@ -/*******************************************************************************
- * 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.filesystem.core.model;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
-import org.eclipse.tcf.te.core.interfaces.IViewerInput;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpUser;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-
-/**
- * The base class of FSTreeNode and ProcessTreeNode which provides base members and methods.
- */
-public abstract class AbstractTreeNode extends PlatformObject implements IPeerModelProvider{
- // The unique id of this node.
- protected final UUID uniqueId = UUID.randomUUID();
-
- /**
- * The tree node name.
- */
- public String name = null;
-
- /**
- * The tree node type.
- */
- public String type = null;
-
- /**
- * The peer node the file system tree node is associated with.
- */
- public IPeerModel peerNode = null;
-
- /**
- * Flag to mark once the children of the node got queried
- */
- public boolean childrenQueried = false;
-
- /**
- * Flag to mark once the children query is running
- */
- public boolean childrenQueryRunning = false;
-
- /**
- * The tree node parent.
- */
- protected AbstractTreeNode parent = null;
-
- /**
- * The tree node children.
- */
- protected List<AbstractTreeNode> children = Collections.synchronizedList(new ArrayList<AbstractTreeNode>());
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public final int hashCode() {
- return uniqueId.hashCode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public final boolean equals(Object obj) {
- if(this == obj)
- return true;
- if (obj instanceof AbstractTreeNode) {
- return uniqueId.equals(((AbstractTreeNode) obj).uniqueId);
- }
- return super.equals(obj);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
- buffer.append(": name=" + (name != null ? name : super.toString())); //$NON-NLS-1$
- buffer.append(", UUID=" + uniqueId.toString()); //$NON-NLS-1$
- return buffer.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider#getPeerModel()
- */
- @Override
- public IPeerModel getPeerModel() {
- return peerNode;
- }
-
- /**
- * Called when the children query is done.
- */
- public void queryDone() {
- childrenQueryRunning = false;
- childrenQueried = true;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "query_done", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Called when the children query is started.
- */
- public void queryStarted() {
- childrenQueryRunning = true;
- PropertyChangeEvent event = new PropertyChangeEvent(this, "query_started", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Get the user account of the specified TCF peer.
- *
- * @param peerNode The peer node of the TCF agent.
- * @return The user account that runs the agent.
- */
- protected UserAccount getUserAccount(IPeerModel peerNode) {
- OpUser user = new OpUser(peerNode);
- new NullOpExecutor().execute(user);
- return user.getUserAccount();
- }
-
- /**
- * Fire a property change event to notify one of the node's property has changed.
- *
- * @param event The property change event.
- */
- public void firePropertyChange(PropertyChangeEvent event) {
- if(peerNode != null) {
- IPropertyChangeProvider provider = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class);
- provider.firePropertyChange(event);
- } else if(parent != null) {
- parent.firePropertyChange(event);
- }
- }
-
- /**
- * Add the specified nodes to the children list.
- *
- * @param nodes The nodes to be added.
- */
- public void addChidren(List<? extends AbstractTreeNode> nodes) {
- children.addAll(nodes);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "addChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Remove the specified nodes from the children list.
- *
- * @param nodes The nodes to be removed.
- */
- public void removeChildren(List<? extends AbstractTreeNode> nodes) {
- children.removeAll(nodes);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Add the specified the node to the children list.
- *
- * @param node The child node to be added.
- */
- public void addChild(AbstractTreeNode node) {
- children.add(node);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "addChild", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Remove the specified child node from its children list.
- *
- * @param node The child node to be removed.
- */
- public void removeChild(AbstractTreeNode node) {
- children.remove(node);
- PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChild", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * Clear the children of this folder.
- */
- public void clearChildren() {
- children.clear();
- PropertyChangeEvent event = new PropertyChangeEvent(this, "clearChildren", null, null); //$NON-NLS-1$
- firePropertyChange(event);
- }
-
- /**
- * If this node is ancestor of the specified node.
- * @return true if it is.
- */
- public boolean isAncestorOf(AbstractTreeNode node) {
- if (node == null) return false;
- if (node.parent == this) return true;
- return isAncestorOf(node.parent);
- }
-
- /**
- * Get the parent node of this node.
- *
- * @return The parent node.
- */
- public AbstractTreeNode getParent() {
- return parent;
- }
-
- /**
- * Set the parent node of this node.
- *
- * @param parent The parent node.
- */
- public void setParent(AbstractTreeNode parent) {
- this.parent = parent;
- }
-
- /**
- * Recursively refresh the children of the given process context.
- *
- * @param parentNode The process context node. Must not be <code>null</code>.
- */
- public void refresh() {
- refresh(null);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if(IViewerInput.class.equals(adapter)) {
- return peerNode.getAdapter(IViewerInput.class);
- }
- if(IPropertyChangeProvider.class.equals(adapter)) {
- return peerNode.getAdapter(adapter);
- }
- return super.getAdapter(adapter);
- }
-
- /**
- * Recursively refresh the children of the given process context with a callback, which is
- * called when whole process is finished.
- *
- * @param callback The callback object, or <code>null</code> when callback is not needed.
- */
- public void refresh(ICallback callback) {
- queryStarted();
- Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, doCreateRefreshDoneOpenChannel(callback));
- }
-
- /**
- * Create the callback object of opening channel for refreshing itself.
- *
- * @param callback The callback object.
- * @return The callback object.
- */
- protected abstract DoneOpenChannel doCreateRefreshDoneOpenChannel(ICallback callback);
-
- /**
- * Query the children of this file system node.
- */
- public void queryChildren() {
- queryChildren(null);
- }
- /**
- * Query the children of this file system node.
- */
- public void queryChildren(ICallback callback) {
- queryStarted();
- Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, doCreateQueryDoneOpenChannel(callback));
- }
-
- /**
- * Create the callback object of opening channel for querying children.
- *
- * @return The callback object.
- */
- protected abstract DoneOpenChannel doCreateQueryDoneOpenChannel(ICallback callback);
-
- /**
- * Return if this node is the system root.
- *
- * @return true if it is.
- */
- public abstract boolean isSystemRoot();
-
- /**
- * Get the children of this tree node.
- *
- * @return The list of the children.
- */
- public List<? extends AbstractTreeNode> getChildren() {
- return new ArrayList<AbstractTreeNode>(children);
- }
-
- /**
- * Refresh the children's children.
- */
- public abstract void refreshChildren();
-}
+/******************************************************************************* + * 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.filesystem.core.model; + +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; +import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.NullOpExecutor; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpUser; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; + +/** + * The base class of FSTreeNode and ProcessTreeNode which provides base members and methods. + */ +public abstract class AbstractTreeNode extends PlatformObject { + // The unique id of this node. + protected final UUID uniqueId = UUID.randomUUID(); + + /** + * The tree node name. + */ + public String name = null; + + /** + * The tree node type. + */ + public String type = null; + + /** + * The peer node the file system tree node is associated with. + */ + public IPeerModel peerNode = null; + + /** + * Flag to mark once the children of the node got queried + */ + public boolean childrenQueried = false; + + /** + * Flag to mark once the children query is running + */ + public boolean childrenQueryRunning = false; + + /** + * The tree node parent. + */ + protected AbstractTreeNode parent = null; + + /** + * The tree node children. + */ + protected List<AbstractTreeNode> children = Collections.synchronizedList(new ArrayList<AbstractTreeNode>()); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public final int hashCode() { + return uniqueId.hashCode(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public final boolean equals(Object obj) { + if(this == obj) + return true; + if (obj instanceof AbstractTreeNode) { + return uniqueId.equals(((AbstractTreeNode) obj).uniqueId); + } + return super.equals(obj); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); + buffer.append(": name=" + (name != null ? name : super.toString())); //$NON-NLS-1$ + buffer.append(", UUID=" + uniqueId.toString()); //$NON-NLS-1$ + return buffer.toString(); + } + + /** + * Called when the children query is done. + */ + public void queryDone() { + childrenQueryRunning = false; + childrenQueried = true; + PropertyChangeEvent event = new PropertyChangeEvent(this, "query_done", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Called when the children query is started. + */ + public void queryStarted() { + childrenQueryRunning = true; + PropertyChangeEvent event = new PropertyChangeEvent(this, "query_started", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Get the user account of the specified TCF peer. + * + * @param peerNode The peer node of the TCF agent. + * @return The user account that runs the agent. + */ + protected UserAccount getUserAccount(IPeerModel peerNode) { + OpUser user = new OpUser(peerNode); + new NullOpExecutor().execute(user); + return user.getUserAccount(); + } + + /** + * Fire a property change event to notify one of the node's property has changed. + * + * @param event The property change event. + */ + public void firePropertyChange(PropertyChangeEvent event) { + if(peerNode != null) { + IPropertyChangeProvider provider = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class); + provider.firePropertyChange(event); + } else if(parent != null) { + parent.firePropertyChange(event); + } + } + + /** + * Add the specified nodes to the children list. + * + * @param nodes The nodes to be added. + */ + public void addChidren(List<? extends AbstractTreeNode> nodes) { + children.addAll(nodes); + PropertyChangeEvent event = new PropertyChangeEvent(this, "addChildren", null, null); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Remove the specified nodes from the children list. + * + * @param nodes The nodes to be removed. + */ + public void removeChildren(List<? extends AbstractTreeNode> nodes) { + children.removeAll(nodes); + PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChildren", null, null); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Add the specified the node to the children list. + * + * @param node The child node to be added. + */ + public void addChild(AbstractTreeNode node) { + children.add(node); + PropertyChangeEvent event = new PropertyChangeEvent(this, "addChild", null, null); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Remove the specified child node from its children list. + * + * @param node The child node to be removed. + */ + public void removeChild(AbstractTreeNode node) { + children.remove(node); + PropertyChangeEvent event = new PropertyChangeEvent(this, "removeChild", null, null); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * Clear the children of this folder. + */ + public void clearChildren() { + children.clear(); + PropertyChangeEvent event = new PropertyChangeEvent(this, "clearChildren", null, null); //$NON-NLS-1$ + firePropertyChange(event); + } + + /** + * If this node is ancestor of the specified node. + * @return true if it is. + */ + public boolean isAncestorOf(AbstractTreeNode node) { + if (node == null) return false; + if (node.parent == this) return true; + return isAncestorOf(node.parent); + } + + /** + * Get the parent node of this node. + * + * @return The parent node. + */ + public AbstractTreeNode getParent() { + return parent; + } + + /** + * Set the parent node of this node. + * + * @param parent The parent node. + */ + public void setParent(AbstractTreeNode parent) { + this.parent = parent; + } + + /** + * Recursively refresh the children of the given process context. + * + * @param parentNode The process context node. Must not be <code>null</code>. + */ + public void refresh() { + refresh(null); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) { + if(IViewerInput.class.equals(adapter)) { + return peerNode.getAdapter(IViewerInput.class); + } + if(IPropertyChangeProvider.class.equals(adapter)) { + return peerNode.getAdapter(adapter); + } + return super.getAdapter(adapter); + } + + /** + * Recursively refresh the children of the given process context with a callback, which is + * called when whole process is finished. + * + * @param callback The callback object, or <code>null</code> when callback is not needed. + */ + public void refresh(ICallback callback) { + queryStarted(); + Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, doCreateRefreshDoneOpenChannel(callback)); + } + + /** + * Create the callback object of opening channel for refreshing itself. + * + * @param callback The callback object. + * @return The callback object. + */ + protected abstract DoneOpenChannel doCreateRefreshDoneOpenChannel(ICallback callback); + + /** + * Query the children of this file system node. + */ + public void queryChildren() { + queryChildren(null); + } + /** + * Query the children of this file system node. + */ + public void queryChildren(ICallback callback) { + queryStarted(); + Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, doCreateQueryDoneOpenChannel(callback)); + } + + /** + * Create the callback object of opening channel for querying children. + * + * @return The callback object. + */ + protected abstract DoneOpenChannel doCreateQueryDoneOpenChannel(ICallback callback); + + /** + * Return if this node is the system root. + * + * @return true if it is. + */ + public abstract boolean isSystemRoot(); + + /** + * Get the children of this tree node. + * + * @return The list of the children. + */ + public List<? extends AbstractTreeNode> getChildren() { + return new ArrayList<AbstractTreeNode>(children); + } + + /** + * Refresh the children's children. + */ + public abstract void refreshChildren(); +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF index 6f641ae39..77b1272fc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF @@ -54,5 +54,4 @@ Export-Package: org.eclipse.tcf.te.tcf.filesystem.ui.activator;x-internal:=true, org.eclipse.tcf.te.tcf.filesystem.ui.internal.tabbed;x-internal:=true, org.eclipse.tcf.te.tcf.filesystem.ui.internal.testers;x-internal:=true, org.eclipse.tcf.te.tcf.filesystem.ui.internal.wizards;x-internal:=true, - org.eclipse.tcf.te.tcf.filesystem.ui.nls;x-internal:=true, - org.eclipse.tcf.te.tcf.filesystem.ui.services + org.eclipse.tcf.te.tcf.filesystem.ui.nls;x-internal:=true diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml index 7074626fd..a621432cc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml @@ -95,21 +95,6 @@ </commonFilter> </extension> -<!-- Service contributions --> - <extension point="org.eclipse.tcf.te.runtime.services.services"> - <service - class="org.eclipse.tcf.te.tcf.filesystem.ui.services.UIService" - id="org.eclipse.tcf.te.tcf.filesytsem.uiservice"> - <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.IUIService"/> - <enablement> - <or> - <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/> - <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel"/> - </or> - </enablement> - </service> - </extension> - <!-- Editor page contributions --> <extension point="org.eclipse.tcf.te.ui.views.editorPages"> <editorPage @@ -127,14 +112,13 @@ pageId="org.eclipse.tcf.te.tcf.filesystem.FSExplorerEditorPage"> <enablement> <with variable="activeEditorInput"> - <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"> - <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="FileSystem"/> - <test - property="org.eclipse.tcf.te.runtime.preference" - args="bundleId=org.eclipse.tcf.te.tcf.filesystem.ui,key=te.tcf.filesystem.core.feature.editor.content.enable" - value="true"> - </test> - </adapt> + <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/> + <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="FileSystem"/> + <test + property="org.eclipse.tcf.te.runtime.preference" + args="bundleId=org.eclipse.tcf.te.tcf.filesystem.ui,key=te.tcf.filesystem.core.feature.editor.content.enable" + value="true"> + </test> </with> </enablement> </editorPageBinding> @@ -1691,24 +1675,12 @@ <factory adaptableType="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode" class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory"> - <adapter - type="org.eclipse.ui.IActionFilter"> - </adapter> - <adapter - type="org.eclipse.jface.viewers.ILabelProvider"> - </adapter> - <adapter - type="org.eclipse.ui.IPersistableElement"> - </adapter> - <adapter - type="org.eclipse.tcf.te.ui.interfaces.ILazyLoader"> - </adapter> - <adapter - type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"> - </adapter> - <adapter - type="org.eclipse.tcf.te.ui.interfaces.ISearchable"> - </adapter> + <adapter type="org.eclipse.ui.IActionFilter"/> + <adapter type="org.eclipse.jface.viewers.ILabelProvider"/> + <adapter type="org.eclipse.ui.IPersistableElement"/> + <adapter type="org.eclipse.tcf.te.ui.interfaces.ILazyLoader"/> + <adapter type="org.eclipse.tcf.te.ui.interfaces.ISearchable"/> + <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider"/> </factory> <factory adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel" diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java index 278420737..5c9c6772e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java @@ -1,84 +1,118 @@ -/*******************************************************************************
- * 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.filesystem.ui.internal.adapters;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider;
-import org.eclipse.tcf.te.tcf.filesystem.ui.internal.search.FSTreeNodeSearchable;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.ui.interfaces.ILazyLoader;
-import org.eclipse.tcf.te.ui.interfaces.ISearchable;
-import org.eclipse.ui.IActionFilter;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * The adapter factory of <code>FSTreeNode</code> over <code>IActionFilter</code>
- */
-public class FSTreeNodeAdapterFactory implements IAdapterFactory {
- private static ILabelProvider nodeLabelProvider = new FSTreeElementLabelProvider();
- // The fFilters map caching fFilters for FS nodes.
- private Map<FSTreeNode, NodeStateFilter> filters;
-
- /**
- * Constructor.
- */
- public FSTreeNodeAdapterFactory(){
- this.filters = Collections.synchronizedMap(new HashMap<FSTreeNode, NodeStateFilter>());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- @Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if(adaptableObject instanceof FSTreeNode) {
- FSTreeNode node = (FSTreeNode) adaptableObject;
- if(adapterType == IActionFilter.class) {
- NodeStateFilter filter = filters.get(node);
- if(filter == null){
- filter = new NodeStateFilter(node);
- filters.put(node, filter);
- }
- return filter;
- }
- else if(adapterType == ILabelProvider.class) {
- return nodeLabelProvider;
- }
- else if(adapterType == IPersistableElement.class && UIPlugin.isExpandedPersisted()) {
- return new PersistableNode(node);
- }
- else if(adapterType == ILazyLoader.class) {
- return new FSTreeNodeLoader(node);
- }
- else if(adapterType == IPeerModel.class) {
- return node.getPeerModel();
- }
- else if(adapterType == ISearchable.class) {
- return new FSTreeNodeSearchable(node);
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- @Override
- public Class[] getAdapterList() {
- return new Class[] { IActionFilter.class, ILabelProvider.class, IPersistableElement.class, ILazyLoader.class, ISearchable.class };
- }
-}
+/******************************************************************************* + * 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.filesystem.ui.internal.adapters; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.search.FSTreeNodeSearchable; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.ui.interfaces.ILazyLoader; +import org.eclipse.tcf.te.ui.interfaces.ISearchable; +import org.eclipse.ui.IActionFilter; +import org.eclipse.ui.IPersistableElement; + +/** + * The adapter factory of <code>FSTreeNode</code> over <code>IActionFilter</code> + */ +public class FSTreeNodeAdapterFactory implements IAdapterFactory { + private static ILabelProvider nodeLabelProvider = new FSTreeElementLabelProvider(); + // The fFilters map caching fFilters for FS nodes. + private Map<FSTreeNode, NodeStateFilter> filters; + + public static class FSTreeNodePeerModelProvider extends PlatformObject implements IPeerModelProvider { + private final FSTreeNode node; + + /** + * Constructor + */ + public FSTreeNodePeerModelProvider(FSTreeNode node) { + Assert.isNotNull(node); + this.node = node; + } + + /** + * Returns the associated file system tree node. + * + * @return The associated file system tree node. + */ + public final FSTreeNode getFSTreeNode() { + return node; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider#getPeerModel() + */ + @Override + public final IPeerModel getPeerModel() { + return node.peerNode; + } + } + + /** + * Constructor. + */ + public FSTreeNodeAdapterFactory() { + this.filters = Collections.synchronizedMap(new HashMap<FSTreeNode, NodeStateFilter>()); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof FSTreeNode) { + FSTreeNode node = (FSTreeNode) adaptableObject; + if (adapterType == IActionFilter.class) { + NodeStateFilter filter = filters.get(node); + if (filter == null) { + filter = new NodeStateFilter(node); + filters.put(node, filter); + } + return filter; + } + else if (adapterType == ILabelProvider.class) { + return nodeLabelProvider; + } + else if (adapterType == IPersistableElement.class && UIPlugin.isExpandedPersisted()) { + return new PersistableNode(node); + } + else if (adapterType == ILazyLoader.class) { + return new FSTreeNodeLoader(node); + } + else if (adapterType == IPeerModelProvider.class) { + return new FSTreeNodePeerModelProvider(node); + } + else if (adapterType == ISearchable.class) { + return new FSTreeNodeSearchable(node); + } + } + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + @Override + public Class[] getAdapterList() { + return new Class[] { IActionFilter.class, ILabelProvider.class, IPersistableElement.class, ILazyLoader.class, ISearchable.class, IPeerModelProvider.class }; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/EditorHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/EditorHandlerDelegate.java deleted file mode 100644 index fb64aac8b..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/EditorHandlerDelegate.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * EditorHandlerDelegate.java - * Created on Jan 25, 2012 - * - * Copyright (c) 2012, 2013 Wind River Systems, Inc. - * - * The right to copy, distribute, modify, or otherwise make use - * of this software may be licensed only pursuant to the terms - * of an applicable Wind River license agreement. - */ -package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel; -import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.pages.FSExplorerEditorPage; -import org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerModelEditorHandlerDelegate; -import org.eclipse.tcf.te.ui.swt.DisplayUtil; -import org.eclipse.tcf.te.ui.views.editor.Editor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.editor.IFormPage; - -/** - * Systems context node properties command handler implementation. - */ -public class EditorHandlerDelegate extends AbstractPeerModelEditorHandlerDelegate { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate#postOpenProperties(org.eclipse.ui.IEditorPart, java.lang.Object) - */ - @Override - public void postOpenEditor(IEditorPart editor, final Object element) { - if (editor instanceof FormEditor) { - final FormEditor formEditor = (FormEditor)editor; - DisplayUtil.safeAsyncExec(new Runnable() { - @Override - public void run() { - IFormPage page = formEditor.setActivePage("org.eclipse.tcf.te.tcf.filesystem.FSExplorerEditorPage"); //$NON-NLS-1$ - // If the element is a context node, select the node - if (page != null && element instanceof FSTreeNode || element instanceof FSModel) { - Viewer viewer = ((FSExplorerEditorPage)page).getTreeControl().getViewer(); - if (viewer != null) { - viewer.setSelection(new StructuredSelection(element), true); - } - } - else if (formEditor instanceof Editor) { - ((Editor)formEditor).setActivePage(0); - } - } - }); - } - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java index 165af9d80..1376ff9be 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/tabbed/BasicFolderSection.java @@ -1,116 +1,116 @@ -/*******************************************************************************
- * 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.filesystem.ui.internal.tabbed;
-
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.util.Date;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-/**
- * The section that displays the basic information of a folder.
- */
-public class BasicFolderSection extends BaseTitledSection {
- // The formatter for the size of a file.
- private static final DecimalFormat SIZE_FORMAT = new DecimalFormat();
-
- // The original node to be displayed and edited.
- protected FSTreeNode node;
- // The copy used to be edited.
- protected FSTreeNode clone;
-
- // The text for the name of the node.
- protected Text nameText;
- // The text for the type of the node.
- protected Text typeText;
- // The text for the location of the node.
- protected Text locationText;
- // The text for the modified time of the node.
- protected Text modifiedText;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
- */
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
- super.createControls(parent, aTabbedPropertySheetPage);
- nameText = createTextField(null, Messages.GeneralInformationPage_Name);
- typeText = createTextField(nameText, Messages.GeneralInformationPage_Type);
- locationText = createWrapTextField(typeText, Messages.GeneralInformationPage_Location);
- modifiedText = createTextField(locationText, Messages.GeneralInformationPage_Modified);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider)
- */
- @Override
- protected void updateInput(IPeerModelProvider input) {
- Assert.isTrue(input instanceof FSTreeNode);
- this.node = (FSTreeNode) input;
- this.clone = (FSTreeNode) node.clone();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
- */
- @Override
- public void refresh() {
- SWTControlUtil.setText(nameText, clone != null ? clone.name : ""); //$NON-NLS-1$
- SWTControlUtil.setText(typeText, clone != null ? clone.getFileType() : ""); //$NON-NLS-1$
- String location = clone == null || clone.isRoot() ? Messages.GeneralInformationPage_Computer : clone.getLocation();
- SWTControlUtil.setText(locationText, location);
- SWTControlUtil.setText(modifiedText, clone != null ? getDateText(clone.attr.mtime) : ""); //$NON-NLS-1$
- super.refresh();
- }
-
- /**
- * Get the string of the specific time using the formatter, DATE_FORMAT.
- *
- * @param time The time to be formatted.
- * @return The string in the format of DATE_FORMAT.
- */
- protected String getDateText(long time) {
- DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
- return dateFormat.format(new Date(time));
- }
-
- /**
- * Get the string of the file size using using the formatter, SIZE_FORMAT.
- *
- * @param size
- * The size of the file to be formatted.
- * @return The string in the format of SIZE_FORMAT.
- */
- protected String getSizeText(long size) {
- return NLS.bind(Messages.GeneralInformationPage_FileSizeInfo, SIZE_FORMAT.format(size / 1024), SIZE_FORMAT.format(size));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
- */
- @Override
- protected String getText() {
- return Messages.BasicFolderSection_BasicInfoText;
- }
+/******************************************************************************* + * 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.filesystem.ui.internal.tabbed; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.util.Date; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeAdapterFactory.FSTreeNodePeerModelProvider; +import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider; +import org.eclipse.tcf.te.tcf.ui.tabbed.BaseTitledSection; +import org.eclipse.tcf.te.ui.swt.SWTControlUtil; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; + +/** + * The section that displays the basic information of a folder. + */ +public class BasicFolderSection extends BaseTitledSection { + // The formatter for the size of a file. + private static final DecimalFormat SIZE_FORMAT = new DecimalFormat(); + + // The original node to be displayed and edited. + protected FSTreeNode node; + // The copy used to be edited. + protected FSTreeNode clone; + + // The text for the name of the node. + protected Text nameText; + // The text for the type of the node. + protected Text typeText; + // The text for the location of the node. + protected Text locationText; + // The text for the modified time of the node. + protected Text modifiedText; + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) + */ + @Override + public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { + super.createControls(parent, aTabbedPropertySheetPage); + nameText = createTextField(null, Messages.GeneralInformationPage_Name); + typeText = createTextField(nameText, Messages.GeneralInformationPage_Type); + locationText = createWrapTextField(typeText, Messages.GeneralInformationPage_Location); + modifiedText = createTextField(locationText, Messages.GeneralInformationPage_Modified); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#updateData(org.eclipse.tcf.te.ui.interfaces.IPropertyChangeProvider) + */ + @Override + protected void updateInput(IPeerModelProvider input) { + Assert.isTrue(input instanceof FSTreeNodePeerModelProvider); + this.node = ((FSTreeNodePeerModelProvider)input).getFSTreeNode(); + this.clone = (FSTreeNode) node.clone(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh() + */ + @Override + public void refresh() { + SWTControlUtil.setText(nameText, clone != null ? clone.name : ""); //$NON-NLS-1$ + SWTControlUtil.setText(typeText, clone != null ? clone.getFileType() : ""); //$NON-NLS-1$ + String location = clone == null || clone.isRoot() ? Messages.GeneralInformationPage_Computer : clone.getLocation(); + SWTControlUtil.setText(locationText, location); + SWTControlUtil.setText(modifiedText, clone != null ? getDateText(clone.attr.mtime) : ""); //$NON-NLS-1$ + super.refresh(); + } + + /** + * Get the string of the specific time using the formatter, DATE_FORMAT. + * + * @param time The time to be formatted. + * @return The string in the format of DATE_FORMAT. + */ + protected String getDateText(long time) { + DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); + return dateFormat.format(new Date(time)); + } + + /** + * Get the string of the file size using using the formatter, SIZE_FORMAT. + * + * @param size + * The size of the file to be formatted. + * @return The string in the format of SIZE_FORMAT. + */ + protected String getSizeText(long size) { + return NLS.bind(Messages.GeneralInformationPage_FileSizeInfo, SIZE_FORMAT.format(size / 1024), SIZE_FORMAT.format(size)); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText() + */ + @Override + protected String getText() { + return Messages.BasicFolderSection_BasicInfoText; + } }
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java deleted file mode 100644 index 807e594e7..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * UIService.java - * Created on Nov 15, 2012 - * - * Copyright (c) 2012, 2013 Wind River Systems, Inc. - * - * The right to copy, distribute, modify, or otherwise make use - * of this software may be licensed only pursuant to the terms - * of an applicable Wind River license agreement. - */ -package org.eclipse.tcf.te.tcf.filesystem.ui.services; - -import org.eclipse.tcf.te.runtime.services.AbstractService; -import org.eclipse.tcf.te.runtime.services.interfaces.IUIService; -import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.EditorHandlerDelegate; -import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate; - -/** - * UI service implementation. - */ -public class UIService extends AbstractService implements IUIService { - private final IEditorHandlerDelegate editorHandlerDelegate = new EditorHandlerDelegate(); - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.services.interfaces.IUIService#getDelegate(java.lang.Object, java.lang.Class) - */ - @SuppressWarnings("unchecked") - @Override - public <V> V getDelegate(Object context, Class<? extends V> clazz) { - - if (IEditorHandlerDelegate.class.isAssignableFrom(clazz)) { - return (V) editorHandlerDelegate; - } - - return null; - } - -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java index e5bc10cd4..7d3e43e44 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java @@ -13,6 +13,8 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; @@ -61,8 +63,13 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen } Assert.isTrue(selection instanceof IStructuredSelection); Object input = ((IStructuredSelection) selection).getFirstElement(); - if (input instanceof IPeerModelProvider) { - this.provider = (IPeerModelProvider) input; + + IPeerModelProvider provider = input instanceof IPeerModelProvider ? (IPeerModelProvider) input : null; + if (provider == null) provider = input instanceof IAdaptable ? (IPeerModelProvider)((IAdaptable)input).getAdapter(IPeerModelProvider.class) : null; + if (provider == null) provider = (IPeerModelProvider)Platform.getAdapterManager().getAdapter(input, IPeerModelProvider.class); + + if (provider != null) { + this.provider = provider; IPeerModel peerNode = this.provider.getPeerModel(); this.viewerInput = (IPropertyChangeProvider) peerNode.getAdapter(IPropertyChangeProvider.class); if (this.viewerInput != null) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties index 8f05de740..cd7e13307 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties @@ -70,7 +70,7 @@ menu.find.mnemonic = f menu.filter.label = Filter... menu.filter.mnemonic = t -menu.reset.label = Reset +menu.reset.label = Reset Filter menu.reset.mnemonic = r command.find.name = Find... |