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 18 import org.eclipse.jdt.internal.junit.Messages; 19 import org.eclipse.jdt.internal.junit.ui.JUnitMessages; 20 21 import org.eclipse.ltk.core.refactoring.Change; 22 23 public class LaunchConfigSetAttributeChange extends LaunchConfigChange { 24 25 private String fNewValue; 26 27 private final String fAttributeName; 28 29 public LaunchConfigSetAttributeChange(LaunchConfigurationContainer config, String attributeName, String newValue, boolean shouldFlagWarning) { 30 super(config, shouldFlagWarning); 31 fNewValue= newValue; 32 fAttributeName= attributeName; 33 } 34 35 protected Change getUndo(String oldValue) throws CoreException { 36 return new LaunchConfigSetAttributeChange(fConfig, fAttributeName, oldValue, shouldFlagWarning()); 37 } 38 39 public String getChangedAttributeName() { 40 return fAttributeName; 41 } 42 43 protected void alterLaunchConfiguration(ILaunchConfigurationWorkingCopy copy) throws CoreException { 44 copy.setAttribute(fAttributeName, fNewValue); 45 } 46 47 protected String getOldValue(ILaunchConfiguration config) throws CoreException { 48 return config.getAttribute(fAttributeName, (String ) null); 49 } 50 51 public String getName() { 52 return Messages.format(JUnitMessages.LaunchConfigSetAttributeChange_name, new Object [] {fAttributeName, fConfig.getName()}); 53 } 54 } | Popular Tags |