KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > launcher > LaunchConfigurationListener


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.pde.internal.ui.launcher;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.debug.core.DebugPlugin;
16 import org.eclipse.debug.core.ILaunchConfiguration;
17 import org.eclipse.debug.core.ILaunchConfigurationListener;
18 import org.eclipse.pde.internal.core.PDECore;
19 import org.eclipse.pde.internal.core.util.CoreUtility;
20
21
22 public class LaunchConfigurationListener implements ILaunchConfigurationListener {
23
24     /* (non-Javadoc)
25      * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration)
26      */

27     public void launchConfigurationAdded(ILaunchConfiguration configuration) {
28     }
29
30     /* (non-Javadoc)
31      * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
32      */

33     public void launchConfigurationChanged(ILaunchConfiguration configuration) {
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
38      */

39     public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
40         File JavaDoc metadataLocation = new File JavaDoc(PDECore.getDefault().getStateLocation().toOSString());
41         File JavaDoc configDir = new File JavaDoc(metadataLocation, configuration.getName());
42         if (configDir.exists()) {
43             // rename the config area if it was auto-set by PDE when the launch configuration is renamed
44
ILaunchConfiguration destination = DebugPlugin.getDefault().getLaunchManager().getMovedTo(configuration);
45             boolean delete = true;
46             if (destination != null) {
47                 delete = !configDir.renameTo(new File JavaDoc(metadataLocation, destination.getName()));
48             }
49             if (delete)
50                 CoreUtility.deleteContent(configDir);
51         }
52     }
53
54 }
55
Popular Tags