1 /*******************************************************************************
2  * Copyright (c) 2000, 2012 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 
15 package org.eclipse.jdt.internal.debug.core.refactoring;
16 
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.jdt.core.IJavaProject;
20 import org.eclipse.ltk.core.refactoring.Change;
21 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
22 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
23 import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
24 
25 /**
26  * Provides a rename participant for java projects with respect to launch configurations
27  */
28 public class LaunchConfigurationIJavaProjectRenameParticipant extends RenameParticipant {
29 
30 	/**
31 	 * the project to rename
32 	 */
33 	private IJavaProject fJavaProject;
34 
35 	/* (non-Javadoc)
36 	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
37 	 */
38 	@Override
initialize(Object element)39 	protected boolean initialize(Object element) {
40 		fJavaProject = (IJavaProject) element;
41 		return true;
42 	}
43 
44 	/* (non-Javadoc)
45 	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
46 	 */
47 	@Override
getName()48 	public String getName() {
49 		return RefactoringMessages.LaunchConfigurationParticipant_0;
50 	}
51 
52 	/* (non-Javadoc)
53 	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
54 	 */
55 	@Override
checkConditions(IProgressMonitor pm, CheckConditionsContext context)56 	public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
57 		return new RefactoringStatus();
58 	}
59 
60 	/* (non-Javadoc)
61 	 * @see org.eclipse.jdt.internal.corext.refactoring.participants.IRefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
62 	 */
63 	@Override
createChange(IProgressMonitor pm)64 	public Change createChange(IProgressMonitor pm) throws CoreException {
65 		return JDTDebugRefactoringUtil.createChangesForProjectRename(fJavaProject, getArguments().getNewName());
66 	}
67 }
68