KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 /*
12  * Created on Apr 11, 2004
13  *
14  * To change the template for this generated file go to
15  * Window - Preferences - Java - Code Generation - Code and Comments
16  */

17 package org.eclipse.jdt.internal.junit.refactoring;
18
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.runtime.IProgressMonitor;
21 import org.eclipse.debug.core.ILaunchConfiguration;
22 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
24 import org.eclipse.ltk.core.refactoring.Change;
25 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
26
27
28 class LaunchConfigProjectChange extends Change {
29
30     private ILaunchConfiguration fConfig;
31     private String JavaDoc fNewName;
32
33     public LaunchConfigProjectChange(ILaunchConfiguration config, String JavaDoc newName) {
34         fConfig= config;
35         fNewName= newName;
36     }
37     
38     /**
39      * {@inheritDoc}
40      */

41     public String JavaDoc getName() {
42         return fConfig.getName();
43     }
44     
45     /**
46      * {@inheritDoc}
47      */

48     public void initializeValidationData(IProgressMonitor pm) {
49         // must be implemented to decide correct value of isValid
50
}
51
52     public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
53         return new RefactoringStatus();
54     }
55         
56     /* (non-Javadoc)
57      * @see org.eclipse.jdt.internal.corext.refactoring.base.IChange#perform(org.eclipse.jdt.internal.corext.refactoring.base.ChangeContext, org.eclipse.core.runtime.IProgressMonitor)
58      */

59     public Change perform(IProgressMonitor pm) throws CoreException {
60         pm.beginTask("", 1); //$NON-NLS-1$
61
String JavaDoc oldProjectName= fConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String JavaDoc)null);
62
63         ILaunchConfigurationWorkingCopy copy = fConfig.getWorkingCopy();
64         copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewName);
65         copy.doSave();
66         pm.worked(1);
67         return new LaunchConfigProjectChange(fConfig, oldProjectName);
68     }
69
70     /* (non-Javadoc)
71      * @see org.eclipse.jdt.internal.corext.refactoring.base.IChange#getModifiedLanguageElement()
72      */

73     public Object JavaDoc getModifiedElement() {
74         return fConfig;
75     }
76 }
Popular Tags