1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.internal.debug.ui.actions;
15 
16 
17 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer;
18 import org.eclipse.jdt.internal.debug.ui.launcher.RuntimeClasspathAdvancedDialog;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.jface.dialogs.Dialog;
21 
22 /**
23  * Opens a dialog to allow the user to choose among advanced actions.
24  */
25 public class AddAdvancedAction extends RuntimeClasspathAction {
26 
27 	private IAction[] fActions;
28 
AddAdvancedAction(IClasspathViewer viewer, IAction[] actions)29 	public AddAdvancedAction(IClasspathViewer viewer, IAction[] actions) {
30 		super(ActionMessages.AddAdvancedAction_Ad_vanced____1, viewer);
31 		fActions = actions;
32 		setViewer(viewer);
33 	}
34 
35 	/**
36 	 * Prompts for a project to add.
37 	 *
38 	 * @see IAction#run()
39 	 */
40 	@Override
run()41 	public void run() {
42 		Dialog dialog = new RuntimeClasspathAdvancedDialog(getShell(), fActions, getViewer());
43 		dialog.open();
44 	}
45 
46 	/**
47 	 * @see RuntimeClasspathAction#setViewer(RuntimeClasspathViewer)
48 	 */
49 	@Override
setViewer(IClasspathViewer viewer)50 	public void setViewer(IClasspathViewer viewer) {
51 		super.setViewer(viewer);
52 		if (fActions != null) {
53 			for (IAction action : fActions) {
54 				if (action instanceof RuntimeClasspathAction) {
55 					((RuntimeClasspathAction) action).setViewer(viewer);
56 				}
57 			}
58 		}
59 	}
60 
61 	@Override
getActionType()62 	protected int getActionType() {
63 		return ADD;
64 	}
65 }
66