blob: 46f4e6ef4b568e90d4106999a94188bc8792c11a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.debug.ui.actions;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer;
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
/**
* Adds a library to the runtime class path.
*/
public class AddLibraryAction extends RuntimeClasspathAction {
public AddLibraryAction(IClasspathViewer viewer) {
super(ActionMessages.AddLibraryAction_0, viewer);
}
/**
* Prompts for folder(s) to add.
*
* @see org.eclipse.jface.action.IAction#run()
*/
@Override
public void run() {
IClasspathEntry[] newEntries = BuildPathDialogAccess.chooseContainerEntries(getShell(), null, new IClasspathEntry[0]);
if (newEntries != null) {
IRuntimeClasspathEntry[] res= new IRuntimeClasspathEntry[newEntries.length];
for (int i = 0; i < newEntries.length; i++) {
IClasspathEntry entry = newEntries[i];
try {
res[i] = JavaRuntime.newRuntimeContainerClasspathEntry(entry.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
} catch (CoreException e) {
JDIDebugUIPlugin.statusDialog(LauncherMessages.RuntimeClasspathAdvancedDialog_Unable_to_create_new_entry__3, e.getStatus());
return;
}
}
getViewer().addEntries(res);
}
}
@Override
protected int getActionType() {
return ADD;
}
}
|