KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > refactoring > LaunchConfigSetAttributeChange


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.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 JavaDoc fNewValue;
26
27     private final String JavaDoc fAttributeName;
28
29     public LaunchConfigSetAttributeChange(LaunchConfigurationContainer config, String JavaDoc attributeName, String JavaDoc newValue, boolean shouldFlagWarning) {
30         super(config, shouldFlagWarning);
31         fNewValue= newValue;
32         fAttributeName= attributeName;
33     }
34
35     protected Change getUndo(String JavaDoc oldValue) throws CoreException {
36         return new LaunchConfigSetAttributeChange(fConfig, fAttributeName, oldValue, shouldFlagWarning());
37     }
38
39     public String JavaDoc getChangedAttributeName() {
40         return fAttributeName;
41     }
42
43     protected void alterLaunchConfiguration(ILaunchConfigurationWorkingCopy copy) throws CoreException {
44         copy.setAttribute(fAttributeName, fNewValue);
45     }
46
47     protected String JavaDoc getOldValue(ILaunchConfiguration config) throws CoreException {
48         return config.getAttribute(fAttributeName, (String JavaDoc) null);
49     }
50
51     public String JavaDoc getName() {
52         return Messages.format(JUnitMessages.LaunchConfigSetAttributeChange_name, new Object JavaDoc[] {fAttributeName, fConfig.getName()});
53     }
54 }
Popular Tags