blob: 0f41bb987b4cd202a2aca12fa4125e592bf93b1c [file] [log] [blame]
package org.eclipse.debug.ui.actions;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
This file is made available under the terms of the Common Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
**********************************************************************/
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
/**
* Opens the launch configuration dialog in the context of a launch group.
* <p>
* Clients are not intended to subclass this class; clients may instantiate this
* class.
* </p>
* @since 2.1
*/
public class OpenLaunchDialogAction extends Action implements IWorkbenchWindowActionDelegate {
/**
* Launch group identifier
*/
private String fIdentifier;
/**
* Constucts an action that opens the launch configuration dialog in
* the context of the specified launch group.
*
* @param identifier unique identifier of a launch group extension
*/
public OpenLaunchDialogAction(String identifier) {
fIdentifier = identifier;
LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
if (extension != null) {
setText(extension.getLabel() + "..."); //$NON-NLS-1$
setImageDescriptor(extension.getImageDescriptor());
}
// TODO: help context
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
LaunchHistory history = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchHistory(fIdentifier);
ILaunchConfiguration configuration = history.getRecentLaunch();
IStructuredSelection selection = null;
if (configuration == null) {
selection = new StructuredSelection();
} else {
selection = new StructuredSelection(configuration);
}
DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
}
/**
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
}
/**
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
}
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
run();
}
/**
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}