01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.refactoring;
11:
12: import java.util.HashMap;
13:
14: import org.eclipse.core.resources.IFile;
15: import org.eclipse.core.resources.IProject;
16: import org.eclipse.core.runtime.IPath;
17: import org.eclipse.pde.internal.core.WorkspaceModelManager;
18: import org.eclipse.pde.internal.ui.PDEUIMessages;
19:
20: public class FileRenameParticipant extends PDERenameParticipant {
21:
22: public String getName() {
23: return PDEUIMessages.FileRenameParticipant_renameFiles;
24: }
25:
26: protected boolean initialize(Object element) {
27: if (element instanceof IFile) {
28: IProject project = ((IFile) element).getProject();
29: if (WorkspaceModelManager.isPluginProject(project)) {
30: IPath path = ((IFile) element).getProjectRelativePath()
31: .removeLastSegments(1);
32: String newName = path.append(
33: getArguments().getNewName()).toString();
34: fProject = project;
35: fElements = new HashMap();
36: fElements.put(element, newName);
37: return true;
38: }
39: }
40: return false;
41: }
42:
43: }
|