1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.eclipse.adt.internal.launch;
18 
19 import org.eclipse.debug.core.DebugException;
20 import org.eclipse.debug.core.ILaunchConfiguration;
21 import org.eclipse.debug.core.ILaunchManager;
22 import org.eclipse.debug.core.Launch;
23 import org.eclipse.debug.core.model.ISourceLocator;
24 
25 /**
26  * Custom implementation of Launch to allow access to the LaunchManager
27  *
28  */
29 public class AndroidLaunch extends Launch {
30 
31     /**
32      * Basic constructor does nothing special
33      * @param launchConfiguration
34      * @param mode
35      * @param locator
36      */
AndroidLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator)37     public AndroidLaunch(ILaunchConfiguration launchConfiguration, String mode,
38             ISourceLocator locator) {
39         super(launchConfiguration, mode, locator);
40     }
41 
42     /** Stops the launch, and removes it from the launch manager */
stopLaunch()43     public void stopLaunch() {
44         ILaunchManager mgr = getLaunchManager();
45 
46         if (canTerminate()) {
47             try {
48                 terminate();
49             } catch (DebugException e) {
50                 // well looks like we couldn't stop it. nothing else to be
51                 // done really
52             }
53         }
54         // remove the launch
55         mgr.removeLaunch(this);
56     }
57 }
58