Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 166025 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/hyades/test/core/launch/configurations/AbstractLaunchConfigurationFacade.java (-3 / +35 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 72-78 Link Here
72
		} else {
72
		} else {
73
			if (eObject.eResource() == null) {
73
			if (eObject.eResource() == null) {
74
				throw new IllegalArgumentException(
74
				throw new IllegalArgumentException(
75
						"eObject must belong to a resource");
75
						"eObject must belong to a resource"); //$NON-NLS-1$
76
			}
76
			}
77
			uri = eObject.eResource().getURI().toString();
77
			uri = eObject.eResource().getURI().toString();
78
			uriFragment = eObject.eResource().getURIFragment(eObject);
78
			uriFragment = eObject.eResource().getURIFragment(eObject);
Lines 153-159 Link Here
153
					Resource resource = eObject.eResource();
153
					Resource resource = eObject.eResource();
154
					if (resource == null) {
154
					if (resource == null) {
155
						throw new NullPointerException(
155
						throw new NullPointerException(
156
								"Resource object must be non-null");
156
								"Resource object must be non-null"); //$NON-NLS-1$
157
					}
157
					}
158
					uriList.add(eObject.eResource().getURI().toString());
158
					uriList.add(eObject.eResource().getURI().toString());
159
					uriFragmentList.add(eObject.eResource().getURIFragment(
159
					uriFragmentList.add(eObject.eResource().getURIFragment(
Lines 279-283 Link Here
279
		}
279
		}
280
		configuration.setAttribute(property, container);
280
		configuration.setAttribute(property, container);
281
	}
281
	}
282
	
283
	/**
284
	 * Returns whether the given property in a launch configuration is an EMF reference
285
	 * to an object with the same URI as the given URI.
286
	 * @param configuration
287
	 * @param property Name of the property.
288
	 * @param uri The URI to compare to. null is not allowed.
289
	 * @return <code>true</code> if the launch configuration has a property with this name,
290
	 * and if it is an EMF reference to an object with the same URI as <code>uri</code>.
291
	 * @throws CoreException
292
	 */
293
	protected static boolean isSameURI(ILaunchConfiguration configuration, String property, URI uri) throws CoreException {
294
		String uriString = configuration.getAttribute(property
295
				+ PROPERTY_SUFFIX_URI, (String) null);
296
		String uriFragment = configuration.getAttribute(property
297
				+ PROPERTY_SUFFIX_FRAGMENT, (String) null);
298
		return uri.trimFragment().toString().equals(uriString)
299
			&& uri.fragment().equals(uriFragment);
300
	}
301
302
	/**
303
	 * Updates an EMF reference property within a launch configuration by changing its URI.
304
	 * This API is provided for refactor use cases when the URI of a referenced EMF object
305
	 * needs to be updated.
306
	 * @param configuration
307
	 * @param property Name of the property.
308
	 * @param newURI The new URI.
309
	 */
310
	protected static void updateURI(ILaunchConfigurationWorkingCopy configuration, String property, URI newURI) {
311
		configuration.setAttribute(property + PROPERTY_SUFFIX_URI, newURI.trimFragment().toString());
312
		configuration.setAttribute(property + PROPERTY_SUFFIX_FRAGMENT, newURI.fragment());
313
	}
282
314
283
}
315
}
(-)src/org/eclipse/hyades/test/core/launch/configurations/TestLaunchConfigurationFacade.java (-3 / +28 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: TestLaunchConfigurationFacade.java,v 1.10 2007/05/03 02:23:44 paules Exp $
7
 * $Id: TestLaunchConfigurationFacade.java,v 1.7 2006/05/19 15:44:10 mddunn Exp $
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
10
 *     IBM Corporation - initial API and implementation
Lines 16-21 Link Here
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationType;
17
import org.eclipse.debug.core.ILaunchConfigurationType;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.emf.common.util.URI;
19
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.resource.ResourceSet;
21
import org.eclipse.emf.ecore.resource.ResourceSet;
21
import org.eclipse.hyades.models.common.testprofile.TPFTest;
22
import org.eclipse.hyades.models.common.testprofile.TPFTest;
Lines 100-106 Link Here
100
	/**
101
	/**
101
	 * Validates a Test launch configuration.
102
	 * Validates a Test launch configuration.
102
	 * The validation is performed by the validator registered in the extension registry
103
	 * The validation is performed by the validator registered in the extension registry
103
	 * using the extension point <code>org.eclipse.hyades.test.core.launchconfigValidator</code>.
104
	 * using the extension point <code>org.eclipse.hyades.test.core.launchConfigValidator</code>.
104
	 * @param configuration A launch configuration.
105
	 * @param configuration A launch configuration.
105
	 * @param resourceSet The resource set that should be used for loading EMF objects,
106
	 * @param resourceSet The resource set that should be used for loading EMF objects,
106
	 * if required.
107
	 * if required.
Lines 135-138 Link Here
135
        return createOKDiagnostic();
136
        return createOKDiagnostic();
136
	}
137
	}
137
	
138
	
139
	/**
140
	 * Returns whether a test launch configuration references a test that has a given URI.
141
	 * @param configuration A test launch configuration.
142
	 * @param uri A URI to compare to.
143
	 * @return <code>true</code> if the test launch configuration references a test with the
144
	 * same URI as <code>uri</code>.
145
	 * @throws CoreException
146
	 */
147
	public static boolean isTestURI(ILaunchConfiguration configuration, URI uri) throws CoreException {
148
		return isSameURI(configuration, PROPERTY_TEST, uri);
149
	}
150
	
151
	/**
152
	 * Updates a test launch configuration by changing its test URI.
153
	 * This API is provided for refactor use cases when a test URI is changed. If the
154
	 * launch configuration's test must be changed, use {@link #setTest(ILaunchConfigurationWorkingCopy, TPFTest)}
155
	 * instead.
156
	 * @param configuration A test launch configuration.
157
	 * @param newURI The new URI of the test.
158
	 * @throws CoreException
159
	 */
160
	public static void updateTestURI(ILaunchConfigurationWorkingCopy configuration, URI newURI) throws CoreException {
161
		updateURI(configuration, PROPERTY_TEST, newURI);
162
	}
138
}
163
}
(-)META-INF/MANIFEST.MF (-1 / +10 lines)
Lines 82-94 Link Here
82
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.2.0,4.0.0)",
82
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.2.0,4.0.0)",
83
 org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)",
83
 org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)",
84
 org.eclipse.xsd;bundle-version="[2.2.0,3.0.0)",
84
 org.eclipse.xsd;bundle-version="[2.2.0,3.0.0)",
85
 org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
85
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
86
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
86
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
87
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
88
 org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
87
 org.eclipse.tptp.platform.models;bundle-version="[4.2.0,5.0.0)",
89
 org.eclipse.tptp.platform.models;bundle-version="[4.2.0,5.0.0)",
88
 org.eclipse.hyades.test.core;bundle-version="[4.2.0,5.0.0)",
90
 org.eclipse.hyades.test.core;bundle-version="[4.2.0,5.0.0)",
89
 org.eclipse.hyades.trace.ui;bundle-version="[4.2.0,5.0.0)";resolution:=optional,
91
 org.eclipse.hyades.trace.ui;bundle-version="[4.2.0,5.0.0)";resolution:=optional,
90
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
92
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
93
 org.eclipse.help.ui;bundle-version="[3.2.0,4.0.0)",
94
 org.eclipse.ui.cheatsheets;bundle-version="[3.2.0,4.0.0)",
95
 org.eclipse.pde.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
91
 org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
96
 org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
92
 org.eclipse.birt.chart.engine;bundle-version="[2.1.0,3.0.0)";resolution:=optional
97
 org.eclipse.birt.chart.engine;bundle-version="[2.1.0,3.0.0)";resolution:=optional,
98
 org.eclipse.birt.core;bundle-version="[2.1.0,3.0.0)";resolution:=optional,
99
 org.eclipse.ui.browser;bundle-version="[3.2.0,4.0.0)",
100
 org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
101
 org.eclipse.ltk.ui.refactoring;bundle-version="[3.2.0,4.0.0)"
93
Eclipse-LazyStart: true
102
Eclipse-LazyStart: true
94
Bundle-RequiredExecutionEnvironment: J2SE-1.4
103
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/hyades/test/ui/navigator/IFileProxyFactory.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
 *  Implementation of this interface should be used in the following extension point: 
17
 *  Implementation of this interface should be used in the following extension point: 
18
 * <p><code>org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory</code></p>
18
 * <p><code>org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory</code></p>
19
 * @author jgout
19
 * @author jgout
20
 * @version February 26, 2008
20
 * @since 3.2
21
 * @since 3.2
21
 */
22
 */
22
public interface IFileProxyFactory {
23
public interface IFileProxyFactory {
Lines 25-30 Link Here
25
	 * @param file the file to convert in proxy.
26
	 * @param file the file to convert in proxy.
26
	 * @param parent an existing object (proxy node or not) which is the parent of the file proxy node in the proxy node hierarchy.
27
	 * @param parent an existing object (proxy node or not) which is the parent of the file proxy node in the proxy node hierarchy.
27
	 * @return a proxy which is used in the test navigator instead of the file itself.
28
	 * @return a proxy which is used in the test navigator instead of the file itself.
29
	 * The returned node must meet the following condition:
30
	 * <code>file.equals(factory.create(file, parent).getAdapter(IFile.class))</code>
28
	 */
31
	 */
29
	public IProxyNode create(IFile file, Object parent);
32
	public IProxyNode create(IFile file, Object parent);
30
	
33
	
(-)src/org/eclipse/hyades/test/ui/navigator/FileProxyNode.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 41-50 Link Here
41
 * This class is dedicated to wrap physical file into proxy 
41
 * This class is dedicated to wrap physical file into proxy 
42
 * 
42
 * 
43
 * @author jgout
43
 * @author jgout
44
 * @version February 26, 2008
44
 * @since 3.2
45
 * @since 3.2
45
 */
46
 */
46
public abstract class FileProxyNode implements IProxyNodeRenamer, IExtendedProxyNode {
47
public abstract class FileProxyNode extends AbstractProxy implements IProxyNodeRenamer, IExtendedProxyNode {
47
48
	
48
	private IFile file;
49
	private IFile file;
49
50
50
    /**
51
    /**
(-)src/org/eclipse/hyades/test/ui/navigator/IFileProxyManager.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2006 IBM Corporation and others. 
2
 * Copyright (c) 2005, 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 17-22 Link Here
17
 * This interface is not intended to be implemented by client.
17
 * This interface is not intended to be implemented by client.
18
 * 
18
 * 
19
 * @author jgout
19
 * @author jgout
20
 * @version February 26, 2008
20
 * @since 4.0
21
 * @since 4.0
21
 */
22
 */
22
public interface IFileProxyManager {
23
public interface IFileProxyManager {
Lines 72-77 Link Here
72
     * @param fileName name of the underlying resource of the searched proxy
73
     * @param fileName name of the underlying resource of the searched proxy
73
     * @param identifier identifier of the searched proxy
74
     * @param identifier identifier of the searched proxy
74
     * @return a proxy node or <code>null</code> if not found.
75
     * @return a proxy node or <code>null</code> if not found.
76
     * @deprecated use {@link #getCorrespondingProxy(new Proxy(fileName, String))} instead.
75
     */
77
     */
76
    public IProxyNode getCorrespondingProxy(String fileName, String identifier);
78
    public IProxyNode getCorrespondingProxy(String fileName, String identifier);
77
79
(-)src/org/eclipse/hyades/test/ui/navigator/ProxyNodeTransfer.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-29 Link Here
24
 * Transfer class used by Copy/Paste actions of proxy nodes, in resource mode.
24
 * Transfer class used by Copy/Paste actions of proxy nodes, in resource mode.
25
 * 
25
 * 
26
 * @author jgout
26
 * @author jgout
27
 * @version February 26, 2008
27
 * @since 3.3
28
 * @since 3.3
28
 */
29
 */
29
public class ProxyNodeTransfer extends ByteArrayTransfer {
30
public class ProxyNodeTransfer extends ByteArrayTransfer {
Lines 67-73 Link Here
67
		String identifier = dataIn.readUTF();
68
		String identifier = dataIn.readUTF();
68
		return ResourceTestNavigatorProvider.getSharedFileProxyManager().getCorrespondingProxy(fileName, identifier);
69
		return ResourceTestNavigatorProvider.getSharedFileProxyManager().getCorrespondingProxy(fileName, identifier);
69
	}
70
	}
70
71
	
71
	/**
72
	/**
72
	 * @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)
73
	 * @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)
73
	 */
74
	 */
(-)src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java (-15 / +119 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-18 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.hyades.test.ui.navigator;
12
package org.eclipse.hyades.test.ui.navigator;
13
13
14
import java.util.Collection;
15
import java.util.Set;
16
17
import org.eclipse.core.resources.IContainer;
18
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Path;
17
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.emf.common.util.URI;
24
import org.eclipse.emf.common.util.URI;
Lines 23-49 Link Here
23
import org.eclipse.hyades.test.ui.TestUIConstants;
29
import org.eclipse.hyades.test.ui.TestUIConstants;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory;
30
import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory;
25
import org.eclipse.hyades.test.ui.internal.navigator.proxy.IExtendedProxyNode;
31
import org.eclipse.hyades.test.ui.internal.navigator.proxy.IExtendedProxyNode;
32
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyManager.IUnboundedParent;
33
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceRegistry;
34
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteModelElementChange;
35
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.ModelPathChange;
36
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveModelChange;
37
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteModelChange;
38
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.UpdateModelChange;
39
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter;
40
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover;
41
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodePaster;
42
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater;
43
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
44
import org.eclipse.ltk.core.refactoring.Change;
26
import org.eclipse.ui.IMemento;
45
import org.eclipse.ui.IMemento;
27
46
28
/** EMF object proxy element for the test navigator.
47
/** EMF object proxy element for the test navigator.
29
 * Subclasses should provide IProxyNode methods implementation.
48
 * Subclasses should provide IProxyNode methods implementation.
30
 * EMF objects wrapped by subclasses will be stored in the test navigator resource set
49
 * EMF objects wrapped by subclasses will be stored in the test navigator resource set
31
 * @author jgout
50
 * @author jgout
51
 * @version February 26, 2008
32
 */
52
 */
33
public abstract class EObjectProxyNode implements IPersistableProxyNode, IExtendedProxyNode {
53
public abstract class EObjectProxyNode extends AbstractProxy implements IPersistableProxyNode, IExtendedProxyNode, 
54
	IReferencerProxyNode, IProxyNodeMover, IProxyNodeUpdater, IProxyNodeDeleter,IProxyNodePaster {
34
	
55
	
35
	private static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$
56
	private static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$
36
	
57
		
37
	private URI originatorURI;
58
	private URI originatorURI;
38
	private Object parent;
59
	private Object parent;
60
	private static final String VERSION = "4.3"; //$NON-NLS-1$
61
	private static final String TAG_STATE_VERSION = "stateVersion"; //$NON-NLS-1$
39
	
62
	
40
    /**
63
	/**
41
     * Constructor used to load a persisted proxy. 
64
     * Constructor used to load a persisted proxy. 
42
     * @param memento the memento containing the saved state of the proxy.
65
     * @param memento the memento containing the saved state of the proxy.
43
     * @param parent the parent node of the proxy node.
66
     * @param parent the parent node of the proxy node.
44
     */
67
     */
45
	public EObjectProxyNode(IMemento memento,  Object parent) {
68
	public EObjectProxyNode(IMemento memento,  Object parent) {
46
        String uriFragmentName;
69
        String uriFragmentName;
70
        checkVersion(VERSION, memento);
47
        //- backward compatibility of the existing persisted proxy node states
71
        //- backward compatibility of the existing persisted proxy node states
48
        String uri = memento.getString(TestUIConstants.TAG_URI);
72
        String uri = memento.getString(TestUIConstants.TAG_URI);
49
        if(uri != null) {
73
        if(uri != null) {
Lines 53-62 Link Here
53
        } else {
77
        } else {
54
            uriFragmentName = memento.getString(TAG_URI_FRAGMENT);
78
            uriFragmentName = memento.getString(TAG_URI_FRAGMENT);
55
        }
79
        }
56
		//- this data is not persisted but added by the proxy node loader (FileProxyManager#buildProxy)
80
		//- this data is not persisted but added by the proxy node loader (FileProxyNodeCache#buildProxyFromSavedState)
57
        String uriRootName = memento.getString(TestUIConstants.TAG_URI_ROOT);
81
        String uriRootName = memento.getString(TestUIConstants.TAG_URI_ROOT);
58
        try {
82
        try {
59
            URI uriRoot = URI.createPlatformResourceURI(uriRootName);
83
            URI uriRoot = URI.createPlatformResourceURI(uriRootName,false);
60
            this.originatorURI = uriRoot.appendFragment(uriFragmentName);
84
            this.originatorURI = uriRoot.appendFragment(uriFragmentName);
61
        } catch (IllegalArgumentException e) {
85
        } catch (IllegalArgumentException e) {
62
            throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve uri field"); //$NON-NLS-1$        }
86
            throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve uri field"); //$NON-NLS-1$        }
Lines 64-69 Link Here
64
 		this.parent = parent;
88
 		this.parent = parent;
65
	}
89
	}
66
	
90
	
91
	protected void checkVersion(String version, IMemento memento) {
92
		String savedVersion = memento.getString(TAG_STATE_VERSION);
93
		if(savedVersion == null || !VERSION.equals(savedVersion)) {
94
			throw new ProxyNeedToBeRebuiltException();
95
		}
96
	}
97
67
	/**
98
	/**
68
	 *  Creates a proxy node from a emf object.
99
	 *  Creates a proxy node from a emf object.
69
	 *  CAUTION: this object should be stored in a EMF resource in order to get its URI
100
	 *  CAUTION: this object should be stored in a EMF resource in order to get its URI
Lines 101-107 Link Here
101
	
132
	
102
	/** 
133
	/** 
103
     * Identifier for an EMF object is its URI fragment part. 
134
     * Identifier for an EMF object is its URI fragment part. 
104
     * If there is no fragment identifier is empty, this means that the object is a root object.  
135
     * If there is the fragment identifier is empty, this means that the object is a root object.  
105
	 * @return the identifier of the proxy node.
136
	 * @return the identifier of the proxy node.
106
	 */
137
	 */
107
	public String getIdentifier() {
138
	public String getIdentifier() {
Lines 144-160 Link Here
144
     * @retrun an adapted object for the given class using the global plateform adapter manager.
175
     * @retrun an adapted object for the given class using the global plateform adapter manager.
145
	 */
176
	 */
146
	public Object getAdapter(Class adapter) {
177
	public Object getAdapter(Class adapter) {
147
		return Platform.getAdapterManager().getAdapter(this, adapter);
178
		//- this proxy is adaptable in IFile if it has been placed instead of a file
179
		if(adapter.isAssignableFrom(IFile.class) && getParent() instanceof IUnboundedParent) {
180
		    return getUnderlyingResource();
181
 		} else if(adapter == IProxyNodeUpdater.class 
182
 			|| adapter == IProxyNodeMover.class 
183
 			|| adapter == IProxyNodeDeleter.class
184
 			|| adapter == IProxyNodePaster.class) {
185
 			return this;
186
	 	} else {
187
			return Platform.getAdapterManager().getAdapter(this, adapter);
188
		}
148
	}
189
	}
149
190
150
	/**
191
	public void addReference(String refType, IProxy proxyRef) {
151
	 * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#getFactoryID()
192
		IResource ur = proxyRef.getUnderlyingResource();
152
	 * @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).
193
		if(ur instanceof IFile) {
153
	 */
194
			ReferenceRegistry.getInstance().addReference((IFile)getUnderlyingResource(), refType, (IFile)ur);
154
	public String getFactoryID() {
195
		}
155
		return EMFResourceProxyFactory.ID;
196
	}
197
198
	public void addBidirectionalReference(String refType, IReferencerProxyNode proxyRef, String oppositeRefType) {
199
		IResource ur = proxyRef.getUnderlyingResource();
200
		if(ur instanceof IFile) {
201
			ReferenceRegistry.getInstance().addBidirectionalReference((IFile)getUnderlyingResource(), refType, (IFile)ur, oppositeRefType);
202
		}
203
	}
204
	
205
	public void removeReference(IProxyNode proxyRef) {
206
		IResource ur = proxyRef.getUnderlyingResource();
207
		if(ur instanceof IFile) {
208
			ReferenceRegistry.getInstance().removeReference((IFile)getUnderlyingResource(), (IFile)ur);
209
		}
210
	}
211
212
	public Collection getReferences(String refType) {
213
		return ReferenceRegistry.getInstance().getReferences((IFile)getUnderlyingResource(), refType);
156
	}
214
	}
157
	
215
	
216
	public Set getReferenceTypes() {
217
		return ReferenceRegistry.getInstance().getReferenceTypes((IFile)getUnderlyingResource());
218
	}
219
158
	/**
220
	/**
159
	 * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#saveState(org.eclipse.ui.IMemento)
221
	 * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#saveState(org.eclipse.ui.IMemento)
160
	 * @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).
222
	 * @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).
Lines 164-169 Link Here
164
		memento.putString(TAG_URI_FRAGMENT, getOriginatorURI().fragment());
226
		memento.putString(TAG_URI_FRAGMENT, getOriginatorURI().fragment());
165
		return true;
227
		return true;
166
	}
228
	}
229
230
	public Change createMoveChange(IRefactoringContext context, IPath destinationPath) {
231
		return this.getAdapter(IFile.class) != null ? new MoveModelChange(this, context, destinationPath) : null;
232
	}
233
234
	public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referenced, String refType, IPath destinationPath) {
235
		return new UpdateModelChange(this, context);
236
	}
237
238
	public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath) {
239
		return new ModelPathChange(this, context, destinationPath);
240
	}
241
242
	public Change createDeleteChange(IRefactoringContext context) {
243
		return new DeleteModelElementChange(context, this);
244
	}
245
	
246
	public Change createPasteChange(IRefactoringContext context, IPath destinationPath,String [] targetName) {
247
		return new PasteModelChange(context,this,destinationPath,targetName);
248
	}
249
	
250
	//- overwrite AbstractProxy.equals to avoid to access to the underlying resource
251
	public boolean equals(Object arg0) {
252
		if(arg0 instanceof EObjectProxyNode) {
253
			URI argURI = ((EObjectProxyNode)arg0).originatorURI;
254
			return (originatorURI == null && argURI == null)  
255
				|| (originatorURI != null && originatorURI.equals(argURI));
256
		}
257
		return false;
258
	}
259
260
	//- overwrite AbstractProxy.hashCode to avoid to access to the underlying resource
261
	public int hashCode() {
262
		return originatorURI != null ? originatorURI.hashCode() : -2;
263
	}
264
265
	/**
266
	 * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#getFactoryID()
267
	 * @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).
268
	 */
269
	public String getFactoryID() {
270
		return EMFResourceProxyFactory.ID;
271
	}
167
	
272
	
168
	/**
273
	/**
169
	 * @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).
274
	 * @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).
Lines 176-180 Link Here
176
	public IResource getCorrespondingResource() {
281
	public IResource getCorrespondingResource() {
177
		return getUnderlyingResource();
282
		return getUnderlyingResource();
178
	}
283
	}
179
180
}
284
}
(-)src/org/eclipse/hyades/test/ui/navigator/IProxyNode.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-22 Link Here
15
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.graphics.Image;
16
16
17
/**
17
/**
18
 * Main interface to wrap objects into the test navigator
18
 * Main interface to wrap objects into the test navigator.
19
 * Instances of this interface must meet the following condition:
20
 * <code>getAdapter(IFile.class) == null || getAdapter(IFile.class) == getUnderlyingResource() </code>
21
 * 
19
 * @author jgout
22
 * @author jgout
23
 * @version February 26, 2008
20
 */
24
 */
21
public interface IProxyNode extends IAdaptable, IProxy {
25
public interface IProxyNode extends IAdaptable, IProxy {
22
26
(-)src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java (-11 / +116 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-25 Link Here
12
package org.eclipse.hyades.test.ui.navigator;
12
package org.eclipse.hyades.test.ui.navigator;
13
13
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.OperationCanceledException;
19
import org.eclipse.core.runtime.Path;
15
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.EObject;
16
import org.eclipse.emf.ecore.resource.Resource;
21
import org.eclipse.emf.ecore.resource.Resource;
17
import org.eclipse.hyades.models.common.common.CMNNamedElement;
22
import org.eclipse.hyades.models.common.common.CMNNamedElement;
18
import org.eclipse.hyades.test.core.util.EMFUtil;
23
import org.eclipse.hyades.test.core.util.EMFUtil;
24
import org.eclipse.hyades.test.ui.TestUIConstants;
19
import org.eclipse.hyades.test.ui.UiPlugin;
25
import org.eclipse.hyades.test.ui.UiPlugin;
26
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction;
27
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveModelChange;
28
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.RefactoringMessages;
20
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
29
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
30
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2;
31
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
21
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIInlineEditor;
32
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIInlineEditor;
22
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
33
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
34
import org.eclipse.ltk.core.refactoring.Change;
35
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
36
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.ui.IEditorInput;
37
import org.eclipse.ui.IEditorInput;
24
import org.eclipse.ui.IEditorPart;
38
import org.eclipse.ui.IEditorPart;
25
import org.eclipse.ui.IEditorReference;
39
import org.eclipse.ui.IEditorReference;
Lines 33-43 Link Here
33
 * Proxy node for <code>CMNNamedElement</code> element.
47
 * Proxy node for <code>CMNNamedElement</code> element.
34
 * @author jgout
48
 * @author jgout
35
 */
49
 */
36
public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer  {
50
/**
51
 * @author jgout
52
 * @version February 26, 2008
53
 * @since 
54
 */
55
public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer2, IProxyNodeRenamer  {
37
	
56
	
38
	private final static String TAG_NAME = "name"; //$NON-NLS-1$
57
	private final static String TAG_NAME = "name"; //$NON-NLS-1$
39
	private final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
58
	private final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
40
	
59
41
	private String name;
60
	private String name;
42
	private String description;
61
	private String description;
43
62
Lines 89-94 Link Here
89
		this.name = name;
108
		this.name = name;
90
	}
109
	}
91
	
110
	
111
 	/**
112
 	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
113
 	 */
114
 	public Object getAdapter(Class adapter) {
115
 		if (adapter == IProxyNodeRenamer2.class) {
116
			return this;
117
		} if (adapter == IProxyNodeRenamer.class) {
118
			return this;
119
		} else {
120
			return super.getAdapter(adapter);
121
		}
122
	}
123
92
	/**
124
	/**
93
	 * @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).
125
	 * @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).
94
	 */
126
	 */
Lines 104-110 Link Here
104
	public String getDescription() {
136
	public String getDescription() {
105
		return this.description;
137
		return this.description;
106
	}
138
	}
107
108
	/** 
139
	/** 
109
	 * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#isApplicableFor()
140
	 * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#isApplicableFor()
110
	 */
141
	 */
Lines 168-185 Link Here
168
    
199
    
169
	/**
200
	/**
170
	 * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#performUserInteraction(java.lang.String)
201
	 * @see org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer#performUserInteraction(java.lang.String)
202
	 * @deprecated
171
	 */
203
	 */
172
	public RenamerUIStatus performUserInteraction(String oldName) {
204
	public RenamerUIStatus performUserInteraction(String oldName) {
173
		return new RenamerUIInlineEditor();
205
		return new RenamerUIInlineEditor();
174
	}
206
	}
175
	
207
	
176
	/**
208
	public boolean saveState(IMemento memento) {
177
	 * @see org.eclipse.hyades.test.ui.navigator.EObjectProxyNode#saveState(org.eclipse.ui.IMemento)
209
		if (this instanceof IPersistableProxyNode) {
178
	 * @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).
210
			//- data from CMNNamedElementProxyNode
179
	 */
211
			memento.putString(TestUIConstants.TAG_NAME, getText());
180
	public boolean saveState(IMemento memento) { 
212
			return super.saveState(memento);
181
		memento.putString(TAG_NAME, getName());
213
		}	
182
		return super.saveState(memento);
214
		return false;
215
	}
216
217
	public Change createRenameChange(IRefactoringContext context, String newName) {
218
		if(getAdapter(IFile.class) != null) {
219
			IPath oldPath = getUnderlyingResource().getFullPath();
220
			IPath newPath = oldPath.removeLastSegments(1).append(new Path(newName+'.'+oldPath.getFileExtension()));
221
			return new RenameModelChange(this, context, newPath, newName);
222
		} else {
223
			return new RenameElementChange(this, context, newName);
224
		}
225
	}
226
	
227
	protected class RenameElementChange extends Change {
228
		private EMFRefactoringTransaction context;
229
		private String newName;
230
		private CMNNamedElementProxyNode proxy;
231
		
232
		public RenameElementChange(CMNNamedElementProxyNode node, IRefactoringContext context, String newName) {
233
			this.proxy = node;
234
			this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
235
			this.newName = newName;
236
		}
237
		
238
		public Change perform(IProgressMonitor pm) throws CoreException {
239
			if(context != null) {
240
				EObject object = context.getResourceSet().getEObject(getOriginatorURI(), true);
241
				((CMNNamedElement)object).setName(newName);
242
				context.addResourceToSave(object.eResource());
243
			}
244
			return null;
245
		}
246
247
		public Object getModifiedElement() {
248
			return proxy;
249
		}
250
251
		public String getName() {
252
			return NLS.bind(RefactoringMessages.RENAME_PROXY, proxy.getText(), newName);		
253
		}
254
255
		public void initializeValidationData(IProgressMonitor pm) {
256
		}
257
258
		public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
259
			return new RefactoringStatus();
260
		}
183
	}
261
	}
184
	
262
	
263
	protected class RenameModelChange extends MoveModelChange {
264
		private IRefactoringContext context;
265
		private String newName;
266
		public RenameModelChange(IProxyNode node, IRefactoringContext context, IPath destinationPath, String newName) {
267
			super(node, context, destinationPath);
268
			this.context = context;
269
			this.newName = newName;
270
		}
271
		public Change perform(IProgressMonitor pm) throws CoreException {
272
			Change change = super.perform(pm);
273
			EMFRefactoringTransaction t = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
274
			if(t != null) {
275
				EObject object = t.getResourceSet().getEObject(getOriginatorURI(), false);
276
				((CMNNamedElement)object).setName(newName);
277
			}
278
			return change;
279
		}
280
		
281
		protected void handleFileAlreadyExists(RefactoringStatus status) {
282
			//- this is actually a rename but there is a conflict name, this is an error.
283
			status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROXY_DURING_RENAME, destination.toPortableString()));
284
		}
285
286
		public String getName() {
287
			return NLS.bind(RefactoringMessages.RENAME_PROXY, proxy.getText(), destination.removeFileExtension().lastSegment());		
288
		}
289
	}
185
}
290
}
(-)src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java (-2 / +165 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-31 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.LinkedList;
15
import java.util.LinkedList;
16
import java.util.List;
16
17
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationType;
17
import org.eclipse.emf.common.util.EList;
24
import org.eclipse.emf.common.util.EList;
25
import org.eclipse.emf.common.util.URI;
18
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
28
import org.eclipse.hyades.models.common.facades.behavioral.IBlock;
29
import org.eclipse.hyades.models.common.facades.behavioral.IDecision;
30
import org.eclipse.hyades.models.common.facades.behavioral.ILoop;
31
import org.eclipse.hyades.models.common.facades.behavioral.ITest;
32
import org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation;
19
import org.eclipse.hyades.models.common.testprofile.TPFTestCase;
33
import org.eclipse.hyades.models.common.testprofile.TPFTestCase;
20
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
34
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
35
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
21
import org.eclipse.hyades.test.ui.TestUIConstants;
36
import org.eclipse.hyades.test.ui.TestUIConstants;
22
import org.eclipse.hyades.test.ui.TestUIExtension;
37
import org.eclipse.hyades.test.ui.TestUIExtension;
23
import org.eclipse.hyades.test.ui.TestUIImages;
38
import org.eclipse.hyades.test.ui.TestUIImages;
39
import org.eclipse.hyades.test.ui.UiPlugin;
40
import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory;
41
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager;
42
import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager;
43
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteTestInvocationChange;
44
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.LaunchConfigurationDeleteChange;
45
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.LaunchConfigurationUpdateChange;
46
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
25
import org.eclipse.hyades.ui.extension.IAssociationConstants;
47
import org.eclipse.hyades.ui.extension.IAssociationConstants;
26
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
48
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
27
import org.eclipse.hyades.ui.extension.IAssociationMapping;
49
import org.eclipse.hyades.ui.extension.IAssociationMapping;
28
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
50
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
51
import org.eclipse.ltk.core.refactoring.Change;
52
import org.eclipse.ltk.core.refactoring.CompositeChange;
29
import org.eclipse.swt.graphics.Image;
53
import org.eclipse.swt.graphics.Image;
30
import org.eclipse.ui.IMemento;
54
import org.eclipse.ui.IMemento;
31
55
Lines 38-43 Link Here
38
 * <li> test suite proxy node is persisted using the proxy nodes persistency mechanism.
62
 * <li> test suite proxy node is persisted using the proxy nodes persistency mechanism.
39
 * </ul>
63
 * </ul>
40
 * @author jgout
64
 * @author jgout
65
 * @version February 26, 2008
41
 * @since 3.2
66
 * @since 3.2
42
 */
67
 */
43
public class DefaultTestSuiteProxyNode extends TypedElementProxyNode implements ITestSuiteProxyNode, IPersistableProxyNode {
68
public class DefaultTestSuiteProxyNode extends TypedElementProxyNode implements ITestSuiteProxyNode, IPersistableProxyNode {
Lines 64-70 Link Here
64
				tcProxies.add(proxy);
89
				tcProxies.add(proxy);
65
			}
90
			}
66
		}
91
		}
67
		testCases = (CMNNamedElementProxyNode[]) tcProxies.toArray(new CMNNamedElementProxyNode[tcProxies.size()]);	
92
		testCases = (CMNNamedElementProxyNode[]) tcProxies.toArray(new CMNNamedElementProxyNode[tcProxies.size()]);
93
		//- add references on associated datapools
94
		for (Iterator it = ts.getDatapools().iterator(); it.hasNext();) {
95
			DPLDatapool dp = (DPLDatapool) it.next();
96
			IProxyNode dpProxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(dp);
97
			if(dpProxy != null) {
98
				addBidirectionalReference("Test2Datapool", (IReferencerProxyNode)dpProxy, "Datapool2Test");  //$NON-NLS-1$ //$NON-NLS-2$
99
			}
100
		}
101
		//- add references on invocations
102
		addInvocationReferences(ts.getImplementor().getBlock());
103
	}
104
105
	private void addInvocationReferences(IBlock block) {
106
		if (block != null) {
107
			List actions = block.getActions();
108
			for (Iterator it = actions.iterator(); it.hasNext();) {
109
				Object action = it.next();
110
				if (action instanceof ILoop) {
111
					addInvocationReferences(((ILoop) action).getBlock());
112
				} else if (action instanceof IDecision) {
113
					IDecision ifAction = (IDecision) action;
114
					addInvocationReferences(ifAction.getFailureBlock());
115
					addInvocationReferences(ifAction.getSuccessBlock());
116
				} else if (action instanceof ITestInvocation) {
117
					ITestInvocation invocationAction = (ITestInvocation) action;
118
					ITest invokedTest = invocationAction.getInvokedTest();
119
					if (((EObject) invocationAction).eResource() != ((EObject) invokedTest).eResource()) {
120
						IProxyNode invokedProxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(invokedTest);
121
						if (invokedProxy != null) {
122
							addBidirectionalReference("TestInvoker2TestInvoked", (IReferencerProxyNode) invokedProxy, "TestInvoked2TestInvoker"); //$NON-NLS-1$ //$NON-NLS-2$
123
						}
124
					}
125
				}
126
			}
127
		}		
68
	}
128
	}
69
129
70
    /**
130
    /**
Lines 136-141 Link Here
136
		}
196
		}
137
	}
197
	}
138
	
198
	
199
    /**
200
     * Returns the ID of the factory that is used to recreate this proxy node.
201
     * @return the ID of the factory that is used to recreate this proxy node.
202
     */
203
	public String getFactoryID() {
204
		return EMFResourceProxyFactory.ID; 
205
	}
206
	
139
	/**
207
	/**
140
	 * @see org.eclipse.hyades.test.ui.navigator.EObjectProxyNode#getNodeKind()
208
	 * @see org.eclipse.hyades.test.ui.navigator.EObjectProxyNode#getNodeKind()
141
	 * @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).
209
	 * @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).
Lines 166-169 Link Here
166
		}
234
		}
167
		return true;
235
		return true;
168
	}	
236
	}	
237
238
	private void launchConfigurationUpdateChanges(CompositeChange composite, URI newURI) {
239
		ILaunchConfigurationType configsType = TestLaunchConfigurationFacade.getLaunchConfigurationType();
240
		ILaunchConfiguration[] configs = new ILaunchConfiguration[0];
241
		try {
242
			configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configsType);
243
		} catch (CoreException e) {
244
			UiPlugin.logError("Unable to get Launch Configuraions", e); //$NON-NLS-1$
245
		}
246
		for (int i = 0; i < configs.length; i++) {
247
			try {
248
				URI originatorURI = getOriginatorURI();
249
				if (TestLaunchConfigurationFacade.isTestURI(configs[i], originatorURI)) {
250
					composite.add(new LaunchConfigurationUpdateChange(configs[i], newURI.appendFragment(originatorURI.fragment())));;
251
				}
252
			} catch (CoreException e) {
253
				UiPlugin.logError("Unable to update Launch Configuraions", e); //$NON-NLS-1$
254
			}		
255
		}
256
	}
257
258
	private void launchConfigurationDeleteChanges(CompositeChange composite) {
259
		ILaunchConfigurationType configsType = TestLaunchConfigurationFacade.getLaunchConfigurationType();
260
		ILaunchConfiguration[] configs = new ILaunchConfiguration[0];
261
		try {
262
			configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configsType);
263
		} catch (CoreException e) {
264
			UiPlugin.logError("Unable to get Launch Configuraions", e); //$NON-NLS-1$
265
		}
266
		for (int i = 0; i < configs.length; i++) {
267
			try {
268
				URI originatorURI = getOriginatorURI();
269
				if (TestLaunchConfigurationFacade.isTestURI(configs[i], originatorURI)) {
270
					composite.add(new LaunchConfigurationDeleteChange(configs[i]));
271
				}
272
			} catch (CoreException e) {
273
				UiPlugin.logError("Unable to delete Launch Configuraions", e); //$NON-NLS-1$
274
			}		
275
		}
276
	}	
277
278
	public Change createRenameChange(IRefactoringContext context, String newName) {
279
		CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$
280
		Change superChange = super.createRenameChange(context, newName);
281
		if (superChange != null && superChange instanceof RenameModelChange) {
282
			launchConfigurationUpdateChanges(composite, ((RenameModelChange)superChange).getNewURI());
283
			composite.add(superChange);
284
		}
285
		composite.markAsSynthetic();
286
		return composite;
287
	}
288
289
	public Change createMoveChange(IRefactoringContext context, IPath destinationPath) {
290
		CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$
291
		launchConfigurationUpdateChanges(composite, URI.createPlatformResourceURI(destinationPath.toPortableString()));
292
		Change superChange = super.createMoveChange(context, destinationPath);
293
		if (superChange != null) {
294
			composite.add(superChange);
295
		}
296
		composite.markAsSynthetic();
297
		return composite;
298
	}
299
300
	public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath) {
301
		CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$
302
		launchConfigurationUpdateChanges(composite, URI.createPlatformResourceURI(destinationPath.toPortableString()));
303
		Change superChange = super.createUpdateChange(context, container, destinationPath);
304
		if (superChange != null) {
305
			composite.add(superChange);
306
		}
307
		composite.markAsSynthetic();
308
		return composite;
309
	}
310
311
	public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referenced, String refType, IPath destinationPath) {
312
		if(destinationPath == null) {
313
			if("TestInvoked2TestInvoker".equals(refType)) { //$NON-NLS-1$
314
				//- remove the link to referenced in this (clean invocation)
315
				return new DeleteTestInvocationChange(context, this, referenced);
316
			}
317
		}
318
		return super.createUpdateChange(context, referenced, refType, destinationPath);
319
	}
320
321
	public Change createDeleteChange(IRefactoringContext context) {
322
		CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$
323
		launchConfigurationDeleteChanges(composite);
324
		Change superChange = super.createDeleteChange(context);
325
		if(superChange != null) {
326
			composite.add(superChange);
327
		}
328
		composite.markAsSynthetic();
329
		return composite;
330
	}
331
169
}
332
}
(-)src/org/eclipse/hyades/test/ui/navigator/IPersistableFileProxyFactory.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
/** 
17
/** 
18
 * Interface for factories that can handle the persistancy of created proxy nodes.
18
 * Interface for factories that can handle the persistancy of created proxy nodes.
19
 * @author jgout
19
 * @author jgout
20
 * @version February 26, 2008
20
 * @since 3.3
21
 * @since 3.3
21
 */
22
 */
22
public interface IPersistableFileProxyFactory extends IFileProxyFactory {
23
public interface IPersistableFileProxyFactory extends IFileProxyFactory {
Lines 29-34 Link Here
29
     * @param file The file that the proxy node is the placeholder.
30
     * @param file The file that the proxy node is the placeholder.
30
     * @param parent The parent of the new created proxy node in the test navigator. 
31
     * @param parent The parent of the new created proxy node in the test navigator. 
31
     * @return The proxy node built based on the content of the given memento.
32
     * @return The proxy node built based on the content of the given memento.
33
	 * The returned node must meet the following condition:
34
	 * <code>file.equals(factory.create(file, parent).getAdapter(IFile.class))</code>
32
	 */
35
	 */
33
	public IProxyNode recreate(IMemento memento, IFile file, Object parent);
36
	public IProxyNode recreate(IMemento memento, IFile file, Object parent);
34
	
37
	
(-)src/org/eclipse/hyades/test/ui/navigator/IProxy.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-21 Link Here
15
15
16
/**
16
/**
17
 * Lightweight object that represents an arbitrary element within a resource.
17
 * Lightweight object that represents an arbitrary element within a resource.
18
 * Two instances of this class should be equal if and only if they have equal
19
 * underlying resource and identifier.
18
 * @author jcanches
20
 * @author jcanches
21
 * @version February 26, 2008
19
 * @since 4.0
22
 * @since 4.0
20
 */
23
 */
21
public interface IProxy {
24
public interface IProxy {
(-)src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java (-5 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
/** General proxy for typed element. 
19
/** General proxy for typed element. 
20
 *  This class is derived for test suite, test case, test component and execution result
20
 *  This class is derived for test suite, test case, test component and execution result
21
 * @author jgout
21
 * @author jgout
22
 * @version February 26, 2008
22
 */
23
 */
23
public abstract class TypedElementProxyNode extends CMNNamedElementProxyNode implements ITypedElementProxyNode {
24
public abstract class TypedElementProxyNode extends CMNNamedElementProxyNode implements ITypedElementProxyNode {
24
	
25
	
Lines 81-88 Link Here
81
     * @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).
82
     * @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).
82
     */
83
     */
83
    public boolean saveState(IMemento memento) {
84
    public boolean saveState(IMemento memento) {
84
        memento.putString(TAG_TYPE, getType());
85
		if (this instanceof IPersistableProxyNode) {
85
        return super.saveState(memento);
86
			//- data from TypedElementProxyNode
86
    }
87
			memento.putString(TAG_TYPE, getType());
87
    
88
			return super.saveState(memento);
89
		}
90
		return false;
91
	}
88
}
92
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/CopyAction.java (-51 / +51 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 44-54 Link Here
44
44
45
/**
45
/**
46
 * Copy Action for the Resource mode.
46
 * Copy Action for the Resource mode.
47
 * @author jgout
47
 * @author jgout,jbozier
48
 * @version February 26, 2008
48
 */
49
 */
49
public class CopyAction extends Action implements IDisposable {
50
public class CopyAction extends Action implements IDisposable {
50
	private Clipboard clipboard;
51
	private Clipboard clipboard;
51
	private IStructuredSelection selection;
52
	private IStructuredSelection selection;
53
	private boolean isResourceNav;
52
	
54
	
53
	static class ClipboardManager {
55
	static class ClipboardManager {
54
		private Map clipboardContent;
56
		private Map clipboardContent;
Lines 133-143 Link Here
133
	
135
	
134
	
136
	
135
	public CopyAction(Clipboard clipboard) {
137
	public CopyAction(Clipboard clipboard) {
136
		super(UiPluginResourceBundle.command_Copy); //$NON-NLS-1$
138
		super(UiPluginResourceBundle.command_Copy);
137
		if (clipboard == null) {
139
		if (clipboard == null) {
138
			throw new IllegalArgumentException("Unable to perform copy action due to 'clipboard == null'"); //$NON-NLS-1$
140
			throw new IllegalArgumentException("Unable to perform copy action due to 'clipboard == null'"); //$NON-NLS-1$
139
		}
141
		}
140
		this.clipboard = clipboard;
142
		this.clipboard = clipboard;
143
		this.isResourceNav = false;
141
	}
144
	}
142
	
145
	
143
	public void dispose() {
146
	public void dispose() {
Lines 158-186 Link Here
158
		}
161
		}
159
	}
162
	}
160
163
161
	private boolean copyResources() {
164
	private void copyOneResource(IResource res) {
162
		if(selection.getFirstElement() instanceof IResource) {
165
		IPath location = res.getLocation();
163
			ClipboardManager.getInstance().clear();
166
		if (location != null) {
164
			List selectedResources = selection.toList();
167
			//- file path to be used in external copy
165
			for (Iterator it = selectedResources.iterator(); it.hasNext();) {
168
			ClipboardManager.getInstance().addFile(location.toOSString());
166
				IResource res = (IResource) it.next();
169
		}
167
				IPath location = res.getLocation();
170
		//- file name to by used in textual context copy 
168
				if (location != null) {
171
		ClipboardManager.getInstance().addText(res.getName());
169
					//- file path to be used in external copy
172
		//- resource itself to be used in internal copy (inside Eclipse)
170
					ClipboardManager.getInstance().addFile(location.toOSString());
173
		ClipboardManager.getInstance().addResource(res);
171
				}
172
				//- file name to by used in textual context copy 
173
				ClipboardManager.getInstance().addText(res.getName());
174
				//- resource itself to be used in internal copy (inside Eclipse)
175
				ClipboardManager.getInstance().addResource(res);
176
			}
177
			setClipboard();
178
			return true;
179
		} else {
180
			return false;
181
		}
182
	}
174
	}
183
175
	
184
	/** Tests whether the given proxy is a proxy of file or not
176
	/** Tests whether the given proxy is a proxy of file or not
185
	 * @param proxy
177
	 * @param proxy
186
	 * @return true if this proxy replaces a file
178
	 * @return true if this proxy replaces a file
Lines 190-226 Link Here
190
		return proxy instanceof FileProxyNode || parent instanceof IContainer;
182
		return proxy instanceof FileProxyNode || parent instanceof IContainer;
191
	}
183
	}
192
184
193
	private void copyProxies() {
185
	private void copyOneProxy(IProxyNode proxy) {
194
		if(selection.getFirstElement() instanceof IProxyNode) {
186
		if(isAFileProxy(proxy)) {
195
			ClipboardManager.getInstance().clear();
187
			IResource res = proxy.getUnderlyingResource();
196
			List proxies = selection.toList();
188
			IPath location = res.getLocation();
197
			for (Iterator it = proxies.iterator(); it.hasNext();) {
189
			if (location != null) {
198
				IProxyNode proxy = (IProxyNode) it.next();
190
				//- external file path of the underlying resource to be used in external copy
199
				if(isAFileProxy(proxy)) {
191
				ClipboardManager.getInstance().addFile(location.toOSString());
200
					IResource res = proxy.getUnderlyingResource();
192
			}
201
					IPath location = res.getLocation();
193
			//- underlying resource to be used in internal copy (inside Eclipse)
202
					if (location != null) {
194
			ClipboardManager.getInstance().addResource(res);
203
						//- external file path of the underlying resource to be used in external copy
195
		}
204
						ClipboardManager.getInstance().addFile(location.toOSString());
196
		//- Fully qualified proxy name to by used in textual context copy 
205
					}
197
		ClipboardManager.getInstance().addText(proxy.getClass().getName()+"::"+proxy.getText()); //$NON-NLS-1$
206
					//- underlying resource to be used in internal copy (inside Eclipse)
207
					ClipboardManager.getInstance().addResource(res);
208
				}
209
				//- Fully qualified proxy name to by used in textual context copy 
210
				ClipboardManager.getInstance().addText(proxy.getClass().getName()+"::"+proxy.getText()); //$NON-NLS-1$
211
198
212
				//- proxy itself for test navigator context copy
199
		//- proxy itself for test navigator context copy
213
				ClipboardManager.getInstance().addProxy(proxy);
200
		ClipboardManager.getInstance().addProxy(proxy);
201
	}
202
		
203
	private void copySelection() {
204
		ClipboardManager.getInstance().clear();
205
		List allSelected = selection.toList();
206
		for (Iterator it = allSelected.iterator(); it.hasNext();) {
207
			Object item = (it.next());
208
			if (item instanceof IResource) {
209
				copyOneResource((IResource)item);
210
			} else {
211
				if (item instanceof IProxyNode) {
212
					copyOneProxy((IProxyNode)item);
213
				}
214
			}
214
			}
215
			setClipboard();
216
		}
215
		}
216
		setClipboard();
217
	}
217
	}
218
218
219
	public void run() {
219
	public void run() {
220
		if(copyResources()) {
220
		copySelection();
221
			return;
222
		} 
223
		copyProxies();
224
	}
221
	}
225
222
226
	private boolean selectionIsHomogeneous() {
223
	private boolean selectionIsHomogeneous() {
Lines 283-288 Link Here
283
	}
280
	}
284
281
285
	public boolean isApplicableForSelection() {
282
	public boolean isApplicableForSelection() {
283
		//- Copy action only allowed if the navigator is presenting its resource mode
284
		if(!isResourceNav) return false;
286
		if (selection == null || selection.isEmpty()) {
285
		if (selection == null || selection.isEmpty()) {
287
			return false;
286
			return false;
288
		}	
287
		}	
Lines 297-303 Link Here
297
		return true;
296
		return true;
298
	}
297
	}
299
	
298
	
300
	public void selectionChanged(IStructuredSelection structuredSelection) {
299
	public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceNav) {
301
		selection = structuredSelection;
300
		selection = structuredSelection;
301
		this.isResourceNav = isResourceNav;
302
	}
302
	}
303
}
303
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteExtensionManager.java (-5 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-31 Link Here
24
import org.eclipse.swt.dnd.Clipboard;
24
import org.eclipse.swt.dnd.Clipboard;
25
25
26
/**
26
/**
27
 * @author jgout
27
 * @author jgout,jbozier
28
 * @since 3.3
28
 * @version February 26, 2008
29
 */
29
 */
30
public class PasteExtensionManager {
30
public class PasteExtensionManager {
31
	
31
	
Lines 42-48 Link Here
42
		public PasterExtensionInfo (String target, boolean strict, IConfigurationElement element) {
42
		public PasterExtensionInfo (String target, boolean strict, IConfigurationElement element) {
43
			this.strict = strict;
43
			this.strict = strict;
44
			try {
44
			try {
45
				this.target = Platform.getBundle(element.getDeclaringExtension().getNamespace()).loadClass(target);
45
				this.target = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()).loadClass(target);
46
			} catch (ClassNotFoundException e) {
46
			} catch (ClassNotFoundException e) {
47
				UiPlugin.logError(e);
47
				UiPlugin.logError(e);
48
			}
48
			}
Lines 126-132 Link Here
126
		return false;
126
		return false;
127
	}
127
	}
128
	
128
	
129
	/** Retruns all registered paster that can deal with the given target object.
129
	/** Returns all registered paster that can deal with the given target object.
130
	 * 
130
	 * 
131
	 * @param selection the current selection (location where the user wants to paste)
131
	 * @param selection the current selection (location where the user wants to paste)
132
	 * @return IPaster [] the array of pasters registered for the given selection.
132
	 * @return IPaster [] the array of pasters registered for the given selection.
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/FileProxyInContainerPaste.java (-4 / +6 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 27-37 Link Here
27
27
28
/**
28
/**
29
 * Paste action for the resource mode.
29
 * Paste action for the resource mode.
30
 * @author jgout
30
 * @author jgout,jbozier
31
 * @since 3.3
31
 * @since 3.3
32
 * @version February 26, 2008
33
 * @deprecated
32
 */
34
 */
33
public class FileProxyInContainerPaste implements IPaster {
35
public class FileProxyInContainerPaste implements IPaster {
34
36
	
35
	private IResource [] getResourceFromClipboard(final Clipboard clipboard) {
37
	private IResource [] getResourceFromClipboard(final Clipboard clipboard) {
36
		final IResource[][] clipboardData = new IResource[1][];
38
		final IResource[][] clipboardData = new IResource[1][];
37
		Display.getCurrent().syncExec(new Runnable() {
39
		Display.getCurrent().syncExec(new Runnable() {
Lines 65-71 Link Here
65
		}
67
		}
66
		return false;
68
		return false;
67
	}
69
	}
68
70
	
69
	public boolean performPaste(Clipboard clipboard, Object selection) {
71
	public boolean performPaste(Clipboard clipboard, Object selection) {
70
		// - check for internal copy (inside eclipse)
72
		// - check for internal copy (inside eclipse)
71
		IResource [] res = getResourceFromClipboard(clipboard);
73
		IResource [] res = getResourceFromClipboard(clipboard);
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/FileFolderInContainerPaste.java (-4 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 40-47 Link Here
40
40
41
/**
41
/**
42
 * Paste action for the resource mode.
42
 * Paste action for the resource mode.
43
 * @author jgout
43
 * @author jgout,jbozier
44
 * @since 3.3
44
 * @since 3.3
45
 * @version February 26, 2008
46
 * @deprecated
45
 */
47
 */
46
public class FileFolderInContainerPaste implements IPaster {
48
public class FileFolderInContainerPaste implements IPaster {
47
49
Lines 150-157 Link Here
150
            throw new OperationCanceledException();
152
            throw new OperationCanceledException();
151
        }
153
        }
152
        //- if the user has omitted/misspelled the correct file extension (same as source one) we should add it 
154
        //- if the user has omitted/misspelled the correct file extension (same as source one) we should add it 
153
        if(!returnValue[0].endsWith(resource.getFileExtension())) {
155
        String fileExt = resource.getFileExtension();
154
            returnValue[0] += '.'+resource.getFileExtension();
156
        if (fileExt != null) {
157
        	if(!returnValue[0].endsWith(fileExt)) {
158
        		returnValue[0] += '.'+fileExt;
159
        	}
155
        }
160
        }
156
        return prefix.append(returnValue[0]);
161
        return prefix.append(returnValue[0]);
157
    }
162
    }
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/PasteAction.java (-9 / +18 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
13
14
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.IPasterExtended;
16
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
17
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
17
import org.eclipse.hyades.test.ui.navigator.actions.IPaster;
18
import org.eclipse.hyades.test.ui.navigator.actions.IPaster;
18
import org.eclipse.hyades.ui.util.IDisposable;
19
import org.eclipse.hyades.ui.util.IDisposable;
Lines 24-36 Link Here
24
import org.eclipse.ui.part.ResourceTransfer;
25
import org.eclipse.ui.part.ResourceTransfer;
25
26
26
/**
27
/**
27
 * @author jgout
28
 * @author jgout,jbozier
28
 * @since 3.3
29
 * @version February 26, 2008
29
 */
30
 */
30
public class PasteAction extends Action implements IDisposable {
31
public class PasteAction extends Action implements IDisposable {
31
	protected Clipboard clipboard;
32
	protected Clipboard clipboard;
32
	private IStructuredSelection selection;
33
	private IStructuredSelection selection;
33
	private Shell shell;
34
	private Shell shell;
35
	private boolean isResourceNav;
34
	
36
	
35
	public PasteAction(Shell shell, Clipboard clipboard) {
37
	public PasteAction(Shell shell, Clipboard clipboard) {
36
		super(UiPluginResourceBundle.command_Paste); 
38
		super(UiPluginResourceBundle.command_Paste); 
Lines 40-45 Link Here
40
		if (clipboard == null)
42
		if (clipboard == null)
41
			throw new IllegalArgumentException("Unable to perform paste action due to 'clipboard == null'"); //$NON-NLS-1$
43
			throw new IllegalArgumentException("Unable to perform paste action due to 'clipboard == null'"); //$NON-NLS-1$
42
		this.clipboard = clipboard;
44
		this.clipboard = clipboard;
45
		this.isResourceNav = false;
43
	}
46
	}
44
	
47
	
45
	public void dispose() {
48
	public void dispose() {
Lines 49-61 Link Here
49
		clipboard = null;
52
		clipboard = null;
50
		shell = null;
53
		shell = null;
51
	}
54
	}
52
	
55
		
53
	public void run() {
56
	public void run() {
54
		Object target = selection != null ? selection.getFirstElement() : null;
57
		Object target = selection != null ? selection.getFirstElement() : null;
55
		if(target != null) {
58
		if(target != null) {			
56
			IPaster [] pasters = PasteExtensionManager.getInstance().getPasters(target);
59
			IPaster [] pasters = PasteExtensionManager.getInstance().getPasters(target);			
57
			for (int i = 0; i < pasters.length; i++) {
60
			for (int i = 0; i < pasters.length; i++) {
58
				IPaster paster = pasters[i];
61
				IPaster paster = pasters[i];
62
				if (paster instanceof IPasterExtended) {
63
					((IPasterExtended)paster).setShell(shell);
64
				}
59
				if(paster.performPaste(clipboard, target)) {
65
				if(paster.performPaste(clipboard, target)) {
60
					return;
66
					return;
61
				}
67
				}
Lines 82-89 Link Here
82
			}
88
			}
83
		});
89
		});
84
		return clipboardData[0];
90
		return clipboardData[0];
85
	}
91
	}	
86
	
92
87
	private boolean doesClipboardContainProjects() {
93
	private boolean doesClipboardContainProjects() {
88
		//- if clipboard contains a project, paste is valid if project is open
94
		//- if clipboard contains a project, paste is valid if project is open
89
		IResource [] res = getResourceFromClipboard();
95
		IResource [] res = getResourceFromClipboard();
Lines 100-105 Link Here
100
	}
106
	}
101
	
107
	
102
	public boolean isApplicableForSelection() {
108
	public boolean isApplicableForSelection() {
109
		//- paste action is only allowed for resource view of the test navigator
110
		if(!isResourceNav) return false;
103
		//- regardless the selection if clipboard contains a project, this is possible to paste it.
111
		//- regardless the selection if clipboard contains a project, this is possible to paste it.
104
		if (doesClipboardContainProjects()) {
112
		if (doesClipboardContainProjects()) {
105
			return true;
113
			return true;
Lines 116-122 Link Here
116
		return false;
124
		return false;
117
	}
125
	}
118
	
126
	
119
	public void selectionChanged(IStructuredSelection structuredSelection) {
127
	public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceNav) {
120
		selection = structuredSelection;
128
		selection = structuredSelection;
129
		this.isResourceNav = isResourceNav;
121
	}
130
	}
122
}
131
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/RenameAction.java (-26 / +155 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-43 Link Here
19
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.SubProgressMonitor;
21
import org.eclipse.core.runtime.SubProgressMonitor;
22
import org.eclipse.hyades.test.ui.UiPlugin;
22
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
23
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
24
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.RenameRefactoring;
23
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
25
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
26
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
24
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
27
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
28
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2;
25
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
29
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
26
import org.eclipse.hyades.ui.internal.navigator.TreeNavigator;
30
import org.eclipse.hyades.ui.internal.navigator.TreeNavigator;
27
import org.eclipse.hyades.ui.util.IDisposable;
31
import org.eclipse.hyades.ui.util.IDisposable;
28
import org.eclipse.jface.action.Action;
32
import org.eclipse.jface.action.Action;
33
import org.eclipse.jface.dialogs.Dialog;
29
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
34
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
30
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
31
import org.eclipse.jface.viewers.StructuredSelection;
36
import org.eclipse.jface.viewers.StructuredSelection;
37
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
38
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
39
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
32
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.custom.TreeEditor;
41
import org.eclipse.swt.custom.TreeEditor;
34
import org.eclipse.swt.events.FocusAdapter;
42
import org.eclipse.swt.events.FocusAdapter;
35
import org.eclipse.swt.events.FocusEvent;
43
import org.eclipse.swt.events.FocusEvent;
44
import org.eclipse.swt.events.ModifyEvent;
45
import org.eclipse.swt.events.ModifyListener;
36
import org.eclipse.swt.graphics.Point;
46
import org.eclipse.swt.graphics.Point;
47
import org.eclipse.swt.layout.GridData;
48
import org.eclipse.swt.layout.GridLayout;
37
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Display;
50
import org.eclipse.swt.widgets.Display;
39
import org.eclipse.swt.widgets.Event;
51
import org.eclipse.swt.widgets.Event;
52
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Listener;
53
import org.eclipse.swt.widgets.Listener;
54
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.swt.widgets.Text;
55
import org.eclipse.swt.widgets.Text;
42
import org.eclipse.swt.widgets.Tree;
56
import org.eclipse.swt.widgets.Tree;
43
import org.eclipse.swt.widgets.TreeItem;
57
import org.eclipse.swt.widgets.TreeItem;
Lines 47-53 Link Here
47
/**
61
/**
48
 * @author  Jerome Gout
62
 * @author  Jerome Gout
49
 * @author  Paul E. Slauenwhite
63
 * @author  Paul E. Slauenwhite
50
 * @version March, 2007
64
 * @version February 26, 2008
51
 * @since   3.3
65
 * @since   3.3
52
 */
66
 */
53
public class RenameAction extends Action implements IDisposable {
67
public class RenameAction extends Action implements IDisposable {
Lines 60-65 Link Here
60
	protected TreeNavigator navigator;
74
	protected TreeNavigator navigator;
61
	protected IContainer renamedResource;
75
	protected IContainer renamedResource;
62
76
77
	private class RenameRefactoringWizard extends RefactoringWizard {
78
		private RenameRefactoringNewNameInputPage page;
79
80
		private RenameRefactoringWizard(RenameRefactoring refactoring, String name) {
81
			super(refactoring, DIALOG_BASED_USER_INTERFACE/* | NONE*/);
82
			this.page = new RenameRefactoringNewNameInputPage(refactoring, name);
83
		}
84
85
		protected void addUserInputPages() {
86
			addPage(page);
87
		}
88
	}
89
90
	class RenameRefactoringNewNameInputPage extends UserInputWizardPage {
91
		private RenameRefactoring refactoring;
92
		private Text nameText;
93
		private String oldName;
94
		private String newName;
95
		
96
		public RenameRefactoringNewNameInputPage(RenameRefactoring refactoring, String oldName) {
97
			super(""); //$NON-NLS-1$
98
			this.oldName = oldName;
99
			this.refactoring = refactoring;
100
		}
101
102
		public void createControl(Composite parent) {
103
			Composite result= new Composite(parent, SWT.NONE);
104
			setControl(result);
105
			result.setLayout(new GridLayout(2, false));
106
			
107
			Label label= new Label(result, SWT.NONE);
108
			label.setText(ActionMessages.RENAME_NEW_NAME_LABEL);
109
			nameText = new Text(result, SWT.SINGLE | SWT.BORDER);
110
			nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
111
			nameText.setText(oldName);
112
			nameText.addModifyListener(new ModifyListener() {
113
				public void modifyText(ModifyEvent e) {
114
					newName = nameText.getText();
115
					refactoring.setNewName(newName);
116
					setPageComplete(isPageComplete());
117
				}
118
			});
119
			nameText.selectAll();
120
			Dialog.applyDialogFont(result);
121
		}
122
123
		public boolean isPageComplete() {
124
			return newName != null && newName.length() > 0 && !newName.equals(oldName);
125
		}
126
	}
127
	
63
	public RenameAction(TreeNavigator treeNav) {
128
	public RenameAction(TreeNavigator treeNav) {
64
		super(TestNavigatorMessages.RenameAction_ActionName);
129
		super(TestNavigatorMessages.RenameAction_ActionName);
65
		this.navigator = treeNav;
130
		this.navigator = treeNav;
Lines 82-97 Link Here
82
			return true;
147
			return true;
83
		} else if (objSelected instanceof IProxyNode) {
148
		} else if (objSelected instanceof IProxyNode) {
84
			IProxyNode proxy = (IProxyNode) objSelected;
149
			IProxyNode proxy = (IProxyNode) objSelected;
85
			IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class);
150
			IProxyNodeRenamer2 renamer2 = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class);
86
			if (renamer != null) {
151
			if(renamer2 != null) {
87
				return renamer.isApplicableFor();
152
				return true;
88
			} else {
89
				//- this means that there is no renamer for this proxy
90
				return false;
91
			}
153
			}
92
		} else {
154
			oldActionValidation(proxy);
93
			return false;
94
		}
155
		}
156
		return false;
157
	}
158
159
	/**
160
	 * @param proxy
161
	 * @return
162
	 * @deprecated
163
	 */
164
	private boolean oldActionValidation(IProxyNode proxy) {
165
		IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class);
166
		if (renamer != null) {
167
			return renamer.isApplicableFor();
168
		}
169
		return false;
95
	}
170
	}
96
171
97
	/**
172
	/**
Lines 111-117 Link Here
111
	 * Create the text editor widget.
186
	 * Create the text editor widget.
112
	 * This code has been imported from RenameResourceAction
187
	 * This code has been imported from RenameResourceAction
113
	 * @param renamer
188
	 * @param renamer
114
	 * 
189
	 * @deprecated
115
	 */
190
	 */
116
	private void createTextEditor(final IProxyNodeRenamer renamer) {
191
	private void createTextEditor(final IProxyNodeRenamer renamer) {
117
		//- Create text editor parent.  This draws a nice bounding rect.
192
		//- Create text editor parent.  This draws a nice bounding rect.
Lines 165-170 Link Here
165
			textActionHandler.addText(textEditor);
240
			textActionHandler.addText(textEditor);
166
	}
241
	}
167
242
243
	/**
244
	 * 
245
	 * @param renamer
246
	 * @param newName
247
	 * @deprecated
248
	 */
168
	protected void performRename(final IProxyNodeRenamer renamer, final String newName) {
249
	protected void performRename(final IProxyNodeRenamer renamer, final String newName) {
169
		Runnable query = new Runnable() {
250
		Runnable query = new Runnable() {
170
			public void run() {
251
			public void run() {
Lines 242-247 Link Here
242
	 * This code is inspired from RenameResourceAction
323
	 * This code is inspired from RenameResourceAction
243
	 * @param oldName current value of the selected item
324
	 * @param oldName current value of the selected item
244
	 * @param renamer
325
	 * @param renamer
326
	 * @deprecated
245
	 */
327
	 */
246
	private void getNewNameInline(String oldName, IProxyNodeRenamer renamer) {
328
	private void getNewNameInline(String oldName, IProxyNodeRenamer renamer) {
247
		//- Make sure text editor is created only once. 
329
		//- Make sure text editor is created only once. 
Lines 265-292 Link Here
265
		Object objSelected = selection.getFirstElement();
347
		Object objSelected = selection.getFirstElement();
266
		if (objSelected instanceof IContainer) {
348
		if (objSelected instanceof IContainer) {
267
			renamedResource = (IContainer)objSelected;
349
			renamedResource = (IContainer)objSelected;
268
			//- reuse the inline editor to rename a project or folder node
350
			preformContainerRefactoringRename(renamedResource);
269
			getNewNameInline(((IContainer)objSelected).getName(), null);
270
		} else if (objSelected instanceof IProxyNode) {
351
		} else if (objSelected instanceof IProxyNode) {
271
			IProxyNode proxy = (IProxyNode) objSelected;
352
			IProxyNode proxy = (IProxyNode) objSelected;
272
			IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class);
353
			IProxyNodeRenamer2 renamer2 = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class);
273
			if (renamer != null) {
354
			if(renamer2 != null) {
274
				RenamerUIStatus status = renamer.performUserInteraction(proxy.getText());
355
				performProxyRefactoringRename(proxy);
275
				switch (status.getStatus()) {
356
			} else {
276
					case RenamerUIStatus.OK :
357
				IReferencerProxyNode ref = (IReferencerProxyNode)proxy.getAdapter(IReferencerProxyNode.class);
277
						performRename(renamer, status.getNewName());
358
				if(ref != null) {
278
						break;
359
					performProxyRefactoringRename(proxy);
279
					case RenamerUIStatus.CANCEL :
360
				} else {
280
						//- nothing to do 
361
					performOldRename(proxy);
281
						break;
282
					case RenamerUIStatus.INLINE_EDITOR :
283
						getNewNameInline(proxy.getText(), renamer);
284
						break;
285
				}
362
				}
286
			}
363
			}
287
		}
364
		}
288
	}
365
	}
289
366
367
	/**
368
	 * @param proxy
369
	 * @deprecated
370
	 */
371
	private void performOldRename(IProxyNode proxy) {
372
		//- this code will be removed in 5.0
373
		IProxyNodeRenamer renamer = (IProxyNodeRenamer) proxy.getAdapter(IProxyNodeRenamer.class);
374
		if (renamer != null) {
375
			RenamerUIStatus status = renamer.performUserInteraction(proxy.getText());
376
			switch (status.getStatus()) {
377
			case RenamerUIStatus.OK :
378
				performRename(renamer, status.getNewName());
379
				break;
380
			case RenamerUIStatus.CANCEL :
381
				//- nothing to do 
382
				break;
383
			case RenamerUIStatus.INLINE_EDITOR :
384
				getNewNameInline(proxy.getText(), renamer);
385
				break;
386
			}
387
		}
388
	}
389
390
	private void preformContainerRefactoringRename(IContainer container) {
391
		RenameRefactoring refactoring = new RenameRefactoring(container);
392
		performRefactoringRename(refactoring, container.getName());
393
	}
394
395
	private void performProxyRefactoringRename(IProxyNode proxy) {
396
		RenameRefactoring refactoring = new RenameRefactoring(proxy);
397
		performRefactoringRename(refactoring, proxy.getText());
398
	}
399
400
	private void performRefactoringRename(final RenameRefactoring refactoring, final String oldName) {
401
		Shell shell = Display.getCurrent().getActiveShell();
402
		if (! canActivate(shell))
403
			return;
404
		RefactoringWizard wizard = new RenameRefactoringWizard(refactoring, oldName);
405
		wizard.setDefaultPageTitle(ActionMessages.RENAME_ACTION_NAME);
406
		wizard.setNeedsProgressMonitor(true);
407
		RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
408
		try {
409
			op.run(shell , ""); //$NON-NLS-1$
410
		} catch (InterruptedException e) {
411
			UiPlugin.logError(e);
412
		}
413
	}
414
415
	private boolean canActivate(Shell shell) {
416
		return EditorUtil.saveEditors(shell);
417
	}
418
290
	public void selectionChanged(IStructuredSelection structuredSelection) {
419
	public void selectionChanged(IStructuredSelection structuredSelection) {
291
		selection = structuredSelection;
420
		selection = structuredSelection;
292
	}
421
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/TestNavigatorActionGroup.java (-59 / +37 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-22 Link Here
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import java.util.List;
19
import java.util.Set;
20
19
21
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IProject;
Lines 25-31 Link Here
25
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.emf.ecore.EObject;
25
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.hyades.test.ui.TestUIImages;
26
import org.eclipse.hyades.test.ui.TestUIImages;
28
import org.eclipse.hyades.test.ui.internal.model.ui.RemoveChildrenAction;
29
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator;
27
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator;
30
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
28
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
31
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
29
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
Lines 60-66 Link Here
60
import org.eclipse.ui.actions.AddBookmarkAction;
58
import org.eclipse.ui.actions.AddBookmarkAction;
61
import org.eclipse.ui.actions.AddTaskAction;
59
import org.eclipse.ui.actions.AddTaskAction;
62
import org.eclipse.ui.actions.CloseResourceAction;
60
import org.eclipse.ui.actions.CloseResourceAction;
63
import org.eclipse.ui.actions.DeleteResourceAction;
64
import org.eclipse.ui.actions.OpenResourceAction;
61
import org.eclipse.ui.actions.OpenResourceAction;
65
import org.eclipse.ui.actions.RefreshAction;
62
import org.eclipse.ui.actions.RefreshAction;
66
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
63
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
Lines 96-103 Link Here
96
	protected CloseResourceAction closeProjectAction;
93
	protected CloseResourceAction closeProjectAction;
97
	protected StopAction stopAction;
94
	protected StopAction stopAction;
98
95
99
	protected DeleteResourceAction deleteResourceAction;
96
	protected DeleteAction deleteAction;
100
	protected RemoveChildrenAction deleteChildEObject;
101
	
97
	
102
	protected NavigatorSorterActionGroup sorterActionGroup;
98
	protected NavigatorSorterActionGroup sorterActionGroup;
103
	protected NewActionGroup newActionGroup;
99
	protected NewActionGroup newActionGroup;
Lines 106-111 Link Here
106
	protected RenameAction renameAction;
102
	protected RenameAction renameAction;
107
	protected CopyAction copyAction;
103
	protected CopyAction copyAction;
108
	protected PasteAction pasteAction;
104
	protected PasteAction pasteAction;
105
	protected MoveAction moveAction;
109
    protected OpenWithActionGroup openWithActionGroup;
106
    protected OpenWithActionGroup openWithActionGroup;
110
	 	
107
	 	
111
	
108
	
Lines 133-138 Link Here
133
		renameAction.dispose();
130
		renameAction.dispose();
134
		stopAction.dispose();
131
		stopAction.dispose();
135
		pasteAction.dispose();
132
		pasteAction.dispose();
133
		moveAction.dispose();
136
		if(clipboard != null) {
134
		if(clipboard != null) {
137
			clipboard.dispose();
135
			clipboard.dispose();
138
			clipboard = null;
136
			clipboard = null;
Lines 186-217 Link Here
186
		TestUIImages.INSTANCE.setImageDescriptors(toggleEObjectChildren, TestUIImages.ACT_SHOW_EOBJECT_CHILDREN);
184
		TestUIImages.INSTANCE.setImageDescriptors(toggleEObjectChildren, TestUIImages.ACT_SHOW_EOBJECT_CHILDREN);
187
185
188
		ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
186
		ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
189
		deleteResourceAction = new DeleteResourceAction(shell);
187
		deleteAction = new DeleteAction(shell);
190
		deleteResourceAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
188
		deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
191
		deleteResourceAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));		
189
		deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));		
192
		deleteResourceAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
190
		deleteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
193
		
194
		deleteChildEObject = new RemoveChildrenAction(true)
195
		{
196
			protected List saveResources(Set changedResources)
197
			{
198
				TestNavigator testNavigator = (TestNavigator)getNavigator();
199
				testNavigator.getTreeViewer().remove(getStructuredSelection().toArray());
200
				
201
				testNavigator.setMonitoringResourceChange(false);
202
				try
203
				{
204
					return super.saveResources(changedResources);
205
				}
206
				finally
207
				{
208
					testNavigator.setMonitoringResourceChange(true);
209
				}
210
			}
211
		};
212
		deleteChildEObject.setStructuredViewer(((TestNavigator)getNavigator()).getViewer());
213
		deleteChildEObject.setShowErrorDialog(true);
214
		
215
		openReportAction = new OpenReportAction();	
191
		openReportAction = new OpenReportAction();	
216
		generateAction = new GenerateAction();	
192
		generateAction = new GenerateAction();	
217
        generateAction.setImageDescriptor(TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.GENERATE_TEST));//$NON-NLS-1$ 
193
        generateAction.setImageDescriptor(TestUIImages.INSTANCE.getImageDescriptor("e", TestUIImages.GENERATE_TEST));//$NON-NLS-1$ 
Lines 222-233 Link Here
222
		stopAction = new StopAction();	
198
		stopAction = new StopAction();	
223
		renameAction = new RenameAction((TreeNavigator)getNavigator());
199
		renameAction = new RenameAction((TreeNavigator)getNavigator());
224
		pasteAction = new PasteAction(shell, clipboard);
200
		pasteAction = new PasteAction(shell, clipboard);
225
		pasteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
201
		pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
226
		pasteAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
202
		pasteAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
227
		copyAction = new CopyAction(clipboard);
203
		copyAction = new CopyAction(clipboard);
228
		copyAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
204
		copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
229
		copyAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
205
		copyAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
230
		
206
		moveAction = new MoveAction(shell);
231
	}
207
	}
232
208
233
	/**
209
	/**
Lines 346-384 Link Here
346
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, stopAction);
322
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, stopAction);
347
			stopAction.setEnabled(stopAction.isApplicableForEnablement());
323
			stopAction.setEnabled(stopAction.isApplicableForEnablement());
348
		}
324
		}
349
		
325
		boolean isResourceTestNav = ((TestNavigator)getNavigator()).getCurrentViewIndex()==TestNavigator.VIEW_ID_RESOURCE;
350
		copyAction.selectionChanged(selection);
326
		copyAction.selectionChanged(selection, isResourceTestNav);
351
		if(copyAction.isApplicableForSelection()){
327
		if(copyAction.isApplicableForSelection()){
352
				menu.appendToGroup(INavigatorContribution.GROUP_DELETE, copyAction);
328
				menu.appendToGroup(INavigatorContribution.GROUP_DELETE, copyAction);
353
		}
329
		}
354
		
330
		
355
		pasteAction.selectionChanged(selection);
331
		pasteAction.selectionChanged(selection, isResourceTestNav);
356
		if(pasteAction.isApplicableForSelection()){
332
		if(pasteAction.isApplicableForSelection()){
357
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, pasteAction);
333
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, pasteAction);
358
		}
334
		}
359
					
335
					
360
		deleteResourceAction.setEnabled(false);		
336
		moveAction.selectionChanged(selection, isResourceTestNav);
361
		if(resSelection.size() == selection.size())
337
		if(moveAction.isApplicableForSelection()){
362
		{
338
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, moveAction);
363
			deleteResourceAction.selectionChanged(resSelection);
364
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, deleteResourceAction);
365
			
366
			addBookmarkAction.selectionChanged(resSelection);
367
			if(addBookmarkAction.isEnabled())
368
				menu.appendToGroup(INavigatorContribution.GROUP_DELETE, addBookmarkAction);
369
		}
339
		}
370
		if(!deleteResourceAction.isEnabled()){
340
		
371
			menu.add(new Separator());
341
		deleteAction.selectionChanged(selection);
372
			deleteChildEObject.selectionChanged(selection);
342
		if(deleteAction.isEnabled()) {
373
			if(deleteChildEObject.isEnabled())
343
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, deleteAction);
374
				menu.add(deleteChildEObject);
375
		}
344
		}
376
345
		
377
		renameAction.selectionChanged(selection);
346
		renameAction.selectionChanged(selection);
378
		if(renameAction.isApplicableForSelection())	{
347
		if(renameAction.isApplicableForSelection())	{
379
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, renameAction);
348
			menu.appendToGroup(INavigatorContribution.GROUP_DELETE, renameAction);
380
		}
349
		}
381
350
351
		if(resSelection.size() == selection.size() && selection.size() > 0)
352
		{
353
			addBookmarkAction.selectionChanged(resSelection);
354
			if(addBookmarkAction.isEnabled())
355
				menu.appendToGroup(INavigatorContribution.GROUP_DELETE, addBookmarkAction);
356
		}
357
382
		if(selection.size() == 1) {
358
		if(selection.size() == 1) {
383
			propertyDialogAction.selectionChanged(selection);
359
			propertyDialogAction.selectionChanged(selection);
384
			if(propertyDialogAction.isApplicableForSelection())
360
			if(propertyDialogAction.isApplicableForSelection())
Lines 394-400 Link Here
394
		actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(),	propertyDialogAction);
370
		actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(),	propertyDialogAction);
395
		actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
371
		actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
396
		actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
372
		actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
397
		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteResourceAction);
373
		actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
398
374
399
		frameListActionGroup.fillActionBars(actionBars);
375
		frameListActionGroup.fillActionBars(actionBars);
400
		newActionGroup.fillActionBars(actionBars);
376
		newActionGroup.fillActionBars(actionBars);
Lines 432-444 Link Here
432
		
408
		
433
		propertyDialogAction.setEnabled(structuredSelection.size() == 1);
409
		propertyDialogAction.setEnabled(structuredSelection.size() == 1);
434
		addBookmarkAction.selectionChanged(resourceStructuredSelection);
410
		addBookmarkAction.selectionChanged(resourceStructuredSelection);
435
		deleteResourceAction.selectionChanged(resourceStructuredSelection);
411
		deleteAction.selectionChanged(resourceStructuredSelection);
436
		addTaskAction.selectionChanged(structuredSelection);	
412
		addTaskAction.selectionChanged(structuredSelection);	
437
		refreshAction.selectionChanged(structuredSelection);
413
		refreshAction.selectionChanged(structuredSelection);
438
		openProjectAction.selectionChanged(structuredSelection);
414
		openProjectAction.selectionChanged(structuredSelection);
439
		closeProjectAction.selectionChanged(structuredSelection);
415
		closeProjectAction.selectionChanged(structuredSelection);
440
		copyAction.selectionChanged(structuredSelection);
416
		boolean isResourceTestNav = ((TestNavigator)getNavigator()).getCurrentViewIndex()==TestNavigator.VIEW_ID_RESOURCE;
441
		pasteAction.selectionChanged(structuredSelection);
417
		copyAction.selectionChanged(structuredSelection, isResourceTestNav);
418
		pasteAction.selectionChanged(structuredSelection, isResourceTestNav);
419
		moveAction.selectionChanged(structuredSelection, isResourceTestNav);
442
		renameAction.selectionChanged(structuredSelection);
420
		renameAction.selectionChanged(structuredSelection);
443
421
444
	
422
	
Lines 465-472 Link Here
465
	{
443
	{
466
		if(event.character == SWT.DEL && (event.stateMask == SWT.None))
444
		if(event.character == SWT.DEL && (event.stateMask == SWT.None))
467
		{
445
		{
468
			if(deleteResourceAction.isEnabled())
446
			if(deleteAction.isEnabled())
469
				deleteResourceAction.run();
447
				deleteAction.run();
470
				//- Swallow the event.
448
				//- Swallow the event.
471
				event.doit = false;
449
				event.doit = false;
472
		}
450
		}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 21-26 Link Here
21
21
22
/**
22
/**
23
 * @author jgout
23
 * @author jgout
24
 * @author jbozier
25
 * @version February 26, 2008
24
 * @since 3.2
26
 * @since 3.2
25
 */
27
 */
26
public class DatapoolProxyNode extends CMNNamedElementProxyNode {
28
public class DatapoolProxyNode extends CMNNamedElementProxyNode {
Lines 49-54 Link Here
49
		return new IProxyNode[0];
51
		return new IProxyNode[0];
50
	}
52
	}
51
	
53
	
54
	public String getFactoryID() {
55
		return EMFResourceProxyFactory.ID; 
56
	}
57
	
58
	public boolean saveState(IMemento memento) {
59
		//- data to retrieve the correct object 
60
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_NODE);
61
		return super.saveState(memento);
62
	}
63
	
52
	protected String getNodeKind() {
64
	protected String getNodeKind() {
53
		return TestUIConstants.DATAPOOL_NODE;
65
		return TestUIConstants.DATAPOOL_NODE;
54
	}
66
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java (-1 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @author jbozier
25
 * @version February 26, 2008
23
 * @since 3.2
26
 * @since 3.2
24
 */
27
 */
25
public class DeploymentFileProxyNode extends EMFResourceProxyNode {
28
public class DeploymentFileProxyNode extends EMFResourceProxyNode {
Lines 36-41 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DEPLOYMENT);
39
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DEPLOYMENT);
37
	}
40
	}
38
41
42
	public String getFactoryID() {
43
		return EMFResourceProxyFactory.ID; 
44
	}
45
	
46
	public boolean saveState(IMemento memento) {
47
		//- data to retrieve the correct object 
48
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_FILE_NODE);
49
		//- data from EMFResourceProxyNode
50
		memento.putString(TestUIConstants.TAG_NAME, getText());
51
		IProxyNode [] children = getChildren();
52
		for (int i = 0; i < children.length; i++) {
53
			if(!saveChildState(memento, children[i])) {
54
				return false;
55
			}
56
		}
57
		return true;
58
	}
59
	
39
	protected String getNodeKind() {
60
	protected String getNodeKind() {
40
		return TestUIConstants.DEPLOY_FILE_NODE;
61
		return TestUIConstants.DEPLOY_FILE_NODE;
41
	}
62
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java (-1 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-26 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
13
14
import java.util.Iterator;
15
16
import org.eclipse.hyades.models.common.configuration.CFGArtifact;
17
import org.eclipse.hyades.models.common.configuration.CFGLocation;
14
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
18
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
19
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
20
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
21
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
19
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.ui.IMemento;
25
import org.eclipse.ui.IMemento;
21
26
22
/**
27
/**
23
 * @author jgout
28
 * @author jgout
29
 * @author jbozier
30
 * @version February 26, 2008
24
 * @since 3.2
31
 * @since 3.2
25
 */
32
 */
26
public class DeploymentProxyNode extends CMNNamedElementProxyNode {
33
public class DeploymentProxyNode extends CMNNamedElementProxyNode {
Lines 30-35 Link Here
30
	 */
37
	 */
31
	public DeploymentProxyNode(TPFDeployment deploy, Object parent) {
38
	public DeploymentProxyNode(TPFDeployment deploy, Object parent) {
32
		super(deploy, parent);
39
		super(deploy, parent);
40
		for (Iterator it = deploy.getArtifacts().iterator(); it.hasNext();) {
41
			IProxyNode artifact = FileProxyNodeCache.getInstance().getCorrespondingProxy( (CFGArtifact)it.next());
42
			if(artifact != null) {
43
				addBidirectionalReference("Deploy2Artifact", (IReferencerProxyNode) artifact, "Artifact2Deploy");  //$NON-NLS-1$//$NON-NLS-2$
44
			}
45
		}
46
		for (Iterator it = deploy.getLocations().iterator(); it.hasNext();) {
47
			IProxyNode location = FileProxyNodeCache.getInstance().getCorrespondingProxy((CFGLocation)it.next());
48
			if(location != null) {
49
				addBidirectionalReference("Deploy2Location", (IReferencerProxyNode) location, "Location2Deploy"); //$NON-NLS-1$ //$NON-NLS-2$
50
			}
51
		}
33
	}
52
	}
34
53
35
	/**
54
	/**
Lines 49-54 Link Here
49
		return new IProxyNode[0];
68
		return new IProxyNode[0];
50
	}
69
	}
51
	
70
	
71
	public String getFactoryID() {
72
		return EMFResourceProxyFactory.ID; 
73
	}
74
	
75
	public boolean saveState(IMemento memento) {
76
		//- data to retrieve the correct object 
77
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_NODE);
78
		return super.saveState(memento);	
79
	}
80
	
52
	protected String getNodeKind() {
81
	protected String getNodeKind() {
53
    	return TestUIConstants.DEPLOY_NODE;
82
    	return TestUIConstants.DEPLOY_NODE;
54
    }
83
    }
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
23
24
/**
24
/**
25
 * @author jgout
25
 * @author jgout
26
 * @version February 26, 2008
26
 * @since 3.2
27
 * @since 3.2
27
 */
28
 */
28
public class TypedElementFactoryManager {
29
public class TypedElementFactoryManager {
Lines 111-116 Link Here
111
	 */
112
	 */
112
	public ITypedElementProxyFactory getFactoryFromID(String factoryID) {
113
	public ITypedElementProxyFactory getFactoryFromID(String factoryID) {
113
		Object value = factories.get(factoryID);
114
		Object value = factories.get(factoryID);
115
		if(value == null) return null;
114
		if (value instanceof IConfigurationElement) {
116
		if (value instanceof IConfigurationElement) {
115
			//- if the factory has not yet been loaded
117
			//- if the factory has not yet been loaded
116
			IConfigurationElement element = (IConfigurationElement) value;
118
			IConfigurationElement element = (IConfigurationElement) value;
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 29-34 Link Here
29
29
30
/**
30
/**
31
 * @author jgout
31
 * @author jgout
32
 * @author jbozier
33
 * @version February 26, 2008
32
 */
34
 */
33
public class DefaultTestCaseProxyNode extends TypedElementProxyNode implements ITestCaseProxyNode, IPersistableProxyNode {
35
public class DefaultTestCaseProxyNode extends TypedElementProxyNode implements ITestCaseProxyNode, IPersistableProxyNode {
34
36
Lines 75-80 Link Here
75
		}
77
		}
76
	}
78
	}
77
	
79
	
80
	public String getFactoryID() {
81
		return EMFResourceProxyFactory.ID; 
82
	}
83
	
84
	public boolean saveState(IMemento memento) {
85
		//- data to retrieve the correct object 
86
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCASE_NODE);
87
		return super.saveState(memento);
88
	}
89
		
78
	protected String getNodeKind() {
90
	protected String getNodeKind() {
79
		return TestUIConstants.TESTCASE_NODE;
91
		return TestUIConstants.TESTCASE_NODE;
80
	}
92
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java (-1 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @author jbozier
25
 * @version February 26, 2008
23
 * @since 3.2
26
 * @since 3.2
24
 */
27
 */
25
public class ArtifactFileProxyNode extends EMFResourceProxyNode {
28
public class ArtifactFileProxyNode extends EMFResourceProxyNode {
Lines 36-41 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_ARTIFACT);
39
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_ARTIFACT);
37
	}
40
	}
38
41
42
	public String getFactoryID() {
43
		return EMFResourceProxyFactory.ID;
44
	}
45
	
46
	public boolean saveState(IMemento memento) {
47
		//- data to retrieve the correct object 
48
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_FILE_NODE);
49
		//- data from EMFResourceProxyNode
50
		memento.putString(TestUIConstants.TAG_NAME, getText());
51
		IProxyNode [] children = getChildren();
52
		for (int i = 0; i < children.length; i++) {
53
			if(!saveChildState(memento, children[i])) {
54
				return false;
55
			}
56
		}
57
		return true;
58
	}
59
	
39
	public String getNodeKind() {
60
	public String getNodeKind() {
40
		return TestUIConstants.ARTIFACT_FILE_NODE;
61
		return TestUIConstants.ARTIFACT_FILE_NODE;
41
	}
62
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java (+21 lines)
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @author jbozier
25
 * @version February 26, 2008
23
 * @since 3.2
26
 * @since 3.2
24
 */
27
 */
25
public class DatapoolFileProxyNode extends EMFResourceProxyNode {
28
public class DatapoolFileProxyNode extends EMFResourceProxyNode {
Lines 36-41 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DATAPOOL);
39
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DATAPOOL);
37
	}
40
	}
38
	
41
	
42
	public String getFactoryID() {
43
		return EMFResourceProxyFactory.ID; 
44
	}
45
	
46
	public boolean saveState(IMemento memento) {
47
		//- data to retrieve the correct object 
48
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_FILE_NODE);
49
		//- data from EMFResourceProxyNode
50
		memento.putString(TestUIConstants.TAG_NAME, getText());
51
		IProxyNode [] children = getChildren();
52
		for (int i = 0; i < children.length; i++) {
53
			if(!saveChildState(memento, children[i])) {
54
				return false;
55
			}
56
		}
57
		return true;
58
	}
59
	
39
	protected String getNodeKind() {
60
	protected String getNodeKind() {
40
		return TestUIConstants.DATAPOOL_FILE_NODE;
61
		return TestUIConstants.DATAPOOL_FILE_NODE;
41
	}
62
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java (-2 / +25 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-26 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
13
14
import java.util.Iterator;
15
14
import org.eclipse.hyades.models.common.configuration.CFGArtifact;
16
import org.eclipse.hyades.models.common.configuration.CFGArtifact;
17
import org.eclipse.hyades.models.common.configuration.CFGClass;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
18
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
19
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
20
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
21
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
19
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.ui.IMemento;
24
import org.eclipse.ui.IMemento;
21
25
22
/**
26
/**
23
 * @author jgout
27
 * @author jgout
28
 * @author jbozier
29
 * @version February 26, 2008
24
 * @since 3.2
30
 * @since 3.2
25
 */
31
 */
26
public class ArtifactProxyNode extends CMNNamedElementProxyNode {
32
public class ArtifactProxyNode extends CMNNamedElementProxyNode {
Lines 39-44 Link Here
39
	 */
45
	 */
40
	public ArtifactProxyNode(CFGArtifact artifact, Object parent) {
46
	public ArtifactProxyNode(CFGArtifact artifact, Object parent) {
41
		super(artifact, parent);
47
		super(artifact, parent);
48
		//- add references on tets.
49
		for (Iterator it = artifact.getDeployableInstances().iterator(); it.hasNext();) {
50
			CFGClass test = (CFGClass) it.next();
51
			IProxyNode proxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(test);
52
			if(proxy != null && proxy instanceof IReferencerProxyNode) {
53
				addBidirectionalReference("Artifact2Test", (IReferencerProxyNode) proxy, "Test2Artifact"); //$NON-NLS-1$ //$NON-NLS-2$
54
			}
55
		}
42
	}
56
	}
43
	
57
	
44
	public Image getImage() {
58
	public Image getImage() {
Lines 50-57 Link Here
50
		return new IProxyNode[0];
64
		return new IProxyNode[0];
51
	}
65
	}
52
	
66
	
67
	public String getFactoryID() {
68
		return EMFResourceProxyFactory.ID;
69
	}
70
	
71
	public boolean saveState(IMemento memento) { 
72
		//- data to retrieve the correct object
73
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_NODE);
74
		return super.saveState(memento);
75
	}
76
	
53
	protected String getNodeKind() {
77
	protected String getNodeKind() {
54
		return TestUIConstants.ARTIFACT_NODE;
78
		return TestUIConstants.ARTIFACT_NODE;
55
	}
79
	}
56
	
57
}
80
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 33-38 Link Here
33
 * Delegation is made for typed object.
33
 * Delegation is made for typed object.
34
 *  
34
 *  
35
 * @author jgout
35
 * @author jgout
36
 * @author jbozier
37
 * @version February 26, 2008
36
 * @since 3.2
38
 * @since 3.2
37
 */
39
 */
38
public class EMFResourceProxyFactory implements IFileProxyFactory, IPersistableFileProxyFactory {
40
public class EMFResourceProxyFactory implements IFileProxyFactory, IPersistableFileProxyFactory {
Lines 40-46 Link Here
40
	/**
42
	/**
41
	 * Factory id.
43
	 * Factory id.
42
	 */
44
	 */
43
	public final static String ID = "EMFResourceProxyFactory"; //$NON-NLS-1$
45
	public final static String ID = "EMFResourceProxyFactory_4.3"; //$NON-NLS-1$
44
	
46
	
45
	/** This method is called to build a node that contains multiple EMF objects as children.
47
	/** This method is called to build a node that contains multiple EMF objects as children.
46
	 *  The object created depends of the extension of the file (.datapool -> DatapoolFileProxyNode)
48
	 *  The object created depends of the extension of the file (.datapool -> DatapoolFileProxyNode)
Lines 80-86 Link Here
80
     * @return the resource associated to the given file or <code>null</code> if the resource was unable to be loaded.
82
     * @return the resource associated to the given file or <code>null</code> if the resource was unable to be loaded.
81
     */
83
     */
82
	private Resource getEMFResource(IFile file) {
84
	private Resource getEMFResource(IFile file) {
83
		URI uri = URI.createPlatformResourceURI(file.getFullPath().toString());
85
		URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(),false);
84
		ResourceSet rs = new ResourceSetImpl();
86
		ResourceSet rs = new ResourceSetImpl();
85
        return rs.getResource(uri, true);
87
        return rs.getResource(uri, true);
86
	}
88
	}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java (-2 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @version February 26, 2008
23
 * @since 3.2
25
 * @since 3.2
24
 */
26
 */
25
public class TestComponentFileProxyNode extends EMFResourceProxyNode {
27
public class TestComponentFileProxyNode extends EMFResourceProxyNode {
Lines 36-43 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_COMPONENT);
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_COMPONENT);
37
	}
39
	}
38
	
40
	
41
	public String getFactoryID() {
42
		return EMFResourceProxyFactory.ID;
43
	}
44
	
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCOMPONENT_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i]))
53
				return false;
54
		}
55
		return true;
56
	}
57
	
39
	protected String getNodeKind() {
58
	protected String getNodeKind() {
40
    	return TestUIConstants.TESTCOMPONENT_FILE_NODE;
59
    	return TestUIConstants.TESTCOMPONENT_FILE_NODE;
41
    }
60
    }
42
61
	
43
}
62
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileFactoryManager.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 25-30 Link Here
25
25
26
/**
26
/**
27
 * @author jgout
27
 * @author jgout
28
 * @author jbozier
29
 * @version February 26, 2008
28
 * @since 3.2
30
 * @since 3.2
29
 */
31
 */
30
public class FileFactoryManager {
32
public class FileFactoryManager {
Lines 151-157 Link Here
151
			if (value instanceof IConfigurationElement) {
153
			if (value instanceof IConfigurationElement) {
152
				//- if the factory has not yet been loaded
154
				//- if the factory has not yet been loaded
153
				IConfigurationElement element = (IConfigurationElement) value;
155
				IConfigurationElement element = (IConfigurationElement) value;
154
				IFileProxyFactory factory; //$NON-NLS-1$
156
				IFileProxyFactory factory;
155
				try {
157
				try {
156
					if(element.getName().equals("file")) { //$NON-NLS-1$
158
					if(element.getName().equals("file")) { //$NON-NLS-1$
157
						//- old extension point
159
						//- old extension point
Lines 166-172 Link Here
166
				} catch (CoreException e) {
168
				} catch (CoreException e) {
167
					//- remove this element since we can not create a factory from it
169
					//- remove this element since we can not create a factory from it
168
					factories.remove(id);
170
					factories.remove(id);
169
					UiPlugin.logError("Enable to create the factory instance from configuration element");  //$NON-NLS-1$//$NON-NLS-2$
171
					UiPlugin.logError("Enable to create the factory instance from configuration element");  //$NON-NLS-1$
170
					return null;
172
					return null;
171
				}
173
				}
172
			} else if(value instanceof IFileProxyFactory) {
174
			} else if(value instanceof IFileProxyFactory) {
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java (-63 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-26 Link Here
15
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
15
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
16
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
16
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
17
import org.eclipse.hyades.models.common.testprofile.TPFTest;
17
import org.eclipse.hyades.models.common.testprofile.TPFTest;
18
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
18
import org.eclipse.hyades.test.ui.TestUIConstants;
19
import org.eclipse.hyades.test.ui.TestUIConstants;
19
import org.eclipse.hyades.test.ui.TestUIImages;
20
import org.eclipse.hyades.test.ui.TestUIImages;
20
import org.eclipse.hyades.test.ui.internal.model.EventUtil;
21
import org.eclipse.hyades.test.ui.internal.model.EventUtil;
21
import org.eclipse.hyades.test.ui.navigator.IExecutionResultProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.IExecutionResultProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
24
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
25
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
24
import org.eclipse.hyades.test.ui.navigator.ProxyNeedToBeRebuiltException;
26
import org.eclipse.hyades.test.ui.navigator.ProxyNeedToBeRebuiltException;
25
import org.eclipse.hyades.test.ui.navigator.TypedElementProxyNode;
27
import org.eclipse.hyades.test.ui.navigator.TypedElementProxyNode;
26
import org.eclipse.swt.graphics.Image;
28
import org.eclipse.swt.graphics.Image;
Lines 29-34 Link Here
29
/**
31
/**
30
 * @author jgout
32
 * @author jgout
31
 * @author jcanches
33
 * @author jcanches
34
 * @author jbozier
35
 * @version February 26, 2008
32
 * @since 3.2
36
 * @since 3.2
33
 */
37
 */
34
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode {
38
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode {
Lines 47-62 Link Here
47
	 */
51
	 */
48
	public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) {
52
	public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) {
49
		super(er, parent);
53
		super(er, parent);
50
		
51
//		LinkedList c = new LinkedList();
52
//		TPFExecutionHistory history = er.getExecutionHistory();
53
//		if (history != null ) {
54
//			EList events = history.getExecutionEvents();
55
//			for (Iterator it = events.iterator(); it.hasNext();) {
56
//				getEventChildren((TPFExecutionEvent) it.next(), c, er);
57
//			}
58
//		}
59
//		children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]);
60
		children = new IProxyNode[0];
54
		children = new IProxyNode[0];
61
		//- save the name of this element
55
		//- save the name of this element
62
		String name = er.getName();
56
		String name = er.getName();
Lines 74-84 Link Here
74
				name = testName;
68
				name = testName;
75
			}
69
			}
76
		}
70
		}
77
		setName(name);
71
        if((er.getTest() != null) && (((er.getTest()).getName()) != null)) {
78
		if (!(parent instanceof IExecutionResultProxyNode)) {
72
            if (test instanceof TPFTestSuite) {
79
			if (er.getExecutionHistory().getExecutionEvents() != null && er.getExecutionHistory().getExecutionEvents().size()>0) {
73
                if (er.getExecutionHistory().getExecutionEvents()!=null && er.getExecutionHistory().getExecutionEvents().size()>0) {
80
				timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp();
74
                	timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp();
81
			}
75
                    String dateStamp = EventUtil.getTime(timestamp);
76
                    name += " ["+dateStamp+"]";  //$NON-NLS-1$//$NON-NLS-2$
77
                }
78
                //- add the link between execution and test suite.
79
                IProxyNode proxy = FileProxyNodeCache.getInstance().getCorrespondingProxy(test);
80
                if (proxy != null) {
81
                	addBidirectionalReference("TestLog2TestSuite", (IReferencerProxyNode)proxy, "TestSuite2TestLog");  //$NON-NLS-1$//$NON-NLS-2$
82
				}
83
            } else {
84
                name += " [" + (er.getTest()).getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
85
            }
82
		}
86
		}
83
        verdict = er.getVerdict().getValue();
87
        verdict = er.getVerdict().getValue();
84
	}
88
	}
Lines 98-143 Link Here
98
        } catch (NumberFormatException e) {
102
        } catch (NumberFormatException e) {
99
        	timestamp = 0L;
103
        	timestamp = 0L;
100
        }
104
        }
101
//		IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD);
102
//        LinkedList execChildren = new LinkedList();
103
//		for (int i = 0; i < childrenMemento.length; i++) {
104
//			IMemento mementoChild = childrenMemento[i];
105
//            //- inherit the TAG_URI_ROOT which is an extra data contained by the parent
106
//            mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));
107
//			String type = getType();
108
//			if(type == null) {
109
//				throw new ProxyNeedToBeRebuiltException();
110
//			}
111
//			ITypedElementProxyFactory factory = TypedElementFactoryManager.getInstance().getFactory(type);
112
//			if(factory instanceof IPersistableTypedElementProxyFactory) {
113
//                IProxyNode proxy = ((IPersistableTypedElementProxyFactory)factory).recreate(mementoChild, this);
114
//                if(proxy != null) {
115
//                    execChildren.add(proxy);
116
//                }
117
//			}
118
//		}
119
//        children = (IProxyNode[]) execChildren.toArray(new IProxyNode[execChildren.size()]);
120
        children = new IProxyNode[0];
105
        children = new IProxyNode[0];
121
	}
106
	}
122
	
107
	
123
//	/**
124
//	 * @param event
125
//	 * @param parent
126
//	 */
127
//	private void getEventChildren(TPFExecutionEvent event, List c, TPFExecutionResult parent) {
128
//		if ( event instanceof TPFInvocationEvent) {
129
//			TPFExecutionResult er = ((TPFInvocationEvent)event).getInvokedExecutionResult();
130
//            if(er != null) {
131
//                c.add(new DefaultExecutionResultProxyNode(er, parent));
132
//            }
133
//		} else {
134
//			Iterator iterator = event.getChildren().iterator();
135
//			while (iterator.hasNext()) {
136
//				getEventChildren((TPFExecutionEvent) iterator.next(), c, parent);
137
//			}
138
//		}
139
//	}
140
141
	public String getText() {
108
	public String getText() {
142
		if (timestamp != 0L) {
109
		if (timestamp != 0L) {
143
			if (cachedName == null) {
110
			if (cachedName == null) {
Lines 174-193 Link Here
174
    	return TestUIConstants.EXECUTION_RESULT_NODE;
141
    	return TestUIConstants.EXECUTION_RESULT_NODE;
175
    }
142
    }
176
    
143
    
144
    public String getFactoryID() {
145
        return EMFResourceProxyFactory.ID; 
146
    }
147
 
177
    public boolean saveState(IMemento memento) {
148
    public boolean saveState(IMemento memento) {
178
        //- data to retrieve the correct object 
149
        //- data to retrieve the correct object 
179
        memento.putInteger(TAG_VERDICT, getVerdict());
150
        memento.putInteger(TAG_VERDICT, getVerdict());
180
        memento.putString(TAG_TIMESTAMP, Long.toString(timestamp));
151
        memento.putString(TAG_TIMESTAMP, Long.toString(timestamp));
181
//        //- children (testcases)
182
//        for (int i = 0; i < children.length; i++) {
183
//            DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i];
184
//            IMemento childMemento = memento.createChild(TestUIConstants.TAG_CHILD);
185
//            if(!child.saveState(childMemento)) {
186
//                return false;
187
//            }
188
//        }
189
        return super.saveState(memento);
152
        return super.saveState(memento);
190
    }
153
    }
191
    
192
    
193
}
154
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 26-31 Link Here
26
import java.util.zip.GZIPOutputStream;
26
import java.util.zip.GZIPOutputStream;
27
27
28
import org.eclipse.core.resources.IFile;
28
import org.eclipse.core.resources.IFile;
29
import org.eclipse.core.runtime.Assert;
29
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.hyades.test.ui.TestUIConstants;
32
import org.eclipse.hyades.test.ui.TestUIConstants;
Lines 43-48 Link Here
43
import org.eclipse.ui.XMLMemento;
44
import org.eclipse.ui.XMLMemento;
44
import org.osgi.framework.Bundle;
45
import org.osgi.framework.Bundle;
45
46
47
/**
48
 * @author jgout
49
 * @author jbozier
50
 * @version February 26, 2008
51
 */
46
public class FileProxyMetadataPersister implements IFileProxyPersister {
52
public class FileProxyMetadataPersister implements IFileProxyPersister {
47
53
48
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
54
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
Lines 126-132 Link Here
126
        if(factory != null) {
132
        if(factory != null) {
127
            if(factory instanceof IPersistableFileProxyFactory) {
133
            if(factory instanceof IPersistableFileProxyFactory) {
128
                try {
134
                try {
129
                    return ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent);
135
                    IProxyNode proxy = ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent);
136
                    Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$
137
					return proxy;
130
                } catch (IllegalArgumentException e) {
138
                } catch (IllegalArgumentException e) {
131
                    //- problem encountered during load
139
                    //- problem encountered during load
132
                    return null;
140
                    return null;
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java (-2 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @author jbozier
25
 * @version February 26, 2008
23
 * @since 3.2
26
 * @since 3.2
24
 */
27
 */
25
public class ExecutionFileProxyNode extends EMFResourceProxyNode {
28
public class ExecutionFileProxyNode extends EMFResourceProxyNode {
Lines 36-43 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
39
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
37
	}
40
	}
38
	
41
	
42
	public String getFactoryID() {
43
		return EMFResourceProxyFactory.ID;
44
	}
45
	
46
	public boolean saveState(IMemento memento) { 
47
		//- data to retrieve the correct object 
48
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.EXECUTION_FILE_NODE);
49
		//- data from EMFResourceProxyNode
50
		memento.putString(TestUIConstants.TAG_NAME, getText());
51
		IProxyNode [] children = getChildren();
52
		for (int i = 0; i < children.length; i++) {
53
			if(!saveChildState(memento, children[i])) {
54
				return false;
55
			}
56
		}
57
		return true;
58
	}
59
	
39
	protected String getNodeKind() {
60
	protected String getNodeKind() {
40
    	return TestUIConstants.EXECUTION_FILE_NODE;
61
    	return TestUIConstants.EXECUTION_FILE_NODE;
41
    }
62
    }
42
63
	
43
}
64
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyManager.java (-56 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-31 Link Here
13
13
14
import java.util.Collections;
14
import java.util.Collections;
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.Map;
16
import java.util.Map;
18
17
19
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.hyades.test.ui.navigator.IFileProxyManager;
19
import org.eclipse.hyades.test.ui.navigator.IFileProxyManager;
24
import org.eclipse.hyades.test.ui.navigator.IProxy;
25
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
26
21
27
/**
22
/**
28
 * @author jgout
23
 * @author jgout
24
 * @version February 26, 2008
29
 * @since 3.2
25
 * @since 3.2
30
 */
26
 */
31
public class FileProxyManager implements IFileProxyManager {
27
public class FileProxyManager implements IFileProxyManager {
Lines 119-143 Link Here
119
	 * @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.
115
	 * @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.
120
	 */
116
	 */
121
	public IProxyNode findProxyByID(IProxyNode proxy, String uid) {
117
	public IProxyNode findProxyByID(IProxyNode proxy, String uid) {
122
		if(proxy == null) return proxy;
118
		return fileProxyNodeCache.findProxyByID(proxy, uid);
123
		//- only for root node that has no fragment part
124
		if(uid.length() > 0) {
125
			//- proxy found ?
126
			if(proxy.getIdentifier().equals(uid)) return proxy;
127
			else {
128
				//- search in its children array
129
				IProxyNode[] children = proxy.getChildren();
130
				for (int i = 0; i < children.length; i++) {
131
					proxy = findProxyByID(children[i], uid);
132
					if(proxy != null) {
133
						//- found !!
134
						return proxy;
135
					}
136
				}
137
				//- not found in this sub tree
138
				return null;
139
			}
140
		} else return proxy;
141
	}
119
	}
142
120
143
	/** 
121
	/** 
Lines 161-183 Link Here
161
	 * @return the proxy associated to the given object or <code>null</code> if such proxy node does not exist.
139
	 * @return the proxy associated to the given object or <code>null</code> if such proxy node does not exist.
162
	 */
140
	 */
163
	public IProxyNode getCorrespondingProxy(Object object) {
141
	public IProxyNode getCorrespondingProxy(Object object) {
164
		IProxy proxy;
142
		return fileProxyNodeCache.getCorrespondingProxy(object);
165
		if (object instanceof IAdaptable) {
166
			proxy = (IProxy) ((IAdaptable)object).getAdapter(IProxy.class);
167
		} else {
168
			proxy = (IProxy) Platform.getAdapterManager().getAdapter(object, IProxy.class);
169
		}
170
		if (proxy != null) {
171
			IResource res = proxy.getUnderlyingResource();
172
			if (res instanceof IFile) {
173
				IFile file = (IFile)res;
174
				IProxyNode fileProxy = getProxy(file, null);
175
				if (fileProxy != null) {
176
					return findProxyByID(fileProxy, proxy.getIdentifier());
177
				}
178
			}
179
		}
180
		return null;
181
	}
143
	}
182
	
144
	
183
	/** 
145
	/** 
Lines 185-206 Link Here
185
	 * @param fileName name of the underlying resource of the searched proxy
147
	 * @param fileName name of the underlying resource of the searched proxy
186
	 * @param identifier identifier of the searched proxy
148
	 * @param identifier identifier of the searched proxy
187
	 * @return a proxy node or <code>null</code> if not found.
149
	 * @return a proxy node or <code>null</code> if not found.
150
	 * @deprecated use {@link #getCorrespondingProxy(new Proxy(fileName, String))} instead.
188
	 */
151
	 */
189
	public IProxyNode getCorrespondingProxy(String fileName, String identifier) {
152
	public IProxyNode getCorrespondingProxy(String fileName, String identifier) {
190
		IProxyNode root = null;
153
		return getCorrespondingProxy(new Proxy(fileName, identifier));
191
		for (Iterator it = fileProxyNodeCache.filesIterator(); it.hasNext();) {
154
	}
192
			IFile file = (IFile) it.next();
193
			if(fileName.equals(file.getLocation().toOSString())) {
194
                //- since file is retrieve from the proxy cache, getProxy method will find the proxy in the cache.
195
				root = fileProxyNodeCache.getProxy(file);
196
				break;
197
			}
198
		}
199
		if(root != null) {
200
			return findProxyByID(root, identifier);
201
		}
202
		return null;
203
 	}
204
    
155
    
205
    /**
156
    /**
206
     * Returns the parent of the given proxy node.
157
     * Returns the parent of the given proxy node.
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java (-2 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @version February 26, 2008
23
 * @since 3.2
25
 * @since 3.2
24
 */
26
 */
25
public class LocationFileProxyNode extends EMFResourceProxyNode {
27
public class LocationFileProxyNode extends EMFResourceProxyNode {
Lines 35-42 Link Here
35
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_LOCATION);
37
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_LOCATION);
36
	}
38
	}
37
	
39
	
40
	public String getFactoryID() {
41
		return EMFResourceProxyFactory.ID;
42
	}
43
	
44
	public boolean saveState(IMemento memento) {
45
		//- data to retrieve the correct object 
46
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_FILE_NODE);
47
		//- data from EMFResourceProxyNode
48
		memento.putString(TestUIConstants.TAG_NAME, getText());
49
		IProxyNode [] children = getChildren();
50
		for (int i = 0; i < children.length; i++) {
51
			if(!saveChildState(memento, children[i])) {
52
				return false;
53
			}
54
		}
55
		return true;
56
	}	
57
	
38
	protected String getNodeKind() {
58
	protected String getNodeKind() {
39
    	return TestUIConstants.LOCATION_FILE_NODE;
59
    	return TestUIConstants.LOCATION_FILE_NODE;
40
    }
60
    }
41
61
	
42
}
62
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java (-2 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-25 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
20
21
21
/**
22
/**
22
 * @author jgout
23
 * @author jgout
24
 * @version February 26, 2008
23
 * @since 3.2
25
 * @since 3.2
24
 */
26
 */
25
public class TestSuiteFileProxyNode extends EMFResourceProxyNode {
27
public class TestSuiteFileProxyNode extends EMFResourceProxyNode {
Lines 36-43 Link Here
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_SUITE);
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_SUITE);
37
	}
39
	}
38
	
40
	
41
	public String getFactoryID() {
42
		return EMFResourceProxyFactory.ID; 
43
	}
44
	
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTSUITE_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
58
	
39
	protected String getNodeKind() {
59
	protected String getNodeKind() {
40
    	return TestUIConstants.TESTSUITE_FILE_NODE;
60
    	return TestUIConstants.TESTSUITE_FILE_NODE;
41
    }
61
    }
42
62
	
43
}
63
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java (-8 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 21-26 Link Here
21
import org.eclipse.core.resources.IMarker;
21
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.WorkspaceJob;
23
import org.eclipse.core.resources.WorkspaceJob;
24
import org.eclipse.core.runtime.Assert;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.IStatus;
Lines 42-57 Link Here
42
import org.eclipse.ui.IMemento;
43
import org.eclipse.ui.IMemento;
43
import org.eclipse.ui.XMLMemento;
44
import org.eclipse.ui.XMLMemento;
44
45
46
/**
47
 * @author jgout
48
 * @author jbozier
49
 * @version February 26, 2008
50
 *
51
 */
45
public class FileProxyMarkerPersister implements IFileProxyPersister {
52
public class FileProxyMarkerPersister implements IFileProxyPersister {
46
53
47
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
54
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
48
    private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
55
    private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
49
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
56
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
50
    private static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$
57
    public static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$
58
    
51
    
59
    
52
    private FileProxyMetadataPersister fallbackPersister = new FileProxyMetadataPersister();
60
    private FileProxyMetadataPersister fallbackPersister = new FileProxyMetadataPersister();
53
61
54
    /* (non-Javadoc)
62
    /*
55
	 * @see org.eclipse.hyades.test.ui.internal.navigator.proxy.IFileProxyPersister#loadProxy(org.eclipse.core.resources.IFile)
63
	 * @see org.eclipse.hyades.test.ui.internal.navigator.proxy.IFileProxyPersister#loadProxy(org.eclipse.core.resources.IFile)
56
	 */
64
	 */
57
    public IProxyNode loadProxy(IFile file) {
65
    public IProxyNode loadProxy(IFile file) {
Lines 99-105 Link Here
99
        if(factory != null) {
107
        if(factory != null) {
100
            if(factory instanceof IPersistableFileProxyFactory) {
108
            if(factory instanceof IPersistableFileProxyFactory) {
101
                try {
109
                try {
102
                    return ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent);
110
                    IProxyNode proxy = ((IPersistableFileProxyFactory)factory).recreate(memento, file, FileProxyNodeCache.unboundedParent);
111
                    Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$
112
					return proxy;
103
                } catch (IllegalArgumentException e) {
113
                } catch (IllegalArgumentException e) {
104
                    //- problem encountered during load
114
                    //- problem encountered during load
105
                    return null;
115
                    return null;
Lines 123-140 Link Here
123
                    } catch (IllegalArgumentException e) {
133
                    } catch (IllegalArgumentException e) {
124
                        //- problem encountered during load
134
                        //- problem encountered during load
125
                        return null;
135
                        return null;
136
                    } catch (ProxyNeedToBeRebuiltException e) {
137
                        //- the factory encountered a problem retrieving information form memento.
138
                        //- this can be due to the fact that the persisted memento is an obsolete one.
139
                        return null;
126
                    }
140
                    }
127
                } else {
141
                } else {
128
                    //- saved marker contains id of a factory which can not recreate elements
142
                    //- saved marker contains id of a factory which can not recreate elements
129
                    UiPlugin.logError("The factory id: "+factoryID+" should be instanceof IPersistableTypedElementProxyFactory");  //$NON-NLS-1$//$NON-NLS-2$
143
                    UiPlugin.logError("The factory id: "+factoryID+" should be instanceof IPersistableTypedElementProxyFactory");  //$NON-NLS-1$//$NON-NLS-2$
130
                    return null;                            
144
                    return null;                            
131
                }
145
                }
132
            } else {
133
                //- saved marker contains an unknown id of a factory
134
                UiPlugin.logError("The persisted proxy for file: "+file.getName()+" contains an unknown factory ID");  //$NON-NLS-1$//$NON-NLS-2$
135
                return null;
136
            }
146
            }
137
        }
147
        }
148
        return null;
138
    }
149
    }
139
150
140
    /* (non-Javadoc)
151
    /* (non-Javadoc)
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EObjectProxyAdapterFactory.java (-27 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-18 Link Here
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
13
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.IAdapterFactory;
15
import org.eclipse.core.runtime.IAdapterFactory;
17
import org.eclipse.emf.ecore.EObject;
16
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.emf.ecore.resource.Resource;
17
import org.eclipse.emf.ecore.resource.Resource;
Lines 26-56 Link Here
26
 */
25
 */
27
public class EObjectProxyAdapterFactory implements IAdapterFactory {
26
public class EObjectProxyAdapterFactory implements IAdapterFactory {
28
27
29
	private static class Proxy implements IProxy {
30
31
		private String identifier;
32
		private IResource underlyingResource;
33
34
		/**
35
		 * @param identifier
36
		 * @param underlyingResource
37
		 */
38
		public Proxy(IResource underlyingResource, String identifier) {
39
			super();
40
			this.identifier = identifier;
41
			this.underlyingResource = underlyingResource;
42
		}
43
		
44
		public IResource getUnderlyingResource() {
45
			return underlyingResource;
46
		}
47
48
		public String getIdentifier() {
49
			return identifier;
50
		}
51
		
52
	}
53
	
54
	/* (non-Javadoc)
28
	/* (non-Javadoc)
55
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
29
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
56
	 */
30
	 */
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java (-2 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 21-26 Link Here
21
21
22
/**
22
/**
23
 * @author jgout
23
 * @author jgout
24
 * @version February 26, 2008
24
 * @since 3.2
25
 * @since 3.2
25
 */
26
 */
26
public class LocationProxyNode extends CMNNamedElementProxyNode {
27
public class LocationProxyNode extends CMNNamedElementProxyNode {
Lines 49-56 Link Here
49
		return new IProxyNode[0];
50
		return new IProxyNode[0];
50
	}
51
	}
51
	
52
	
53
	public String getFactoryID() {
54
		return EMFResourceProxyFactory.ID; 
55
	}
56
	
57
	public boolean saveState(IMemento memento) {
58
		//- data to retrieve the correct object 
59
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_NODE);
60
		return super.saveState(memento);	
61
	}
62
	
52
	protected String getNodeKind() {
63
	protected String getNodeKind() {
53
    	return TestUIConstants.LOCATION_NODE;
64
    	return TestUIConstants.LOCATION_NODE;
54
    }
65
    }
55
66
	
56
}
67
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyNodeCache.java (-1 / +96 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2006, 2007 IBM Corporation and others. 
2
 * Copyright (c) 2006, 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 27-40 Link Here
27
import org.eclipse.core.resources.IResourceDelta;
27
import org.eclipse.core.resources.IResourceDelta;
28
import org.eclipse.core.resources.IResourceDeltaVisitor;
28
import org.eclipse.core.resources.IResourceDeltaVisitor;
29
import org.eclipse.core.resources.ResourcesPlugin;
29
import org.eclipse.core.resources.ResourcesPlugin;
30
import org.eclipse.core.runtime.Assert;
30
import org.eclipse.core.runtime.CoreException;
31
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.IAdaptable;
33
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.hyades.test.ui.UiPlugin;
34
import org.eclipse.hyades.test.ui.UiPlugin;
32
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator;
35
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator;
33
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
36
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
34
import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.SynchronizedAccess;
37
import org.eclipse.hyades.test.ui.internal.navigator.proxy.async.SynchronizedAccess;
38
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceRegistry;
35
import org.eclipse.hyades.test.ui.navigator.FileProxyNode;
39
import org.eclipse.hyades.test.ui.navigator.FileProxyNode;
36
import org.eclipse.hyades.test.ui.navigator.IFileProxyFactory;
40
import org.eclipse.hyades.test.ui.navigator.IFileProxyFactory;
37
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
41
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
42
import org.eclipse.hyades.test.ui.navigator.IProxy;
38
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
43
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
39
import org.eclipse.swt.graphics.Image;
44
import org.eclipse.swt.graphics.Image;
40
import org.eclipse.ui.IMemento;
45
import org.eclipse.ui.IMemento;
Lines 45-50 Link Here
45
 * File proxy node cache manager.<br>
50
 * File proxy node cache manager.<br>
46
 * This class is a singleton and is in charge of storing all file proxy nodes for all instances of FileProxyManager.
51
 * This class is a singleton and is in charge of storing all file proxy nodes for all instances of FileProxyManager.
47
 * @author jgout
52
 * @author jgout
53
 * @version February 26, 2008
48
 * @since 4.2
54
 * @since 4.2
49
 */
55
 */
50
public class FileProxyNodeCache extends SynchronizedAccess {
56
public class FileProxyNodeCache extends SynchronizedAccess {
Lines 193-199 Link Here
193
        return proxies.keySet().iterator();
199
        return proxies.keySet().iterator();
194
    }
200
    }
195
    
201
    
202
    /**
203
     * Saves the given proxy if it is possible (if it is a <code>org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode</code>).
204
     * @param proxy the proxy node to save.
205
     */
206
	public void saveProxy(IProxyNode proxy) {
207
		if (proxy instanceof IPersistableProxyNode) {
208
			IPersistableProxyNode pProxy = (IPersistableProxyNode) proxy;
209
			IResource underlyingResource = proxy.getUnderlyingResource();
210
			if (underlyingResource instanceof IFile) {
211
				saveProxy((IFile)underlyingResource, pProxy);
212
			} else {
213
				UiPlugin.logWarning("Unable to save proxy because its underlying resource is not a file"); //$NON-NLS-1$
214
			}
215
		}
216
	}
196
217
218
    
197
    /**
219
    /**
198
     * Returns the proxy node associated to the given file.<br>
220
     * Returns the proxy node associated to the given file.<br>
199
     * If the proxy has already been built the same instance will be returned. 
221
     * If the proxy has already been built the same instance will be returned. 
Lines 284-289 Link Here
284
            //- use the unbounded parent marker instance as parent.
306
            //- use the unbounded parent marker instance as parent.
285
            proxy = factory.create(file, unboundedParent);
307
            proxy = factory.create(file, unboundedParent);
286
            if (proxy != null) {
308
            if (proxy != null) {
309
            	Assert.isLegal(file.equals(proxy.getAdapter(IFile.class)), "invalid proxy returned by factory"); //$NON-NLS-1$
287
                break;
310
                break;
288
            }
311
            }
289
        }
312
        }
Lines 321-326 Link Here
321
    public void removeResourceListener(IResourceChangeListener listener) {
344
    public void removeResourceListener(IResourceChangeListener listener) {
322
		resourceListeners.remove(listener);
345
		resourceListeners.remove(listener);
323
    }
346
    }
347
     
348
	/** Returns the proxy which has the given uid. This search starts from the given proxy node and cross its complete sub tree of proxies.
349
	 * 
350
	 * @param proxy root of the proxy tree where the search is done. 
351
	 * @param uid the uid of the searched proxy.
352
	 * @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.
353
	 */
354
	public IProxyNode findProxyByID(IProxyNode proxy, String uid) {
355
		if(proxy == null) return proxy;
356
		//- only for root node that has no fragment part
357
		if(uid.length() > 0) {
358
			//- proxy found ?
359
			if(proxy.getIdentifier().equals(uid)) return proxy;
360
			else {
361
				//- search in its children array
362
				IProxyNode[] children = proxy.getChildren();
363
				for (int i = 0; i < children.length; i++) {
364
					proxy = findProxyByID(children[i], uid);
365
					if(proxy != null) {
366
						//- found !!
367
						return proxy;
368
					}
369
				}
370
				//- not found in this sub tree
371
				return null;
372
			}
373
		} else return proxy;
374
	}
375
376
	/** 
377
     * Retrieves the node using its underlying resource and its identifier. 
378
	 * @param fileName name of the underlying resource of the searched proxy
379
	 * @param identifier identifier of the searched proxy
380
	 * @return a proxy node or <code>null</code> if not found.
381
	 */
382
	public IProxyNode getCorrespondingProxy(String fileName, String identifier) {
383
		return getCorrespondingProxy(new Proxy(fileName, identifier));
384
	}
385
386
	/** 
387
     * Retrieves the node associated to the given object. 
388
	 * This parameter is adapted to a IProxy in order to retrieve the node
389
	 * representing it.
390
	 * 
391
	 * @param object An object adaptable to IProxy.
392
	 * @return the proxy associated to the given object or <code>null</code> if such proxy node does not exist.
393
	 */
394
	public IProxyNode getCorrespondingProxy(Object object) {
395
		IProxy proxy;
396
		if (object instanceof IProxy) {
397
			proxy = (IProxy) object;
398
		} else if (object instanceof IAdaptable) {
399
			proxy = (IProxy) ((IAdaptable)object).getAdapter(IProxy.class);
400
		} else {
401
			proxy = (IProxy) Platform.getAdapterManager().getAdapter(object, IProxy.class);
402
		}
403
		if (proxy != null) {
404
			IResource res = proxy.getUnderlyingResource();
405
			if (res instanceof IFile) {
406
				IFile file = (IFile)res;
407
				IProxyNode fileProxy = getProxy(file);
408
				if (fileProxy != null) {
409
					return findProxyByID(fileProxy, proxy.getIdentifier());
410
				}
411
			}
412
		}
413
		return null;
414
	}
415
    
324
    
416
    
325
    /**
417
    /**
326
     * Invoked when a project is closed. This method cleans up the map and removes any
418
     * Invoked when a project is closed. This method cleans up the map and removes any
Lines 388-393 Link Here
388
				IResource res = delta.getResource();
480
				IResource res = delta.getResource();
389
				if (res.getType() == IResource.FILE) {
481
				if (res.getType() == IResource.FILE) {
390
					FileProxyNodeCache.this.remove((IFile)res);
482
					FileProxyNodeCache.this.remove((IFile)res);
483
					ReferenceRegistry.getInstance().removeReferences((IFile)res);
484
				} else if(res.getType() == IResource.PROJECT){
485
					ReferenceRegistry.getInstance().removeProjectReferenceRegistry((IProject)res);
391
				} else {
486
				} else {
392
					return true;
487
					return true;
393
				}
488
				}
(-)src/org/eclipse/hyades/test/ui/forms/editor/BaseFormEditor.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2007 IBM Corporation and others. 
2
 * Copyright (c) 2005, 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 220-226 Link Here
220
	 */
220
	 */
221
	protected EObject getFileContent(IFile file)
221
	protected EObject getFileContent(IFile file)
222
	{
222
	{
223
		cachedURI = URI.createPlatformResourceURI(file.getFullPath().toString());		
223
		cachedURI = URI.createPlatformResourceURI(file.getFullPath().toString(),false);		
224
		return getFileContent(cachedURI);
224
		return getFileContent(cachedURI);
225
	}
225
	}
226
226
Lines 514-520 Link Here
514
		// Bugzilla_152218 preserve the selection after reload.
514
		// Bugzilla_152218 preserve the selection after reload.
515
		String fragment = null;
515
		String fragment = null;
516
		IStructuredSelection structuredSelection = (IStructuredSelection)getSelection();
516
		IStructuredSelection structuredSelection = (IStructuredSelection)getSelection();
517
		if(structuredSelection.size() == 1)
517
		if(structuredSelection != null && structuredSelection.size() == 1)
518
		{
518
		{
519
			Object selection = structuredSelection.getFirstElement();
519
			Object selection = structuredSelection.getFirstElement();
520
			if(selection instanceof EObject)
520
			if(selection instanceof EObject)
(-)schema/testNavigatorPasteExtension.exsd (-8 / +8 lines)
Lines 11-16 Link Here
11
   </annotation>
11
   </annotation>
12
12
13
   <element name="extension">
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element deprecated="true"/>
17
         </appInfo>
18
         <documentation>
19
            deprecated : for specific paste behavior on proxy node, implement IProxyNodePaster interface instead
20
         </documentation>
21
      </annotation>
14
      <complexType>
22
      <complexType>
15
         <sequence>
23
         <sequence>
16
            <element ref="paster" minOccurs="1" maxOccurs="unbounded"/>
24
            <element ref="paster" minOccurs="1" maxOccurs="unbounded"/>
Lines 104-116 Link Here
104
      </documentation>
112
      </documentation>
105
   </annotation>
113
   </annotation>
106
114
107
   <annotation>
108
      <appInfo>
109
         <meta.section type="copyright"/>
110
      </appInfo>
111
      <documentation>
112
         
113
      </documentation>
114
   </annotation>
115
115
116
</schema>
116
</schema>
(-)src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIStatus.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 31-36 Link Here
31
 * 
31
 * 
32
 * @author jgout
32
 * @author jgout
33
 * @since 3.3
33
 * @since 3.3
34
 * @version February 26, 2008
35
 * @deprecated this class is no longer needed
34
 */
36
 */
35
public class RenamerUIStatus {
37
public class RenamerUIStatus {
36
38
(-)src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIOk.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the ok button.
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the ok button.
16
 * @author jgout
16
 * @author jgout
17
 * @since 3.3
17
 * @since 3.3
18
 * @version February 26, 2008
19
 * @deprecated this class is no longer needed
18
 */
20
 */
19
public class RenamerUIOk extends RenamerUIStatus {
21
public class RenamerUIOk extends RenamerUIStatus {
20
	
22
	
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
 * 
17
 * 
18
 * @author jgout
18
 * @author jgout
19
 * @since 3.3
19
 * @since 3.3
20
 * @version February 26, 2008
21
 * @deprecated client should use IProxyNodeRenamer2 instead.
20
 */
22
 */
21
public interface IProxyNodeRenamer {
23
public interface IProxyNodeRenamer {
22
	
24
	
(-)src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUICancel.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the cancel button.
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the user clicks the cancel button.
16
 * @author jgout
16
 * @author jgout
17
 * @since 3.3
17
 * @since 3.3
18
 * @version February 26, 2008
19
 * @deprecated this class is no longer needed
18
 */
20
 */
19
public class RenamerUICancel extends RenamerUIStatus {
21
public class RenamerUICancel extends RenamerUIStatus {
20
	
22
	
(-)src/org/eclipse/hyades/test/ui/navigator/actions/RenamerUIInlineEditor.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Common Public License v1.0
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the default rename UI should be used.
15
/** This class is returned by IProxyNodeRenamer.performUserInteraction() when the default rename UI should be used.
16
 * @author jgout
16
 * @author jgout
17
 * @since 3.3
17
 * @since 3.3
18
 * @version February 26, 2008
19
 * @deprecated this class is no longer needed
18
 */
20
 */
19
public class RenamerUIInlineEditor extends RenamerUIStatus {
21
public class RenamerUIInlineEditor extends RenamerUIStatus {
20
	
22
	
(-)src/org/eclipse/hyades/test/ui/forms/actions/OpenJavaScriptAction.java (-8 / +8 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2005, 2006 IBM Corporation and others. 
2
 * Copyright (c) 2005, 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 18-26 Link Here
18
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.hyades.loaders.util.RegistryReader;
20
import org.eclipse.hyades.loaders.util.RegistryReader;
21
import org.eclipse.hyades.log.ui.internal.navigator.EMFUtil;
22
import org.eclipse.hyades.models.common.common.CMNExtendedProperty;
21
import org.eclipse.hyades.models.common.common.CMNExtendedProperty;
23
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
22
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
23
import org.eclipse.hyades.test.core.util.EMFUtil;
24
import org.eclipse.hyades.test.core.util.JavaUtil;
24
import org.eclipse.hyades.test.core.util.JavaUtil;
25
import org.eclipse.hyades.test.ui.UiPlugin;
25
import org.eclipse.hyades.test.ui.UiPlugin;
26
import org.eclipse.hyades.test.ui.forms.extensions.IEventAction;
26
import org.eclipse.hyades.test.ui.forms.extensions.IEventAction;
Lines 80-105 Link Here
80
	 * This property is optional for this action. When value not available, the project of the current
80
	 * This property is optional for this action. When value not available, the project of the current
81
	 * selected execution history will be used.
81
	 * selected execution history will be used.
82
	 */
82
	 */
83
	public static String propNamejavaProject = "javaProjectName";
83
	public static String propNamejavaProject = "javaProjectName"; //$NON-NLS-1$
84
	/**
84
	/**
85
	 * Property name for fully qualified class name of your java script used in {@link TPFExecutionEvent#getProperties()}.
85
	 * Property name for fully qualified class name of your java script used in {@link TPFExecutionEvent#getProperties()}.
86
	 * Should make it your own property name generated by your test runner.
86
	 * Should make it your own property name generated by your test runner.
87
	 * This property is required by this action.
87
	 * This property is required by this action.
88
	 */
88
	 */
89
	public static String propNameJavaClass = "qualifiedJavaClassName";
89
	public static String propNameJavaClass = "qualifiedJavaClassName";//$NON-NLS-1$
90
	/**
90
	/**
91
	 * Property name for line number in the java script used in {@link TPFExecutionEvent#getProperties()}. 
91
	 * Property name for line number in the java script used in {@link TPFExecutionEvent#getProperties()}. 
92
	 * Should make it your own property name generated by your test runner.
92
	 * Should make it your own property name generated by your test runner.
93
	 * This property is optional for this action. When value not available, the first line will be highlighted.
93
	 * This property is optional for this action. When value not available, the first line will be highlighted.
94
	 */
94
	 */
95
	public static String propNameLineNumber = "javaClassLineNumber";
95
	public static String propNameLineNumber = "javaClassLineNumber";//$NON-NLS-1$
96
	
96
	
97
	private static boolean isRCP = false;
97
	private static boolean isRCP = false;
98
	private TPFExecutionEvent executionEvent;
98
	private TPFExecutionEvent executionEvent;
99
	private	String javaProject = null, javaClassName = null, javaClassLineNumber = null;
99
	private	String javaProject = null, javaClassName = null, javaClassLineNumber = null;
100
	
100
	
101
	/**
101
	/**
102
	 * Default constructor which takes no arguements. This is necessary for extension instantiation.
102
	 * Default constructor which takes no arguments. This is necessary for extension instantiation.
103
	 */
103
	 */
104
	public OpenJavaScriptAction() {
104
	public OpenJavaScriptAction() {
105
		setEnabled(false);
105
		setEnabled(false);
Lines 197-207 Link Here
197
		int innerClassSeparater = qualifiedJavaClassName.indexOf('$'); 
197
		int innerClassSeparater = qualifiedJavaClassName.indexOf('$'); 
198
		if(innerClassSeparater > -1)
198
		if(innerClassSeparater > -1)
199
			className = qualifiedJavaClassName.substring(0, innerClassSeparater);
199
			className = qualifiedJavaClassName.substring(0, innerClassSeparater);
200
		else if(qualifiedJavaClassName.endsWith(".java"))
200
		else if(qualifiedJavaClassName.endsWith(".java"))//$NON-NLS-1$
201
			className = qualifiedJavaClassName.substring(0, qualifiedJavaClassName.length() - 5);		
201
			className = qualifiedJavaClassName.substring(0, qualifiedJavaClassName.length() - 5);		
202
		if(className.indexOf('.') > -1)
202
		if(className.indexOf('.') > -1)
203
			cuName = className.substring(className.lastIndexOf('.') + 1, className.length());
203
			cuName = className.substring(className.lastIndexOf('.') + 1, className.length());
204
		cuName = cuName + ".java";
204
		cuName = cuName + ".java";//$NON-NLS-1$
205
		
205
		
206
		int line = 1;
206
		int line = 1;
207
		if(lineNumber != null)
207
		if(lineNumber != null)
(-)src/org/eclipse/hyades/test/ui/UiPlugin.java (-3 / +16 lines)
Lines 1-10 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: UiPlugin.java,v 1.40 2007/06/01 14:52:02 jgout Exp $
7
 * $Id: UiPlugin.java,v 1.33 2006/08/28 05:05:22 sleeloy Exp $
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 * IBM - Initial API and implementation
10
 * IBM - Initial API and implementation
Lines 376-381 Link Here
376
		Status status = new Status(IStatus.INFO, getID(), 0, text, new Throwable(text));
376
		Status status = new Status(IStatus.INFO, getID(), 0, text, new Throwable(text));
377
		instance.getLog().log(status);
377
		instance.getLog().log(status);
378
	}
378
	}
379
	
380
	public static void logWarning(String text)
381
	{
382
		Status status = new Status(IStatus.WARNING, getID(), 0, text, new Throwable(text));
383
		instance.getLog().log(status);
384
	}
385
	
386
	public static void logWarning(String text, Throwable throwable)
387
	{
388
		Status status = new Status(IStatus.WARNING, getID(), 0, text, throwable);
389
		instance.getLog().log(status);
390
	}
391
	
379
	// TestGen info
392
	// TestGen info
380
	public static String getPreference(String key)
393
	public static String getPreference(String key)
381
	{
394
	{
Lines 387-393 Link Here
387
	 */
400
	 */
388
	protected void initializeDefaultPreferences(IPreferenceStore store)
401
	protected void initializeDefaultPreferences(IPreferenceStore store)
389
	{		
402
	{		
390
		store.setDefault(UiPlugin.TEST_GENERATOR,getDefaultGeneratorID()); //$NON-NLS-1$
403
		store.setDefault(UiPlugin.TEST_GENERATOR,getDefaultGeneratorID());
391
		store.setDefault(TestUI.REPORT_OPEN_EDITOR, true);
404
		store.setDefault(TestUI.REPORT_OPEN_EDITOR, true);
392
		store.setDefault(TestUI.OPEN_EDITOR, true);
405
		store.setDefault(TestUI.OPEN_EDITOR, true);
393
		store.setDefault(TestUI.EXECUTION_FILTER, 3);
406
		store.setDefault(TestUI.EXECUTION_FILTER, 3);
(-)src/org/eclipse/hyades/test/ui/TestUIConstants.java (-6 / +7 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005-2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: TestUIConstants.java,v 1.8 2006/12/15 17:05:50 jcanches Exp $
7
 * $Id: TestUIConstants.java,v 1.7 2005/10/13 09:32:56 jcanches Exp $
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
10
 *     IBM Corporation - initial API and implementation
Lines 13-34 Link Here
13
13
14
/**
14
/**
15
 * Constants storage interface
15
 * Constants storage interface
16
 * @author jgout
16
 * @author jgout, jBozier
17
 * @version February 26, 2008
17
 */
18
 */
18
public interface TestUIConstants {
19
public interface TestUIConstants {
19
	
20
	
20
    /**
21
    /**
21
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
22
     * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path
22
     */
23
     */
23
	public static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
24
	public static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
24
	public static final String TAG_NODE_KIND = "nodeKind"; //$NON-NLS-1$
25
	public static final String TAG_NODE_KIND = "nodeKind"; //$NON-NLS-1$
25
    /**
26
    /**
26
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
27
     * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path
27
     */
28
     */
28
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
29
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
29
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
30
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
30
    /**
31
    /**
31
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
32
     * @deprecated use TAG_FRAGMENT instead. We no longer should persist the full URI because it contains file path
32
     */
33
     */
33
    public static final String TAG_URI = "uri"; //$NON-NLS-1$
34
    public static final String TAG_URI = "uri"; //$NON-NLS-1$
34
    /**
35
    /**
(-)plugin.xml (-14 / +98 lines)
Lines 33-38 Link Here
33
   <extension-point id="testNavigatorTestAssetGroupProxy" name="%testNavigatorTestAssetGroupProxy" schema="schema/testNavigatorTestAssetGroupProxy.exsd"/>
33
   <extension-point id="testNavigatorTestAssetGroupProxy" name="%testNavigatorTestAssetGroupProxy" schema="schema/testNavigatorTestAssetGroupProxy.exsd"/>
34
   <extension-point id="testLogSearchProvider" name="%TestLogSearchProvider" schema="schema/testLogSearchProvider.exsd"/>
34
   <extension-point id="testLogSearchProvider" name="%TestLogSearchProvider" schema="schema/testLogSearchProvider.exsd"/>
35
   <extension-point id="testLogRecordRepositoryProvider" name="%TestLogRecordRepositoryProvider" schema="schema/testLogRecordRepositoryProvider.exsd"/>
35
   <extension-point id="testLogRecordRepositoryProvider" name="%TestLogRecordRepositoryProvider" schema="schema/testLogRecordRepositoryProvider.exsd"/>
36
   <extension-point id="testNavigatorReferenceTypes" name="org.eclipse.hyades.test.ui.testNavigatorReferenceTypes" schema="schema/testNavigatorReferenceTypes.exsd"/>
37
   <extension-point id="testNavigatorRefactoringTransactions" name="Test Navigator Refactoring Transactions" schema="schema/testNavigatorRefactoringTransactions.exsd"/>
36
38
37
   <extension point="org.eclipse.help.contexts">
39
   <extension point="org.eclipse.help.contexts">
38
	    <contexts file="infopop\hyadesUI.xml" plugin ="org.eclipse.hyades.ui"/>
40
	    <contexts file="infopop\hyadesUI.xml" plugin ="org.eclipse.hyades.ui"/>
Lines 622-628 Link Here
622
         point="org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory">
624
         point="org.eclipse.hyades.test.ui.testNavigatorFileProxyFactory">
623
      <factory
625
      <factory
624
            class="org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory"
626
            class="org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory"
625
            id="EMFResourceProxyFactory"/>
627
            id="EMFResourceProxyFactory_4.3"/>
626
       <factory
628
       <factory
627
            class ="org.eclipse.hyades.test.ui.internal.navigator.proxy.NonEMFResourceProxyFactory"    
629
            class ="org.eclipse.hyades.test.ui.internal.navigator.proxy.NonEMFResourceProxyFactory"    
628
            id="NonEMFResourceProxyFactory"/>
630
            id="NonEMFResourceProxyFactory"/>
Lines 634-658 Link Here
634
            factoryID="NonEMFResourceProxyFactory"/>            
636
            factoryID="NonEMFResourceProxyFactory"/>            
635
      <file
637
      <file
636
            extension="datapool"
638
            extension="datapool"
637
            factoryID="EMFResourceProxyFactory"/>
639
            factoryID="EMFResourceProxyFactory_4.3"/>
638
      <file
640
      <file
639
           extension="location"
641
           extension="location"
640
           factoryID="EMFResourceProxyFactory"/>
642
           factoryID="EMFResourceProxyFactory_4.3"/>
641
      <file
643
      <file
642
            extension="artifact"
644
            extension="artifact"
643
            factoryID="EMFResourceProxyFactory"/>
645
            factoryID="EMFResourceProxyFactory_4.3"/>
644
      <file
646
      <file
645
            extension="deploy"
647
            extension="deploy"
646
            factoryID="EMFResourceProxyFactory"/>
648
            factoryID="EMFResourceProxyFactory_4.3"/>
647
      <file
649
      <file
648
            extension="testcomponent"
650
            extension="testcomponent"
649
            factoryID="EMFResourceProxyFactory"/>
651
            factoryID="EMFResourceProxyFactory_4.3"/>
650
      <file
652
      <file
651
            extension="testsuite"
653
            extension="testsuite"
652
            factoryID="EMFResourceProxyFactory"/>
654
            factoryID="EMFResourceProxyFactory_4.3"/>
653
      <file
655
      <file
654
            extension="execution"
656
            extension="execution"
655
            factoryID="EMFResourceProxyFactory"/>
657
            factoryID="EMFResourceProxyFactory_4.3"/>
656
   </extension>
658
   </extension>
657
   <extension
659
   <extension
658
         id="proxyStateMarker"
660
         id="proxyStateMarker"
Lines 708-719 Link Here
708
         point="org.eclipse.hyades.test.ui.testNavigatorPasteExtension">
710
         point="org.eclipse.hyades.test.ui.testNavigatorPasteExtension">
709
      <paster
711
      <paster
710
            target="org.eclipse.core.resources.IContainer"
712
            target="org.eclipse.core.resources.IContainer"
711
            class="org.eclipse.hyades.test.ui.internal.navigator.action.FileFolderInContainerPaste"
713
            class="org.eclipse.hyades.test.ui.internal.navigator.action.FileAndFolderPaster"
712
            strict="false"/>
714
            strict="false"/>         
713
      <paster
714
            class="org.eclipse.hyades.test.ui.internal.navigator.action.FileProxyInContainerPaste"
715
            target="org.eclipse.core.resources.IContainer"
716
            strict="false"/> 
717
  </extension>
715
  </extension>
718
  <extension
716
  <extension
719
         point="org.eclipse.ui.popupMenus">
717
         point="org.eclipse.ui.popupMenus">
Lines 775-780 Link Here
775
           adaptableType="org.eclipse.emf.ecore.EObject">
773
           adaptableType="org.eclipse.emf.ecore.EObject">
776
        <adapter type="org.eclipse.hyades.test.ui.navigator.IProxy"/>
774
        <adapter type="org.eclipse.hyades.test.ui.navigator.IProxy"/>
777
     </factory>
775
     </factory>
776
     <factory
777
           adaptableType="org.eclipse.hyades.test.ui.navigator.IProxyNode"
778
           class="org.eclipse.hyades.test.ui.internal.navigator.proxy.IProxyNodeAdapterFactory">
779
        <adapter type="org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter"/>
780
     </factory>
778
  </extension>
781
  </extension>
779
  <extension
782
  <extension
780
        point="org.eclipse.ui.importWizards">
783
        point="org.eclipse.ui.importWizards">
Lines 890-895 Link Here
890
      </actionSet>
893
      </actionSet>
891
   </extension>
894
   </extension>
892
       <extension
895
       <extension
896
             point="org.eclipse.hyades.test.ui.testNavigatorReferenceTypes">
897
          <type
898
                id="TestSuite2TestLog"
899
                isExplicit="false"
900
                name="%TestSuite2TestLog_NAME"
901
                oppositeReferenceTypeId="TestLog2TestSuite"
902
                owns="true"/>
903
          <type
904
                id="TestLog2TestSuite"
905
                isExplicit="true"
906
                name="%TestLog2TestSuite_NAME"
907
                oppositeReferenceTypeId="TestSuite2TestLog"
908
                owns="false"/>
909
          <type
910
                id="TestInvoker2TestInvoked"
911
                isExplicit="true"
912
                name="%TestInvoker2TestInvoked_NAME"
913
                oppositeReferenceTypeId="TestInvoked2TestInvoker"
914
                owns="false"/>
915
          <type
916
                id="TestInvoked2TestInvoker"
917
                isExplicit="false"
918
                name="%TestInvoked2TestInvoker_NAME"
919
                oppositeReferenceTypeId="TestInvoker2TestInvoked"
920
                owns="false"/>
921
          <type
922
                id="Test2Datapool"
923
                isExplicit="true"
924
                name="%Test2Datapool_NAME"
925
                oppositeReferenceTypeId="Datapool2Test"
926
                owns="false"/>
927
          <type
928
                id="Datapool2Test"
929
                isExplicit="false"
930
                name="%Datapool2Test_NAME"
931
                oppositeReferenceTypeId="Test2Datapool"
932
                owns="false"/>
933
          <type
934
                id="Artifact2Test"
935
                isExplicit="true"
936
                name="%Artifact2Test_NAME"
937
                oppositeReferenceTypeId="Test2Artifact"
938
                owns="false"/>
939
          <type
940
                id="Test2Artifact"
941
                isExplicit="false"
942
                name="%Test2Artifact_NAME"
943
                oppositeReferenceTypeId="Artifact2Test"
944
                owns="false"/>
945
          <type
946
                id="Deploy2Artifact"
947
                isExplicit="true"
948
                name="%Deploy2Artifact_NAME"
949
                oppositeReferenceTypeId="Artifact2Deploy"
950
                owns="false"/>
951
          <type
952
                id="Artifact2Deploy"
953
                isExplicit="false"
954
                name="%Artifact2Deploy_NAME"
955
                oppositeReferenceTypeId="Deploy2Artifact"
956
                owns="false"/>
957
          <type
958
                id="Deploy2Location"
959
                isExplicit="true"
960
                name="%Deploy2Location_NAME"
961
                oppositeReferenceTypeId="Location2Deploy"
962
                owns="false"/>
963
          <type
964
                id="Location2Deploy"
965
                isExplicit="false"
966
                name="%Location2Deploy_NAME"
967
                oppositeReferenceTypeId="Deploy2Location"
968
                owns="false"/>
969
       </extension>
970
       <extension
971
             point="org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions">
972
          <transaction
973
                class="org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction"
974
                domainId="org.eclipse.hyades.test.ui.EMFRefactoringTransaction"/>
975
       </extension>
976
       <extension
893
             point="org.eclipse.hyades.test.ui.executionHistoryExtension">
977
             point="org.eclipse.hyades.test.ui.executionHistoryExtension">
894
          <verdictProvider
978
          <verdictProvider
895
                provider="org.eclipse.hyades.test.ui.forms.extensions.provisional.TPTPVerdictCategoryProvider"
979
                provider="org.eclipse.hyades.test.ui.forms.extensions.provisional.TPTPVerdictCategoryProvider"
(-)plugin.properties (+39 lines)
Lines 144-149 Link Here
144
144
145
NewRecordingWizardPage.TITLE 	= Create New Test From Recording
145
NewRecordingWizardPage.TITLE 	= Create New Test From Recording
146
146
147
RecLocationWizardPage.TITLE = Select Location For Recording
148
RecLocationWizardPage.DESCRIPTION=Select existing recording from which to create a test.
149
RecLocationWizardPage.FILENAME_LABEL=&Recording file name:
150
151
TestsuiteLocationWizardPage.TITLE = Select Location For Test Suite
152
TestsuiteLocationWizardPage.DESCRIPTION=Select project and file name for test
153
TestsuiteLocationWizardPage.FILENAME_LABEL=&Test file name:
154
155
DefaultRecWizardProvider.FILES_EXIST_TITLE=Warning
156
DefaultRecWizardProvider.TESTSUITE_EXISTS=The generated test already exists and will be overwritten.  Proceed?
157
DefaultRecWizardProvider.REC_EXISTS=The trace file already exists and will be overwritten.  Proceed?
158
DefaultRecWizardProvider.BOTH_EXIST=Both the trace file and generated test already exist and will be overwritten.  Proceed?
159
160
RecorderClientUI.INIT_JOB = Initializing Recorder...
161
RecorderClientUI.RECORDING_ABORTED_DUE_TO_EXCEPTION_MESSAGE=IWAT3042E recording aborted due to exception:
162
163
showAdvanced = &Advanced >>
164
hideAdvanced = << &Advanced
165
166
TEST_FROM_RECORDING = Test From Recording
167
GENERIC_RECORDING = Generic Recording
168
GENERIC_RECORDING_ACTION_SET = Action Set for Generic Recording Framework
169
GEN_RECORDER_TOOLTIP = Create a Test From Recording
170
171
W_NAME = Name
172
W_DESCRIPTION = Description
173
174
TestSuite2TestLog_NAME=Associated Test Logs
175
TestLog2TestSuite_NAME=Source Test Suite
176
TestInvoker2TestInvoked_NAME=Invoked tests
177
TestInvoked2TestInvoker_NAME=Test Invocations
178
Test2Datapool_NAME=Associated Datapools
179
Datapool2Test_NAME=Associated Tests
180
Artifact2Test_NAME=Associated Tests
181
Test2Artifact_NAME=Associated Artifacts
182
Deploy2Artifact_NAME=Associated Artifacts
183
Artifact2Deploy_NAME=Associated Deployments
184
Deploy2Location_NAME=Associated Locations
185
Location2Deploy_NAME=Associated Deployments# Add support for importing test log files
147
# Add support for importing test log files
186
# Add support for importing test log files
148
TEST_LOG_FILE= Test Log File
187
TEST_LOG_FILE= Test Log File
149
IMP_TEST_LOG_DSC= Import a test log file from the local file system into the workspace.
188
IMP_TEST_LOG_DSC= Import a test log file from the local file system into the workspace.
(-)src/org/eclipse/hyades/test/ui/navigator/IRefactoringTransaction.java (+51 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.ltk.core.refactoring.Change;
17
18
/**
19
 * Some refactoring operations need to perform its change in a global context.
20
 * This interface allows to declare contexts for grouping refactoring change.
21
 * This interface is used in the extension point 
22
 * <code>org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions</code>.
23
 * 
24
 * @author jgout
25
 * @version February 26, 2008
26
 * @since 4.4
27
 */
28
public interface IRefactoringTransaction {
29
30
	/**
31
	 * Starts the refactoring transaction.
32
	 * Implementors can use this method to initialize internal data.
33
	 * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired.
34
	 */
35
	public void beginChanges(IProgressMonitor pm);
36
37
	/**
38
	 * Method called if the transaction is cancelled.
39
	 * Implementors can use this method to dispose internal data.
40
	 * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired.
41
	 */
42
	public void cancelChanges(IProgressMonitor pm);
43
44
	/**
45
	 * Performs changes.
46
	 * @return the undo change that is composed of all committed changes or <code>null</code> if undo change is not possible.
47
	 * @param pm a progress monitor, or <code>null</code> if progress reporting is not desired.
48
	 * @throws <code>CoreException</code> if the operation failed.
49
	 */
50
	public Change commitChanges(IProgressMonitor pm) throws CoreException;
51
}
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeUpdater.java (+57 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
17
import org.eclipse.ltk.core.refactoring.Change;
18
19
/**
20
 * Interface that allows to describe the update behavior of a proxy node.
21
 * 
22
 * @author jgout
23
 * @version February 26, 2008
24
 * @since 4.4
25
 */
26
public interface IProxyNodeUpdater {
27
28
	/**
29
	 * Returns the refactoring change when an instance need to be updated according the move/delete of a referencer proxy node.
30
	 * The given context can be used if the local change cannot be perform without a global context.
31
	 * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect 
32
	 * data. Such refactoring transaction will performed changes in one time.
33
	 * 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>.
34
	 * For instance a test can update its state when one of its invoked test is deleted.
35
	 *  
36
	 * @param context a context that contains all IRefactoringTransaction instances defined by clients.
37
	 * @param referencer the proxy node that has changed and implies the update of this instance. (<code>referencer.getReferences(refType).contains(this) == true</code>)
38
	 * @param refType the type of the reference between this instance and <code>referencer</code>. 
39
	 * @param newPath the destination path of this proxy node. This parameter is <code>null</code> when the reason of the update is a delete.
40
	 * @return the change that performs the update of instance following a move of a reference to itself.
41
	 */
42
	public Change createUpdateChange(IRefactoringContext context, IReferencerProxyNode referencer, String refType, IPath destinationPath);
43
	
44
	/**
45
	 * Returns the refactoring change when an instance need to be updated according the change of its container.
46
	 * The given context can be used if the local change cannot be perform without a global context.
47
	 * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect 
48
	 * data. Such refactoring transaction will performed changes in one time.
49
	 * 
50
	 * @param context a context that contains all IRefactoringTransaction instances defined by clients.
51
	 * @param container the container that has changed and that implies the update of this instance.
52
	 * @param destinationPath the new path of the instance.
53
	 * @return the change that performs the update of instance following a rename of the given container to the given path.
54
	 */
55
	public Change createUpdateChange(IRefactoringContext context, IContainer container, IPath destinationPath);
56
57
}
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeMover.java (+37 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 20062008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.ltk.core.refactoring.Change;
16
17
/**
18
 * Interface that allows to describe the move behavior of a proxy node.
19
 * 
20
 * @author jgout
21
 * @version February 26, 2008
22
 * @since 4.4
23
 */
24
public interface IProxyNodeMover {
25
26
	/**
27
	 * Returns the refactoring change when moving this instance to the new destination path.
28
	 * The given context can be used if the local change cannot be perform without a global context.
29
	 * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect 
30
	 * data. Such refactoring transaction will performed changes in one time.
31
	 *   
32
	 * @param context a context that contains all IRefactoringTransaction instances defined by clients.
33
	 * @param newPath the destination path of this proxy node.
34
	 * @return the change that performs the move of the proxy node to the given destination path.
35
	 */
36
	public Change createMoveChange(IRefactoringContext context, IPath destinationPath);
37
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoringWizard.java (+35 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.ltk.core.refactoring.Refactoring;
16
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
17
18
/**
19
 * @author jbozier
20
 * @version February 26, 2008
21
 */
22
public class PasteRefactoringWizard extends RefactoringWizard {
23
	
24
	public PasteRefactoringWizard(Refactoring refactoring,Object selected) {
25
		super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE);
26
27
		PasteRefactoring ref = (PasteRefactoring) getRefactoring();
28
		ref.setDestination((IContainer)selected);
29
30
	}
31
	
32
	protected void addUserInputPages() {	
33
	}
34
	
35
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceRegistry.java (+205 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import java.util.Collection;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.Map;
19
import java.util.Set;
20
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.ISaveContext;
24
import org.eclipse.core.resources.ISaveParticipant;
25
import org.eclipse.core.resources.ISavedState;
26
import org.eclipse.core.resources.ResourcesPlugin;
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.hyades.test.ui.UiPlugin;
30
31
/**
32
 * @author jgout
33
 * @version February 26, 2008
34
 */
35
public class ReferenceRegistry implements ISaveParticipant {
36
	
37
	private static ReferenceRegistry instance;
38
	//- Map (project, ProjectReferenceRegistry)
39
	private Map projectRegistries;
40
	private IReferenceRegistrySavedState internalSavedState;
41
	
42
	private class SavedState implements IReferenceRegistrySavedState {
43
		private ISavedState savedState;
44
		public SavedState(ISavedState state) {
45
			savedState = state;
46
		}
47
		public IPath lookup(IPath path) {
48
			return savedState.lookup(path);
49
		}
50
	}
51
	
52
	public static ReferenceRegistry getInstance() {
53
		if(instance == null) {
54
			instance = new ReferenceRegistry();
55
		}
56
		return instance;
57
	}
58
	
59
	private ReferenceRegistry() {
60
		 projectRegistries = new HashMap();
61
		 try {
62
	        ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant(UiPlugin.getDefault(), this);
63
	        this.internalSavedState = (lastState != null) ? new SavedState(lastState) : null;
64
		} catch (CoreException e) {
65
			//- unable to retrieve the previous saved state, start with empty state.
66
		}
67
	}
68
	
69
	private ProjectReferenceRegistry getRegistry(IFile referencer) {
70
		IProject project = referencer.getProject();
71
		if (project.isAccessible()) {
72
			return getProjectReferenceRegistry(project);
73
		}
74
		return null;
75
	}
76
77
	public ProjectReferenceRegistry getProjectReferenceRegistry(IProject project) {
78
		ProjectReferenceRegistry registry =	(ProjectReferenceRegistry)this.projectRegistries.get(project);
79
		if (registry == null) {
80
			//- Not initialized yet
81
			registry = new ProjectReferenceRegistry(project, this.internalSavedState);
82
			this.projectRegistries.put(project, registry);
83
		}
84
		return registry;
85
	}
86
87
	public void removeProjectReferenceRegistry(IProject project) {
88
		projectRegistries.remove(project); 
89
	}
90
	
91
	public void addReference(IFile referencer, String refType, IFile referenced) {
92
		ProjectReferenceRegistry registry = getRegistry(referencer);
93
		if (registry != null) {
94
			registry.addReference(referencer, refType, referenced);
95
		}
96
	}
97
		
98
	public void addBidirectionalReference(IFile referencer, String refType, IFile referenced, String oppositeRefType) {
99
		ProjectReferenceRegistry registryReferencer = getRegistry(referencer);
100
		ProjectReferenceRegistry registryReferenced = getRegistry(referenced);
101
		if (registryReferencer != null) {
102
			registryReferencer.addReference(referencer, refType, referenced);
103
		}
104
		if (registryReferenced != null) {
105
			registryReferenced.addReference(referenced, oppositeRefType, referencer);
106
		}
107
	}
108
	
109
	public void removeReference(IFile referencer, IFile referenced) {
110
		ProjectReferenceRegistry registry = getRegistry(referencer);
111
		if (registry != null) {
112
			registry.removeReference(referencer, referenced);
113
		}
114
	}
115
	
116
	public Collection getReferences(IFile referencer, String refType) {
117
		ProjectReferenceRegistry registry = getRegistry(referencer);
118
		if (registry != null) {
119
			return registry.getReferences(referencer, refType);
120
		}
121
		return Collections.EMPTY_LIST;
122
	}
123
	
124
	public Set getReferenceTypes(IFile referencer) {
125
		ProjectReferenceRegistry registry = getRegistry(referencer);
126
		if (registry != null) {
127
			return registry.getReferenceTypes(referencer);
128
		}
129
		return Collections.EMPTY_SET;
130
	}
131
	
132
	//- Persistence methods, delegation to project focused registries
133
	
134
	public void doneSaving(ISaveContext context) {
135
		if (context.getKind() == ISaveContext.PROJECT_SAVE) {
136
			IProject project = context.getProject();
137
			ProjectReferenceRegistry registry =	(ProjectReferenceRegistry)projectRegistries.get(project);
138
			if (registry != null) {
139
				registry.doneSaving(context);
140
			}
141
		} else {
142
			Iterator it = projectRegistries.values().iterator();
143
			while (it.hasNext()) {
144
				ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next();
145
				registry.doneSaving(context);
146
			}
147
		}			
148
	}
149
150
	public void prepareToSave(ISaveContext context) throws CoreException {
151
		if (context.getKind() == ISaveContext.PROJECT_SAVE) {
152
			IProject project = context.getProject();
153
			ProjectReferenceRegistry registry =	(ProjectReferenceRegistry)projectRegistries.get(project);
154
			if (registry != null) {
155
				registry.prepareToSave(context);
156
			}
157
		} else {
158
			Iterator it = projectRegistries.values().iterator();
159
			while (it.hasNext()) {
160
				ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next();
161
				registry.prepareToSave(context);
162
			}
163
		}	
164
	}
165
166
	public void rollback(ISaveContext context) {
167
		if (context.getKind() == ISaveContext.PROJECT_SAVE) {
168
			IProject project = context.getProject();
169
			ProjectReferenceRegistry registry =	(ProjectReferenceRegistry)projectRegistries.get(project);
170
			if (registry != null) {
171
				registry.rollback(context);
172
			}
173
		} else {
174
			Iterator it = projectRegistries.values().iterator();
175
			while (it.hasNext()) {
176
				ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next();
177
				registry.rollback(context);
178
			}
179
		}
180
	}
181
182
	public void saving(ISaveContext context) throws CoreException {
183
		if (context.getKind() == ISaveContext.PROJECT_SAVE) {
184
			IProject project = context.getProject();
185
			ProjectReferenceRegistry registry =	(ProjectReferenceRegistry)projectRegistries.get(project);
186
			if (registry != null) {
187
				registry.saving(context);
188
			}
189
		} else {
190
			Iterator it = projectRegistries.values().iterator();
191
			while (it.hasNext()) {
192
				ProjectReferenceRegistry registry = (ProjectReferenceRegistry) it.next();
193
				registry.saving(context);
194
			}
195
		}
196
	}
197
198
	public void removeReferences(IFile referencer) {
199
		ProjectReferenceRegistry registry = getRegistry(referencer);
200
		if (registry != null) {
201
			registry.removeReferences(referencer);
202
		}
203
	}
204
205
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoringWizard.java (+162 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Collection;
15
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.List;
19
20
import org.eclipse.core.resources.IContainer;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
24
import org.eclipse.jface.dialogs.Dialog;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelectionChangedListener;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.SelectionChangedEvent;
29
import org.eclipse.jface.viewers.TreeViewer;
30
import org.eclipse.ltk.core.refactoring.Refactoring;
31
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
32
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
33
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
34
import org.eclipse.osgi.util.NLS;
35
import org.eclipse.swt.SWT;
36
import org.eclipse.swt.layout.GridData;
37
import org.eclipse.swt.layout.GridLayout;
38
import org.eclipse.swt.widgets.Composite;
39
import org.eclipse.swt.widgets.Control;
40
import org.eclipse.swt.widgets.Label;
41
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
42
import org.eclipse.ui.model.WorkbenchLabelProvider;
43
44
/**
45
 * @author jgout
46
 * @version February 26, 2008
47
 */
48
public class MoveRefactoringWizard extends RefactoringWizard {
49
	
50
	private static class MoveRefactoringInputPage extends UserInputWizardPage {
51
		private MoveRefactoring refactoring;
52
		private TreeViewer viewer;
53
		
54
		public MoveRefactoringInputPage(Refactoring ref) {
55
			super(""); //$NON-NLS-1$
56
			this.refactoring = (MoveRefactoring) ref;
57
		}
58
59
		public void createControl(Composite parent) {
60
			initializeDialogUnits(parent);
61
			Composite result= new Composite(parent, SWT.NONE);
62
			setControl(result);
63
			result.setLayout(new GridLayout());
64
			
65
			addLabel(result);
66
			viewer = createViewer(result);
67
			expandSelectionContainer();
68
			viewer.addSelectionChangedListener(new ISelectionChangedListener(){
69
				public void selectionChanged(SelectionChangedEvent event) {
70
					MoveRefactoringInputPage.this.viewerSelectionChanged(event);
71
				}
72
			});
73
			Dialog.applyDialogFont(result);
74
		}
75
		
76
		private void expandSelectionContainer() {
77
			Collection containers = refactoring.getContainers();
78
			Collection proxies = refactoring.getProxies();
79
			Collection parents = new HashSet();
80
			for (Iterator it = containers.iterator(); it.hasNext();) {
81
				parents.add(((IContainer) it.next()).getParent());
82
			}
83
			for (Iterator it = proxies.iterator(); it.hasNext();) {
84
				parents.add(((IProxyNode) it.next()).getUnderlyingResource().getParent());
85
			}
86
			for (Iterator it = parents.iterator(); it.hasNext();) {
87
				viewer.expandToLevel(it.next(), 0);
88
			}
89
		}
90
91
		protected Control addLabel(Composite parent) {
92
			Label label= new Label(parent, SWT.NONE);
93
			String text;
94
			int containers= refactoring.getContainers().size();
95
			int proxies= refactoring.getProxies().size();
96
97
			if (containers == 0 && proxies == 1) {
98
				text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_SINGLE, ((IProxyNode)refactoring.getProxies().get(0)).getText());
99
			} else if (containers == 1 && proxies == 0) {
100
				text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_SINGLE, ((IResource)refactoring.getContainers().get(0)).getName());
101
			} else {
102
				text= NLS.bind(RefactoringMessages.MOVE_CHOOSE_DESTINATION_MULTI, String.valueOf(containers + proxies));
103
			}
104
			label.setText(text);
105
			label.setLayoutData(new GridData(SWT.BEGINNING, SWT.END, false, false));
106
			return label;
107
		}
108
		
109
		private TreeViewer createViewer(Composite parent) {
110
			TreeViewer treeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
111
			GridData gd= new GridData(GridData.FILL_BOTH);
112
			gd.widthHint= convertWidthInCharsToPixels(40);
113
			gd.heightHint= convertHeightInCharsToPixels(15);
114
			treeViewer.getTree().setLayoutData(gd);
115
			BaseWorkbenchContentProvider provider = new BaseWorkbenchContentProvider() {
116
				public Object[] getChildren(Object element) {
117
					Object[] children = super.getChildren(element);
118
					List resChildren = new LinkedList();
119
					for (int i = 0; i < children.length; i++) {
120
						if (children[i] instanceof IContainer) {
121
							resChildren.add(children[i]);
122
						}
123
					}
124
					return resChildren.toArray();
125
				}
126
			};
127
			treeViewer.setLabelProvider(new WorkbenchLabelProvider());
128
			treeViewer.setContentProvider(provider);
129
			treeViewer.setSorter(null);
130
			treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
131
			return treeViewer;
132
		}
133
134
		private void viewerSelectionChanged(SelectionChangedEvent event) {
135
			ISelection selection= event.getSelection();
136
			if (!(selection instanceof IStructuredSelection))
137
				return;
138
			IStructuredSelection sel= (IStructuredSelection)selection;
139
			setPageComplete(verifyDestination(sel.getFirstElement()));
140
		}
141
142
		protected RefactoringStatus verifyDestination(Object selected) {
143
			RefactoringStatus refactoringStatus = new RefactoringStatus();
144
			if (selected instanceof IContainer)
145
				refactoring.setDestination((IContainer)selected);
146
			else {
147
				refactoringStatus= RefactoringStatus.createFatalErrorStatus(RefactoringMessages.MOVE_ERROR); 
148
			}
149
			return refactoringStatus;
150
		}
151
152
	}
153
	
154
	public MoveRefactoringWizard(Refactoring refactoring) {
155
		super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE);
156
	}
157
	
158
	protected void addUserInputPages() {
159
		MoveRefactoringInputPage page = new MoveRefactoringInputPage(getRefactoring());
160
		addPage(page);
161
	}
162
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringContext.java (+134 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Map;
17
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IExtensionPoint;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.SubProgressMonitor;
24
import org.eclipse.hyades.test.ui.UiPlugin;
25
import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction;
26
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
27
import org.eclipse.ltk.core.refactoring.Change;
28
import org.eclipse.ltk.core.refactoring.CompositeChange;
29
30
/**
31
 * @author jgout
32
 * @version February 26, 2008
33
 */
34
public class RefactoringContext implements IRefactoringTransaction,	IRefactoringContext {
35
	//- internal storage (domainId, IConfigurationElement)
36
	private static Map knownTransactions;
37
	//- loaded transaction for this instance (domainId, IRefactoringTransaction)
38
	private Map transactions;
39
	
40
	static {
41
		knownTransactions = new HashMap();
42
	}
43
	
44
	public RefactoringContext() {
45
		transactions = new HashMap();
46
	}
47
48
	public void beginChanges(IProgressMonitor pm) {
49
		pm.beginTask("", transactions.values().size()); //$NON-NLS-1$
50
		try {
51
			for (Iterator it = transactions.values().iterator(); it.hasNext();) {
52
				IRefactoringTransaction transaction = (IRefactoringTransaction) it.next();
53
				transaction.beginChanges(new SubProgressMonitor(pm, 1));
54
			}
55
		} finally {
56
			pm.done();
57
		}		
58
	}
59
60
	public void cancelChanges(IProgressMonitor pm) {
61
		pm.beginTask("", transactions.values().size()); //$NON-NLS-1$
62
		try {
63
			for (Iterator it = transactions.values().iterator(); it.hasNext();) {
64
				IRefactoringTransaction transaction = (IRefactoringTransaction) it.next();
65
				transaction.cancelChanges(new SubProgressMonitor(pm, 1));
66
			}
67
		} finally {
68
			pm.done();
69
		}		
70
	}
71
72
	public Change commitChanges(IProgressMonitor pm) throws CoreException {
73
		CompositeChange c = new CompositeChange(""); //$NON-NLS-1$
74
		pm.beginTask("", transactions.values().size()); //$NON-NLS-1$
75
		try {
76
			for (Iterator it = transactions.values().iterator(); it.hasNext();) {
77
				IRefactoringTransaction transaction = (IRefactoringTransaction) it.next();
78
				c.add(transaction.commitChanges(new SubProgressMonitor(pm, 1)));
79
			}
80
			return c;
81
		} finally {
82
			pm.done();
83
		}		
84
	}
85
86
	public IRefactoringTransaction getRefactoringTransaction(String domainId) {
87
		IRefactoringTransaction t = (IRefactoringTransaction) transactions.get(domainId);
88
		if (t != null) {
89
			return t;
90
		} else {
91
			//- need to load from internal storage
92
			try {
93
				t = internalGetRefactoringTransaction(domainId);
94
				if (t != null) {
95
					//- save this transaction in this instance.
96
					transactions.put(domainId, t);
97
					return t;
98
				}
99
			} catch (CoreException e) {
100
				UiPlugin.logError(e);
101
			}
102
			return null;
103
		}
104
	}
105
106
	private static IRefactoringTransaction internalGetRefactoringTransaction(String domainId) throws CoreException {
107
		IConfigurationElement e = (IConfigurationElement)knownTransactions.get(domainId);
108
		if(e == null) {
109
			//- need to load from extension points.
110
			IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(UiPlugin.getID() + ".testNavigatorRefactoringTransactions"); //$NON-NLS-1$
111
			if (extPoint != null) {
112
				IConfigurationElement[] members = extPoint.getConfigurationElements();
113
				for (int i = 0; i < members.length; i++) {
114
					IConfigurationElement element = members[i];
115
					if ("transaction".equals(element.getName())) { //$NON-NLS-1$
116
						String id = element.getAttribute("domainId"); //$NON-NLS-1$
117
						if(id != null) {
118
							knownTransactions.put(id, element);
119
						}
120
					}
121
				}
122
				//- once extensions have been loaded try to retrieve the asked refactoring transaction
123
				e = (IConfigurationElement)knownTransactions.get(domainId);
124
			}
125
		}
126
		if(e == null) {
127
			//- this domainId is unknown
128
			UiPlugin.logError("Unable to find a registered refactoring transaction with the domain Id: '"+domainId+'\''); //$NON-NLS-1$
129
			return null;
130
		}
131
		return (IRefactoringTransaction) e.createExecutableExtension("class"); //$NON-NLS-1$
132
	}
133
134
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteModelChange.java (+150 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.List;
15
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IWorkspaceRoot;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.Assert;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.OperationCanceledException;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.emf.common.util.URI;
26
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.emf.ecore.resource.Resource;
28
import org.eclipse.hyades.models.common.common.CMNNamedElement;
29
import org.eclipse.hyades.test.core.util.EMFUtil;
30
import org.eclipse.hyades.test.ui.UiPlugin;
31
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
32
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
33
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
34
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
35
import org.eclipse.ltk.core.refactoring.Change;
36
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
37
import org.eclipse.osgi.util.NLS;
38
39
/**
40
 * change to apply to perform a model paste
41
 * @author jbozier
42
 * @version February 26, 2008
43
 * @since 4.5
44
 */
45
public class PasteModelChange extends Change {
46
	private EMFRefactoringTransaction context;
47
	protected IPath destination;
48
	protected IProxyNode proxy;
49
	private boolean shouldBeRenamed;
50
	private RefactoringStatus status;
51
	private String newName = null;
52
	private String newBaseName = null;
53
	
54
	
55
	public PasteModelChange(IRefactoringContext context,IProxyNode node, IPath destinationPath,String [] targetName) {
56
		this.proxy = node;
57
		this.destination = destinationPath;
58
		this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
59
		Assert.isNotNull(this.context);
60
		this.status = new RefactoringStatus();
61
		IFile destFile = ResourcesPlugin.getWorkspace().getRoot().getFile(destination);
62
		if (destFile.exists()) {
63
			handleFileAlreadyExists(this.status);
64
		}
65
		this.newName = getNewName(); 
66
		if ((targetName != null) && (targetName.length > 0)) {
67
			targetName[0] = newName;
68
		}
69
	}
70
71
	public Object getModifiedElement() {
72
		return proxy;
73
	}
74
75
	public String getName() {
76
		String fileName = proxy.getUnderlyingResource().getFullPath().toPortableString();
77
		return NLS.bind(RefactoringMessages.PASTE_FILE, fileName, newName /*destination.removeLastSegments(1)*/);
78
	}
79
80
	public void initializeValidationData(IProgressMonitor pm) {
81
	}
82
83
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
84
		return this.status;
85
	}
86
87
	protected void handleFileAlreadyExists(RefactoringStatus status) {
88
		shouldBeRenamed = true;
89
	}
90
	
91
	public Change perform(IProgressMonitor pm) throws CoreException {
92
		if (proxy instanceof EObjectProxyNode) {
93
			//- load the referencer
94
			Resource res = context.getResourceSet().getResource(((EObjectProxyNode)proxy).getOriginatorURI().trimFragment(), true);
95
			res.setURI(getNewURI());
96
			try {
97
				EMFUtil.save(res);
98
				EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm);
99
				if (shouldBeRenamed) {
100
					if(context != null) {
101
						List objects = res.getContents();
102
						if (!objects.isEmpty()) {
103
							EObject object = (EObject)objects.get(0);
104
							if (object instanceof CMNNamedElement) {
105
								((CMNNamedElement)object).setName(newBaseName);
106
								EMFUtil.save(res);
107
								EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm);
108
							}	
109
						}
110
					}
111
				}				
112
			} catch (Exception e) {
113
				UiPlugin.logError(e);
114
			}
115
		}
116
		return null;
117
	}
118
	
119
	public URI getNewURI() {
120
		return URI.createPlatformResourceURI(newName,false);
121
	}
122
123
	// call it one time only, because can be sometime a bit slow
124
	private String getNewName() {
125
		if(shouldBeRenamed) {
126
			boolean done = false;		
127
			String fullFileName = destination.lastSegment();
128
			int dotIndex = fullFileName.lastIndexOf('.');
129
			String basePart = fullFileName.substring(0, dotIndex);
130
			String endPart = fullFileName.substring(dotIndex);
131
			String newFullName = null;
132
			String ret = null;
133
			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
134
			for (int i=0; (!done); i++) {
135
				 if (i != 0) {
136
					 newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),basePart);
137
				 } else {
138
					 newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,basePart);					 
139
				 }
140
				newFullName = newBaseName+endPart;
141
				ret = destination.removeLastSegments(1).append(newFullName).toPortableString();
142
				IPath newpath = new Path(ret);
143
				done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists());
144
			}
145
			return ret;
146
		} else {
147
			return destination.toPortableString();
148
		}
149
	}
150
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/EMFRefactoringTransaction.java (+121 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Set;
21
22
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.runtime.Assert;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.SubProgressMonitor;
27
import org.eclipse.emf.common.util.URI;
28
import org.eclipse.emf.ecore.resource.Resource;
29
import org.eclipse.emf.ecore.resource.ResourceSet;
30
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
31
import org.eclipse.hyades.test.core.util.EMFUtil;
32
import org.eclipse.hyades.test.ui.UiPlugin;
33
import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction;
34
import org.eclipse.ltk.core.refactoring.Change;
35
36
/**
37
 * @author jgout
38
 * @author jbozier
39
 * @version February 26, 2008
40
 */
41
public class EMFRefactoringTransaction implements IRefactoringTransaction {
42
	public static final String Id = "org.eclipse.hyades.test.ui.EMFRefactoringTransaction"; //$NON-NLS-1$
43
	private Set resources;
44
	private Map newURIs;
45
	private ResourceSet resourceSet;
46
47
	public EMFRefactoringTransaction() {
48
		this.resources = new HashSet();
49
		this.newURIs = new HashMap();
50
		this.resourceSet = new ResourceSetImpl();
51
	}
52
	
53
	public void addChangedURI(Resource res, URI newURI) {
54
		newURIs.put(res, newURI);
55
	}
56
	
57
	public void addResourceToSave(Resource res) {
58
		Assert.isNotNull(res);
59
		if(!resources.contains(res)) {
60
			resources.add(res);
61
		}
62
	}
63
64
	public URI getNewURI(Resource res) {
65
		return (URI)newURIs.get(res);
66
	}
67
	
68
	public ResourceSet getResourceSet() {
69
		return resourceSet;
70
	}
71
72
	public Set getResourcesToSave() {
73
		return resources;
74
	}
75
76
	public Set getResourcesToMove() {
77
		return newURIs.keySet();
78
	}
79
	
80
	public void beginChanges(IProgressMonitor monitor) { /* NOP	*/ }
81
82
	public void cancelChanges(IProgressMonitor monitor) { /* NOP	*/ }
83
	
84
	public Change commitChanges(IProgressMonitor pm) throws CoreException {
85
		List files = new LinkedList();
86
		pm.beginTask("", getResourcesToMove().size()+getResourcesToSave().size()+/*getResourcesToCopy().size()*/+1); //$NON-NLS-1$
87
		try {
88
			//- change the URI of resources that should move
89
			for (Iterator it = getResourcesToMove().iterator(); it.hasNext();) {
90
				Resource res = (Resource) it.next();
91
				if (res != null) {
92
					//- change its URI 
93
					IFile file = EMFUtil.getWorkspaceFile(res);
94
					res.setURI(getNewURI(res));
95
					if (file != null) {
96
						files.add(file);
97
					}
98
				}
99
				pm.worked(1);
100
			}
101
			//- save all EMF resources loaded that need to be saved.
102
			for (Iterator it = getResourcesToSave().iterator(); it.hasNext();) {
103
				Resource res = (Resource) it.next();
104
				try {
105
					EMFUtil.save(res);
106
					EMFUtil.getWorkspaceFile(res).refreshLocal(0, pm);
107
				} catch (Exception e) {
108
					UiPlugin.logError(e);
109
				}
110
				pm.worked(1);
111
			}
112
			//- delete files that moved
113
			for (Iterator it = files.iterator(); it.hasNext();) {
114
				((IFile) it.next()).delete(false, new SubProgressMonitor(pm, 1));
115
			}
116
			return null;
117
		} finally {
118
			pm.done();
119
		}		
120
	}
121
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IPasterExtended.java (+29 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.hyades.test.ui.navigator.actions.IPaster;
15
import org.eclipse.swt.widgets.Shell;
16
17
/**
18
 * interface for graphical paster
19
 * @author jbozier
20
 * @version February 26, 2008
21
 */
22
public interface IPasterExtended extends IPaster {
23
24
	/**
25
	 * set the shell for graphical paster
26
	 * @param shell
27
	 */
28
	public void setShell(Shell shell);
29
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/ActionMessages.java (+39 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.hyades.test.ui.internal.navigator.action;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 * @author jgout,jbozier
17
 * @version February 26, 2008
18
 */
19
public class ActionMessages extends NLS {
20
	private static final String BUNDLE_NAME = "org.eclipse.hyades.test.ui.internal.navigator.action.messages"; //$NON-NLS-1$
21
22
	public static String MOVE_ACTION_NAME;
23
	public static String DELETE_ACTION_NAME;
24
	public static String RENAME_ACTION_NAME;
25
	public static String RENAME_NEW_NAME_LABEL;
26
	public static String PASTE_ACTION_NAME;
27
28
	public static String SAVE_ALL_DIALOG_MESSAGE;
29
30
	public static String SAVE_ALL_DIALOG_NAME;
31
	
32
	static {
33
		// initialize resource bundle
34
		NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
35
	}
36
37
	private ActionMessages() {
38
	}
39
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderCompositeChange.java (+78 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IFolder;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.SubProgressMonitor;
19
import org.eclipse.ltk.core.refactoring.Change;
20
import org.eclipse.ltk.core.refactoring.CompositeChange;
21
import org.eclipse.ltk.core.refactoring.NullChange;
22
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
23
24
/**
25
 * change to apply to perform a folder paste when it have childrens 
26
 * children paste don't appear in refactoring view
27
 * @author jbozier
28
 * @version February 26, 2008
29
 * @since 4.5
30
 */
31
public class PasteFolderCompositeChange extends CompositeChange {
32
	private IFolder folder;
33
	private PasteFolderChange root;
34
35
	public PasteFolderCompositeChange(IFolder folder, IPath newPath,IPath [] targetPath) {
36
		super(""); //$NON-NLS-1$
37
		this.folder = folder;
38
		this.root = new PasteFolderChange(folder, newPath,targetPath);
39
	}
40
41
	public Object getModifiedElement() {
42
		return folder;
43
	}
44
45
	public String getName() {
46
		return root.getName();
47
	}
48
49
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
50
		RefactoringStatus status = root.isValid(pm);
51
		if(folder.getFullPath().isPrefixOf(root.getDestinationPath())) {
52
			status.addFatalError(RefactoringMessages.INNER_FOLDER_PASTE_ERROR);
53
		}
54
		status.merge(super.isValid(pm));
55
		return status;
56
	}
57
58
	public Change perform(IProgressMonitor pm) throws CoreException {
59
		pm.beginTask("", getChildren().length+1);  //$NON-NLS-1$
60
		try {
61
			//- paste the folder and all its content
62
			root.perform(new SubProgressMonitor(pm, 1));
63
			//- children are update changes
64
			super.perform(new SubProgressMonitor(pm, getChildren().length));
65
			return null;
66
		} finally {
67
			pm.done();
68
		}
69
	}
70
	
71
	public void freeze() {
72
		if(getChildren().length == 0) {
73
			markAsSynthetic();
74
			//- add a dummy child in order to keep the composite alive
75
			add(new NullChange(getName()));
76
		}
77
	}
78
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteTestInvocationChange.java (+105 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Collection;
15
import java.util.Iterator;
16
17
import org.eclipse.core.runtime.Assert;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.OperationCanceledException;
21
import org.eclipse.emf.common.util.URI;
22
import org.eclipse.emf.ecore.resource.Resource;
23
import org.eclipse.emf.ecore.util.EcoreUtil;
24
import org.eclipse.hyades.models.common.facades.behavioral.IBlock;
25
import org.eclipse.hyades.models.common.facades.behavioral.IDecision;
26
import org.eclipse.hyades.models.common.facades.behavioral.ILoop;
27
import org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation;
28
import org.eclipse.hyades.models.common.testprofile.TPFTest;
29
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
30
import org.eclipse.hyades.test.ui.navigator.DefaultTestSuiteProxyNode;
31
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
32
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
33
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
34
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
35
import org.eclipse.ltk.core.refactoring.Change;
36
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
37
import org.eclipse.osgi.util.NLS;
38
39
/**
40
 * @author jgout
41
 * @version February 26, 2008
42
 */
43
public class DeleteTestInvocationChange extends Change {
44
	private EMFRefactoringTransaction context;
45
	private IProxyNode invokee;
46
	private DefaultTestSuiteProxyNode test;
47
	
48
	public DeleteTestInvocationChange(IRefactoringContext context, DefaultTestSuiteProxyNode node, IReferencerProxyNode referenced) {
49
		this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
50
		Assert.isNotNull(this.context);
51
		this.test = node;
52
		this.invokee = (IProxyNode) referenced.getAdapter(IProxyNode.class);
53
	}
54
55
	public Object getModifiedElement() {
56
		return test;
57
	}
58
59
	public String getName() {
60
		return NLS.bind(RefactoringMessages.DELETE_INVOCATION, invokee.getText(), test.getText());
61
	}
62
63
	public void initializeValidationData(IProgressMonitor pm) {
64
	}
65
66
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
67
		return new RefactoringStatus();
68
	}
69
70
	private void removeTestInvocation(IBlock block, URI invokeeURI) {
71
		if (block != null) {
72
			Collection actions = block.getActions();
73
			for (Iterator it = actions.iterator(); it.hasNext();) {
74
				Object action = it.next();
75
				if (action instanceof ILoop) {
76
					removeTestInvocation(((ILoop) action).getBlock(), invokeeURI);
77
				} else if (action instanceof IDecision) {
78
					IDecision ifAction = (IDecision) action;
79
					removeTestInvocation(ifAction.getFailureBlock(), invokeeURI);
80
					removeTestInvocation(ifAction.getSuccessBlock(), invokeeURI);
81
				} else if (action instanceof ITestInvocation) {
82
					ITestInvocation invocationAction = (ITestInvocation) action;
83
					TPFTest invokedTest = (TPFTest)invocationAction.getInvokedTest();
84
					if (EcoreUtil.getURI(invokedTest).equals(invokeeURI)) {
85
						it.remove();
86
					}
87
				}
88
			}
89
		}
90
	}
91
	
92
	public Change perform(IProgressMonitor pm) throws CoreException {
93
		if (invokee instanceof EObjectProxyNode) {
94
			URI invokeeURI = ((EObjectProxyNode)invokee).getOriginatorURI();
95
			//- load the test
96
			Resource res = context.getResourceSet().getResource(test.getOriginatorURI().trimFragment(), true);
97
			TPFTestSuite testObject = (TPFTestSuite) res.getEObject(test.getOriginatorURI().fragment());
98
			//- remove all invocations of invokee contained in test
99
			removeTestInvocation(testObject.getImplementor().getBlock(), invokeeURI);
100
			context.addResourceToSave(res);
101
		}
102
		return null;
103
	}
104
105
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteModelElementChange.java (+82 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.OperationCanceledException;
18
import org.eclipse.emf.common.util.URI;
19
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.resource.Resource;
21
import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange;
22
import org.eclipse.hyades.test.core.util.EMFUtil;
23
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
24
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
25
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
26
import org.eclipse.ltk.core.refactoring.Change;
27
import org.eclipse.ltk.core.refactoring.NullChange;
28
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
29
import org.eclipse.osgi.util.NLS;
30
/**
31
 * @author jgout
32
 * @author jbozier
33
 * @version February 26, 2008
34
 */
35
public class DeleteModelElementChange extends Change {
36
	private IProxyNode proxy;
37
	protected EMFRefactoringTransaction context;
38
	private Change fileChange;
39
	
40
	public DeleteModelElementChange(IRefactoringContext context, EObjectProxyNode node) {
41
		this.proxy = node;
42
		this.context = (EMFRefactoringTransaction)context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
43
		//- if the proxy node can be adpated in IFile we need to remove the file as well.
44
		Object file = node.getAdapter(IFile.class);
45
		if(file != null) {
46
			this.fileChange = new DeleteFileChange((IFile) file);
47
		} else {
48
			this.fileChange = new NullChange(NLS.bind(RefactoringMessages.UPDATE_PROXY, proxy.getUnderlyingResource().getFullPath().toPortableString()));
49
		}
50
	}
51
52
	public Object getModifiedElement() {
53
		return null;
54
	}
55
56
	public String getName() {
57
		return fileChange.getName();
58
	}
59
60
	public void initializeValidationData(IProgressMonitor pm) {
61
	}
62
63
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,	OperationCanceledException {
64
		return fileChange.isValid(pm);
65
	}
66
67
	public Change perform(IProgressMonitor pm) throws CoreException {
68
		URI uri = ((EObjectProxyNode)proxy).getOriginatorURI();
69
 		Resource res = context.getResourceSet().getResource(uri.trimFragment(), true);
70
 		EObject eObject = res.getEObject(uri.fragment());
71
		if (eObject != null) {
72
			EMFUtil.remove(eObject);
73
		}
74
		if (fileChange instanceof NullChange) {
75
			context.addResourceToSave(res);
76
		} else {
77
			fileChange.perform(pm);
78
		}
79
		return null;
80
	}
81
82
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DefaultProxyNodeDeleter.java (+42 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.Assert;
16
import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange;
17
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter;
19
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
20
import org.eclipse.ltk.core.refactoring.Change;
21
22
/**
23
 * This class stands as the default deleter for proxy node.
24
 * This class should only be used on proxy nodes that are adaptable in IFile.
25
 * This class is not intented to be used/subclassed by clients.
26
 * 
27
 * @author jgout
28
 * @version February 26, 2008
29
 * @since 4.4
30
 */
31
public class DefaultProxyNodeDeleter implements IProxyNodeDeleter {
32
	private IFile proxyFile;
33
	
34
	public DefaultProxyNodeDeleter(IProxyNode proxy) {
35
		this.proxyFile = (IFile) proxy.getAdapter(IFile.class);
36
		Assert.isNotNull(proxyFile);
37
	}
38
39
	public Change createDeleteChange(IRefactoringContext context) {
40
		return new DeleteFileChange(proxyFile);
41
	}
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IResourceSetRefactoringContext.java (+67 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Set;
15
16
import org.eclipse.emf.common.util.URI;
17
import org.eclipse.emf.ecore.resource.Resource;
18
import org.eclipse.emf.ecore.resource.ResourceSet;
19
20
/**
21
 * Interface used to collect and postpone change to perform on EMF models.
22
 * This interface is not intended to be implemented by clients.
23
 * 
24
 * @author jgout
25
 * @version February 26, 2008
26
 * @since 4.3
27
 */
28
public interface IResourceSetRefactoringContext {
29
30
	/**
31
	 * Adds the given resource into the set of resources that have been loaded.
32
	 * @param res a resource
33
	 */
34
	public void addResourceToSave(Resource res);
35
	
36
	/**
37
	 * Returns the set of resources that are to be saved.
38
	 * @return the set of resources that are to be saved.
39
	 */
40
	public Set getResourcesToSave();
41
	
42
	/**
43
	 * Returns the resource set in which the resource have been loaded.
44
	 * @return the resource set in which the resource have been loaded.
45
	 */
46
	public ResourceSet getResourceSet();
47
	
48
	/**
49
	 * Gathers the resource which the URI has to be changed at the end.
50
	 * @param res the resource which the URI should be changed
51
	 * @param newURI the new URI to set.
52
	 */
53
	public void addChangedURI(Resource res, URI newURI);
54
	
55
	/**
56
	 * Gets the new URI for the given resource
57
	 * @param res a resource which a new URI should be set.
58
	 * @return the new URI.
59
	 */
60
	public URI getNewURI(Resource res);
61
	
62
	/**
63
	 * Returns the set of resources that which URI should be changed.
64
	 * @return the set of resources that which URI should be changed.
65
	 */
66
	public Set getResourcesToMove();
67
}
(-)schema/testNavigatorReferenceTypes.exsd (+152 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.ui" id="testNavigatorReferenceTypes" name="Test Navigator Reference Types"/>
7
      </appInfo>
8
      <documentation>
9
         Extension point that allows to declare proxy node reference types.
10
Proxy nodes can reference other proxy nodes using references (see &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode&lt;/code&gt;)
11
Those references are typed and should be declared using this extension point.
12
      </documentation>
13
   </annotation>
14
15
   <element name="extension">
16
      <complexType>
17
         <sequence minOccurs="1" maxOccurs="unbounded">
18
            <element ref="type"/>
19
         </sequence>
20
         <attribute name="point" type="string" use="required">
21
            <annotation>
22
               <documentation>
23
                  
24
               </documentation>
25
            </annotation>
26
         </attribute>
27
         <attribute name="id" type="string">
28
            <annotation>
29
               <documentation>
30
                  
31
               </documentation>
32
            </annotation>
33
         </attribute>
34
         <attribute name="name" type="string">
35
            <annotation>
36
               <documentation>
37
                  
38
               </documentation>
39
               <appInfo>
40
                  <meta.attribute translatable="true"/>
41
               </appInfo>
42
            </annotation>
43
         </attribute>
44
      </complexType>
45
   </element>
46
47
   <element name="type">
48
      <complexType>
49
         <attribute name="id" type="string" use="required">
50
            <annotation>
51
               <documentation>
52
                  Id of the type. This Id is used in &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode.addReference()&lt;/code&gt;
53
               </documentation>
54
            </annotation>
55
         </attribute>
56
         <attribute name="name" type="string" use="required">
57
            <annotation>
58
               <documentation>
59
                  A human readable name for this type. This name is displayed in the refactoring wizards.
60
               </documentation>
61
            </annotation>
62
         </attribute>
63
         <attribute name="isExplicit" type="boolean" use="required">
64
            <annotation>
65
               <documentation>
66
                  This flag determines whether the proxy node reference is explicit inside the underneath EMF objects.
67
               </documentation>
68
            </annotation>
69
         </attribute>
70
         <attribute name="owns" type="boolean" use="required">
71
            <annotation>
72
               <documentation>
73
                  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.
74
This relation is equivalent to the composition relation in UML.
75
               </documentation>
76
            </annotation>
77
         </attribute>
78
         <attribute name="oppositeReferenceTypeId" type="string">
79
            <annotation>
80
               <documentation>
81
                  The type id of the opposite reference if such a reference has been defined.
82
This is an optional attribute.
83
               </documentation>
84
            </annotation>
85
         </attribute>
86
      </complexType>
87
   </element>
88
89
   <annotation>
90
      <appInfo>
91
         <meta.section type="since"/>
92
      </appInfo>
93
      <documentation>
94
         4.3
95
      </documentation>
96
   </annotation>
97
98
   <annotation>
99
      <appInfo>
100
         <meta.section type="examples"/>
101
      </appInfo>
102
      <documentation>
103
         &lt;pre&gt;
104
       &lt;extension
105
             point=&quot;org.eclipse.hyades.test.ui.testNavigatorReferenceTypes&quot;&gt;
106
          &lt;type
107
                id=&quot;TestSuite2TestLog&quot;
108
                isExplicit=&quot;false&quot;
109
                name=&quot;Dependent Test Logs&quot;
110
                oppositeReferenceTypeId=&quot;TestLog2TestSuite&quot;
111
                owns=&quot;true&quot;/&gt;
112
          &lt;type
113
                id=&quot;TestLog2TestSuite&quot;
114
                isExplicit=&quot;true&quot;
115
                name=&quot;Source Test Suite&quot;
116
                oppositeReferenceTypeId=&quot;TestSuite2TestLog&quot;
117
                owns=&quot;false&quot;/&gt;
118
       &lt;/extension&gt;
119
&lt;/pre&gt;
120
      </documentation>
121
   </annotation>
122
123
   <annotation>
124
      <appInfo>
125
         <meta.section type="apiInfo"/>
126
      </appInfo>
127
      <documentation>
128
         
129
      </documentation>
130
   </annotation>
131
132
   <annotation>
133
      <appInfo>
134
         <meta.section type="implementation"/>
135
      </appInfo>
136
      <documentation>
137
         
138
      </documentation>
139
   </annotation>
140
141
   <annotation>
142
      <appInfo>
143
         <meta.section type="copyright"/>
144
      </appInfo>
145
      <documentation>
146
         Copyright (c) 2006 IBM Corporation and others.&lt;br&gt;
147
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
148
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
149
      </documentation>
150
   </annotation>
151
152
</schema>
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodePaster.java (+39 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.ltk.core.refactoring.Change;
16
17
/**
18
 * Interface that allows to describe the paste behavior of a proxy node.
19
 * 
20
 * @author jbozier
21
 * @version February 26, 2008
22
 * @since 4.5
23
 */
24
public interface IProxyNodePaster {
25
	/**
26
	 * Returns the refactoring change when pasting this instance to the new destination path.
27
	 * The given context can be used if the local change cannot be perform without a global context.
28
	 * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect 
29
	 * data. Such refactoring transaction will performed changes in one time.
30
	 * create a new proxy on dest location + copy proxy link if any
31
	 *   
32
	 * @param context a context that contains all IRefactoringTransaction instances defined by clients.
33
	 * @param newPath the destination path of this proxy node.
34
	 * @param targetName a 1 element array that will contain newly pasted proxy file name after call
35
	 * @return the change that performs the paste of the proxy node to the given destination path.
36
	 */
37
	public Change createPasteChange(IRefactoringContext context, IPath destinationPath,String [] targetName);
38
39
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameContainerChange.java (+151 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFolder;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProjectDescription;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourceAttributes;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.OperationCanceledException;
25
import org.eclipse.core.runtime.Path;
26
import org.eclipse.core.runtime.SubProgressMonitor;
27
import org.eclipse.hyades.test.ui.UiPlugin;
28
import org.eclipse.ltk.core.refactoring.Change;
29
import org.eclipse.ltk.core.refactoring.CompositeChange;
30
import org.eclipse.ltk.core.refactoring.NullChange;
31
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
32
import org.eclipse.osgi.util.NLS;
33
34
/**
35
 * @author jgout
36
 * @version February 26, 2008
37
 */
38
public class RenameContainerChange extends CompositeChange {
39
	private IContainer container;
40
	private boolean isFolder;
41
	private String newName;
42
43
	public RenameContainerChange(IContainer container, String newName) {
44
		super(""); //$NON-NLS-1$
45
		this.container = container;
46
		this.newName = newName;
47
		this.isFolder = container.getFullPath().segmentCount() > 1;
48
	}
49
	
50
	public Object getModifiedElement() {
51
		return container;
52
	}
53
54
	public String getName() {
55
		return NLS.bind(RefactoringMessages.RENAME_CONTAINER, container.getName(), newName);
56
	}
57
58
	public void initializeValidationData(IProgressMonitor pm) {
59
	}
60
61
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
62
		RefactoringStatus status = new RefactoringStatus();
63
		IContainer newContainer = getNewContainer();
64
		if (!container.isAccessible()) {
65
			if(isFolder) {
66
				status.addError(RefactoringMessages.NO_FOLDER);
67
			} else {
68
				status.addError(RefactoringMessages.NO_PROJECT);
69
			}
70
		}
71
		ResourceAttributes att = container.getResourceAttributes();
72
		if(att != null && att.isReadOnly()) {
73
			if(isFolder) {
74
				status.addError(RefactoringMessages.READ_ONLY_FOLDER);
75
			} else {
76
				status.addError(RefactoringMessages.READ_ONLY_PROJECT);
77
			}
78
		}
79
		if(newContainer.exists()) {
80
			if(isFolder) {
81
				status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FOLDER, newContainer.getName()));
82
			} else {
83
				status.addError(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROJECT, newContainer.getName()));
84
			}
85
		}
86
87
		return status;
88
	}
89
90
	private IContainer getNewContainer() {
91
		if(isFolder) {
92
			return container.getParent().getFolder(new Path(newName));
93
		} else {
94
			return ResourcesPlugin.getWorkspace().getRoot().getProject(newName);
95
		}
96
	}
97
98
	public Change perform(IProgressMonitor pm) throws CoreException {
99
		if(isFolder) {
100
			return performFolder(pm);
101
		} else {
102
			return performProject(pm);
103
		}
104
	}
105
106
	private Change performProject(IProgressMonitor pm) {
107
		pm.beginTask("", 2); //$NON-NLS-1$
108
		try {
109
			IProject project = (IProject) container;
110
			try {
111
				//- first process all children
112
				super.perform(new SubProgressMonitor(pm, 1));
113
				IProjectDescription description = project.getDescription();
114
				IPath newPath = container.getFullPath().removeLastSegments(1).append(newName);
115
				description.setName(newPath.segment(0));
116
		        project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1));
117
			} catch (CoreException e) {
118
				UiPlugin.logError(e);
119
			}
120
			return null;
121
		} finally {
122
			pm.done();
123
		}		
124
	}
125
	
126
	private Change performFolder(IProgressMonitor pm) {
127
		pm.beginTask("", 2); //$NON-NLS-1$
128
		try {
129
			IFolder folder = (IFolder) container;
130
			try {
131
				//- first process all children
132
				super.perform(new SubProgressMonitor(pm, 1));
133
				IPath newPath = folder.getFullPath().removeLastSegments(1).append(newName);
134
				folder.move(newPath, IResource.KEEP_HISTORY, new SubProgressMonitor(pm, 1));
135
			} catch (CoreException e) {
136
				UiPlugin.logError(e);
137
			}
138
			return null;
139
		} finally {
140
			pm.done();
141
		}		
142
	}
143
	
144
	public void freeze() {
145
		if(getChildren().length == 0) {
146
			markAsSynthetic();
147
			//- add a dummy child in order to keep the composite alive
148
			add(new NullChange(getName()));
149
		}
150
	}
151
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/CompositeReferencerProxyNode.java (+126 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import java.util.Collection;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Set;
19
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.hyades.internal.execution.local.control.NotImplementedException;
22
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
24
import org.eclipse.swt.graphics.Image;
25
26
/**
27
 * Wrapper class around a (referencer or not) proxy node.
28
 * The proxy node part is same as the wrapped one.
29
 * The references of this proxy node is built by grouping all references found of the whole proxy node hierarchy.
30
 * 
31
 * @author jgout
32
 * @version February 26, 2008
33
 * @since 4.3
34
 */
35
public class CompositeReferencerProxyNode implements IReferencerProxyNode {
36
	private IProxyNode proxy;
37
	//- map that associate a type name to the collection of referenced elements for this type of reference
38
	//- (typeName, Set(Referenced))
39
	private Map types;
40
	
41
	public CompositeReferencerProxyNode(IProxyNode proxy) {
42
		super();
43
		this.proxy = proxy;
44
		types = new HashMap();
45
		getDeepReferences(proxy);
46
	}
47
48
	public Set getReferenceTypes() {
49
		return types.keySet();
50
	}
51
52
	public Collection getReferences(String refType) {
53
		return (Collection) types.get(refType);
54
	}
55
56
	private void getDeepReferences(IProxyNode p) {
57
		if (p instanceof IReferencerProxyNode) {
58
			//- first, add all its references
59
			IReferencerProxyNode referencer = (IReferencerProxyNode) p;
60
			for (Iterator it = referencer.getReferenceTypes().iterator(); it.hasNext();) {
61
				String type = (String) it.next();
62
				types.put(type, referencer.getReferences(type));
63
			}
64
		}
65
		//- next, add those contained by its children
66
		IProxyNode[] children = p.getChildren();
67
		for (int i = 0; i < children.length; i++) {
68
			getDeepReferences(children[i]);
69
		}
70
	}
71
72
	/**
73
	 * This method is not intended to be called in this extender.
74
	 * Throws a NotImplementedException.
75
	 */
76
	public void removeReference(IProxyNode reference) {
77
		throw new NotImplementedException();
78
	}
79
	
80
	public String getIdentifier() {
81
		return proxy.getIdentifier();
82
	}
83
84
	public IResource getUnderlyingResource() {
85
		return proxy.getUnderlyingResource();
86
	}
87
88
	public IProxyNode[] getChildren() {
89
		return proxy.getChildren();
90
	}
91
92
	public Image getImage() {
93
		return proxy.getImage();
94
	}
95
96
	public Object getParent() {
97
		return proxy.getParent();
98
	}
99
100
	public String getText() {
101
		return proxy.getText();
102
	}
103
104
	public Object getAdapter(Class adapter) {
105
		if(adapter == IProxyNode.class) {
106
			return proxy;
107
		}
108
		return proxy.getAdapter(adapter);
109
	}
110
111
	public boolean equals(Object obj) {
112
		if (obj instanceof CompositeReferencerProxyNode) {
113
			CompositeReferencerProxyNode c = (CompositeReferencerProxyNode) obj;
114
			return proxy.equals(c.proxy);
115
		}
116
		return false;
117
	}
118
119
	public int hashCode() {
120
		return proxy.hashCode();
121
	}
122
123
	public IProxyNode getProxy() {
124
		return proxy;
125
	}
126
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ResourceSetRefactoring.java (+63 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Map;
17
import java.util.Set;
18
19
import org.eclipse.emf.common.util.URI;
20
import org.eclipse.emf.ecore.resource.Resource;
21
import org.eclipse.emf.ecore.resource.ResourceSet;
22
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
23
24
/**
25
 * @author jgout
26
 * @version February 26, 2008
27
 * @deprecated
28
 */
29
class ResourceSetRefactoring implements IResourceSetRefactoringContext {
30
	private Set resources;
31
	private Map newURIs;
32
	private ResourceSet resourceSet;
33
	
34
	public ResourceSetRefactoring() {
35
		this.resources = new HashSet();
36
		this.newURIs = new HashMap();
37
		this.resourceSet = new ResourceSetImpl();
38
	}
39
40
	public void addChangedURI(Resource res, URI newURI) {
41
		newURIs.put(res, newURI);
42
	}
43
44
	public void addResourceToSave(Resource res) {
45
		resources.add(res);
46
	}
47
48
	public URI getNewURI(Resource res) {
49
		return (URI)newURIs.get(res);
50
	}
51
52
	public ResourceSet getResourceSet() {
53
		return resourceSet;
54
	}
55
56
	public Set getResourcesToSave() {
57
		return resources;
58
	}
59
60
	public Set getResourcesToMove() {
61
		return newURIs.keySet();
62
	}
63
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderChange.java (+65 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFolder;
16
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.OperationCanceledException;
21
import org.eclipse.core.runtime.SubProgressMonitor;
22
import org.eclipse.hyades.test.ui.UiPlugin;
23
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
24
import org.eclipse.osgi.util.NLS;
25
26
/**
27
 * @author jgout
28
 * @author jbozier
29
 * @version February 26, 2008
30
 */
31
public class MoveFolderChange extends ReorgContainerChange {
32
	protected IPath destPath;
33
34
	public MoveFolderChange(IFolder folder, IPath destPath) {
35
		super(folder);
36
		this.destPath = destPath;
37
	}
38
39
	public IPath getDestinationPath() {
40
		return destPath;
41
	}
42
	
43
	public String getName() {
44
		IPath path = getPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
45
		return NLS.bind(RefactoringMessages.MOVE_FOLDER, path.toOSString(), destPath.toOSString());
46
	}
47
48
	public void reorgFolder(IContainer container, SubProgressMonitor monitor) {
49
		try {
50
			container.move(destPath.append(container.getName()), false, monitor);
51
		} catch (CoreException e) {
52
			UiPlugin.logError("Unable to move container", e); //$NON-NLS-1$
53
		}
54
	}
55
56
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
57
		RefactoringStatus status = new RefactoringStatus();
58
		IFolder folder = (IFolder) getModifiedElement();
59
		if(!folder.isAccessible()) {
60
			status.addFatalError(RefactoringMessages.NO_FOLDER);
61
		}
62
		return super.isValid(pm);
63
	}
64
65
}
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeDeleter.java (+27 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.ltk.core.refactoring.Change;
15
16
/**
17
 * Interface that allows to describe the delete behavior of a proxy node.
18
 * 
19
 * @author jgout
20
 * @version February 26, 2008
21
 * @since 4.4
22
 */
23
public interface IProxyNodeDeleter {
24
25
	public Change createDeleteChange(IRefactoringContext context);
26
27
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteRefactoring.java (+207 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Iterator;
15
import java.util.LinkedList;
16
import java.util.List;
17
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFolder;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IPath;
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.OperationCanceledException;
27
import org.eclipse.core.runtime.SubProgressMonitor;
28
import org.eclipse.hyades.test.ui.UiPlugin;
29
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
30
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
31
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
32
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodePaster;
33
import org.eclipse.ltk.core.refactoring.Change;
34
import org.eclipse.ltk.core.refactoring.CompositeChange;
35
import org.eclipse.ltk.core.refactoring.Refactoring;
36
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
37
import org.eclipse.osgi.util.NLS;
38
39
/**
40
 * refactoring for paste
41
 * @author jbozier
42
 * @version February 26, 2008
43
 * @since 4.5
44
 */
45
46
public class PasteRefactoring extends Refactoring {
47
	private Change change;
48
	private IContainer destination;
49
	private RefactoringContext context;
50
	protected List seenElements;
51
	private List folders; 
52
	private List proxies; 
53
54
	public PasteRefactoring(List folders, List proxies) {
55
		super();
56
		this.seenElements = new LinkedList();
57
		this.context = new RefactoringContext();
58
		this.folders = folders;
59
		this.proxies = proxies;
60
	}
61
	
62
	public List getContainers() {
63
		return folders;
64
	}
65
66
	public List getProxies() {
67
		return proxies;
68
	}
69
	
70
	public String getName() {
71
		return RefactoringMessages.UPDATE_OWNED_RESSOURCES_REFERENCES;  
72
	}
73
	
74
	public void setDestination(IContainer container) {
75
		this.destination = container;
76
		change = null;
77
	}
78
79
	public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
80
		pm.beginTask("", 3); //$NON-NLS-1$
81
		try {
82
			ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot());
83
			try {
84
				scanner.scan(new SubProgressMonitor(pm, 1));
85
			} catch (OperationCanceledException e) {
86
				return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG);
87
			}			
88
			change = createChange(new SubProgressMonitor(pm, 1));
89
			RefactoringStatus valid = change.isValid(new SubProgressMonitor(pm, 1));
90
			if(!valid.isOK()) {
91
				change = null;
92
			}
93
			return valid;
94
		} finally {
95
			pm.done();
96
		}
97
	}
98
99
	public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
100
		pm.beginTask("", 1); //$NON-NLS-1$
101
		try {
102
			return new RefactoringStatus();
103
		} finally {
104
			pm.done();
105
		}
106
	}
107
108
	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
109
		if (change != null) {
110
			return change;
111
		}
112
		pm.beginTask("", folders.size() + proxies.size()); //$NON-NLS-1$ 
113
		try {
114
			RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context);
115
			for (Iterator it = folders.iterator(); it.hasNext();) {
116
				Change containerChange = createPasteContainerChange((IFolder) it.next(), destination);
117
				if (containerChange != null) {
118
					c.add(containerChange);
119
				}
120
				pm.worked(1);
121
			}
122
			for (Iterator it = proxies.iterator(); it.hasNext();) {
123
				Change refChange = createPasteProxyChange((IProxyNode) it.next(), destination);
124
				if (refChange != null) {
125
					c.add(refChange);
126
				}
127
				pm.worked(1);
128
			}
129
			c.markAsSynthetic();
130
			return c;
131
		} finally {
132
			pm.done();
133
		}
134
	}
135
	
136
	private Change createPasteContainerChange(IFolder folder, IContainer dest) {
137
		IPath [] finalPath = new IPath[1]; 
138
		PasteFolderCompositeChange change = new PasteFolderCompositeChange(folder, dest.getFullPath(),finalPath);
139
		performContainerChildren(change, (IContainer)folder, finalPath[0]);
140
		change.freeze();
141
		return change;
142
	}
143
	
144
	private Change performContainerChildren(CompositeChange change, IContainer source, IPath newPath) {
145
		if(source.isAccessible()) {
146
			IResource[] resources;
147
			try {
148
				resources = source.members();
149
			} catch (CoreException e) {
150
				UiPlugin.logError("Unable to get members of container: "+source.getFullPath().toOSString(), e); //$NON-NLS-1$
151
				return null;
152
			}
153
			for (int i = 0; i < resources.length; i++) {
154
				if (resources[i] instanceof IFile) {
155
					IFile file = (IFile)resources[i];
156
					IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file);
157
					if (proxy != null) {
158
						// add here stuff to memorize changed children
159
					}
160
				} else {
161
					performContainerChildren(change, (IContainer)resources[i], newPath.append(resources[i].getName()));
162
				}
163
			}
164
		}
165
		return change;
166
	}
167
	
168
	// physical paste in case there is no link
169
	// create a new proxy on dest location + copy proxy link if any
170
	private Change createShallowPasteProxyChange(IProxyNode node, IContainer dest,String [] targetName) {
171
		IResource res = node.getUnderlyingResource();
172
		IProxyNodePaster paster = (IProxyNodePaster)node.getAdapter(IProxyNodePaster.class);
173
		if (paster != null) {
174
			IPath newPath = dest.getFullPath().append(res.getName());
175
			Change change = paster.createPasteChange(context, newPath,targetName);
176
			return change;
177
		} else {			
178
			if (res instanceof IFile) {
179
				return new PasteFileChange((IFile) res, dest);
180
			}
181
		}
182
		return null;
183
	}
184
	
185
	protected Change createPasteProxyChange(IProxyNode node, IContainer dest) {
186
		if (!seenElements.contains(node)) {
187
			seenElements.add(node);
188
			if (node instanceof IReferencerProxyNode) {
189
				Change change = createPasteReferencerChange((IReferencerProxyNode)node, dest,new String[1]);
190
				return change;
191
			} else {
192
				return createShallowPasteProxyChange(node, dest,new String[1]);
193
			}
194
		}		
195
		return null;
196
	}
197
	
198
	// logical paste in case there is links
199
	private Change createPasteReferencerChange(IReferencerProxyNode nodeA,IContainer dest,String [] targetName) {
200
		CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.PASTE_PROXY, nodeA.getText(), dest.getName()));
201
		Change pasteNode = createShallowPasteProxyChange(nodeA, dest,targetName); 
202
		if(pasteNode != null) {
203
			composite.add(pasteNode);
204
		}				
205
		return composite;
206
	}
207
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ProxyNodeScanner.java (+103 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IMarker;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.core.runtime.SubProgressMonitor;
23
import org.eclipse.hyades.test.ui.TestUIConstants;
24
import org.eclipse.hyades.test.ui.UiPlugin;
25
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator;
26
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyMarkerPersister;
27
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
28
import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager;
29
import org.eclipse.hyades.test.ui.navigator.IFileProxyFactory;
30
import org.eclipse.hyades.test.ui.navigator.ITypedElementProxyFactory;
31
32
/**
33
 * @author jgout
34
 * @author jbozier
35
 * @version February 26, 2008
36
 */
37
public class ProxyNodeScanner {
38
39
	private IContainer root;
40
	
41
	public ProxyNodeScanner(IContainer root) {
42
		this.root = root;
43
	}
44
45
	public void scan(IProgressMonitor pm) {
46
		scanContainer(root, pm);
47
	}
48
	
49
	private void scanContainer(IContainer container, IProgressMonitor pm) {
50
		Assert.isNotNull(container);
51
		try {
52
			if (container.isAccessible()) {
53
				IResource [] resources;
54
				try {
55
					resources = container.members();
56
				} catch (Exception e) {
57
					UiPlugin.logError("Unable to retrieve content of " + container.getName(), e); //$NON-NLS-1$
58
					return;
59
				}
60
				pm.beginTask(RefactoringMessages.ProxyNodeScanner_PM_LABEL, resources.length);
61
				for (int i = 0; i < resources.length; i++) {
62
					if (pm.isCanceled()) {
63
						throw new OperationCanceledException();
64
					}
65
					IResource res = resources[i];
66
					if (res instanceof IFile) {
67
						processFile((IFile) res);
68
						pm.worked(1);
69
					} else if (res instanceof IContainer) {
70
						scanContainer((IContainer) res, new SubProgressMonitor(pm, 1));
71
					}
72
				}
73
			}
74
		} finally{
75
			pm.done();
76
		}		
77
	}
78
79
	private void processFile(IFile file) {
80
		if(file.exists()) {
81
			IMarker[] markers;
82
			try {
83
				markers = file.findMarkers(FileProxyMarkerPersister.MARKER_PROXYSTATE, false, IResource.DEPTH_ZERO);
84
				if(markers.length == 0) {
85
					//- no proxy has ever been persisted for this file, load it in cache
86
					FileProxyNodeCache.getInstance().getProxy(file);
87
				} else {
88
					String factoryID = markers[0].getAttribute(TestUIConstants.TAG_FACTORY_ID, null);
89
					IFileProxyFactory fileFactory = TestNavigator.getFileFactoryManager().getFactory(factoryID);
90
					ITypedElementProxyFactory typedElementFactory = TypedElementFactoryManager.getInstance().getFactoryFromID(factoryID);
91
					if(fileFactory == null && typedElementFactory == null) {
92
						//- this is an old version of persisted proxy node or the tool that produced it is no longer installed
93
						//- we need to load it in cache
94
						FileProxyNodeCache.getInstance().getProxy(file);
95
					}
96
				}
97
			} catch (CoreException e) {
98
				//- this should never appear, since the file exists.
99
			}
100
        }
101
	}
102
103
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/EditorUtil.java (+152 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.action;
13
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.HashSet;
17
import java.util.List;
18
import java.util.Set;
19
20
import org.eclipse.core.resources.IWorkspace;
21
import org.eclipse.core.resources.IWorkspaceDescription;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.NullProgressMonitor;
25
import org.eclipse.hyades.test.ui.UiPlugin;
26
import org.eclipse.hyades.test.ui.internal.dialog.ListDialog;
27
import org.eclipse.hyades.ui.adapter.ISynchronizedEditorAdapter;
28
import org.eclipse.hyades.ui.editor.IEditorExtension;
29
import org.eclipse.hyades.ui.internal.editor.HyadesEditorPart;
30
import org.eclipse.jface.viewers.ArrayContentProvider;
31
import org.eclipse.jface.viewers.ILabelProvider;
32
import org.eclipse.jface.viewers.LabelProvider;
33
import org.eclipse.jface.window.Window;
34
import org.eclipse.swt.graphics.Image;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Control;
37
import org.eclipse.swt.widgets.Shell;
38
import org.eclipse.ui.IEditorInput;
39
import org.eclipse.ui.IEditorPart;
40
import org.eclipse.ui.IWorkbench;
41
import org.eclipse.ui.IWorkbenchPage;
42
import org.eclipse.ui.IWorkbenchWindow;
43
import org.eclipse.ui.PlatformUI;
44
45
/**
46
 * @author jgout,jbozier
47
 * @version February 26, 2008
48
 */
49
public class EditorUtil {
50
	
51
	/**
52
	 * Saves all modified editors.
53
	 * @param shell
54
	 * @return <code>true</code> if all saves have been successfully performed and <code>false</code> otherwise. 
55
	 */
56
	public static boolean saveEditors(Shell shell) {
57
		IEditorPart[] dirtyEditors= getDirtyEditors();
58
		if (dirtyEditors.length == 0)
59
			return true;
60
		if (! saveAllDirtyEditors(shell, dirtyEditors))
61
			return false;
62
		try {
63
			// Save isn't cancelable.
64
			IWorkspace workspace= ResourcesPlugin.getWorkspace();
65
			IWorkspaceDescription description= workspace.getDescription();
66
			boolean autoBuild= description.isAutoBuilding();
67
			description.setAutoBuilding(false);
68
			workspace.setDescription(description);
69
			try {
70
				for (int i = 0; i < dirtyEditors.length; i++) {
71
					IEditorPart part = dirtyEditors[i];
72
					if (part instanceof HyadesEditorPart) {
73
						HyadesEditorPart hyadesEditor = (HyadesEditorPart) part;
74
						hyadesEditor.doSave(new NullProgressMonitor());
75
						IEditorExtension extension = hyadesEditor.getEditorExtension();
76
						if (extension instanceof ISynchronizedEditorAdapter) {
77
							((ISynchronizedEditorAdapter) extension).reload();
78
						}
79
					}
80
				}
81
				if (!UiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false))
82
					return false;
83
			} finally {
84
				description.setAutoBuilding(autoBuild);
85
				workspace.setDescription(description);
86
			}
87
			return true;
88
		} catch (CoreException e) {
89
			UiPlugin.logError("Unable to save modified resources", e); //$NON-NLS-1$
90
			return false;
91
		}
92
	}
93
94
	private static boolean saveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) {
95
		ListDialog dialog= new ListDialog(shell) {
96
			protected Control createDialogArea(Composite parent) {
97
				Composite result= (Composite) super.createDialogArea(parent);
98
				applyDialogFont(result);
99
				return result;
100
			}
101
		};
102
		dialog.setTitle(ActionMessages.SAVE_ALL_DIALOG_NAME); 
103
		dialog.setAddCancelButton(true);
104
		dialog.setLabelProvider(createDialogLabelProvider());
105
		dialog.setMessage(ActionMessages.SAVE_ALL_DIALOG_MESSAGE); 
106
		dialog.setContentProvider(new ArrayContentProvider());
107
		dialog.setInput(Arrays.asList(dirtyEditors));
108
		return dialog.open() == Window.OK;
109
	}
110
	
111
	private static ILabelProvider createDialogLabelProvider() {
112
		return new LabelProvider() {
113
			public Image getImage(Object element) {
114
				return ((IEditorPart) element).getTitleImage();
115
			}
116
			public String getText(Object element) {
117
				return ((IEditorPart) element).getTitle();
118
			}
119
		};
120
	}	
121
	
122
	/**
123
	 * Returns an array of all editors that have an unsaved content. If the identical content is 
124
	 * presented in more than one editor, only one of those editor parts is part of the result.
125
	 * (Copied from jdt internal)
126
	 * 
127
	 * @return an array of all dirty editor parts.
128
	 */
129
	private static IEditorPart[] getDirtyEditors() {
130
		Set inputs= new HashSet();
131
		List result= new ArrayList(0);
132
		IWorkbench workbench= PlatformUI.getWorkbench();
133
		IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
134
		for (int i= 0; i < windows.length; i++) {
135
			IWorkbenchPage[] pages= windows[i].getPages();
136
			for (int x= 0; x < pages.length; x++) {
137
				IEditorPart[] editors= pages[x].getDirtyEditors();
138
				for (int z= 0; z < editors.length; z++) {
139
					IEditorPart ep= editors[z];
140
					if (ep instanceof HyadesEditorPart) {
141
						IEditorInput input= ep.getEditorInput();
142
						if (!inputs.contains(input)) {
143
							inputs.add(input);
144
							result.add(ep);
145
						}
146
					}
147
				}
148
			}
149
		}
150
		return (IEditorPart[])result.toArray(new IEditorPart[result.size()]);
151
	}
152
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/UpdateModelChange.java (+67 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.OperationCanceledException;
18
import org.eclipse.emf.ecore.resource.Resource;
19
import org.eclipse.emf.ecore.util.EcoreUtil;
20
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
21
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
23
import org.eclipse.ltk.core.refactoring.Change;
24
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
25
import org.eclipse.osgi.util.NLS;
26
27
/**
28
 * @author jbozier
29
 * @author jgout
30
 * @version February 26, 2008
31
 */
32
public class UpdateModelChange extends Change {
33
	private IProxyNode referencer;
34
	private EMFRefactoringTransaction context;
35
36
	public UpdateModelChange(IProxyNode node, IRefactoringContext context) {
37
		this.referencer = node;
38
		this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
39
		Assert.isNotNull(this.context);
40
	}
41
42
	public String getName() {
43
		return NLS.bind(RefactoringMessages.UPDATE_REFERENCES, referencer.getText());
44
	}
45
46
	public Change perform(IProgressMonitor pm) throws CoreException {
47
		if (referencer instanceof EObjectProxyNode) {
48
			//- load the referencer
49
			Resource res = context.getResourceSet().getResource(((EObjectProxyNode)referencer).getOriginatorURI().trimFragment(), true);
50
			EcoreUtil.resolveAll(res); 
51
			context.addResourceToSave(res);
52
		}
53
		return null;
54
	}
55
56
	public Object getModifiedElement() {
57
		return referencer;
58
	}
59
60
	public void initializeValidationData(IProgressMonitor pm) {
61
	}
62
63
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
64
		return new RefactoringStatus();
65
	}
66
67
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/FileAndFolderPaster.java (+112 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.action;
13
14
import java.util.LinkedList;
15
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFolder;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.runtime.IAdaptable;
21
import org.eclipse.hyades.test.ui.UiPlugin;
22
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
23
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.IPasterExtended;
24
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteRefactoring;
25
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.PasteRefactoringWizard;
26
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
27
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
28
import org.eclipse.swt.dnd.Clipboard;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.ui.part.ResourceTransfer;
31
/**
32
 * @author jbozier
33
 * @version February 26, 2008
34
 */
35
public class FileAndFolderPaster implements IPasterExtended {
36
37
	private LinkedList folders;
38
	private LinkedList proxies;
39
	private Clipboard clipboard;
40
	private Shell shell;
41
42
	public FileAndFolderPaster() {
43
		folders = new LinkedList();
44
		clipboard = null;
45
		proxies = new LinkedList();
46
		shell = null;
47
	}
48
	
49
	public boolean isPasteAllowedFor(Clipboard clipboard, Object selection) {		
50
		return (selection instanceof IContainer);
51
	}
52
53
	public void setShell(Shell shell) {
54
		this.shell = shell;
55
	}
56
	
57
	private void sortClipboardElements() {
58
		folders.clear();
59
		proxies.clear();
60
		IResource [] res = getResourceFromClipboard();
61
		for (int i=0; i<res.length; i++) {
62
			if (res[i] instanceof IFile) {
63
				IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy((IFile)res[i]);
64
				if (proxy != null) {
65
					proxies.add(proxy);
66
				}				
67
			} else if (res[i] instanceof IAdaptable) {
68
				IAdaptable a = (IAdaptable) res[i];
69
				Object o = a.getAdapter(IFolder.class);
70
				if(o != null) {
71
					folders.add((IFolder) o);
72
				}
73
			}
74
		}
75
	}
76
	
77
	
78
	private IResource [] getResourceFromClipboard() {
79
		final IResource[][] clipboardData = new IResource[1][];
80
		shell.getDisplay().syncExec(new Runnable() {
81
			public void run() {
82
				//- clipboard must have resources or files
83
				ResourceTransfer resTransfer = ResourceTransfer.getInstance();
84
				clipboardData[0] = (IResource[]) clipboard.getContents(resTransfer);
85
			}
86
		});
87
		return clipboardData[0];
88
	}
89
	
90
	private boolean canActivate(Shell shell) {
91
		return EditorUtil.saveEditors(shell);
92
	}
93
	
94
	public boolean performPaste(Clipboard clipboard, Object selection) {
95
		if (! canActivate(shell))
96
			return false;
97
		this.clipboard = clipboard;
98
		sortClipboardElements();
99
		PasteRefactoring refactoring = new PasteRefactoring(folders,proxies);
100
		PasteRefactoringWizard wizard = new PasteRefactoringWizard(refactoring,selection);
101
		wizard.setDefaultPageTitle(ActionMessages.PASTE_ACTION_NAME);
102
		wizard.setNeedsProgressMonitor(true);
103
		RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
104
		try {
105
			op.run(shell , ""); //$NON-NLS-1$
106
		} catch (InterruptedException e) {
107
			UiPlugin.logError(e);
108
		}
109
		return true;
110
	}
111
112
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFileChange.java (+82 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.OperationCanceledException;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.ltk.core.refactoring.Change;
21
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
22
import org.eclipse.osgi.util.NLS;
23
24
/**
25
 * @author jgout
26
 * @author jbozier
27
 * @version February 26, 2008
28
 */
29
public class MoveFileChange extends Change {
30
31
	private IFile file;
32
	private IContainer destFolder;
33
34
	public MoveFileChange(IFile file, IContainer destination) {
35
		super();
36
		this.file = file;
37
		this.destFolder = destination;
38
	}
39
40
	public Object getModifiedElement() {
41
		return file;
42
	}
43
44
	public String getName() {
45
		return NLS.bind(RefactoringMessages.MOVE_FILE, file.getName(), destFolder.getFullPath().toOSString());
46
	}
47
48
	public void initializeValidationData(IProgressMonitor pm) {
49
	}
50
51
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
52
		RefactoringStatus status = new RefactoringStatus();
53
		IFile destFile = destFolder.getFile(new Path(file.getName()));
54
		if (!file.exists()) {
55
			status.addError(RefactoringMessages.NO_FILE);
56
		}
57
		if(destFile.exists()) {
58
			status.addWarning(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FILE, destFile.getFullPath().toPortableString()));
59
		}
60
		if (file.isReadOnly()) {
61
			status.addWarning(RefactoringMessages.READ_ONLY_FILE);
62
		}
63
		return status;
64
	}
65
66
	public Change perform(IProgressMonitor pm) throws CoreException {
67
		Change undo = null;
68
		pm.beginTask("", 1);  //$NON-NLS-1$
69
		try {
70
			IContainer parent = file.getParent();
71
			if (parent != null) {
72
				undo = new MoveFileChange(file, parent);
73
			}
74
			file.move(destFolder.getFullPath().append(file.getName()), false, true, pm);
75
			pm.worked(1);
76
			return undo;
77
		} finally {
78
			pm.done();
79
		}
80
	}
81
82
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerCompositeChange.java (+38 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
/**
15
 * @author jgout
16
 * @version February 26, 2008
17
 */
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.ltk.core.refactoring.Change;
20
import org.eclipse.osgi.util.NLS;
21
22
public class DeleteContainerCompositeChange extends ReorgContainerCompositeChange {
23
	private DeleteContainerChange delChange;
24
	
25
	public DeleteContainerCompositeChange(IContainer container) {
26
		super(NLS.bind(RefactoringMessages.DELETE_FOLDER, container.getFullPath().toOSString()), container);
27
		delChange = new DeleteContainerChange(container);
28
	}
29
30
	public Change getDeleteContainerChange() {
31
		return delChange;
32
	}
33
34
	public Change getRootChange() {
35
		return delChange;
36
	}
37
	
38
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveModelChange.java (+101 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Date;
15
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.OperationCanceledException;
23
import org.eclipse.emf.common.util.URI;
24
import org.eclipse.emf.ecore.resource.Resource;
25
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
26
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
27
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
28
import org.eclipse.ltk.core.refactoring.Change;
29
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
30
import org.eclipse.osgi.util.NLS;
31
32
/**
33
 * @author jgout
34
 * @version February 26, 2008
35
 */
36
public class MoveModelChange extends Change {
37
	private EMFRefactoringTransaction context;
38
	protected IPath destination;
39
	protected IProxyNode proxy;
40
	private boolean shouldBeRenamed;
41
	private RefactoringStatus status;
42
43
	public MoveModelChange(IProxyNode node, IRefactoringContext context, IPath destinationPath) {
44
		this.proxy = node;
45
		this.destination = destinationPath;
46
		this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
47
		Assert.isNotNull(this.context);
48
		this.status = new RefactoringStatus();
49
		IFile destFile = ResourcesPlugin.getWorkspace().getRoot().getFile(destination);
50
		if (destFile.exists()) {
51
			handleFileAlreadyExists(this.status);
52
		}
53
	}
54
55
	public Object getModifiedElement() {
56
		return proxy;
57
	}
58
59
	public String getName() {
60
		String fileName = proxy.getUnderlyingResource().getFullPath().toPortableString();
61
		return NLS.bind(RefactoringMessages.MOVE_FILE, fileName, destination.removeLastSegments(1));
62
	}
63
64
	public void initializeValidationData(IProgressMonitor pm) {
65
	}
66
67
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
68
		return this.status;
69
	}
70
71
	protected void handleFileAlreadyExists(RefactoringStatus status) {
72
		status.addInfo(NLS.bind(RefactoringMessages.ALREADY_EXISTS_PROXY_DURING_MOVE, destination.toPortableString()));
73
		shouldBeRenamed = true;
74
	}
75
	
76
	public Change perform(IProgressMonitor pm) throws CoreException {
77
		if (proxy instanceof EObjectProxyNode) {
78
			//- load the referencer
79
			Resource res = context.getResourceSet().getResource(((EObjectProxyNode)proxy).getOriginatorURI().trimFragment(), true);
80
			context.addResourceToSave(res);
81
			context.addChangedURI(res, getNewURI());
82
		}
83
		return null;
84
	}
85
86
	public URI getNewURI() {
87
		return URI.createPlatformResourceURI(getNewName(),false);
88
	}
89
90
	private String getNewName() {
91
		if(shouldBeRenamed) {
92
			String fullFileName = destination.lastSegment();
93
			int dotIndex = fullFileName.lastIndexOf('.');
94
			long number = new Date().getTime();
95
			String newName = fullFileName.substring(0, dotIndex-1)+number+fullFileName.substring(dotIndex);
96
			return destination.removeLastSegments(1).append(newName).toPortableString();
97
		} else {
98
			return destination.toPortableString();
99
		}
100
	}	
101
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringMessages.java (+81 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.osgi.util.NLS;
15
16
/**
17
 * @author jgout
18
 * @author jbozier
19
 * @version February 26, 2008
20
 */
21
public class RefactoringMessages extends NLS {
22
	private static final String BUNDLE_NAME = "org.eclipse.hyades.test.ui.internal.navigator.refactoring.messages"; //$NON-NLS-1$
23
24
	public static String DELETE_FOLDER;
25
	public static String DELETE_PROXY;
26
	public static String DELETE_INVOCATION;
27
	public static String DELETE_CONFIRM_1;
28
	public static String DELETE_CONFIRM_N;
29
	public static String DELETE_DEEP_REMOVE;
30
31
	public static String NO_FOLDER;
32
	public static String NO_PROJECT;
33
34
	public static String ProxyNodeScanner_PM_LABEL;
35
	public static String READ_ONLY_FOLDER;
36
	public static String READ_ONLY_PROJECT;
37
	public static String ALREADY_EXISTS_FOLDER;
38
	public static String ALREADY_EXISTS_PROJECT;
39
	public static String MOVE_FOLDER;
40
	public static String MOVE_CHOOSE_DESTINATION_SINGLE;
41
	public static String MOVE_CHOOSE_DESTINATION_MULTI;
42
	public static String MOVE_ERROR;
43
	public static String MOVE_FILE;
44
	public static String MOVE_PROXY;
45
	
46
	public static String PASTE_FILE;
47
	public static String PASTE_FOLDER;
48
	public static String PASTE_PROXY;
49
	public static String PASTE_CHOOSE_DESTINATION_SINGLE;
50
	public static String PASTE_CHOOSE_DESTINATION_MULTI;
51
	public static String PASTE_ERROR;
52
53
	public static String ReorgRefactoring_CANCELED_OPERATION_MSG;
54
	public static String UPDATE_PROXY;
55
	public static String CHANGES_FOR_UPDATING;
56
	public static String UPDATE_PROXY_PATH_CHANGED;
57
	public static String UPDATE_REFERENCES;
58
	public static String UPDATE_OWNED_RESSOURCES_REFERENCES;
59
	public static String NO_FILE;
60
	public static String ALREADY_EXISTS_FILE;
61
	public static String READ_ONLY_FILE;
62
	public static String ALREADY_EXISTS_PROXY_DURING_MOVE;
63
	public static String ALREADY_EXISTS_PROXY_DURING_RENAME;
64
	public static String ALREADY_EXISTS_PROXY_DURING_PASTE;
65
	public static String RENAME_FILE;
66
	public static String RENAME_PROXY;
67
	public static String RENAME_CONTAINER;
68
	public static String INNER_FOLDER_MOVE_ERROR;
69
	public static String INNER_FOLDER_PASTE_ERROR;
70
	
71
	public static String LaunchConfigurationUpdateChange_NAME;
72
	public static String LaunchConfigurationDeleteChange_NAME;
73
	
74
	static {
75
		// initialize resource bundle
76
		NLS.initializeMessages(BUNDLE_NAME, RefactoringMessages.class);
77
	}
78
79
	private RefactoringMessages() {
80
	}
81
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RefactoringTransactionRootChange.java (+76 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IWorkspaceRunnable;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.SubProgressMonitor;
19
import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction;
20
import org.eclipse.ltk.core.refactoring.Change;
21
import org.eclipse.ltk.core.refactoring.CompositeChange;
22
23
/**
24
 * Root change of move and rename action. 
25
 * The performChange implementation has a transactional behavior according to the following pattern:
26
 *  - context.beginChanges()
27
 *  - Children perfomChange()
28
 *  - context.commitChanges()
29
 *  That way, it is guarantee that refactoring transactions (stored in the context) 
30
 *  commit their changes after children ones. 
31
 * @author jgout
32
 * @version February 26, 2008
33
 * @since 4.3
34
 */
35
public class RefactoringTransactionRootChange extends CompositeChange {
36
	private IRefactoringTransaction context;
37
38
	private final class SaveResourceSetRunnable implements IWorkspaceRunnable {
39
		private Change undoChange;
40
		
41
		public void run(IProgressMonitor monitor) throws CoreException {
42
			undoChange = RefactoringTransactionRootChange.super.perform(monitor);
43
		}
44
		
45
		public Change getUndoChange() {
46
			return undoChange;
47
		}
48
	}
49
50
	public RefactoringTransactionRootChange(IRefactoringTransaction context) {
51
		super(""); //$NON-NLS-1$
52
		this.context = context;
53
	}
54
55
	public Change perform(IProgressMonitor pm) throws CoreException {
56
		pm.beginTask("", 3); //$NON-NLS-1$
57
		try {
58
			CompositeChange undo = new CompositeChange("");//$NON-NLS-1$
59
			context.beginChanges(new SubProgressMonitor(pm, 1));
60
			try {
61
				//- Children performChange()
62
				SaveResourceSetRunnable action = new SaveResourceSetRunnable();
63
				ResourcesPlugin.getWorkspace().run(action, new SubProgressMonitor(pm, 1));
64
				undo.add(action.getUndoChange());
65
			} catch (CoreException t) {
66
				context.cancelChanges(pm);
67
				throw t;
68
			}		
69
			undo.add(context.commitChanges(new SubProgressMonitor(pm, 1)));
70
			return undo;
71
		} finally {
72
			pm.done();
73
		}		
74
	}
75
76
}
(-)src/org/eclipse/hyades/test/ui/navigator/IReferencerProxyNode.java (+40 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator;
13
14
import java.util.Collection;
15
import java.util.Set;
16
17
/**
18
 * Interface to set references between proxy nodes.
19
 * 
20
 * @author jgout
21
 * @version February 26, 2008
22
 * @since 4.4
23
 */
24
public interface IReferencerProxyNode extends IProxyNode {	
25
	/**
26
	 * Gets the reference collection of the given type. The content of this list is populated using {@link addReference} or {@link addBidirectionalReference}.
27
	 * @param refType the type of the reference to retrieve.
28
	 * @return a collection containing all the references (IProxyNode) of the 
29
	 * given type found in the current implementor. An empty 
30
	 * collection is returned in case of no such typed reference has been found.
31
	 */
32
	public Collection getReferences(String refType);
33
	
34
	/**
35
	 * Returns the set of the reference types (as <code>String</code>) contained in the implementor proxy node.
36
	 * @return the set of the reference types (as <code>String</code>) contained in the implementor proxy node.
37
	 */
38
	public Set getReferenceTypes();
39
	
40
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/DeleteAction.java (+85 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.hyades.test.ui.internal.navigator.action;
12
13
import java.util.Iterator;
14
import java.util.LinkedList;
15
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.hyades.test.ui.UiPlugin;
18
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteRefactoring;
19
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DeleteRefactoringWizard;
20
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
21
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter;
22
import org.eclipse.hyades.ui.util.IDisposable;
23
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.ui.actions.SelectionListenerAction;
27
28
/**
29
 * @author jgout,jbozier
30
 * @version February 26, 2008
31
 */
32
public class DeleteAction extends SelectionListenerAction implements IDisposable {
33
	private Shell shell;
34
	private LinkedList containers;
35
	private LinkedList proxies;
36
	
37
	public DeleteAction(Shell shell) {
38
		super(ActionMessages.DELETE_ACTION_NAME); 
39
		this.shell = shell;
40
		containers = new LinkedList();
41
		proxies = new LinkedList();
42
	}
43
44
	public void run() {
45
		if (! canActivate(shell))
46
			return;
47
		DeleteRefactoring refactoring = new DeleteRefactoring(containers, proxies);
48
		DeleteRefactoringWizard wizard = new DeleteRefactoringWizard(refactoring);
49
		wizard.setDefaultPageTitle(ActionMessages.DELETE_ACTION_NAME);
50
		wizard.setNeedsProgressMonitor(true);
51
		RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
52
		try {
53
			op.run(shell , ""); //$NON-NLS-1$
54
		} catch (InterruptedException e) {
55
			UiPlugin.logError(e);
56
		}
57
	}
58
59
	private boolean canActivate(Shell shell) {
60
		return EditorUtil.saveEditors(shell);
61
	}
62
63
	public void dispose() {
64
	}
65
66
	protected boolean updateSelection(IStructuredSelection selection) {
67
		boolean selOk = true;
68
		containers.clear();
69
		proxies.clear();
70
		for (Iterator it = selection.iterator(); it.hasNext() && selOk;) {
71
			Object o = it.next();
72
			if (o instanceof IContainer) {
73
				containers.add((IContainer) o);
74
			} else if (o instanceof IProxyNode) {
75
				IProxyNodeDeleter deleter = (IProxyNodeDeleter) ((IProxyNode) o).getAdapter(IProxyNodeDeleter.class);
76
				selOk &= deleter != null;
77
				proxies.add(deleter);
78
			} else {
79
				selOk = false;
80
			}
81
		}
82
		return selOk;
83
	}
84
	
85
}
(-)src/org/eclipse/hyades/test/ui/internal/dialog/ListDialog.java (+94 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.dialog;
13
14
import org.eclipse.jface.dialogs.IDialogConstants;
15
import org.eclipse.jface.viewers.ILabelProvider;
16
import org.eclipse.jface.viewers.IStructuredContentProvider;
17
import org.eclipse.jface.viewers.TableViewer;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.swt.widgets.Shell;
23
import org.eclipse.swt.widgets.Table;
24
import org.eclipse.ui.dialogs.SelectionDialog;
25
26
public class ListDialog extends SelectionDialog {
27
28
	private IStructuredContentProvider fContentProvider;
29
	private ILabelProvider fLabelProvider;
30
	private Object fInput;
31
	private TableViewer fTableViewer;
32
	private boolean fAddCancelButton;
33
	
34
	public ListDialog(Shell parent) {
35
		super(parent);
36
		fAddCancelButton= false;
37
	}
38
39
	public void setInput(Object input) {
40
		fInput= input;
41
	}
42
	
43
	public void setContentProvider(IStructuredContentProvider sp){
44
		fContentProvider= sp;
45
	}
46
	
47
	public void setLabelProvider(ILabelProvider lp){
48
		fLabelProvider= lp;
49
	}
50
51
	public void setAddCancelButton(boolean addCancelButton) {
52
		fAddCancelButton= addCancelButton;
53
	}
54
	
55
	public TableViewer getTableViewer(){
56
		return fTableViewer;
57
	}
58
			
59
	public boolean hasFilters(){
60
		return fTableViewer.getFilters() != null && fTableViewer.getFilters().length != 0;
61
	}
62
	
63
	public void create() {
64
		setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
65
		super.create();
66
	}
67
	
68
	protected void createButtonsForButtonBar(Composite parent) {
69
		if (! fAddCancelButton)
70
			createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
71
		else
72
			super.createButtonsForButtonBar(parent);	
73
	}	
74
	
75
	protected Control createDialogArea(Composite container) {
76
		Composite parent= (Composite) super.createDialogArea(container);
77
		createMessageArea(parent);
78
		fTableViewer= new TableViewer(parent, getTableStyle());
79
		fTableViewer.setContentProvider(fContentProvider);
80
		Table table= fTableViewer.getTable();
81
		fTableViewer.setLabelProvider(fLabelProvider);
82
		fTableViewer.setInput(fInput);
83
		GridData gd= new GridData(GridData.FILL_BOTH);
84
		gd.heightHint= convertHeightInCharsToPixels(15);
85
		gd.widthHint= convertWidthInCharsToPixels(55);
86
		table.setLayoutData(gd);
87
		applyDialogFont(parent);		
88
		return parent;
89
	}
90
	
91
	protected int getTableStyle() {
92
		return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
93
	}
94
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ModelPathChange.java (+70 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.OperationCanceledException;
19
import org.eclipse.emf.common.util.URI;
20
import org.eclipse.emf.ecore.resource.Resource;
21
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.actions.IRefactoringContext;
24
import org.eclipse.ltk.core.refactoring.Change;
25
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
26
import org.eclipse.osgi.util.NLS;
27
28
/**
29
 * @author jgout
30
 * @author jbozier
31
 * @version February 26, 2008
32
 */
33
public class ModelPathChange extends Change {
34
	private IProxyNode referenced;
35
	private EMFRefactoringTransaction context;
36
	private IPath newPath;
37
38
	public ModelPathChange(EObjectProxyNode node, IRefactoringContext context, IPath destinationPath) {
39
		this.referenced = node;
40
		this.context = (EMFRefactoringTransaction) context.getRefactoringTransaction(EMFRefactoringTransaction.Id);
41
		this.newPath = destinationPath;
42
		Assert.isNotNull(this.context);
43
	}
44
45
	public Object getModifiedElement() {
46
		return referenced;
47
	}
48
49
	public String getName() {
50
		return NLS.bind(RefactoringMessages.UPDATE_PROXY_PATH_CHANGED, referenced.getText());
51
	}
52
53
	public void initializeValidationData(IProgressMonitor pm) {
54
	}
55
56
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,	OperationCanceledException {
57
		return new RefactoringStatus();
58
	}
59
60
	public Change perform(IProgressMonitor pm) throws CoreException {
61
		if (referenced instanceof EObjectProxyNode) {
62
			//- load the referenced
63
			Resource res = context.getResourceSet().getResource(((EObjectProxyNode)referenced).getOriginatorURI().trimFragment(), true);
64
			context.addResourceToSave(res);
65
			context.addChangedURI(res, URI.createPlatformResourceURI(newPath.toPortableString(),false));
66
		}
67
		return null;
68
	}
69
70
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteContainerChange.java (+42 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
/**
15
 * @author jgout
16
 * @version February 26, 2008
17
 */
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.SubProgressMonitor;
21
import org.eclipse.hyades.test.ui.UiPlugin;
22
import org.eclipse.osgi.util.NLS;
23
24
public class DeleteContainerChange extends ReorgContainerChange {
25
26
	public DeleteContainerChange(IContainer cont) {
27
		super(cont);
28
	}
29
30
	public void reorgFolder(IContainer container, SubProgressMonitor monitor) {
31
		try {
32
			container.delete(false, monitor);
33
		} catch (CoreException e) {
34
			UiPlugin.logError(e);
35
		}
36
	}
37
38
	public String getName() {
39
		return NLS.bind(RefactoringMessages.DELETE_FOLDER, getPath().toOSString());
40
	}
41
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/CompositeChangeWithRoot.java (+76 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
/**
15
 * @author jgout
16
 * @version February 26, 2008
17
 */
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.SubProgressMonitor;
22
import org.eclipse.ltk.core.refactoring.Change;
23
import org.eclipse.ltk.core.refactoring.CompositeChange;
24
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
25
26
public class CompositeChangeWithRoot extends CompositeChange {
27
	private Change root;
28
	private String name;
29
30
	public CompositeChangeWithRoot(Change root) {
31
		super(""); //$NON-NLS-1$
32
		Assert.isNotNull(root);
33
		this.root = root;
34
	}
35
	
36
	public CompositeChangeWithRoot(Change root, String name) {
37
		super(name);
38
		//- in this constructor, root can be null 
39
		this.root = root;
40
		if(root == null) {
41
			Assert.isLegal(name != null && name.length() > 0, "Empty name with null root"); //$NON-NLS-1$
42
			this.name = name;
43
		}
44
	}
45
46
	public String getName() {
47
		return root != null ? root.getName() : name;
48
	}
49
50
	public Change freeze() {
51
		if(getChildren().length == 0) {
52
			return root;
53
		}
54
		if (root instanceof CompositeChange) {
55
			merge((CompositeChange)root);
56
		} else {
57
			add(root);
58
		}
59
		
60
		return this;
61
	}
62
63
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
64
		pm.beginTask("", getChildren().length+1); //$NON-NLS-1$
65
		try {
66
			RefactoringStatus status = super.isValid(new SubProgressMonitor(pm, getChildren().length));
67
			if (root != null) {
68
				status.merge(root.isValid(new SubProgressMonitor(pm, 1)));
69
			}
70
			return status;
71
		} finally {
72
			pm.done();
73
		}
74
	}
75
76
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ReferenceTypeRegistry.java (+148 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IExtensionPoint;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.hyades.test.ui.UiPlugin;
21
22
/**
23
 * Registry to manage reference types (<code>ReferenceType</code>).
24
 * @author jgout
25
 * @version February 26, 2008
26
 * @since 4.3
27
 */
28
public class ReferenceTypeRegistry {
29
30
	private static ReferenceTypeRegistry instance;
31
	private Map types;
32
	
33
	static class ReferenceType {
34
35
		private String name;
36
		private boolean owns;
37
		private boolean isExplicit;
38
		private String oppositeId;
39
40
		public ReferenceType(String name, boolean owns, boolean isExplicit, String oppositeId) {
41
			this.name = name;
42
			this.owns = owns;
43
			this.isExplicit = isExplicit;
44
			this.oppositeId = oppositeId;
45
		}
46
47
		public boolean owns() {
48
			return owns;
49
		}
50
51
		public boolean isExplicit() {
52
			return isExplicit;
53
		}
54
55
		public String getOppositeId() {
56
			return oppositeId;
57
		}
58
59
		public String getName() {
60
			return name;
61
		}
62
	}
63
	
64
	private ReferenceTypeRegistry() {
65
		types = new HashMap();
66
		IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(UiPlugin.getID() + ".testNavigatorReferenceTypes"); //$NON-NLS-1$
67
		if (extPoint != null) {
68
			IConfigurationElement[] members = extPoint.getConfigurationElements();
69
			for (int i = 0; i < members.length; i++) {
70
				IConfigurationElement element = members[i];
71
				if ("type".equals(element.getName())) { //$NON-NLS-1$
72
					String id = element.getAttribute("id"); //$NON-NLS-1$
73
					String name = element.getAttribute("name"); //$NON-NLS-1$
74
					boolean owns = Boolean.valueOf(element.getAttribute("owns")).booleanValue(); //$NON-NLS-1$
75
					boolean isExplicit = Boolean.valueOf(element.getAttribute("isExplicit")).booleanValue(); //$NON-NLS-1$
76
					String oppositeId = element.getAttribute("oppositeReferenceTypeId"); //$NON-NLS-1$
77
					types.put(id, new ReferenceType(name, owns, isExplicit, oppositeId));
78
				}
79
			}
80
		}
81
	}
82
	
83
	public static ReferenceTypeRegistry getInstance() {
84
		if(instance == null) {
85
			instance = new ReferenceTypeRegistry();
86
		}
87
		return instance;
88
	}
89
	
90
	/**
91
	 * Tests whether the reference type (given through its id) owns.
92
	 * @param refTypeId the id of the reference type
93
	 * @return <code>true</code> if the reference type (given through its id) owns or <code>false</code> otherwise.
94
	 */
95
	public boolean owns(String refTypeId) {
96
		ReferenceType type = (ReferenceType)types.get(refTypeId);
97
		if(type != null) {
98
			return type.owns();
99
		}
100
		UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$  //$NON-NLS-2$
101
		return false;
102
	}
103
	
104
	/**
105
	 * Tests whether the reference type (given through its id) is explicit.
106
	 * @param refTypeId the id of the reference type
107
	 * @return <code>true</code> if the reference type (given through its id) is explicit or <code>false</code> otherwise.
108
	 */
109
	public boolean isExplicit(String refTypeId) {
110
		if (refTypeId != null) {
111
			ReferenceType type = (ReferenceType) types.get(refTypeId);
112
			if (type != null) {
113
				return type.isExplicit();
114
			}
115
			UiPlugin.logWarning("Unable to find reference type: " + refTypeId + " default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$
116
		}		
117
		return false;
118
	}
119
	
120
	/**
121
	 * Returns the human readable name of the given reference type. 
122
	 * @param refTypeId the id of the reference type.
123
	 * @return the human readable name of the given reference type. 
124
	 */
125
	public String getName(String refTypeId) {
126
		ReferenceType type = (ReferenceType)types.get(refTypeId);
127
		if(type != null) {
128
			return type.getName();
129
		}
130
		UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$
131
		return "Unknown reference"; //$NON-NLS-1$
132
	}
133
	
134
	/**
135
	 * Returns the opposite reference type id of a given one if it has been defined or <code>null</code> otherwise.
136
	 * @param refTypeId the reference type id 
137
	 * @return the opposite reference type id of a given one if it has been defined or <code>null</code> otherwise.
138
	 */
139
	public String getOppositeReferenceType(String refTypeId) {
140
		ReferenceType type = (ReferenceType)types.get(refTypeId);
141
		if(type != null) {
142
			return type.getOppositeId();
143
		}
144
		UiPlugin.logWarning("Unable to find reference type: "+refTypeId+" default setting is applied."); //$NON-NLS-1$ //$NON-NLS-2$
145
		return "Unknown reference"; //$NON-NLS-1$
146
	}
147
	
148
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerCompositeChange.java (+70 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.ltk.core.refactoring.Change;
18
import org.eclipse.ltk.core.refactoring.CompositeChange;
19
20
/**
21
 * Abstract class for handling move and delete of a container.
22
 * The resulted change has a root change (move or delete of the folder itself) and children
23
 * whose are move or delete of each container member.
24
 * 
25
 * @author jgout
26
 * @version February 26, 2008
27
 * @since 4.3
28
 * 
29
 */
30
public abstract class ReorgContainerCompositeChange extends CompositeChange {
31
	private IContainer container;
32
	private Change rootChange;
33
	
34
	public ReorgContainerCompositeChange(String name, IContainer container) {
35
		super(name);
36
		this.container = container;
37
	}
38
	
39
	public Object getModifiedElement() {
40
		return container;
41
	}
42
	
43
	public abstract Change getRootChange();
44
45
	public Change perform(IProgressMonitor pm) throws CoreException {
46
		//- if one of children is not enabled, we do not perform on root
47
		boolean needToPerform = true;
48
		Change[] children = getChildren();
49
		for (int i = 0; i < children.length; i++) {
50
			needToPerform &= ((Change)children[i]).isEnabled();
51
		}
52
		super.perform(pm);
53
		if(needToPerform) {
54
			if (rootChange == null) {
55
				rootChange = getRootChange();
56
			}
57
			rootChange.perform(pm);
58
		}
59
		//- no undo available.
60
		return null; 
61
	}
62
63
	public String getName() {
64
		if(rootChange == null) {
65
			rootChange = getRootChange();
66
		}
67
		return rootChange.getName();
68
	}
69
70
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/IRefactoringRenamer.java (+23 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
/**
15
 * Interface that allows client to implement rename using refactoring mechanism.
16
 * 
17
 * @author jgout
18
 * @version February 26, 2008
19
 * @since 4.3
20
 */
21
public interface IRefactoringRenamer {
22
23
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoringWizard.java (+122 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.ltk.core.refactoring.Refactoring;
18
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
19
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
20
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.layout.GridLayout;
26
import org.eclipse.swt.widgets.Button;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Control;
29
import org.eclipse.swt.widgets.Label;
30
31
/**
32
 * @author jgout
33
 * @author jbozier
34
 * @version February 26, 2008
35
 */
36
public class DeleteRefactoringWizard extends RefactoringWizard {
37
	private DeleteRefactoringInputPage page;
38
	
39
	private class DeleteRefactoringInputPage extends UserInputWizardPage {
40
		private static final String DEEP_REMOVE_CHECK_STATE= "DeepRemoveCheckState"; //$NON-NLS-1$
41
		private DeleteRefactoring refactoring;
42
		
43
		public DeleteRefactoringInputPage(Refactoring ref) {
44
			super(""); //$NON-NLS-1$
45
			this.refactoring = (DeleteRefactoring) ref;
46
		}
47
48
		public void createControl(Composite parent) {
49
			initializeDialogUnits(parent);
50
			Composite result= new Composite(parent, SWT.NONE);
51
			setControl(result);
52
			result.setLayout(new GridLayout());
53
			addLabel(result);
54
			addDeleteRemoveCheckBox(result);
55
			Dialog.applyDialogFont(result);
56
		}
57
58
		private void addDeleteRemoveCheckBox(Composite parent) {
59
			final Button check = new Button(parent, SWT.CHECK);
60
			boolean deepRemove = getBooleanSetting(DEEP_REMOVE_CHECK_STATE, false);
61
			check.setText(RefactoringMessages.DELETE_DEEP_REMOVE);
62
			check.setSelection(deepRemove);
63
			updateRefactoring(deepRemove);
64
			check.addSelectionListener(new SelectionAdapter() {
65
				public void widgetSelected(SelectionEvent e) {
66
					saveBooleanSetting(DEEP_REMOVE_CHECK_STATE, check);
67
					updateRefactoring(check.getSelection());
68
				}
69
			});
70
		}
71
72
		protected void updateRefactoring(boolean deepRemove) {
73
			DeleteRefactoringWizard.this.setForcePreviewReview(deepRemove);
74
			refactoring.setDeepRemove(deepRemove);			
75
		}
76
77
		private Control addLabel(Composite parent) {
78
			Label label= new Label(parent, SWT.NONE);
79
			String text;
80
			int containers= refactoring.getContainers().size();
81
			int proxies= refactoring.getProxies().size();
82
83
			if (containers == 0 && proxies == 1) {
84
				text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_1, ((IProxyNode)refactoring.getProxies().get(0)).getText());
85
			} else if (containers == 1 && proxies == 0) {
86
				text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_1, ((IResource)refactoring.getContainers().get(0)).getName());
87
			} else {
88
				text= NLS.bind(RefactoringMessages.DELETE_CONFIRM_N, String.valueOf(containers + proxies));
89
			}
90
			label.setText(text);
91
			label = new Label(parent, SWT.NONE); //- spacing the first label
92
			label.setLayoutData(new GridData(SWT.BEGINNING, GridData.FILL, false, true));
93
			return label;
94
		}
95
		
96
		protected boolean getBooleanSetting(String key, boolean defaultValue) {
97
			String value= getRefactoringSettings().get(key);
98
			if (value != null)
99
				return Boolean.valueOf(value).booleanValue();
100
			else
101
				return defaultValue;
102
		}
103
		
104
		protected void saveBooleanSetting(String key, Button checkBox) {
105
			if (checkBox != null)
106
				getRefactoringSettings().put(key, checkBox.getSelection());
107
		}
108
	}
109
	
110
	public DeleteRefactoringWizard(Refactoring refactoring) {
111
		super(refactoring, DIALOG_BASED_USER_INTERFACE | NONE);
112
	}
113
	
114
	protected void addUserInputPages() {
115
		page = new DeleteRefactoringInputPage(getRefactoring());
116
		addPage(page);
117
	}
118
	
119
	public boolean deepRemove() {
120
		return page.getBooleanSetting(DeleteRefactoringInputPage.DEEP_REMOVE_CHECK_STATE, false);
121
	}
122
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/Reference.java (+83 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
17
import org.eclipse.hyades.test.ui.internal.navigator.proxy.Proxy;
18
import org.eclipse.hyades.test.ui.navigator.IProxy;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
21
/**
22
 * @author jgout
23
 * @version February 26, 2008
24
 */
25
public class Reference {
26
	private String type;
27
	private String proxyId;
28
	private IFile proxyFile;
29
	
30
	public Reference(String type, String proxyId, IFile proxyFile) {
31
		if(type == null || proxyId == null || proxyFile == null) {
32
			throw new IllegalArgumentException("Can not create reference with null value"); //$NON-NLS-1$
33
		}
34
		this.type = type;
35
		this.proxyId = proxyId;
36
		this.proxyFile = proxyFile;
37
	}
38
	
39
	public Reference(String type, IProxy proxy) {
40
		IResource ulr = proxy.getUnderlyingResource();
41
		if (ulr instanceof IFile) {
42
			this.proxyFile = (IFile) ulr;
43
		}
44
		this.type = type;
45
		this.proxyId = proxy.getIdentifier();
46
	}
47
48
	/**
49
	 * Returns the referenced proxy node.
50
	 * @return the referenced proxy node or <code>null</code> 
51
	 * if the file that was containing it no longer exists. 
52
	 */
53
	public IProxyNode getReferencedProxy() {
54
		return FileProxyNodeCache.getInstance().getCorrespondingProxy(new Proxy(proxyFile, proxyId));
55
	}
56
57
	public String getType() {
58
		return type;
59
	}
60
	
61
	public IFile getProxyFile() {
62
		return proxyFile;
63
	}
64
	
65
	public String getProxyId() {
66
		return proxyId;
67
	}
68
69
	public boolean equals(Object arg0) {
70
		if(arg0 == this) return true;
71
		if (arg0 instanceof Reference) {
72
			Reference ref = (Reference) arg0;
73
			if (ref != null) {
74
				return ref.type.equals(type) && ref.proxyId.equals(proxyId) && ref.proxyFile.equals(proxyFile);
75
			}
76
		}
77
		return false;
78
	}
79
80
	public int hashCode() {
81
		return proxyFile.hashCode();
82
	}
83
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgContainerChange.java (+96 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFolder;
16
import org.eclipse.core.resources.ResourceAttributes;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.OperationCanceledException;
23
import org.eclipse.core.runtime.SubProgressMonitor;
24
import org.eclipse.ltk.core.refactoring.Change;
25
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
26
27
/**
28
 * Abstract class for handling the change for deletion or move of a container.
29
 * This change has no children. 
30
 * 
31
 * @author jgout
32
 * @version February 26, 2008
33
 * @since 4.3
34
 */
35
public abstract class ReorgContainerChange extends Change {
36
	private IPath path;
37
	
38
	public ReorgContainerChange(IContainer cont) {
39
		path = getPath(cont);
40
	}
41
	
42
	public static IPath getPath(IContainer container){
43
		return container.getFullPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
44
	}
45
	
46
	private IContainer getContainer(IPath path) {
47
		if(path.segmentCount() == 1) {
48
			//- this the path of a project
49
			return ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
50
		} else {
51
			//- this the path of a folder
52
			return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
53
		}
54
	}
55
56
	public IPath getPath() {
57
		return path;
58
	}
59
	
60
	public Object getModifiedElement() {
61
		return getContainer(path);
62
	}
63
64
	public abstract String getName();
65
66
	public void initializeValidationData(IProgressMonitor pm) {
67
	}
68
69
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,	OperationCanceledException {
70
		RefactoringStatus status = new RefactoringStatus();
71
		IFolder folder = (IFolder)getModifiedElement();
72
		if (!folder.exists()) {
73
			status.addError(RefactoringMessages.NO_FOLDER);
74
		}
75
		ResourceAttributes resAtt = folder.getResourceAttributes();
76
		if (resAtt.isReadOnly()) {
77
			status.addWarning(RefactoringMessages.READ_ONLY_FOLDER);
78
		}
79
		return status;
80
	}
81
82
	public Change perform(IProgressMonitor pm) throws CoreException {
83
		IContainer container = getContainer(path);
84
		Assert.isTrue(container.isAccessible());
85
		pm.beginTask("", 1); //$NON-NLS-1$
86
		try {
87
			reorgFolder(container, new SubProgressMonitor(pm, 1));
88
			return null;
89
		} finally {
90
			pm.done();
91
		}
92
	}
93
94
	abstract public void reorgFolder(IContainer container, SubProgressMonitor monitor);
95
96
}
(-)schema/testNavigatorRefactoringTransactions.exsd (+124 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.ui" id="testNavigatorRefactoringTransactions" name="Test Navigator Refactoring Transactions"/>
7
      </appInfo>
8
      <documentation>
9
         Test navigator supports refactoring for actions such as Move or Rename.
10
Those refactoring operations are based upon the references stored in &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode&lt;/code&gt;. That allows to propagate move or rename refactoring operations on several linked elements (e.g. Test logs and the test that produced them).
11
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).
12
This extension point allows clients to define a refactoring transaction which is used in those refactoring operations.
13
      </documentation>
14
   </annotation>
15
16
   <element name="extension">
17
      <complexType>
18
         <sequence minOccurs="1" maxOccurs="unbounded">
19
            <element ref="transaction"/>
20
         </sequence>
21
         <attribute name="point" type="string" use="required">
22
            <annotation>
23
               <documentation>
24
                  
25
               </documentation>
26
            </annotation>
27
         </attribute>
28
         <attribute name="id" type="string">
29
            <annotation>
30
               <documentation>
31
                  
32
               </documentation>
33
            </annotation>
34
         </attribute>
35
         <attribute name="name" type="string">
36
            <annotation>
37
               <documentation>
38
                  
39
               </documentation>
40
               <appInfo>
41
                  <meta.attribute translatable="true"/>
42
               </appInfo>
43
            </annotation>
44
         </attribute>
45
      </complexType>
46
   </element>
47
48
   <element name="transaction">
49
      <complexType>
50
         <attribute name="domainId" type="string" use="required">
51
            <annotation>
52
               <documentation>
53
                  The id of the transaction domain. This id should be used to retrieve the &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction&lt;/code&gt; from &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IRefactoringContext&lt;/code&gt;
54
               </documentation>
55
            </annotation>
56
         </attribute>
57
         <attribute name="class" type="string" use="required">
58
            <annotation>
59
               <documentation>
60
                  Instance of &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction&lt;/code&gt;.
61
               </documentation>
62
               <appInfo>
63
                  <meta.attribute kind="java" basedOn="org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction"/>
64
               </appInfo>
65
            </annotation>
66
         </attribute>
67
      </complexType>
68
   </element>
69
70
   <annotation>
71
      <appInfo>
72
         <meta.section type="since"/>
73
      </appInfo>
74
      <documentation>
75
         4.3
76
      </documentation>
77
   </annotation>
78
79
   <annotation>
80
      <appInfo>
81
         <meta.section type="examples"/>
82
      </appInfo>
83
      <documentation>
84
         &lt;pre&gt;
85
       &lt;extension
86
             point=&quot;org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions&quot;&gt;
87
          &lt;transaction
88
                class=&quot;org.eclipse.hyades.test.ui.internal.navigator.refactoring.EMFRefactoringTransaction&quot;
89
                domainId=&quot;org.eclipse.hyades.test.ui.EMFRefactoringTransaction&quot;/&gt;
90
       &lt;/extension&gt;
91
&lt;/pre&gt;
92
      </documentation>
93
   </annotation>
94
95
   <annotation>
96
      <appInfo>
97
         <meta.section type="apiInfo"/>
98
      </appInfo>
99
      <documentation>
100
         Instances used in the class attribute should implement  &lt;code&gt;org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction&lt;/code&gt;.
101
      </documentation>
102
   </annotation>
103
104
   <annotation>
105
      <appInfo>
106
         <meta.section type="implementation"/>
107
      </appInfo>
108
      <documentation>
109
         
110
      </documentation>
111
   </annotation>
112
113
   <annotation>
114
      <appInfo>
115
         <meta.section type="copyright"/>
116
      </appInfo>
117
      <documentation>
118
         Copyright (c) 2006 IBM Corporation and others.&lt;br&gt;
119
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
120
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
121
      </documentation>
122
   </annotation>
123
124
</schema>
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationUpdateChange.java (+63 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.OperationCanceledException;
17
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.emf.common.util.URI;
20
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
21
import org.eclipse.ltk.core.refactoring.Change;
22
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
23
import org.eclipse.osgi.util.NLS;
24
25
/**
26
 * @author jgout
27
 * @version February 26, 2008
28
 */
29
public class LaunchConfigurationUpdateChange extends Change {
30
31
	private ILaunchConfiguration config;
32
	private URI newURI;
33
	
34
	public LaunchConfigurationUpdateChange(ILaunchConfiguration config, URI newURI) {
35
		super();
36
		this.config = config;
37
		this.newURI = newURI;
38
	}
39
40
	public Object getModifiedElement() {
41
		return this.config;
42
	}
43
44
	public String getName() {
45
		return NLS.bind(RefactoringMessages.LaunchConfigurationUpdateChange_NAME, config.getName());
46
	}
47
48
	public void initializeValidationData(IProgressMonitor pm) {
49
	}
50
51
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
52
		RefactoringStatus status = new RefactoringStatus();
53
		return status;
54
	}
55
56
	public Change perform(IProgressMonitor pm) throws CoreException {
57
		ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
58
		TestLaunchConfigurationFacade.updateTestURI(workingCopy, newURI);
59
		workingCopy.doSave();
60
		return null;
61
	}
62
63
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFileChange.java (+113 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IWorkspaceRoot;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange;
24
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
25
import org.eclipse.ltk.core.refactoring.Change;
26
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
27
import org.eclipse.osgi.util.NLS;
28
29
/**
30
 * change to apply to perform a file paste
31
 * @author jbozier
32
 * @version February 26, 2008
33
 * @since 4.5
34
 */
35
public class PasteFileChange extends Change {
36
37
	private IFile file;	
38
	private IContainer destFolder;
39
	private String destName = null;
40
41
	public PasteFileChange(IFile file, IContainer destination) {
42
		super();
43
		this.file = file;
44
		this.destFolder = destination;
45
		this.destName = getNewName(destFolder.getFullPath().append(file.getName()));
46
	}
47
48
	public Object getModifiedElement() {
49
		return file;
50
	}
51
52
	public String getName() {
53
		return NLS.bind(RefactoringMessages.PASTE_FILE, file.getName(), destName);
54
	}
55
56
	public void initializeValidationData(IProgressMonitor pm) {
57
	}
58
59
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
60
		RefactoringStatus status = new RefactoringStatus();
61
		if (!file.exists()) {
62
			status.addError(RefactoringMessages.NO_FILE);
63
		}
64
		return status;
65
	}
66
67
	private String getNewName(IPath destination) {
68
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
69
		if ( (root.getFolder(destination).exists()) || (root.getFile(destination).exists())) {
70
			String newBaseName = null;
71
			boolean done = false;		
72
			String fullFileName = destination.lastSegment();
73
			int dotIndex = fullFileName.lastIndexOf('.');
74
			String basePart = fullFileName.substring(0, dotIndex);
75
			String endPart = fullFileName.substring(dotIndex);
76
			String newFullName = null;
77
			String ret = null;
78
			for (int i=0; (!done); i++) {
79
				if (i != 0) {
80
					newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),basePart);
81
				} else {
82
					newBaseName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,basePart);					 
83
				}
84
				newFullName = newBaseName+endPart;
85
				ret = destination.removeLastSegments(1).append(newFullName).toPortableString();
86
				IPath newpath = new Path(ret);
87
				done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists());
88
			}
89
			return ret;
90
		} else {
91
			return destination.toPortableString();
92
		}
93
	}
94
		
95
	public Change perform(IProgressMonitor pm) throws CoreException {
96
		Change undo = null;
97
		pm.beginTask("", 1);  //$NON-NLS-1$
98
		try {
99
			IContainer parent = file.getParent();
100
			file.copy(new Path(destName), false, pm);
101
			if (parent != null) {
102
				IFile destFile = destFolder.getFile(new Path(destName));
103
				undo = new DeleteFileChange(destFile);
104
			}
105
			file.refreshLocal(0, pm);
106
			pm.worked(1);
107
			return undo;
108
		} finally {
109
			pm.done();
110
		}
111
	}
112
113
}
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IRefactoringContext.java (+33 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.hyades.test.ui.navigator.IRefactoringTransaction;
15
16
/**
17
 * Global context that contents all domain specific refactoring transactions defined using 
18
 * the extension point <code>org.eclipse.hyades.test.ui.testNavigatorRefactoringTransactions</code>
19
 * This interface is not intented to be implemented by clients.
20
 * 
21
 * @author jgout
22
 * @version February 26, 2008
23
 * @since 4.4
24
 */
25
public interface IRefactoringContext {
26
27
	/**
28
	 * Returns the refactoring transaction given its domain id.
29
	 * @param domainId a domain id.
30
	 * @return the refactoring transaction given its domain id or <code>null</code> if the domain id is unknown.
31
	 */
32
	public IRefactoringTransaction getRefactoringTransaction(String domainId);
33
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/Proxy.java (+51 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006, 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
14
/**
15
 * @author jgout
16
 * @version February 26, 2008
17
 */
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.hyades.test.ui.navigator.AbstractProxy;
22
import org.eclipse.hyades.test.ui.navigator.IProxy;
23
24
public class Proxy extends AbstractProxy implements IProxy {
25
	private IResource res;
26
	private String id;
27
	
28
	public Proxy(IResource res, String id) {
29
		this.res = res;
30
		this.id = id;
31
	}
32
33
	/**
34
	 * Creates a proxy
35
	 * @param resName the workspace relative path of the underlying resource of the proxy
36
	 * @param id identifier of the proxy
37
	 */
38
	public Proxy(String resName, String id) {
39
		this.res = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(resName));
40
		this.id = id;
41
	}
42
43
	public String getIdentifier() {
44
		return id;
45
	}
46
47
	public IResource getUnderlyingResource() {
48
		return res;
49
	}
50
51
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameRefactoring.java (+139 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Iterator;
15
16
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.core.runtime.SubProgressMonitor;
23
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry;
25
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
26
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
27
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer2;
28
import org.eclipse.ltk.core.refactoring.Change;
29
import org.eclipse.ltk.core.refactoring.CompositeChange;
30
31
/**
32
 * @author jgout
33
 * @version February 26, 2008
34
 */
35
public class RenameRefactoring extends ReorgRefactoring {
36
	private IProxyNode proxy;
37
	private IContainer container;
38
	private String name;
39
40
	public RenameRefactoring(IProxyNode node) {
41
		super();
42
		this.proxy = node;
43
	}
44
45
	public RenameRefactoring(IContainer cont) {
46
		super();
47
		this.container = cont;
48
	}
49
50
	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
51
		if (change != null) {
52
			return change;
53
		}
54
		try {
55
			pm.beginTask("", 1);  //$NON-NLS-1$
56
			RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context);
57
			if(container != null) {
58
				Change containerChange = createRenameContainerChange(new SubProgressMonitor(pm, 1));
59
				if (containerChange != null) {
60
					c.add(containerChange);
61
				}
62
			} else if(proxy != null) {
63
				Change proxyChange = createRenameProxyNodeChange();
64
				if (proxyChange != null) {
65
					c.add(proxyChange);
66
				}
67
				pm.worked(1);
68
			}
69
			c.markAsSynthetic();
70
			return c;
71
		} finally {
72
			pm.done();
73
		}
74
	}
75
76
	private Change createRenameProxyNodeChange() {
77
		if (!seenElements.contains(proxy)) {
78
			seenElements.add(proxy);
79
			if (proxy instanceof IReferencerProxyNode) {
80
				return createRenameModelChange();
81
			} else {
82
				createShallowRenameProxyChange();
83
			}
84
		}		
85
		return null;
86
	}
87
	
88
	private Change createShallowRenameProxyChange() {
89
		IProxyNodeRenamer2 renamer = (IProxyNodeRenamer2)proxy.getAdapter(IProxyNodeRenamer2.class);
90
		if (renamer != null) {
91
			return renamer.createRenameChange(context, name);
92
		} else {
93
			IResource res = proxy.getUnderlyingResource();
94
			if (res instanceof IFile) {
95
				return new RenameFileChange((IFile) res, name);
96
			}
97
		}
98
		return null;
99
	}
100
101
	private Change createRenameModelChange() {
102
		CompositeChange composite = new CompositeChange(""); //$NON-NLS-1$
103
		Change renameNode = createShallowRenameProxyChange();
104
		if(renameNode != null) {
105
			composite.add(renameNode);
106
		}
107
		CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(proxy);
108
		for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) {
109
			String type = (String)it.next();
110
			String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type);
111
			if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) {
112
				composite.add(createUpdateReferenceTypeChange(ref, type));
113
			}
114
		}
115
		composite.markAsSynthetic();
116
		return composite;
117
	}
118
119
	private Change createUpdateReferenceTypeChange(CompositeReferencerProxyNode ref, String type) {
120
		CompositeChange change = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type));
121
		for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) {
122
			change.add(new UpdateModelChange((IProxyNode)it.next(), context));
123
		}
124
		return change;
125
	}
126
	
127
	private Change createRenameContainerChange(IProgressMonitor pm) {
128
		RenameContainerChange change = new RenameContainerChange(container, name);
129
		performContainerChildren(change, container, container.getFullPath().removeLastSegments(1).append(name));
130
		change.freeze();
131
		return change;
132
	}
133
134
	public void setNewName(String text) {
135
		name = text;
136
		change = null;
137
		seenElements.clear();
138
	}
139
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/IReferenceRegistrySavedState.java (+36 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import org.eclipse.core.runtime.IPath;
15
16
/**
17
 * Generic interface that provides the common feature of Eclipse ISavedState
18
 * and ISaveContext methods. It provides a lookup feature for retrieving the
19
 * real file associated to a symbolic file in a given save state.
20
 * @author jcanches
21
 * @version February 26, 2008
22
 * @see org.eclipse.core.resources.ISavedState
23
 * @see org.eclipse.core.resources.ISaveContext
24
 * @since 4.3
25
 */
26
public interface IReferenceRegistrySavedState {
27
28
29
	/**
30
	 * @see org.eclipse.core.resources.ISavedState#lookup(org.eclipse.core.runtime.IPath)
31
	 * @see org.eclipse.core.resources.ISaveContext#lookup(org.eclipse.core.runtime.IPath)
32
	 */
33
	public IPath lookup(IPath path);
34
		
35
36
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/PasteFolderChange.java (+97 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFolder;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IWorkspaceRoot;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.SubProgressMonitor;
24
import org.eclipse.hyades.test.ui.UiPlugin;
25
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorMessages;
26
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
27
import org.eclipse.osgi.util.NLS;
28
29
/**
30
 * change to apply to perform a folder paste
31
 * @author jbozier
32
 * @version February 26, 2008
33
 * @since 4.5
34
 */
35
36
public class PasteFolderChange extends ReorgContainerChange {
37
	private IPath destPath;
38
	private IPath targetPath;
39
	private RefactoringStatus status;
40
41
	public PasteFolderChange(IFolder folder, IPath destPath,IPath [] finalPath) {
42
		super(folder);
43
		this.destPath = destPath;
44
		this.status = new RefactoringStatus();
45
		this.targetPath = handleFolderAlreadyExists(folder,destPath);
46
		if ((finalPath != null) && (finalPath.length > 0)) {
47
			finalPath[0] = targetPath;
48
		}
49
	}
50
51
	// update target path in case of conflict
52
	private IPath handleFolderAlreadyExists(IFolder folder, IPath destPath) {
53
		IPath path = destPath.append(folder.getName());
54
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
55
		if ((root.getFolder(path).exists()) || (root.getFile(path).exists())) {
56
			boolean done = false;		
57
			String folderName = path.lastSegment();
58
			String ret = null;
59
			String newName = null;
60
			for (int i=0; (!done); i++) {
61
				 if (i != 0) {
62
					 newName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameTwoArg,new Integer(i),folderName);
63
				 } else {
64
					 newName = NLS.bind(TestNavigatorMessages.FileFolderInContainerPaste_NameOneArg,folderName);					 
65
				 }
66
				 ret = path.removeLastSegments(1).append(newName).toPortableString();
67
				 IPath newpath = new Path(ret);
68
				 done = (!root.getFolder(newpath).exists()) && (!root.getFile(newpath).exists());
69
			}
70
			path = destPath.append(newName);
71
		} 
72
		return path;
73
	}
74
	
75
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
76
		return this.status;
77
	}
78
	
79
	public IPath getDestinationPath() {
80
		return destPath;
81
	}
82
	
83
	public String getName() {
84
		IPath path = getPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
85
		return NLS.bind(RefactoringMessages.PASTE_FOLDER, path.toOSString(), targetPath.toOSString());
86
	}
87
88
	public void reorgFolder(IContainer container, SubProgressMonitor monitor) {
89
		try {
90
			container.copy(targetPath, 0, monitor);
91
			container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
92
		} catch (CoreException e) {
93
			UiPlugin.logError("Unable to copy container", e); //$NON-NLS-1$
94
		}
95
	}
96
97
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/messages.properties (+7 lines)
Added Link Here
1
DELETE_ACTION_NAME=Delete
2
MOVE_ACTION_NAME=Move
3
PASTE_ACTION_NAME=Paste
4
RENAME_ACTION_NAME=Rename
5
RENAME_NEW_NAME_LABEL=New Name:
6
SAVE_ALL_DIALOG_NAME=Save All Modified Resources
7
SAVE_ALL_DIALOG_MESSAGE=All modified resources must be saved before this operation.
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/ReorgRefactoring.java (+152 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Iterator;
15
import java.util.LinkedList;
16
import java.util.List;
17
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.OperationCanceledException;
26
import org.eclipse.core.runtime.SubProgressMonitor;
27
import org.eclipse.hyades.test.ui.UiPlugin;
28
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
29
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode;
30
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry;
31
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
32
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
33
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater;
34
import org.eclipse.ltk.core.refactoring.Change;
35
import org.eclipse.ltk.core.refactoring.CompositeChange;
36
import org.eclipse.ltk.core.refactoring.Refactoring;
37
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
38
import org.eclipse.osgi.util.NLS;
39
40
/**
41
 * Common refactoring between move and rename.
42
 * @author jgout
43
 * @author jbozier
44
 * @version February 26, 2008
45
 * @since 4.3
46
 */
47
public abstract class ReorgRefactoring extends Refactoring {
48
	protected Change change;
49
	protected List seenElements;
50
	protected RefactoringContext context;
51
	
52
	public ReorgRefactoring() {
53
		this.seenElements = new LinkedList();
54
		this.context = new RefactoringContext();
55
	}
56
57
	public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
58
		pm.beginTask("", 3); //$NON-NLS-1$
59
		try {
60
			ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot());
61
			try {
62
				scanner.scan(new SubProgressMonitor(pm, 1));
63
			} catch (OperationCanceledException e) {
64
				return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG);
65
			}			
66
			change = createChange(new SubProgressMonitor(pm, 1));
67
			pm.worked(1);
68
			return change.isValid(new SubProgressMonitor(pm, 1));
69
		} finally {
70
			pm.done();
71
		}
72
	}
73
74
	public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
75
		pm.beginTask("", 1); //$NON-NLS-1$
76
		try {
77
			pm.worked(1);
78
			return new RefactoringStatus();
79
		} finally {
80
			pm.done();
81
		}
82
	}
83
84
	public String getName() {
85
		return "";  //$NON-NLS-1$
86
	}
87
88
	protected Change performContainerChildren(CompositeChange change, IContainer source, IPath newPath) {
89
		if(source.isAccessible()) {
90
			IResource[] resources;
91
			try {
92
				resources = source.members();
93
			} catch (CoreException e) {
94
				UiPlugin.logError("Unable to get members of container: "+source.getFullPath().toOSString(), e); //$NON-NLS-1$
95
				return null;
96
			}
97
			for (int i = 0; i < resources.length; i++) {
98
				if (resources[i] instanceof IFile) {
99
					IFile file = (IFile)resources[i];
100
					IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file);
101
					if (proxy != null) {
102
						if(!seenElements.contains(proxy)) {
103
							seenElements.add(proxy);
104
							//- is this proxy adaptable to updater ?
105
							Change updateChange = null;
106
							IProxyNodeUpdater updater = (IProxyNodeUpdater)proxy.getAdapter(IProxyNodeUpdater.class);
107
							if(updater != null) {
108
								updateChange = updater.createUpdateChange(context, source, newPath.append(file.getName()));
109
							}
110
							CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.CHANGES_FOR_UPDATING, proxy.getText()));
111
							if(updateChange != null) {
112
								composite.add(updateChange);
113
							}
114
							//- process all references
115
							if (proxy instanceof IReferencerProxyNode) {
116
								CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(proxy);
117
								for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) {
118
									createRenameReferencerTypeChildren(composite, ref, (String)it.next());
119
								}
120
							}
121
							change.add(composite);
122
						}
123
					}
124
				} else {
125
					performContainerChildren(change, (IContainer)resources[i], newPath.append(resources[i].getName()));
126
				}
127
			}
128
		}
129
		return change;
130
	}
131
132
	private void createRenameReferencerTypeChildren(CompositeChange change, CompositeReferencerProxyNode ref, String type) {
133
		String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type);
134
		if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) {
135
			CompositeChange c = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type));
136
			for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) {
137
				IProxyNodeUpdater updater = (IProxyNodeUpdater) ((IProxyNode)it.next()).getAdapter(IProxyNodeUpdater.class);
138
				if (updater != null) {
139
					IPath destPath = ref.getUnderlyingResource().getFullPath();
140
					Change updateChange = updater.createUpdateChange(context, ref, type, destPath);
141
					if (updateChange != null) {
142
						c.add(updateChange);
143
					}						
144
				}
145
			}
146
			if(c.getChildren().length > 0) {
147
				change.add(c);
148
			}
149
		}
150
	}
151
152
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/RenameFileChange.java (+80 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IContainer;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.OperationCanceledException;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.ltk.core.refactoring.Change;
21
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
22
import org.eclipse.osgi.util.NLS;
23
24
/**
25
 * @author jgout
26
 * @version February 26, 2008
27
 */
28
public class RenameFileChange extends Change {
29
	private IFile file;
30
	private String name;
31
32
	public RenameFileChange(IFile file, String name) {
33
		this.file = file;
34
		this.name = name;
35
	}
36
37
	public Object getModifiedElement() {
38
		return file;
39
	}
40
41
	public String getName() {
42
		String newPathName = file.getParent().getFullPath().append(new Path(name)).toOSString();
43
		return NLS.bind(RefactoringMessages.RENAME_FILE, file.getName(), newPathName);
44
	}
45
46
	public void initializeValidationData(IProgressMonitor pm) {
47
	}
48
49
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,	OperationCanceledException {
50
		RefactoringStatus status = new RefactoringStatus();
51
		IFile destFile = file.getParent().getFile(new Path(name));
52
		if (!file.exists()) {
53
			status.addError(RefactoringMessages.NO_FILE);
54
		}
55
		if (file.isReadOnly()) {
56
			status.addWarning(RefactoringMessages.READ_ONLY_FILE);
57
		}
58
		if(destFile.exists()) {
59
			status.addWarning(NLS.bind(RefactoringMessages.ALREADY_EXISTS_FILE, destFile.getFullPath().toPortableString()));
60
		}
61
		return status;
62
	}
63
64
	public Change perform(IProgressMonitor pm) throws CoreException {
65
		Change undo = null;
66
		try {
67
			pm.beginTask("", 1);  //$NON-NLS-1$
68
			IContainer parent = file.getParent();
69
			if (parent != null) {
70
				undo = new RenameFileChange(file, file.getName());
71
			}
72
			file.move(parent.getFullPath().append(new Path(name)), false, true, pm);
73
			pm.worked(1);
74
			return undo;
75
		} finally {
76
			pm.done();
77
		}
78
	}
79
80
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/reference/ProjectReferenceRegistry.java (+333 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy.reference;
13
14
import java.io.BufferedInputStream;
15
import java.io.BufferedOutputStream;
16
import java.io.File;
17
import java.io.FileInputStream;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
20
import java.io.InputStream;
21
import java.io.InputStreamReader;
22
import java.io.OutputStreamWriter;
23
import java.util.Collection;
24
import java.util.Collections;
25
import java.util.HashMap;
26
import java.util.HashSet;
27
import java.util.Iterator;
28
import java.util.LinkedList;
29
import java.util.List;
30
import java.util.Map;
31
import java.util.Set;
32
import java.util.zip.GZIPInputStream;
33
import java.util.zip.GZIPOutputStream;
34
35
import org.eclipse.core.resources.IFile;
36
import org.eclipse.core.resources.IProject;
37
import org.eclipse.core.resources.ISaveContext;
38
import org.eclipse.core.resources.ISaveParticipant;
39
import org.eclipse.core.resources.ResourcesPlugin;
40
import org.eclipse.core.runtime.Assert;
41
import org.eclipse.core.runtime.CoreException;
42
import org.eclipse.core.runtime.IPath;
43
import org.eclipse.core.runtime.Path;
44
import org.eclipse.hyades.test.ui.TestUIConstants;
45
import org.eclipse.hyades.test.ui.UiPlugin;
46
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
47
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
48
import org.eclipse.ui.IMemento;
49
import org.eclipse.ui.WorkbenchException;
50
import org.eclipse.ui.XMLMemento;
51
52
/**
53
 * This class is used to store proxy references for a given project.
54
 * Its persistency is made using a save participant.
55
 * 
56
 * @author jgout
57
 * @version February 26, 2008
58
 * @since 4.3
59
 */
60
public class ProjectReferenceRegistry implements ISaveParticipant {
61
	
62
	public static final String TAG_REFERENCE = "reference"; //$NON-NLS-1$
63
	public static final String TAG_REFERENCER = "referencer"; //$NON-NLS-1$
64
	public static final String TAG_REF_TYPE = "refType"; //$NON-NLS-1$
65
	
66
	//- (proxy, Set(Reference))
67
	private Map references;
68
	private boolean hasChanged;
69
	private IProject project;
70
	
71
	class Reference {
72
		private String type;
73
		private IFile referenced;
74
75
		public Reference(String typeRef, IFile referenced) {
76
			this.type = typeRef;
77
			this.referenced = referenced;
78
		}
79
80
		public IFile getReferenced() {
81
			return referenced;
82
		}
83
84
		public String getType() {
85
			return type;
86
		}
87
		
88
		public boolean equals(Object arg0) {
89
			if(arg0 == this) return true;
90
			if (arg0 instanceof Reference) {
91
				Reference ref = (Reference) arg0;
92
				if (ref != null) {
93
					if(type != null && referenced != null) {
94
						return type.equals(ref.type) && referenced.equals(ref.referenced);
95
					} else if((type == null && ref.type == null) || (referenced == null && ref.referenced == null)) {
96
						return true;
97
					}
98
				}
99
			}
100
			return false;
101
		}
102
103
		public int hashCode() {
104
			return referenced != null ? referenced.hashCode() : -1;
105
		}
106
	}
107
	
108
	public ProjectReferenceRegistry(IProject project, IReferenceRegistrySavedState savedState) {
109
		this.references = new HashMap();
110
		this.hasChanged = false;
111
		this.project = project;
112
		if (savedState != null) {
113
			IPath refsFilePath = savedState.lookup(getSavedStateFileKey());
114
			if (refsFilePath != null) {
115
				File dependenciesFile = UiPlugin.getDefault().getStateLocation().append(refsFilePath).toFile();
116
				try {
117
					load(new GZIPInputStream(new BufferedInputStream(new FileInputStream(dependenciesFile))));
118
				} catch (Throwable t) {
119
					//- Oops, let's forget anything and start with a clean registry
120
					clear();
121
					UiPlugin.logWarning("Unable to load proxy node references file for project " + this.project.getName(), t); //$NON-NLS-1$
122
				}
123
			}
124
		}
125
	}
126
127
	private void addReference(IFile referencer, Reference ref) {
128
		Assert.isNotNull(ref);
129
		Collection refs = (Collection) references.get(referencer);
130
		if(refs == null) {
131
			//- this proxy has not yet references
132
			refs = new HashSet();
133
			references.put(referencer, refs);
134
		}
135
		refs.add(ref);
136
		hasChanged = true;
137
	}
138
	
139
	public void addReference(IFile referencer, String refType, IFile referenced) {
140
		addReference(referencer, new Reference(refType, referenced));
141
	}
142
	
143
	public void addBidirectionalReference(IFile referencer, String refType, IFile referenced, String oppositeRefType) {
144
		addReference(referencer, refType, referenced);
145
		addReference(referenced, oppositeRefType, referencer);
146
	}
147
148
	public void removeReference(IFile referencer, IFile referenced) {
149
		Assert.isNotNull(referenced);
150
		Collection refs = (Collection) references.get(referencer);
151
		if(refs != null) {
152
			for (Iterator it = refs.iterator(); it.hasNext();) {
153
				Reference ref = (Reference) it.next();
154
				if(referenced.equals(ref.getReferenced())) {
155
					it.remove();
156
					hasChanged = true;
157
				}
158
			}
159
		}
160
	}
161
162
	public void removeReferences(IFile referencer) {
163
		references.remove(referencer);
164
	}
165
	
166
	/**
167
	 * Returns the list of referenced proxy node associated to the given referencer.
168
	 * Only references matching with the given type are considered
169
	 * @param referencer
170
	 * @param refType
171
	 * @return
172
	 */
173
	public Collection getReferences(IFile referencer, String refType) {
174
		Assert.isNotNull(refType,"type should be not null"); //$NON-NLS-1$
175
		Collection refs = (Collection) references.get(referencer);
176
		if(refs != null) {
177
			List res = new LinkedList();
178
			for (Iterator it = refs.iterator(); it.hasNext();) {
179
				Reference ref = (Reference) it.next();
180
				if(refType.equals(ref.getType())) {
181
					IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(ref.getReferenced());
182
					if(proxy == null) {
183
						it.remove();
184
					} else {
185
						res.add(proxy);
186
					}
187
				}
188
			}
189
			return res;
190
		} else {
191
			return Collections.EMPTY_LIST;
192
		}
193
	}
194
	
195
	/**
196
	 * Returns all references of type {@link Reference} registered for the given referencer.
197
	 * This method is used to persistence.
198
	 * @param referencer
199
	 * @return all references of type {@link Reference} registered for the given referencer.
200
	 */
201
	private Collection getAllReferences(IFile referencer) {
202
		Collection list = (Collection) references.get(referencer);
203
		return list != null ? list : Collections.EMPTY_LIST;
204
	}
205
	
206
	public Set getReferenceTypes(IFile referencer) {
207
		Set res = new HashSet();
208
		Collection refs = (Collection) references.get(referencer);
209
		if(refs != null) {
210
			for (Iterator it = refs.iterator(); it.hasNext();) {
211
				Reference ref = (Reference) it.next();
212
				res.add(ref.getType());
213
			}
214
		}
215
		return res;
216
	}
217
	
218
	/**
219
	 * Clears the registry
220
	 */
221
	public void clear() {
222
		references.clear();
223
		hasChanged = false;
224
	}
225
226
	/**
227
	 * Returns the File to use for saving and restoring the last built state for the given project.
228
	 */
229
	private File getPersistenceFile(int saveNumber) {
230
		if (!project.exists()) return null;
231
		String depsFileName = project.getName() + ".references-" + Integer.toString(saveNumber); //$NON-NLS-1$
232
		return UiPlugin.getDefault().getStateLocation().append(depsFileName).toFile();
233
	}
234
	
235
	private IPath getSavedStateFileKey() {
236
		return new Path("references").append(project.getName()); //$NON-NLS-1$
237
	}
238
239
	public void doneSaving(ISaveContext context) {
240
		if(hasChanged) {
241
			hasChanged = false;
242
			//- cleanup previous saved file
243
			File depsFile = getPersistenceFile(context.getPreviousSaveNumber());
244
			if (depsFile.exists()) {
245
				depsFile.delete();
246
			}
247
		}
248
	}
249
250
	public void prepareToSave(ISaveContext context) throws CoreException {
251
		//- nop
252
	}
253
254
	public void rollback(ISaveContext context) {
255
		//- Remove the file we generated
256
		File file = getPersistenceFile(context.getSaveNumber());
257
		if (file.exists()) {
258
			file.delete();
259
		}
260
	}
261
262
	public void saving(ISaveContext context) throws CoreException {
263
		//- if context.getKind() == ISaveContext.PROJECT_SAVE then only 
264
		//- the instance of this class that has this.project == context.getProject is called
265
		if(hasChanged && project.exists()) {
266
			int saveNumber = context.getSaveNumber();
267
			File depsFile = getPersistenceFile(saveNumber);
268
			try {
269
				save(depsFile);
270
				context.map(getSavedStateFileKey(), new Path(depsFile.getName()));
271
				context.needSaveNumber();
272
			} catch (IOException e) {
273
				UiPlugin.logError("Unexpected exception during references saving operation.", e); //$NON-NLS-1$
274
			}			
275
		}
276
	}
277
278
	private void load(InputStream stream) throws WorkbenchException, IOException {
279
		InputStreamReader reader = new InputStreamReader(stream);
280
		IMemento memento = XMLMemento.createReadRoot(reader);
281
		reader.close();
282
		IMemento [] referencers = memento.getChildren(TAG_REFERENCER);
283
		for (int i = 0; i < referencers.length; i++) {
284
			String underlyingResName = referencers[i].getString(TestUIConstants.TAG_UNDERLYING_RESOURCE);
285
			IFile refFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(underlyingResName));
286
			if(refFile != null) {
287
				loadProxyReferences(refFile, referencers[i]);
288
			}
289
		}
290
	}
291
292
	private void loadProxyReferences(IFile file, IMemento memento) {
293
		//- retrieving references
294
		IMemento [] refStates = memento.getChildren(TAG_REFERENCE);
295
		IFile refFile;
296
		for (int j = 0; j < refStates.length; j++) {
297
			IMemento refMemento = refStates[j];
298
			String underlyingResName = refMemento.getString(TestUIConstants.TAG_UNDERLYING_RESOURCE);
299
			String refType = refMemento.getString(TAG_REF_TYPE);
300
			refFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(underlyingResName));
301
			if(refFile.exists()) {
302
				addReference(file, new Reference(refType, refFile));
303
			} else {
304
				//- be sure that next save will purge this dead entry
305
				hasChanged = true;
306
			}
307
		} 
308
	}
309
310
	private void save(File depsFile) throws IOException {
311
		OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(depsFile))));
312
		IMemento memento = XMLMemento.createWriteRoot("references"); //$NON-NLS-1$
313
		for (Iterator it = references.keySet().iterator(); it.hasNext();) {
314
			saveProxyReferences((IFile) it.next(), memento);
315
		}
316
		((XMLMemento) memento).save(writer);
317
		writer.close();
318
	}
319
320
	private void saveProxyReferences(IFile file, IMemento memento) {
321
		//- save the referencer proxy itself
322
		IMemento referencerMemento = memento.createChild(TAG_REFERENCER);
323
		referencerMemento.putString(TestUIConstants.TAG_UNDERLYING_RESOURCE, file.getFullPath().toPortableString());
324
		//- save references as well
325
		for (Iterator it = getAllReferences(file).iterator(); it.hasNext();) {
326
			Reference ref = (Reference) it.next();
327
			IMemento referenceMemento = referencerMemento.createChild(TAG_REFERENCE);
328
			referenceMemento.putString(TAG_REF_TYPE, ref.getType());
329
			referenceMemento.putString(TestUIConstants.TAG_UNDERLYING_RESOURCE, ref.getReferenced().getFullPath().toPortableString());
330
		}
331
332
	}
333
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/messages.properties (+59 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2006-2008 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials 
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
# $Id$
8
# 
9
# Contributors:
10
#     IBM Corporation - initial API and implementation
11
###############################################################################
12
13
# NLS_MESSAGEFORMAT_VAR
14
# NLS_ENCODING=UTF-8
15
16
DELETE_FOLDER = Delete folder ''{0}''
17
MOVE_FOLDER = Move folder ''{0}'' into ''{1}''
18
PASTE_FOLDER = Paste folder ''{0}'' into ''{1}''
19
MOVE_FILE = Move file ''{0}'' into ''{1}''
20
PASTE_FILE = Paste file ''{0}'' into ''{1}''
21
DELETE_PROXY = Delete ''{0}''
22
DELETE_INVOCATION = Remove invocation of ''{0}'' from ''{1}''
23
DELETE_CONFIRM_1 = Are you sure you want to delete ''{0}'' from the file system?
24
DELETE_CONFIRM_N = Are you sure you want to delete {0} selected elements from the file system?
25
DELETE_DEEP_REMOVE = Delete owned referenced assets as well (forces preview)
26
MOVE_PROXY = Move ''{0}'' into ''{1}''
27
PASTE_PROXY = Copy ''{0}'' into ''{1}''
28
NO_FOLDER=Folder does not exist
29
NO_PROJECT=Project does not exist or not open.
30
READ_ONLY_FOLDER=Folder is read-only
31
READ_ONLY_PROJECT=Project is read-only
32
ALREADY_EXISTS_FOLDER=Folder ''{0}'' already exists.
33
ALREADY_EXISTS_PROJECT=Project ''{0}'' already exists.
34
MOVE_CHOOSE_DESTINATION_SINGLE=&Choose destination for ''{0}'':
35
MOVE_CHOOSE_DESTINATION_MULTI=&Choose destination for ''{0}'' selected elements:
36
PASTE_CHOOSE_DESTINATION_SINGLE=&Choose destination for ''{0}'':
37
PASTE_CHOOSE_DESTINATION_MULTI=&Choose destination for ''{0}'' selected elements:
38
MOVE_ERROR=The selected element cannot be the destination of this operation.
39
PASTE_ERROR=The selected element cannot be the destination of this operation.
40
UPDATE_PROXY=Update ''{0}''
41
CHANGES_FOR_UPDATING=Changes for updating ''{0}''
42
UPDATE_PROXY_PATH_CHANGED=Update references in ''{0}''
43
UPDATE_REFERENCES=Update references in ''{0}''
44
UPDATE_OWNED_RESSOURCES_REFERENCES=Update references for owned resources
45
NO_FILE=File does not exist
46
READ_ONLY_FILE=File is read-only
47
ALREADY_EXISTS_FILE= File ''{0}'' already exists, it will overwritten.
48
ALREADY_EXISTS_PROXY_DURING_MOVE = File ''{0}'' will be renamed because a file with the same name exists in the destination folder.
49
ALREADY_EXISTS_PROXY_DURING_PASTE = File ''{0}'' will be renamed because a file with the same name exists in the destination folder.
50
ALREADY_EXISTS_PROXY_DURING_RENAME = File ''{0}'' already exists.
51
INNER_FOLDER_MOVE_ERROR=Unable to move a folder into one of its descendents.
52
INNER_FOLDER_PASTE_ERROR=Unable to copy a folder into one of its descendents.
53
RENAME_FILE= Rename File ''{0}'' in ''{1}''
54
RENAME_PROXY=Rename ''{0}'' in ''{1}'' 
55
RENAME_CONTAINER=Rename ''{0}'' in ''{1}'' 
56
ProxyNodeScanner_PM_LABEL=Searching for references...
57
ReorgRefactoring_CANCELED_OPERATION_MSG=Operation canceled by user
58
LaunchConfigurationUpdateChange_NAME=Update Launch Configuration ''{0}''
59
LaunchConfigurationDeleteChange_NAME=Delete Launch Configuration ''{0}''
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/IProxyNodeAdapterFactory.java (+40 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.IAdapterFactory;
16
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.DefaultProxyNodeDeleter;
17
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter;
19
20
/**
21
 * @author jgout
22
 * @version February 26, 2008
23
 */
24
public class IProxyNodeAdapterFactory implements IAdapterFactory {
25
26
	public Object getAdapter(Object adaptableObject, Class adapterType) {
27
		if (adaptableObject instanceof IProxyNode && IProxyNodeDeleter.class.equals(adapterType)) {
28
			IProxyNode proxy = (IProxyNode) adaptableObject;
29
			if(proxy.getAdapter(IFile.class) != null) {
30
				return new DefaultProxyNodeDeleter(proxy);
31
			}
32
		}
33
		return null;
34
	}
35
36
	public Class[] getAdapterList() {
37
		return new Class[] { IProxyNodeDeleter.class };
38
	}
39
40
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/LaunchConfigurationDeleteChange.java (+56 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.OperationCanceledException;
17
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.ltk.core.refactoring.Change;
19
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
20
import org.eclipse.osgi.util.NLS;
21
22
/**
23
 * @author jgout
24
 * @version February 26, 2008
25
 */
26
public class LaunchConfigurationDeleteChange extends Change {
27
28
	private ILaunchConfiguration config;
29
	
30
	public LaunchConfigurationDeleteChange(ILaunchConfiguration config) {
31
		super();
32
		this.config = config;
33
	}
34
35
	public Object getModifiedElement() {
36
		return this.config;
37
	}
38
39
	public String getName() {
40
		return NLS.bind(RefactoringMessages.LaunchConfigurationDeleteChange_NAME, config.getName());
41
	}
42
43
	public void initializeValidationData(IProgressMonitor pm) {
44
	}
45
46
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
47
		RefactoringStatus status = new RefactoringStatus();
48
		return status;
49
	}
50
51
	public Change perform(IProgressMonitor pm) throws CoreException {
52
		config.delete();
53
		return null;
54
	}
55
56
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveRefactoring.java (+157 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.core.resources.IContainer;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFolder;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.OperationCanceledException;
25
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode;
26
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry;
27
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
28
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
29
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover;
30
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater;
31
import org.eclipse.ltk.core.refactoring.Change;
32
import org.eclipse.ltk.core.refactoring.CompositeChange;
33
import org.eclipse.osgi.util.NLS;
34
35
/**
36
 * @author jgout
37
 * @version February 26, 2008
38
 */
39
public class MoveRefactoring extends ReorgRefactoring {
40
	private List folders; 
41
	private List proxies; 
42
	private IContainer destination;
43
	
44
	public MoveRefactoring(List folders, List proxies) {
45
		super();
46
		this.folders = folders;
47
		this.proxies = proxies;
48
	}
49
50
	public List getContainers() {
51
		return folders;
52
	}
53
54
	public List getProxies() {
55
		return proxies;
56
	}
57
	
58
	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
59
		if (change != null) {
60
			return change;
61
		}
62
		pm.beginTask("", folders.size() + proxies.size()); //$NON-NLS-1$
63
		try {
64
			RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context);
65
			for (Iterator it = folders.iterator(); it.hasNext();) {
66
				Change containerChange = createMoveContainerChange((IFolder) it.next(), destination);
67
				if (containerChange != null) {
68
					c.add(containerChange);
69
				}
70
				pm.worked(1);
71
			}
72
			for (Iterator it = proxies.iterator(); it.hasNext();) {
73
				Change refChange = createMoveProxyChange((IProxyNode) it.next(), destination);
74
				if (refChange != null) {
75
					c.add(refChange);
76
				}
77
				pm.worked(1);
78
			}
79
			c.markAsSynthetic();
80
			return c;
81
		} finally {
82
			pm.done();
83
		}
84
	}
85
86
	public String getName() {
87
		return "";  //$NON-NLS-1$
88
	}
89
	
90
	public void setDestination(IContainer container) {
91
		this.destination = container;
92
		change = null;
93
		seenElements.clear();
94
	}
95
96
	protected Change createMoveProxyChange(IProxyNode node, IContainer dest) {
97
		if (!seenElements.contains(node)) {
98
			seenElements.add(node);
99
			if (node instanceof IReferencerProxyNode) {
100
				return createMoveReferencerChange(node, dest);
101
			} else {
102
				return createShallowMoveProxyChange(node, dest);
103
			}
104
		}		
105
		return null;
106
	}
107
108
	private Change createShallowMoveProxyChange(IProxyNode node, IContainer dest) {
109
		IResource res = node.getUnderlyingResource();
110
		IProxyNodeMover mover = (IProxyNodeMover)node.getAdapter(IProxyNodeMover.class);
111
		if (mover != null) {
112
			return mover.createMoveChange(context, dest.getFullPath().append(res.getName()));
113
		} else {
114
			if (res instanceof IFile) {
115
				return new MoveFileChange((IFile) res, dest);
116
			}
117
		}
118
		return null;
119
	}
120
121
	private Change createMoveReferencerChange(final IProxyNode node, final IContainer dest) {
122
		CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.MOVE_PROXY, node.getText(), dest.getName()));
123
		Change moveNode = createShallowMoveProxyChange(node, dest);
124
		CompositeReferencerProxyNode ref = new CompositeReferencerProxyNode(node);
125
		for (Iterator it = ref.getReferenceTypes().iterator(); it.hasNext();) {
126
			String type = (String)it.next();
127
			String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(type);
128
			if(ReferenceTypeRegistry.getInstance().isExplicit(oppType)) {
129
				composite.add(createUpdateReferenceTypeChange(ref, type, dest));
130
			}
131
		}
132
		if(moveNode != null) {
133
			composite.add(moveNode);
134
		}
135
		return composite;
136
	}
137
138
	private Change createUpdateReferenceTypeChange(CompositeReferencerProxyNode ref, String type, IContainer dest) {
139
		CompositeChange change = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(type));
140
		for (Iterator it = ref.getReferences(type).iterator(); it.hasNext();) {
141
			IProxyNode proxy = (IProxyNode)it.next();
142
			IProxyNodeUpdater updater = (IProxyNodeUpdater) proxy.getAdapter(IProxyNodeUpdater.class);
143
			if (updater != null) {
144
				IPath destPath = dest.getFullPath().append(ref.getUnderlyingResource().getName());
145
				change.add(updater.createUpdateChange(context, ref, type, destPath));
146
			}
147
		}
148
		return change;
149
	}
150
151
	private Change createMoveContainerChange(IFolder folder, IContainer dest) {
152
		MoveFolderCompositeChange change = new MoveFolderCompositeChange(folder, dest.getFullPath());
153
		performContainerChildren(change, (IContainer)folder, dest.getFullPath().append(folder.getName()));
154
		change.freeze();
155
		return change;
156
	}
157
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/MoveFolderCompositeChange.java (+76 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import org.eclipse.core.resources.IFolder;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.SubProgressMonitor;
19
import org.eclipse.ltk.core.refactoring.Change;
20
import org.eclipse.ltk.core.refactoring.CompositeChange;
21
import org.eclipse.ltk.core.refactoring.NullChange;
22
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
23
24
/**
25
 * @author jgout
26
 * @version February 26, 2008
27
 */
28
public class MoveFolderCompositeChange extends CompositeChange {
29
	private IFolder folder;
30
	private MoveFolderChange root;
31
32
	public MoveFolderCompositeChange(IFolder folder, IPath newPath) {
33
		super(""); //$NON-NLS-1$
34
		this.folder = folder;
35
		this.root = new MoveFolderChange(folder, newPath);
36
	}
37
38
	public Object getModifiedElement() {
39
		return folder;
40
	}
41
42
	public String getName() {
43
		return root.getName();
44
	}
45
46
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
47
		RefactoringStatus status = root.isValid(pm);
48
		if(folder.getFullPath().isPrefixOf(root.getDestinationPath())) {
49
			status.addFatalError(RefactoringMessages.INNER_FOLDER_MOVE_ERROR);
50
		}
51
		status.merge(super.isValid(pm));
52
		return status;
53
	}
54
55
	public Change perform(IProgressMonitor pm) throws CoreException {
56
		pm.beginTask("", getChildren().length+1);  //$NON-NLS-1$
57
		try {
58
			//- children are update changes
59
			super.perform(new SubProgressMonitor(pm, getChildren().length));
60
			//- move the folder and all its content
61
			root.perform(new SubProgressMonitor(pm, 1));
62
			return null;
63
		} finally {
64
			pm.done();
65
		}
66
	}
67
	
68
	public void freeze() {
69
		if(getChildren().length == 0) {
70
			markAsSynthetic();
71
			//- add a dummy child in order to keep the composite alive
72
			add(new NullChange(getName()));
73
		}
74
	}
75
76
}
(-)src/org/eclipse/hyades/test/ui/navigator/actions/IProxyNodeRenamer2.java (+36 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator.actions;
13
14
import org.eclipse.ltk.core.refactoring.Change;
15
16
/**
17
 * Interface that allows to describe the rename behavior of a proxy node.
18
 * 
19
 * @author jgout
20
 * @version February 26, 2008
21
 * @since 4.4
22
 */
23
public interface IProxyNodeRenamer2 {
24
25
	/**
26
	 * Returns the refactoring change when renaming this instance with the new name.
27
	 * The given context can be used if the local change cannot be perform without a global context.
28
	 * This can be performed using an IRefactoringTransaction (retrieved by its domain Id) to collect 
29
	 * data. Such refactoring transaction will performed changes in one time.
30
	 *   
31
	 * @param context a context that contains all IRefactoringTransaction instances defined by clients.
32
	 * @param newName the new name of this proxy node.
33
	 * @return the change that performs the rename of the proxy node using the given new name.
34
	 */
35
	public Change createRenameChange(IRefactoringContext context, String newName);
36
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/refactoring/DeleteRefactoring.java (+310 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.internal.navigator.refactoring;
13
14
import java.util.Collection;
15
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.List;
19
20
import org.eclipse.core.resources.IContainer;
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.OperationCanceledException;
27
import org.eclipse.core.runtime.SubProgressMonitor;
28
import org.eclipse.hyades.test.core.internal.changes.DeleteFileChange;
29
import org.eclipse.hyades.test.ui.UiPlugin;
30
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
31
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.CompositeReferencerProxyNode;
32
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry;
33
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
34
import org.eclipse.hyades.test.ui.navigator.IReferencerProxyNode;
35
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeDeleter;
36
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeUpdater;
37
import org.eclipse.ltk.core.refactoring.Change;
38
import org.eclipse.ltk.core.refactoring.CompositeChange;
39
import org.eclipse.ltk.core.refactoring.Refactoring;
40
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
41
import org.eclipse.osgi.util.NLS;
42
43
/**
44
 * @author jgout
45
 * @author jbozier
46
 * @version February 26, 2008
47
 */
48
public class DeleteRefactoring extends Refactoring {
49
	private List containers; 
50
	private List proxies; 
51
	private List seenElements;
52
	private Change change;
53
	private RefactoringContext context;
54
	private boolean deepRemove;
55
	private Collection nodesToUpdateLater;
56
57
	private class NodeToUpdateLater {
58
		private CompositeChange composite;
59
		private String refType;
60
		private CompositeReferencerProxyNode node;
61
		
62
		public NodeToUpdateLater(CompositeChange composite, String refType, CompositeReferencerProxyNode node) {
63
			this.composite = composite;
64
			this.refType = refType;
65
			this.node = node;
66
		}
67
68
		public CompositeChange getComposite() {
69
			return composite;
70
		}
71
72
		public CompositeReferencerProxyNode getNode() {
73
			return node;
74
		}
75
76
		public String getRefType() {
77
			return refType;
78
		}
79
	}
80
	
81
	public List getContainers() {
82
		return containers;
83
	}
84
85
	public List getProxies() {
86
		return proxies;
87
	}
88
89
	public DeleteRefactoring(List containers, List proxies) {
90
		this.containers = containers;
91
		this.proxies = proxies;
92
		this.seenElements = new LinkedList();
93
		this.context = new RefactoringContext();
94
		this.deepRemove = false;
95
		this.nodesToUpdateLater = new HashSet();
96
	}
97
98
	private List getReferencers() {
99
		List proxyReferencers = new LinkedList();
100
		for (Iterator it = proxies.iterator(); it.hasNext();) {
101
			proxyReferencers.add(new CompositeReferencerProxyNode((IProxyNode) it.next()));
102
		}
103
		return proxyReferencers;
104
	}
105
	
106
	public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
107
		pm.beginTask("", 3); //$NON-NLS-1$
108
		try {
109
			ProxyNodeScanner scanner = new ProxyNodeScanner(ResourcesPlugin.getWorkspace().getRoot());
110
			try {
111
				scanner.scan(new SubProgressMonitor(pm, 1));
112
			} catch (OperationCanceledException e) {
113
				return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.ReorgRefactoring_CANCELED_OPERATION_MSG);
114
			}			
115
			change = createChange(new SubProgressMonitor(pm, 1));
116
			RefactoringStatus valid = change.isValid(new SubProgressMonitor(pm, 1));
117
			if(!valid.isOK()) {
118
				change = null;
119
			}
120
			return valid;
121
		} finally {
122
			pm.done();
123
		}
124
	}
125
126
	public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
127
		pm.beginTask("", 1); //$NON-NLS-1$
128
		try {
129
			return new RefactoringStatus();
130
		} finally {
131
			pm.done();
132
		}
133
	}
134
135
	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
136
		if (change != null) {
137
			return change;
138
		}
139
		pm.beginTask("", containers.size()+proxies.size()+1); //$NON-NLS-1$
140
		try {
141
			RefactoringTransactionRootChange c = new RefactoringTransactionRootChange(context);
142
			for (Iterator it = containers.iterator(); it.hasNext();) {
143
				Change containerChange = createDeleteContainerChange((IContainer) it.next());
144
				if (containerChange != null) {
145
					c.add(containerChange);
146
				}
147
				pm.worked(1);
148
			}
149
			for (Iterator it = getReferencers().iterator(); it.hasNext();) {
150
				CompositeReferencerProxyNode ref = (CompositeReferencerProxyNode) it.next();
151
				if (!seenElements.contains(ref)) {
152
					Change refChange = createDeleteReferencerChange(ref);
153
					if (refChange != null) {
154
						c.add(refChange);
155
					}
156
				}		
157
				pm.worked(1);
158
			}
159
			processNodesToUpdateLater();
160
			c.markAsSynthetic();
161
			return c;
162
		} finally {
163
			pm.done();
164
		}
165
	}
166
	
167
	/**
168
	 * Adds the given change as the first children of the given composite change.
169
	 * @param composite
170
	 * @param c
171
	 */
172
	private static void insertFirst(CompositeChange composite, Change c) {
173
		composite.add(c);
174
		Change[] children = composite.getChildren();
175
		for (int i = 0; i < children.length-1; i++) {
176
			composite.remove(children[i]);
177
			composite.add(children[i]);
178
		}
179
	}
180
	
181
	/**
182
	 * Completes delete proxy composite change by adding update changes only 
183
	 * for cases where the element to update still exists
184
	 */
185
	private void processNodesToUpdateLater() {
186
		for (Iterator it = nodesToUpdateLater.iterator(); it.hasNext();) {
187
			NodeToUpdateLater element = (NodeToUpdateLater) it.next();
188
			Change updateTypeChange = createUpdateReferenceTypeChange(element.getRefType(), element.getNode());
189
			if (updateTypeChange != null) {
190
				insertFirst(element.getComposite(), updateTypeChange);
191
			}			
192
		}
193
	}
194
195
	private Change createDeleteReferencerChange(CompositeReferencerProxyNode node) {
196
		IProxyNodeDeleter deleter = (IProxyNodeDeleter) node.getAdapter(IProxyNodeDeleter.class);
197
		if(deleter != null) {
198
			CompositeChange composite = new CompositeChange(NLS.bind(RefactoringMessages.DELETE_PROXY, node.getText()));
199
			seenElements.add(node);
200
			//- we need to add as children all referenced elements from ref type with owns flag set to true.
201
			for (Iterator it = node.getReferenceTypes().iterator(); it.hasNext();) {
202
				String refType = (String) it.next();
203
				String oppType = ReferenceTypeRegistry.getInstance().getOppositeReferenceType(refType);
204
				if (deepRemove && ReferenceTypeRegistry.getInstance().owns(refType)) {
205
					Change referenceTypeChange = createDeleteReferenceTypeChange(refType, node);
206
					if(referenceTypeChange != null) {
207
						composite.add(referenceTypeChange);
208
						continue;
209
					}
210
				}
211
				//- opposite explicit references need to be updated according to the deletion of node
212
				if (ReferenceTypeRegistry.getInstance().isExplicit(oppType)) {
213
					nodesToUpdateLater.add(new NodeToUpdateLater(composite, refType, node));
214
				}
215
			}
216
			composite.add(deleter.createDeleteChange(context));
217
			return composite;
218
		}
219
		return null;
220
	}
221
222
	private Change createUpdateReferenceTypeChange(String refType, CompositeReferencerProxyNode node) {
223
		CompositeChange composite = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(refType));
224
		Collection references = node.getReferences(refType);
225
		for (Iterator it = references.iterator(); it.hasNext();) {
226
			IProxyNode proxy = (IProxyNode) it.next();
227
			if (!seenElements.contains(new CompositeReferencerProxyNode(proxy))) {
228
				IProxyNodeUpdater updater = (IProxyNodeUpdater) proxy.getAdapter(IProxyNodeUpdater.class);
229
				if (updater != null) {
230
					composite.add(updater.createUpdateChange(context, node, refType, null));
231
				}
232
			}						
233
		}		
234
		return composite.getChildren().length > 0 ? composite : null;
235
	}
236
	
237
	private Change createDeleteReferenceTypeChange(String refType, CompositeReferencerProxyNode node) {
238
		CompositeChange composite = new CompositeChange(ReferenceTypeRegistry.getInstance().getName(refType));
239
		Collection references = node.getReferences(refType);
240
		for (Iterator it = references.iterator(); it.hasNext();) {
241
			IProxyNode proxy = (IProxyNode) it.next();
242
			if (proxy.getAdapter(IFile.class) != null) {
243
				//- if the referenced proxy is a referencer itself we need to get its references as well.
244
				if (proxy instanceof IReferencerProxyNode) {
245
					CompositeReferencerProxyNode referenced = new CompositeReferencerProxyNode((IReferencerProxyNode) proxy);
246
					//- we need to check that the referenced element was not previously processed.
247
					//- this check is needed because of bidirectional/circular references.
248
					if (!seenElements.contains(referenced)) {
249
						Change refChange = createDeleteReferencerChange(referenced);
250
						if (refChange != null) {
251
							composite.add(refChange);
252
						}						
253
					}
254
				} else {
255
					// - the referenced element is not a referencer
256
					if (!seenElements.contains(proxy)) {
257
						composite.add(new DeleteFileChange((IFile) proxy.getUnderlyingResource()));
258
					}
259
				}
260
			}			
261
		}		
262
		return composite.getChildren().length > 0 ? composite : null;
263
	}
264
265
	private Change createDeleteContainerChange(IContainer container) {
266
		DeleteContainerCompositeChange contChange = new DeleteContainerCompositeChange(container);
267
		if(container.isAccessible()) {
268
			IResource[] resources;
269
			try {
270
				resources = container.members();
271
			} catch (CoreException e) {
272
				UiPlugin.logWarning("Unable to get members of container: "+container.getFullPath().toOSString(), e); //$NON-NLS-1$
273
				return null;
274
			}
275
			for (int i = 0; i < resources.length; i++) {
276
				if (resources[i] instanceof IFile) {
277
					IFile file = (IFile)resources[i];
278
					IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy(file);
279
					if (proxy != null) {
280
						Change refChange = createDeleteReferencerChange(new CompositeReferencerProxyNode(proxy));
281
						if (refChange != null) {
282
							contChange.add(refChange);
283
							if(proxies.contains(proxy)) {
284
								//- this means that the current proxy (found inside the folder) 
285
								//- was in the original selection as well. We need to remove it to not duplicate change.
286
								proxies.remove(proxy);
287
							}
288
						}		
289
					} else {
290
						//- plain file that are not displayed by the navigator,
291
						//- those files should be shown in the refactoring since they are potentially deleted
292
						contChange.add(new DeleteFileChange(file));
293
					}
294
				} else {
295
					contChange.add(createDeleteContainerChange((IContainer)resources[i]));
296
				}
297
			}
298
		}
299
		return contChange.getChildren().length > 0 ? contChange : contChange.getDeleteContainerChange();
300
	}
301
302
	public String getName() {
303
		return "";  //$NON-NLS-1$
304
	}
305
306
	public void setDeepRemove(boolean deepRemove) {
307
		this.deepRemove = deepRemove;
308
	}
309
310
}
(-)src/org/eclipse/hyades/test/ui/navigator/AbstractProxy.java (+41 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2006-2008 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * $Id: $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.navigator;
13
14
import org.eclipse.core.resources.IResource;
15
16
/**
17
 * Partial implementation of the IProxy interface that manages the <code>equals</code> and <code>hashcode</code> methods.
18
 * 
19
 * @author jgout
20
 * @version February 26, 2008
21
 * @since 4.4
22
 */
23
public abstract class AbstractProxy implements IProxy {
24
25
	public boolean equals(Object arg0) {
26
		if(arg0 instanceof IProxy) {
27
			IResource resThis=this.getUnderlyingResource();
28
			IResource resArg = ((IProxy)arg0).getUnderlyingResource();
29
			String idThis = this.getIdentifier();
30
			String idArg = ((IProxy)arg0).getIdentifier();
31
			return ((resThis != null && resThis.equals(resArg)) || (resThis == null && resArg == null)) 
32
				&& ((idThis != null && idThis.equals(idArg)) || (idThis == null && idArg == null));
33
		}
34
		return false;
35
	}
36
37
	public int hashCode() {
38
		IResource resThis=this.getUnderlyingResource();
39
		return resThis != null ? resThis.hashCode() :  -1;
40
	}
41
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/action/MoveAction.java (+118 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.hyades.test.ui.internal.navigator.action;
12
13
import java.util.Iterator;
14
import java.util.LinkedList;
15
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFolder;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.hyades.test.ui.UiPlugin;
20
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
21
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveRefactoring;
22
import org.eclipse.hyades.test.ui.internal.navigator.refactoring.MoveRefactoringWizard;
23
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
24
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeMover;
25
import org.eclipse.hyades.ui.util.IDisposable;
26
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
28
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.ui.actions.SelectionListenerAction;
30
31
/**
32
 * @author jgout,jbozier
33
 * @version February 26, 2008
34
 */
35
public class MoveAction extends SelectionListenerAction implements IDisposable {
36
	
37
	private Shell shell;
38
	private LinkedList folders;
39
	private LinkedList proxies;
40
	private boolean isResourceNav;
41
	
42
	public MoveAction(Shell shell) {
43
		super(ActionMessages.MOVE_ACTION_NAME); 
44
		this.shell = shell;
45
		folders = new LinkedList();
46
		proxies = new LinkedList();
47
		isResourceNav = false;
48
	}
49
50
	public void run() {
51
		if (! canActivate(shell))
52
			return;
53
		MoveRefactoring refactoring = new MoveRefactoring(folders, proxies);
54
		MoveRefactoringWizard wizard = new MoveRefactoringWizard(refactoring);
55
		wizard.setDefaultPageTitle(ActionMessages.MOVE_ACTION_NAME);
56
		wizard.setNeedsProgressMonitor(true);
57
		RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
58
		try {
59
			op.run(shell , ""); //$NON-NLS-1$
60
		} catch (InterruptedException e) {
61
			UiPlugin.logError(e);
62
		}
63
	}
64
65
	private boolean canActivate(Shell shell) {
66
		return EditorUtil.saveEditors(shell);
67
	}
68
69
	/**
70
	 * Selected elements should be only instances of IFile or IContainer (project/folder)
71
	 */
72
	private void sortSelectedElements() {
73
		folders.clear();
74
		proxies.clear();
75
		IStructuredSelection sel = getStructuredSelection();
76
		for (Iterator it = sel.iterator(); it.hasNext();) {
77
			Object o = it.next();
78
			if (o instanceof IProxyNode) {
79
				proxies.add(o);
80
			} else if (o instanceof IFile) {
81
				IProxyNode proxy = FileProxyNodeCache.getInstance().getProxy((IFile)o);
82
				if (proxy != null) {
83
					proxies.add(proxy);
84
				}				
85
			} else if (o instanceof IAdaptable) {
86
				IAdaptable a = (IAdaptable) o;
87
				o = a.getAdapter(IFolder.class);
88
				if(o != null) {
89
					folders.add((IFolder) o);
90
				}
91
			}
92
		}
93
	}
94
95
	public void dispose() {
96
	}
97
98
	public void selectionChanged(IStructuredSelection structuredSelection, boolean isResourceTestNav) {
99
		this.isResourceNav = isResourceTestNav;
100
		super.selectionChanged(structuredSelection);
101
		sortSelectedElements();
102
	}
103
104
	public boolean isApplicableForSelection() {
105
		//- Move action is only allowed for the resource view of the test navigator
106
		if(!isResourceNav) return false;
107
		return folders.size() > 0 || areProxiesMovable();
108
	}
109
110
	private boolean areProxiesMovable() {
111
		boolean res = true;
112
		for (Iterator it = proxies.iterator(); it.hasNext();) {
113
			IProxyNode proxy = (IProxyNode)it.next();
114
			res &= proxy.getAdapter(IFile.class) != null && proxy instanceof IProxyNodeMover;
115
		}
116
		return res;
117
	}
118
}

Return to bug 166025