KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > AddVariableAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.debug.ui.actions;
12
13
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer;
16 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
17 import org.eclipse.jdt.launching.JavaRuntime;
18 import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
19
20 /**
21  * Adds a variable to the runtime class path.
22  */

23 public class AddVariableAction extends RuntimeClasspathAction {
24
25     public AddVariableAction(IClasspathViewer viewer) {
26         super(ActionMessages.AddVariableAction_Add_Variables_1, viewer);
27     }
28
29     /**
30      * Prompts for variables to add.
31      *
32      * @see org.eclipse.jface.action.IAction#run()
33      */

34     public void run() {
35         
36         IPath[] paths = BuildPathDialogAccess.chooseVariableEntries(getShell(), new IPath[0]);
37         if (paths != null) {
38             IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[paths.length];
39             for (int i = 0; i < paths.length; i++) {
40                 entries[i] = JavaRuntime.newVariableRuntimeClasspathEntry(paths[i]);
41             }
42             getViewer().addEntries(entries);
43         }
44     }
45     
46     protected int getActionType() {
47         return ADD;
48     }
49 }
50
Popular Tags