Skip to main content
summaryrefslogtreecommitdiffstats
blob: db2e95b5044f1908061c47df4f15fdcdbf8091f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2004, 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsp.ui.internal.java.refactoring;

import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;

/**
 * {@link JSPRenameParticipant} used to update JSP documents when a Java type is renamed
 */
public class JSPTypeRenameParticipant extends JSPRenameParticipant {

	
	/**
	 * Initializes the name of this participant to the name of the {@link IType}
	 * 
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
	 */
	protected boolean initialize(Object element) {
		boolean success = false;
		if(element instanceof IType) {
			super.fName = ((IType)element).getElementName();
			success = true;
		}
		return success;
	}

	/**
	 * @return a {@link JSPTypeRenameRequestor}
	 * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant#getSearchRequestor(org.eclipse.jdt.core.IJavaElement, java.lang.String)
	 */
	protected BasicRefactorSearchRequestor getSearchRequestor(IJavaElement element, String newName) {
		
		BasicRefactorSearchRequestor searchRequestor = null;
		
		if(isLegalElementType(element)) {
			searchRequestor = new JSPTypeRenameRequestor((IType)element, newName);
		}
		
		return searchRequestor;
	}

	/**
	 * <p>Legal types are: 
	 * <ul><li>{@link IType}</li></ul></p>

	 * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.JSPRenameParticipant#isLegalElementType(org.eclipse.jdt.core.IJavaElement)
	 */
	protected boolean isLegalElementType(IJavaElement element) {
		return (element instanceof IType);
	}
}

Back to the top