Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 136242 Details for
Bug 164483
Test navigator doesn't show regular JUnits that are not under a source folder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch.
Bugzilla_164483_Patch.txt (text/plain), 80.17 KB, created by
Paul Slauenwhite
on 2009-05-18 20:04:26 EDT
(
hide
)
Description:
Patch.
Filename:
MIME Type:
Creator:
Paul Slauenwhite
Created:
2009-05-18 20:04:26 EDT
Size:
80.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.ui >Index: src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java,v >retrieving revision 1.6 >diff -u -r1.6 ProxyNodeTransfer.java >--- src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java 20 Mar 2008 19:49:53 -0000 1.6 >+++ src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,18 +16,20 @@ > import java.io.DataOutputStream; > import java.io.IOException; > >-import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorProvider; >+import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorContentProvider; > import org.eclipse.swt.dnd.ByteArrayTransfer; > import org.eclipse.swt.dnd.TransferData; > > /** >- * Transfer class used by Copy/Paste actions of proxy nodes, in resource mode. >+ * <p>Transfer class used by copy and paste actions of proxy nodes in the Resource view of the Test Navigator.</p> > * >- * @author jgout >- * @version February 26, 2008 >- * @since 3.3 >+ * >+ * @author Jerome Gout >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since March 7, 2005 > */ >-public class ProxyNodeTransfer extends ByteArrayTransfer { >+ public class ProxyNodeTransfer extends ByteArrayTransfer { > private static final ProxyNodeTransfer instance = new ProxyNodeTransfer(); > //- Create a unique ID to make sure that different Eclipse > //- applications use different "types" of <code>ProxyNodeTransfer</code> >@@ -66,7 +68,7 @@ > private IProxyNode readProxy(DataInputStream dataIn) throws IOException { > String fileName = dataIn.readUTF(); > String identifier = dataIn.readUTF(); >- return ResourceTestNavigatorProvider.getSharedFileProxyManager().getCorrespondingProxy(fileName, identifier); >+ return ResourceTestNavigatorContentProvider.getSharedFileProxyManager().getCorrespondingProxy(fileName, identifier); > } > > /** >Index: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorLabelProvider.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorLabelProvider.java,v >retrieving revision 1.4 >diff -u -r1.4 TestNavigatorLabelProvider.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorLabelProvider.java 22 Mar 2007 14:42:05 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorLabelProvider.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >@@ -26,10 +26,14 @@ > import org.eclipse.ui.model.IWorkbenchAdapter; > import org.eclipse.ui.model.WorkbenchLabelProvider; > >-/** Label provider used by the views of the test navigator >+/** >+ * <p>Abstract label provider for the Test Navigator.</p> > * >- * @author jgout >- * @since 4.0 >+ * >+ * @author Jerome Gout >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since February 1, 2005 > */ > public class TestNavigatorLabelProvider implements ILabelProvider, ILabelProviderListener { > >@@ -48,7 +52,7 @@ > > return workbenchAdapter; > } >- >+ > public Image getImage(Object element) { > if (element == null) > return null; >@@ -98,7 +102,6 @@ > } > > public void dispose() { >-// listeners.clear(); > workbenchProvider.dispose(); > } > >@@ -111,5 +114,4 @@ > UiPlugin.logInfo("Unable to remove listener '" + listener.toString()); //$NON-NLS-1$ > } > } >- > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorProvider.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorProvider.java 6 Apr 2007 13:49:24 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,240 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation 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 >- * $Id: ResourceTestNavigatorProvider.java,v 1.10 2007/04/06 13:49:24 jgout Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.test.ui.internal.navigator; >- >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.hyades.test.ui.UiPlugin; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.FileProxiesRequest; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.IProxiesRequestListener; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.ProxiesRequest; >-import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >-import org.eclipse.hyades.test.ui.navigator.IProxyNode; >-import org.eclipse.hyades.ui.util.IDisposable; >- >-/** This the resource oriented provider for the test navigator view. >- * @author jgout >- * @since 4.0 >- */ >-public class ResourceTestNavigatorProvider extends TestNavigatorProvider { >- >- /** The file proxy manager to acces to proxies from files */ >- private static FileProxyManager fileProxyManager = new FileProxyManager(); >- >- /** >- * @return Returns the fileProxyManager. >- */ >- public static FileProxyManager getSharedFileProxyManager() { >- return fileProxyManager; >- } >- >- public ResourceTestNavigatorProvider(TestNavigator testNavigator) { >- super(testNavigator); >- } >- >- private FileProxyRequests requests = new FileProxyRequests(); >- >- protected IFileProxyManager getFileProxyManager() { >- return fileProxyManager; >- } >- >- public Object getParent(Object element) { >- if (element instanceof IResource) { >- return ((IResource) element).getParent(); >- } >- return super.getParent(element); >- } >- >- public boolean hasChildren(Object parentElement) { >- if (parentElement == null) >- return false; >- if (parentElement instanceof IContainer) { >- IContainer container = (IContainer) parentElement; >- if (!container.isAccessible()) >- return false; >- >- IResource[] resources = null; >- try { >- resources = container.members(); >- } catch (CoreException e) { >- UiPlugin.logError(e); >- return false; >- } >- if (resources.length == 0) return false; >- if (parentElement instanceof IProject) { >- return true; >- } >- for (int i = 0; i < resources.length; i++) { >- if (resources[i].getType() != IResource.FILE) { >- if (!TestNavigator.getFiltersManager().filter(resources[i])) >- return true; >- } else { >- String fileExtension = resources[i].getFileExtension(); >- if (fileExtension != null) { >- if (TestNavigator.getFiltersManager().isVisibleResource(resources[i])) return true; >- } >- } >- } >- return false; >- } >- return super.hasChildren(parentElement); >- } >- >- public Object[] getChildren(Object parentElement) { >- if (parentElement instanceof IContainer) { >- return getContainerChildren(parentElement); >- } else { >- return super.getChildren(parentElement); >- } >- } >- >- /** returns the children of a container node (project or folder) >- * @param parentElement >- * @return an array of Object which cn be empty but not null >- */ >- private Object[] getContainerChildren(Object parentElement) { >- IResource[] resources = null; >- IContainer container = ((IContainer) parentElement); >- if (container.isAccessible()) { >- try { >- resources = container.members(); >- } catch (CoreException e) { >- UiPlugin.logError(e); >- return new Object[0]; >- } >- List children = new ArrayList(resources.length); >- FileProxiesRequest request = requests.getRequest(container, resources); >- for (int i = 0, maxi = resources.length; i < maxi; i++) { >- if (!TestNavigator.getFiltersManager().filter(resources[i])) { >- if (resources[i].getType() != IResource.FILE) { >- children.add(resources[i]); >- } else { >- //- convert the file in something else (proxy) >- IFile file = (IFile)resources[i]; >- IProxyNode node = request.getProxy(file); >- if (!TestNavigator.getFiltersManager().filter(node)) { >- children.add(node); >- fileProxyManager.cacheProxy(file, node); >- } >- } >- } >- } >- return children.toArray(); >- } >- return new Object[0]; >- } >- >- public IGlobalProxyNodeListener getProxyNodeListener() { >- return requests; >- } >- >- private class FileProxyRequests implements IProxiesRequestListener, IDisposable, IGlobalProxyNodeListener { >- >- private Map containerToRequestMap = Collections.synchronizedMap(new HashMap()); >- >- public FileProxiesRequest getRequest(IContainer container, IResource[] members) { >- FileProxiesRequest request = (FileProxiesRequest)containerToRequestMap.get(container); >- if (request == null) { >- request = newRequest(container, members); >- } >- return request; >- } >- >- public FileProxiesRequest newRequest(IContainer container, IResource[] members) { >- ArrayList filesToRequest = new ArrayList(members.length); >- for (int i = 0, maxi = members.length; i < maxi; i++) { >- if (members[i].getType() == IResource.FILE) { >- if (!TestNavigator.getFiltersManager().filter(members[i])) { >- filesToRequest.add(members[i]); >- } >- } >- } >- if (filesToRequest.isEmpty()) return null; >- FileProxiesRequest req = new FileProxiesRequest(filesToRequest, fileProxyManager, container, testNavigator); >- req.setPriority(getJobPriority()); >- testNavigator.getJobPool().scheduleJob(req); >- if (!req.wait(getResponseTime(), this, 2000)) { >- containerToRequestMap.put(container, req); >- } >- return req; >- } >- >- public void proxyComputed(final ProxiesRequest request, Object key) { >- } >- >- public void computationCompleted(ProxiesRequest request) { >- IContainer parent = ((FileProxiesRequest)request).getParent(); >- if (containerToRequestMap.containsKey(parent)) { >- testNavigator.refresh(parent); >- } >- } >- >- public void dispose() { >- // Cancel all running requests. As the atomic action of FileProxiesRequest is >- // the computation of a single file proxy, all requests should honor the cancel >- // request quite quickly. However we don't wait them to complete (i.e. they may >- // be still running while this instance has been disposed). >- for (Iterator it = containerToRequestMap.values().iterator(); it.hasNext();) { >- FileProxiesRequest request = (FileProxiesRequest) it.next(); >- request.dispose(); >- it.remove(); >- } >- } >- >- public void proxiesComputed(ProxiesRequest request) { >- testNavigator.refresh(((FileProxiesRequest)request).getParent()); >- } >- >- public void nodeChanged(Object node) { >- if (node instanceof IContainer) { >- FileProxiesRequest req = (FileProxiesRequest) containerToRequestMap.remove(node); >- if (req != null) { >- // Then we need to cancel the current request. A new one will be spawned >- // when getChildren() is invoked on this project. >- if (req.cancel(1000)) { >- containerToRequestMap.remove(node); >- } >- } >- } >- } >- >- public void nodesChanged() { >- for (Iterator it = containerToRequestMap.keySet().iterator(); it.hasNext();) { >- nodeChanged(it.next()); >- } >- } >- >- public void computationCancelled(ProxiesRequest request) { >- IContainer parent = ((FileProxiesRequest)request).getParent(); >- containerToRequestMap.remove(parent); >- testNavigator.refresh(parent); >- } >- >- } >- >- public void dispose() { >- requests.dispose(); >- super.dispose(); >- } >- >-} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorProvider.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorProvider.java 12 Feb 2009 19:19:00 -0000 1.13 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,273 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation 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 >- * $Id: TestNavigatorProvider.java,v 1.13 2009/02/12 19:19:00 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.test.ui.internal.navigator; >- >-import java.util.LinkedList; >- >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >-import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >-import org.eclipse.hyades.test.ui.navigator.IProxyNode; >-import org.eclipse.hyades.test.ui.navigator.IProxyNodeListener; >-import org.eclipse.jface.viewers.IBaseLabelProvider; >-import org.eclipse.jface.viewers.IContentProvider; >-import org.eclipse.jface.viewers.ITreeContentProvider; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.swt.graphics.Image; >- >-/** >- * TestNavigatorProvider.java >- * <p/> >- * >- * >- * @author Jerome Gout >- * @author Julien Canches >- * @author Paul E. Slauenwhite >- * @version February 12, 2008 >- * @since March 18, 2005 >- */ >-public abstract class TestNavigatorProvider extends TestNavigatorLabelProvider implements ITreeContentProvider { >- >- private static final int MAX_PROXY_NODE_CHILDREN = 100; >- public static final int CONTEXT_LOADING = 0; >- public static final int CONTEXT_INTERACTIVE = 1; >- >- protected TestNavigator testNavigator; >- private int context; >- >- public TestNavigatorProvider(TestNavigator testNavigator) { >- this.testNavigator = testNavigator; >- this.context = CONTEXT_LOADING; >- } >- >- protected abstract IGlobalProxyNodeListener getProxyNodeListener(); >- >- protected abstract IFileProxyManager getFileProxyManager(); >- >- public Object getParent(Object element) { >- if (element instanceof IProxyNode) { >- Object parent = ((IProxyNode) element).getParent(); >- if(parent instanceof FileProxyManager.IUnboundedParent) { >- return getFileProxyManager().getParent((IProxyNode) element); >- } else { >- return parent; >- } >- } >- return null; >- } >- >- public boolean hasChildren(Object parentElement) { >- if (parentElement instanceof IProxyNode) { >- IProxyNode proxy = (IProxyNode) parentElement; >- return proxy.getChildren().length > 0; >- } >- if (parentElement instanceof IProxyGroup) { >- return true; >- } >- return false; >- } >- >- public Object[] getChildren(Object parentElement) { >- if (parentElement instanceof IProxyNode) { >- IProxyNode proxy = (IProxyNode) parentElement; >- return foldProxyNodes(proxy); >- } >- if (parentElement instanceof IProxyGroup) { >- return ((IProxyGroup)parentElement).getChildren(); >- } >- return new Object[0]; >- } >- >- public String getText(Object element) { >- if (element instanceof IProxyGroup) { >- return ((IProxyGroup)element).getText(); >- } >- return super.getText(element); >- } >- >- public Image getImage(Object element) { >- if (element instanceof IProxyGroup) { >- return ((IProxyGroup)element).getImage(); >- } >- return super.getImage(element); >- } >- >- public Object[] getElements(Object inputElement) { >- if (inputElement instanceof IWorkspaceRoot) { >- IProject [] projects = ((IWorkspaceRoot) inputElement).getProjects(); >- LinkedList visibleProjects = new LinkedList(); >- for(int i = 0; i < projects.length; i++) { >- if(!TestNavigator.getFiltersManager().filter(projects[i])) { >- visibleProjects.add(projects[i]); >- } >- } >- return visibleProjects.toArray(); >- } >- return getChildren(inputElement); >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- } >- >- public static interface IGlobalProxyNodeListener extends IProxyNodeListener { >- >- void nodesChanged(); >- >- } >- >- public static interface IProxyGroup { >- IProxyNode[] getChildren(); >- String getText(); >- Image getImage(); >- int getOrder(); >- } >- >- private static class ProxyGroup implements IProxyGroup { >- private IProxyNode parent; >- private int sequence; >- public ProxyGroup(IProxyNode node, int sequence) { >- this.parent = node; >- this.sequence = sequence; >- } >- public IProxyNode[] getChildren() { >- int start = sequence * MAX_PROXY_NODE_CHILDREN; >- IProxyNode[] completeChildren = parent.getChildren(); >- IProxyNode[] children = new IProxyNode[MAX_PROXY_NODE_CHILDREN]; >- System.arraycopy(completeChildren, start, children, 0, MAX_PROXY_NODE_CHILDREN); >- return children; >- } >- public String getText() { >- int start = sequence * MAX_PROXY_NODE_CHILDREN + 1; >- int end = (sequence + 1) * MAX_PROXY_NODE_CHILDREN; >- return ("[".concat(Integer.toString(start)).concat(" - ").concat(Integer.toString(end)).concat("]")); >- } >- public Image getImage() { >- return parent.getImage(); >- } >- public int getOrder() { >- return sequence; >- } >- } >- >- private static class RemainingProxyGroup implements IProxyGroup { >- private IProxyNode parent; >- public RemainingProxyGroup(IProxyNode parent) { >- this.parent = parent; >- } >- public IProxyNode[] getChildren() { >- IProxyNode[] completeChildren = parent.getChildren(); >- int completeLength = completeChildren.length; >- int length = completeLength % MAX_PROXY_NODE_CHILDREN; >- IProxyNode[] children = new IProxyNode[length]; >- System.arraycopy(completeChildren, completeLength - length, children, 0, length); >- return children; >- } >- public String getText() { >- IProxyNode[] completeChildren = parent.getChildren(); >- int end = completeChildren.length; >- int length = end % MAX_PROXY_NODE_CHILDREN; >- int start = end - length + 1; >- return ("[".concat(Integer.toString(start)).concat(" - ").concat(Integer.toString(end)).concat("]")); >- } >- public Image getImage() { >- return parent.getImage(); >- } >- public int getOrder() { >- return Integer.MAX_VALUE; >- } >- } >- >- protected Object[] foldProxyNodes(IProxyNode parent) { >- IProxyNode[] children = parent.getChildren(); >- int length = children.length; >- if (length <= MAX_PROXY_NODE_CHILDREN) return children; >- int size = length / MAX_PROXY_NODE_CHILDREN; >- int remaining = length % MAX_PROXY_NODE_CHILDREN; >- int totalSize = size + (remaining > 0 ? 1 : 0); >- Object[] groups = new IProxyGroup[totalSize]; >- for (int i = 0; i < size; i++) { >- groups[i] = new ProxyGroup(parent, i); >- } >- if (remaining > 0) { >- groups[size] = new RemainingProxyGroup(parent); >- } >- return groups; >- } >- >- /** >- * Sets the context in which the provider is used. There are two available values: >- * INTERACTIVE and LOADING. The context has an effect on two parameters: >- * 1) responsiveness: time that getChildren() is allowed to spent before returning >- * control. High responsiveness means that the provider will return incomplete nodes, >- * compute the remaining in a background task, and update the navigator when computation >- * is complete. Low responsiveness means that the UI will be blocked for a longer period of >- * time but the returned node are more likely to be complete. >- * 2) computation job priority: the priority allocated to the computation job, if the provider >- * does not manage to compute nodes in the allocated time (responsiveness parameter). This does >- * not affect the thread priority, but helps eclipse decide which job should be launched first. >- * In LOADING mode, responsiveness is high (100ms) and priority is low (NORMAL). >- * In INTERACTIVE mode, responsiveness is lower (800ms) and priority is high (INTERACTIVE). >- */ >- public void setContext(int context) { >- this.context = context; >- } >- >- protected int getContext() { >- return context; >- } >- >- protected int getResponseTime() { >- switch (context) { >- case CONTEXT_INTERACTIVE: >- return 800; >- case CONTEXT_LOADING: >- return 100; >- } >- return 100; >- } >- >- protected int getJobPriority() { >- switch(context) { >- case CONTEXT_INTERACTIVE: >- return Job.INTERACTIVE; >- case CONTEXT_LOADING: >- return Job.LONG; >- } >- return Job.LONG; >- } >- >- /** >- * Empty implementation of the ({@link TestNavigatorLabelProvider#dispose()}) >- * method. >- * <p/> >- * Since the {@link TestNavigatorProvider} is both a content provider >- * ({@link IContentProvider}) and label provider ({@link IBaseLabelProvider}), >- * the {@link #dispose()} method may be invoked as the implementation for the >- * {@link IContentProvider#dispose()} method or {@link IBaseLabelProvider#dispose()} >- * method. Since there is no way to determine if the invocation of this method is >- * intended to dispose the content provider ({@link IContentProvider}) or label >- * provider ({@link IBaseLabelProvider}), this method is an empty implementation. >- * <p/> >- * To dispose the label provider, call the {@link TestNavigatorLabelProvider#dispose()} >- * method directly. >- * <p/> >- * >- * @see TestNavigatorLabelProvider#dispose() >- * @see IContentProvider#dispose() >- * @see IBaseLabelProvider#dispose() >- */ >- public void dispose() { >- //No-operation. >- } >-} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigator.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigator.java,v >retrieving revision 1.37 >diff -u -r1.37 TestNavigator.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigator.java 4 May 2009 15:52:27 -0000 1.37 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigator.java 19 May 2009 00:03:27 -0000 >@@ -36,8 +36,8 @@ > import org.eclipse.hyades.test.ui.UiPlugin; > import org.eclipse.hyades.test.ui.internal.editor.BaseEditorPart; > import org.eclipse.hyades.test.ui.internal.model.ResourceUtil.ResourceAdaptable; >-import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorProvider.IGlobalProxyNodeListener; >-import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorProvider.IProxyGroup; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorContentProvider.IGlobalProxyNodeListener; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorContentProvider.IProxyGroup; > import org.eclipse.hyades.test.ui.internal.navigator.action.TestNavigatorActionGroup; > import org.eclipse.hyades.test.ui.internal.navigator.action.ToggleViewAction; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileFactoryManager; >@@ -70,7 +70,6 @@ > import org.eclipse.jface.action.IToolBarManager; > import org.eclipse.jface.action.Separator; > import org.eclipse.jface.viewers.DoubleClickEvent; >-import org.eclipse.jface.viewers.ILabelDecorator; > import org.eclipse.jface.viewers.ILabelProvider; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -101,8 +100,8 @@ > > /** > * <p>Concrete implementation of the >- * {@link org.eclipse.hyades.ui.internal.navigator.Navigator}for the Hyades >- * Test objects.</p> >+ * {@link org.eclipse.hyades.ui.internal.navigator.TreeNavigator} >+ * for test assets.</p> > * > * > * @author Marcelo Paternostro >@@ -110,7 +109,7 @@ > * @author Paul E. Slauewnhite > * @author Paul Klicnik > * @author Kurtis Martin >- * @version April 23, 2009 >+ * @version May 18, 2009 > * @since February 1, 2005 > */ > public class TestNavigator extends TreeNavigator implements ISelectionListener, IGlobalProxyNodeListener, ITestNavigator { >@@ -167,8 +166,10 @@ > /** actions to switch between both logical and resource views. */ > private ToggleViewAction[] viewActions; > >- /** Current content and label provider. */ >- private TestNavigatorProvider currentProvider; >+ /** >+ * Current content provider for the Test Navigator. >+ */ >+ private TestNavigatorContentProvider currentContentProvider; > > // - constants are used in the IDialogSettings > protected final static String SET_SHOW_FOLDERS = "SHOW_FOLDERS"; //$NON-NLS-1$ >@@ -276,7 +277,7 @@ > } > > public IFileProxyManager getCurrentFileProxyManager() { >- return currentProvider.getFileProxyManager(); >+ return currentContentProvider.getFileProxyManager(); > } > > /** >@@ -306,7 +307,7 @@ > private static class TypeProviderContext implements ITypeProviderContext { > private IProxyNodeListener refresher; > public IFileProxyManager getFileProxyManager() { >- return LogicalTestNavigatorProvider.getSharedFileProxyManager(); >+ return LogicalTestNavigatorContentProvider.getSharedFileProxyManager(); > } > public IProxyNodeListener getProxyNodeListener() { > if (refresher == null) { >@@ -397,11 +398,11 @@ > } > > private void adjustCurrentProviderContext(boolean isLoading) { >- if (currentProvider != null) { >+ if (currentContentProvider != null) { > if (isLoading) { >- currentProvider.setContext(TestNavigatorProvider.CONTEXT_LOADING); >+ currentContentProvider.setContext(TestNavigatorContentProvider.CONTEXT_LOADING); > } else { >- currentProvider.setContext(TestNavigatorProvider.CONTEXT_INTERACTIVE); >+ currentContentProvider.setContext(TestNavigatorContentProvider.CONTEXT_INTERACTIVE); > } > } > } >@@ -563,20 +564,20 @@ > updateTestNavigatorProvider(treeViewer); > } > >- /** >- * @param treeViewer >- */ > private void updateTestNavigatorProvider(TreeViewer treeViewer) { >+ > if (currentViewIndex == VIEW_ID_RESOURCE) { >- currentProvider = new ResourceTestNavigatorProvider(this); >- } else { >- currentProvider = new LogicalTestNavigatorProvider(this); >+ currentContentProvider = new ResourceTestNavigatorContentProvider(this); >+ } >+ else { >+ currentContentProvider = new LogicalTestNavigatorContentProvider(this); > } >+ > adjustCurrentProviderContext(true); >- treeViewer.setContentProvider(currentProvider); >- ILabelDecorator decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); >- ILabelProvider labelProvider = new TestDecoratingLabelProvider(currentProvider, decorator, this); >- treeViewer.setLabelProvider(labelProvider); >+ >+ treeViewer.setContentProvider(currentContentProvider); >+ treeViewer.setLabelProvider(new TestDecoratingLabelProvider(new TestNavigatorLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), this)); >+ > adjustCurrentProviderContext(false); > } > >@@ -1081,12 +1082,12 @@ > * Invoked by test providers to notify that a node and its children should be refreshed. > */ > public void nodeChanged(Object node) { >- currentProvider.getProxyNodeListener().nodeChanged(node); >+ currentContentProvider.getProxyNodeListener().nodeChanged(node); > refresh(node); > } > > public void nodesChanged() { >- currentProvider.getProxyNodeListener().nodesChanged(); >+ currentContentProvider.getProxyNodeListener().nodesChanged(); > refresh(null); > } > >@@ -1141,7 +1142,7 @@ > switch (currentViewIndex) { > case VIEW_ID_LOGICAL: { > IProject project = file.getProject(); >- if (project != null)currentProvider.getChildren(project); >+ if (project != null)currentContentProvider.getChildren(project); > return proxyManager.getProxy(file, null); > } > case VIEW_ID_RESOURCE: { >Index: src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorProvider.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorProvider.java 6 Apr 2007 13:49:24 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,248 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation 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 >- * $Id: LogicalTestNavigatorProvider.java,v 1.11 2007/04/06 13:49:24 jgout Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.test.ui.internal.navigator; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.hyades.test.ui.TestUIExtension; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.IProxiesRequestListener; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.LogicalProjectProxiesRequest; >-import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.ProxiesRequest; >-import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >-import org.eclipse.hyades.test.ui.navigator.IProxyNode; >-import org.eclipse.hyades.ui.extension.IAssociationConstants; >-import org.eclipse.hyades.ui.extension.IAssociationDescriptor; >-import org.eclipse.hyades.ui.extension.IAssociationMapping; >-import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry; >-import org.eclipse.hyades.ui.util.IDisposable; >-import org.eclipse.swt.graphics.Image; >- >-/** This is the provider of the logical test navigator. >- * @author jgout >- * @since 4.0 >- */ >-public class LogicalTestNavigatorProvider extends TestNavigatorProvider { >- >- /** The file proxy manager to acces to proxies from files */ >- private static FileProxyManager fileProxyManager = new FileProxyManager(); >- >- private ProxiesRequests requests = new ProxiesRequests(); >- >- /** >- * @return Returns the fileProxyManager. >- */ >- public static IFileProxyManager getSharedFileProxyManager() { >- return fileProxyManager; >- } >- >- public LogicalTestNavigatorProvider(TestNavigator testNavigator) { >- super(testNavigator); >- } >- >- protected IFileProxyManager getFileProxyManager() { >- return fileProxyManager; >- } >- >- public boolean hasChildren(Object parentElement) { >- if (parentElement == null) >- return false; >- if(parentElement instanceof IProject) { >- return true; >- } >- return super.hasChildren(parentElement); >- } >- >- public Object[] getChildren(Object parentElement) { >- if(parentElement instanceof IProject) { >- IProject project = (IProject)parentElement; >- if (project.isAccessible()) { >- Collection types = getTypes(); >- Collection extensions = getExtensions(); >- ArrayList ret = new ArrayList(types.size() + extensions.size()); >- LogicalProjectProxiesRequest request = requests.getRequest(project, types, extensions); >- for (Iterator it = types.iterator(); it.hasNext();) { >- String type = (String) it.next(); >- IProxyNode proxy = request.getProxy(LogicalProjectProxiesRequest.TYPE_PROVIDER_PREFIX + type); >- if (proxy != null) { >- ret.add(proxy); >- } >- } >- for (Iterator it = extensions.iterator(); it.hasNext();) { >- String ext = (String) it.next(); >- IProxyNode proxy = request.getProxy(LogicalProjectProxiesRequest.TEST_ASSET_EXTENSION_PREFIX + ext); >- if (proxy != null) { >- ret.add(proxy); >- } >- } >- if (request.isPending()) { >- ret.add(0, new PendingProxy(project)); >- } >- return ret.toArray(); >- } >- return new Object[0]; >- } >- return super.getChildren(parentElement); >- } >- >- private Collection getTypes() { >- AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry(); >- IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS); >- String[] types = associationMapping.getTypes(); >- List typeProviders = new ArrayList(types.length); >- for (int i = 0; i < types.length; i++) { >- IAssociationDescriptor descriptor = associationMapping.getDefaultAssociationDescriptor(types[i]); >- if (descriptor != null) { >- typeProviders.add(types[i]); >- } >- } >- return typeProviders; >- } >- >- private Collection getExtensions() { >- return TestNavigator.getTestAssetGroupProxyManager().getExtensions(); >- } >- >- public IGlobalProxyNodeListener getProxyNodeListener() { >- return requests; >- } >- >- public void dispose() { >- requests.dispose(); >- super.dispose(); >- } >- >- class ProxiesRequests implements IProxiesRequestListener, IGlobalProxyNodeListener, IDisposable { >- >- private Map projectToRequestMap = new HashMap(); >- >- public LogicalProjectProxiesRequest getRequest(IProject project, Collection types, Collection extensions) { >- LogicalProjectProxiesRequest req = (LogicalProjectProxiesRequest)projectToRequestMap.get(project); >- if (req == null) { >- ArrayList requests = new ArrayList(types.size() + extensions.size()); >- for(Iterator it = types.iterator(); it.hasNext(); ) { >- requests.add(LogicalProjectProxiesRequest.TYPE_PROVIDER_PREFIX + (String)it.next()); >- } >- for(Iterator it = extensions.iterator(); it.hasNext(); ) { >- requests.add(LogicalProjectProxiesRequest.TEST_ASSET_EXTENSION_PREFIX + (String)it.next()); >- } >- req = new LogicalProjectProxiesRequest(requests, TestNavigator.getTypeProviderManager(), TestNavigator.getTestAssetGroupProxyManager(), project, testNavigator); >- req.setPriority(getJobPriority()); >- testNavigator.getJobPool().scheduleJob(req); >- if (!req.wait(getResponseTime(), this, 2000)) { >- projectToRequestMap.put(project, req); >- } >- } >- return req; >- } >- >- public void computationCompleted(ProxiesRequest request) { >- IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >- if (projectToRequestMap.containsKey(project)) { >- // A last refresh is necessary to remove the "Pending..." node. >- testNavigator.refresh(project); >- } >- } >- >- public void proxiesComputed(ProxiesRequest request) { >- IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >- testNavigator.refresh(project); >- } >- >- public void proxyComputed(ProxiesRequest request, Object key) { >- } >- >- public void nodeChanged(Object node) { >- if (node instanceof IProject) { >- LogicalProjectProxiesRequest req = (LogicalProjectProxiesRequest) projectToRequestMap.get(node); >- if (req != null) { >- // Then we need to cancel the current request. A new one will be spawned >- // when getChildren() is invoked on this project. >- if (req.cancel(1000)) { >- projectToRequestMap.remove(node); >- } >- } >- } >- } >- >- public void nodesChanged() { >- for (Iterator it = projectToRequestMap.keySet().iterator(); it.hasNext();) { >- nodeChanged(it.next()); >- } >- } >- >- public void computationCancelled(ProxiesRequest request) { >- IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >- projectToRequestMap.remove(project); >- testNavigator.refresh(project); >- } >- >- public void dispose() { >- // Cancel all running requests. Note that a LogicalProjectProxiesRequest may take >- // considerable time before it can honor the cancel request. So in general the >- // request may be still running for a long time after this instance has been >- // disposed. >- // If the user switches from the logical view to the resource view, and then back >- // to the logical view, this provider is disposed, and then another instance gets >- // created. As a result, two requests for the same project may be running: the old >- // one, which has been cancelled but has not stopped yet, and the new one. This >- // will look as if two jobs are doing the same thing at the same time. However what >- // really happens is that the new job is blocked on a wait until the old request >- // completes, and then the new job automatically leverages the computation performed >- // by the old one, so there is no CPU waste. The only drawback is that the new job >- // occupies a slot in the Test navigator job pool. >- for (Iterator it = projectToRequestMap.values().iterator(); it.hasNext();) { >- ProxiesRequest request = (ProxiesRequest) it.next(); >- request.dispose(); >- it.remove(); >- } >- } >- >- } >- >- private static class PendingProxy implements IProxyNode { >- public PendingProxy(Object parent) { >- this.parent = parent; >- } >- private Object parent; >- private static IProxyNode[] NO_CHILDREN = new IProxyNode[0]; >- public IProxyNode[] getChildren() { >- return NO_CHILDREN; >- } >- public Image getImage() { >- return null; >- } >- public Object getParent() { >- return parent; >- } >- public String getText() { >- return TestNavigatorMessages.NODE_PENDING; >- } >- public Object getAdapter(Class adapter) { >- return null; >- } >- public String getIdentifier() { >- return "~"; //$NON-NLS-1$ >- } >- public IResource getUnderlyingResource() { >- return null; >- } >- } >- >-} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java,v >retrieving revision 1.9 >diff -u -r1.9 CopyAction.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java 20 Mar 2008 19:49:54 -0000 1.9 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >@@ -26,7 +26,7 @@ > import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.IPath; > import org.eclipse.hyades.test.ui.UiPlugin; >-import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorProvider; >+import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorContentProvider; > import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; > import org.eclipse.hyades.test.ui.navigator.FileProxyNode; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >@@ -42,10 +42,15 @@ > import org.eclipse.swt.dnd.Transfer; > import org.eclipse.ui.part.ResourceTransfer; > >-/** >- * Copy Action for the Resource mode. >- * @author jgout,Jerome Bozier >- * @version February 26, 2008 >+/** >+ * <p>Copy action for the Resource view of the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Jerome Bozier >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since March 7, 2005 > */ > public class CopyAction extends Action implements IDisposable { > private Clipboard clipboard; >@@ -178,7 +183,7 @@ > * @return true if this proxy replaces a file > */ > private boolean isAFileProxy(IProxyNode proxy) { >- Object parent = ResourceTestNavigatorProvider.getSharedFileProxyManager().getParent(proxy); >+ Object parent = ResourceTestNavigatorContentProvider.getSharedFileProxyManager().getParent(proxy); > return proxy instanceof FileProxyNode || parent instanceof IContainer; > } > >@@ -258,7 +263,7 @@ > return res.getParent(); > } else if (sel instanceof IProxyNode) { > IProxyNode proxy = (IProxyNode) sel; >- return ResourceTestNavigatorProvider.getSharedFileProxyManager().getParent(proxy); >+ return ResourceTestNavigatorContentProvider.getSharedFileProxyManager().getParent(proxy); > } else { > return null; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java,v >retrieving revision 1.3 >diff -u -r1.3 FileProxyInContainerPaste.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java 20 Mar 2008 19:49:54 -0000 1.3 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,7 +13,7 @@ > > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IResource; >-import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorProvider; >+import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorContentProvider; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; > import org.eclipse.hyades.test.ui.navigator.FileProxyNode; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >@@ -25,14 +25,18 @@ > import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; > import org.eclipse.ui.part.ResourceTransfer; > >-/** >- * Paste action for the resource mode. >- * @author jgout,Jerome Bozier >- * @since 3.3 >- * @version February 26, 2008 >+/** >+ * <p>Paste action for the Resource view of the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Jerome Bozier >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since March 16, 2007 > * @deprecated > */ >-public class FileProxyInContainerPaste implements IPaster { >+ public class FileProxyInContainerPaste implements IPaster { > > private IResource [] getResourceFromClipboard(final Clipboard clipboard) { > final IResource[][] clipboardData = new IResource[1][]; >@@ -57,7 +61,7 @@ > IProxyNode proxy = clipContent[i]; > Object parent = proxy.getParent(); > if(parent instanceof FileProxyManager.IUnboundedParent) { >- parent = ResourceTestNavigatorProvider.getSharedFileProxyManager().getParent(proxy); >+ parent = ResourceTestNavigatorContentProvider.getSharedFileProxyManager().getParent(proxy); > } > if(!(proxy instanceof FileProxyNode) && !(parent instanceof IContainer)) { > return false; >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java,v >retrieving revision 1.6 >diff -u -r1.6 FileFolderInContainerPaste.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java 20 Mar 2008 19:49:54 -0000 1.6 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -21,7 +21,7 @@ > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.hyades.test.ui.UiPlugin; >-import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorProvider; >+import org.eclipse.hyades.test.ui.internal.navigator.ResourceTestNavigatorContentProvider; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.hyades.test.ui.navigator.actions.IPaster; >@@ -38,11 +38,15 @@ > import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; > import org.eclipse.ui.part.ResourceTransfer; > >-/** >- * Paste action for the resource mode. >- * @author jgout,Jerome Bozier >- * @since 3.3 >- * @version February 26, 2008 >+/** >+ * <p>Paste action for the Resource view of the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Jerome Bozier >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since March 7, 2005 > * @deprecated > */ > public class FileFolderInContainerPaste implements IPaster { >@@ -191,7 +195,7 @@ > oneCopied = true; > if (source instanceof IFile && conflict) { > IFile file = source.getWorkspace().getRoot().getFile(destinationPath); >- IProxyNode proxy = ResourceTestNavigatorProvider.getSharedFileProxyManager().getProxy(file, null); >+ IProxyNode proxy = ResourceTestNavigatorContentProvider.getSharedFileProxyManager().getProxy(file, null); > IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class); > if (renamer != null) { > //- use the renamer of this proxy node to rename properly >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestAssetGroupProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestAssetGroupProxyNode.java,v >retrieving revision 1.10 >diff -u -r1.10 TestAssetGroupProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestAssetGroupProxyNode.java 22 Mar 2007 14:42:09 -0000 1.10 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestAssetGroupProxyNode.java 19 May 2009 00:03:27 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >@@ -14,19 +14,22 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; > import org.eclipse.hyades.test.ui.UiPlugin; >-import org.eclipse.hyades.test.ui.internal.navigator.LogicalTestNavigatorProvider; >+import org.eclipse.hyades.test.ui.internal.navigator.LogicalTestNavigatorContentProvider; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.hyades.test.ui.navigator.ITestFolderContentValidator; > import org.eclipse.hyades.test.ui.navigator.TestFolderProxyNode; > import org.eclipse.swt.graphics.Image; > > /** >- * Generic test asset group proxy node. >- * This class is used by the test asset group manager >- * @author jgout >- * @since 4.0 >+ * <p>Generic test asset group proxy node.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since March 18, 2005 > */ >-public class TestAssetGroupProxyNode extends TestFolderProxyNode implements ITestAssetGroupProxyNode { >+ public class TestAssetGroupProxyNode extends TestFolderProxyNode implements ITestAssetGroupProxyNode { > > private String extension; > private String name; >@@ -53,7 +56,7 @@ > } > > public TestAssetGroupProxyNode(IProject project, String extension, String name, String imageKey, boolean flat, Object parent) { >- super(project, new TestAssetGroupValidator(extension), LogicalTestNavigatorProvider.getSharedFileProxyManager(), flat, parent); >+ super(project, new TestAssetGroupValidator(extension), LogicalTestNavigatorContentProvider.getSharedFileProxyManager(), flat, parent); > this.extension = extension; > this.name = name; > this.imageKey = imageKey; >Index: src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorContentProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorContentProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/LogicalTestNavigatorContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,252 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >+ * $Id: LogicalTestNavigatorProvider.java,v 1.11 2007/04/06 13:49:24 jgout Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.hyades.test.ui.TestUIExtension; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.IProxiesRequestListener; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.LogicalProjectProxiesRequest; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.ProxiesRequest; >+import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.ui.extension.IAssociationConstants; >+import org.eclipse.hyades.ui.extension.IAssociationDescriptor; >+import org.eclipse.hyades.ui.extension.IAssociationMapping; >+import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry; >+import org.eclipse.hyades.ui.util.IDisposable; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * <p>Content provider for the Logical view of the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since February 1, 2005 >+ */ >+public class LogicalTestNavigatorContentProvider extends TestNavigatorContentProvider { >+ >+ /** The file proxy manager to acces to proxies from files */ >+ private static FileProxyManager fileProxyManager = new FileProxyManager(); >+ >+ private ProxiesRequests requests = new ProxiesRequests(); >+ >+ /** >+ * @return Returns the fileProxyManager. >+ */ >+ public static IFileProxyManager getSharedFileProxyManager() { >+ return fileProxyManager; >+ } >+ >+ public LogicalTestNavigatorContentProvider(TestNavigator testNavigator) { >+ super(testNavigator); >+ } >+ >+ protected IFileProxyManager getFileProxyManager() { >+ return fileProxyManager; >+ } >+ >+ public boolean hasChildren(Object parentElement) { >+ if (parentElement == null) >+ return false; >+ if(parentElement instanceof IProject) { >+ return true; >+ } >+ return super.hasChildren(parentElement); >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ if(parentElement instanceof IProject) { >+ IProject project = (IProject)parentElement; >+ if (project.isAccessible()) { >+ Collection types = getTypes(); >+ Collection extensions = getExtensions(); >+ ArrayList ret = new ArrayList(types.size() + extensions.size()); >+ LogicalProjectProxiesRequest request = requests.getRequest(project, types, extensions); >+ for (Iterator it = types.iterator(); it.hasNext();) { >+ String type = (String) it.next(); >+ IProxyNode proxy = request.getProxy(LogicalProjectProxiesRequest.TYPE_PROVIDER_PREFIX + type); >+ if (proxy != null) { >+ ret.add(proxy); >+ } >+ } >+ for (Iterator it = extensions.iterator(); it.hasNext();) { >+ String ext = (String) it.next(); >+ IProxyNode proxy = request.getProxy(LogicalProjectProxiesRequest.TEST_ASSET_EXTENSION_PREFIX + ext); >+ if (proxy != null) { >+ ret.add(proxy); >+ } >+ } >+ if (request.isPending()) { >+ ret.add(0, new PendingProxy(project)); >+ } >+ return ret.toArray(); >+ } >+ return new Object[0]; >+ } >+ return super.getChildren(parentElement); >+ } >+ >+ private Collection getTypes() { >+ AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry(); >+ IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS); >+ String[] types = associationMapping.getTypes(); >+ List typeProviders = new ArrayList(types.length); >+ for (int i = 0; i < types.length; i++) { >+ IAssociationDescriptor descriptor = associationMapping.getDefaultAssociationDescriptor(types[i]); >+ if (descriptor != null) { >+ typeProviders.add(types[i]); >+ } >+ } >+ return typeProviders; >+ } >+ >+ private Collection getExtensions() { >+ return TestNavigator.getTestAssetGroupProxyManager().getExtensions(); >+ } >+ >+ public IGlobalProxyNodeListener getProxyNodeListener() { >+ return requests; >+ } >+ >+ public void dispose() { >+ requests.dispose(); >+ } >+ >+ class ProxiesRequests implements IProxiesRequestListener, IGlobalProxyNodeListener, IDisposable { >+ >+ private Map projectToRequestMap = new HashMap(); >+ >+ public LogicalProjectProxiesRequest getRequest(IProject project, Collection types, Collection extensions) { >+ LogicalProjectProxiesRequest req = (LogicalProjectProxiesRequest)projectToRequestMap.get(project); >+ if (req == null) { >+ ArrayList requests = new ArrayList(types.size() + extensions.size()); >+ for(Iterator it = types.iterator(); it.hasNext(); ) { >+ requests.add(LogicalProjectProxiesRequest.TYPE_PROVIDER_PREFIX + (String)it.next()); >+ } >+ for(Iterator it = extensions.iterator(); it.hasNext(); ) { >+ requests.add(LogicalProjectProxiesRequest.TEST_ASSET_EXTENSION_PREFIX + (String)it.next()); >+ } >+ req = new LogicalProjectProxiesRequest(requests, TestNavigator.getTypeProviderManager(), TestNavigator.getTestAssetGroupProxyManager(), project, testNavigator); >+ req.setPriority(getJobPriority()); >+ testNavigator.getJobPool().scheduleJob(req); >+ if (!req.wait(getResponseTime(), this, 2000)) { >+ projectToRequestMap.put(project, req); >+ } >+ } >+ return req; >+ } >+ >+ public void computationCompleted(ProxiesRequest request) { >+ IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >+ if (projectToRequestMap.containsKey(project)) { >+ // A last refresh is necessary to remove the "Pending..." node. >+ testNavigator.refresh(project); >+ } >+ } >+ >+ public void proxiesComputed(ProxiesRequest request) { >+ IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >+ testNavigator.refresh(project); >+ } >+ >+ public void proxyComputed(ProxiesRequest request, Object key) { >+ } >+ >+ public void nodeChanged(Object node) { >+ if (node instanceof IProject) { >+ LogicalProjectProxiesRequest req = (LogicalProjectProxiesRequest) projectToRequestMap.get(node); >+ if (req != null) { >+ // Then we need to cancel the current request. A new one will be spawned >+ // when getChildren() is invoked on this project. >+ if (req.cancel(1000)) { >+ projectToRequestMap.remove(node); >+ } >+ } >+ } >+ } >+ >+ public void nodesChanged() { >+ for (Iterator it = projectToRequestMap.keySet().iterator(); it.hasNext();) { >+ nodeChanged(it.next()); >+ } >+ } >+ >+ public void computationCancelled(ProxiesRequest request) { >+ IProject project = ((LogicalProjectProxiesRequest)request).getProject(); >+ projectToRequestMap.remove(project); >+ testNavigator.refresh(project); >+ } >+ >+ public void dispose() { >+ // Cancel all running requests. Note that a LogicalProjectProxiesRequest may take >+ // considerable time before it can honor the cancel request. So in general the >+ // request may be still running for a long time after this instance has been >+ // disposed. >+ // If the user switches from the logical view to the resource view, and then back >+ // to the logical view, this provider is disposed, and then another instance gets >+ // created. As a result, two requests for the same project may be running: the old >+ // one, which has been cancelled but has not stopped yet, and the new one. This >+ // will look as if two jobs are doing the same thing at the same time. However what >+ // really happens is that the new job is blocked on a wait until the old request >+ // completes, and then the new job automatically leverages the computation performed >+ // by the old one, so there is no CPU waste. The only drawback is that the new job >+ // occupies a slot in the Test navigator job pool. >+ for (Iterator it = projectToRequestMap.values().iterator(); it.hasNext();) { >+ ProxiesRequest request = (ProxiesRequest) it.next(); >+ request.dispose(); >+ it.remove(); >+ } >+ } >+ >+ } >+ >+ private static class PendingProxy implements IProxyNode { >+ public PendingProxy(Object parent) { >+ this.parent = parent; >+ } >+ private Object parent; >+ private static IProxyNode[] NO_CHILDREN = new IProxyNode[0]; >+ public IProxyNode[] getChildren() { >+ return NO_CHILDREN; >+ } >+ public Image getImage() { >+ return null; >+ } >+ public Object getParent() { >+ return parent; >+ } >+ public String getText() { >+ return TestNavigatorMessages.NODE_PENDING; >+ } >+ public Object getAdapter(Class adapter) { >+ return null; >+ } >+ public String getIdentifier() { >+ return "~"; //$NON-NLS-1$ >+ } >+ public IResource getUnderlyingResource() { >+ return null; >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorContentProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorContentProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/ResourceTestNavigatorContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,243 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >+ * $Id: ResourceTestNavigatorProvider.java,v 1.10 2007/04/06 13:49:24 jgout Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.FileProxiesRequest; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.IProxiesRequestListener; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.ProxiesRequest; >+import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.ui.util.IDisposable; >+ >+/** >+ * <p>Content provider for the Resource view of the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Paul Slauenwhite >+ * @version May 18, 2009 >+ * @since February 1, 2005 >+ */ >+public class ResourceTestNavigatorContentProvider extends TestNavigatorContentProvider { >+ >+ /** The file proxy manager to acces to proxies from files */ >+ private static FileProxyManager fileProxyManager = new FileProxyManager(); >+ >+ /** >+ * @return Returns the fileProxyManager. >+ */ >+ public static FileProxyManager getSharedFileProxyManager() { >+ return fileProxyManager; >+ } >+ >+ public ResourceTestNavigatorContentProvider(TestNavigator testNavigator) { >+ super(testNavigator); >+ } >+ >+ private FileProxyRequests requests = new FileProxyRequests(); >+ >+ protected IFileProxyManager getFileProxyManager() { >+ return fileProxyManager; >+ } >+ >+ public Object getParent(Object element) { >+ if (element instanceof IResource) { >+ return ((IResource) element).getParent(); >+ } >+ return super.getParent(element); >+ } >+ >+ public boolean hasChildren(Object parentElement) { >+ if (parentElement == null) >+ return false; >+ if (parentElement instanceof IContainer) { >+ IContainer container = (IContainer) parentElement; >+ if (!container.isAccessible()) >+ return false; >+ >+ IResource[] resources = null; >+ try { >+ resources = container.members(); >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ return false; >+ } >+ if (resources.length == 0) return false; >+ if (parentElement instanceof IProject) { >+ return true; >+ } >+ for (int i = 0; i < resources.length; i++) { >+ if (resources[i].getType() != IResource.FILE) { >+ if (!TestNavigator.getFiltersManager().filter(resources[i])) >+ return true; >+ } else { >+ String fileExtension = resources[i].getFileExtension(); >+ if (fileExtension != null) { >+ if (TestNavigator.getFiltersManager().isVisibleResource(resources[i])) return true; >+ } >+ } >+ } >+ return false; >+ } >+ return super.hasChildren(parentElement); >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof IContainer) { >+ return getContainerChildren(parentElement); >+ } else { >+ return super.getChildren(parentElement); >+ } >+ } >+ >+ /** returns the children of a container node (project or folder) >+ * @param parentElement >+ * @return an array of Object which cn be empty but not null >+ */ >+ private Object[] getContainerChildren(Object parentElement) { >+ IResource[] resources = null; >+ IContainer container = ((IContainer) parentElement); >+ if (container.isAccessible()) { >+ try { >+ resources = container.members(); >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ return new Object[0]; >+ } >+ List children = new ArrayList(resources.length); >+ FileProxiesRequest request = requests.getRequest(container, resources); >+ for (int i = 0, maxi = resources.length; i < maxi; i++) { >+ if (!TestNavigator.getFiltersManager().filter(resources[i])) { >+ if (resources[i].getType() != IResource.FILE) { >+ children.add(resources[i]); >+ } else { >+ //- convert the file in something else (proxy) >+ IFile file = (IFile)resources[i]; >+ IProxyNode node = request.getProxy(file); >+ if (!TestNavigator.getFiltersManager().filter(node)) { >+ children.add(node); >+ fileProxyManager.cacheProxy(file, node); >+ } >+ } >+ } >+ } >+ return children.toArray(); >+ } >+ return new Object[0]; >+ } >+ >+ public IGlobalProxyNodeListener getProxyNodeListener() { >+ return requests; >+ } >+ >+ private class FileProxyRequests implements IProxiesRequestListener, IDisposable, IGlobalProxyNodeListener { >+ >+ private Map containerToRequestMap = Collections.synchronizedMap(new HashMap()); >+ >+ public FileProxiesRequest getRequest(IContainer container, IResource[] members) { >+ FileProxiesRequest request = (FileProxiesRequest)containerToRequestMap.get(container); >+ if (request == null) { >+ request = newRequest(container, members); >+ } >+ return request; >+ } >+ >+ public FileProxiesRequest newRequest(IContainer container, IResource[] members) { >+ ArrayList filesToRequest = new ArrayList(members.length); >+ for (int i = 0, maxi = members.length; i < maxi; i++) { >+ if (members[i].getType() == IResource.FILE) { >+ if (!TestNavigator.getFiltersManager().filter(members[i])) { >+ filesToRequest.add(members[i]); >+ } >+ } >+ } >+ if (filesToRequest.isEmpty()) return null; >+ FileProxiesRequest req = new FileProxiesRequest(filesToRequest, fileProxyManager, container, testNavigator); >+ req.setPriority(getJobPriority()); >+ testNavigator.getJobPool().scheduleJob(req); >+ if (!req.wait(getResponseTime(), this, 2000)) { >+ containerToRequestMap.put(container, req); >+ } >+ return req; >+ } >+ >+ public void proxyComputed(final ProxiesRequest request, Object key) { >+ } >+ >+ public void computationCompleted(ProxiesRequest request) { >+ IContainer parent = ((FileProxiesRequest)request).getParent(); >+ if (containerToRequestMap.containsKey(parent)) { >+ testNavigator.refresh(parent); >+ } >+ } >+ >+ public void dispose() { >+ // Cancel all running requests. As the atomic action of FileProxiesRequest is >+ // the computation of a single file proxy, all requests should honor the cancel >+ // request quite quickly. However we don't wait them to complete (i.e. they may >+ // be still running while this instance has been disposed). >+ for (Iterator it = containerToRequestMap.values().iterator(); it.hasNext();) { >+ FileProxiesRequest request = (FileProxiesRequest) it.next(); >+ request.dispose(); >+ it.remove(); >+ } >+ } >+ >+ public void proxiesComputed(ProxiesRequest request) { >+ testNavigator.refresh(((FileProxiesRequest)request).getParent()); >+ } >+ >+ public void nodeChanged(Object node) { >+ if (node instanceof IContainer) { >+ FileProxiesRequest req = (FileProxiesRequest) containerToRequestMap.remove(node); >+ if (req != null) { >+ // Then we need to cancel the current request. A new one will be spawned >+ // when getChildren() is invoked on this project. >+ if (req.cancel(1000)) { >+ containerToRequestMap.remove(node); >+ } >+ } >+ } >+ } >+ >+ public void nodesChanged() { >+ for (Iterator it = containerToRequestMap.keySet().iterator(); it.hasNext();) { >+ nodeChanged(it.next()); >+ } >+ } >+ >+ public void computationCancelled(ProxiesRequest request) { >+ IContainer parent = ((FileProxiesRequest)request).getParent(); >+ containerToRequestMap.remove(parent); >+ testNavigator.refresh(parent); >+ } >+ >+ } >+ >+ public void dispose() { >+ requests.dispose(); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorContentProvider.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorContentProvider.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,254 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 IBM Corporation 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 >+ * $Id: TestNavigatorProvider.java,v 1.13 2009/02/12 19:19:00 paules Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator; >+ >+import java.util.LinkedList; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager; >+import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNodeListener; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * <p>Content provider for the Test Navigator.</p> >+ * >+ * >+ * @author Jerome Gout >+ * @author Julien Canches >+ * @author Paul E. Slauenwhite >+ * @version May 18, 2009 >+ * @since March 18, 2005 >+ */ >+public abstract class TestNavigatorContentProvider implements ITreeContentProvider { >+ >+ private static final int MAX_PROXY_NODE_CHILDREN = 100; >+ public static final int CONTEXT_LOADING = 0; >+ public static final int CONTEXT_INTERACTIVE = 1; >+ >+ protected TestNavigator testNavigator; >+ private int context; >+ >+ public TestNavigatorContentProvider(TestNavigator testNavigator) { >+ this.testNavigator = testNavigator; >+ this.context = CONTEXT_LOADING; >+ } >+ >+ protected abstract IGlobalProxyNodeListener getProxyNodeListener(); >+ >+ protected abstract IFileProxyManager getFileProxyManager(); >+ >+ public Object getParent(Object element) { >+ if (element instanceof IProxyNode) { >+ Object parent = ((IProxyNode) element).getParent(); >+ if(parent instanceof FileProxyManager.IUnboundedParent) { >+ return getFileProxyManager().getParent((IProxyNode) element); >+ } else { >+ return parent; >+ } >+ } >+ return null; >+ } >+ >+ public boolean hasChildren(Object parentElement) { >+ if (parentElement instanceof IProxyNode) { >+ IProxyNode proxy = (IProxyNode) parentElement; >+ return proxy.getChildren().length > 0; >+ } >+ if (parentElement instanceof IProxyGroup) { >+ return true; >+ } >+ return false; >+ } >+ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof IProxyNode) { >+ IProxyNode proxy = (IProxyNode) parentElement; >+ return foldProxyNodes(proxy); >+ } >+ if (parentElement instanceof IProxyGroup) { >+ return ((IProxyGroup)parentElement).getChildren(); >+ } >+ return new Object[0]; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof IWorkspaceRoot) { >+ IProject [] projects = ((IWorkspaceRoot) inputElement).getProjects(); >+ LinkedList visibleProjects = new LinkedList(); >+ for(int i = 0; i < projects.length; i++) { >+ if(!TestNavigator.getFiltersManager().filter(projects[i])) { >+ visibleProjects.add(projects[i]); >+ } >+ } >+ return visibleProjects.toArray(); >+ } >+ return getChildren(inputElement); >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public static interface IGlobalProxyNodeListener extends IProxyNodeListener { >+ >+ void nodesChanged(); >+ >+ } >+ >+ public static interface IProxyGroup extends IProxyNode{ >+ int getOrder(); >+ } >+ >+ private static class ProxyGroup implements IProxyGroup { >+ private IProxyNode parent; >+ private int sequence; >+ public ProxyGroup(IProxyNode node, int sequence) { >+ this.parent = node; >+ this.sequence = sequence; >+ } >+ public IProxyNode[] getChildren() { >+ int start = sequence * MAX_PROXY_NODE_CHILDREN; >+ IProxyNode[] completeChildren = parent.getChildren(); >+ IProxyNode[] children = new IProxyNode[MAX_PROXY_NODE_CHILDREN]; >+ System.arraycopy(completeChildren, start, children, 0, MAX_PROXY_NODE_CHILDREN); >+ return children; >+ } >+ public String getText() { >+ int start = sequence * MAX_PROXY_NODE_CHILDREN + 1; >+ int end = (sequence + 1) * MAX_PROXY_NODE_CHILDREN; >+ return ("[".concat(Integer.toString(start)).concat(" - ").concat(Integer.toString(end)).concat("]")); >+ } >+ public Image getImage() { >+ return parent.getImage(); >+ } >+ public int getOrder() { >+ return sequence; >+ } >+ public Object getParent() { >+ return parent; >+ } >+ public Object getAdapter(Class adapter) { >+ return null; >+ } >+ public String getIdentifier() { >+ return null; >+ } >+ public IResource getUnderlyingResource() { >+ return null; >+ } >+ } >+ >+ private static class RemainingProxyGroup implements IProxyGroup { >+ private IProxyNode parent; >+ public RemainingProxyGroup(IProxyNode parent) { >+ this.parent = parent; >+ } >+ public IProxyNode[] getChildren() { >+ IProxyNode[] completeChildren = parent.getChildren(); >+ int completeLength = completeChildren.length; >+ int length = completeLength % MAX_PROXY_NODE_CHILDREN; >+ IProxyNode[] children = new IProxyNode[length]; >+ System.arraycopy(completeChildren, completeLength - length, children, 0, length); >+ return children; >+ } >+ public String getText() { >+ IProxyNode[] completeChildren = parent.getChildren(); >+ int end = completeChildren.length; >+ int length = end % MAX_PROXY_NODE_CHILDREN; >+ int start = end - length + 1; >+ return ("[".concat(Integer.toString(start)).concat(" - ").concat(Integer.toString(end)).concat("]")); >+ } >+ public Image getImage() { >+ return parent.getImage(); >+ } >+ public int getOrder() { >+ return Integer.MAX_VALUE; >+ } >+ public Object getParent() { >+ return parent; >+ } >+ public Object getAdapter(Class adapter) { >+ return null; >+ } >+ public String getIdentifier() { >+ return null; >+ } >+ public IResource getUnderlyingResource() { >+ return null; >+ } >+ } >+ >+ protected Object[] foldProxyNodes(IProxyNode parent) { >+ IProxyNode[] children = parent.getChildren(); >+ int length = children.length; >+ if (length <= MAX_PROXY_NODE_CHILDREN) return children; >+ int size = length / MAX_PROXY_NODE_CHILDREN; >+ int remaining = length % MAX_PROXY_NODE_CHILDREN; >+ int totalSize = size + (remaining > 0 ? 1 : 0); >+ Object[] groups = new IProxyGroup[totalSize]; >+ for (int i = 0; i < size; i++) { >+ groups[i] = new ProxyGroup(parent, i); >+ } >+ if (remaining > 0) { >+ groups[size] = new RemainingProxyGroup(parent); >+ } >+ return groups; >+ } >+ >+ /** >+ * Sets the context in which the provider is used. There are two available values: >+ * INTERACTIVE and LOADING. The context has an effect on two parameters: >+ * 1) responsiveness: time that getChildren() is allowed to spent before returning >+ * control. High responsiveness means that the provider will return incomplete nodes, >+ * compute the remaining in a background task, and update the navigator when computation >+ * is complete. Low responsiveness means that the UI will be blocked for a longer period of >+ * time but the returned node are more likely to be complete. >+ * 2) computation job priority: the priority allocated to the computation job, if the provider >+ * does not manage to compute nodes in the allocated time (responsiveness parameter). This does >+ * not affect the thread priority, but helps eclipse decide which job should be launched first. >+ * In LOADING mode, responsiveness is high (100ms) and priority is low (NORMAL). >+ * In INTERACTIVE mode, responsiveness is lower (800ms) and priority is high (INTERACTIVE). >+ */ >+ public void setContext(int context) { >+ this.context = context; >+ } >+ >+ protected int getContext() { >+ return context; >+ } >+ >+ protected int getResponseTime() { >+ switch (context) { >+ case CONTEXT_INTERACTIVE: >+ return 800; >+ case CONTEXT_LOADING: >+ return 100; >+ } >+ return 100; >+ } >+ >+ protected int getJobPriority() { >+ switch(context) { >+ case CONTEXT_INTERACTIVE: >+ return Job.INTERACTIVE; >+ case CONTEXT_LOADING: >+ return Job.LONG; >+ } >+ return Job.LONG; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 164483
:
136242