KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > refactoring > FileRenameParticipant


1 /*******************************************************************************
2  * Copyright (c) 2006 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 Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.refactoring;
12
13 import java.util.HashMap JavaDoc;
14
15 import org.eclipse.core.resources.IFile;
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.runtime.IPath;
18 import org.eclipse.pde.internal.core.WorkspaceModelManager;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20
21 public class FileRenameParticipant extends PDERenameParticipant {
22
23     public String JavaDoc getName() {
24         return PDEUIMessages.FileRenameParticipant_renameFiles;
25     }
26
27     protected boolean initialize(Object JavaDoc element) {
28         if (element instanceof IFile) {
29             IProject project = ((IFile)element).getProject();
30             if (WorkspaceModelManager.isPluginProject(project)) {
31                 IPath path = ((IFile)element).getProjectRelativePath().removeLastSegments(1);
32                 String JavaDoc newName = path.append(getArguments().getNewName()).toString();
33                 fProject = project;
34                 fElements = new HashMap JavaDoc();
35                 fElements.put(element, newName);
36                 return true;
37             }
38         }
39         return false;
40     }
41
42 }
43
Popular Tags