KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 JavaDoc fNewName;
27
28     private final ILaunchManager fLaunchManager;
29
30     public LaunchConfigRenameChange(LaunchConfigurationContainer config,
31             String JavaDoc 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 JavaDoc getOldValue(ILaunchConfiguration config) {
44         return fConfig.getName();
45     }
46
47     public Change getUndo(String JavaDoc oldValue) throws CoreException {
48         return new LaunchConfigRenameChange(fConfig, oldValue, fLaunchManager,
49                 shouldFlagWarning());
50     }
51
52     public String JavaDoc getName() {
53         return Messages.format(JUnitMessages.LaunchConfigRenameChange_name,
54                 new Object JavaDoc[] { fConfig.getName(), fNewName });
55     }
56 }
Popular Tags