1 11 package org.eclipse.pde.internal.ui.refactoring; 12 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.OperationCanceledException; 20 import org.eclipse.ltk.core.refactoring.Change; 21 import org.eclipse.ltk.core.refactoring.CompositeChange; 22 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 23 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; 24 import org.eclipse.ltk.core.refactoring.participants.ISharableParticipant; 25 import org.eclipse.ltk.core.refactoring.participants.MoveArguments; 26 import org.eclipse.ltk.core.refactoring.participants.MoveParticipant; 27 import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments; 28 29 public abstract class PDEMoveParticipant extends MoveParticipant implements ISharableParticipant { 30 31 protected IProject fProject; 32 protected HashMap fElements; 33 34 public RefactoringStatus checkConditions(IProgressMonitor pm, 35 CheckConditionsContext context) throws OperationCanceledException { 36 return new RefactoringStatus(); 37 } 38 39 public void addElement(Object element, RefactoringArguments arguments) { 40 Object destination = ((MoveArguments)arguments).getDestination(); 41 fElements.put(element, getNewName(destination, element)); 42 } 43 44 public Change createChange(IProgressMonitor pm) throws CoreException, 45 OperationCanceledException { 46 CompositeChange result = new CompositeChange(getName()); 47 addChange(result, pm); 48 if (isInterestingForExtensions()) { 49 addChange(result, "plugin.xml", pm); addChange(result, "fragment.xml", pm); } 52 return (result.getChildren().length == 0) ? null : result; 53 } 54 55 protected abstract boolean isInterestingForExtensions(); 56 57 protected void addChange(CompositeChange result, String filename, IProgressMonitor pm) 58 throws CoreException { 59 } 60 61 protected void addChange(CompositeChange result, IProgressMonitor pm) 63 throws CoreException { 64 } 65 66 protected String getNewName(Object destination, Object element) { 67 return element.toString(); 68 } 69 70 protected String [] getNewNames() { 71 String [] result = new String [fElements.size()]; 72 Iterator iter = fElements.values().iterator(); 73 for (int i = 0; i < fElements.size(); i++) 74 result[i] = iter.next().toString(); 75 return result; 76 } 77 78 } 79 | Popular Tags |