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 92444 Details for
Bug 166025
Move, Copy, Delete, Rename and Import/Export test assets.
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 V10
166025_V10_patch.txt (text/plain), 419.50 KB, created by
Bozier jerome
on 2008-03-13 10:54:51 EDT
(
hide
)
Description:
patch V10
Filename:
MIME Type:
Creator:
Bozier jerome
Created:
2008-03-13 10:54:51 EDT
Size:
419.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.core >Index: src/org/eclipse/hyades/test/core/launch/configurations/AbstractLaunchConfigurationFacade.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.core/src/org/eclipse/hyades/test/core/launch/configurations/AbstractLaunchConfigurationFacade.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractLaunchConfigurationFacade.java >--- src/org/eclipse/hyades/test/core/launch/configurations/AbstractLaunchConfigurationFacade.java 22 Dec 2005 16:20:04 -0000 1.7 >+++ src/org/eclipse/hyades/test/core/launch/configurations/AbstractLaunchConfigurationFacade.java 13 Mar 2008 14:45:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -72,7 +72,7 @@ > } else { > if (eObject.eResource() == null) { > throw new IllegalArgumentException( >- "eObject must belong to a resource"); >+ "eObject must belong to a resource"); //$NON-NLS-1$ > } > uri = eObject.eResource().getURI().toString(); > uriFragment = eObject.eResource().getURIFragment(eObject); >@@ -153,7 +153,7 @@ > Resource resource = eObject.eResource(); > if (resource == null) { > throw new NullPointerException( >- "Resource object must be non-null"); >+ "Resource object must be non-null"); //$NON-NLS-1$ > } > uriList.add(eObject.eResource().getURI().toString()); > uriFragmentList.add(eObject.eResource().getURIFragment( >@@ -279,5 +279,37 @@ > } > configuration.setAttribute(property, container); > } >+ >+ /** >+ * Returns whether the given property in a launch configuration is an EMF reference >+ * to an object with the same URI as the given URI. >+ * @param configuration >+ * @param property Name of the property. >+ * @param uri The URI to compare to. null is not allowed. >+ * @return <code>true</code> if the launch configuration has a property with this name, >+ * and if it is an EMF reference to an object with the same URI as <code>uri</code>. >+ * @throws CoreException >+ */ >+ protected static boolean isSameURI(ILaunchConfiguration configuration, String property, URI uri) throws CoreException { >+ String uriString = configuration.getAttribute(property >+ + PROPERTY_SUFFIX_URI, (String) null); >+ String uriFragment = configuration.getAttribute(property >+ + PROPERTY_SUFFIX_FRAGMENT, (String) null); >+ return uri.trimFragment().toString().equals(uriString) >+ && uri.fragment().equals(uriFragment); >+ } >+ >+ /** >+ * Updates an EMF reference property within a launch configuration by changing its URI. >+ * This API is provided for refactor use cases when the URI of a referenced EMF object >+ * needs to be updated. >+ * @param configuration >+ * @param property Name of the property. >+ * @param newURI The new URI. >+ */ >+ protected static void updateURI(ILaunchConfigurationWorkingCopy configuration, String property, URI newURI) { >+ configuration.setAttribute(property + PROPERTY_SUFFIX_URI, newURI.trimFragment().toString()); >+ configuration.setAttribute(property + PROPERTY_SUFFIX_FRAGMENT, newURI.fragment()); >+ } > > } >Index: src/org/eclipse/hyades/test/core/launch/configurations/TestLaunchConfigurationFacade.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.core/src/org/eclipse/hyades/test/core/launch/configurations/TestLaunchConfigurationFacade.java,v >retrieving revision 1.10 >diff -u -r1.10 TestLaunchConfigurationFacade.java >--- src/org/eclipse/hyades/test/core/launch/configurations/TestLaunchConfigurationFacade.java 3 May 2007 02:23:44 -0000 1.10 >+++ src/org/eclipse/hyades/test/core/launch/configurations/TestLaunchConfigurationFacade.java 13 Mar 2008 14:45:31 -0000 >@@ -1,10 +1,10 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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: TestLaunchConfigurationFacade.java,v 1.10 2007/05/03 02:23:44 paules Exp $ >+ * $Id: TestLaunchConfigurationFacade.java,v 1.7 2006/05/19 15:44:10 mddunn Exp $ > * > * Contributors: > * IBM Corporation - initial API and implementation >@@ -16,6 +16,7 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationType; > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.resource.ResourceSet; > import org.eclipse.hyades.models.common.testprofile.TPFTest; >@@ -100,7 +101,7 @@ > /** > * Validates a Test launch configuration. > * The validation is performed by the validator registered in the extension registry >- * using the extension point <code>org.eclipse.hyades.test.core.launchconfigValidator</code>. >+ * using the extension point <code>org.eclipse.hyades.test.core.launchConfigValidator</code>. > * @param configuration A launch configuration. > * @param resourceSet The resource set that should be used for loading EMF objects, > * if required. >@@ -135,4 +136,28 @@ > return createOKDiagnostic(); > } > >+ /** >+ * Returns whether a test launch configuration references a test that has a given URI. >+ * @param configuration A test launch configuration. >+ * @param uri A URI to compare to. >+ * @return <code>true</code> if the test launch configuration references a test with the >+ * same URI as <code>uri</code>. >+ * @throws CoreException >+ */ >+ public static boolean isTestURI(ILaunchConfiguration configuration, URI uri) throws CoreException { >+ return isSameURI(configuration, PROPERTY_TEST, uri); >+ } >+ >+ /** >+ * Updates a test launch configuration by changing its test URI. >+ * This API is provided for refactor use cases when a test URI is changed. If the >+ * launch configuration's test must be changed, use {@link #setTest(ILaunchConfigurationWorkingCopy, TPFTest)} >+ * instead. >+ * @param configuration A test launch configuration. >+ * @param newURI The new URI of the test. >+ * @throws CoreException >+ */ >+ public static void updateTestURI(ILaunchConfigurationWorkingCopy configuration, URI newURI) throws CoreException { >+ updateURI(configuration, PROPERTY_TEST, newURI); >+ } > } >#P org.eclipse.hyades.test.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.25 >diff -u -r1.25 MANIFEST.MF >--- META-INF/MANIFEST.MF 11 Mar 2008 18:13:15 -0000 1.25 >+++ META-INF/MANIFEST.MF 13 Mar 2008 14:45:34 -0000 >@@ -81,13 +81,22 @@ > org.eclipse.ui.workbench.texteditor;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)", > org.eclipse.xsd;bundle-version="[2.2.0,3.0.0)", >+ org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)";resolution:=optional, > org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional, > org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)";resolution:=optional, >+ org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional, > org.eclipse.tptp.platform.models;bundle-version="[4.2.0,5.0.0)", > org.eclipse.hyades.test.core;bundle-version="[4.2.0,5.0.0)", > org.eclipse.hyades.trace.ui;bundle-version="[4.2.0,5.0.0)";resolution:=optional, > org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.help.ui;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.ui.cheatsheets;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.pde.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional, > org.eclipse.search;bundle-version="[3.2.0,4.0.0)", >- org.eclipse.birt.chart.engine;bundle-version="[2.1.0,3.0.0)";resolution:=optional >+ org.eclipse.birt.chart.engine;bundle-version="[2.1.0,3.0.0)";resolution:=optional, >+ org.eclipse.birt.core;bundle-version="[2.1.0,3.0.0)";resolution:=optional, >+ org.eclipse.ui.browser;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)", >+ org.eclipse.ltk.ui.refactoring;bundle-version="[3.2.0,4.0.0)" > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: src/org/eclipse/hyades/test/ui/navigator/IFileProxyFactory.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/IFileProxyFactory.java,v >retrieving revision 1.4 >diff -u -r1.4 IFileProxyFactory.java >--- src/org/eclipse/hyades/test/ui/navigator/IFileProxyFactory.java 9 Jun 2005 09:34:10 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/navigator/IFileProxyFactory.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -17,6 +17,7 @@ > * Implementation of this interface should be used in the following extension point: > * <p><code>org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory</code></p> > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public interface IFileProxyFactory { >@@ -25,6 +26,8 @@ > * @param file the file to convert in proxy. > * @param parent an existing object (proxy node or not) which is the parent of the file proxy node in the proxy node hierarchy. > * @return a proxy which is used in the test navigator instead of the file itself. >+ * The returned node must meet the following condition: >+ * <code>file.equals(factory.create(file, parent).getAdapter(IFile.class))</code> > */ > public IProxyNode create(IFile file, Object parent); > >Index: src/org/eclipse/hyades/test/ui/navigator/FileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/FileProxyNode.java,v >retrieving revision 1.9 >diff -u -r1.9 FileProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/FileProxyNode.java 1 Jun 2007 14:52:01 -0000 1.9 >+++ src/org/eclipse/hyades/test/ui/navigator/FileProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -41,10 +41,11 @@ > * This class is dedicated to wrap physical file into proxy > * > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ >-public abstract class FileProxyNode implements IProxyNodeRenamer, IExtendedProxyNode { >- >+public abstract class FileProxyNode extends AbstractProxy implements IProxyNodeRenamer, IExtendedProxyNode { >+ > private IFile file; > > /** >Index: src/org/eclipse/hyades/test/ui/navigator/IFileProxyManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/IFileProxyManager.java,v >retrieving revision 1.4 >diff -u -r1.4 IFileProxyManager.java >--- src/org/eclipse/hyades/test/ui/navigator/IFileProxyManager.java 30 Jan 2006 09:19:55 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/navigator/IFileProxyManager.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -17,6 +17,7 @@ > * This interface is not intended to be implemented by client. > * > * @author jgout >+ * @version February 26, 2008 > * @since 4.0 > */ > public interface IFileProxyManager { >@@ -72,6 +73,7 @@ > * @param fileName name of the underlying resource of the searched proxy > * @param identifier identifier of the searched proxy > * @return a proxy node or <code>null</code> if not found. >+ * @deprecated use {@link #getCorrespondingProxy(new Proxy(fileName, String))} instead. > */ > public IProxyNode getCorrespondingProxy(String fileName, String identifier); > >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.5 >diff -u -r1.5 ProxyNodeTransfer.java >--- src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java 22 Mar 2007 14:42:13 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -24,6 +24,7 @@ > * Transfer class used by Copy/Paste actions of proxy nodes, in resource mode. > * > * @author jgout >+ * @version February 26, 2008 > * @since 3.3 > */ > public class ProxyNodeTransfer extends ByteArrayTransfer { >@@ -67,7 +68,7 @@ > String identifier = dataIn.readUTF(); > return ResourceTestNavigatorProvider.getSharedFileProxyManager().getCorrespondingProxy(fileName, identifier); > } >- >+ > /** > * @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData) > */ >Index: src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java,v >retrieving revision 1.11 >diff -u -r1.11 EObjectProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java 4 Jun 2007 13:58:47 -0000 1.11 >+++ src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -11,8 +11,14 @@ > *******************************************************************************/ > package org.eclipse.hyades.test.ui.navigator; > >+import java.util.Collection; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.emf.common.util.URI; >@@ -23,27 +29,45 @@ > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.IExtendedProxyNode; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager.IUnboundedParent; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceRegistry; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteModelElementChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.ModelPathChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveModelChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteModelChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.UpdateModelChange; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodePaster; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; > import org.eclipse.ui.IMemento; > > /** EMF object proxy element for the test navigator. > * Subclasses should provide IProxyNode methods implementation. > * EMF objects wrapped by subclasses will be stored in the test navigator resource set > * @author jgout >+ * @version February 26, 2008 > */ >-public abstract class EObjectProxyNode implements IPersistableProxyNode, IExtendedProxyNode { >+public abstract class EObjectProxyNode extends AbstractProxy implements IPersistableProxyNode, IExtendedProxyNode, >+ IReferencerProxyNode, IProxyNodeMover, IProxyNodeUpdater, IProxyNodeDeleter,IProxyNodePaster { > > private static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$ >- >+ > private URI originatorURI; > private Object parent; >+ private static final String VERSION = "4.3"; //$NON-NLS-1$ >+ private static final String TAG_STATE_VERSION = "stateVersion"; //$NON-NLS-1$ > >- /** >+ /** > * Constructor used to load a persisted proxy. > * @param memento the memento containing the saved state of the proxy. > * @param parent the parent node of the proxy node. > */ > public EObjectProxyNode(IMemento memento, Object parent) { > String uriFragmentName; >+ checkVersion(VERSION, memento); > //- backward compatibility of the existing persisted proxy node states > String uri = memento.getString(TestUIConstants.TAG_URI); > if(uri != null) { >@@ -53,10 +77,10 @@ > } else { > uriFragmentName = memento.getString(TAG_URI_FRAGMENT); > } >- //- this data is not persisted but added by the proxy node loader (FileProxyManager#buildProxy) >+ //- this data is not persisted but added by the proxy node loader (FileProxyNodeCache#buildProxyFromSavedState) > String uriRootName = memento.getString(TestUIConstants.TAG_URI_ROOT); > try { >- URI uriRoot = URI.createPlatformResourceURI(uriRootName); >+ URI uriRoot = URI.createPlatformResourceURI(uriRootName,false); > this.originatorURI = uriRoot.appendFragment(uriFragmentName); > } catch (IllegalArgumentException e) { > throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve uri field"); //$NON-NLS-1$ } >@@ -64,6 +88,13 @@ > this.parent = parent; > } > >+ protected void checkVersion(String version, IMemento memento) { >+ String savedVersion = memento.getString(TAG_STATE_VERSION); >+ if(savedVersion == null || !VERSION.equals(savedVersion)) { >+ throw new ProxyNeedToBeRebuiltException(); >+ } >+ } >+ > /** > * Creates a proxy node from a emf object. > * CAUTION: this object should be stored in a EMF resource in order to get its URI >@@ -101,7 +132,7 @@ > > /** > * Identifier for an EMF object is its URI fragment part. >- * If there is no fragment identifier is empty, this means that the object is a root object. >+ * If there is the fragment identifier is empty, this means that the object is a root object. > * @return the identifier of the proxy node. > */ > public String getIdentifier() { >@@ -144,17 +175,48 @@ > * @retrun an adapted object for the given class using the global plateform adapter manager. > */ > public Object getAdapter(Class adapter) { >- return Platform.getAdapterManager().getAdapter(this, adapter); >+ //- this proxy is adaptable in IFile if it has been placed instead of a file >+ if(adapter.isAssignableFrom(IFile.class) && getParent() instanceof IUnboundedParent) { >+ return getUnderlyingResource(); >+ } else if(adapter == IProxyNodeUpdater.class >+ || adapter == IProxyNodeMover.class >+ || adapter == IProxyNodeDeleter.class >+ || adapter == IProxyNodePaster.class) { >+ return this; >+ } else { >+ return Platform.getAdapterManager().getAdapter(this, adapter); >+ } > } > >- /** >- * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#getFactoryID() >- * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >- */ >- public String getFactoryID() { >- return EMFResourceProxyFactory.ID; >+ public void addReference(String refType, IProxy proxyRef) { >+ IResource ur = proxyRef.getUnderlyingResource(); >+ if(ur instanceof IFile) { >+ ReferenceRegistry.getInstance().addReference((IFile)getUnderlyingResource(), refType, (IFile)ur); >+ } >+ } >+ >+ public void addBidirectionalReference(String refType, IReferencerProxyNode proxyRef, String oppositeRefType) { >+ IResource ur = proxyRef.getUnderlyingResource(); >+ if(ur instanceof IFile) { >+ ReferenceRegistry.getInstance().addBidirectionalReference((IFile)getUnderlyingResource(), refType, (IFile)ur, oppositeRefType); >+ } >+ } >+ >+ public void removeReference(IProxyNode proxyRef) { >+ IResource ur = proxyRef.getUnderlyingResource(); >+ if(ur instanceof IFile) { >+ ReferenceRegistry.getInstance().removeReference((IFile)getUnderlyingResource(), (IFile)ur); >+ } >+ } >+ >+ public Collection getReferences(String refType) { >+ return ReferenceRegistry.getInstance().getReferences((IFile)getUnderlyingResource(), refType); > } > >+ public Set getReferenceTypes() { >+ return ReferenceRegistry.getInstance().getReferenceTypes((IFile)getUnderlyingResource()); >+ } >+ > /** > * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#saveState(org.eclipse.ui.IMemento) > * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >@@ -164,6 +226,49 @@ > memento.putString(TAG_URI_FRAGMENT, getOriginatorURI().fragment()); > return true; > } >+ >+ public Change createMoveChange(IRefactoringContext context, IPath destinationPath) { >+ return this.getAdapter(IFile.class) != null ? new MoveModelChange(this, context, destinationPath) : null; >+ } >+ >+ public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referenced, String refType, IPath destinationPath) { >+ return new UpdateModelChange(this, context); >+ } >+ >+ public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath) { >+ return new ModelPathChange(this, context, destinationPath); >+ } >+ >+ public Change createDeleteChange(IRefactoringContext context) { >+ return new DeleteModelElementChange(context, this); >+ } >+ >+ public Change createPasteChange(IRefactoringContext context, IPath destinationPath,String [] targetName) { >+ return new PasteModelChange(context,this,destinationPath,targetName); >+ } >+ >+ //- overwrite AbstractProxy.equals to avoid to access to the underlying resource >+ public boolean equals(Object arg0) { >+ if(arg0 instanceof EObjectProxyNode) { >+ URI argURI = ((EObjectProxyNode)arg0).originatorURI; >+ return (originatorURI == null && argURI == null) >+ || (originatorURI != null && originatorURI.equals(argURI)); >+ } >+ return false; >+ } >+ >+ //- overwrite AbstractProxy.hashCode to avoid to access to the underlying resource >+ public int hashCode() { >+ return originatorURI != null ? originatorURI.hashCode() : -2; >+ } >+ >+ /** >+ * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#getFactoryID() >+ * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >+ */ >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } > > /** > * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >@@ -176,5 +281,4 @@ > public IResource getCorrespondingResource() { > return getUnderlyingResource(); > } >- > } >Index: src/org/eclipse/hyades/test/ui/navigator/IProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/IProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 IProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/IProxyNode.java 23 Mar 2005 15:28:48 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/navigator/IProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -15,8 +15,12 @@ > import org.eclipse.swt.graphics.Image; > > /** >- * Main interface to wrap objects into the test navigator >+ * Main interface to wrap objects into the test navigator. >+ * Instances of this interface must meet the following condition: >+ * <code>getAdapter(IFile.class) == null || getAdapter(IFile.class) == getUnderlyingResource() </code> >+ * > * @author jgout >+ * @version February 26, 2008 > */ > public interface IProxyNode extends IAdaptable, IProxy { > >Index: src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java,v >retrieving revision 1.14 >diff -u -r1.14 CMNNamedElementProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java 4 Jun 2007 13:58:47 -0000 1.14 >+++ src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -12,14 +12,28 @@ > package org.eclipse.hyades.test.ui.navigator; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.models.common.common.CMNNamedElement; > import org.eclipse.hyades.test.core.util.EMFUtil; >+import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveModelChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.RefactoringMessages; > import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; > import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIInlineEditor; > import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IEditorReference; >@@ -33,11 +47,16 @@ > * Proxy node for <code>CMNNamedElement</code> element. > * @author jgout > */ >-public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer { >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ * @since >+ */ >+public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer2, IProxyNodeRenamer { > > private final static String TAG_NAME = "name"; //$NON-NLS-1$ > private final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$ >- >+ > private String name; > private String description; > >@@ -89,6 +108,19 @@ > this.name = name; > } > >+ /** >+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if (adapter == IProxyNodeRenamer2.class) { >+ return this; >+ } if (adapter == IProxyNodeRenamer.class) { >+ return this; >+ } else { >+ return super.getAdapter(adapter); >+ } >+ } >+ > /** > * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). > */ >@@ -104,7 +136,6 @@ > public String getDescription() { > return this.description; > } >- > /** > * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#isApplicableFor() > */ >@@ -168,18 +199,92 @@ > > /** > * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#performUserInteraction(java.lang.String) >+ * @deprecated > */ > public RenamerUIStatus performUserInteraction(String oldName) { > return new RenamerUIInlineEditor(); > } > >- /** >- * @see org.eclipse.hyades.test.ui.navigator.EObjectProxyNode#saveState(org.eclipse.ui.IMemento) >- * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >- */ >- public boolean saveState(IMemento memento) { >- memento.putString(TAG_NAME, getName()); >- return super.saveState(memento); >+ public boolean saveState(IMemento memento) { >+ if (this instanceof IPersistableProxyNode) { >+ //- data from CMNNamedElementProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ return super.saveState(memento); >+ } >+ return false; >+ } >+ >+ public Change createRenameChange(IRefactoringContext context, String newName) { >+ if(getAdapter(IFile.class) != null) { >+ IPath oldPath = getUnderlyingResource().getFullPath(); >+ IPath newPath = oldPath.removeLastSegments(1).append(new Path(newName+'.'+oldPath.getFileExtension())); >+ return new RenameModelChange(this, context, newPath, newName); >+ } else { >+ return new RenameElementChange(this, context, newName); >+ } >+ } >+ >+ protected class RenameElementChange extends Change { >+ private EMFRefactoringTransaction context; >+ private String newName; >+ private CMNNamedElementProxyNode proxy; >+ >+ public RenameElementChange(CMNNamedElementProxyNode node, IRefactoringContext context, String newName) { >+ this.proxy = node; >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ this.newName = newName; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if(context != null) { >+ EObject object = context.getResourceSet().getEObject(getOriginatorURI(), true); >+ ((CMNNamedElement)object).setName(newName); >+ context.addResourceToSave(object.eResource()); >+ } >+ return null; >+ } >+ >+ public Object getModifiedElement() { >+ return proxy; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.RENAME_PROXY, proxy.getText(), newName); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return new RefactoringStatus(); >+ } > } > >+ protected class RenameModelChange extends MoveModelChange { >+ private IRefactoringContext context; >+ private String newName; >+ public RenameModelChange(IProxyNode node, IRefactoringContext context, IPath destinationPath, String newName) { >+ super(node, context, destinationPath); >+ this.context = context; >+ this.newName = newName; >+ } >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ Change change = super.perform(pm); >+ EMFRefactoringTransaction t = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ if(t != null) { >+ EObject object = t.getResourceSet().getEObject(getOriginatorURI(), false); >+ ((CMNNamedElement)object).setName(newName); >+ } >+ return change; >+ } >+ >+ protected void handleFileAlreadyExists(RefactoringStatus status) { >+ //- this is actually a rename but there is a conflict name, this is an error. >+ status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROXY_DURING_RENAME, destination.toPortableString())); >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.RENAME_PROXY, proxy.getText(), destination.removeFileExtension().lastSegment()); >+ } >+ } > } >Index: src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java,v >retrieving revision 1.6 >diff -u -r1.6 DefaultTestSuiteProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java 4 Jun 2007 13:58:47 -0000 1.6 >+++ src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -13,19 +13,43 @@ > > import java.util.Iterator; > import java.util.LinkedList; >+import java.util.List; > >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; > import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EObject; >+import org.eclipse.hyades.models.common.datapool.DPLDatapool; >+import org.eclipse.hyades.models.common.facades.behavioral.IBlock; >+import org.eclipse.hyades.models.common.facades.behavioral.IDecision; >+import org.eclipse.hyades.models.common.facades.behavioral.ILoop; >+import org.eclipse.hyades.models.common.facades.behavioral.ITest; >+import org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation; > import org.eclipse.hyades.models.common.testprofile.TPFTestCase; > import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; >+import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIExtension; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteTestInvocationChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.LaunchConfigurationDeleteChange; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.LaunchConfigurationUpdateChange; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; > 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.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > >@@ -38,6 +62,7 @@ > * <li> test suite proxy node is persisted using the proxy nodes persistency mechanism. > * </ul> > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DefaultTestSuiteProxyNode extends TypedElementProxyNode implements ITestSuiteProxyNode, IPersistableProxyNode { >@@ -64,7 +89,42 @@ > tcProxies.add(proxy); > } > } >- testCases = (CMNNamedElementProxyNode[]) tcProxies.toArray(new CMNNamedElementProxyNode[tcProxies.size()]); >+ testCases = (CMNNamedElementProxyNode[]) tcProxies.toArray(new CMNNamedElementProxyNode[tcProxies.size()]); >+ //- add references on associated datapools >+ for (Iterator it = ts.getDatapools().iterator(); it.hasNext();) { >+ DPLDatapool dp = (DPLDatapool) it.next(); >+ IProxyNode dpProxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(dp); >+ if(dpProxy != null) { >+ addBidirectionalReference("Test2Datapool", (IReferencerProxyNode)dpProxy, "Datapool2Test"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ //- add references on invocations >+ addInvocationReferences(ts.getImplementor().getBlock()); >+ } >+ >+ private void addInvocationReferences(IBlock block) { >+ if (block != null) { >+ List actions = block.getActions(); >+ for (Iterator it = actions.iterator(); it.hasNext();) { >+ Object action = it.next(); >+ if (action instanceof ILoop) { >+ addInvocationReferences(((ILoop) action).getBlock()); >+ } else if (action instanceof IDecision) { >+ IDecision ifAction = (IDecision) action; >+ addInvocationReferences(ifAction.getFailureBlock()); >+ addInvocationReferences(ifAction.getSuccessBlock()); >+ } else if (action instanceof ITestInvocation) { >+ ITestInvocation invocationAction = (ITestInvocation) action; >+ ITest invokedTest = invocationAction.getInvokedTest(); >+ if (((EObject) invocationAction).eResource() != ((EObject) invokedTest).eResource()) { >+ IProxyNode invokedProxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(invokedTest); >+ if (invokedProxy != null) { >+ addBidirectionalReference("TestInvoker2TestInvoked", (IReferencerProxyNode) invokedProxy, "TestInvoked2TestInvoker"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ } >+ } >+ } > } > > /** >@@ -136,6 +196,14 @@ > } > } > >+ /** >+ * Returns the ID of the factory that is used to recreate this proxy node. >+ * @return the ID of the factory that is used to recreate this proxy node. >+ */ >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ > /** > * @see org.eclipse.hyades.test.ui.navigator.EObjectProxyNode#getNodeKind() > * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). >@@ -166,4 +234,99 @@ > } > return true; > } >+ >+ private void launchConfigurationUpdateChanges(CompositeChange composite, URI newURI) { >+ ILaunchConfigurationType configsType = TestLaunchConfigurationFacade.getLaunchConfigurationType(); >+ ILaunchConfiguration[] configs = new ILaunchConfiguration[0]; >+ try { >+ configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configsType); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to get Launch Configuraions", e); //$NON-NLS-1$ >+ } >+ for (int i = 0; i < configs.length; i++) { >+ try { >+ URI originatorURI = getOriginatorURI(); >+ if (TestLaunchConfigurationFacade.isTestURI(configs[i], originatorURI)) { >+ composite.add(new LaunchConfigurationUpdateChange(configs[i], newURI.appendFragment(originatorURI.fragment())));; >+ } >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to update Launch Configuraions", e); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ private void launchConfigurationDeleteChanges(CompositeChange composite) { >+ ILaunchConfigurationType configsType = TestLaunchConfigurationFacade.getLaunchConfigurationType(); >+ ILaunchConfiguration[] configs = new ILaunchConfiguration[0]; >+ try { >+ configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configsType); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to get Launch Configuraions", e); //$NON-NLS-1$ >+ } >+ for (int i = 0; i < configs.length; i++) { >+ try { >+ URI originatorURI = getOriginatorURI(); >+ if (TestLaunchConfigurationFacade.isTestURI(configs[i], originatorURI)) { >+ composite.add(new LaunchConfigurationDeleteChange(configs[i])); >+ } >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to delete Launch Configuraions", e); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ public Change createRenameChange(IRefactoringContext context, String newName) { >+ CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$ >+ Change superChange = super.createRenameChange(context, newName); >+ if (superChange != null && superChange instanceof RenameModelChange) { >+ launchConfigurationUpdateChanges(composite, ((RenameModelChange)superChange).getNewURI()); >+ composite.add(superChange); >+ } >+ composite.markAsSynthetic(); >+ return composite; >+ } >+ >+ public Change createMoveChange(IRefactoringContext context, IPath destinationPath) { >+ CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$ >+ launchConfigurationUpdateChanges(composite, URI.createPlatformResourceURI(destinationPath.toPortableString())); >+ Change superChange = super.createMoveChange(context, destinationPath); >+ if (superChange != null) { >+ composite.add(superChange); >+ } >+ composite.markAsSynthetic(); >+ return composite; >+ } >+ >+ public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath) { >+ CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$ >+ launchConfigurationUpdateChanges(composite, URI.createPlatformResourceURI(destinationPath.toPortableString())); >+ Change superChange = super.createUpdateChange(context, container, destinationPath); >+ if (superChange != null) { >+ composite.add(superChange); >+ } >+ composite.markAsSynthetic(); >+ return composite; >+ } >+ >+ public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referenced, String refType, IPath destinationPath) { >+ if(destinationPath == null) { >+ if("TestInvoked2TestInvoker".equals(refType)) { //$NON-NLS-1$ >+ //- remove the link to referenced in this (clean invocation) >+ return new DeleteTestInvocationChange(context, this, referenced); >+ } >+ } >+ return super.createUpdateChange(context, referenced, refType, destinationPath); >+ } >+ >+ public Change createDeleteChange(IRefactoringContext context) { >+ CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$ >+ launchConfigurationDeleteChanges(composite); >+ Change superChange = super.createDeleteChange(context); >+ if(superChange != null) { >+ composite.add(superChange); >+ } >+ composite.markAsSynthetic(); >+ return composite; >+ } >+ > } >Index: src/org/eclipse/hyades/test/ui/navigator/IPersistableFileProxyFactory.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/IPersistableFileProxyFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 IPersistableFileProxyFactory.java >--- src/org/eclipse/hyades/test/ui/navigator/IPersistableFileProxyFactory.java 23 Mar 2005 09:42:11 -0000 1.3 >+++ src/org/eclipse/hyades/test/ui/navigator/IPersistableFileProxyFactory.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -17,6 +17,7 @@ > /** > * Interface for factories that can handle the persistancy of created proxy nodes. > * @author jgout >+ * @version February 26, 2008 > * @since 3.3 > */ > public interface IPersistableFileProxyFactory extends IFileProxyFactory { >@@ -29,6 +30,8 @@ > * @param file The file that the proxy node is the placeholder. > * @param parent The parent of the new created proxy node in the test navigator. > * @return The proxy node built based on the content of the given memento. >+ * The returned node must meet the following condition: >+ * <code>file.equals(factory.create(file, parent).getAdapter(IFile.class))</code> > */ > public IProxyNode recreate(IMemento memento, IFile file, Object parent); > >Index: src/org/eclipse/hyades/test/ui/navigator/IProxy.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/IProxy.java,v >retrieving revision 1.1 >diff -u -r1.1 IProxy.java >--- src/org/eclipse/hyades/test/ui/navigator/IProxy.java 23 Mar 2005 15:28:48 -0000 1.1 >+++ src/org/eclipse/hyades/test/ui/navigator/IProxy.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -15,7 +15,10 @@ > > /** > * Lightweight object that represents an arbitrary element within a resource. >+ * Two instances of this class should be equal if and only if they have equal >+ * underlying resource and identifier. > * @author jcanches >+ * @version February 26, 2008 > * @since 4.0 > */ > public interface IProxy { >Index: src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java,v >retrieving revision 1.5 >diff -u -r1.5 TypedElementProxyNode.java >--- src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java 4 Jun 2007 13:58:47 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -19,6 +19,7 @@ > /** General proxy for typed element. > * This class is derived for test suite, test case, test component and execution result > * @author jgout >+ * @version February 26, 2008 > */ > public abstract class TypedElementProxyNode extends CMNNamedElementProxyNode implements ITypedElementProxyNode { > >@@ -81,8 +82,11 @@ > * @provisional As of TPTP V4.4.0, this is stable provisional API (see http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html). > */ > public boolean saveState(IMemento memento) { >- memento.putString(TAG_TYPE, getType()); >- return super.saveState(memento); >- } >- >+ if (this instanceof IPersistableProxyNode) { >+ //- data from TypedElementProxyNode >+ memento.putString(TAG_TYPE, getType()); >+ return super.saveState(memento); >+ } >+ return false; >+ } > } >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.8 >diff -u -r1.8 CopyAction.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java 22 Mar 2007 14:42:03 -0000 1.8 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -44,11 +44,13 @@ > > /** > * Copy Action for the Resource mode. >- * @author jgout >+ * @author jgout,jbozier >+ * @version February 26, 2008 > */ > public class CopyAction extends Action implements IDisposable { > private Clipboard clipboard; > private IStructuredSelection selection; >+ private boolean isResourceNav; > > static class ClipboardManager { > private Map clipboardContent; >@@ -133,11 +135,12 @@ > > > public CopyAction(Clipboard clipboard) { >- super(UiPluginResourceBundle.command_Copy); //$NON-NLS-1$ >+ super(UiPluginResourceBundle.command_Copy); > if (clipboard == null) { > throw new IllegalArgumentException("Unable to perform copy action due to 'clipboard == null'"); //$NON-NLS-1$ > } > this.clipboard = clipboard; >+ this.isResourceNav = false; > } > > public void dispose() { >@@ -158,29 +161,18 @@ > } > } > >- private boolean copyResources() { >- if(selection.getFirstElement() instanceof IResource) { >- ClipboardManager.getInstance().clear(); >- List selectedResources = selection.toList(); >- for (Iterator it = selectedResources.iterator(); it.hasNext();) { >- IResource res = (IResource) it.next(); >- IPath location = res.getLocation(); >- if (location != null) { >- //- file path to be used in external copy >- ClipboardManager.getInstance().addFile(location.toOSString()); >- } >- //- file name to by used in textual context copy >- ClipboardManager.getInstance().addText(res.getName()); >- //- resource itself to be used in internal copy (inside Eclipse) >- ClipboardManager.getInstance().addResource(res); >- } >- setClipboard(); >- return true; >- } else { >- return false; >- } >+ private void copyOneResource(IResource res) { >+ IPath location = res.getLocation(); >+ if (location != null) { >+ //- file path to be used in external copy >+ ClipboardManager.getInstance().addFile(location.toOSString()); >+ } >+ //- file name to by used in textual context copy >+ ClipboardManager.getInstance().addText(res.getName()); >+ //- resource itself to be used in internal copy (inside Eclipse) >+ ClipboardManager.getInstance().addResource(res); > } >- >+ > /** Tests whether the given proxy is a proxy of file or not > * @param proxy > * @return true if this proxy replaces a file >@@ -190,37 +182,42 @@ > return proxy instanceof FileProxyNode || parent instanceof IContainer; > } > >- private void copyProxies() { >- if(selection.getFirstElement() instanceof IProxyNode) { >- ClipboardManager.getInstance().clear(); >- List proxies = selection.toList(); >- for (Iterator it = proxies.iterator(); it.hasNext();) { >- IProxyNode proxy = (IProxyNode) it.next(); >- if(isAFileProxy(proxy)) { >- IResource res = proxy.getUnderlyingResource(); >- IPath location = res.getLocation(); >- if (location != null) { >- //- external file path of the underlying resource to be used in external copy >- ClipboardManager.getInstance().addFile(location.toOSString()); >- } >- //- underlying resource to be used in internal copy (inside Eclipse) >- ClipboardManager.getInstance().addResource(res); >- } >- //- Fully qualified proxy name to by used in textual context copy >- ClipboardManager.getInstance().addText(proxy.getClass().getName()+"::"+proxy.getText()); //$NON-NLS-1$ >+ private void copyOneProxy(IProxyNode proxy) { >+ if(isAFileProxy(proxy)) { >+ IResource res = proxy.getUnderlyingResource(); >+ IPath location = res.getLocation(); >+ if (location != null) { >+ //- external file path of the underlying resource to be used in external copy >+ ClipboardManager.getInstance().addFile(location.toOSString()); >+ } >+ //- underlying resource to be used in internal copy (inside Eclipse) >+ ClipboardManager.getInstance().addResource(res); >+ } >+ //- Fully qualified proxy name to by used in textual context copy >+ ClipboardManager.getInstance().addText(proxy.getClass().getName()+"::"+proxy.getText()); //$NON-NLS-1$ > >- //- proxy itself for test navigator context copy >- ClipboardManager.getInstance().addProxy(proxy); >+ //- proxy itself for test navigator context copy >+ ClipboardManager.getInstance().addProxy(proxy); >+ } >+ >+ private void copySelection() { >+ ClipboardManager.getInstance().clear(); >+ List allSelected = selection.toList(); >+ for (Iterator it = allSelected.iterator(); it.hasNext();) { >+ Object item = (it.next()); >+ if (item instanceof IResource) { >+ copyOneResource((IResource)item); >+ } else { >+ if (item instanceof IProxyNode) { >+ copyOneProxy((IProxyNode)item); >+ } > } >- setClipboard(); > } >+ setClipboard(); > } > > public void run() { >- if(copyResources()) { >- return; >- } >- copyProxies(); >+ copySelection(); > } > > private boolean selectionIsHomogeneous() { >@@ -283,6 +280,8 @@ > } > > public boolean isApplicableForSelection() { >+ //- Copy action only allowed if the navigator is presenting its resource mode >+ if(!isResourceNav) return false; > if (selection == null || selection.isEmpty()) { > return false; > } >@@ -297,7 +296,8 @@ > return true; > } > >- public void selectionChanged(IStructuredSelection structuredSelection) { >+ public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceNav) { > selection = structuredSelection; >+ this.isResourceNav = isResourceNav; > } > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteExtensionManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteExtensionManager.java,v >retrieving revision 1.4 >diff -u -r1.4 PasteExtensionManager.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteExtensionManager.java 19 Apr 2007 12:27:42 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteExtensionManager.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -24,8 +24,8 @@ > import org.eclipse.swt.dnd.Clipboard; > > /** >- * @author jgout >- * @since 3.3 >+ * @author jgout,jbozier >+ * @version February 26, 2008 > */ > public class PasteExtensionManager { > >@@ -42,7 +42,7 @@ > public PasterExtensionInfo (String target, boolean strict, IConfigurationElement element) { > this.strict = strict; > try { >- this.target = Platform.getBundle(element.getDeclaringExtension().getNamespace()).loadClass(target); >+ this.target = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()).loadClass(target); > } catch (ClassNotFoundException e) { > UiPlugin.logError(e); > } >@@ -126,7 +126,7 @@ > return false; > } > >- /** Retruns all registered paster that can deal with the given target object. >+ /** Returns all registered paster that can deal with the given target object. > * > * @param selection the current selection (location where the user wants to paste) > * @return IPaster [] the array of pasters registered for the given selection. >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.2 >diff -u -r1.2 FileProxyInContainerPaste.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java 22 Mar 2007 14:42:04 -0000 1.2 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -27,11 +27,13 @@ > > /** > * Paste action for the resource mode. >- * @author jgout >+ * @author jgout,jbozier > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated > */ > public class FileProxyInContainerPaste implements IPaster { >- >+ > private IResource [] getResourceFromClipboard(final Clipboard clipboard) { > final IResource[][] clipboardData = new IResource[1][]; > Display.getCurrent().syncExec(new Runnable() { >@@ -65,7 +67,7 @@ > } > return false; > } >- >+ > public boolean performPaste(Clipboard clipboard, Object selection) { > // - check for internal copy (inside eclipse) > IResource [] res = getResourceFromClipboard(clipboard); >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.5 >diff -u -r1.5 FileFolderInContainerPaste.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java 22 Mar 2007 14:42:04 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -40,8 +40,10 @@ > > /** > * Paste action for the resource mode. >- * @author jgout >+ * @author jgout,jbozier > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated > */ > public class FileFolderInContainerPaste implements IPaster { > >@@ -150,8 +152,11 @@ > throw new OperationCanceledException(); > } > //- if the user has omitted/misspelled the correct file extension (same as source one) we should add it >- if(!returnValue[0].endsWith(resource.getFileExtension())) { >- returnValue[0] += '.'+resource.getFileExtension(); >+ String fileExt = resource.getFileExtension(); >+ if (fileExt != null) { >+ if(!returnValue[0].endsWith(fileExt)) { >+ returnValue[0] += '.'+fileExt; >+ } > } > return prefix.append(returnValue[0]); > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteAction.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteAction.java,v >retrieving revision 1.3 >diff -u -r1.3 PasteAction.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteAction.java 22 Mar 2007 14:42:04 -0000 1.3 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteAction.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -13,6 +13,7 @@ > > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.IPasterExtended; > import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; > import org.eclipse.hyades.test.ui.navigator.actions.IPaster; > import org.eclipse.hyades.ui.util.IDisposable; >@@ -24,13 +25,14 @@ > import org.eclipse.ui.part.ResourceTransfer; > > /** >- * @author jgout >- * @since 3.3 >+ * @author jgout,jbozier >+ * @version February 26, 2008 > */ > public class PasteAction extends Action implements IDisposable { > protected Clipboard clipboard; > private IStructuredSelection selection; > private Shell shell; >+ private boolean isResourceNav; > > public PasteAction(Shell shell, Clipboard clipboard) { > super(UiPluginResourceBundle.command_Paste); >@@ -40,6 +42,7 @@ > if (clipboard == null) > throw new IllegalArgumentException("Unable to perform paste action due to 'clipboard == null'"); //$NON-NLS-1$ > this.clipboard = clipboard; >+ this.isResourceNav = false; > } > > public void dispose() { >@@ -49,13 +52,16 @@ > clipboard = null; > shell = null; > } >- >+ > public void run() { > Object target = selection != null ? selection.getFirstElement() : null; >- if(target != null) { >- IPaster [] pasters = PasteExtensionManager.getInstance().getPasters(target); >+ if(target != null) { >+ IPaster [] pasters = PasteExtensionManager.getInstance().getPasters(target); > for (int i = 0; i < pasters.length; i++) { > IPaster paster = pasters[i]; >+ if (paster instanceof IPasterExtended) { >+ ((IPasterExtended)paster).setShell(shell); >+ } > if(paster.performPaste(clipboard, target)) { > return; > } >@@ -82,8 +88,8 @@ > } > }); > return clipboardData[0]; >- } >- >+ } >+ > private boolean doesClipboardContainProjects() { > //- if clipboard contains a project, paste is valid if project is open > IResource [] res = getResourceFromClipboard(); >@@ -100,6 +106,8 @@ > } > > public boolean isApplicableForSelection() { >+ //- paste action is only allowed for resource view of the test navigator >+ if(!isResourceNav) return false; > //- regardless the selection if clipboard contains a project, this is possible to paste it. > if (doesClipboardContainProjects()) { > return true; >@@ -116,7 +124,8 @@ > return false; > } > >- public void selectionChanged(IStructuredSelection structuredSelection) { >+ public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceNav) { > selection = structuredSelection; >+ this.isResourceNav = isResourceNav; > } > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/RenameAction.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/RenameAction.java,v >retrieving revision 1.9 >diff -u -r1.9 RenameAction.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/RenameAction.java 19 Apr 2007 18:47:07 -0000 1.9 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/RenameAction.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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,30 +14,47 @@ > import java.lang.reflect.InvocationTargetException; > > import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.RenameRefactoring; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; > import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2; > import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus; > import org.eclipse.hyades.ui.internal.navigator.TreeNavigator; > import org.eclipse.hyades.ui.util.IDisposable; > import org.eclipse.jface.action.Action; >+import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.ProgressMonitorDialog; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizard; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; >+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.TreeEditor; > import org.eclipse.swt.events.FocusAdapter; > import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; > import org.eclipse.swt.widgets.Tree; > import org.eclipse.swt.widgets.TreeItem; >@@ -47,7 +64,7 @@ > /** > * @author Jerome Gout > * @author Paul E. Slauenwhite >- * @version March, 2007 >+ * @version March 12, 2008 > * @since 3.3 > */ > public class RenameAction extends Action implements IDisposable { >@@ -60,6 +77,92 @@ > protected TreeNavigator navigator; > protected IContainer renamedResource; > >+ private class RenameRefactoringWizard extends RefactoringWizard { >+ private RenameRefactoringNewNameInputPage page; >+ >+ private RenameRefactoringWizard(RenameRefactoring refactoring, String name) { >+ super(refactoring, DIALOG_BASED_USER_INTERFACE/* | NONE*/); >+ this.page = new RenameRefactoringNewNameInputPage(refactoring, name); >+ } >+ >+ protected void addUserInputPages() { >+ addPage(page); >+ } >+ } >+ >+ class RenameRefactoringNewNameInputPage extends UserInputWizardPage { >+ private RenameRefactoring refactoring; >+ private Text nameText; >+ private String oldName; >+ private String newName; >+ >+ public RenameRefactoringNewNameInputPage(RenameRefactoring refactoring, String oldName) { >+ super(""); //$NON-NLS-1$ >+ this.oldName = oldName; >+ this.refactoring = refactoring; >+ } >+ >+ public void createControl(Composite parent) { >+ Composite result= new Composite(parent, SWT.NONE); >+ setControl(result); >+ result.setLayout(new GridLayout(2, false)); >+ >+ Label label= new Label(result, SWT.NONE); >+ label.setText(ActionMessages.RENAME_NEW_NAME_LABEL); >+ nameText = new Text(result, SWT.SINGLE | SWT.BORDER); >+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); >+ nameText.setText(oldName); >+ nameText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ newName = nameText.getText(); >+ refactoring.setNewName(newName); >+ setPageComplete(isPageComplete()); >+ } >+ }); >+ nameText.selectAll(); >+ Dialog.applyDialogFont(result); >+ } >+ >+ public boolean isPageComplete() { >+ // first check if name is not empty and have changed >+ boolean basicCondition = newName != null && newName.length() > 0 && !newName.equals(oldName); >+ if (!basicCondition) { >+ return false; >+ } >+ // then check if target is ok >+ if (selection == null || selection.isEmpty()) { >+ return false; >+ } >+ Object objSelected = selection.getFirstElement(); >+ if (objSelected instanceof IContainer) { >+ // check if destination exists in case of a container >+ IContainer destContainer = getIContainer((IContainer)objSelected, newName); >+ return !(destContainer.exists()); >+ } else if (objSelected instanceof IProxyNode) { >+ IProxyNode proxy = (IProxyNode) objSelected; >+ IResource res = proxy.getUnderlyingResource(); >+ if (res instanceof IFile) { >+ IFile file = (IFile)res; >+ String extension = file.getFileExtension(); >+ String destName = newName; >+ if (extension != null) { >+ destName = newName+'.'+extension; >+ } >+ IFile destFile = ((IFile)res).getParent().getFile(new Path(destName)); >+ return (!destFile.exists()); >+ } >+ } >+ return false; >+ } >+ } >+ >+ private IContainer getIContainer(IContainer container,String newName) { >+ if(container.getFullPath().segmentCount() > 1) { >+ return container.getParent().getFolder(new Path(newName)); >+ } else { >+ return ResourcesPlugin.getWorkspace().getRoot().getProject(newName); >+ } >+ } > public RenameAction(TreeNavigator treeNav) { > super(TestNavigatorMessages.RenameAction_ActionName); > this.navigator = treeNav; >@@ -82,16 +185,26 @@ > return true; > } else if (objSelected instanceof IProxyNode) { > IProxyNode proxy = (IProxyNode) objSelected; >- IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class); >- if (renamer != null) { >- return renamer.isApplicableFor(); >- } else { >- //- this means that there is no renamer for this proxy >- return false; >+ IProxyNodeRenamer2 renamer2 = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class); >+ if(renamer2 != null) { >+ return true; > } >- } else { >- return false; >+ oldActionValidation(proxy); >+ } >+ return false; >+ } >+ >+ /** >+ * @param proxy >+ * @return >+ * @deprecated >+ */ >+ private boolean oldActionValidation(IProxyNode proxy) { >+ IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class); >+ if (renamer != null) { >+ return renamer.isApplicableFor(); > } >+ return false; > } > > /** >@@ -111,7 +224,7 @@ > * Create the text editor widget. > * This code has been imported from RenameResourceAction > * @param renamer >- * >+ * @deprecated > */ > private void createTextEditor(final IProxyNodeRenamer renamer) { > //- Create text editor parent. This draws a nice bounding rect. >@@ -165,6 +278,12 @@ > textActionHandler.addText(textEditor); > } > >+ /** >+ * >+ * @param renamer >+ * @param newName >+ * @deprecated >+ */ > protected void performRename(final IProxyNodeRenamer renamer, final String newName) { > Runnable query = new Runnable() { > public void run() { >@@ -242,6 +361,7 @@ > * This code is inspired from RenameResourceAction > * @param oldName current value of the selected item > * @param renamer >+ * @deprecated > */ > private void getNewNameInline(String oldName, IProxyNodeRenamer renamer) { > //- Make sure text editor is created only once. >@@ -265,28 +385,75 @@ > Object objSelected = selection.getFirstElement(); > if (objSelected instanceof IContainer) { > renamedResource = (IContainer)objSelected; >- //- reuse the inline editor to rename a project or folder node >- getNewNameInline(((IContainer)objSelected).getName(), null); >+ preformContainerRefactoringRename(renamedResource); > } else if (objSelected instanceof IProxyNode) { > IProxyNode proxy = (IProxyNode) objSelected; >- IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class); >- if (renamer != null) { >- RenamerUIStatus status = renamer.performUserInteraction(proxy.getText()); >- switch (status.getStatus()) { >- case RenamerUIStatus.OK : >- performRename(renamer, status.getNewName()); >- break; >- case RenamerUIStatus.CANCEL : >- //- nothing to do >- break; >- case RenamerUIStatus.INLINE_EDITOR : >- getNewNameInline(proxy.getText(), renamer); >- break; >+ IProxyNodeRenamer2 renamer2 = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class); >+ if(renamer2 != null) { >+ performProxyRefactoringRename(proxy); >+ } else { >+ IReferencerProxyNode ref = (IReferencerProxyNode)proxy.getAdapter(IReferencerProxyNode.class); >+ if(ref != null) { >+ performProxyRefactoringRename(proxy); >+ } else { >+ performOldRename(proxy); > } > } > } > } > >+ /** >+ * @param proxy >+ * @deprecated >+ */ >+ private void performOldRename(IProxyNode proxy) { >+ //- this code will be removed in 5.0 >+ IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class); >+ if (renamer != null) { >+ RenamerUIStatus status = renamer.performUserInteraction(proxy.getText()); >+ switch (status.getStatus()) { >+ case RenamerUIStatus.OK : >+ performRename(renamer, status.getNewName()); >+ break; >+ case RenamerUIStatus.CANCEL : >+ //- nothing to do >+ break; >+ case RenamerUIStatus.INLINE_EDITOR : >+ getNewNameInline(proxy.getText(), renamer); >+ break; >+ } >+ } >+ } >+ >+ private void preformContainerRefactoringRename(IContainer container) { >+ RenameRefactoring refactoring = new RenameRefactoring(container); >+ performRefactoringRename(refactoring, container.getName()); >+ } >+ >+ private void performProxyRefactoringRename(IProxyNode proxy) { >+ RenameRefactoring refactoring = new RenameRefactoring(proxy); >+ performRefactoringRename(refactoring, proxy.getText()); >+ } >+ >+ private void performRefactoringRename(final RenameRefactoring refactoring, final String oldName) { >+ Shell shell = Display.getCurrent().getActiveShell(); >+ if (! canActivate(shell)) >+ return; >+ RefactoringWizard wizard = new RenameRefactoringWizard(refactoring, oldName); >+ wizard.setDefaultPageTitle(ActionMessages.RENAME_ACTION_NAME); >+ wizard.setNeedsProgressMonitor(true); >+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard); >+ try { >+ op.run(shell , ""); //$NON-NLS-1$ >+ } catch (InterruptedException e) { >+ UiPlugin.logError(e); >+ } >+ } >+ >+ private boolean canActivate(Shell shell) { >+ return EditorUtil.saveEditors(shell); >+ } >+ > public void selectionChanged(IStructuredSelection structuredSelection) { > selection = structuredSelection; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/TestNavigatorActionGroup.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/action/TestNavigatorActionGroup.java,v >retrieving revision 1.13 >diff -u -r1.13 TestNavigatorActionGroup.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/action/TestNavigatorActionGroup.java 22 Mar 2007 14:42:04 -0000 1.13 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/TestNavigatorActionGroup.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -16,7 +16,6 @@ > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; >-import java.util.Set; > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; >@@ -25,7 +24,6 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.hyades.test.ui.TestUIImages; >-import org.eclipse.hyades.test.ui.internal.model.ui.RemoveChildrenAction; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; > import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; >@@ -60,7 +58,6 @@ > import org.eclipse.ui.actions.AddBookmarkAction; > import org.eclipse.ui.actions.AddTaskAction; > import org.eclipse.ui.actions.CloseResourceAction; >-import org.eclipse.ui.actions.DeleteResourceAction; > import org.eclipse.ui.actions.OpenResourceAction; > import org.eclipse.ui.actions.RefreshAction; > import org.eclipse.ui.actions.WorkingSetFilterActionGroup; >@@ -96,8 +93,7 @@ > protected CloseResourceAction closeProjectAction; > protected StopAction stopAction; > >- protected DeleteResourceAction deleteResourceAction; >- protected RemoveChildrenAction deleteChildEObject; >+ protected DeleteAction deleteAction; > > protected NavigatorSorterActionGroup sorterActionGroup; > protected NewActionGroup newActionGroup; >@@ -106,6 +102,7 @@ > protected RenameAction renameAction; > protected CopyAction copyAction; > protected PasteAction pasteAction; >+ protected MoveAction moveAction; > protected OpenWithActionGroup openWithActionGroup; > > >@@ -133,6 +130,7 @@ > renameAction.dispose(); > stopAction.dispose(); > pasteAction.dispose(); >+ moveAction.dispose(); > if(clipboard != null) { > clipboard.dispose(); > clipboard = null; >@@ -186,32 +184,10 @@ > TestUIImages.INSTANCE.setImageDescriptors(toggleEObjectChildren, TestUIImages.ACT_SHOW_EOBJECT_CHILDREN); > > ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); >- deleteResourceAction = new DeleteResourceAction(shell); >- deleteResourceAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); >- deleteResourceAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); >- deleteResourceAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); >- >- deleteChildEObject = new RemoveChildrenAction(true) >- { >- protected List saveResources(Set changedResources) >- { >- TestNavigator testNavigator = (TestNavigator)getNavigator(); >- testNavigator.getTreeViewer().remove(getStructuredSelection().toArray()); >- >- testNavigator.setMonitoringResourceChange(false); >- try >- { >- return super.saveResources(changedResources); >- } >- finally >- { >- testNavigator.setMonitoringResourceChange(true); >- } >- } >- }; >- deleteChildEObject.setStructuredViewer(((TestNavigator)getNavigator()).getViewer()); >- deleteChildEObject.setShowErrorDialog(true); >- >+ deleteAction = new DeleteAction(shell); >+ deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); >+ deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); >+ deleteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); > openReportAction = new OpenReportAction(); > generateAction = new GenerateAction(); > generateAction.setImageDescriptor(TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.GENERATE_TEST));//$NON-NLS-1$ >@@ -222,12 +198,12 @@ > stopAction = new StopAction(); > renameAction = new RenameAction((TreeNavigator)getNavigator()); > pasteAction = new PasteAction(shell, clipboard); >- pasteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); >+ pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); > pasteAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); > copyAction = new CopyAction(clipboard); >- copyAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); >+ copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); > copyAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); >- >+ moveAction = new MoveAction(shell); > } > > /** >@@ -346,39 +322,39 @@ > menu.appendToGroup(INavigatorContribution.GROUP_DELETE, stopAction); > stopAction.setEnabled(stopAction.isApplicableForEnablement()); > } >- >- copyAction.selectionChanged(selection); >+ boolean isResourceTestNav = ((TestNavigator)getNavigator()).getCurrentViewIndex()==TestNavigator.VIEW_ID_RESOURCE; >+ copyAction.selectionChanged(selection, isResourceTestNav); > if(copyAction.isApplicableForSelection()){ > menu.appendToGroup(INavigatorContribution.GROUP_DELETE, copyAction); > } > >- pasteAction.selectionChanged(selection); >+ pasteAction.selectionChanged(selection, isResourceTestNav); > if(pasteAction.isApplicableForSelection()){ > menu.appendToGroup(INavigatorContribution.GROUP_DELETE, pasteAction); > } > >- deleteResourceAction.setEnabled(false); >- if(resSelection.size() == selection.size()) >- { >- deleteResourceAction.selectionChanged(resSelection); >- menu.appendToGroup(INavigatorContribution.GROUP_DELETE, deleteResourceAction); >- >- addBookmarkAction.selectionChanged(resSelection); >- if(addBookmarkAction.isEnabled()) >- menu.appendToGroup(INavigatorContribution.GROUP_DELETE, addBookmarkAction); >+ moveAction.selectionChanged(selection, isResourceTestNav); >+ if(moveAction.isApplicableForSelection()){ >+ menu.appendToGroup(INavigatorContribution.GROUP_DELETE, moveAction); > } >- if(!deleteResourceAction.isEnabled()){ >- menu.add(new Separator()); >- deleteChildEObject.selectionChanged(selection); >- if(deleteChildEObject.isEnabled()) >- menu.add(deleteChildEObject); >+ >+ deleteAction.selectionChanged(selection); >+ if(deleteAction.isEnabled()) { >+ menu.appendToGroup(INavigatorContribution.GROUP_DELETE, deleteAction); > } >- >+ > renameAction.selectionChanged(selection); > if(renameAction.isApplicableForSelection()) { > menu.appendToGroup(INavigatorContribution.GROUP_DELETE, renameAction); > } > >+ if(resSelection.size() == selection.size() && selection.size() > 0) >+ { >+ addBookmarkAction.selectionChanged(resSelection); >+ if(addBookmarkAction.isEnabled()) >+ menu.appendToGroup(INavigatorContribution.GROUP_DELETE, addBookmarkAction); >+ } >+ > if(selection.size() == 1) { > propertyDialogAction.selectionChanged(selection); > if(propertyDialogAction.isApplicableForSelection()) >@@ -394,7 +370,7 @@ > actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertyDialogAction); > actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction); > actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction); >- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteResourceAction); >+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); > > frameListActionGroup.fillActionBars(actionBars); > newActionGroup.fillActionBars(actionBars); >@@ -432,13 +408,15 @@ > > propertyDialogAction.setEnabled(structuredSelection.size() == 1); > addBookmarkAction.selectionChanged(resourceStructuredSelection); >- deleteResourceAction.selectionChanged(resourceStructuredSelection); >+ deleteAction.selectionChanged(resourceStructuredSelection); > addTaskAction.selectionChanged(structuredSelection); > refreshAction.selectionChanged(structuredSelection); > openProjectAction.selectionChanged(structuredSelection); > closeProjectAction.selectionChanged(structuredSelection); >- copyAction.selectionChanged(structuredSelection); >- pasteAction.selectionChanged(structuredSelection); >+ boolean isResourceTestNav = ((TestNavigator)getNavigator()).getCurrentViewIndex()==TestNavigator.VIEW_ID_RESOURCE; >+ copyAction.selectionChanged(structuredSelection, isResourceTestNav); >+ pasteAction.selectionChanged(structuredSelection, isResourceTestNav); >+ moveAction.selectionChanged(structuredSelection, isResourceTestNav); > renameAction.selectionChanged(structuredSelection); > > >@@ -465,8 +443,8 @@ > { > if(event.character == SWT.DEL && (event.stateMask == SWT.None)) > { >- if(deleteResourceAction.isEnabled()) >- deleteResourceAction.run(); >+ if(deleteAction.isEnabled()) >+ deleteAction.run(); > //- Swallow the event. > event.doit = false; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java,v >retrieving revision 1.5 >diff -u -r1.5 DatapoolProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java 28 Feb 2008 17:04:23 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -21,6 +21,8 @@ > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DatapoolProxyNode extends CMNNamedElementProxyNode { >@@ -49,6 +51,16 @@ > return new IProxyNode[0]; > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_NODE); >+ return super.saveState(memento); >+ } >+ > protected String getNodeKind() { > return TestUIConstants.DATAPOOL_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 DeploymentFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,14 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DeploymentFileProxyNode extends EMFResourceProxyNode { >@@ -36,6 +39,24 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DEPLOYMENT); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.DEPLOY_FILE_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java,v >retrieving revision 1.5 >diff -u -r1.5 DeploymentProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java 28 Feb 2008 17:04:23 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -11,16 +11,23 @@ > *******************************************************************************/ > package org.eclipse.hyades.test.ui.internal.navigator.proxy; > >+import java.util.Iterator; >+ >+import org.eclipse.hyades.models.common.configuration.CFGArtifact; >+import org.eclipse.hyades.models.common.configuration.CFGLocation; > import org.eclipse.hyades.models.common.testprofile.TPFDeployment; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; > import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DeploymentProxyNode extends CMNNamedElementProxyNode { >@@ -30,6 +37,18 @@ > */ > public DeploymentProxyNode(TPFDeployment deploy, Object parent) { > super(deploy, parent); >+ for (Iterator it = deploy.getArtifacts().iterator(); it.hasNext();) { >+ IProxyNode artifact = FileProxyNodeCache.getInstance().getCorrespondingProxy( (CFGArtifact)it.next()); >+ if(artifact != null) { >+ addBidirectionalReference("Deploy2Artifact", (IReferencerProxyNode) artifact, "Artifact2Deploy"); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ } >+ for (Iterator it = deploy.getLocations().iterator(); it.hasNext();) { >+ IProxyNode location = FileProxyNodeCache.getInstance().getCorrespondingProxy((CFGLocation)it.next()); >+ if(location != null) { >+ addBidirectionalReference("Deploy2Location", (IReferencerProxyNode) location, "Location2Deploy"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } > } > > /** >@@ -49,6 +68,16 @@ > return new IProxyNode[0]; > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_NODE); >+ return super.saveState(memento); >+ } >+ > protected String getNodeKind() { > return TestUIConstants.DEPLOY_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java,v >retrieving revision 1.7 >diff -u -r1.7 TypedElementFactoryManager.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java 28 Feb 2008 17:04:23 -0000 1.7 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java 13 Mar 2008 14:45:35 -0000 >@@ -23,6 +23,7 @@ > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class TypedElementFactoryManager { >@@ -111,6 +112,7 @@ > */ > public ITypedElementProxyFactory getFactoryFromID(String factoryID) { > Object value = factories.get(factoryID); >+ if(value == null) return null; > if (value instanceof IConfigurationElement) { > //- if the factory has not yet been loaded > IConfigurationElement element = (IConfigurationElement) value; >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java,v >retrieving revision 1.7 >diff -u -r1.7 DefaultTestCaseProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java 28 Feb 2008 17:04:23 -0000 1.7 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -29,6 +29,8 @@ > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > */ > public class DefaultTestCaseProxyNode extends TypedElementProxyNode implements ITestCaseProxyNode, IPersistableProxyNode { > >@@ -75,6 +77,16 @@ > } > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCASE_NODE); >+ return super.saveState(memento); >+ } >+ > protected String getNodeKind() { > return TestUIConstants.TESTCASE_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 ArtifactFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,14 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class ArtifactFileProxyNode extends EMFResourceProxyNode { >@@ -36,6 +39,24 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_ARTIFACT); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > public String getNodeKind() { > return TestUIConstants.ARTIFACT_FILE_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 DatapoolFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,14 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DatapoolFileProxyNode extends EMFResourceProxyNode { >@@ -36,6 +39,24 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DATAPOOL); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.DATAPOOL_FILE_NODE; > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java,v >retrieving revision 1.5 >diff -u -r1.5 ArtifactProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java 28 Feb 2008 17:04:23 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -11,16 +11,22 @@ > *******************************************************************************/ > package org.eclipse.hyades.test.ui.internal.navigator.proxy; > >+import java.util.Iterator; >+ > import org.eclipse.hyades.models.common.configuration.CFGArtifact; >+import org.eclipse.hyades.models.common.configuration.CFGClass; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; > import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class ArtifactProxyNode extends CMNNamedElementProxyNode { >@@ -39,6 +45,14 @@ > */ > public ArtifactProxyNode(CFGArtifact artifact, Object parent) { > super(artifact, parent); >+ //- add references on tets. >+ for (Iterator it = artifact.getDeployableInstances().iterator(); it.hasNext();) { >+ CFGClass test = (CFGClass) it.next(); >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(test); >+ if(proxy != null && proxy instanceof IReferencerProxyNode) { >+ addBidirectionalReference("Artifact2Test", (IReferencerProxyNode) proxy, "Test2Artifact"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } > } > > public Image getImage() { >@@ -50,8 +64,17 @@ > return new IProxyNode[0]; > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_NODE); >+ return super.saveState(memento); >+ } >+ > protected String getNodeKind() { > return TestUIConstants.ARTIFACT_NODE; > } >- > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java,v >retrieving revision 1.12 >diff -u -r1.12 EMFResourceProxyFactory.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java 15 Dec 2006 17:05:48 -0000 1.12 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -33,6 +33,8 @@ > * Delegation is made for typed object. > * > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class EMFResourceProxyFactory implements IFileProxyFactory, IPersistableFileProxyFactory { >@@ -40,7 +42,7 @@ > /** > * Factory id. > */ >- public final static String ID = "EMFResourceProxyFactory"; //$NON-NLS-1$ >+ public final static String ID = "EMFResourceProxyFactory_4.3"; //$NON-NLS-1$ > > /** This method is called to build a node that contains multiple EMF objects as children. > * The object created depends of the extension of the file (.datapool -> DatapoolFileProxyNode) >@@ -80,7 +82,7 @@ > * @return the resource associated to the given file or <code>null</code> if the resource was unable to be loaded. > */ > private Resource getEMFResource(IFile file) { >- URI uri = URI.createPlatformResourceURI(file.getFullPath().toString()); >+ URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(),false); > ResourceSet rs = new ResourceSetImpl(); > return rs.getResource(uri, true); > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 TestComponentFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,13 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class TestComponentFileProxyNode extends EMFResourceProxyNode { >@@ -36,8 +38,25 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_COMPONENT); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCOMPONENT_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) >+ return false; >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.TESTCOMPONENT_FILE_NODE; > } >- >+ > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileFactoryManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileFactoryManager.java,v >retrieving revision 1.4 >diff -u -r1.4 FileFactoryManager.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileFactoryManager.java 18 Mar 2005 16:43:34 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileFactoryManager.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -25,6 +25,8 @@ > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class FileFactoryManager { >@@ -151,7 +153,7 @@ > if (value instanceof IConfigurationElement) { > //- if the factory has not yet been loaded > IConfigurationElement element = (IConfigurationElement) value; >- IFileProxyFactory factory; //$NON-NLS-1$ >+ IFileProxyFactory factory; > try { > if(element.getName().equals("file")) { //$NON-NLS-1$ > //- old extension point >@@ -166,7 +168,7 @@ > } catch (CoreException e) { > //- remove this element since we can not create a factory from it > factories.remove(id); >- UiPlugin.logError("Enable to create the factory instance from configuration element"); //$NON-NLS-1$//$NON-NLS-2$ >+ UiPlugin.logError("Enable to create the factory instance from configuration element"); //$NON-NLS-1$ > return null; > } > } else if(value instanceof IFileProxyFactory) { >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java,v >retrieving revision 1.10 >diff -u -r1.10 DefaultExecutionResultProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java 16 Apr 2007 17:38:31 -0000 1.10 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -15,12 +15,14 @@ > import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent; > import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult; > import org.eclipse.hyades.models.common.testprofile.TPFTest; >+import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; > import org.eclipse.hyades.test.ui.internal.model.EventUtil; > import org.eclipse.hyades.test.ui.navigator.IExecutionResultProxyNode; > import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; > import org.eclipse.hyades.test.ui.navigator.ProxyNeedToBeRebuiltException; > import org.eclipse.hyades.test.ui.navigator.TypedElementProxyNode; > import org.eclipse.swt.graphics.Image; >@@ -29,6 +31,8 @@ > /** > * @author jgout > * @author jcanches >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode { >@@ -47,16 +51,6 @@ > */ > public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) { > super(er, parent); >- >-// LinkedList c = new LinkedList(); >-// TPFExecutionHistory history = er.getExecutionHistory(); >-// if (history != null ) { >-// EList events = history.getExecutionEvents(); >-// for (Iterator it = events.iterator(); it.hasNext();) { >-// getEventChildren((TPFExecutionEvent) it.next(), c, er); >-// } >-// } >-// children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]); > children = new IProxyNode[0]; > //- save the name of this element > String name = er.getName(); >@@ -74,11 +68,21 @@ > name = testName; > } > } >- setName(name); >- if (!(parent instanceof IExecutionResultProxyNode)) { >- if (er.getExecutionHistory().getExecutionEvents() != null && er.getExecutionHistory().getExecutionEvents().size()>0) { >- timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp(); >- } >+ if((er.getTest() != null)/* && (((er.getTest()).getName()) != null)*/) { >+ if (test instanceof TPFTestSuite) { >+ if (er.getExecutionHistory().getExecutionEvents()!=null && er.getExecutionHistory().getExecutionEvents().size()>0) { >+ timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp(); >+ String dateStamp = EventUtil.getTime(timestamp); >+ name += " ["+dateStamp+"]"; //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ //- add the link between execution and test suite. >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(test); >+ if (proxy != null) { >+ addBidirectionalReference("TestLog2TestSuite", (IReferencerProxyNode)proxy, "TestSuite2TestLog"); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ } else { >+ name += " [" + (er.getTest()).getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } > } > verdict = er.getVerdict().getValue(); > } >@@ -98,46 +102,9 @@ > } catch (NumberFormatException e) { > timestamp = 0L; > } >-// IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD); >-// LinkedList execChildren = new LinkedList(); >-// for (int i = 0; i < childrenMemento.length; i++) { >-// IMemento mementoChild = childrenMemento[i]; >-// //- inherit the TAG_URI_ROOT which is an extra data contained by the parent >-// mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT)); >-// String type = getType(); >-// if(type == null) { >-// throw new ProxyNeedToBeRebuiltException(); >-// } >-// ITypedElementProxyFactory factory = TypedElementFactoryManager.getInstance().getFactory(type); >-// if(factory instanceof IPersistableTypedElementProxyFactory) { >-// IProxyNode proxy = ((IPersistableTypedElementProxyFactory)factory).recreate(mementoChild, this); >-// if(proxy != null) { >-// execChildren.add(proxy); >-// } >-// } >-// } >-// children = (IProxyNode[]) execChildren.toArray(new IProxyNode[execChildren.size()]); > children = new IProxyNode[0]; > } > >-// /** >-// * @param event >-// * @param parent >-// */ >-// private void getEventChildren(TPFExecutionEvent event, List c, TPFExecutionResult parent) { >-// if ( event instanceof TPFInvocationEvent) { >-// TPFExecutionResult er = ((TPFInvocationEvent)event).getInvokedExecutionResult(); >-// if(er != null) { >-// c.add(new DefaultExecutionResultProxyNode(er, parent)); >-// } >-// } else { >-// Iterator iterator = event.getChildren().iterator(); >-// while (iterator.hasNext()) { >-// getEventChildren((TPFExecutionEvent) iterator.next(), c, parent); >-// } >-// } >-// } >- > public String getText() { > if (timestamp != 0L) { > if (cachedName == null) { >@@ -174,20 +141,14 @@ > return TestUIConstants.EXECUTION_RESULT_NODE; > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ > public boolean saveState(IMemento memento) { > //- data to retrieve the correct object > memento.putInteger(TAG_VERDICT, getVerdict()); > memento.putString(TAG_TIMESTAMP, Long.toString(timestamp)); >-// //- children (testcases) >-// for (int i = 0; i < children.length; i++) { >-// DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i]; >-// IMemento childMemento = memento.createChild(TestUIConstants.TAG_CHILD); >-// if(!child.saveState(childMemento)) { >-// return false; >-// } >-// } > return super.saveState(memento); > } >- >- > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java,v >retrieving revision 1.4 >diff -u -r1.4 FileProxyMetadataPersister.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java 2 May 2007 19:35:52 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 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,6 +26,7 @@ > import java.util.zip.GZIPOutputStream; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Platform; > import org.eclipse.hyades.test.ui.TestUIConstants; >@@ -43,6 +44,11 @@ > import org.eclipse.ui.XMLMemento; > import org.osgi.framework.Bundle; > >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ > public class FileProxyMetadataPersister implements IFileProxyPersister { > > private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$ >@@ -126,7 +132,9 @@ > if(factory != null) { > if(factory instanceof IPersistableFileProxyFactory) { > try { >- return ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent); >+ IProxyNode proxy = ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent); >+ Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$ >+ return proxy; > } catch (IllegalArgumentException e) { > //- problem encountered during load > return null; >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 ExecutionFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,14 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 > * @since 3.2 > */ > public class ExecutionFileProxyNode extends EMFResourceProxyNode { >@@ -36,8 +39,26 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.EXECUTION_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.EXECUTION_FILE_NODE; > } >- >+ > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyManager.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyManager.java,v >retrieving revision 1.27 >diff -u -r1.27 FileProxyManager.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyManager.java 17 Apr 2007 15:06:18 -0000 1.27 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyManager.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -13,19 +13,15 @@ > > import java.util.Collections; > import java.util.HashMap; >-import java.util.Iterator; > import java.util.Map; > > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.Platform; > import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; >-import org.eclipse.hyades.test.ui.navigator.IProxy; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class FileProxyManager implements IFileProxyManager { >@@ -119,25 +115,7 @@ > * @return a proxy node which has the given uid or <code>null</code> if there is no such proxy found in the complete given tree of proxy. > */ > public IProxyNode findProxyByID(IProxyNode proxy, String uid) { >- if(proxy == null) return proxy; >- //- only for root node that has no fragment part >- if(uid.length() > 0) { >- //- proxy found ? >- if(proxy.getIdentifier().equals(uid)) return proxy; >- else { >- //- search in its children array >- IProxyNode[] children = proxy.getChildren(); >- for (int i = 0; i < children.length; i++) { >- proxy = findProxyByID(children[i], uid); >- if(proxy != null) { >- //- found !! >- return proxy; >- } >- } >- //- not found in this sub tree >- return null; >- } >- } else return proxy; >+ return fileProxyNodeCache.findProxyByID(proxy, uid); > } > > /** >@@ -161,23 +139,7 @@ > * @return the proxy associated to the given object or <code>null</code> if such proxy node does not exist. > */ > public IProxyNode getCorrespondingProxy(Object object) { >- IProxy proxy; >- if (object instanceof IAdaptable) { >- proxy = (IProxy) ((IAdaptable)object).getAdapter(IProxy.class); >- } else { >- proxy = (IProxy) Platform.getAdapterManager().getAdapter(object, IProxy.class); >- } >- if (proxy != null) { >- IResource res = proxy.getUnderlyingResource(); >- if (res instanceof IFile) { >- IFile file = (IFile)res; >- IProxyNode fileProxy = getProxy(file, null); >- if (fileProxy != null) { >- return findProxyByID(fileProxy, proxy.getIdentifier()); >- } >- } >- } >- return null; >+ return fileProxyNodeCache.getCorrespondingProxy(object); > } > > /** >@@ -185,22 +147,11 @@ > * @param fileName name of the underlying resource of the searched proxy > * @param identifier identifier of the searched proxy > * @return a proxy node or <code>null</code> if not found. >+ * @deprecated use {@link #getCorrespondingProxy(new Proxy(fileName, String))} instead. > */ > public IProxyNode getCorrespondingProxy(String fileName, String identifier) { >- IProxyNode root = null; >- for (Iterator it = fileProxyNodeCache.filesIterator(); it.hasNext();) { >- IFile file = (IFile) it.next(); >- if(fileName.equals(file.getLocation().toOSString())) { >- //- since file is retrieve from the proxy cache, getProxy method will find the proxy in the cache. >- root = fileProxyNodeCache.getProxy(file); >- break; >- } >- } >- if(root != null) { >- return findProxyByID(root, identifier); >- } >- return null; >- } >+ return getCorrespondingProxy(new Proxy(fileName, identifier)); >+ } > > /** > * Returns the parent of the given proxy node. >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 LocationFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -15,11 +15,13 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class LocationFileProxyNode extends EMFResourceProxyNode { >@@ -35,8 +37,26 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_LOCATION); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.LOCATION_FILE_NODE; > } >- >+ > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java,v >retrieving revision 1.4 >diff -u -r1.4 TestSuiteFileProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java 28 Feb 2008 17:04:23 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -4,7 +4,7 @@ > * 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: TestSuiteFileProxyNode.java,v 1.4 2008/02/28 17:04:23 jkubasta Exp $ >+ * $Id: TestSuiteFileProxyNode.java,v 1.3 2006/12/15 17:05:48 jcanches Exp $ > * > * Contributors: > * IBM Corporation - initial API and implementation >@@ -15,11 +15,13 @@ > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.hyades.test.ui.TestUIConstants; > import org.eclipse.hyades.test.ui.TestUIImages; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class TestSuiteFileProxyNode extends EMFResourceProxyNode { >@@ -36,8 +38,26 @@ > return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_SUITE); > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTSUITE_FILE_NODE); >+ //- data from EMFResourceProxyNode >+ memento.putString(TestUIConstants.TAG_NAME, getText()); >+ IProxyNode [] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if(!saveChildState(memento, children[i])) { >+ return false; >+ } >+ } >+ return true; >+ } >+ > protected String getNodeKind() { > return TestUIConstants.TESTSUITE_FILE_NODE; > } >- >+ > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java,v >retrieving revision 1.4 >diff -u -r1.4 FileProxyMarkerPersister.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java 2 May 2007 19:35:52 -0000 1.4 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 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 >@@ -21,6 +21,7 @@ > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.WorkspaceJob; >+import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; >@@ -42,16 +43,23 @@ > import org.eclipse.ui.IMemento; > import org.eclipse.ui.XMLMemento; > >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ * >+ */ > public class FileProxyMarkerPersister implements IFileProxyPersister { > > private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$ > private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$ > private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$ >- private static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$ >+ public static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$ >+ > > private FileProxyMetadataPersister fallbackPersister = new FileProxyMetadataPersister(); > >- /* (non-Javadoc) >+ /* > * @see org.eclipse.hyades.test.ui.internal.navigator.proxy.IFileProxyPersister#loadProxy(org.eclipse.core.resources.IFile) > */ > public IProxyNode loadProxy(IFile file) { >@@ -99,7 +107,9 @@ > if(factory != null) { > if(factory instanceof IPersistableFileProxyFactory) { > try { >- return ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent); >+ IProxyNode proxy = ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent); >+ Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$ >+ return proxy; > } catch (IllegalArgumentException e) { > //- problem encountered during load > return null; >@@ -123,18 +133,19 @@ > } catch (IllegalArgumentException e) { > //- problem encountered during load > return null; >+ } catch (ProxyNeedToBeRebuiltException e) { >+ //- the factory encountered a problem retrieving information form memento. >+ //- this can be due to the fact that the persisted memento is an obsolete one. >+ return null; > } > } else { > //- saved marker contains id of a factory which can not recreate elements > UiPlugin.logError("The factory id: "+factoryID+" should be instanceof IPersistableTypedElementProxyFactory"); //$NON-NLS-1$//$NON-NLS-2$ > return null; > } >- } else { >- //- saved marker contains an unknown id of a factory >- UiPlugin.logError("The persisted proxy for file: "+file.getName()+" contains an unknown factory ID"); //$NON-NLS-1$//$NON-NLS-2$ >- return null; > } > } >+ return null; > } > > /* (non-Javadoc) >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EObjectProxyAdapterFactory.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EObjectProxyAdapterFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 EObjectProxyAdapterFactory.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EObjectProxyAdapterFactory.java 27 Oct 2006 18:59:09 -0000 1.3 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EObjectProxyAdapterFactory.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -12,7 +12,6 @@ > package org.eclipse.hyades.test.ui.internal.navigator.proxy; > > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.IAdapterFactory; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.resource.Resource; >@@ -26,31 +25,6 @@ > */ > public class EObjectProxyAdapterFactory implements IAdapterFactory { > >- private static class Proxy implements IProxy { >- >- private String identifier; >- private IResource underlyingResource; >- >- /** >- * @param identifier >- * @param underlyingResource >- */ >- public Proxy(IResource underlyingResource, String identifier) { >- super(); >- this.identifier = identifier; >- this.underlyingResource = underlyingResource; >- } >- >- public IResource getUnderlyingResource() { >- return underlyingResource; >- } >- >- public String getIdentifier() { >- return identifier; >- } >- >- } >- > /* (non-Javadoc) > * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) > */ >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java,v >retrieving revision 1.5 >diff -u -r1.5 LocationProxyNode.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java 28 Feb 2008 17:04:23 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java 13 Mar 2008 14:45:35 -0000 >@@ -21,6 +21,7 @@ > > /** > * @author jgout >+ * @version February 26, 2008 > * @since 3.2 > */ > public class LocationProxyNode extends CMNNamedElementProxyNode { >@@ -49,8 +50,18 @@ > return new IProxyNode[0]; > } > >+ public String getFactoryID() { >+ return EMFResourceProxyFactory.ID; >+ } >+ >+ public boolean saveState(IMemento memento) { >+ //- data to retrieve the correct object >+ memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_NODE); >+ return super.saveState(memento); >+ } >+ > protected String getNodeKind() { > return TestUIConstants.LOCATION_NODE; > } >- >+ > } >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyNodeCache.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyNodeCache.java,v >retrieving revision 1.14 >diff -u -r1.14 FileProxyNodeCache.java >--- src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyNodeCache.java 3 May 2007 01:10:50 -0000 1.14 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyNodeCache.java 13 Mar 2008 14:45:35 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 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 >@@ -27,14 +27,19 @@ > import org.eclipse.core.resources.IResourceDelta; > import org.eclipse.core.resources.IResourceDeltaVisitor; > import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.hyades.test.ui.UiPlugin; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator; > import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; > import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.SynchronizedAccess; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceRegistry; > import org.eclipse.hyades.test.ui.navigator.FileProxyNode; > import org.eclipse.hyades.test.ui.navigator.IFileProxyFactory; > import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxy; > import org.eclipse.hyades.test.ui.navigator.IProxyNode; > import org.eclipse.swt.graphics.Image; > import org.eclipse.ui.IMemento; >@@ -45,6 +50,7 @@ > * File proxy node cache manager.<br> > * This class is a singleton and is in charge of storing all file proxy nodes for all instances of FileProxyManager. > * @author jgout >+ * @version February 26, 2008 > * @since 4.2 > */ > public class FileProxyNodeCache extends SynchronizedAccess { >@@ -193,7 +199,23 @@ > return proxies.keySet().iterator(); > } > >+ /** >+ * Saves the given proxy if it is possible (if it is a <code>org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode</code>). >+ * @param proxy the proxy node to save. >+ */ >+ public void saveProxy(IProxyNode proxy) { >+ if (proxy instanceof IPersistableProxyNode) { >+ IPersistableProxyNode pProxy = (IPersistableProxyNode) proxy; >+ IResource underlyingResource = proxy.getUnderlyingResource(); >+ if (underlyingResource instanceof IFile) { >+ saveProxy((IFile)underlyingResource, pProxy); >+ } else { >+ UiPlugin.logWarning("Unable to save proxy because its underlying resource is not a file"); //$NON-NLS-1$ >+ } >+ } >+ } > >+ > /** > * Returns the proxy node associated to the given file.<br> > * If the proxy has already been built the same instance will be returned. >@@ -284,6 +306,7 @@ > //- use the unbounded parent marker instance as parent. > proxy = factory.create(file, unboundedParent); > if (proxy != null) { >+ Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$ > break; > } > } >@@ -321,6 +344,75 @@ > public void removeResourceListener(IResourceChangeListener listener) { > resourceListeners.remove(listener); > } >+ >+ /** Returns the proxy which has the given uid. This search starts from the given proxy node and cross its complete sub tree of proxies. >+ * >+ * @param proxy root of the proxy tree where the search is done. >+ * @param uid the uid of the searched proxy. >+ * @return a proxy node which has the given uid or <code>null</code> if there is no such proxy found in the complete given tree of proxy. >+ */ >+ public IProxyNode findProxyByID(IProxyNode proxy, String uid) { >+ if(proxy == null) return proxy; >+ //- only for root node that has no fragment part >+ if(uid.length() > 0) { >+ //- proxy found ? >+ if(proxy.getIdentifier().equals(uid)) return proxy; >+ else { >+ //- search in its children array >+ IProxyNode[] children = proxy.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ proxy = findProxyByID(children[i], uid); >+ if(proxy != null) { >+ //- found !! >+ return proxy; >+ } >+ } >+ //- not found in this sub tree >+ return null; >+ } >+ } else return proxy; >+ } >+ >+ /** >+ * Retrieves the node using its underlying resource and its identifier. >+ * @param fileName name of the underlying resource of the searched proxy >+ * @param identifier identifier of the searched proxy >+ * @return a proxy node or <code>null</code> if not found. >+ */ >+ public IProxyNode getCorrespondingProxy(String fileName, String identifier) { >+ return getCorrespondingProxy(new Proxy(fileName, identifier)); >+ } >+ >+ /** >+ * Retrieves the node associated to the given object. >+ * This parameter is adapted to a IProxy in order to retrieve the node >+ * representing it. >+ * >+ * @param object An object adaptable to IProxy. >+ * @return the proxy associated to the given object or <code>null</code> if such proxy node does not exist. >+ */ >+ public IProxyNode getCorrespondingProxy(Object object) { >+ IProxy proxy; >+ if (object instanceof IProxy) { >+ proxy = (IProxy) object; >+ } else if (object instanceof IAdaptable) { >+ proxy = (IProxy) ((IAdaptable)object).getAdapter(IProxy.class); >+ } else { >+ proxy = (IProxy) Platform.getAdapterManager().getAdapter(object, IProxy.class); >+ } >+ if (proxy != null) { >+ IResource res = proxy.getUnderlyingResource(); >+ if (res instanceof IFile) { >+ IFile file = (IFile)res; >+ IProxyNode fileProxy = getProxy(file); >+ if (fileProxy != null) { >+ return findProxyByID(fileProxy, proxy.getIdentifier()); >+ } >+ } >+ } >+ return null; >+ } >+ > > /** > * Invoked when a project is closed. This method cleans up the map and removes any >@@ -388,6 +480,9 @@ > IResource res = delta.getResource(); > if (res.getType() == IResource.FILE) { > FileProxyNodeCache.this.remove((IFile)res); >+ ReferenceRegistry.getInstance().removeReferences((IFile)res); >+ } else if(res.getType() == IResource.PROJECT){ >+ ReferenceRegistry.getInstance().removeProjectReferenceRegistry((IProject)res); > } else { > return true; > } >Index: src/org/eclipse/hyades/test/ui/forms/editor/BaseFormEditor.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/forms/editor/BaseFormEditor.java,v >retrieving revision 1.10 >diff -u -r1.10 BaseFormEditor.java >--- src/org/eclipse/hyades/test/ui/forms/editor/BaseFormEditor.java 22 Mar 2007 14:42:14 -0000 1.10 >+++ src/org/eclipse/hyades/test/ui/forms/editor/BaseFormEditor.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -220,7 +220,7 @@ > */ > protected EObject getFileContent(IFile file) > { >- cachedURI = URI.createPlatformResourceURI(file.getFullPath().toString()); >+ cachedURI = URI.createPlatformResourceURI(file.getFullPath().toString(),false); > return getFileContent(cachedURI); > } > >@@ -514,7 +514,7 @@ > // Bugzilla_152218 preserve the selection after reload. > String fragment = null; > IStructuredSelection structuredSelection = (IStructuredSelection)getSelection(); >- if(structuredSelection.size() == 1) >+ if(structuredSelection != null && structuredSelection.size() == 1) > { > Object selection = structuredSelection.getFirstElement(); > if(selection instanceof EObject) >Index: schema/testNavigatorPasteExtension.exsd >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/schema/testNavigatorPasteExtension.exsd,v >retrieving revision 1.4 >diff -u -r1.4 testNavigatorPasteExtension.exsd >--- schema/testNavigatorPasteExtension.exsd 29 Feb 2008 04:13:26 -0000 1.4 >+++ schema/testNavigatorPasteExtension.exsd 13 Mar 2008 14:45:34 -0000 >@@ -11,6 +11,14 @@ > </annotation> > > <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element deprecated="true"/> >+ </appInfo> >+ <documentation> >+ deprecated : for specific paste behavior on proxy node, implement IProxyNodePaster interface instead >+ </documentation> >+ </annotation> > <complexType> > <sequence> > <element ref="paster" minOccurs="1" maxOccurs="unbounded"/> >Index: src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIStatus.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIStatus.java,v >retrieving revision 1.1 >diff -u -r1.1 RenamerUIStatus.java >--- src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIStatus.java 9 Jun 2005 09:34:10 -0000 1.1 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIStatus.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -31,6 +31,8 @@ > * > * @author jgout > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated this class is no longer needed > */ > public class RenamerUIStatus { > >Index: src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIOk.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIOk.java,v >retrieving revision 1.2 >diff -u -r1.2 RenamerUIOk.java >--- src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIOk.java 9 Jun 2005 09:34:10 -0000 1.2 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIOk.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -15,6 +15,8 @@ > /** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the ok button. > * @author jgout > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated this class is no longer needed > */ > public class RenamerUIOk extends RenamerUIStatus { > >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer.java,v >retrieving revision 1.5 >diff -u -r1.5 IProxyNodeRenamer.java >--- src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer.java 2 May 2007 19:35:47 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -17,6 +17,8 @@ > * > * @author jgout > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated client should use IProxyNodeRenamer2 instead. > */ > public interface IProxyNodeRenamer { > >Index: src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUICancel.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUICancel.java,v >retrieving revision 1.2 >diff -u -r1.2 RenamerUICancel.java >--- src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUICancel.java 9 Jun 2005 09:34:10 -0000 1.2 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUICancel.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -15,6 +15,8 @@ > /** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the cancel button. > * @author jgout > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated this class is no longer needed > */ > public class RenamerUICancel extends RenamerUIStatus { > >Index: src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIInlineEditor.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIInlineEditor.java,v >retrieving revision 1.2 >diff -u -r1.2 RenamerUIInlineEditor.java >--- src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIInlineEditor.java 9 Jun 2005 09:34:10 -0000 1.2 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIInlineEditor.java 13 Mar 2008 14:45:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >+ * Copyright (c) 2005-2008 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 >@@ -15,6 +15,8 @@ > /** This class is returned by IProxyNodeRenamer.performUserInteraction() when the default rename UI should be used. > * @author jgout > * @since 3.3 >+ * @version February 26, 2008 >+ * @deprecated this class is no longer needed > */ > public class RenamerUIInlineEditor extends RenamerUIStatus { > >Index: src/org/eclipse/hyades/test/ui/forms/actions/OpenJavaScriptAction.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/forms/actions/OpenJavaScriptAction.java,v >retrieving revision 1.5 >diff -u -r1.5 OpenJavaScriptAction.java >--- src/org/eclipse/hyades/test/ui/forms/actions/OpenJavaScriptAction.java 3 May 2006 16:39:48 -0000 1.5 >+++ src/org/eclipse/hyades/test/ui/forms/actions/OpenJavaScriptAction.java 13 Mar 2008 14:45:34 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 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 >@@ -18,9 +18,9 @@ > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.hyades.loaders.util.RegistryReader; >-import org.eclipse.hyades.log.ui.internal.navigator.EMFUtil; > import org.eclipse.hyades.models.common.common.CMNExtendedProperty; > import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent; >+import org.eclipse.hyades.test.core.util.EMFUtil; > import org.eclipse.hyades.test.core.util.JavaUtil; > import org.eclipse.hyades.test.ui.UiPlugin; > import org.eclipse.hyades.test.ui.forms.extensions.IEventAction; >@@ -80,26 +80,26 @@ > * This property is optional for this action. When value not available, the project of the current > * selected execution history will be used. > */ >- public static String propNamejavaProject = "javaProjectName"; >+ public static String propNamejavaProject = "javaProjectName"; //$NON-NLS-1$ > /** > * Property name for fully qualified class name of your java script used in {@link TPFExecutionEvent#getProperties()}. > * Should make it your own property name generated by your test runner. > * This property is required by this action. > */ >- public static String propNameJavaClass = "qualifiedJavaClassName"; >+ public static String propNameJavaClass = "qualifiedJavaClassName";//$NON-NLS-1$ > /** > * Property name for line number in the java script used in {@link TPFExecutionEvent#getProperties()}. > * Should make it your own property name generated by your test runner. > * This property is optional for this action. When value not available, the first line will be highlighted. > */ >- public static String propNameLineNumber = "javaClassLineNumber"; >+ public static String propNameLineNumber = "javaClassLineNumber";//$NON-NLS-1$ > > private static boolean isRCP = false; > private TPFExecutionEvent executionEvent; > private String javaProject = null, javaClassName = null, javaClassLineNumber = null; > > /** >- * Default constructor which takes no arguements. This is necessary for extension instantiation. >+ * Default constructor which takes no arguments. This is necessary for extension instantiation. > */ > public OpenJavaScriptAction() { > setEnabled(false); >@@ -197,11 +197,11 @@ > int innerClassSeparater = qualifiedJavaClassName.indexOf('$'); > if(innerClassSeparater > -1) > className = qualifiedJavaClassName.substring(0, innerClassSeparater); >- else if(qualifiedJavaClassName.endsWith(".java")) >+ else if(qualifiedJavaClassName.endsWith(".java"))//$NON-NLS-1$ > className = qualifiedJavaClassName.substring(0, qualifiedJavaClassName.length() - 5); > if(className.indexOf('.') > -1) > cuName = className.substring(className.lastIndexOf('.') + 1, className.length()); >- cuName = cuName + ".java"; >+ cuName = cuName + ".java";//$NON-NLS-1$ > > int line = 1; > if(lineNumber != null) >Index: src/org/eclipse/hyades/test/ui/UiPlugin.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/UiPlugin.java,v >retrieving revision 1.43 >diff -u -r1.43 UiPlugin.java >--- src/org/eclipse/hyades/test/ui/UiPlugin.java 11 Mar 2008 18:13:15 -0000 1.43 >+++ src/org/eclipse/hyades/test/ui/UiPlugin.java 13 Mar 2008 14:45:34 -0000 >@@ -381,6 +381,19 @@ > Status status = new Status(IStatus.INFO, getID(), 0, text, new Throwable(text)); > instance.getLog().log(status); > } >+ >+ public static void logWarning(String text) >+ { >+ Status status = new Status(IStatus.WARNING, getID(), 0, text, new Throwable(text)); >+ instance.getLog().log(status); >+ } >+ >+ public static void logWarning(String text, Throwable throwable) >+ { >+ Status status = new Status(IStatus.WARNING, getID(), 0, text, throwable); >+ instance.getLog().log(status); >+ } >+ > // TestGen info > public static String getPreference(String key) > { >Index: src/org/eclipse/hyades/test/ui/TestUIConstants.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/TestUIConstants.java,v >retrieving revision 1.9 >diff -u -r1.9 TestUIConstants.java >--- src/org/eclipse/hyades/test/ui/TestUIConstants.java 28 Feb 2008 14:21:08 -0000 1.9 >+++ src/org/eclipse/hyades/test/ui/TestUIConstants.java 13 Mar 2008 14:45:34 -0000 >@@ -12,6 +12,9 @@ > package org.eclipse.hyades.test.ui; > > /** >+ * Constants storage interface >+ * @author jgout, jBozier >+ * @version February 26, 2008 > * Constants storage interface. > * <p> > * >@@ -29,17 +32,17 @@ > public static final String TEST_PERSPECTIVE_ID = "org.eclipse.hyades.ui.perspective.TestPerspective"; > > /** >- * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path >+ * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path > */ > public static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$ > public static final String TAG_NODE_KIND = "nodeKind"; //$NON-NLS-1$ > /** >- * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path >+ * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path > */ > public static final String TAG_NAME = "name"; //$NON-NLS-1$ > public static final String TAG_TYPE = "type"; //$NON-NLS-1$ > /** >- * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path >+ * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path > */ > public static final String TAG_URI = "uri"; //$NON-NLS-1$ > /** >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/plugin.xml,v >retrieving revision 1.82 >diff -u -r1.82 plugin.xml >--- plugin.xml 11 Mar 2008 18:13:16 -0000 1.82 >+++ plugin.xml 13 Mar 2008 14:45:34 -0000 >@@ -33,6 +33,8 @@ > <extension-point id="testNavigatorTestAssetGroupProxy" name="%testNavigatorTestAssetGroupProxy" schema="schema/testNavigatorTestAssetGroupProxy.exsd"/> > <extension-point id="testLogSearchProvider" name="%TestLogSearchProvider" schema="schema/testLogSearchProvider.exsd"/> > <extension-point id="testLogRecordRepositoryProvider" name="%TestLogRecordRepositoryProvider" schema="schema/testLogRecordRepositoryProvider.exsd"/> >+ <extension-point id="testNavigatorReferenceTypes" name="org.eclipse.hyades.test.ui.testNavigatorReferenceTypes" schema="schema/testNavigatorReferenceTypes.exsd"/> >+ <extension-point id="testNavigatorRefactoringTransactions" name="Test Navigator Refactoring Transactions" schema="schema/testNavigatorRefactoringTransactions.exsd"/> > > <extension point="org.eclipse.help.contexts"> > <contexts file="infopop\hyadesUI.xml" plugin ="org.eclipse.hyades.ui"/> >@@ -669,7 +671,7 @@ > point="org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory"> > <factory > class="org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory" >- id="EMFResourceProxyFactory"/> >+ id="EMFResourceProxyFactory_4.3"/> > <factory > class ="org.eclipse.hyades.test.ui.internal.navigator.proxy.NonEMFResourceProxyFactory" > id="NonEMFResourceProxyFactory"/> >@@ -681,25 +683,25 @@ > factoryID="NonEMFResourceProxyFactory"/> > <file > extension="datapool" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="location" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="artifact" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="deploy" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="testcomponent" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="testsuite" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > <file > extension="execution" >- factoryID="EMFResourceProxyFactory"/> >+ factoryID="EMFResourceProxyFactory_4.3"/> > </extension> > <extension > id="proxyStateMarker" >@@ -732,12 +734,8 @@ > point="org.eclipse.hyades.test.ui.testNavigatorPasteExtension"> > <paster > target="org.eclipse.core.resources.IContainer" >- class="org.eclipse.hyades.test.ui.internal.navigator.action.FileFolderInContainerPaste" >- strict="false"/> >- <paster >- class="org.eclipse.hyades.test.ui.internal.navigator.action.FileProxyInContainerPaste" >- target="org.eclipse.core.resources.IContainer" >- strict="false"/> >+ class="org.eclipse.hyades.test.ui.internal.navigator.action.FileAndFolderPaster" >+ strict="false"/> > </extension> > <extension > point="org.eclipse.ui.popupMenus"> >@@ -799,6 +797,11 @@ > adaptableType="org.eclipse.emf.ecore.EObject"> > <adapter type="org.eclipse.hyades.test.ui.navigator.IProxy"/> > </factory> >+ <factory >+ adaptableType="org.eclipse.hyades.test.ui.navigator.IProxyNode" >+ class="org.eclipse.hyades.test.ui.internal.navigator.proxy.IProxyNodeAdapterFactory"> >+ <adapter type="org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter"/> >+ </factory> > </extension> > <extension > point="org.eclipse.ui.importWizards"> >@@ -914,6 +917,87 @@ > </actionSet> > </extension> > <extension >+ point="org.eclipse.hyades.test.ui.testNavigatorReferenceTypes"> >+ <type >+ id="TestSuite2TestLog" >+ isExplicit="false" >+ name="%TestSuite2TestLog_NAME" >+ oppositeReferenceTypeId="TestLog2TestSuite" >+ owns="true"/> >+ <type >+ id="TestLog2TestSuite" >+ isExplicit="true" >+ name="%TestLog2TestSuite_NAME" >+ oppositeReferenceTypeId="TestSuite2TestLog" >+ owns="false"/> >+ <type >+ id="TestInvoker2TestInvoked" >+ isExplicit="true" >+ name="%TestInvoker2TestInvoked_NAME" >+ oppositeReferenceTypeId="TestInvoked2TestInvoker" >+ owns="false"/> >+ <type >+ id="TestInvoked2TestInvoker" >+ isExplicit="false" >+ name="%TestInvoked2TestInvoker_NAME" >+ oppositeReferenceTypeId="TestInvoker2TestInvoked" >+ owns="false"/> >+ <type >+ id="Test2Datapool" >+ isExplicit="true" >+ name="%Test2Datapool_NAME" >+ oppositeReferenceTypeId="Datapool2Test" >+ owns="false"/> >+ <type >+ id="Datapool2Test" >+ isExplicit="false" >+ name="%Datapool2Test_NAME" >+ oppositeReferenceTypeId="Test2Datapool" >+ owns="false"/> >+ <type >+ id="Artifact2Test" >+ isExplicit="true" >+ name="%Artifact2Test_NAME" >+ oppositeReferenceTypeId="Test2Artifact" >+ owns="false"/> >+ <type >+ id="Test2Artifact" >+ isExplicit="false" >+ name="%Test2Artifact_NAME" >+ oppositeReferenceTypeId="Artifact2Test" >+ owns="false"/> >+ <type >+ id="Deploy2Artifact" >+ isExplicit="true" >+ name="%Deploy2Artifact_NAME" >+ oppositeReferenceTypeId="Artifact2Deploy" >+ owns="false"/> >+ <type >+ id="Artifact2Deploy" >+ isExplicit="false" >+ name="%Artifact2Deploy_NAME" >+ oppositeReferenceTypeId="Deploy2Artifact" >+ owns="false"/> >+ <type >+ id="Deploy2Location" >+ isExplicit="true" >+ name="%Deploy2Location_NAME" >+ oppositeReferenceTypeId="Location2Deploy" >+ owns="false"/> >+ <type >+ id="Location2Deploy" >+ isExplicit="false" >+ name="%Location2Deploy_NAME" >+ oppositeReferenceTypeId="Deploy2Location" >+ owns="false"/> >+ </extension> >+ <extension >+ point="org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions"> >+ <transaction >+ class="org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction" >+ domainId="org.eclipse.hyades.test.ui.EMFRefactoringTransaction"/> >+ </extension> >+ <extension > point="org.eclipse.hyades.test.ui.executionHistoryExtension"> > <verdictProvider > provider="org.eclipse.hyades.test.ui.forms.extensions.provisional.TPTPVerdictCategoryProvider" >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/plugin.properties,v >retrieving revision 1.84 >diff -u -r1.84 plugin.properties >--- plugin.properties 11 Mar 2008 18:13:16 -0000 1.84 >+++ plugin.properties 13 Mar 2008 14:45:33 -0000 >@@ -141,6 +141,45 @@ > > NewRecordingWizardPage.TITLE = Create New Test From Recording > >+RecLocationWizardPage.TITLE = Select Location For Recording >+RecLocationWizardPage.DESCRIPTION=Select existing recording from which to create a test. >+RecLocationWizardPage.FILENAME_LABEL=&Recording file name: >+ >+TestsuiteLocationWizardPage.TITLE = Select Location For Test Suite >+TestsuiteLocationWizardPage.DESCRIPTION=Select project and file name for test >+TestsuiteLocationWizardPage.FILENAME_LABEL=&Test file name: >+ >+DefaultRecWizardProvider.FILES_EXIST_TITLE=Warning >+DefaultRecWizardProvider.TESTSUITE_EXISTS=The generated test already exists and will be overwritten. Proceed? >+DefaultRecWizardProvider.REC_EXISTS=The trace file already exists and will be overwritten. Proceed? >+DefaultRecWizardProvider.BOTH_EXIST=Both the trace file and generated test already exist and will be overwritten. Proceed? >+ >+RecorderClientUI.INIT_JOB = Initializing Recorder... >+RecorderClientUI.RECORDING_ABORTED_DUE_TO_EXCEPTION_MESSAGE=IWAT3042E recording aborted due to exception: >+ >+showAdvanced = &Advanced >> >+hideAdvanced = << &Advanced >+ >+TEST_FROM_RECORDING = Test From Recording >+GENERIC_RECORDING = Generic Recording >+GENERIC_RECORDING_ACTION_SET = Action Set for Generic Recording Framework >+GEN_RECORDER_TOOLTIP = Create a Test From Recording >+ >+W_NAME = Name >+W_DESCRIPTION = Description >+ >+TestSuite2TestLog_NAME=Associated Test Logs >+TestLog2TestSuite_NAME=Source Test Suite >+TestInvoker2TestInvoked_NAME=Invoked tests >+TestInvoked2TestInvoker_NAME=Test Invocations >+Test2Datapool_NAME=Associated Datapools >+Datapool2Test_NAME=Associated Tests >+Artifact2Test_NAME=Associated Tests >+Test2Artifact_NAME=Associated Artifacts >+Deploy2Artifact_NAME=Associated Artifacts >+Artifact2Deploy_NAME=Associated Deployments >+Deploy2Location_NAME=Associated Locations >+Location2Deploy_NAME=Associated Deployments# Add support for importing test log files > # Add support for importing test log files > TEST_LOG_FILE= Test Log File > IMP_TEST_LOG_DSC= Import a test log file from the local file system into the workspace. >Index: src/org/eclipse/hyades/test/ui/navigator/IRefactoringTransaction.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/IRefactoringTransaction.java >diff -N src/org/eclipse/hyades/test/ui/navigator/IRefactoringTransaction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/IRefactoringTransaction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Some refactoring operations need to perform its change in a global context. >+ * This interface allows to declare contexts for grouping refactoring change. >+ * This interface is used in the extension point >+ * <code>org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions</code>. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IRefactoringTransaction { >+ >+ /** >+ * Starts the refactoring transaction. >+ * Implementors can use this method to initialize internal data. >+ * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired. >+ */ >+ public void beginChanges(IProgressMonitor pm); >+ >+ /** >+ * Method called if the transaction is cancelled. >+ * Implementors can use this method to dispose internal data. >+ * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired. >+ */ >+ public void cancelChanges(IProgressMonitor pm); >+ >+ /** >+ * Performs changes. >+ * @return the undo change that is composed of all committed changes or <code>null</code> if undo change is not possible. >+ * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired. >+ * @throws <code>CoreException</code> if the operation failed. >+ */ >+ public Change commitChanges(IProgressMonitor pm) throws CoreException; >+} >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeUpdater.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeUpdater.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeUpdater.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeUpdater.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Interface that allows to describe the update behavior of a proxy node. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IProxyNodeUpdater { >+ >+ /** >+ * Returns the refactoring change when an instance need to be updated according the move/delete of a referencer proxy node. >+ * The given context can be used if the local change cannot be perform without a global context. >+ * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect >+ * data. Such refactoring transaction will performed changes in one time. >+ * The destination path can be <code>null</code>, this means that this instance need to be updated according to the deletion of the given <code>referencer</code>. >+ * For instance a test can update its state when one of its invoked test is deleted. >+ * >+ * @param context a context that contains all IRefactoringTransaction instances defined by clients. >+ * @param referencer the proxy node that has changed and implies the update of this instance. (<code>referencer.getReferences(refType).contains(this) == true</code>) >+ * @param refType the type of the reference between this instance and <code>referencer</code>. >+ * @param newPath the destination path of this proxy node. This parameter is <code>null</code> when the reason of the update is a delete. >+ * @return the change that performs the update of instance following a move of a reference to itself. >+ */ >+ public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referencer, String refType, IPath destinationPath); >+ >+ /** >+ * Returns the refactoring change when an instance need to be updated according the change of its container. >+ * The given context can be used if the local change cannot be perform without a global context. >+ * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect >+ * data. Such refactoring transaction will performed changes in one time. >+ * >+ * @param context a context that contains all IRefactoringTransaction instances defined by clients. >+ * @param container the container that has changed and that implies the update of this instance. >+ * @param destinationPath the new path of the instance. >+ * @return the change that performs the update of instance following a rename of the given container to the given path. >+ */ >+ public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath); >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeMover.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeMover.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeMover.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeMover.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/********************************************************************** >+ * Copyright (c) 20062008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Interface that allows to describe the move behavior of a proxy node. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IProxyNodeMover { >+ >+ /** >+ * Returns the refactoring change when moving this instance to the new destination path. >+ * The given context can be used if the local change cannot be perform without a global context. >+ * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect >+ * data. Such refactoring transaction will performed changes in one time. >+ * >+ * @param context a context that contains all IRefactoringTransaction instances defined by clients. >+ * @param newPath the destination path of this proxy node. >+ * @return the change that performs the move of the proxy node to the given destination path. >+ */ >+ public Change createMoveChange(IRefactoringContext context, IPath destinationPath); >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoringWizard.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoringWizard.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoringWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoringWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizard; >+ >+/** >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class PasteRefactoringWizard extends RefactoringWizard { >+ >+ public PasteRefactoringWizard(Refactoring refactoring,Object selected) { >+ super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE); >+ >+ PasteRefactoring ref = (PasteRefactoring) getRefactoring(); >+ ref.setDestination((IContainer)selected); >+ >+ } >+ >+ protected void addUserInputPages() { >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceRegistry.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceRegistry.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,204 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import java.util.Collection; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ISaveContext; >+import org.eclipse.core.resources.ISaveParticipant; >+import org.eclipse.core.resources.ISavedState; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.hyades.test.ui.UiPlugin; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class ReferenceRegistry implements ISaveParticipant { >+ >+ private static ReferenceRegistry instance; >+ private Map projectRegistries; >+ private IReferenceRegistrySavedState internalSavedState; >+ >+ private class SavedState implements IReferenceRegistrySavedState { >+ private ISavedState savedState; >+ public SavedState(ISavedState state) { >+ savedState = state; >+ } >+ public IPath lookup(IPath path) { >+ return savedState.lookup(path); >+ } >+ } >+ >+ public static ReferenceRegistry getInstance() { >+ if(instance == null) { >+ instance = new ReferenceRegistry(); >+ } >+ return instance; >+ } >+ >+ private ReferenceRegistry() { >+ projectRegistries = new HashMap(); >+ try { >+ ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant(UiPlugin.getDefault(), this); >+ this.internalSavedState = (lastState != null) ? new SavedState(lastState) : null; >+ } catch (CoreException e) { >+ //- unable to retrieve the previous saved state, start with empty state. >+ } >+ } >+ >+ private ProjectReferenceRegistry getRegistry(IFile referencer) { >+ IProject project = referencer.getProject(); >+ if (project.isAccessible()) { >+ return getProjectReferenceRegistry(project); >+ } >+ return null; >+ } >+ >+ public ProjectReferenceRegistry getProjectReferenceRegistry(IProject project) { >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry)this.projectRegistries.get(project); >+ if (registry == null) { >+ //- Not initialized yet >+ registry = new ProjectReferenceRegistry(project, this.internalSavedState); >+ this.projectRegistries.put(project, registry); >+ } >+ return registry; >+ } >+ >+ public void removeProjectReferenceRegistry(IProject project) { >+ projectRegistries.remove(project); >+ } >+ >+ public void addReference(IFile referencer, String refType, IFile referenced) { >+ ProjectReferenceRegistry registry = getRegistry(referencer); >+ if (registry != null) { >+ registry.addReference(referencer, refType, referenced); >+ } >+ } >+ >+ public void addBidirectionalReference(IFile referencer, String refType, IFile referenced, String oppositeRefType) { >+ ProjectReferenceRegistry registryReferencer = getRegistry(referencer); >+ ProjectReferenceRegistry registryReferenced = getRegistry(referenced); >+ if (registryReferencer != null) { >+ registryReferencer.addReference(referencer, refType, referenced); >+ } >+ if (registryReferenced != null) { >+ registryReferenced.addReference(referenced, oppositeRefType, referencer); >+ } >+ } >+ >+ public void removeReference(IFile referencer, IFile referenced) { >+ ProjectReferenceRegistry registry = getRegistry(referencer); >+ if (registry != null) { >+ registry.removeReference(referencer, referenced); >+ } >+ } >+ >+ public Collection getReferences(IFile referencer, String refType) { >+ ProjectReferenceRegistry registry = getRegistry(referencer); >+ if (registry != null) { >+ return registry.getReferences(referencer, refType); >+ } >+ return Collections.EMPTY_LIST; >+ } >+ >+ public Set getReferenceTypes(IFile referencer) { >+ ProjectReferenceRegistry registry = getRegistry(referencer); >+ if (registry != null) { >+ return registry.getReferenceTypes(referencer); >+ } >+ return Collections.EMPTY_SET; >+ } >+ >+ //- Persistence methods, delegation to project focused registries >+ >+ public void doneSaving(ISaveContext context) { >+ if (context.getKind() == ISaveContext.PROJECT_SAVE) { >+ IProject project = context.getProject(); >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry)projectRegistries.get(project); >+ if (registry != null) { >+ registry.doneSaving(context); >+ } >+ } else { >+ Iterator it = projectRegistries.values().iterator(); >+ while (it.hasNext()) { >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next(); >+ registry.doneSaving(context); >+ } >+ } >+ } >+ >+ public void prepareToSave(ISaveContext context) throws CoreException { >+ if (context.getKind() == ISaveContext.PROJECT_SAVE) { >+ IProject project = context.getProject(); >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry)projectRegistries.get(project); >+ if (registry != null) { >+ registry.prepareToSave(context); >+ } >+ } else { >+ Iterator it = projectRegistries.values().iterator(); >+ while (it.hasNext()) { >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next(); >+ registry.prepareToSave(context); >+ } >+ } >+ } >+ >+ public void rollback(ISaveContext context) { >+ if (context.getKind() == ISaveContext.PROJECT_SAVE) { >+ IProject project = context.getProject(); >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry)projectRegistries.get(project); >+ if (registry != null) { >+ registry.rollback(context); >+ } >+ } else { >+ Iterator it = projectRegistries.values().iterator(); >+ while (it.hasNext()) { >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next(); >+ registry.rollback(context); >+ } >+ } >+ } >+ >+ public void saving(ISaveContext context) throws CoreException { >+ if (context.getKind() == ISaveContext.PROJECT_SAVE) { >+ IProject project = context.getProject(); >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry)projectRegistries.get(project); >+ if (registry != null) { >+ registry.saving(context); >+ } >+ } else { >+ Iterator it = projectRegistries.values().iterator(); >+ while (it.hasNext()) { >+ ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next(); >+ registry.saving(context); >+ } >+ } >+ } >+ >+ public void removeReferences(IFile referencer) { >+ ProjectReferenceRegistry registry = getRegistry(referencer); >+ if (registry != null) { >+ registry.removeReferences(referencer); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoringWizard.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoringWizard.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoringWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoringWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,162 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Collection; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizard; >+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.ui.model.BaseWorkbenchContentProvider; >+import org.eclipse.ui.model.WorkbenchLabelProvider; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class MoveRefactoringWizard extends RefactoringWizard { >+ >+ private static class MoveRefactoringInputPage extends UserInputWizardPage { >+ private MoveRefactoring refactoring; >+ private TreeViewer viewer; >+ >+ public MoveRefactoringInputPage(Refactoring ref) { >+ super(""); //$NON-NLS-1$ >+ this.refactoring = (MoveRefactoring) ref; >+ } >+ >+ public void createControl(Composite parent) { >+ initializeDialogUnits(parent); >+ Composite result= new Composite(parent, SWT.NONE); >+ setControl(result); >+ result.setLayout(new GridLayout()); >+ >+ addLabel(result); >+ viewer = createViewer(result); >+ expandSelectionContainer(); >+ viewer.addSelectionChangedListener(new ISelectionChangedListener(){ >+ public void selectionChanged(SelectionChangedEvent event) { >+ MoveRefactoringInputPage.this.viewerSelectionChanged(event); >+ } >+ }); >+ Dialog.applyDialogFont(result); >+ } >+ >+ private void expandSelectionContainer() { >+ Collection containers = refactoring.getContainers(); >+ Collection proxies = refactoring.getProxies(); >+ Collection parents = new HashSet(); >+ for (Iterator it = containers.iterator(); it.hasNext();) { >+ parents.add(((IContainer) it.next()).getParent()); >+ } >+ for (Iterator it = proxies.iterator(); it.hasNext();) { >+ parents.add(((IProxyNode) it.next()).getUnderlyingResource().getParent()); >+ } >+ for (Iterator it = parents.iterator(); it.hasNext();) { >+ viewer.expandToLevel(it.next(), 0); >+ } >+ } >+ >+ protected Control addLabel(Composite parent) { >+ Label label= new Label(parent, SWT.NONE); >+ String text; >+ int containers= refactoring.getContainers().size(); >+ int proxies= refactoring.getProxies().size(); >+ >+ if (containers == 0 && proxies == 1) { >+ text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_SINGLE, ((IProxyNode)refactoring.getProxies().get(0)).getText()); >+ } else if (containers == 1 && proxies == 0) { >+ text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_SINGLE, ((IResource)refactoring.getContainers().get(0)).getName()); >+ } else { >+ text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_MULTI, String.valueOf(containers + proxies)); >+ } >+ label.setText(text); >+ label.setLayoutData(new GridData(SWT.BEGINNING, SWT.END, false, false)); >+ return label; >+ } >+ >+ private TreeViewer createViewer(Composite parent) { >+ TreeViewer treeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ GridData gd= new GridData(GridData.FILL_BOTH); >+ gd.widthHint= convertWidthInCharsToPixels(40); >+ gd.heightHint= convertHeightInCharsToPixels(15); >+ treeViewer.getTree().setLayoutData(gd); >+ BaseWorkbenchContentProvider provider = new BaseWorkbenchContentProvider() { >+ public Object[] getChildren(Object element) { >+ Object[] children = super.getChildren(element); >+ List resChildren = new LinkedList(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof IContainer) { >+ resChildren.add(children[i]); >+ } >+ } >+ return resChildren.toArray(); >+ } >+ }; >+ treeViewer.setLabelProvider(new WorkbenchLabelProvider()); >+ treeViewer.setContentProvider(provider); >+ treeViewer.setSorter(null); >+ treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); >+ return treeViewer; >+ } >+ >+ private void viewerSelectionChanged(SelectionChangedEvent event) { >+ ISelection selection= event.getSelection(); >+ if (!(selection instanceof IStructuredSelection)) >+ return; >+ IStructuredSelection sel= (IStructuredSelection)selection; >+ setPageComplete(verifyDestination(sel.getFirstElement())); >+ } >+ >+ protected RefactoringStatus verifyDestination(Object selected) { >+ RefactoringStatus refactoringStatus = new RefactoringStatus(); >+ if (selected instanceof IContainer) >+ refactoring.setDestination((IContainer)selected); >+ else { >+ refactoringStatus= RefactoringStatus.createFatalErrorStatus(RefactoringMessages.MOVE_ERROR); >+ } >+ return refactoringStatus; >+ } >+ >+ } >+ >+ public MoveRefactoringWizard(Refactoring refactoring) { >+ super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE); >+ } >+ >+ protected void addUserInputPages() { >+ MoveRefactoringInputPage page = new MoveRefactoringInputPage(getRefactoring()); >+ addPage(page); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringContext.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringContext.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class RefactoringContext implements IRefactoringTransaction, IRefactoringContext { >+ //- internal storage (domainId, IConfigurationElement) >+ private static Map knownTransactions; >+ //- loaded transaction for this instance (domainId, IRefactoringTransaction) >+ private Map transactions; >+ >+ static { >+ knownTransactions = new HashMap(); >+ } >+ >+ public RefactoringContext() { >+ transactions = new HashMap(); >+ } >+ >+ public void beginChanges(IProgressMonitor pm) { >+ pm.beginTask("", transactions.values().size()); //$NON-NLS-1$ >+ try { >+ for (Iterator it = transactions.values().iterator(); it.hasNext();) { >+ IRefactoringTransaction transaction = (IRefactoringTransaction) it.next(); >+ transaction.beginChanges(new SubProgressMonitor(pm, 1)); >+ } >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public void cancelChanges(IProgressMonitor pm) { >+ pm.beginTask("", transactions.values().size()); //$NON-NLS-1$ >+ try { >+ for (Iterator it = transactions.values().iterator(); it.hasNext();) { >+ IRefactoringTransaction transaction = (IRefactoringTransaction) it.next(); >+ transaction.cancelChanges(new SubProgressMonitor(pm, 1)); >+ } >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public Change commitChanges(IProgressMonitor pm) throws CoreException { >+ CompositeChange c = new CompositeChange(""); //$NON-NLS-1$ >+ pm.beginTask("", transactions.values().size()); //$NON-NLS-1$ >+ try { >+ for (Iterator it = transactions.values().iterator(); it.hasNext();) { >+ IRefactoringTransaction transaction = (IRefactoringTransaction) it.next(); >+ c.add(transaction.commitChanges(new SubProgressMonitor(pm, 1))); >+ } >+ return c; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public IRefactoringTransaction getRefactoringTransaction(String domainId) { >+ IRefactoringTransaction t = (IRefactoringTransaction) transactions.get(domainId); >+ if (t != null) { >+ return t; >+ } else { >+ //- need to load from internal storage >+ try { >+ t = internalGetRefactoringTransaction(domainId); >+ if (t != null) { >+ //- save this transaction in this instance. >+ transactions.put(domainId, t); >+ return t; >+ } >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ } >+ return null; >+ } >+ } >+ >+ private static IRefactoringTransaction internalGetRefactoringTransaction(String domainId) throws CoreException { >+ IConfigurationElement e = (IConfigurationElement)knownTransactions.get(domainId); >+ if(e == null) { >+ //- need to load from extension points. >+ IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(UiPlugin.getID() + ".testNavigatorRefactoringTransactions"); //$NON-NLS-1$ >+ if (extPoint != null) { >+ IConfigurationElement[] members = extPoint.getConfigurationElements(); >+ for (int i = 0; i < members.length; i++) { >+ IConfigurationElement element = members[i]; >+ if ("transaction".equals(element.getName())) { //$NON-NLS-1$ >+ String id = element.getAttribute("domainId"); //$NON-NLS-1$ >+ if(id != null) { >+ knownTransactions.put(id, element); >+ } >+ } >+ } >+ //- once extensions have been loaded try to retrieve the asked refactoring transaction >+ e = (IConfigurationElement)knownTransactions.get(domainId); >+ } >+ } >+ if(e == null) { >+ //- this domainId is unknown >+ UiPlugin.logError("Unable to find a registered refactoring transaction with the domain Id: '"+domainId+'\''); //$NON-NLS-1$ >+ return null; >+ } >+ return (IRefactoringTransaction) e.createExecutableExtension("class"); //$NON-NLS-1$ >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteModelChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteModelChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteModelChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteModelChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,150 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.List; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.hyades.models.common.common.CMNNamedElement; >+import org.eclipse.hyades.test.core.util.EMFUtil; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * change to apply to perform a model paste >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+public class PasteModelChange extends Change { >+ private EMFRefactoringTransaction context; >+ protected IPath destination; >+ protected IProxyNode proxy; >+ private boolean shouldBeRenamed; >+ private RefactoringStatus status; >+ private String newName = null; >+ private String newBaseName = null; >+ >+ >+ public PasteModelChange(IRefactoringContext context,IProxyNode node, IPath destinationPath,String [] targetName) { >+ this.proxy = node; >+ this.destination = destinationPath; >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ Assert.isNotNull(this.context); >+ this.status = new RefactoringStatus(); >+ IFile destFile = ResourcesPlugin.getWorkspace().getRoot().getFile(destination); >+ if (destFile.exists()) { >+ handleFileAlreadyExists(this.status); >+ } >+ this.newName = getNewName(); >+ if ((targetName != null) && (targetName.length > 0)) { >+ targetName[0] = newName; >+ } >+ } >+ >+ public Object getModifiedElement() { >+ return proxy; >+ } >+ >+ public String getName() { >+ String fileName = proxy.getUnderlyingResource().getFullPath().toPortableString(); >+ return NLS.bind(RefactoringMessages.PASTE_FILE, fileName, newName /*destination.removeLastSegments(1)*/); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return this.status; >+ } >+ >+ protected void handleFileAlreadyExists(RefactoringStatus status) { >+ shouldBeRenamed = true; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if (proxy instanceof EObjectProxyNode) { >+ //- load the referencer >+ Resource res = context.getResourceSet().getResource(((EObjectProxyNode)proxy).getOriginatorURI().trimFragment(), true); >+ res.setURI(getNewURI()); >+ try { >+ EMFUtil.save(res); >+ EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm); >+ if (shouldBeRenamed) { >+ if(context != null) { >+ List objects = res.getContents(); >+ if (!objects.isEmpty()) { >+ EObject object = (EObject)objects.get(0); >+ if (object instanceof CMNNamedElement) { >+ ((CMNNamedElement)object).setName(newBaseName); >+ EMFUtil.save(res); >+ EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm); >+ } >+ } >+ } >+ } >+ } catch (Exception e) { >+ UiPlugin.logError(e); >+ } >+ } >+ return null; >+ } >+ >+ public URI getNewURI() { >+ return URI.createPlatformResourceURI(newName,false); >+ } >+ >+ // call it one time only, because can be sometime a bit slow >+ private String getNewName() { >+ if(shouldBeRenamed) { >+ boolean done = false; >+ String fullFileName = destination.lastSegment(); >+ int dotIndex = fullFileName.lastIndexOf('.'); >+ String basePart = fullFileName.substring(0, dotIndex); >+ String endPart = fullFileName.substring(dotIndex); >+ String newFullName = null; >+ String ret = null; >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ for (int i=0; (!done); i++) { >+ if (i != 0) { >+ newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),basePart); >+ } else { >+ newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,basePart); >+ } >+ newFullName = newBaseName+endPart; >+ ret = destination.removeLastSegments(1).append(newFullName).toPortableString(); >+ IPath newpath = new Path(ret); >+ done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists()); >+ } >+ return ret; >+ } else { >+ return destination.toPortableString(); >+ } >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/EMFRefactoringTransaction.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/EMFRefactoringTransaction.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/EMFRefactoringTransaction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/EMFRefactoringTransaction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,121 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.hyades.test.core.util.EMFUtil; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class EMFRefactoringTransaction implements IRefactoringTransaction { >+ public static final String Id = "org.eclipse.hyades.test.ui.EMFRefactoringTransaction"; //$NON-NLS-1$ >+ private Set resources; >+ private Map newURIs; >+ private ResourceSet resourceSet; >+ >+ public EMFRefactoringTransaction() { >+ this.resources = new HashSet(); >+ this.newURIs = new HashMap(); >+ this.resourceSet = new ResourceSetImpl(); >+ } >+ >+ public void addChangedURI(Resource res, URI newURI) { >+ newURIs.put(res, newURI); >+ } >+ >+ public void addResourceToSave(Resource res) { >+ Assert.isNotNull(res); >+ if(!resources.contains(res)) { >+ resources.add(res); >+ } >+ } >+ >+ public URI getNewURI(Resource res) { >+ return (URI)newURIs.get(res); >+ } >+ >+ public ResourceSet getResourceSet() { >+ return resourceSet; >+ } >+ >+ public Set getResourcesToSave() { >+ return resources; >+ } >+ >+ public Set getResourcesToMove() { >+ return newURIs.keySet(); >+ } >+ >+ public void beginChanges(IProgressMonitor monitor) { /* NOP */ } >+ >+ public void cancelChanges(IProgressMonitor monitor) { /* NOP */ } >+ >+ public Change commitChanges(IProgressMonitor pm) throws CoreException { >+ List files = new LinkedList(); >+ pm.beginTask("", getResourcesToMove().size()+getResourcesToSave().size()+/*getResourcesToCopy().size()*/+1); //$NON-NLS-1$ >+ try { >+ //- change the URI of resources that should move >+ for (Iterator it = getResourcesToMove().iterator(); it.hasNext();) { >+ Resource res = (Resource) it.next(); >+ if (res != null) { >+ //- change its URI >+ IFile file = EMFUtil.getWorkspaceFile(res); >+ res.setURI(getNewURI(res)); >+ if (file != null) { >+ files.add(file); >+ } >+ } >+ pm.worked(1); >+ } >+ //- save all EMF resources loaded that need to be saved. >+ for (Iterator it = getResourcesToSave().iterator(); it.hasNext();) { >+ Resource res = (Resource) it.next(); >+ try { >+ EMFUtil.save(res); >+ EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm); >+ } catch (Exception e) { >+ UiPlugin.logError(e); >+ } >+ pm.worked(1); >+ } >+ //- delete files that moved >+ for (Iterator it = files.iterator(); it.hasNext();) { >+ ((IFile) it.next()).delete(false, new SubProgressMonitor(pm, 1)); >+ } >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IPasterExtended.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IPasterExtended.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IPasterExtended.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IPasterExtended.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.hyades.test.ui.navigator.actions.IPaster; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * interface for graphical paster >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public interface IPasterExtended extends IPaster { >+ >+ /** >+ * set the shell for graphical paster >+ * @param shell >+ */ >+ public void setShell(Shell shell); >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/ActionMessages.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/ActionMessages.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/ActionMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/ActionMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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 >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.action; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout,jbozier >+ * @version February 26, 2008 >+ */ >+public class ActionMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.hyades.test.ui.internal.navigator.action.messages"; //$NON-NLS-1$ >+ >+ public static String MOVE_ACTION_NAME; >+ public static String DELETE_ACTION_NAME; >+ public static String RENAME_ACTION_NAME; >+ public static String RENAME_NEW_NAME_LABEL; >+ public static String PASTE_ACTION_NAME; >+ >+ public static String SAVE_ALL_DIALOG_MESSAGE; >+ >+ public static String SAVE_ALL_DIALOG_NAME; >+ >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class); >+ } >+ >+ private ActionMessages() { >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderCompositeChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderCompositeChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderCompositeChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderCompositeChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.NullChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+ >+/** >+ * change to apply to perform a folder paste when it have childrens >+ * children paste don't appear in refactoring view >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+public class PasteFolderCompositeChange extends CompositeChange { >+ private IFolder folder; >+ private PasteFolderChange root; >+ >+ public PasteFolderCompositeChange(IFolder folder, IPath newPath,IPath [] targetPath) { >+ super(""); //$NON-NLS-1$ >+ this.folder = folder; >+ this.root = new PasteFolderChange(folder, newPath,targetPath); >+ } >+ >+ public Object getModifiedElement() { >+ return folder; >+ } >+ >+ public String getName() { >+ return root.getName(); >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { >+ RefactoringStatus status = root.isValid(pm); >+ if(folder.getFullPath().isPrefixOf(root.getDestinationPath())) { >+ status.addFatalError(RefactoringMessages.INNER_FOLDER_PASTE_ERROR); >+ } >+ status.merge(super.isValid(pm)); >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ pm.beginTask("", getChildren().length+1); //$NON-NLS-1$ >+ try { >+ //- paste the folder and all its content >+ root.perform(new SubProgressMonitor(pm, 1)); >+ //- children are update changes >+ super.perform(new SubProgressMonitor(pm, getChildren().length)); >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public void freeze() { >+ if(getChildren().length == 0) { >+ markAsSynthetic(); >+ //- add a dummy child in order to keep the composite alive >+ add(new NullChange(getName())); >+ } >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteTestInvocationChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteTestInvocationChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteTestInvocationChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteTestInvocationChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Collection; >+import java.util.Iterator; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.hyades.models.common.facades.behavioral.IBlock; >+import org.eclipse.hyades.models.common.facades.behavioral.IDecision; >+import org.eclipse.hyades.models.common.facades.behavioral.ILoop; >+import org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation; >+import org.eclipse.hyades.models.common.testprofile.TPFTest; >+import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; >+import org.eclipse.hyades.test.ui.navigator.DefaultTestSuiteProxyNode; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class DeleteTestInvocationChange extends Change { >+ private EMFRefactoringTransaction context; >+ private IProxyNode invokee; >+ private DefaultTestSuiteProxyNode test; >+ >+ public DeleteTestInvocationChange(IRefactoringContext context, DefaultTestSuiteProxyNode node, IReferencerProxyNode referenced) { >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ Assert.isNotNull(this.context); >+ this.test = node; >+ this.invokee = (IProxyNode) referenced.getAdapter(IProxyNode.class); >+ } >+ >+ public Object getModifiedElement() { >+ return test; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.DELETE_INVOCATION, invokee.getText(), test.getText()); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return new RefactoringStatus(); >+ } >+ >+ private void removeTestInvocation(IBlock block, URI invokeeURI) { >+ if (block != null) { >+ Collection actions = block.getActions(); >+ for (Iterator it = actions.iterator(); it.hasNext();) { >+ Object action = it.next(); >+ if (action instanceof ILoop) { >+ removeTestInvocation(((ILoop) action).getBlock(), invokeeURI); >+ } else if (action instanceof IDecision) { >+ IDecision ifAction = (IDecision) action; >+ removeTestInvocation(ifAction.getFailureBlock(), invokeeURI); >+ removeTestInvocation(ifAction.getSuccessBlock(), invokeeURI); >+ } else if (action instanceof ITestInvocation) { >+ ITestInvocation invocationAction = (ITestInvocation) action; >+ TPFTest invokedTest = (TPFTest)invocationAction.getInvokedTest(); >+ if (EcoreUtil.getURI(invokedTest).equals(invokeeURI)) { >+ it.remove(); >+ } >+ } >+ } >+ } >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if (invokee instanceof EObjectProxyNode) { >+ URI invokeeURI = ((EObjectProxyNode)invokee).getOriginatorURI(); >+ //- load the test >+ Resource res = context.getResourceSet().getResource(test.getOriginatorURI().trimFragment(), true); >+ TPFTestSuite testObject = (TPFTestSuite) res.getEObject(test.getOriginatorURI().fragment()); >+ //- remove all invocations of invokee contained in test >+ removeTestInvocation(testObject.getImplementor().getBlock(), invokeeURI); >+ context.addResourceToSave(res); >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteModelElementChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteModelElementChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteModelElementChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteModelElementChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange; >+import org.eclipse.hyades.test.core.util.EMFUtil; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.NullChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class DeleteModelElementChange extends Change { >+ private IProxyNode proxy; >+ protected EMFRefactoringTransaction context; >+ private Change fileChange; >+ >+ public DeleteModelElementChange(IRefactoringContext context, EObjectProxyNode node) { >+ this.proxy = node; >+ this.context = (EMFRefactoringTransaction)context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ //- if the proxy node can be adpated in IFile we need to remove the file as well. >+ Object file = node.getAdapter(IFile.class); >+ if(file != null) { >+ this.fileChange = new DeleteFileChange((IFile) file); >+ } else { >+ this.fileChange = new NullChange(NLS.bind(RefactoringMessages.UPDATE_PROXY, proxy.getUnderlyingResource().getFullPath().toPortableString())); >+ } >+ } >+ >+ public Object getModifiedElement() { >+ return null; >+ } >+ >+ public String getName() { >+ return fileChange.getName(); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return fileChange.isValid(pm); >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ URI uri = ((EObjectProxyNode)proxy).getOriginatorURI(); >+ Resource res = context.getResourceSet().getResource(uri.trimFragment(), true); >+ EObject eObject = res.getEObject(uri.fragment()); >+ if (eObject != null) { >+ EMFUtil.remove(eObject); >+ } >+ if (fileChange instanceof NullChange) { >+ context.addResourceToSave(res); >+ } else { >+ fileChange.perform(pm); >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DefaultProxyNodeDeleter.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DefaultProxyNodeDeleter.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DefaultProxyNodeDeleter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DefaultProxyNodeDeleter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * This class stands as the default deleter for proxy node. >+ * This class should only be used on proxy nodes that are adaptable in IFile. >+ * This class is not intented to be used/subclassed by clients. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public class DefaultProxyNodeDeleter implements IProxyNodeDeleter { >+ private IFile proxyFile; >+ >+ public DefaultProxyNodeDeleter(IProxyNode proxy) { >+ this.proxyFile = (IFile) proxy.getAdapter(IFile.class); >+ Assert.isNotNull(proxyFile); >+ } >+ >+ public Change createDeleteChange(IRefactoringContext context) { >+ return new DeleteFileChange(proxyFile); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IResourceSetRefactoringContext.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IResourceSetRefactoringContext.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IResourceSetRefactoringContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IResourceSetRefactoringContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,67 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Set; >+ >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+ >+/** >+ * Interface used to collect and postpone change to perform on EMF models. >+ * This interface is not intended to be implemented by clients. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public interface IResourceSetRefactoringContext { >+ >+ /** >+ * Adds the given resource into the set of resources that have been loaded. >+ * @param res a resource >+ */ >+ public void addResourceToSave(Resource res); >+ >+ /** >+ * Returns the set of resources that are to be saved. >+ * @return the set of resources that are to be saved. >+ */ >+ public Set getResourcesToSave(); >+ >+ /** >+ * Returns the resource set in which the resource have been loaded. >+ * @return the resource set in which the resource have been loaded. >+ */ >+ public ResourceSet getResourceSet(); >+ >+ /** >+ * Gathers the resource which the URI has to be changed at the end. >+ * @param res the resource which the URI should be changed >+ * @param newURI the new URI to set. >+ */ >+ public void addChangedURI(Resource res, URI newURI); >+ >+ /** >+ * Gets the new URI for the given resource >+ * @param res a resource which a new URI should be set. >+ * @return the new URI. >+ */ >+ public URI getNewURI(Resource res); >+ >+ /** >+ * Returns the set of resources that which URI should be changed. >+ * @return the set of resources that which URI should be changed. >+ */ >+ public Set getResourcesToMove(); >+} >Index: schema/testNavigatorReferenceTypes.exsd >=================================================================== >RCS file: schema/testNavigatorReferenceTypes.exsd >diff -N schema/testNavigatorReferenceTypes.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/testNavigatorReferenceTypes.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.hyades.test.ui"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.hyades.test.ui" id="testNavigatorReferenceTypes" name="Test Navigator Reference Types"/> >+ </appInfo> >+ <documentation> >+ Extension point that allows to declare proxy node reference types. >+Proxy nodes can reference other proxy nodes using references (see <code>org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode</code>) >+Those references are typed and should be declared using this extension point. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="type"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="type"> >+ <complexType> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Id of the type. This Id is used in <code>org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode.addReference()</code> >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A human readable name for this type. This name is displayed in the refactoring wizards. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="isExplicit" type="boolean" use="required"> >+ <annotation> >+ <documentation> >+ This flag determines whether the proxy node reference is explicit inside the underneath EMF objects. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="owns" type="boolean" use="required"> >+ <annotation> >+ <documentation> >+ This flag is used to describe whether the referencer proxy node (which contains references of this type) owns the referenced element or just reference it. >+This relation is equivalent to the composition relation in UML. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="oppositeReferenceTypeId" type="string"> >+ <annotation> >+ <documentation> >+ The type id of the opposite reference if such a reference has been defined. >+This is an optional attribute. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 4.3 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ <pre> >+ <extension >+ point="org.eclipse.hyades.test.ui.testNavigatorReferenceTypes"> >+ <type >+ id="TestSuite2TestLog" >+ isExplicit="false" >+ name="Dependent Test Logs" >+ oppositeReferenceTypeId="TestLog2TestSuite" >+ owns="true"/> >+ <type >+ id="TestLog2TestSuite" >+ isExplicit="true" >+ name="Source Test Suite" >+ oppositeReferenceTypeId="TestSuite2TestLog" >+ owns="false"/> >+ </extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2006 IBM Corporation and others.<br> >+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 >+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodePaster.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodePaster.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodePaster.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodePaster.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Interface that allows to describe the paste behavior of a proxy node. >+ * >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+public interface IProxyNodePaster { >+ /** >+ * Returns the refactoring change when pasting this instance to the new destination path. >+ * The given context can be used if the local change cannot be perform without a global context. >+ * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect >+ * data. Such refactoring transaction will performed changes in one time. >+ * create a new proxy on dest location + copy proxy link if any >+ * >+ * @param context a context that contains all IRefactoringTransaction instances defined by clients. >+ * @param newPath the destination path of this proxy node. >+ * @param targetName a 1 element array that will contain newly pasted proxy file name after call >+ * @return the change that performs the paste of the proxy node to the given destination path. >+ */ >+ public Change createPasteChange(IRefactoringContext context, IPath destinationPath,String [] targetName); >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameContainerChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameContainerChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameContainerChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameContainerChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,151 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourceAttributes; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.NullChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class RenameContainerChange extends CompositeChange { >+ private IContainer container; >+ private boolean isFolder; >+ private String newName; >+ >+ public RenameContainerChange(IContainer container, String newName) { >+ super(""); //$NON-NLS-1$ >+ this.container = container; >+ this.newName = newName; >+ this.isFolder = container.getFullPath().segmentCount() > 1; >+ } >+ >+ public Object getModifiedElement() { >+ return container; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.RENAME_CONTAINER, container.getName(), newName); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ IContainer newContainer = getNewContainer(); >+ if (!container.isAccessible()) { >+ if(isFolder) { >+ status.addError(RefactoringMessages.NO_FOLDER); >+ } else { >+ status.addError(RefactoringMessages.NO_PROJECT); >+ } >+ } >+ ResourceAttributes att = container.getResourceAttributes(); >+ if(att != null && att.isReadOnly()) { >+ if(isFolder) { >+ status.addError(RefactoringMessages.READ_ONLY_FOLDER); >+ } else { >+ status.addError(RefactoringMessages.READ_ONLY_PROJECT); >+ } >+ } >+ if(newContainer.exists()) { >+ if(isFolder) { >+ status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FOLDER, newContainer.getName())); >+ } else { >+ status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROJECT, newContainer.getName())); >+ } >+ } >+ >+ return status; >+ } >+ >+ private IContainer getNewContainer() { >+ if(isFolder) { >+ return container.getParent().getFolder(new Path(newName)); >+ } else { >+ return ResourcesPlugin.getWorkspace().getRoot().getProject(newName); >+ } >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if(isFolder) { >+ return performFolder(pm); >+ } else { >+ return performProject(pm); >+ } >+ } >+ >+ private Change performProject(IProgressMonitor pm) { >+ pm.beginTask("", 2); //$NON-NLS-1$ >+ try { >+ IProject project = (IProject) container; >+ try { >+ //- first process all children >+ super.perform(new SubProgressMonitor(pm, 1)); >+ IProjectDescription description = project.getDescription(); >+ IPath newPath = container.getFullPath().removeLastSegments(1).append(newName); >+ description.setName(newPath.segment(0)); >+ project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1)); >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ } >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ private Change performFolder(IProgressMonitor pm) { >+ pm.beginTask("", 2); //$NON-NLS-1$ >+ try { >+ IFolder folder = (IFolder) container; >+ try { >+ //- first process all children >+ super.perform(new SubProgressMonitor(pm, 1)); >+ IPath newPath = folder.getFullPath().removeLastSegments(1).append(newName); >+ folder.move(newPath, IResource.KEEP_HISTORY, new SubProgressMonitor(pm, 1)); >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ } >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public void freeze() { >+ if(getChildren().length == 0) { >+ markAsSynthetic(); >+ //- add a dummy child in order to keep the composite alive >+ add(new NullChange(getName())); >+ } >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/CompositeReferencerProxyNode.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/CompositeReferencerProxyNode.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/CompositeReferencerProxyNode.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/CompositeReferencerProxyNode.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,126 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.hyades.internal.execution.local.control.NotImplementedException; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * Wrapper class around a (referencer or not) proxy node. >+ * The proxy node part is same as the wrapped one. >+ * The references of this proxy node is built by grouping all references found of the whole proxy node hierarchy. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public class CompositeReferencerProxyNode implements IReferencerProxyNode { >+ private IProxyNode proxy; >+ //- map that associate a type name to the collection of referenced elements for this type of reference >+ //- (typeName, Set(Referenced)) >+ private Map types; >+ >+ public CompositeReferencerProxyNode(IProxyNode proxy) { >+ super(); >+ this.proxy = proxy; >+ types = new HashMap(); >+ getDeepReferences(proxy); >+ } >+ >+ public Set getReferenceTypes() { >+ return types.keySet(); >+ } >+ >+ public Collection getReferences(String refType) { >+ return (Collection) types.get(refType); >+ } >+ >+ private void getDeepReferences(IProxyNode p) { >+ if (p instanceof IReferencerProxyNode) { >+ //- first, add all its references >+ IReferencerProxyNode referencer = (IReferencerProxyNode) p; >+ for (Iterator it = referencer.getReferenceTypes().iterator(); it.hasNext();) { >+ String type = (String) it.next(); >+ types.put(type, referencer.getReferences(type)); >+ } >+ } >+ //- next, add those contained by its children >+ IProxyNode[] children = p.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ getDeepReferences(children[i]); >+ } >+ } >+ >+ /** >+ * This method is not intended to be called in this extender. >+ * Throws a NotImplementedException. >+ */ >+ public void removeReference(IProxyNode reference) { >+ throw new NotImplementedException(); >+ } >+ >+ public String getIdentifier() { >+ return proxy.getIdentifier(); >+ } >+ >+ public IResource getUnderlyingResource() { >+ return proxy.getUnderlyingResource(); >+ } >+ >+ public IProxyNode[] getChildren() { >+ return proxy.getChildren(); >+ } >+ >+ public Image getImage() { >+ return proxy.getImage(); >+ } >+ >+ public Object getParent() { >+ return proxy.getParent(); >+ } >+ >+ public String getText() { >+ return proxy.getText(); >+ } >+ >+ public Object getAdapter(Class adapter) { >+ if(adapter == IProxyNode.class) { >+ return proxy; >+ } >+ return proxy.getAdapter(adapter); >+ } >+ >+ public boolean equals(Object obj) { >+ if (obj instanceof CompositeReferencerProxyNode) { >+ CompositeReferencerProxyNode c = (CompositeReferencerProxyNode) obj; >+ return proxy.equals(c.proxy); >+ } >+ return false; >+ } >+ >+ public int hashCode() { >+ return proxy.hashCode(); >+ } >+ >+ public IProxyNode getProxy() { >+ return proxy; >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ResourceSetRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ResourceSetRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ResourceSetRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ResourceSetRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ * @deprecated >+ */ >+class ResourceSetRefactoring implements IResourceSetRefactoringContext { >+ private Set resources; >+ private Map newURIs; >+ private ResourceSet resourceSet; >+ >+ public ResourceSetRefactoring() { >+ this.resources = new HashSet(); >+ this.newURIs = new HashMap(); >+ this.resourceSet = new ResourceSetImpl(); >+ } >+ >+ public void addChangedURI(Resource res, URI newURI) { >+ newURIs.put(res, newURI); >+ } >+ >+ public void addResourceToSave(Resource res) { >+ resources.add(res); >+ } >+ >+ public URI getNewURI(Resource res) { >+ return (URI)newURIs.get(res); >+ } >+ >+ public ResourceSet getResourceSet() { >+ return resourceSet; >+ } >+ >+ public Set getResourcesToSave() { >+ return resources; >+ } >+ >+ public Set getResourcesToMove() { >+ return newURIs.keySet(); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class MoveFolderChange extends ReorgContainerChange { >+ protected IPath destPath; >+ >+ public MoveFolderChange(IFolder folder, IPath destPath) { >+ super(folder); >+ this.destPath = destPath; >+ } >+ >+ public IPath getDestinationPath() { >+ return destPath; >+ } >+ >+ public String getName() { >+ IPath path = getPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount()); >+ return NLS.bind(RefactoringMessages.MOVE_FOLDER, path.toOSString(), destPath.toOSString()); >+ } >+ >+ public void reorgFolder(IContainer container, SubProgressMonitor monitor) { >+ try { >+ container.move(destPath.append(container.getName()), false, monitor); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to move container", e); //$NON-NLS-1$ >+ } >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ IFolder folder = (IFolder) getModifiedElement(); >+ if(!folder.isAccessible()) { >+ status.addFatalError(RefactoringMessages.NO_FOLDER); >+ } >+ return super.isValid(pm); >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeDeleter.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeDeleter.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeDeleter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeDeleter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Interface that allows to describe the delete behavior of a proxy node. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IProxyNodeDeleter { >+ >+ public Change createDeleteChange(IRefactoringContext context); >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,207 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodePaster; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * refactoring for paste >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+ >+public class PasteRefactoring extends Refactoring { >+ private Change change; >+ private IContainer destination; >+ private RefactoringContext context; >+ protected List seenElements; >+ private List folders; >+ private List proxies; >+ >+ public PasteRefactoring(List folders, List proxies) { >+ super(); >+ this.seenElements = new LinkedList(); >+ this.context = new RefactoringContext(); >+ this.folders = folders; >+ this.proxies = proxies; >+ } >+ >+ public List getContainers() { >+ return folders; >+ } >+ >+ public List getProxies() { >+ return proxies; >+ } >+ >+ public String getName() { >+ return RefactoringMessages.UPDATE_OWNED_RESSOURCES_REFERENCES; >+ } >+ >+ public void setDestination(IContainer container) { >+ this.destination = container; >+ change = null; >+ } >+ >+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 3); //$NON-NLS-1$ >+ try { >+ ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot()); >+ try { >+ scanner.scan(new SubProgressMonitor(pm, 1)); >+ } catch (OperationCanceledException e) { >+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG); >+ } >+ change = createChange(new SubProgressMonitor(pm, 1)); >+ RefactoringStatus valid = change.isValid(new SubProgressMonitor(pm, 1)); >+ if(!valid.isOK()) { >+ change = null; >+ } >+ return valid; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ return new RefactoringStatus(); >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ if (change != null) { >+ return change; >+ } >+ pm.beginTask("", folders.size() + proxies.size()); //$NON-NLS-1$ >+ try { >+ RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context); >+ for (Iterator it = folders.iterator(); it.hasNext();) { >+ Change containerChange = createPasteContainerChange((IFolder) it.next(), destination); >+ if (containerChange != null) { >+ c.add(containerChange); >+ } >+ pm.worked(1); >+ } >+ for (Iterator it = proxies.iterator(); it.hasNext();) { >+ Change refChange = createPasteProxyChange((IProxyNode) it.next(), destination); >+ if (refChange != null) { >+ c.add(refChange); >+ } >+ pm.worked(1); >+ } >+ c.markAsSynthetic(); >+ return c; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ private Change createPasteContainerChange(IFolder folder, IContainer dest) { >+ IPath [] finalPath = new IPath[1]; >+ PasteFolderCompositeChange change = new PasteFolderCompositeChange(folder, dest.getFullPath(),finalPath); >+ performContainerChildren(change, (IContainer)folder, finalPath[0]); >+ change.freeze(); >+ return change; >+ } >+ >+ private Change performContainerChildren(CompositeChange change, IContainer source, IPath newPath) { >+ if(source.isAccessible()) { >+ IResource[] resources; >+ try { >+ resources = source.members(); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to get members of container: "+source.getFullPath().toOSString(), e); //$NON-NLS-1$ >+ return null; >+ } >+ for (int i = 0; i < resources.length; i++) { >+ if (resources[i] instanceof IFile) { >+ IFile file = (IFile)resources[i]; >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file); >+ if (proxy != null) { >+ // add here stuff to memorize changed children >+ } >+ } else { >+ performContainerChildren(change, (IContainer)resources[i], newPath.append(resources[i].getName())); >+ } >+ } >+ } >+ return change; >+ } >+ >+ // physical paste in case there is no link >+ // create a new proxy on dest location + copy proxy link if any >+ private Change createShallowPasteProxyChange(IProxyNode node, IContainer dest,String [] targetName) { >+ IResource res = node.getUnderlyingResource(); >+ IProxyNodePaster paster = (IProxyNodePaster)node.getAdapter(IProxyNodePaster.class); >+ if (paster != null) { >+ IPath newPath = dest.getFullPath().append(res.getName()); >+ Change change = paster.createPasteChange(context, newPath,targetName); >+ return change; >+ } else { >+ if (res instanceof IFile) { >+ return new PasteFileChange((IFile) res, dest); >+ } >+ } >+ return null; >+ } >+ >+ protected Change createPasteProxyChange(IProxyNode node, IContainer dest) { >+ if (!seenElements.contains(node)) { >+ seenElements.add(node); >+ if (node instanceof IReferencerProxyNode) { >+ Change change = createPasteReferencerChange((IReferencerProxyNode)node, dest,new String[1]); >+ return change; >+ } else { >+ return createShallowPasteProxyChange(node, dest,new String[1]); >+ } >+ } >+ return null; >+ } >+ >+ // logical paste in case there is links >+ private Change createPasteReferencerChange(IReferencerProxyNode nodeA,IContainer dest,String [] targetName) { >+ CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.PASTE_PROXY, nodeA.getText(), dest.getName())); >+ Change pasteNode = createShallowPasteProxyChange(nodeA, dest,targetName); >+ if(pasteNode != null) { >+ composite.add(pasteNode); >+ } >+ return composite; >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ProxyNodeScanner.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ProxyNodeScanner.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ProxyNodeScanner.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ProxyNodeScanner.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.TestUIConstants; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyMarkerPersister; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager; >+import org.eclipse.hyades.test.ui.navigator.IFileProxyFactory; >+import org.eclipse.hyades.test.ui.navigator.ITypedElementProxyFactory; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class ProxyNodeScanner { >+ >+ private IContainer root; >+ >+ public ProxyNodeScanner(IContainer root) { >+ this.root = root; >+ } >+ >+ public void scan(IProgressMonitor pm) { >+ scanContainer(root, pm); >+ } >+ >+ private void scanContainer(IContainer container, IProgressMonitor pm) { >+ Assert.isNotNull(container); >+ try { >+ if (container.isAccessible()) { >+ IResource [] resources; >+ try { >+ resources = container.members(); >+ } catch (Exception e) { >+ UiPlugin.logError("Unable to retrieve content of " + container.getName(), e); //$NON-NLS-1$ >+ return; >+ } >+ pm.beginTask(RefactoringMessages.ProxyNodeScanner_PM_LABEL, resources.length); >+ for (int i = 0; i < resources.length; i++) { >+ if (pm.isCanceled()) { >+ throw new OperationCanceledException(); >+ } >+ IResource res = resources[i]; >+ if (res instanceof IFile) { >+ processFile((IFile) res); >+ pm.worked(1); >+ } else if (res instanceof IContainer) { >+ scanContainer((IContainer) res, new SubProgressMonitor(pm, 1)); >+ } >+ } >+ } >+ } finally{ >+ pm.done(); >+ } >+ } >+ >+ private void processFile(IFile file) { >+ if(file.exists()) { >+ IMarker[] markers; >+ try { >+ markers = file.findMarkers(FileProxyMarkerPersister.MARKER_PROXYSTATE, false, IResource.DEPTH_ZERO); >+ if(markers.length == 0) { >+ //- no proxy has ever been persisted for this file, load it in cache >+ FileProxyNodeCache.getInstance().getProxy(file); >+ } else { >+ String factoryID = markers[0].getAttribute(TestUIConstants.TAG_FACTORY_ID, null); >+ IFileProxyFactory fileFactory = TestNavigator.getFileFactoryManager().getFactory(factoryID); >+ ITypedElementProxyFactory typedElementFactory = TypedElementFactoryManager.getInstance().getFactoryFromID(factoryID); >+ if(fileFactory == null && typedElementFactory == null) { >+ //- this is an old version of persisted proxy node or the tool that produced it is no longer installed >+ //- we need to load it in cache >+ FileProxyNodeCache.getInstance().getProxy(file); >+ } >+ } >+ } catch (CoreException e) { >+ //- this should never appear, since the file exists. >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/EditorUtil.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/EditorUtil.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/EditorUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/EditorUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.action; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashSet; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceDescription; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.dialog.ListDialog; >+import org.eclipse.hyades.ui.adapter.ISynchronizedEditorAdapter; >+import org.eclipse.hyades.ui.editor.IEditorExtension; >+import org.eclipse.hyades.ui.internal.editor.HyadesEditorPart; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * @author jgout,jbozier >+ * @version February 26, 2008 >+ */ >+public class EditorUtil { >+ >+ /** >+ * Saves all modified editors. >+ * @param shell >+ * @return <code>true</code> if all saves have been successfully performed and <code>false</code> otherwise. >+ */ >+ public static boolean saveEditors(Shell shell) { >+ IEditorPart[] dirtyEditors= getDirtyEditors(); >+ if (dirtyEditors.length == 0) >+ return true; >+ if (! saveAllDirtyEditors(shell, dirtyEditors)) >+ return false; >+ try { >+ // Save isn't cancelable. >+ IWorkspace workspace= ResourcesPlugin.getWorkspace(); >+ IWorkspaceDescription description= workspace.getDescription(); >+ boolean autoBuild= description.isAutoBuilding(); >+ description.setAutoBuilding(false); >+ workspace.setDescription(description); >+ try { >+ for (int i = 0; i < dirtyEditors.length; i++) { >+ IEditorPart part = dirtyEditors[i]; >+ if (part instanceof HyadesEditorPart) { >+ HyadesEditorPart hyadesEditor = (HyadesEditorPart) part; >+ hyadesEditor.doSave(new NullProgressMonitor()); >+ IEditorExtension extension = hyadesEditor.getEditorExtension(); >+ if (extension instanceof ISynchronizedEditorAdapter) { >+ ((ISynchronizedEditorAdapter) extension).reload(); >+ } >+ } >+ } >+ if (!UiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false)) >+ return false; >+ } finally { >+ description.setAutoBuilding(autoBuild); >+ workspace.setDescription(description); >+ } >+ return true; >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to save modified resources", e); //$NON-NLS-1$ >+ return false; >+ } >+ } >+ >+ private static boolean saveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) { >+ ListDialog dialog= new ListDialog(shell) { >+ protected Control createDialogArea(Composite parent) { >+ Composite result= (Composite) super.createDialogArea(parent); >+ applyDialogFont(result); >+ return result; >+ } >+ }; >+ dialog.setTitle(ActionMessages.SAVE_ALL_DIALOG_NAME); >+ dialog.setAddCancelButton(true); >+ dialog.setLabelProvider(createDialogLabelProvider()); >+ dialog.setMessage(ActionMessages.SAVE_ALL_DIALOG_MESSAGE); >+ dialog.setContentProvider(new ArrayContentProvider()); >+ dialog.setInput(Arrays.asList(dirtyEditors)); >+ return dialog.open() == Window.OK; >+ } >+ >+ private static ILabelProvider createDialogLabelProvider() { >+ return new LabelProvider() { >+ public Image getImage(Object element) { >+ return ((IEditorPart) element).getTitleImage(); >+ } >+ public String getText(Object element) { >+ return ((IEditorPart) element).getTitle(); >+ } >+ }; >+ } >+ >+ /** >+ * Returns an array of all editors that have an unsaved content. If the identical content is >+ * presented in more than one editor, only one of those editor parts is part of the result. >+ * (Copied from jdt internal) >+ * >+ * @return an array of all dirty editor parts. >+ */ >+ private static IEditorPart[] getDirtyEditors() { >+ Set inputs= new HashSet(); >+ List result= new ArrayList(0); >+ IWorkbench workbench= PlatformUI.getWorkbench(); >+ IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); >+ for (int i= 0; i < windows.length; i++) { >+ IWorkbenchPage[] pages= windows[i].getPages(); >+ for (int x= 0; x < pages.length; x++) { >+ IEditorPart[] editors= pages[x].getDirtyEditors(); >+ for (int z= 0; z < editors.length; z++) { >+ IEditorPart ep= editors[z]; >+ if (ep instanceof HyadesEditorPart) { >+ IEditorInput input= ep.getEditorInput(); >+ if (!inputs.contains(input)) { >+ inputs.add(input); >+ result.add(ep); >+ } >+ } >+ } >+ } >+ } >+ return (IEditorPart[])result.toArray(new IEditorPart[result.size()]); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/UpdateModelChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/UpdateModelChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/UpdateModelChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/UpdateModelChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,67 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jbozier >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class UpdateModelChange extends Change { >+ private IProxyNode referencer; >+ private EMFRefactoringTransaction context; >+ >+ public UpdateModelChange(IProxyNode node, IRefactoringContext context) { >+ this.referencer = node; >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ Assert.isNotNull(this.context); >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.UPDATE_REFERENCES, referencer.getText()); >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if (referencer instanceof EObjectProxyNode) { >+ //- load the referencer >+ Resource res = context.getResourceSet().getResource(((EObjectProxyNode)referencer).getOriginatorURI().trimFragment(), true); >+ EcoreUtil.resolveAll(res); >+ context.addResourceToSave(res); >+ } >+ return null; >+ } >+ >+ public Object getModifiedElement() { >+ return referencer; >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return new RefactoringStatus(); >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/FileAndFolderPaster.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/FileAndFolderPaster.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/FileAndFolderPaster.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/FileAndFolderPaster.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.action; >+ >+import java.util.LinkedList; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.IPasterExtended; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteRefactoring; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteRefactoringWizard; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.part.ResourceTransfer; >+/** >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class FileAndFolderPaster implements IPasterExtended { >+ >+ private LinkedList folders; >+ private LinkedList proxies; >+ private Clipboard clipboard; >+ private Shell shell; >+ >+ public FileAndFolderPaster() { >+ folders = new LinkedList(); >+ clipboard = null; >+ proxies = new LinkedList(); >+ shell = null; >+ } >+ >+ public boolean isPasteAllowedFor(Clipboard clipboard, Object selection) { >+ return (selection instanceof IContainer); >+ } >+ >+ public void setShell(Shell shell) { >+ this.shell = shell; >+ } >+ >+ private void sortClipboardElements() { >+ folders.clear(); >+ proxies.clear(); >+ IResource [] res = getResourceFromClipboard(); >+ for (int i=0; i<res.length; i++) { >+ if (res[i] instanceof IFile) { >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy((IFile)res[i]); >+ if (proxy != null) { >+ proxies.add(proxy); >+ } >+ } else if (res[i] instanceof IAdaptable) { >+ IAdaptable a = (IAdaptable) res[i]; >+ Object o = a.getAdapter(IFolder.class); >+ if(o != null) { >+ folders.add((IFolder) o); >+ } >+ } >+ } >+ } >+ >+ >+ private IResource [] getResourceFromClipboard() { >+ final IResource[][] clipboardData = new IResource[1][]; >+ shell.getDisplay().syncExec(new Runnable() { >+ public void run() { >+ //- clipboard must have resources or files >+ ResourceTransfer resTransfer = ResourceTransfer.getInstance(); >+ clipboardData[0] = (IResource[]) clipboard.getContents(resTransfer); >+ } >+ }); >+ return clipboardData[0]; >+ } >+ >+ private boolean canActivate(Shell shell) { >+ return EditorUtil.saveEditors(shell); >+ } >+ >+ public boolean performPaste(Clipboard clipboard, Object selection) { >+ if (! canActivate(shell)) >+ return false; >+ this.clipboard = clipboard; >+ sortClipboardElements(); >+ PasteRefactoring refactoring = new PasteRefactoring(folders,proxies); >+ PasteRefactoringWizard wizard = new PasteRefactoringWizard(refactoring,selection); >+ wizard.setDefaultPageTitle(ActionMessages.PASTE_ACTION_NAME); >+ wizard.setNeedsProgressMonitor(true); >+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard); >+ try { >+ op.run(shell , ""); //$NON-NLS-1$ >+ } catch (InterruptedException e) { >+ UiPlugin.logError(e); >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFileChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFileChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFileChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFileChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class MoveFileChange extends Change { >+ >+ private IFile file; >+ private IContainer destFolder; >+ >+ public MoveFileChange(IFile file, IContainer destination) { >+ super(); >+ this.file = file; >+ this.destFolder = destination; >+ } >+ >+ public Object getModifiedElement() { >+ return file; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.MOVE_FILE, file.getName(), destFolder.getFullPath().toOSString()); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ IFile destFile = destFolder.getFile(new Path(file.getName())); >+ if (!file.exists()) { >+ status.addError(RefactoringMessages.NO_FILE); >+ } >+ if(destFile.exists()) { >+ status.addWarning(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FILE, destFile.getFullPath().toPortableString())); >+ } >+ if (file.isReadOnly()) { >+ status.addWarning(RefactoringMessages.READ_ONLY_FILE); >+ } >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ Change undo = null; >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ IContainer parent = file.getParent(); >+ if (parent != null) { >+ undo = new MoveFileChange(file, parent); >+ } >+ file.move(destFolder.getFullPath().append(file.getName()), false, true, pm); >+ pm.worked(1); >+ return undo; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerCompositeChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerCompositeChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerCompositeChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerCompositeChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.osgi.util.NLS; >+ >+public class DeleteContainerCompositeChange extends ReorgContainerCompositeChange { >+ private DeleteContainerChange delChange; >+ >+ public DeleteContainerCompositeChange(IContainer container) { >+ super(NLS.bind(RefactoringMessages.DELETE_FOLDER, container.getFullPath().toOSString()), container); >+ delChange = new DeleteContainerChange(container); >+ } >+ >+ public Change getDeleteContainerChange() { >+ return delChange; >+ } >+ >+ public Change getRootChange() { >+ return delChange; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveModelChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveModelChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveModelChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveModelChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,101 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Date; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class MoveModelChange extends Change { >+ private EMFRefactoringTransaction context; >+ protected IPath destination; >+ protected IProxyNode proxy; >+ private boolean shouldBeRenamed; >+ private RefactoringStatus status; >+ >+ public MoveModelChange(IProxyNode node, IRefactoringContext context, IPath destinationPath) { >+ this.proxy = node; >+ this.destination = destinationPath; >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ Assert.isNotNull(this.context); >+ this.status = new RefactoringStatus(); >+ IFile destFile = ResourcesPlugin.getWorkspace().getRoot().getFile(destination); >+ if (destFile.exists()) { >+ handleFileAlreadyExists(this.status); >+ } >+ } >+ >+ public Object getModifiedElement() { >+ return proxy; >+ } >+ >+ public String getName() { >+ String fileName = proxy.getUnderlyingResource().getFullPath().toPortableString(); >+ return NLS.bind(RefactoringMessages.MOVE_FILE, fileName, destination.removeLastSegments(1)); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return this.status; >+ } >+ >+ protected void handleFileAlreadyExists(RefactoringStatus status) { >+ status.addInfo(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROXY_DURING_MOVE, destination.toPortableString())); >+ shouldBeRenamed = true; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if (proxy instanceof EObjectProxyNode) { >+ //- load the referencer >+ Resource res = context.getResourceSet().getResource(((EObjectProxyNode)proxy).getOriginatorURI().trimFragment(), true); >+ context.addResourceToSave(res); >+ context.addChangedURI(res, getNewURI()); >+ } >+ return null; >+ } >+ >+ public URI getNewURI() { >+ return URI.createPlatformResourceURI(getNewName(),false); >+ } >+ >+ private String getNewName() { >+ if(shouldBeRenamed) { >+ String fullFileName = destination.lastSegment(); >+ int dotIndex = fullFileName.lastIndexOf('.'); >+ long number = new Date().getTime(); >+ String newName = fullFileName.substring(0, dotIndex-1)+number+fullFileName.substring(dotIndex); >+ return destination.removeLastSegments(1).append(newName).toPortableString(); >+ } else { >+ return destination.toPortableString(); >+ } >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringMessages.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringMessages.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class RefactoringMessages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.hyades.test.ui.internal.navigator.refactoring.messages"; //$NON-NLS-1$ >+ >+ public static String DELETE_FOLDER; >+ public static String DELETE_PROXY; >+ public static String DELETE_INVOCATION; >+ public static String DELETE_CONFIRM_1; >+ public static String DELETE_CONFIRM_N; >+ public static String DELETE_DEEP_REMOVE; >+ >+ public static String NO_FOLDER; >+ public static String NO_PROJECT; >+ >+ public static String ProxyNodeScanner_PM_LABEL; >+ public static String READ_ONLY_FOLDER; >+ public static String READ_ONLY_PROJECT; >+ public static String ALREADY_EXISTS_FOLDER; >+ public static String ALREADY_EXISTS_PROJECT; >+ public static String MOVE_FOLDER; >+ public static String MOVE_CHOOSE_DESTINATION_SINGLE; >+ public static String MOVE_CHOOSE_DESTINATION_MULTI; >+ public static String MOVE_ERROR; >+ public static String MOVE_FILE; >+ public static String MOVE_PROXY; >+ >+ public static String PASTE_FILE; >+ public static String PASTE_FOLDER; >+ public static String PASTE_PROXY; >+ public static String PASTE_CHOOSE_DESTINATION_SINGLE; >+ public static String PASTE_CHOOSE_DESTINATION_MULTI; >+ public static String PASTE_ERROR; >+ >+ public static String ReorgRefactoring_CANCELED_OPERATION_MSG; >+ public static String UPDATE_PROXY; >+ public static String CHANGES_FOR_UPDATING; >+ public static String UPDATE_PROXY_PATH_CHANGED; >+ public static String UPDATE_REFERENCES; >+ public static String UPDATE_OWNED_RESSOURCES_REFERENCES; >+ public static String NO_FILE; >+ public static String ALREADY_EXISTS_FILE; >+ public static String READ_ONLY_FILE; >+ public static String ALREADY_EXISTS_PROXY_DURING_MOVE; >+ public static String ALREADY_EXISTS_PROXY_DURING_RENAME; >+ public static String ALREADY_EXISTS_PROXY_DURING_PASTE; >+ public static String RENAME_FILE; >+ public static String RENAME_PROXY; >+ public static String RENAME_CONTAINER; >+ public static String INNER_FOLDER_MOVE_ERROR; >+ public static String INNER_FOLDER_PASTE_ERROR; >+ >+ public static String LaunchConfigurationUpdateChange_NAME; >+ public static String LaunchConfigurationDeleteChange_NAME; >+ >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, RefactoringMessages.class); >+ } >+ >+ private RefactoringMessages() { >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringTransactionRootChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringTransactionRootChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringTransactionRootChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringTransactionRootChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IWorkspaceRunnable; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+ >+/** >+ * Root change of move and rename action. >+ * The performChange implementation has a transactional behavior according to the following pattern: >+ * - context.beginChanges() >+ * - Children perfomChange() >+ * - context.commitChanges() >+ * That way, it is guarantee that refactoring transactions (stored in the context) >+ * commit their changes after children ones. >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public class RefactoringTransactionRootChange extends CompositeChange { >+ private IRefactoringTransaction context; >+ >+ private final class SaveResourceSetRunnable implements IWorkspaceRunnable { >+ private Change undoChange; >+ >+ public void run(IProgressMonitor monitor) throws CoreException { >+ undoChange = RefactoringTransactionRootChange.super.perform(monitor); >+ } >+ >+ public Change getUndoChange() { >+ return undoChange; >+ } >+ } >+ >+ public RefactoringTransactionRootChange(IRefactoringTransaction context) { >+ super(""); //$NON-NLS-1$ >+ this.context = context; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ pm.beginTask("", 3); //$NON-NLS-1$ >+ try { >+ CompositeChange undo = new CompositeChange("");//$NON-NLS-1$ >+ context.beginChanges(new SubProgressMonitor(pm, 1)); >+ try { >+ //- Children performChange() >+ SaveResourceSetRunnable action = new SaveResourceSetRunnable(); >+ ResourcesPlugin.getWorkspace().run(action, new SubProgressMonitor(pm, 1)); >+ undo.add(action.getUndoChange()); >+ } catch (CoreException t) { >+ context.cancelChanges(pm); >+ throw t; >+ } >+ undo.add(context.commitChanges(new SubProgressMonitor(pm, 1))); >+ return undo; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/IReferencerProxyNode.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/IReferencerProxyNode.java >diff -N src/org/eclipse/hyades/test/ui/navigator/IReferencerProxyNode.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/IReferencerProxyNode.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator; >+ >+import java.util.Collection; >+import java.util.Set; >+ >+/** >+ * Interface to set references between proxy nodes. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IReferencerProxyNode extends IProxyNode { >+ /** >+ * Gets the reference collection of the given type. The content of this list is populated using {@link addReference} or {@link addBidirectionalReference}. >+ * @param refType the type of the reference to retrieve. >+ * @return a collection containing all the references (IProxyNode) of the >+ * given type found in the current implementor. An empty >+ * collection is returned in case of no such typed reference has been found. >+ */ >+ public Collection getReferences(String refType); >+ >+ /** >+ * Returns the set of the reference types (as <code>String</code>) contained in the implementor proxy node. >+ * @return the set of the reference types (as <code>String</code>) contained in the implementor proxy node. >+ */ >+ public Set getReferenceTypes(); >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/DeleteAction.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/DeleteAction.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/DeleteAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/DeleteAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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 >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.action; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteRefactoring; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteRefactoringWizard; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter; >+import org.eclipse.hyades.ui.util.IDisposable; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.actions.SelectionListenerAction; >+ >+/** >+ * @author jgout,jbozier >+ * @version February 26, 2008 >+ */ >+public class DeleteAction extends SelectionListenerAction implements IDisposable { >+ private Shell shell; >+ private LinkedList containers; >+ private LinkedList proxies; >+ >+ public DeleteAction(Shell shell) { >+ super(ActionMessages.DELETE_ACTION_NAME); >+ this.shell = shell; >+ containers = new LinkedList(); >+ proxies = new LinkedList(); >+ } >+ >+ public void run() { >+ if (! canActivate(shell)) >+ return; >+ DeleteRefactoring refactoring = new DeleteRefactoring(containers, proxies); >+ DeleteRefactoringWizard wizard = new DeleteRefactoringWizard(refactoring); >+ wizard.setDefaultPageTitle(ActionMessages.DELETE_ACTION_NAME); >+ wizard.setNeedsProgressMonitor(true); >+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard); >+ try { >+ op.run(shell , ""); //$NON-NLS-1$ >+ } catch (InterruptedException e) { >+ UiPlugin.logError(e); >+ } >+ } >+ >+ private boolean canActivate(Shell shell) { >+ return EditorUtil.saveEditors(shell); >+ } >+ >+ public void dispose() { >+ } >+ >+ protected boolean updateSelection(IStructuredSelection selection) { >+ boolean selOk = true; >+ containers.clear(); >+ proxies.clear(); >+ for (Iterator it = selection.iterator(); it.hasNext() && selOk;) { >+ Object o = it.next(); >+ if (o instanceof IContainer) { >+ containers.add((IContainer) o); >+ } else if (o instanceof IProxyNode) { >+ IProxyNodeDeleter deleter = (IProxyNodeDeleter) ((IProxyNode) o).getAdapter(IProxyNodeDeleter.class); >+ selOk &= deleter != null; >+ proxies.add(deleter); >+ } else { >+ selOk = false; >+ } >+ } >+ return selOk; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/dialog/ListDialog.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/dialog/ListDialog.java >diff -N src/org/eclipse/hyades/test/ui/internal/dialog/ListDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/dialog/ListDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.dialog; >+ >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.ui.dialogs.SelectionDialog; >+ >+public class ListDialog extends SelectionDialog { >+ >+ private IStructuredContentProvider fContentProvider; >+ private ILabelProvider fLabelProvider; >+ private Object fInput; >+ private TableViewer fTableViewer; >+ private boolean fAddCancelButton; >+ >+ public ListDialog(Shell parent) { >+ super(parent); >+ fAddCancelButton= false; >+ } >+ >+ public void setInput(Object input) { >+ fInput= input; >+ } >+ >+ public void setContentProvider(IStructuredContentProvider sp){ >+ fContentProvider= sp; >+ } >+ >+ public void setLabelProvider(ILabelProvider lp){ >+ fLabelProvider= lp; >+ } >+ >+ public void setAddCancelButton(boolean addCancelButton) { >+ fAddCancelButton= addCancelButton; >+ } >+ >+ public TableViewer getTableViewer(){ >+ return fTableViewer; >+ } >+ >+ public boolean hasFilters(){ >+ return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0; >+ } >+ >+ public void create() { >+ setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE); >+ super.create(); >+ } >+ >+ protected void createButtonsForButtonBar(Composite parent) { >+ if (! fAddCancelButton) >+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); >+ else >+ super.createButtonsForButtonBar(parent); >+ } >+ >+ protected Control createDialogArea(Composite container) { >+ Composite parent= (Composite) super.createDialogArea(container); >+ createMessageArea(parent); >+ fTableViewer= new TableViewer(parent, getTableStyle()); >+ fTableViewer.setContentProvider(fContentProvider); >+ Table table= fTableViewer.getTable(); >+ fTableViewer.setLabelProvider(fLabelProvider); >+ fTableViewer.setInput(fInput); >+ GridData gd= new GridData(GridData.FILL_BOTH); >+ gd.heightHint= convertHeightInCharsToPixels(15); >+ gd.widthHint= convertWidthInCharsToPixels(55); >+ table.setLayoutData(gd); >+ applyDialogFont(parent); >+ return parent; >+ } >+ >+ protected int getTableStyle() { >+ return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ModelPathChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ModelPathChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ModelPathChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ModelPathChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class ModelPathChange extends Change { >+ private IProxyNode referenced; >+ private EMFRefactoringTransaction context; >+ private IPath newPath; >+ >+ public ModelPathChange(EObjectProxyNode node, IRefactoringContext context, IPath destinationPath) { >+ this.referenced = node; >+ this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id); >+ this.newPath = destinationPath; >+ Assert.isNotNull(this.context); >+ } >+ >+ public Object getModifiedElement() { >+ return referenced; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.UPDATE_PROXY_PATH_CHANGED, referenced.getText()); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ return new RefactoringStatus(); >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ if (referenced instanceof EObjectProxyNode) { >+ //- load the referenced >+ Resource res = context.getResourceSet().getResource(((EObjectProxyNode)referenced).getOriginatorURI().trimFragment(), true); >+ context.addResourceToSave(res); >+ context.addChangedURI(res, URI.createPlatformResourceURI(newPath.toPortableString(),false)); >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.osgi.util.NLS; >+ >+public class DeleteContainerChange extends ReorgContainerChange { >+ >+ public DeleteContainerChange(IContainer cont) { >+ super(cont); >+ } >+ >+ public void reorgFolder(IContainer container, SubProgressMonitor monitor) { >+ try { >+ container.delete(false, monitor); >+ } catch (CoreException e) { >+ UiPlugin.logError(e); >+ } >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.DELETE_FOLDER, getPath().toOSString()); >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/CompositeChangeWithRoot.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/CompositeChangeWithRoot.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/CompositeChangeWithRoot.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/CompositeChangeWithRoot.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+ >+public class CompositeChangeWithRoot extends CompositeChange { >+ private Change root; >+ private String name; >+ >+ public CompositeChangeWithRoot(Change root) { >+ super(""); //$NON-NLS-1$ >+ Assert.isNotNull(root); >+ this.root = root; >+ } >+ >+ public CompositeChangeWithRoot(Change root, String name) { >+ super(name); >+ //- in this constructor, root can be null >+ this.root = root; >+ if(root == null) { >+ Assert.isLegal(name != null && name.length() > 0, "Empty name with null root"); //$NON-NLS-1$ >+ this.name = name; >+ } >+ } >+ >+ public String getName() { >+ return root != null ? root.getName() : name; >+ } >+ >+ public Change freeze() { >+ if(getChildren().length == 0) { >+ return root; >+ } >+ if (root instanceof CompositeChange) { >+ merge((CompositeChange)root); >+ } else { >+ add(root); >+ } >+ >+ return this; >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { >+ pm.beginTask("", getChildren().length+1); //$NON-NLS-1$ >+ try { >+ RefactoringStatus status = super.isValid(new SubProgressMonitor(pm, getChildren().length)); >+ if (root != null) { >+ status.merge(root.isValid(new SubProgressMonitor(pm, 1))); >+ } >+ return status; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceTypeRegistry.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceTypeRegistry.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceTypeRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceTypeRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,148 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.hyades.test.ui.UiPlugin; >+ >+/** >+ * Registry to manage reference types (<code>ReferenceType</code>). >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public class ReferenceTypeRegistry { >+ >+ private static ReferenceTypeRegistry instance; >+ private Map types; >+ >+ static class ReferenceType { >+ >+ private String name; >+ private boolean owns; >+ private boolean isExplicit; >+ private String oppositeId; >+ >+ public ReferenceType(String name, boolean owns, boolean isExplicit, String oppositeId) { >+ this.name = name; >+ this.owns = owns; >+ this.isExplicit = isExplicit; >+ this.oppositeId = oppositeId; >+ } >+ >+ public boolean owns() { >+ return owns; >+ } >+ >+ public boolean isExplicit() { >+ return isExplicit; >+ } >+ >+ public String getOppositeId() { >+ return oppositeId; >+ } >+ >+ public String getName() { >+ return name; >+ } >+ } >+ >+ private ReferenceTypeRegistry() { >+ types = new HashMap(); >+ IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(UiPlugin.getID() + ".testNavigatorReferenceTypes"); //$NON-NLS-1$ >+ if (extPoint != null) { >+ IConfigurationElement[] members = extPoint.getConfigurationElements(); >+ for (int i = 0; i < members.length; i++) { >+ IConfigurationElement element = members[i]; >+ if ("type".equals(element.getName())) { //$NON-NLS-1$ >+ String id = element.getAttribute("id"); //$NON-NLS-1$ >+ String name = element.getAttribute("name"); //$NON-NLS-1$ >+ boolean owns = Boolean.valueOf(element.getAttribute("owns")).booleanValue(); //$NON-NLS-1$ >+ boolean isExplicit = Boolean.valueOf(element.getAttribute("isExplicit")).booleanValue(); //$NON-NLS-1$ >+ String oppositeId = element.getAttribute("oppositeReferenceTypeId"); //$NON-NLS-1$ >+ types.put(id, new ReferenceType(name, owns, isExplicit, oppositeId)); >+ } >+ } >+ } >+ } >+ >+ public static ReferenceTypeRegistry getInstance() { >+ if(instance == null) { >+ instance = new ReferenceTypeRegistry(); >+ } >+ return instance; >+ } >+ >+ /** >+ * Tests whether the reference type (given through its id) owns. >+ * @param refTypeId the id of the reference type >+ * @return <code>true</code> if the reference type (given through its id) owns or <code>false</code> otherwise. >+ */ >+ public boolean owns(String refTypeId) { >+ ReferenceType type = (ReferenceType)types.get(refTypeId); >+ if(type != null) { >+ return type.owns(); >+ } >+ UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$ >+ return false; >+ } >+ >+ /** >+ * Tests whether the reference type (given through its id) is explicit. >+ * @param refTypeId the id of the reference type >+ * @return <code>true</code> if the reference type (given through its id) is explicit or <code>false</code> otherwise. >+ */ >+ public boolean isExplicit(String refTypeId) { >+ if (refTypeId != null) { >+ ReferenceType type = (ReferenceType) types.get(refTypeId); >+ if (type != null) { >+ return type.isExplicit(); >+ } >+ UiPlugin.logWarning("Unable to find reference type: " + refTypeId + " default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ return false; >+ } >+ >+ /** >+ * Returns the human readable name of the given reference type. >+ * @param refTypeId the id of the reference type. >+ * @return the human readable name of the given reference type. >+ */ >+ public String getName(String refTypeId) { >+ ReferenceType type = (ReferenceType)types.get(refTypeId); >+ if(type != null) { >+ return type.getName(); >+ } >+ UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$ >+ return "Unknown reference"; //$NON-NLS-1$ >+ } >+ >+ /** >+ * Returns the opposite reference type id of a given one if it has been defined or <code>null</code> otherwise. >+ * @param refTypeId the reference type id >+ * @return the opposite reference type id of a given one if it has been defined or <code>null</code> otherwise. >+ */ >+ public String getOppositeReferenceType(String refTypeId) { >+ ReferenceType type = (ReferenceType)types.get(refTypeId); >+ if(type != null) { >+ return type.getOppositeId(); >+ } >+ UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$ >+ return "Unknown reference"; //$NON-NLS-1$ >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerCompositeChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerCompositeChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerCompositeChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerCompositeChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+ >+/** >+ * Abstract class for handling move and delete of a container. >+ * The resulted change has a root change (move or delete of the folder itself) and children >+ * whose are move or delete of each container member. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ * >+ */ >+public abstract class ReorgContainerCompositeChange extends CompositeChange { >+ private IContainer container; >+ private Change rootChange; >+ >+ public ReorgContainerCompositeChange(String name, IContainer container) { >+ super(name); >+ this.container = container; >+ } >+ >+ public Object getModifiedElement() { >+ return container; >+ } >+ >+ public abstract Change getRootChange(); >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ //- if one of children is not enabled, we do not perform on root >+ boolean needToPerform = true; >+ Change[] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ needToPerform &= ((Change)children[i]).isEnabled(); >+ } >+ super.perform(pm); >+ if(needToPerform) { >+ if (rootChange == null) { >+ rootChange = getRootChange(); >+ } >+ rootChange.perform(pm); >+ } >+ //- no undo available. >+ return null; >+ } >+ >+ public String getName() { >+ if(rootChange == null) { >+ rootChange = getRootChange(); >+ } >+ return rootChange.getName(); >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IRefactoringRenamer.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IRefactoringRenamer.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IRefactoringRenamer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IRefactoringRenamer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+/** >+ * Interface that allows client to implement rename using refactoring mechanism. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public interface IRefactoringRenamer { >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoringWizard.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoringWizard.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoringWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoringWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizard; >+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Label; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class DeleteRefactoringWizard extends RefactoringWizard { >+ private DeleteRefactoringInputPage page; >+ >+ private class DeleteRefactoringInputPage extends UserInputWizardPage { >+ private static final String DEEP_REMOVE_CHECK_STATE= "DeepRemoveCheckState"; //$NON-NLS-1$ >+ private DeleteRefactoring refactoring; >+ >+ public DeleteRefactoringInputPage(Refactoring ref) { >+ super(""); //$NON-NLS-1$ >+ this.refactoring = (DeleteRefactoring) ref; >+ } >+ >+ public void createControl(Composite parent) { >+ initializeDialogUnits(parent); >+ Composite result= new Composite(parent, SWT.NONE); >+ setControl(result); >+ result.setLayout(new GridLayout()); >+ addLabel(result); >+ addDeleteRemoveCheckBox(result); >+ Dialog.applyDialogFont(result); >+ } >+ >+ private void addDeleteRemoveCheckBox(Composite parent) { >+ final Button check = new Button(parent, SWT.CHECK); >+ boolean deepRemove = getBooleanSetting(DEEP_REMOVE_CHECK_STATE, false); >+ check.setText(RefactoringMessages.DELETE_DEEP_REMOVE); >+ check.setSelection(deepRemove); >+ updateRefactoring(deepRemove); >+ check.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ saveBooleanSetting(DEEP_REMOVE_CHECK_STATE, check); >+ updateRefactoring(check.getSelection()); >+ } >+ }); >+ } >+ >+ protected void updateRefactoring(boolean deepRemove) { >+ DeleteRefactoringWizard.this.setForcePreviewReview(deepRemove); >+ refactoring.setDeepRemove(deepRemove); >+ } >+ >+ private Control addLabel(Composite parent) { >+ Label label= new Label(parent, SWT.NONE); >+ String text; >+ int containers= refactoring.getContainers().size(); >+ int proxies= refactoring.getProxies().size(); >+ >+ if (containers == 0 && proxies == 1) { >+ text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_1, ((IProxyNode)refactoring.getProxies().get(0)).getText()); >+ } else if (containers == 1 && proxies == 0) { >+ text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_1, ((IResource)refactoring.getContainers().get(0)).getName()); >+ } else { >+ text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_N, String.valueOf(containers + proxies)); >+ } >+ label.setText(text); >+ label = new Label(parent, SWT.NONE); //- spacing the first label >+ label.setLayoutData(new GridData(SWT.BEGINNING, GridData.FILL, false, true)); >+ return label; >+ } >+ >+ protected boolean getBooleanSetting(String key, boolean defaultValue) { >+ String value= getRefactoringSettings().get(key); >+ if (value != null) >+ return Boolean.valueOf(value).booleanValue(); >+ else >+ return defaultValue; >+ } >+ >+ protected void saveBooleanSetting(String key, Button checkBox) { >+ if (checkBox != null) >+ getRefactoringSettings().put(key, checkBox.getSelection()); >+ } >+ } >+ >+ public DeleteRefactoringWizard(Refactoring refactoring) { >+ super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE); >+ } >+ >+ protected void addUserInputPages() { >+ page = new DeleteRefactoringInputPage(getRefactoring()); >+ addPage(page); >+ } >+ >+ public boolean deepRemove() { >+ return page.getBooleanSetting(DeleteRefactoringInputPage.DEEP_REMOVE_CHECK_STATE, false); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/Reference.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/Reference.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/Reference.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/Reference.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.Proxy; >+import org.eclipse.hyades.test.ui.navigator.IProxy; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class Reference { >+ private String type; >+ private String proxyId; >+ private IFile proxyFile; >+ >+ public Reference(String type, String proxyId, IFile proxyFile) { >+ if(type == null || proxyId == null || proxyFile == null) { >+ throw new IllegalArgumentException("Can not create reference with null value"); //$NON-NLS-1$ >+ } >+ this.type = type; >+ this.proxyId = proxyId; >+ this.proxyFile = proxyFile; >+ } >+ >+ public Reference(String type, IProxy proxy) { >+ IResource ulr = proxy.getUnderlyingResource(); >+ if (ulr instanceof IFile) { >+ this.proxyFile = (IFile) ulr; >+ } >+ this.type = type; >+ this.proxyId = proxy.getIdentifier(); >+ } >+ >+ /** >+ * Returns the referenced proxy node. >+ * @return the referenced proxy node or <code>null</code> >+ * if the file that was containing it no longer exists. >+ */ >+ public IProxyNode getReferencedProxy() { >+ return FileProxyNodeCache.getInstance().getCorrespondingProxy(new Proxy(proxyFile, proxyId)); >+ } >+ >+ public String getType() { >+ return type; >+ } >+ >+ public IFile getProxyFile() { >+ return proxyFile; >+ } >+ >+ public String getProxyId() { >+ return proxyId; >+ } >+ >+ public boolean equals(Object arg0) { >+ if(arg0 == this) return true; >+ if (arg0 instanceof Reference) { >+ Reference ref = (Reference) arg0; >+ if (ref != null) { >+ return ref.type.equals(type) && ref.proxyId.equals(proxyId) && ref.proxyFile.equals(proxyFile); >+ } >+ } >+ return false; >+ } >+ >+ public int hashCode() { >+ return proxyFile.hashCode(); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,96 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.ResourceAttributes; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+ >+/** >+ * Abstract class for handling the change for deletion or move of a container. >+ * This change has no children. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public abstract class ReorgContainerChange extends Change { >+ private IPath path; >+ >+ public ReorgContainerChange(IContainer cont) { >+ path = getPath(cont); >+ } >+ >+ public static IPath getPath(IContainer container){ >+ return container.getFullPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount()); >+ } >+ >+ private IContainer getContainer(IPath path) { >+ if(path.segmentCount() == 1) { >+ //- this the path of a project >+ return ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment()); >+ } else { >+ //- this the path of a folder >+ return ResourcesPlugin.getWorkspace().getRoot().getFolder(path); >+ } >+ } >+ >+ public IPath getPath() { >+ return path; >+ } >+ >+ public Object getModifiedElement() { >+ return getContainer(path); >+ } >+ >+ public abstract String getName(); >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ IFolder folder = (IFolder)getModifiedElement(); >+ if (!folder.exists()) { >+ status.addError(RefactoringMessages.NO_FOLDER); >+ } >+ ResourceAttributes resAtt = folder.getResourceAttributes(); >+ if (resAtt.isReadOnly()) { >+ status.addWarning(RefactoringMessages.READ_ONLY_FOLDER); >+ } >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ IContainer container = getContainer(path); >+ Assert.isTrue(container.isAccessible()); >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ reorgFolder(container, new SubProgressMonitor(pm, 1)); >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ abstract public void reorgFolder(IContainer container, SubProgressMonitor monitor); >+ >+} >Index: schema/testNavigatorRefactoringTransactions.exsd >=================================================================== >RCS file: schema/testNavigatorRefactoringTransactions.exsd >diff -N schema/testNavigatorRefactoringTransactions.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/testNavigatorRefactoringTransactions.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,124 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.hyades.test.ui"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.hyades.test.ui" id="testNavigatorRefactoringTransactions" name="Test Navigator Refactoring Transactions"/> >+ </appInfo> >+ <documentation> >+ Test navigator supports refactoring for actions such as Move or Rename. >+Those refactoring operations are based upon the references stored in <code>org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode</code>. That allows to propagate move or rename refactoring operations on several linked elements (e.g. Test logs and the test that produced them). >+Such operations may follow a transactional behavior, in the sense that all derived changes of operations may need to be performed in a global common context (e.g a common ResourceSet for changing EMF links). >+This extension point allows clients to define a refactoring transaction which is used in those refactoring operations. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="transaction"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="transaction"> >+ <complexType> >+ <attribute name="domainId" type="string" use="required"> >+ <annotation> >+ <documentation> >+ The id of the transaction domain. This id should be used to retrieve the <code>org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction</code> from <code>org.eclipse.hyades.test.ui.navigator.IRefactoringContext</code> >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Instance of <code>org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction</code>. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 4.3 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ <pre> >+ <extension >+ point="org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions"> >+ <transaction >+ class="org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction" >+ domainId="org.eclipse.hyades.test.ui.EMFRefactoringTransaction"/> >+ </extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ Instances used in the class attribute should implement <code>org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction</code>. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2006 IBM Corporation and others.<br> >+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 >+<a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationUpdateChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationUpdateChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationUpdateChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationUpdateChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class LaunchConfigurationUpdateChange extends Change { >+ >+ private ILaunchConfiguration config; >+ private URI newURI; >+ >+ public LaunchConfigurationUpdateChange(ILaunchConfiguration config, URI newURI) { >+ super(); >+ this.config = config; >+ this.newURI = newURI; >+ } >+ >+ public Object getModifiedElement() { >+ return this.config; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.LaunchConfigurationUpdateChange_NAME, config.getName()); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy(); >+ TestLaunchConfigurationFacade.updateTestURI(workingCopy, newURI); >+ workingCopy.doSave(); >+ return null; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFileChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFileChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFileChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFileChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * change to apply to perform a file paste >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+public class PasteFileChange extends Change { >+ >+ private IFile file; >+ private IContainer destFolder; >+ private String destName = null; >+ >+ public PasteFileChange(IFile file, IContainer destination) { >+ super(); >+ this.file = file; >+ this.destFolder = destination; >+ this.destName = getNewName(destFolder.getFullPath().append(file.getName())); >+ } >+ >+ public Object getModifiedElement() { >+ return file; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.PASTE_FILE, file.getName(), destName); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ if (!file.exists()) { >+ status.addError(RefactoringMessages.NO_FILE); >+ } >+ return status; >+ } >+ >+ private String getNewName(IPath destination) { >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ if ( (root.getFolder(destination).exists()) || (root.getFile(destination).exists())) { >+ String newBaseName = null; >+ boolean done = false; >+ String fullFileName = destination.lastSegment(); >+ int dotIndex = fullFileName.lastIndexOf('.'); >+ String basePart = fullFileName.substring(0, dotIndex); >+ String endPart = fullFileName.substring(dotIndex); >+ String newFullName = null; >+ String ret = null; >+ for (int i=0; (!done); i++) { >+ if (i != 0) { >+ newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),basePart); >+ } else { >+ newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,basePart); >+ } >+ newFullName = newBaseName+endPart; >+ ret = destination.removeLastSegments(1).append(newFullName).toPortableString(); >+ IPath newpath = new Path(ret); >+ done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists()); >+ } >+ return ret; >+ } else { >+ return destination.toPortableString(); >+ } >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ Change undo = null; >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ IContainer parent = file.getParent(); >+ file.copy(new Path(destName), false, pm); >+ if (parent != null) { >+ IFile destFile = destFolder.getFile(new Path(destName)); >+ undo = new DeleteFileChange(destFile); >+ } >+ file.refreshLocal(0, pm); >+ pm.worked(1); >+ return undo; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IRefactoringContext.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IRefactoringContext.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IRefactoringContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IRefactoringContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction; >+ >+/** >+ * Global context that contents all domain specific refactoring transactions defined using >+ * the extension point <code>org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions</code> >+ * This interface is not intented to be implemented by clients. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IRefactoringContext { >+ >+ /** >+ * Returns the refactoring transaction given its domain id. >+ * @param domainId a domain id. >+ * @return the refactoring transaction given its domain id or <code>null</code> if the domain id is unknown. >+ */ >+ public IRefactoringTransaction getRefactoringTransaction(String domainId); >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/Proxy.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/Proxy.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/Proxy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/Proxy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.hyades.test.ui.navigator.AbstractProxy; >+import org.eclipse.hyades.test.ui.navigator.IProxy; >+ >+public class Proxy extends AbstractProxy implements IProxy { >+ private IResource res; >+ private String id; >+ >+ public Proxy(IResource res, String id) { >+ this.res = res; >+ this.id = id; >+ } >+ >+ /** >+ * Creates a proxy >+ * @param resName the workspace relative path of the underlying resource of the proxy >+ * @param id identifier of the proxy >+ */ >+ public Proxy(String resName, String id) { >+ this.res = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(resName)); >+ this.id = id; >+ } >+ >+ public String getIdentifier() { >+ return id; >+ } >+ >+ public IResource getUnderlyingResource() { >+ return res; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,139 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Iterator; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class RenameRefactoring extends ReorgRefactoring { >+ private IProxyNode proxy; >+ private IContainer container; >+ private String name; >+ >+ public RenameRefactoring(IProxyNode node) { >+ super(); >+ this.proxy = node; >+ } >+ >+ public RenameRefactoring(IContainer cont) { >+ super(); >+ this.container = cont; >+ } >+ >+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ if (change != null) { >+ return change; >+ } >+ try { >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context); >+ if(container != null) { >+ Change containerChange = createRenameContainerChange(new SubProgressMonitor(pm, 1)); >+ if (containerChange != null) { >+ c.add(containerChange); >+ } >+ } else if(proxy != null) { >+ Change proxyChange = createRenameProxyNodeChange(); >+ if (proxyChange != null) { >+ c.add(proxyChange); >+ } >+ pm.worked(1); >+ } >+ c.markAsSynthetic(); >+ return c; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ private Change createRenameProxyNodeChange() { >+ if (!seenElements.contains(proxy)) { >+ seenElements.add(proxy); >+ if (proxy instanceof IReferencerProxyNode) { >+ return createRenameModelChange(); >+ } else { >+ createShallowRenameProxyChange(); >+ } >+ } >+ return null; >+ } >+ >+ private Change createShallowRenameProxyChange() { >+ IProxyNodeRenamer2 renamer = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class); >+ if (renamer != null) { >+ return renamer.createRenameChange(context, name); >+ } else { >+ IResource res = proxy.getUnderlyingResource(); >+ if (res instanceof IFile) { >+ return new RenameFileChange((IFile) res, name); >+ } >+ } >+ return null; >+ } >+ >+ private Change createRenameModelChange() { >+ CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$ >+ Change renameNode = createShallowRenameProxyChange(); >+ if(renameNode != null) { >+ composite.add(renameNode); >+ } >+ CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(proxy); >+ for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) { >+ String type = (String)it.next(); >+ String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type); >+ if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) { >+ composite.add(createUpdateReferenceTypeChange(ref, type)); >+ } >+ } >+ composite.markAsSynthetic(); >+ return composite; >+ } >+ >+ private Change createUpdateReferenceTypeChange(CompositeReferencerProxyNode ref, String type) { >+ CompositeChange change = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type)); >+ for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) { >+ change.add(new UpdateModelChange((IProxyNode)it.next(), context)); >+ } >+ return change; >+ } >+ >+ private Change createRenameContainerChange(IProgressMonitor pm) { >+ RenameContainerChange change = new RenameContainerChange(container, name); >+ performContainerChildren(change, container, container.getFullPath().removeLastSegments(1).append(name)); >+ change.freeze(); >+ return change; >+ } >+ >+ public void setNewName(String text) { >+ name = text; >+ change = null; >+ seenElements.clear(); >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/IReferenceRegistrySavedState.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/IReferenceRegistrySavedState.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/IReferenceRegistrySavedState.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/IReferenceRegistrySavedState.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import org.eclipse.core.runtime.IPath; >+ >+/** >+ * Generic interface that provides the common feature of Eclipse ISavedState >+ * and ISaveContext methods. It provides a lookup feature for retrieving the >+ * real file associated to a symbolic file in a given save state. >+ * @author jcanches >+ * @version February 26, 2008 >+ * @see org.eclipse.core.resources.ISavedState >+ * @see org.eclipse.core.resources.ISaveContext >+ * @since 4.3 >+ */ >+public interface IReferenceRegistrySavedState { >+ >+ >+ /** >+ * @see org.eclipse.core.resources.ISavedState#lookup(org.eclipse.core.runtime.IPath) >+ * @see org.eclipse.core.resources.ISaveContext#lookup(org.eclipse.core.runtime.IPath) >+ */ >+ public IPath lookup(IPath path); >+ >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,97 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * change to apply to perform a folder paste >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.5 >+ */ >+ >+public class PasteFolderChange extends ReorgContainerChange { >+ private IPath destPath; >+ private IPath targetPath; >+ private RefactoringStatus status; >+ >+ public PasteFolderChange(IFolder folder, IPath destPath,IPath [] finalPath) { >+ super(folder); >+ this.destPath = destPath; >+ this.status = new RefactoringStatus(); >+ this.targetPath = handleFolderAlreadyExists(folder,destPath); >+ if ((finalPath != null) && (finalPath.length > 0)) { >+ finalPath[0] = targetPath; >+ } >+ } >+ >+ // update target path in case of conflict >+ private IPath handleFolderAlreadyExists(IFolder folder, IPath destPath) { >+ IPath path = destPath.append(folder.getName()); >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ if ((root.getFolder(path).exists()) || (root.getFile(path).exists())) { >+ boolean done = false; >+ String folderName = path.lastSegment(); >+ String ret = null; >+ String newName = null; >+ for (int i=0; (!done); i++) { >+ if (i != 0) { >+ newName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),folderName); >+ } else { >+ newName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,folderName); >+ } >+ ret = path.removeLastSegments(1).append(newName).toPortableString(); >+ IPath newpath = new Path(ret); >+ done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists()); >+ } >+ path = destPath.append(newName); >+ } >+ return path; >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { >+ return this.status; >+ } >+ >+ public IPath getDestinationPath() { >+ return destPath; >+ } >+ >+ public String getName() { >+ IPath path = getPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount()); >+ return NLS.bind(RefactoringMessages.PASTE_FOLDER, path.toOSString(), targetPath.toOSString()); >+ } >+ >+ public void reorgFolder(IContainer container, SubProgressMonitor monitor) { >+ try { >+ container.copy(targetPath, 0, monitor); >+ container.refreshLocal(IResource.DEPTH_INFINITE, monitor); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to copy container", e); //$NON-NLS-1$ >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/messages.properties >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/messages.properties >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+DELETE_ACTION_NAME=Delete >+MOVE_ACTION_NAME=Move >+PASTE_ACTION_NAME=Paste >+RENAME_ACTION_NAME=Rename >+RENAME_NEW_NAME_LABEL=New Name: >+SAVE_ALL_DIALOG_NAME=Save All Modified Resources >+SAVE_ALL_DIALOG_MESSAGE=All modified resources must be saved before this operation. >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * Common refactoring between move and rename. >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public abstract class ReorgRefactoring extends Refactoring { >+ protected Change change; >+ protected List seenElements; >+ protected RefactoringContext context; >+ >+ public ReorgRefactoring() { >+ this.seenElements = new LinkedList(); >+ this.context = new RefactoringContext(); >+ } >+ >+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 3); //$NON-NLS-1$ >+ try { >+ ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot()); >+ try { >+ scanner.scan(new SubProgressMonitor(pm, 1)); >+ } catch (OperationCanceledException e) { >+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG); >+ } >+ change = createChange(new SubProgressMonitor(pm, 1)); >+ pm.worked(1); >+ return change.isValid(new SubProgressMonitor(pm, 1)); >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ pm.worked(1); >+ return new RefactoringStatus(); >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public String getName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ protected Change performContainerChildren(CompositeChange change, IContainer source, IPath newPath) { >+ if(source.isAccessible()) { >+ IResource[] resources; >+ try { >+ resources = source.members(); >+ } catch (CoreException e) { >+ UiPlugin.logError("Unable to get members of container: "+source.getFullPath().toOSString(), e); //$NON-NLS-1$ >+ return null; >+ } >+ for (int i = 0; i < resources.length; i++) { >+ if (resources[i] instanceof IFile) { >+ IFile file = (IFile)resources[i]; >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file); >+ if (proxy != null) { >+ if(!seenElements.contains(proxy)) { >+ seenElements.add(proxy); >+ //- is this proxy adaptable to updater ? >+ Change updateChange = null; >+ IProxyNodeUpdater updater = (IProxyNodeUpdater)proxy.getAdapter(IProxyNodeUpdater.class); >+ if(updater != null) { >+ updateChange = updater.createUpdateChange(context, source, newPath.append(file.getName())); >+ } >+ CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.CHANGES_FOR_UPDATING, proxy.getText())); >+ if(updateChange != null) { >+ composite.add(updateChange); >+ } >+ //- process all references >+ if (proxy instanceof IReferencerProxyNode) { >+ CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(proxy); >+ for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) { >+ createRenameReferencerTypeChildren(composite, ref, (String)it.next()); >+ } >+ } >+ change.add(composite); >+ } >+ } >+ } else { >+ performContainerChildren(change, (IContainer)resources[i], newPath.append(resources[i].getName())); >+ } >+ } >+ } >+ return change; >+ } >+ >+ private void createRenameReferencerTypeChildren(CompositeChange change, CompositeReferencerProxyNode ref, String type) { >+ String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type); >+ if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) { >+ CompositeChange c = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type)); >+ for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) { >+ IProxyNodeUpdater updater = (IProxyNodeUpdater) ((IProxyNode)it.next()).getAdapter(IProxyNodeUpdater.class); >+ if (updater != null) { >+ IPath destPath = ref.getUnderlyingResource().getFullPath(); >+ Change updateChange = updater.createUpdateChange(context, ref, type, destPath); >+ if (updateChange != null) { >+ c.add(updateChange); >+ } >+ } >+ } >+ if(c.getChildren().length > 0) { >+ change.add(c); >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameFileChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameFileChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameFileChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameFileChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class RenameFileChange extends Change { >+ private IFile file; >+ private String name; >+ >+ public RenameFileChange(IFile file, String name) { >+ this.file = file; >+ this.name = name; >+ } >+ >+ public Object getModifiedElement() { >+ return file; >+ } >+ >+ public String getName() { >+ String newPathName = file.getParent().getFullPath().append(new Path(name)).toOSString(); >+ return NLS.bind(RefactoringMessages.RENAME_FILE, file.getName(), newPathName); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ IFile destFile = file.getParent().getFile(new Path(name)); >+ if (!file.exists()) { >+ status.addError(RefactoringMessages.NO_FILE); >+ } >+ if (file.isReadOnly()) { >+ status.addWarning(RefactoringMessages.READ_ONLY_FILE); >+ } >+ if(destFile.exists()) { >+ status.addWarning(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FILE, destFile.getFullPath().toPortableString())); >+ } >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ Change undo = null; >+ try { >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ IContainer parent = file.getParent(); >+ if (parent != null) { >+ undo = new RenameFileChange(file, file.getName()); >+ } >+ file.move(parent.getFullPath().append(new Path(name)), false, true, pm); >+ pm.worked(1); >+ return undo; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ProjectReferenceRegistry.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ProjectReferenceRegistry.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ProjectReferenceRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ProjectReferenceRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,332 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference; >+ >+import java.io.BufferedInputStream; >+import java.io.BufferedOutputStream; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.io.OutputStreamWriter; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Map; >+import java.util.Set; >+import java.util.zip.GZIPInputStream; >+import java.util.zip.GZIPOutputStream; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ISaveContext; >+import org.eclipse.core.resources.ISaveParticipant; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.hyades.test.ui.TestUIConstants; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.WorkbenchException; >+import org.eclipse.ui.XMLMemento; >+ >+/** >+ * This class is used to store proxy references for a given project. >+ * Its persistency is made using a save participant. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.3 >+ */ >+public class ProjectReferenceRegistry implements ISaveParticipant { >+ >+ public static final String TAG_REFERENCE = "reference"; //$NON-NLS-1$ >+ public static final String TAG_REFERENCER = "referencer"; //$NON-NLS-1$ >+ public static final String TAG_REF_TYPE = "refType"; //$NON-NLS-1$ >+ >+ private Map references; >+ private boolean hasChanged; >+ private IProject project; >+ >+ class Reference { >+ private String type; >+ private IFile referenced; >+ >+ public Reference(String typeRef, IFile referenced) { >+ this.type = typeRef; >+ this.referenced = referenced; >+ } >+ >+ public IFile getReferenced() { >+ return referenced; >+ } >+ >+ public String getType() { >+ return type; >+ } >+ >+ public boolean equals(Object arg0) { >+ if(arg0 == this) return true; >+ if (arg0 instanceof Reference) { >+ Reference ref = (Reference) arg0; >+ if (ref != null) { >+ if(type != null && referenced != null) { >+ return type.equals(ref.type) && referenced.equals(ref.referenced); >+ } else if((type == null && ref.type == null) || (referenced == null && ref.referenced == null)) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ public int hashCode() { >+ return referenced != null ? referenced.hashCode() : -1; >+ } >+ } >+ >+ public ProjectReferenceRegistry(IProject project, IReferenceRegistrySavedState savedState) { >+ this.references = new HashMap(); >+ this.hasChanged = false; >+ this.project = project; >+ if (savedState != null) { >+ IPath refsFilePath = savedState.lookup(getSavedStateFileKey()); >+ if (refsFilePath != null) { >+ File dependenciesFile = UiPlugin.getDefault().getStateLocation().append(refsFilePath).toFile(); >+ try { >+ load(new GZIPInputStream(new BufferedInputStream(new FileInputStream(dependenciesFile)))); >+ } catch (Throwable t) { >+ //- Oops, let's forget anything and start with a clean registry >+ clear(); >+ UiPlugin.logWarning("Unable to load proxy node references file for project " + this.project.getName(), t); //$NON-NLS-1$ >+ } >+ } >+ } >+ } >+ >+ private void addReference(IFile referencer, Reference ref) { >+ Assert.isNotNull(ref); >+ Collection refs = (Collection) references.get(referencer); >+ if(refs == null) { >+ //- this proxy has not yet references >+ refs = new HashSet(); >+ references.put(referencer, refs); >+ } >+ refs.add(ref); >+ hasChanged = true; >+ } >+ >+ public void addReference(IFile referencer, String refType, IFile referenced) { >+ addReference(referencer, new Reference(refType, referenced)); >+ } >+ >+ public void addBidirectionalReference(IFile referencer, String refType, IFile referenced, String oppositeRefType) { >+ addReference(referencer, refType, referenced); >+ addReference(referenced, oppositeRefType, referencer); >+ } >+ >+ public void removeReference(IFile referencer, IFile referenced) { >+ Assert.isNotNull(referenced); >+ Collection refs = (Collection) references.get(referencer); >+ if(refs != null) { >+ for (Iterator it = refs.iterator(); it.hasNext();) { >+ Reference ref = (Reference) it.next(); >+ if(referenced.equals(ref.getReferenced())) { >+ it.remove(); >+ hasChanged = true; >+ } >+ } >+ } >+ } >+ >+ public void removeReferences(IFile referencer) { >+ references.remove(referencer); >+ } >+ >+ /** >+ * Returns the list of referenced proxy node associated to the given referencer. >+ * Only references matching with the given type are considered >+ * @param referencer >+ * @param refType >+ * @return >+ */ >+ public Collection getReferences(IFile referencer, String refType) { >+ Assert.isNotNull(refType,"type should be not null"); //$NON-NLS-1$ >+ Collection refs = (Collection) references.get(referencer); >+ if(refs != null) { >+ List res = new LinkedList(); >+ for (Iterator it = refs.iterator(); it.hasNext();) { >+ Reference ref = (Reference) it.next(); >+ if(refType.equals(ref.getType())) { >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(ref.getReferenced()); >+ if(proxy == null) { >+ it.remove(); >+ } else { >+ res.add(proxy); >+ } >+ } >+ } >+ return res; >+ } else { >+ return Collections.EMPTY_LIST; >+ } >+ } >+ >+ /** >+ * Returns all references of type {@link Reference} registered for the given referencer. >+ * This method is used to persistence. >+ * @param referencer >+ * @return all references of type {@link Reference} registered for the given referencer. >+ */ >+ private Collection getAllReferences(IFile referencer) { >+ Collection list = (Collection) references.get(referencer); >+ return list != null ? list : Collections.EMPTY_LIST; >+ } >+ >+ public Set getReferenceTypes(IFile referencer) { >+ Set res = new HashSet(); >+ Collection refs = (Collection) references.get(referencer); >+ if(refs != null) { >+ for (Iterator it = refs.iterator(); it.hasNext();) { >+ Reference ref = (Reference) it.next(); >+ res.add(ref.getType()); >+ } >+ } >+ return res; >+ } >+ >+ /** >+ * Clears the registry >+ */ >+ public void clear() { >+ references.clear(); >+ hasChanged = false; >+ } >+ >+ /** >+ * Returns the File to use for saving and restoring the last built state for the given project. >+ */ >+ private File getPersistenceFile(int saveNumber) { >+ if (!project.exists()) return null; >+ String depsFileName = project.getName() + ".references-" + Integer.toString(saveNumber); //$NON-NLS-1$ >+ return UiPlugin.getDefault().getStateLocation().append(depsFileName).toFile(); >+ } >+ >+ private IPath getSavedStateFileKey() { >+ return new Path("references").append(project.getName()); //$NON-NLS-1$ >+ } >+ >+ public void doneSaving(ISaveContext context) { >+ if(hasChanged) { >+ hasChanged = false; >+ //- cleanup previous saved file >+ File depsFile = getPersistenceFile(context.getPreviousSaveNumber()); >+ if (depsFile.exists()) { >+ depsFile.delete(); >+ } >+ } >+ } >+ >+ public void prepareToSave(ISaveContext context) throws CoreException { >+ //- nop >+ } >+ >+ public void rollback(ISaveContext context) { >+ //- Remove the file we generated >+ File file = getPersistenceFile(context.getSaveNumber()); >+ if (file.exists()) { >+ file.delete(); >+ } >+ } >+ >+ public void saving(ISaveContext context) throws CoreException { >+ //- if context.getKind() == ISaveContext.PROJECT_SAVE then only >+ //- the instance of this class that has this.project == context.getProject is called >+ if(hasChanged && project.exists()) { >+ int saveNumber = context.getSaveNumber(); >+ File depsFile = getPersistenceFile(saveNumber); >+ try { >+ save(depsFile); >+ context.map(getSavedStateFileKey(), new Path(depsFile.getName())); >+ context.needSaveNumber(); >+ } catch (IOException e) { >+ UiPlugin.logError("Unexpected exception during references saving operation.", e); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ private void load(InputStream stream) throws WorkbenchException, IOException { >+ InputStreamReader reader = new InputStreamReader(stream); >+ IMemento memento = XMLMemento.createReadRoot(reader); >+ reader.close(); >+ IMemento [] referencers = memento.getChildren(TAG_REFERENCER); >+ for (int i = 0; i < referencers.length; i++) { >+ String underlyingResName = referencers[i].getString(TestUIConstants.TAG_UNDERLYING_RESOURCE); >+ IFile refFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(underlyingResName)); >+ if(refFile != null) { >+ loadProxyReferences(refFile, referencers[i]); >+ } >+ } >+ } >+ >+ private void loadProxyReferences(IFile file, IMemento memento) { >+ //- retrieving references >+ IMemento [] refStates = memento.getChildren(TAG_REFERENCE); >+ IFile refFile; >+ for (int j = 0; j < refStates.length; j++) { >+ IMemento refMemento = refStates[j]; >+ String underlyingResName = refMemento.getString(TestUIConstants.TAG_UNDERLYING_RESOURCE); >+ String refType = refMemento.getString(TAG_REF_TYPE); >+ refFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(underlyingResName)); >+ if(refFile.exists()) { >+ addReference(file, new Reference(refType, refFile)); >+ } else { >+ //- be sure that next save will purge this dead entry >+ hasChanged = true; >+ } >+ } >+ } >+ >+ private void save(File depsFile) throws IOException { >+ OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(depsFile)))); >+ IMemento memento = XMLMemento.createWriteRoot("references"); //$NON-NLS-1$ >+ for (Iterator it = references.keySet().iterator(); it.hasNext();) { >+ saveProxyReferences((IFile) it.next(), memento); >+ } >+ ((XMLMemento) memento).save(writer); >+ writer.close(); >+ } >+ >+ private void saveProxyReferences(IFile file, IMemento memento) { >+ //- save the referencer proxy itself >+ IMemento referencerMemento = memento.createChild(TAG_REFERENCER); >+ referencerMemento.putString(TestUIConstants.TAG_UNDERLYING_RESOURCE, file.getFullPath().toPortableString()); >+ //- save references as well >+ for (Iterator it = getAllReferences(file).iterator(); it.hasNext();) { >+ Reference ref = (Reference) it.next(); >+ IMemento referenceMemento = referencerMemento.createChild(TAG_REFERENCE); >+ referenceMemento.putString(TAG_REF_TYPE, ref.getType()); >+ referenceMemento.putString(TestUIConstants.TAG_UNDERLYING_RESOURCE, ref.getReferenced().getFullPath().toPortableString()); >+ } >+ >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/messages.properties >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/messages.properties >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+############################################################################### >+# Copyright (c) 2006, 2008 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$ >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+ >+# NLS_MESSAGEFORMAT_VAR >+# NLS_ENCODING=UTF-8 >+ >+DELETE_FOLDER = Delete folder ''{0}'' >+MOVE_FOLDER = Move folder ''{0}'' into ''{1}'' >+PASTE_FOLDER = Paste folder ''{0}'' into ''{1}'' >+MOVE_FILE = Move file ''{0}'' into ''{1}'' >+PASTE_FILE = Paste file ''{0}'' into ''{1}'' >+DELETE_PROXY = Delete ''{0}'' >+DELETE_INVOCATION = Remove invocation of ''{0}'' from ''{1}'' >+DELETE_CONFIRM_1 = Are you sure you want to delete ''{0}'' from the file system? >+DELETE_CONFIRM_N = Are you sure you want to delete {0} selected elements from the file system? >+DELETE_DEEP_REMOVE = Delete any referenced test assets as well (forces preview) >+MOVE_PROXY = Move ''{0}'' into ''{1}'' >+PASTE_PROXY = Copy ''{0}'' into ''{1}'' >+NO_FOLDER=Folder does not exist >+NO_PROJECT=Project does not exist or not open. >+READ_ONLY_FOLDER=Folder is read-only >+READ_ONLY_PROJECT=Project is read-only >+ALREADY_EXISTS_FOLDER=Folder ''{0}'' already exists. >+ALREADY_EXISTS_PROJECT=Project ''{0}'' already exists. >+MOVE_CHOOSE_DESTINATION_SINGLE=&Choose destination for ''{0}'': >+MOVE_CHOOSE_DESTINATION_MULTI=&Choose destination for ''{0}'' selected elements: >+PASTE_CHOOSE_DESTINATION_SINGLE=&Choose destination for ''{0}'': >+PASTE_CHOOSE_DESTINATION_MULTI=&Choose destination for ''{0}'' selected elements: >+MOVE_ERROR=The selected element cannot be the destination of this operation. >+PASTE_ERROR=The selected element cannot be the destination of this operation. >+UPDATE_PROXY=Update ''{0}'' >+CHANGES_FOR_UPDATING=Changes for updating ''{0}'' >+UPDATE_PROXY_PATH_CHANGED=Update references in ''{0}'' >+UPDATE_REFERENCES=Update references in ''{0}'' >+UPDATE_OWNED_RESSOURCES_REFERENCES=Update references for owned resources >+NO_FILE=File does not exist >+READ_ONLY_FILE=File is read-only >+ALREADY_EXISTS_FILE= File ''{0}'' already exists, it will overwritten. >+ALREADY_EXISTS_PROXY_DURING_MOVE = File ''{0}'' will be renamed because a file with the same name exists in the destination folder. >+ALREADY_EXISTS_PROXY_DURING_PASTE = File ''{0}'' will be renamed because a file with the same name exists in the destination folder. >+ALREADY_EXISTS_PROXY_DURING_RENAME = File ''{0}'' already exists. >+INNER_FOLDER_MOVE_ERROR=Unable to move a folder into one of its descendents. >+INNER_FOLDER_PASTE_ERROR=Unable to copy a folder into one of its descendents. >+RENAME_FILE= Rename File ''{0}'' in ''{1}'' >+RENAME_PROXY=Rename ''{0}'' in ''{1}'' >+RENAME_CONTAINER=Rename ''{0}'' in ''{1}'' >+ProxyNodeScanner_PM_LABEL=Searching for references... >+ReorgRefactoring_CANCELED_OPERATION_MSG=Operation canceled by user >+LaunchConfigurationUpdateChange_NAME=Update Launch Configuration ''{0}'' >+LaunchConfigurationDeleteChange_NAME=Delete Launch Configuration ''{0}'' >Index: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/IProxyNodeAdapterFactory.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/proxy/IProxyNodeAdapterFactory.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/proxy/IProxyNodeAdapterFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/proxy/IProxyNodeAdapterFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.proxy; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DefaultProxyNodeDeleter; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class IProxyNodeAdapterFactory implements IAdapterFactory { >+ >+ public Object getAdapter(Object adaptableObject, Class adapterType) { >+ if (adaptableObject instanceof IProxyNode && IProxyNodeDeleter.class.equals(adapterType)) { >+ IProxyNode proxy = (IProxyNode) adaptableObject; >+ if(proxy.getAdapter(IFile.class) != null) { >+ return new DefaultProxyNodeDeleter(proxy); >+ } >+ } >+ return null; >+ } >+ >+ public Class[] getAdapterList() { >+ return new Class[] { IProxyNodeDeleter.class }; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationDeleteChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationDeleteChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationDeleteChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationDeleteChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class LaunchConfigurationDeleteChange extends Change { >+ >+ private ILaunchConfiguration config; >+ >+ public LaunchConfigurationDeleteChange(ILaunchConfiguration config) { >+ super(); >+ this.config = config; >+ } >+ >+ public Object getModifiedElement() { >+ return this.config; >+ } >+ >+ public String getName() { >+ return NLS.bind(RefactoringMessages.LaunchConfigurationDeleteChange_NAME, config.getName()); >+ } >+ >+ public void initializeValidationData(IProgressMonitor pm) { >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ config.delete(); >+ return null; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,157 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class MoveRefactoring extends ReorgRefactoring { >+ private List folders; >+ private List proxies; >+ private IContainer destination; >+ >+ public MoveRefactoring(List folders, List proxies) { >+ super(); >+ this.folders = folders; >+ this.proxies = proxies; >+ } >+ >+ public List getContainers() { >+ return folders; >+ } >+ >+ public List getProxies() { >+ return proxies; >+ } >+ >+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ if (change != null) { >+ return change; >+ } >+ pm.beginTask("", folders.size() + proxies.size()); //$NON-NLS-1$ >+ try { >+ RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context); >+ for (Iterator it = folders.iterator(); it.hasNext();) { >+ Change containerChange = createMoveContainerChange((IFolder) it.next(), destination); >+ if (containerChange != null) { >+ c.add(containerChange); >+ } >+ pm.worked(1); >+ } >+ for (Iterator it = proxies.iterator(); it.hasNext();) { >+ Change refChange = createMoveProxyChange((IProxyNode) it.next(), destination); >+ if (refChange != null) { >+ c.add(refChange); >+ } >+ pm.worked(1); >+ } >+ c.markAsSynthetic(); >+ return c; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public String getName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ public void setDestination(IContainer container) { >+ this.destination = container; >+ change = null; >+ seenElements.clear(); >+ } >+ >+ protected Change createMoveProxyChange(IProxyNode node, IContainer dest) { >+ if (!seenElements.contains(node)) { >+ seenElements.add(node); >+ if (node instanceof IReferencerProxyNode) { >+ return createMoveReferencerChange(node, dest); >+ } else { >+ return createShallowMoveProxyChange(node, dest); >+ } >+ } >+ return null; >+ } >+ >+ private Change createShallowMoveProxyChange(IProxyNode node, IContainer dest) { >+ IResource res = node.getUnderlyingResource(); >+ IProxyNodeMover mover = (IProxyNodeMover)node.getAdapter(IProxyNodeMover.class); >+ if (mover != null) { >+ return mover.createMoveChange(context, dest.getFullPath().append(res.getName())); >+ } else { >+ if (res instanceof IFile) { >+ return new MoveFileChange((IFile) res, dest); >+ } >+ } >+ return null; >+ } >+ >+ private Change createMoveReferencerChange(final IProxyNode node, final IContainer dest) { >+ CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.MOVE_PROXY, node.getText(), dest.getName())); >+ Change moveNode = createShallowMoveProxyChange(node, dest); >+ CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(node); >+ for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) { >+ String type = (String)it.next(); >+ String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type); >+ if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) { >+ composite.add(createUpdateReferenceTypeChange(ref, type, dest)); >+ } >+ } >+ if(moveNode != null) { >+ composite.add(moveNode); >+ } >+ return composite; >+ } >+ >+ private Change createUpdateReferenceTypeChange(CompositeReferencerProxyNode ref, String type, IContainer dest) { >+ CompositeChange change = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type)); >+ for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) { >+ IProxyNode proxy = (IProxyNode)it.next(); >+ IProxyNodeUpdater updater = (IProxyNodeUpdater) proxy.getAdapter(IProxyNodeUpdater.class); >+ if (updater != null) { >+ IPath destPath = dest.getFullPath().append(ref.getUnderlyingResource().getName()); >+ change.add(updater.createUpdateChange(context, ref, type, destPath)); >+ } >+ } >+ return change; >+ } >+ >+ private Change createMoveContainerChange(IFolder folder, IContainer dest) { >+ MoveFolderCompositeChange change = new MoveFolderCompositeChange(folder, dest.getFullPath()); >+ performContainerChildren(change, (IContainer)folder, dest.getFullPath().append(folder.getName())); >+ change.freeze(); >+ return change; >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderCompositeChange.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderCompositeChange.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderCompositeChange.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderCompositeChange.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.NullChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+ >+/** >+ * @author jgout >+ * @version February 26, 2008 >+ */ >+public class MoveFolderCompositeChange extends CompositeChange { >+ private IFolder folder; >+ private MoveFolderChange root; >+ >+ public MoveFolderCompositeChange(IFolder folder, IPath newPath) { >+ super(""); //$NON-NLS-1$ >+ this.folder = folder; >+ this.root = new MoveFolderChange(folder, newPath); >+ } >+ >+ public Object getModifiedElement() { >+ return folder; >+ } >+ >+ public String getName() { >+ return root.getName(); >+ } >+ >+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { >+ RefactoringStatus status = root.isValid(pm); >+ if(folder.getFullPath().isPrefixOf(root.getDestinationPath())) { >+ status.addFatalError(RefactoringMessages.INNER_FOLDER_MOVE_ERROR); >+ } >+ status.merge(super.isValid(pm)); >+ return status; >+ } >+ >+ public Change perform(IProgressMonitor pm) throws CoreException { >+ pm.beginTask("", getChildren().length+1); //$NON-NLS-1$ >+ try { >+ //- children are update changes >+ super.perform(new SubProgressMonitor(pm, getChildren().length)); >+ //- move the folder and all its content >+ root.perform(new SubProgressMonitor(pm, 1)); >+ return null; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public void freeze() { >+ if(getChildren().length == 0) { >+ markAsSynthetic(); >+ //- add a dummy child in order to keep the composite alive >+ add(new NullChange(getName())); >+ } >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer2.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer2.java >diff -N src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer2.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer2.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator.actions; >+ >+import org.eclipse.ltk.core.refactoring.Change; >+ >+/** >+ * Interface that allows to describe the rename behavior of a proxy node. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public interface IProxyNodeRenamer2 { >+ >+ /** >+ * Returns the refactoring change when renaming this instance with the new name. >+ * The given context can be used if the local change cannot be perform without a global context. >+ * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect >+ * data. Such refactoring transaction will performed changes in one time. >+ * >+ * @param context a context that contains all IRefactoringTransaction instances defined by clients. >+ * @param newName the new name of this proxy node. >+ * @return the change that performs the rename of the proxy node using the given new name. >+ */ >+ public Change createRenameChange(IRefactoringContext context, String newName); >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoring.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoring.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,310 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.refactoring; >+ >+import java.util.Collection; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.Refactoring; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @author jgout >+ * @author jbozier >+ * @version February 26, 2008 >+ */ >+public class DeleteRefactoring extends Refactoring { >+ private List containers; >+ private List proxies; >+ private List seenElements; >+ private Change change; >+ private RefactoringContext context; >+ private boolean deepRemove; >+ private Collection nodesToUpdateLater; >+ >+ private class NodeToUpdateLater { >+ private CompositeChange composite; >+ private String refType; >+ private CompositeReferencerProxyNode node; >+ >+ public NodeToUpdateLater(CompositeChange composite, String refType, CompositeReferencerProxyNode node) { >+ this.composite = composite; >+ this.refType = refType; >+ this.node = node; >+ } >+ >+ public CompositeChange getComposite() { >+ return composite; >+ } >+ >+ public CompositeReferencerProxyNode getNode() { >+ return node; >+ } >+ >+ public String getRefType() { >+ return refType; >+ } >+ } >+ >+ public List getContainers() { >+ return containers; >+ } >+ >+ public List getProxies() { >+ return proxies; >+ } >+ >+ public DeleteRefactoring(List containers, List proxies) { >+ this.containers = containers; >+ this.proxies = proxies; >+ this.seenElements = new LinkedList(); >+ this.context = new RefactoringContext(); >+ this.deepRemove = false; >+ this.nodesToUpdateLater = new HashSet(); >+ } >+ >+ private List getReferencers() { >+ List proxyReferencers = new LinkedList(); >+ for (Iterator it = proxies.iterator(); it.hasNext();) { >+ proxyReferencers.add(new CompositeReferencerProxyNode((IProxyNode) it.next())); >+ } >+ return proxyReferencers; >+ } >+ >+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 3); //$NON-NLS-1$ >+ try { >+ ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot()); >+ try { >+ scanner.scan(new SubProgressMonitor(pm, 1)); >+ } catch (OperationCanceledException e) { >+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG); >+ } >+ change = createChange(new SubProgressMonitor(pm, 1)); >+ RefactoringStatus valid = change.isValid(new SubProgressMonitor(pm, 1)); >+ if(!valid.isOK()) { >+ change = null; >+ } >+ return valid; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ pm.beginTask("", 1); //$NON-NLS-1$ >+ try { >+ return new RefactoringStatus(); >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { >+ if (change != null) { >+ return change; >+ } >+ pm.beginTask("", containers.size()+proxies.size()+1); //$NON-NLS-1$ >+ try { >+ RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context); >+ for (Iterator it = containers.iterator(); it.hasNext();) { >+ Change containerChange = createDeleteContainerChange((IContainer) it.next()); >+ if (containerChange != null) { >+ c.add(containerChange); >+ } >+ pm.worked(1); >+ } >+ for (Iterator it = getReferencers().iterator(); it.hasNext();) { >+ CompositeReferencerProxyNode ref = (CompositeReferencerProxyNode) it.next(); >+ if (!seenElements.contains(ref)) { >+ Change refChange = createDeleteReferencerChange(ref); >+ if (refChange != null) { >+ c.add(refChange); >+ } >+ } >+ pm.worked(1); >+ } >+ processNodesToUpdateLater(); >+ c.markAsSynthetic(); >+ return c; >+ } finally { >+ pm.done(); >+ } >+ } >+ >+ /** >+ * Adds the given change as the first children of the given composite change. >+ * @param composite >+ * @param c >+ */ >+ private static void insertFirst(CompositeChange composite, Change c) { >+ composite.add(c); >+ Change[] children = composite.getChildren(); >+ for (int i = 0; i < children.length-1; i++) { >+ composite.remove(children[i]); >+ composite.add(children[i]); >+ } >+ } >+ >+ /** >+ * Completes delete proxy composite change by adding update changes only >+ * for cases where the element to update still exists >+ */ >+ private void processNodesToUpdateLater() { >+ for (Iterator it = nodesToUpdateLater.iterator(); it.hasNext();) { >+ NodeToUpdateLater element = (NodeToUpdateLater) it.next(); >+ Change updateTypeChange = createUpdateReferenceTypeChange(element.getRefType(), element.getNode()); >+ if (updateTypeChange != null) { >+ insertFirst(element.getComposite(), updateTypeChange); >+ } >+ } >+ } >+ >+ private Change createDeleteReferencerChange(CompositeReferencerProxyNode node) { >+ IProxyNodeDeleter deleter = (IProxyNodeDeleter) node.getAdapter(IProxyNodeDeleter.class); >+ if(deleter != null) { >+ CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.DELETE_PROXY, node.getText())); >+ seenElements.add(node); >+ //- we need to add as children all referenced elements from ref type with owns flag set to true. >+ for (Iterator it = node.getReferenceTypes().iterator(); it.hasNext();) { >+ String refType = (String) it.next(); >+ String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(refType); >+ if (deepRemove && ReferenceTypeRegistry.getInstance().owns(refType)) { >+ Change referenceTypeChange = createDeleteReferenceTypeChange(refType, node); >+ if(referenceTypeChange != null) { >+ composite.add(referenceTypeChange); >+ continue; >+ } >+ } >+ //- opposite explicit references need to be updated according to the deletion of node >+ if (ReferenceTypeRegistry.getInstance().isExplicit(oppType)) { >+ nodesToUpdateLater.add(new NodeToUpdateLater(composite, refType, node)); >+ } >+ } >+ composite.add(deleter.createDeleteChange(context)); >+ return composite; >+ } >+ return null; >+ } >+ >+ private Change createUpdateReferenceTypeChange(String refType, CompositeReferencerProxyNode node) { >+ CompositeChange composite = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(refType)); >+ Collection references = node.getReferences(refType); >+ for (Iterator it = references.iterator(); it.hasNext();) { >+ IProxyNode proxy = (IProxyNode) it.next(); >+ if (!seenElements.contains(new CompositeReferencerProxyNode(proxy))) { >+ IProxyNodeUpdater updater = (IProxyNodeUpdater) proxy.getAdapter(IProxyNodeUpdater.class); >+ if (updater != null) { >+ composite.add(updater.createUpdateChange(context, node, refType, null)); >+ } >+ } >+ } >+ return composite.getChildren().length > 0 ? composite : null; >+ } >+ >+ private Change createDeleteReferenceTypeChange(String refType, CompositeReferencerProxyNode node) { >+ CompositeChange composite = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(refType)); >+ Collection references = node.getReferences(refType); >+ for (Iterator it = references.iterator(); it.hasNext();) { >+ IProxyNode proxy = (IProxyNode) it.next(); >+ if (proxy.getAdapter(IFile.class) != null) { >+ //- if the referenced proxy is a referencer itself we need to get its references as well. >+ if (proxy instanceof IReferencerProxyNode) { >+ CompositeReferencerProxyNode referenced = new CompositeReferencerProxyNode((IReferencerProxyNode) proxy); >+ //- we need to check that the referenced element was not previously processed. >+ //- this check is needed because of bidirectional/circular references. >+ if (!seenElements.contains(referenced)) { >+ Change refChange = createDeleteReferencerChange(referenced); >+ if (refChange != null) { >+ composite.add(refChange); >+ } >+ } >+ } else { >+ // - the referenced element is not a referencer >+ if (!seenElements.contains(proxy)) { >+ composite.add(new DeleteFileChange((IFile) proxy.getUnderlyingResource())); >+ } >+ } >+ } >+ } >+ return composite.getChildren().length > 0 ? composite : null; >+ } >+ >+ private Change createDeleteContainerChange(IContainer container) { >+ DeleteContainerCompositeChange contChange = new DeleteContainerCompositeChange(container); >+ if(container.isAccessible()) { >+ IResource[] resources; >+ try { >+ resources = container.members(); >+ } catch (CoreException e) { >+ UiPlugin.logWarning("Unable to get members of container: "+container.getFullPath().toOSString(), e); //$NON-NLS-1$ >+ return null; >+ } >+ for (int i = 0; i < resources.length; i++) { >+ if (resources[i] instanceof IFile) { >+ IFile file = (IFile)resources[i]; >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file); >+ if (proxy != null) { >+ Change refChange = createDeleteReferencerChange(new CompositeReferencerProxyNode(proxy)); >+ if (refChange != null) { >+ contChange.add(refChange); >+ if(proxies.contains(proxy)) { >+ //- this means that the current proxy (found inside the folder) >+ //- was in the original selection as well. We need to remove it to not duplicate change. >+ proxies.remove(proxy); >+ } >+ } >+ } else { >+ //- plain file that are not displayed by the navigator, >+ //- those files should be shown in the refactoring since they are potentially deleted >+ contChange.add(new DeleteFileChange(file)); >+ } >+ } else { >+ contChange.add(createDeleteContainerChange((IContainer)resources[i])); >+ } >+ } >+ } >+ return contChange.getChildren().length > 0 ? contChange : contChange.getDeleteContainerChange(); >+ } >+ >+ public String getName() { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ public void setDeepRemove(boolean deepRemove) { >+ this.deepRemove = deepRemove; >+ } >+ >+} >Index: src/org/eclipse/hyades/test/ui/navigator/AbstractProxy.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/navigator/AbstractProxy.java >diff -N src/org/eclipse/hyades/test/ui/navigator/AbstractProxy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/navigator/AbstractProxy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/********************************************************************** >+ * Copyright (c) 2006-2008 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: $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.navigator; >+ >+import org.eclipse.core.resources.IResource; >+ >+/** >+ * Partial implementation of the IProxy interface that manages the <code>equals</code> and <code>hashcode</code> methods. >+ * >+ * @author jgout >+ * @version February 26, 2008 >+ * @since 4.4 >+ */ >+public abstract class AbstractProxy implements IProxy { >+ >+ public boolean equals(Object arg0) { >+ if(arg0 instanceof IProxy) { >+ IResource resThis=this.getUnderlyingResource(); >+ IResource resArg = ((IProxy)arg0).getUnderlyingResource(); >+ String idThis = this.getIdentifier(); >+ String idArg = ((IProxy)arg0).getIdentifier(); >+ return ((resThis != null && resThis.equals(resArg)) || (resThis == null && resArg == null)) >+ && ((idThis != null && idThis.equals(idArg)) || (idThis == null && idArg == null)); >+ } >+ return false; >+ } >+ >+ public int hashCode() { >+ IResource resThis=this.getUnderlyingResource(); >+ return resThis != null ? resThis.hashCode() : -1; >+ } >+} >Index: src/org/eclipse/hyades/test/ui/internal/navigator/action/MoveAction.java >=================================================================== >RCS file: src/org/eclipse/hyades/test/ui/internal/navigator/action/MoveAction.java >diff -N src/org/eclipse/hyades/test/ui/internal/navigator/action/MoveAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/test/ui/internal/navigator/action/MoveAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/********************************************************************** >+ * Copyright (c) 2008 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 >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.test.ui.internal.navigator.action; >+ >+import java.util.Iterator; >+import java.util.LinkedList; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.hyades.test.ui.UiPlugin; >+import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveRefactoring; >+import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveRefactoringWizard; >+import org.eclipse.hyades.test.ui.navigator.IProxyNode; >+import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover; >+import org.eclipse.hyades.ui.util.IDisposable; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.actions.SelectionListenerAction; >+ >+/** >+ * @author jgout,jbozier >+ * @version February 26, 2008 >+ */ >+public class MoveAction extends SelectionListenerAction implements IDisposable { >+ >+ private Shell shell; >+ private LinkedList folders; >+ private LinkedList proxies; >+ private boolean isResourceNav; >+ >+ public MoveAction(Shell shell) { >+ super(ActionMessages.MOVE_ACTION_NAME); >+ this.shell = shell; >+ folders = new LinkedList(); >+ proxies = new LinkedList(); >+ isResourceNav = false; >+ } >+ >+ public void run() { >+ if (! canActivate(shell)) >+ return; >+ MoveRefactoring refactoring = new MoveRefactoring(folders, proxies); >+ MoveRefactoringWizard wizard = new MoveRefactoringWizard(refactoring); >+ wizard.setDefaultPageTitle(ActionMessages.MOVE_ACTION_NAME); >+ wizard.setNeedsProgressMonitor(true); >+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard); >+ try { >+ op.run(shell , ""); //$NON-NLS-1$ >+ } catch (InterruptedException e) { >+ UiPlugin.logError(e); >+ } >+ } >+ >+ private boolean canActivate(Shell shell) { >+ return EditorUtil.saveEditors(shell); >+ } >+ >+ /** >+ * Selected elements should be only instances of IFile or IContainer (project/folder) >+ */ >+ private void sortSelectedElements() { >+ folders.clear(); >+ proxies.clear(); >+ IStructuredSelection sel = getStructuredSelection(); >+ for (Iterator it = sel.iterator(); it.hasNext();) { >+ Object o = it.next(); >+ if (o instanceof IProxyNode) { >+ proxies.add(o); >+ } else if (o instanceof IFile) { >+ IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy((IFile)o); >+ if (proxy != null) { >+ proxies.add(proxy); >+ } >+ } else if (o instanceof IAdaptable) { >+ IAdaptable a = (IAdaptable) o; >+ o = a.getAdapter(IFolder.class); >+ if(o != null) { >+ folders.add((IFolder) o); >+ } >+ } >+ } >+ } >+ >+ public void dispose() { >+ } >+ >+ public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceTestNav) { >+ this.isResourceNav = isResourceTestNav; >+ super.selectionChanged(structuredSelection); >+ sortSelectedElements(); >+ } >+ >+ public boolean isApplicableForSelection() { >+ //- Move action is only allowed for the resource view of the test navigator >+ if(!isResourceNav) return false; >+ return folders.size() > 0 || areProxiesMovable(); >+ } >+ >+ private boolean areProxiesMovable() { >+ boolean res = true; >+ for (Iterator it = proxies.iterator(); it.hasNext();) { >+ IProxyNode proxy = (IProxyNode)it.next(); >+ res &= proxy.getAdapter(IFile.class) != null && proxy instanceof IProxyNodeMover; >+ } >+ return res; >+ } >+}
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 Raw
Actions:
View
Attachments on
bug 166025
:
86571
|
86939
|
87044
|
88264
|
88300
|
88607
|
90738
|
90861
|
91404
|
92336
|
92365
|
92366
|
92444
|
92684
|
92820
|
93654
|
95363
|
95370
|
96228
|
96287
|
96841
|
96860
|
98036