1 11 package org.eclipse.jdt.internal.junit.refactoring; 12 13 import org.eclipse.core.runtime.CoreException; 14 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 17 import org.eclipse.debug.core.ILaunchManager; 18 19 import org.eclipse.jdt.internal.junit.Messages; 20 import org.eclipse.jdt.internal.junit.ui.JUnitMessages; 21 22 import org.eclipse.ltk.core.refactoring.Change; 23 24 public class LaunchConfigRenameChange extends LaunchConfigChange { 25 26 private final String fNewName; 27 28 private final ILaunchManager fLaunchManager; 29 30 public LaunchConfigRenameChange(LaunchConfigurationContainer config, 31 String newName, ILaunchManager lm, boolean shouldFlagWarning) { 32 super(config, shouldFlagWarning); 33 fNewName = newName; 34 fLaunchManager = lm; 35 } 36 37 protected void alterLaunchConfiguration(ILaunchConfigurationWorkingCopy copy) 38 throws CoreException { 39 if (!fLaunchManager.isExistingLaunchConfigurationName(fNewName)) 40 copy.rename(fNewName); 41 } 42 43 protected String getOldValue(ILaunchConfiguration config) { 44 return fConfig.getName(); 45 } 46 47 public Change getUndo(String oldValue) throws CoreException { 48 return new LaunchConfigRenameChange(fConfig, oldValue, fLaunchManager, 49 shouldFlagWarning()); 50 } 51 52 public String getName() { 53 return Messages.format(JUnitMessages.LaunchConfigRenameChange_name, 54 new Object [] { fConfig.getName(), fNewName }); 55 } 56 } | Popular Tags |