plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/internal/session/TerminateSession.java
changeset 471 06589bf52fa7
equal deleted inserted replaced
470:d4809db37847 471:06589bf52fa7
       
     1 /**
       
     2  * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  */
       
    19 package org.symbian.tools.tmw.debug.internal.session;
       
    20 
       
    21 import java.util.Map;
       
    22 
       
    23 import org.eclipse.core.runtime.CoreException;
       
    24 import org.eclipse.debug.core.DebugPlugin;
       
    25 import org.eclipse.debug.core.ILaunch;
       
    26 import org.eclipse.debug.core.ILaunchConfiguration;
       
    27 import org.eclipse.debug.core.ILaunchManager;
       
    28 import org.symbian.tools.tmw.debug.internal.Activator;
       
    29 import org.symbian.tools.tmw.debug.internal.IConstants;
       
    30 import org.symbian.tools.tmw.debug.internal.launch.WidgetLaunchDelegate;
       
    31 import org.symbian.tools.tmw.previewer.IPreviewerCommandHandler;
       
    32 
       
    33 public class TerminateSession implements IPreviewerCommandHandler {
       
    34     @SuppressWarnings("rawtypes")
       
    35     public void handle(String commandName, String projectName, Map parameters) {
       
    36         ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
       
    37         for (ILaunch launch : launchManager.getLaunches()) {
       
    38             try {
       
    39                 if (!launch.isTerminated()) {
       
    40                     ILaunchConfiguration lc = launch.getLaunchConfiguration();
       
    41                     if (WidgetLaunchDelegate.ID.equals(lc.getType().getIdentifier())
       
    42                             && projectName.equals(lc.getAttribute(IConstants.PROP_PROJECT_NAME, ""))) {
       
    43                         launch.terminate();
       
    44                     }
       
    45                 }
       
    46             } catch (CoreException e) {
       
    47                 Activator.log(e);
       
    48             }
       
    49         }
       
    50     }
       
    51 
       
    52 }