KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > ui > actions > LaunchAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.debug.ui.actions;
12
13
14 import org.eclipse.debug.core.ILaunchConfiguration;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
17 import org.eclipse.debug.ui.DebugUITools;
18 import org.eclipse.jface.action.Action;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.jface.viewers.StructuredSelection;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.widgets.Event;
23 import org.eclipse.ui.PlatformUI;
24
25 /**
26  * Launches a launch configuration in a specific mode.
27  * <p>
28  * Clients are not intended to subclass this class; clients may instantiate this
29  * class.
30  * </p>
31  * @since 2.1
32  */

33 public class LaunchAction extends Action {
34
35     /**
36      * The configuration to launch.
37      */

38     private ILaunchConfiguration fConfiguration;
39     /**
40      * The mode to launch in
41      */

42     private String JavaDoc fMode;
43     
44     /**
45      * Constructs an action that launches the specified launch configuration
46      * in the specified mode.
47      *
48      * @param configuration launch configuration
49      * @param mode launch mode - one of <code>ILaunchManager.RUN_MODE</code> or
50      * <code>ILaunchManager.DEBUG_MODE</code>
51      */

52     public LaunchAction(ILaunchConfiguration configuration, String JavaDoc mode) {
53         fConfiguration = configuration;
54         fMode = mode;
55         setText(configuration.getName());
56         setImageDescriptor(DebugUITools.getDefaultImageDescriptor(configuration));
57         PlatformUI.getWorkbench().getHelpSystem().setHelp(
58             this,
59             IDebugHelpContextIds.RELAUNCH_HISTORY_ACTION);
60     }
61
62     /**
63      * @see org.eclipse.jface.action.IAction#run()
64      */

65     public void run() {
66         DebugUITools.launch(fConfiguration, fMode);
67     }
68     
69     /**
70      * If the user has control-clicked the launch history item, open the launch
71      * configuration dialog on the launch configuration, rather than running it.
72      *
73      * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
74      */

75     public void runWithEvent(Event event) {
76         if ((event.stateMask & SWT.MOD1) > 0) {
77             IStructuredSelection selection = new StructuredSelection(fConfiguration);
78             String JavaDoc id = DebugUITools.getLaunchGroup(fConfiguration, fMode).getIdentifier();
79             DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, id);
80         } else {
81             run();
82         }
83     }
84
85 }
86
Popular Tags