diff options
40 files changed, 686 insertions, 252 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml index 7c1588ca0..0fc43f752 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/plugin.xml @@ -38,7 +38,7 @@ class="org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.FSTreeNodePropertyTester" id="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode" namespace="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode" - properties="isFile,isDirectory,isBinaryFile,isReadable,isWritable,isExecutable,isRoot,isReadOnly,isHidden,isWindows,testParent,getCacheState,isSystemRoot" + properties="isFile,isDirectory,isBinaryFile,isReadable,isWritable,isExecutable,isRoot,isReadOnly,isHidden,isWindows,testParent,getCacheState,isSystemRoot,isRevealOnConnect" type="org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode"> </propertyTester> <propertyTester diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java index 35a9a4623..c0e3b9d86 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/activator/CorePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012, 2015 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 @@ -9,14 +9,20 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.core.activator; +import java.util.HashSet; import java.util.Hashtable; +import java.util.Set; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection; import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService; import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; +import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.url.URLConstants; import org.osgi.service.url.URLStreamHandlerService; @@ -25,6 +31,10 @@ import org.osgi.service.url.URLStreamHandlerService; */ public class CorePlugin extends Plugin { + private static final String PREFKEY_REVEAL_ON_CONNECT = "revealOnConnect"; //$NON-NLS-1$ + + private static final String PLUGIN_ID = "org.eclipse.tcf.te.tcf.filesystem.core"; //$NON-NLS-1$ + // The bundle context of this plugin. private static BundleContext context; // The shared instance of this plug-in. @@ -32,6 +42,8 @@ public class CorePlugin extends Plugin { // The service registration for the "tcf" URL stream handler. private ServiceRegistration<?> regURLStreamHandlerService; + private Set<String> fRevealOnConnect; + /** * Get the bundle context of this plugin. * @return The bundle context object. @@ -85,9 +97,62 @@ public class CorePlugin extends Plugin { * Convenience method which returns the unique identifier of this plugin. */ public static String getUniqueIdentifier() { - if (getContext() != null && getContext().getBundle() != null) { - return getContext().getBundle().getSymbolicName(); + return PLUGIN_ID; + } + + + public boolean addToRevealOnConnect(String location) { + if (unsafeGetRevealOnConnect().add(location)) { + storeRevealOnConnect(); + return true; + } + return false; + } + + public boolean removeFromRevealOnConnect(String location) { + if (unsafeGetRevealOnConnect().remove(location)) { + storeRevealOnConnect(); + return true; + } + return false; + } + + public boolean isRevealOnConnect(String location) { + return unsafeGetRevealOnConnect().contains(location); + } + + public Set<String> getRevealOnConnect() { + return new HashSet<String>(unsafeGetRevealOnConnect()); + } + + private void storeRevealOnConnect() { + if (fRevealOnConnect == null) + return; + + StringBuilder buf = new StringBuilder(); + for (String reveal : fRevealOnConnect) { + if (buf.length() > 0) + buf.append("\0"); //$NON-NLS-1$ + buf.append(reveal); + } + IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PLUGIN_ID); + node.put(PREFKEY_REVEAL_ON_CONNECT, buf.toString()); + try { + node.flush(); + } catch (BackingStoreException e) { + } + } + + private Set<String> unsafeGetRevealOnConnect() { + if (fRevealOnConnect == null) { + HashSet<String> favorites = new HashSet<String>(); + String favs = Platform.getPreferencesService().getString(PLUGIN_ID, PREFKEY_REVEAL_ON_CONNECT, "", null); //$NON-NLS-1$ + for (String fav : favs.split("\0")) { //$NON-NLS-1$ + if (fav.length() > 0) + favorites.add(fav); + } + fRevealOnConnect = favorites; } - return "org.eclipse.tcf.te.tcf.filesystem.core"; //$NON-NLS-1$ + return fRevealOnConnect; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java index 38092e0a3..6a6c2c276 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IFSTreeNode.java @@ -160,4 +160,13 @@ public interface IFSTreeNode extends IFSTreeNodeBase, IAdaptable { */ IResultOperation<? extends IFSTreeNode> operationNewFolder(String name); + /** + * Stores whether this file or folder shall be revealed when the target is connected. + */ + void setRevealOnConnect(boolean value); + + /** + * Returns whether this file or folder is revealed when the target is connected. + */ + boolean isRevealOnConnect(); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java index 1b7efcea1..2df7d36d6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/interfaces/runtime/IRuntimeModel.java @@ -13,6 +13,7 @@ import java.io.File; import java.util.List; import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.services.IFileSystem.DirEntry; import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; @@ -21,10 +22,16 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider; /** - * A model dealing with the filesystem at runtime. + * A model dealing with the file system at runtime. */ public interface IRuntimeModel extends IModel, IPeerNodeProvider { + static class Delegate { + public boolean filterRoot(DirEntry entry) { + return true; + } + } + /** * Returns the channel of this runtime model */ @@ -36,6 +43,11 @@ public interface IRuntimeModel extends IModel, IPeerNodeProvider { public IFSTreeNode getRoot(); /** + * Returns the delegate that is used for customized behavior. + */ + public Delegate getDelegate(); + + /** * Returns an operation for restoring nodes from a path */ public IResultOperation<IFSTreeNode> operationRestoreFromPath(String path); @@ -44,4 +56,9 @@ public interface IRuntimeModel extends IModel, IPeerNodeProvider { * Returns an operation for downloading multiple nodes to a destination */ public IOperation operationDownload(List<IFSTreeNode> nodes, File destination, IConfirmCallback confirmCallback); + + /** + * Returns an operation for restoring nodes from a path + */ + public IResultOperation<IFSTreeNode[]> operationRestoreFavorites(); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java index 911873245..8ef81be28 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java @@ -36,6 +36,7 @@ import org.eclipse.tcf.services.IFileSystem.FileAttrs; import org.eclipse.tcf.te.core.interfaces.IFilterable; import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; import org.eclipse.tcf.te.core.interfaces.IViewerInput; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation; @@ -641,4 +642,22 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org } return null; } + + @Override + public void setRevealOnConnect(boolean value) { + if (value) { + if (CorePlugin.getDefault().addToRevealOnConnect(getLocation(true))) { + notifyChange("favorites", Boolean.FALSE, Boolean.TRUE); //$NON-NLS-1$ + } + } else { + if (CorePlugin.getDefault().removeFromRevealOnConnect(getLocation(true))) { + notifyChange("favorites", Boolean.TRUE, Boolean.FALSE); //$NON-NLS-1$ + } + } + } + + @Override + public boolean isRevealOnConnect() { + return CorePlugin.getDefault().isRevealOnConnect(getLocation(true)); + } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java index fcc6fe91a..0b3152ed7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpCacheFileDigest.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode; import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; /** * The operation to calculate the message digest of a cache file. @@ -62,7 +63,7 @@ public class OpCacheFileDigest extends AbstractOperation { this.digest = digest.digest(); return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } catch (Exception e) { - return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), "Failed to update digest", e); //$NON-NLS-1$ + return new Status(IStatus.ERROR, CorePlugin.getUniqueIdentifier(), Messages.OpCacheFileDigest_error_updatingDigest, e); } finally { if (input != null) { try { @@ -82,12 +83,8 @@ public class OpCacheFileDigest extends AbstractOperation { return digest; } - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation#getName() - */ @Override public String getName() { - return "Update cache digest"; //$NON-NLS-1$ + return Messages.OpCacheFileDigest_name; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java index cbdf45b6d..aefdc506a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRefresh.java @@ -13,6 +13,7 @@ import static java.text.MessageFormat.format; import java.io.File; import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -34,6 +35,7 @@ import org.eclipse.tcf.te.runtime.callback.Callback; import org.eclipse.tcf.te.tcf.core.concurrent.TCFOperationMonitor; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel.Delegate; import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode; import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState; import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager; @@ -160,12 +162,13 @@ public class OpRefresh extends AbstractOperation { if (error != null) { result.setError(format(Messages.OpRefresh_errorGetRoots, node.getRuntimeModel().getName()), error); } else if (!result.checkCancelled()) { - int i = 0; - FSTreeNode[] nodes = new FSTreeNode[entries.length]; + Delegate delegate = node.getRuntimeModel().getDelegate(); + List<FSTreeNode> nodes = new ArrayList<FSTreeNode>(entries.length); for (DirEntry entry : entries) { - nodes[i++] = new FSTreeNode(node, entry.filename, true, entry.attrs); + if (delegate.filterRoot(entry)) + nodes.add(new FSTreeNode(node, entry.filename, true, entry.attrs)); } - node.setContent(nodes, false); + node.setContent(nodes.toArray(new FSTreeNode[nodes.size()]), false); for (FSTreeNode node : nodes) { if (fRecursive || node.isFile()) { fWork.addFirst(node); @@ -215,6 +218,7 @@ public class OpRefresh extends AbstractOperation { tcfReadDir(fs, path, new IReadDirDone() { @Override public void error(FileSystemException error) { + node.setContent(NO_CHILDREN, false); result.setError(format(Messages.OpRefresh_errorOpenDir, path), error); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRestoreFavorites.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRestoreFavorites.java new file mode 100644 index 000000000..ddc32098e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpRestoreFavorites.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2015 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.internal.operations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.tcf.te.tcf.filesystem.core.activator.CorePlugin; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.core.model.RuntimeModel; +import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; + +/** + * The operation to restore the favorite nodes + */ +public class OpRestoreFavorites extends AbstractOperation implements IResultOperation<IFSTreeNode[]> { + + private RuntimeModel fRuntimeModel; + private List<IFSTreeNode> fResult = new ArrayList<IFSTreeNode>(); + + public OpRestoreFavorites(RuntimeModel runtimeModel) { + fRuntimeModel = runtimeModel; + } + + @Override + public IFSTreeNode[] getResult() { + return fResult.toArray(new IFSTreeNode[fResult.size()]); + } + + @Override + public IStatus doRun(IProgressMonitor monitor) { + Set<String> favorites = CorePlugin.getDefault().getRevealOnConnect(); + if (favorites.isEmpty()) + return Status.OK_STATUS; + + SubMonitor sm = SubMonitor.convert(monitor, getName(), favorites.size()); + for (String fav : favorites) { + if (openFavorite(fav, sm.newChild(1)).getSeverity() == IStatus.CANCEL) { + monitor.done(); + return Status.CANCEL_STATUS; + } + } + monitor.done(); + return Status.OK_STATUS; + } + + + private IStatus openFavorite(String fav, SubMonitor sm) { + IResultOperation<IFSTreeNode> op = fRuntimeModel.operationRestoreFromPath(fav); + IStatus s = op.run(sm); + + IFSTreeNode node = op.getResult(); + if (node != null) { + fResult.add(node); + } + return s; + } + + @Override + public String getName() { + return Messages.OpRestoreFavorites_name; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java index bb5ab76af..1985c7f86 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/testers/FSTreeNodePropertyTester.java @@ -61,6 +61,10 @@ import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState; * </pre> */ public class FSTreeNodePropertyTester extends PropertyTester { + private enum Property { + isFile, isDirectory, isBinaryFile, isReadable, isWritable, isExecutable, isRoot, + isSystemRoot, isWindows, isReadOnly, isHidden, testParent, getCacheState, isRevealOnConnect + } /* (non-Javadoc) * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) @@ -69,38 +73,48 @@ public class FSTreeNodePropertyTester extends PropertyTester { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if(receiver == null) return false; + Property prop; + try { + prop = Property.valueOf(property); + } catch (Exception e) { + return false; + } + Assert.isTrue(receiver instanceof FSTreeNode); FSTreeNode node = (FSTreeNode) receiver; - if (property.equals("isFile")) { //$NON-NLS-1$ - return node.isFile(); - } else if (property.equals("isDirectory")) { //$NON-NLS-1$ - return node.isDirectory(); - } else if (property.equals("isBinaryFile")) { //$NON-NLS-1$ + switch (prop) { + case getCacheState: + File file = CacheManager.getCacheFile(node); + if(!file.exists()) + return false; + CacheState state = node.getCacheState(); + return state.name().equals(expectedValue); + case isBinaryFile: return ContentTypeHelper.isBinaryFile(node); - } else if (property.equals("isReadable")){ //$NON-NLS-1$ - return node.isReadable(); - } else if (property.equals("isWritable")){ //$NON-NLS-1$ - return node.isWritable(); - } else if (property.equals("isExecutable")){ //$NON-NLS-1$ + case isDirectory: + return node.isDirectory(); + case isExecutable: return node.isExecutable(); - } else if (property.equals("isRoot")) { //$NON-NLS-1$ + case isRevealOnConnect: + return node.isRevealOnConnect(); + case isFile: + return node.isFile(); + case isHidden: + return node.isHidden(); + case isReadOnly: + return node.isReadOnly(); + case isReadable: + return node.isReadable(); + case isRoot: return node.isRootDirectory(); - } else if (property.equals("isSystemRoot")) { //$NON-NLS-1$ + case isSystemRoot: return node.isFileSystem(); - } else if (property.equals("isWindows")) { //$NON-NLS-1$ + case isWindows: return node.isWindowsNode(); - } else if (property.equals("isReadOnly")) { //$NON-NLS-1$ - return node.isReadOnly(); - } else if (property.equals("isHidden")) { //$NON-NLS-1$ - return node.isHidden(); - } else if (property.equals("testParent")) { //$NON-NLS-1$ + case isWritable: + return node.isWritable(); + case testParent: return testParent(node, args, expectedValue); - } else if (property.equals("getCacheState")){ //$NON-NLS-1$ - File file = CacheManager.getCacheFile(node); - if(!file.exists()) - return false; - CacheState state = node.getCacheState(); - return state.name().equals(expectedValue); } return false; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java index 17a62bb07..f22accefa 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/model/RuntimeModel.java @@ -26,6 +26,9 @@ import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider; import org.eclipse.tcf.te.runtime.model.ContainerModelNode; import org.eclipse.tcf.te.runtime.model.factory.Factory; import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactory; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService; +import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelService; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation; @@ -36,6 +39,7 @@ import org.eclipse.tcf.te.tcf.filesystem.core.internal.FSTreeNode; import org.eclipse.tcf.te.tcf.filesystem.core.internal.UserAccount; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCopyLocal; import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpParsePath; +import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpRestoreFavorites; import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager; import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; @@ -50,6 +54,7 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo private final UserAccount fUserAccount; private IChannel fChannel; private IFileSystem fFileSystem; + private Delegate fDelegate; /** * Create a File System ModelManager. @@ -61,9 +66,21 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo fUserAccount = userAccount; fRoot = new FSTreeNode(this, Messages.FSTreeNodeContentProvider_rootNodeLabel); channel.addChannelListener(this); + + fDelegate = findDelegate(); } - @Override + private Delegate findDelegate() { + IService[] services = ServiceManager.getInstance().getServices(fPeerNode, IDelegateService.class, false); + for (IService service : services) { + Delegate cand = ((IDelegateService) service).getDelegate(this, Delegate.class); + if (cand != null) + return cand; + } + return new Delegate(); + } + + @Override protected boolean checkThreadAccess() { return Protocol.isDispatchThread(); } @@ -85,6 +102,7 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo public void dispose() { Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$ fFileSystem = null; + fRoot.setContent(new FSTreeNode[0], false); } @Override @@ -102,6 +120,11 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo } @Override + public Delegate getDelegate() { + return fDelegate; + } + + @Override public Object getAdapter(Class adapter) { if (IPeerNode.class.isAssignableFrom(adapter) || IConnectable.class.isAssignableFrom(adapter)) { final AtomicReference<IPeerNode> peerNode = new AtomicReference<IPeerNode>(); @@ -188,6 +211,11 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo } @Override + public IResultOperation<IFSTreeNode[]> operationRestoreFavorites() { + return new OpRestoreFavorites(this); + } + + @Override public IChannel getChannel() { return fChannel; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java index 4be2d1d85..267011aed 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java @@ -47,6 +47,8 @@ public class Messages extends NLS { public static String Operation_CannotCreateDirectory; public static String Operation_TimeoutOpeningChannel; + public static String OpCacheFileDigest_error_updatingDigest; + public static String OpCacheFileDigest_name; public static String OpCommitAttr_error_cannotSetAttributes; public static String OpCommitAttr_name; public static String OpCopy_Copying; @@ -84,6 +86,7 @@ public class Messages extends NLS { public static String OpRefresh_name; public static String OpRename_TitleRename; + public static String OpRestoreFavorites_name; public static String CacheManager_SetReadOnlyFailed; public static String OpStreamOp_Bytes; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties index 51fded087..1150ba3fb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties @@ -60,6 +60,8 @@ OpStreamOp_Bytes=\ bytes OpStreamOp_KBs=\ KBs OpStreamOp_MBs=\ MBs +OpCacheFileDigest_error_updatingDigest=Failed to update digest +OpCacheFileDigest_name=Update cache digest OpCommitAttr_error_cannotSetAttributes=Cannot set attributes OpCommitAttr_name=Set file attributes: @@ -94,6 +96,7 @@ OpRefresh_errorReadAttributes=Cannot read attributes of {0} OpRefresh_name=Refresh {0} OpRename_TitleRename=Rename +OpRestoreFavorites_name=Open favorites OpTargetFileDigest_error_download=Cannot download {0} OpTargetFileDigest_error_openFile=Cannot open file {0} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.pde.prefs b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.pde.prefs index cf80c8bc5..bba43b532 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.pde.prefs +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/.settings/org.eclipse.pde.prefs @@ -18,7 +18,7 @@ compilers.p.missing-version-export-package=2 compilers.p.missing-version-import-package=1 compilers.p.missing-version-require-bundle=1 compilers.p.no-required-att=0 -compilers.p.not-externalized-att=2 +compilers.p.not-externalized-att=1 compilers.p.unknown-attribute=1 compilers.p.unknown-class=1 compilers.p.unknown-element=1 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 e36169fe8..19bccbda3 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 @@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.compare;bundle-version="3.5.300", org.eclipse.tcf.te.ui.views;bundle-version="1.3.1", org.eclipse.tcf.te.ui.controls;bundle-version="1.3.1", org.eclipse.tcf.te.runtime.services;bundle-version="1.3.1", - org.eclipse.tcf.te.tcf.core.model;bundle-version="1.3.1" + org.eclipse.tcf.te.tcf.core.model;bundle-version="1.3.1", + org.eclipse.core.resources;bundle-version="3.8.1";resolution:=optional Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/icons/ovr/ovr_revealOnConnect.png b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/icons/ovr/ovr_revealOnConnect.png Binary files differnew file mode 100644 index 000000000..55f87a04c --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/icons/ovr/ovr_revealOnConnect.png diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties index 050e20f27..76a072c71 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties @@ -64,6 +64,7 @@ command.commit.name = Commit File command.merge.name = Merge File command.revert.name = Revert File command.download.name = Download Files +command.toggleReavealOnConnect.name = Toggle Reveal on Connect command.delete.label=Delete command.delete.description=Delete the selected node @@ -73,6 +74,7 @@ decorator.outdated.label = Remote File System Outdated Cache Decorator decorator.conflict.label = Remote File System Conflicting Cache Decorator decorator.label.cut = Remote File System Cut File Decorator decorator.hidden.label = Remote File System Hidden File Decorator +decorator.revealOnConnect.label = Remote File System Reveal on Connect Decorator menu.label.openwith = Open With menu.new.label = &New 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 ca7e2f0e2..7cd6897b7 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 @@ -35,7 +35,10 @@ </or> </triggerPoints> <possibleChildren> - <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/> + <or> + <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/> + <adapt type="org.eclipse.core.resources.IResource"/> + </or> </possibleChildren> <commonSorter class="org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeViewerSorter" @@ -523,7 +526,7 @@ </visibleWhen> </command> <command - commandId="org.eclipse.tcf.te.tcf.filesystem.ui.download" + commandId="org.eclipse.tcf.te.tcf.filesystem.commands.download" helpContextId="org.eclipse.tcf.te.tcf.filesystem.command_Download" id="download" label="%command.label.download" @@ -547,6 +550,17 @@ label="%command.search.label" style="push"> </command> + <dynamic + class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.ToggleRevealOnConnectContributionItem" + id="toggleRevealOnConnect"> + <visibleWhen checkEnabled="false"> + <with variable="selection"> + <iterate ifEmpty="false" operator="and"> + <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/> + </iterate> + </with> + </visibleWhen> + </dynamic> <separator name="group.properties" visible="true"/> <command commandId="org.eclipse.ui.file.properties" @@ -632,6 +646,19 @@ </dynamic> </menu> </menuContribution> + <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.search"> + <dynamic + class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.ToggleRevealOnConnectContributionItem" + id="toggleRevealOnConnect"> + <visibleWhen checkEnabled="false"> + <with variable="selection"> + <iterate ifEmpty="false" operator="and"> + <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode"/> + </iterate> + </with> + </visibleWhen> + </dynamic> + </menuContribution> <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.edit"> <command @@ -955,7 +982,7 @@ </visibleWhen> </command> <command - commandId="org.eclipse.tcf.te.tcf.filesystem.ui.download" + commandId="org.eclipse.tcf.te.tcf.filesystem.commands.download" helpContextId="org.eclipse.tcf.te.tcf.filesystem.command_Download" id="download" label="%command.label.download" @@ -1064,7 +1091,7 @@ name="%command.refreshViewer.name"> </command> <command - id="org.eclipse.tcf.te.tcf.filesystem.ui.download" + id="org.eclipse.tcf.te.tcf.filesystem.commands.download" name="%command.download.name"> </command> </extension> @@ -1422,7 +1449,7 @@ </handler> <handler class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.DownloadFilesHandler" - commandId="org.eclipse.tcf.te.tcf.filesystem.ui.download"> + commandId="org.eclipse.tcf.te.tcf.filesystem.commands.download"> <activeWhen> <and> <with variable="activePartId"> @@ -1720,6 +1747,17 @@ </objectState> </enablement> </decorator> + <decorator + icon="icons/ovr/ovr_revealOnConnect.png" + id="revealOnConnect" + label="%decorator.revealOnConnect.label" + lightweight="true" + location="TOP_LEFT" + state="true"> + <enablement> + <objectState name="isRevealOnConnect" value="true"/> + </enablement> + </decorator> </extension> <!-- Preference contributions --> @@ -1837,7 +1875,8 @@ autoExpandLevel="0" contentProvider="org.eclipse.tcf.te.tcf.filesystem.ui.controls.FSTreeContentProvider" id="org.eclipse.tcf.te.ui.controls.viewer.fs" - persistent="true"> + persistent="true" + useLabelDecorator="true"> <creation> <style name="SWT.FULL_SELECTION" /> <style name="SWT.MULTI" /> @@ -1876,7 +1915,7 @@ alignment="SWT.LEFT" comparator="org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementComparator" id="name" - labelProvider="org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider" + labelProvider="org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.DecoratingFSTreeElementLabelProvider" moveable="true" name="%column.name.name" resizable="true" @@ -2043,13 +2082,6 @@ </propertySections> </extension> <extension - point="org.eclipse.ui.elementFactories"> - <factory - class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.FSTreeNodeFactory" - id="org.eclipse.tcf.te.tcf.filesystem.ui.nodeFactory"> - </factory> - </extension> - <extension point="org.eclipse.ui.bindings"> <key commandId="org.eclipse.ui.navigator.Open" diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/activator/UIPlugin.java index 5584c7375..0cc49b3b5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/activator/UIPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -206,17 +206,6 @@ public class UIPlugin extends AbstractUIPlugin implements IPreferenceKeys { } /** - * If the option of "expanded_persisted" is set to on. - * - * @return true if the expanded state should be persisted or else false. - */ - public static boolean isExpandedPersisted() { - IPreferenceStore preferenceStore = getDefault().getPreferenceStore(); - boolean persisted = preferenceStore.getBoolean(PREF_EXPANDED_PERSISTED); - return persisted; - } - - /** * If the option of "in-place editor" is set to on. * * @return true if it uses in-place editor when renaming files/folders. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java index 73a90afae..9c5ef7536 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/controls/NavigatorContentProvider.java @@ -9,10 +9,14 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.filesystem.ui.controls; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Set; + import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.ITreeViewerListener; -import org.eclipse.jface.viewers.TreeExpansionEvent; -import org.eclipse.jface.viewers.Viewer; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.tcf.te.runtime.callback.Callback; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode; import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel; import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager; @@ -22,7 +26,9 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; /** * The base navigator content provider for File System and Process Monitor */ -public abstract class NavigatorContentProvider extends TreeContentProvider implements ITreeViewerListener { +public abstract class NavigatorContentProvider extends TreeContentProvider { + + private Set<IRuntimeModel> fModelsWithOpenFavorites = new HashSet<IRuntimeModel>(); /* (non-Javadoc) * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) @@ -45,53 +51,35 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl return null; } - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeViewerListener#treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent) - */ - @Override - public void treeCollapsed(TreeExpansionEvent event) { - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeViewerListener#treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent) - */ - @Override - public void treeExpanded(TreeExpansionEvent event) { -// Object object = event.getElement(); -// if(object instanceof IFSTreeNode) { -// IFSTreeNode parent = (IFSTreeNode) object; -// IFSTreeNode[] children = parent.getChildren(); -// if (children == null) { -// parent.operationRefresh(false).runInJob(null); -// } -// } - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - super.inputChanged(viewer, oldInput, newInput); - this.viewer.addTreeListener(this); - } - - /* - * (non-Javadoc) - * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#dispose() - */ - @Override - public void dispose() { - this.viewer.removeTreeListener(this); - super.dispose(); + private void checkOpenFavorites(IRuntimeModel rtm) { + if (!fModelsWithOpenFavorites.add(rtm)) + return; + + final IResultOperation<IFSTreeNode[]> operation = rtm.operationRestoreFavorites(); + operation.runInJob(new Callback() { + @Override + protected void internalDone(Object caller, IStatus status) { + IFSTreeNode[] nodes = operation.getResult(); + if (nodes != null) { + final Set<IFSTreeNode> expandMe = new LinkedHashSet<IFSTreeNode>(); + for (IFSTreeNode node : nodes) { + while ((node = node.getParent()) != null) { + expandMe.add(node); + } + } + viewer.getControl().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + for (IFSTreeNode n : expandMe) { + viewer.setExpandedState(n, true); + } + } + }); + } + } + }); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ @Override public Object[] getChildren(Object parentElement) { super.getChildren(parentElement); @@ -102,6 +90,7 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl if (model == null) return NO_ELEMENTS; + checkOpenFavorites(model); if (isRootNodeVisible()) { IFSTreeNode root = model.getRoot(); return new Object[] { root }; @@ -109,6 +98,8 @@ public abstract class NavigatorContentProvider extends TreeContentProvider impl return getChildren(model.getRoot()); } else if (parentElement instanceof IFSTreeNode) { IFSTreeNode node = (IFSTreeNode)parentElement; + checkOpenFavorites(node.getRuntimeModel()); + if (!(node.isDirectory() || node.isFileSystem())) return NO_ELEMENTS; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/interfaces/preferences/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/interfaces/preferences/IPreferenceKeys.java index 7bcc6d246..a32aa7b82 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/interfaces/preferences/IPreferenceKeys.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/interfaces/preferences/IPreferenceKeys.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -24,7 +24,7 @@ public interface IPreferenceKeys { */ public static final String PREF_FEATURE_ENABLE_EDITOR_CONTENT_CONTRIBUTION = PREFIX + "feature.editor.content.enable"; //$NON-NLS-1$ // The default value for editor content contribution - public static final boolean DEFAULT_FEATURE_ENABLE_EDITOR_CONTENT_CONTRIBUTION = true; + public static final boolean DEFAULT_FEATURE_ENABLE_EDITOR_CONTENT_CONTRIBUTION = true; // The preference key to access the option of auto saving public static final String PREF_AUTOSAVING = "PrefAutoSaving"; //$NON-NLS-1$ // The default value of the option of auto saving. @@ -41,8 +41,4 @@ public interface IPreferenceKeys { public static final String PREF_COPY_OWNERSHIP = "PrefCopyOwnership"; //$NON-NLS-1$ // The default value of the option of copy ownership public static final boolean DEFAULT_COPY_OWNERSHIP = true; - // The preference key to access the option that if expanded nodes should be persisted - public static final String PREF_EXPANDED_PERSISTED = "PrefExpandedPersisted"; //$NON-NLS-1$ - // The default value of the option that if expanded nodes should be persisted - public static final boolean DEFAULT_EXPANDED_PERSISTED = false; } 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 2c7e59a06..ed6d86e0c 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 @@ -18,7 +18,6 @@ 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.interfaces.runtime.IFSTreeNode; -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.IPeerNode; @@ -91,9 +90,6 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory { 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); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java deleted file mode 100644 index 0e1c6b4c7..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2015 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 static org.eclipse.tcf.te.tcf.locator.model.ModelManager.getPeerModel; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IResultOperation; -import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode; -import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IRuntimeModel; -import org.eclipse.tcf.te.tcf.filesystem.core.model.ModelManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; -import org.eclipse.ui.IElementFactory; -import org.eclipse.ui.IMemento; - -/** - * The element factory for IFSTreeNode used to restore FSTreeNodes persisted - * for expanded states. - */ -public class FSTreeNodeFactory implements IElementFactory { - @Override - public IAdaptable createElement(IMemento memento) { - String peerId = memento.getString("peerId"); //$NON-NLS-1$ - if (peerId == null) - return null; - - for (IPeerNode peerNode : getPeerModel().getPeerNodes()) { - if (peerNode.getPeerId().equals(peerId)) { - IRuntimeModel rtm = ModelManager.getRuntimeModel(peerNode); - if (rtm != null) { - String path = memento.getString("path"); //$NON-NLS-1$ - if (path == null) { - return rtm.getRoot(); - } - IResultOperation<IFSTreeNode> op = rtm.operationRestoreFromPath(path); - if (op.run(null).isOK()) { - return op.getResult(); - } - } - return null; - } - } - return null; - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java index 528fe7c62..e1f1846ff 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/NodeStateFilter.java @@ -48,8 +48,7 @@ public class NodeStateFilter implements IActionFilter { if (value == null) value = CacheState.consistent.name(); return value.equals(state.name()); - } - else if (name.equals("edit.cut")) { //$NON-NLS-1$ + } else if (name.equals("edit.cut")) { //$NON-NLS-1$ FsClipboard cb = UIPlugin.getClipboard(); if (!cb.isEmpty()) { if (cb.isCutOp()) { @@ -59,8 +58,7 @@ public class NodeStateFilter implements IActionFilter { } } } - } - else if (name.equals("hidden")) { //$NON-NLS-1$ + } else if (name.equals("hidden")) { //$NON-NLS-1$ if (value == null) value = "true"; //$NON-NLS-1$ boolean result = false; if (!node.isRootDirectory()) { @@ -72,6 +70,9 @@ public class NodeStateFilter implements IActionFilter { } } return Boolean.toString(result).equals(value); + } else if (name.equals("isRevealOnConnect")) { //$NON-NLS-1$ + boolean expect = value == null || Boolean.parseBoolean(value); + return expect == node.isRevealOnConnect(); } return false; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DecoratingFSTreeElementLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DecoratingFSTreeElementLabelProvider.java new file mode 100644 index 000000000..41166a3a6 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/columns/DecoratingFSTreeElementLabelProvider.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2011, 2015 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.columns; + +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.DecorationContext; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.ui.PlatformUI; + +/** + * The label provider for the tree column "name". + */ +public class DecoratingFSTreeElementLabelProvider extends DecoratingLabelProvider { + + public DecoratingFSTreeElementLabelProvider() { + super(new FSTreeElementLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); + DecorationContext context = new DecorationContext(); + context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); + setDecorationContext(context); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java index ce23977a6..b40971462 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/CommonDnD.java @@ -12,9 +12,13 @@ package org.eclipse.tcf.te.tcf.filesystem.ui.internal.dnd; import static java.util.Arrays.asList; import java.io.File; +import java.util.ArrayList; import java.util.List; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.IStructuredSelection; @@ -36,6 +40,7 @@ import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.MoveCopyCallback; import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor; import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; import org.eclipse.ui.PlatformUI; +import org.osgi.framework.Bundle; /** * Common DnD operations shared by File Explorer and Target Explorer. */ @@ -123,16 +128,25 @@ public class CommonDnD implements IConfirmCallback { * @return true if the dropping is successful. */ public boolean dropLocalSelection(IFSTreeNode target, int operations, IStructuredSelection selection) { - List<IFSTreeNode> nodes = selection.toList(); + List<IFSTreeNode> nodes = toNodes(selection); IOperation operation; boolean move = (operations & DND.DROP_MOVE) != 0; - if (move) { + if (move && nodes != null) { operation = target.operationDropMove(nodes, new MoveCopyCallback()); } else if ((operations & DND.DROP_COPY) != 0) { - IFSTreeNode dest = getCopyDestination(target, nodes); - boolean cpPerm = UIPlugin.isCopyPermission(); - boolean cpOwn = UIPlugin.isCopyOwnership(); - operation = dest.operationDropCopy(nodes, cpPerm, cpOwn, new MoveCopyCallback()); + if (nodes != null) { + IFSTreeNode dest = getCopyDestination(target, nodes); + boolean cpPerm = UIPlugin.isCopyPermission(); + boolean cpOwn = UIPlugin.isCopyOwnership(); + operation = dest.operationDropCopy(nodes, cpPerm, cpOwn, new MoveCopyCallback()); + } else { + List<String> files = toFiles(selection); + if (files != null) { + operation = target.operationDropFiles(files, new MoveCopyCallback()); + } else { + return false; + } + } } else { return false; } @@ -198,33 +212,74 @@ public class CommonDnD implements IConfirmCallback { * @param transferType The transfered data simulator. * @return true if it is valid for dropping. */ - public boolean validateLocalSelectionDrop(Object target, int operation, TransferData transferType) { + public int validateLocalSelectionDrop(Object target, int operation, TransferData transferType) { IFSTreeNode hovered = (IFSTreeNode) target; LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer(); IStructuredSelection selection = (IStructuredSelection) transfer.getSelection(); - List<IFSTreeNode> nodes = selection.toList(); boolean moving = (operation & DND.DROP_MOVE) != 0; boolean copying = (operation & DND.DROP_COPY) != 0; - if (hovered.isDirectory() && hovered.isWritable() && (moving || copying)) { - IFSTreeNode head = nodes.get(0); - String hid = head.getPeerNode().getPeerId(); - String tid = hovered.getPeerNode().getPeerId(); - if (hid.equals(tid)) { - for (IFSTreeNode node : nodes) { - if (moving && node == hovered || node.getParent() == hovered || node.isAncestorOf(hovered)) { - return false; + if (!moving && !copying) + return 0; + + List<IFSTreeNode> nodes = toNodes(selection); + if (nodes != null) { + if (hovered.isDirectory() && hovered.isWritable() && (moving || copying)) { + IFSTreeNode head = nodes.get(0); + String hid = head.getPeerNode().getPeerId(); + String tid = hovered.getPeerNode().getPeerId(); + if (hid.equals(tid)) { + for (IFSTreeNode node : nodes) { + if (moving && node == hovered || node.getParent() == hovered || node.isAncestorOf(hovered)) { + return 0; + } } + return operation; } - return true; + } else if (hovered.isFile() && (copying || moving)) { + hovered = hovered.getParent(); + return validateLocalSelectionDrop(hovered, operation, transferType); } + return 0; } - else if (hovered.isFile() && copying) { - hovered = hovered.getParent(); - return validateLocalSelectionDrop(hovered, operation, transferType); + List<String> files = toFiles(selection); + if (files != null) { + if (hovered.isDirectory() && hovered.isWritable()) { + return DND.DROP_COPY; + } + return 0; } - return false; + return 0; } + private List<IFSTreeNode> toNodes(IStructuredSelection selection) { + List<IFSTreeNode> nodes = new ArrayList<IFSTreeNode>(); + for (Object o : selection.toList()) { + if (!(o instanceof IFSTreeNode)) + return null; + nodes.add((IFSTreeNode) o); + } + return nodes; + } + + private List<String> toFiles(IStructuredSelection selection) { + // Dependency to org.eclipse.core.resources is optional + Bundle rb = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$ + if (rb == null || rb.getState() != Bundle.ACTIVE) + return null; + + List<String> files = new ArrayList<String>(); + for (Object o : selection.toList()) { + IResource res = (IResource) Platform.getAdapterManager().getAdapter(o, IResource.class); + if (res == null) + return null; + IPath location = res.getLocation(); + if (location == null) + return null; + files.add(location.toFile().getAbsolutePath()); + } + return files; + } + /* * (non-Javadoc) * @see org.eclipse.tcf.te.tcf.filesystem.interfaces.IConfirmCallback#requires(java.lang.Object) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropAdapterAssistant.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropAdapterAssistant.java index 9cf4929e8..5a65c5c08 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropAdapterAssistant.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropAdapterAssistant.java @@ -51,7 +51,11 @@ public class FSDropAdapterAssistant extends CommonDropAdapterAssistant { boolean valid = false; if (target instanceof IFSTreeNode) { if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { - valid = dnd.validateLocalSelectionDrop(target, operation, transferType); + int op = dnd.validateLocalSelectionDrop(target, operation, transferType); + valid = op != 0; + if (valid && op != operation) { + getCommonDropAdapter().overrideOperation(op); + } } else if(FileTransfer.getInstance().isSupportedType(transferType)) { valid = dnd.validateFilesDrop(target, operation, transferType); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java index 0c0b91c3e..62b7be625 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/dnd/FSDropTargetListener.java @@ -59,7 +59,13 @@ public class FSDropTargetListener extends ViewerDropAdapter { public boolean validateDrop(Object target, int operation, TransferData transferType) { if (target instanceof IFSTreeNode) { if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { - return dnd.validateLocalSelectionDrop(target, operation, transferType); + int op = dnd.validateLocalSelectionDrop(target, operation, transferType); + if (op == 0) + return false; + if (op != operation) { + overrideOperation(op); + } + return true; } else if (FileTransfer.getInstance().isSupportedType(transferType)) { return dnd.validateFilesDrop(target, operation, transferType); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/ToggleRevealOnConnectContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/ToggleRevealOnConnectContributionItem.java new file mode 100644 index 000000000..bca4fe9f4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/ToggleRevealOnConnectContributionItem.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2015 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.handlers; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.runtime.IFSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * Handler for adding a file or folder to the favorites + */ +public class ToggleRevealOnConnectContributionItem extends ActionContributionItem { + + private static class ToggleAction extends Action { + public ToggleAction() { + super(Messages.ToggleRevealOnConnectContributionItem_text, IAction.AS_CHECK_BOX); + } + + @Override + public void run() { + boolean value = isChecked(); + IStructuredSelection selection = getSelection(); + if (selection != null) { + for (Object o : selection.toList()) { + if (o instanceof IFSTreeNode) { + ((IFSTreeNode) o).setRevealOnConnect(value); + } + } + } + } + + } + + public ToggleRevealOnConnectContributionItem() { + super(new ToggleAction()); + } + + @Override + public void fill(Menu parent, int index) { + updateAction(); + super.fill(parent, index); + } + + protected static IStructuredSelection getSelection() { + IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (ww == null) + return null; + + ISelection selection = ww.getSelectionService().getSelection(); + if (selection instanceof IStructuredSelection && !selection.isEmpty()) + return (IStructuredSelection) selection; + + return null; + } + + private void updateAction() { + boolean enabled = false; + int on = 0; + + IStructuredSelection selection = getSelection(); + if (selection != null) { + for (Object o : selection.toList()) { + if (!(o instanceof IFSTreeNode)) { + enabled = false; + break; + } + IFSTreeNode node = (IFSTreeNode) o; + if (node.isFileSystem()) { + enabled = false; + break; + } + on += node.isRevealOnConnect() ? 1 : -1; + enabled = true; + } + } + IAction action = getAction(); + action.setEnabled(enabled); + action.setChecked(on > 0); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencePage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencePage.java index e3a22ad7d..d16bddf1b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencePage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -49,8 +49,6 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe addField(copyPermission); BooleanFieldEditor copyOwnership = new BooleanFieldEditor(PREF_COPY_OWNERSHIP, Messages.PreferencePage_CopyOwnershipText, getFieldEditorParent()); addField(copyOwnership); - BooleanFieldEditor persistExpanded = new BooleanFieldEditor(PREF_EXPANDED_PERSISTED, Messages.PreferencePage_PersistExpanded, getFieldEditorParent()); - addField(persistExpanded); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencesInitializer.java index 228af3ced..eb36a2dfa 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencesInitializer.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/preferences/PreferencesInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -45,6 +45,5 @@ public class PreferencesInitializer extends AbstractPreferenceInitializer implem preferenceStore.setDefault(PREF_RENAMING_IN_PLACE_EDITOR, DEFAULT_RENAMING_IN_PLACE_EDITOR); preferenceStore.setDefault(PREF_COPY_PERMISSION, DEFAULT_COPY_PERMISSION); preferenceStore.setDefault(PREF_COPY_OWNERSHIP, DEFAULT_COPY_OWNERSHIP); - preferenceStore.setDefault(PREF_EXPANDED_PERSISTED, DEFAULT_EXPANDED_PERSISTED); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.java index 3fd9bf9c7..9250f3c5c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.java @@ -245,6 +245,7 @@ public class Messages extends NLS { public static String TargetSelectionPage_Description; public static String TargetSelectionPage_Targets; public static String TargetSelectionPage_Title; + public static String ToggleRevealOnConnectContributionItem_text; public static String TreeViewerSearchDialog_LblCancelText; public static String TreeViewerSearchDialog_GrpOptionsText; public static String TreeViewerSearchDialog_BtnCaseText; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties index 33a0fe182..bd1ce8788 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/nls/Messages.properties @@ -167,6 +167,7 @@ SizeValidator_InfoPrompt=Please enter a size number. TargetSelectionPage_Description=Please select the target where the new file or folder is created. TargetSelectionPage_Targets=Targets: TargetSelectionPage_Title=Select the target. +ToggleRevealOnConnectContributionItem_text=Reveal on Connect TreeViewerSearchDialog_LblCancelText=Find: TreeViewerSearchDialog_GrpOptionsText=Options TreeViewerSearchDialog_BtnCaseText=Case sensitive diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileManager.java index 3c6bfc943..306fd747e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileManager.java @@ -31,11 +31,10 @@ public class TCFFileManager implements IRemoteFileManager { @Override public IFileStore getResource(String pathStr) { - IPath path = new Path(pathStr); - if (!path.isAbsolute()) { - path = new Path(fConnection.getWorkingDirectory()).append(path); + if (!pathStr.startsWith("/")) { //$NON-NLS-1$ + pathStr = fConnection.getWorkingDirectory() + "/" + pathStr; //$NON-NLS-1$ } - return TCFFileStore.getInstance(fConnection, path, null); + return TCFFileStore.getInstance(fConnection, pathStr, null); } @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileStore.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileStore.java index 472be855e..63d36c3a8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileStore.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/TCFFileStore.java @@ -21,7 +21,6 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; @@ -43,33 +42,31 @@ import org.eclipse.tcf.te.tcf.remote.core.operation.TCFOperationPutInfo; public final class TCFFileStore extends FileStore { public static IFileStore getInstance(URI uri) { - Path path = new Path(uri.getPath()); IRemoteConnection connection = TCFEclipseFileSystem.getConnection(uri); if (connection instanceof TCFConnection) - return new TCFFileStore((TCFConnection) connection, path, uri, null); + return new TCFFileStore((TCFConnection) connection, uri, null); - return EFS.getNullFileSystem().getStore(path); + return EFS.getNullFileSystem().getStore(new Path(uri.getPath())); } - public static IFileStore getInstance(TCFConnection connection, IPath path, TCFFileStore parent) { + public static IFileStore getInstance(TCFConnection connection, String path, TCFFileStore parent) { try { - return new TCFFileStore(connection, path, TCFEclipseFileSystem.getURIFor(connection, path.toString()), parent); + URI uri = TCFEclipseFileSystem.getURIFor(connection, path); + return new TCFFileStore(connection, uri, parent); } catch (URISyntaxException e) { Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), Messages.TCFFileManager_errorFileStoreForPath, e)); } - return EFS.getNullFileSystem().getStore(path); + return EFS.getNullFileSystem().getStore(new Path(path)); } private final URI fURI; private final TCFConnection fConnection; - private final IPath fRemotePath; private FileAttrs fAttributes; private IFileStore fParent; - private TCFFileStore(TCFConnection connection, IPath path, URI uri, TCFFileStore parent) { + private TCFFileStore(TCFConnection connection, URI uri, TCFFileStore parent) { fURI = uri; fConnection = connection; - fRemotePath = new Path(uri.getPath()); fParent = parent; } @@ -82,8 +79,8 @@ public final class TCFFileStore extends FileStore { return fConnection; } - public IPath getPath() { - return fRemotePath; + public String getPath() { + return fURI.getPath(); } public void setAttributes(FileAttrs attrs) { @@ -96,15 +93,20 @@ public final class TCFFileStore extends FileStore { @Override public IFileStore getChild(String name) { - return getInstance(fConnection, fRemotePath.append(name), this); + String path = getPath() + '/' + name; + path = path.replaceAll("/+", "/"); //$NON-NLS-1$ //$NON-NLS-2$ + if (path.length() > 1 && path.endsWith("/")) //$NON-NLS-1$ + path = path.substring(0, path.length()-1); + return getInstance(fConnection, path, this); } @Override public String getName() { - if (fRemotePath.isRoot()) { - return fRemotePath.toString(); - } - return fRemotePath.lastSegment(); + String path = getPath(); + int idx = path.lastIndexOf('/'); + if (idx > 0) + return path.substring(idx + 1); + return path; } @Override @@ -112,10 +114,12 @@ public final class TCFFileStore extends FileStore { if (fParent != null) return fParent; - if (fRemotePath.isRoot()) + String path = getPath(); + int idx = path.lastIndexOf('/'); + if (idx < 1) return null; - fParent = getInstance(fConnection, fRemotePath.removeLastSegments(1), null); + fParent = getInstance(fConnection, path.substring(0, idx-1), null); return fParent; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/operation/TCFOperationChildStores.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/operation/TCFOperationChildStores.java index b25fee27e..bc26a8fe1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/operation/TCFOperationChildStores.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.remote.core/src/org/eclipse/tcf/te/tcf/remote/core/operation/TCFOperationChildStores.java @@ -24,6 +24,7 @@ import org.eclipse.tcf.services.IFileSystem.DirEntry; import org.eclipse.tcf.services.IFileSystem.DoneClose; import org.eclipse.tcf.services.IFileSystem.DoneOpen; import org.eclipse.tcf.services.IFileSystem.DoneReadDir; +import org.eclipse.tcf.services.IFileSystem.DoneRoots; import org.eclipse.tcf.services.IFileSystem.FileSystemException; import org.eclipse.tcf.services.IFileSystem.IFileHandle; import org.eclipse.tcf.te.tcf.remote.core.TCFFileStore; @@ -65,20 +66,37 @@ public class TCFOperationChildStores extends TCFFileStoreOperation<IFileStore[]> return; setFileSystem(fileSystem); - fileSystem.opendir(getPath(), new DoneOpen() { + final String path = getPath(); + fileSystem.opendir(path, new DoneOpen() { @Override public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) { - if (shallAbort(error)) - return; - - setFileHandle(handle); - readDir(); + if (error != null && (path.length() == 0 || path.equals("/"))) { //$NON-NLS-1$ + readRoots(); + } else if (!shallAbort(error)) { + setFileHandle(handle); + readDir(); + } } }); } }); } + protected void readRoots() { + fFileSystem.roots(new DoneRoots() { + @Override + public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) { + if (shallAbort(error)) { + return; + } + for (DirEntry dirEntry : entries) { + createFileStore(dirEntry); + } + setResult(); + } + }); + } + protected void readDir() { fFileSystem.readdir(fFileHandle, new DoneReadDir() { @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/viewers.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/viewers.exsd index e2a003230..d4be222e8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/viewers.exsd +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/viewers.exsd @@ -95,6 +95,13 @@ </documentation> </annotation> </attribute> + <attribute name="useLabelDecorator" type="boolean"> + <annotation> + <documentation> + Whether to use a decorating label provider. + </documentation> + </annotation> + </attribute> </complexType> </element> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java index ea934d10e..4192b1c40 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/AbstractTreeControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -28,6 +28,7 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.ColumnViewerEditor; import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; +import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -49,8 +50,11 @@ import org.eclipse.tcf.te.core.interfaces.IViewerInput; import org.eclipse.tcf.te.ui.WorkbenchPartControl; import org.eclipse.tcf.te.ui.forms.CustomFormToolkit; import org.eclipse.tcf.te.ui.interfaces.ITreeControlInputChangedListener; +import org.eclipse.ui.IDecoratorManager; +import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; /** @@ -86,7 +90,7 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement /** * Constructor. * - * @param parentPart The parent workbench part this control is embedded in or <code>null</code>. + * @param parent The parent workbench part this control is embedded in or <code>null</code>. */ public AbstractTreeControl(IWorkbenchPart parent) { super(parent); @@ -561,6 +565,13 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement } /** + * Whether to use a decorating label provider. + */ + protected boolean useLabelDecorator() { + return false; + } + + /** * Creates the tree viewer layout data instance. * * @param viewer The tree viewer. Must not be <code>null</code>. @@ -583,12 +594,12 @@ public abstract class AbstractTreeControl extends WorkbenchPartControl implement */ protected ILabelProvider doCreateTreeViewerLabelProvider(AbstractTreeControl parentTreeControl, TreeViewer viewer) { TreeViewerLabelProvider labelProvider = new TreeViewerLabelProvider(parentTreeControl, viewer); - // do not use a decorating label provider to avoid decoration when system management view element is visible - // in this case, the decoration is done also on the editor tab element!! - // IWorkbench workbench = PlatformUI.getWorkbench(); - // IDecoratorManager manager = workbench.getDecoratorManager(); - // ILabelDecorator decorator = manager.getLabelDecorator(); - // return new TreeViewerDecoratingLabelProvider(viewer, labelProvider,decorator); + if (useLabelDecorator()) { + IWorkbench workbench = PlatformUI.getWorkbench(); + IDecoratorManager manager = workbench.getDecoratorManager(); + ILabelDecorator decorator = manager.getLabelDecorator(); + return new TreeViewerDecoratingLabelProvider(viewer, labelProvider,decorator); + } return labelProvider; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeControl.java index 559977c8d..cbbef6ec2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -146,4 +146,9 @@ public class TreeControl extends AbstractTreeControl { protected int getAutoExpandLevel() { return viewerDescriptor.getAutoExpandLevel(); } + + @Override + protected boolean useLabelDecorator() { + return viewerDescriptor.getUseLabelDecorator(); + } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerExtension.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerExtension.java index 58e239515..e4c0d719a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerExtension.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerExtension.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -130,6 +130,10 @@ public class TreeViewerExtension { if (value != null) { descriptor.setPersistent(Boolean.valueOf(value).booleanValue()); } + value = configuration.getAttribute("useLabelDecorator"); //$NON-NLS-1$ + if (value != null) { + descriptor.setUseLabelDecorator(Boolean.valueOf(value).booleanValue()); + } value = configuration.getAttribute("autoExpandLevel"); //$NON-NLS-1$ if (value != null) { try { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerDescriptor.java index 0fdeb1006..2b7dd02f0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerDescriptor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ViewerDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2015 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 @@ -28,6 +28,7 @@ public class ViewerDescriptor { private boolean persistent = false; // The auto expand level. private int autoExpandLevel = 2; + private boolean labelDecorator; public IConfigurationElement getStyleConfig() { return styleConfig; @@ -76,4 +77,12 @@ public class ViewerDescriptor { public void setAutoExpandLevel(int autoExpandLevel) { this.autoExpandLevel = autoExpandLevel; } + + public void setUseLabelDecorator(boolean useDecorator) { + this.labelDecorator = useDecorator; + } + + public boolean getUseLabelDecorator() { + return labelDecorator; + } } |