1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.jdt.core.IClasspathEntry; 16 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 17 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer; 18 import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages; 19 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; 20 import org.eclipse.jdt.launching.JavaRuntime; 21 import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; 22 23 26 public class AddLibraryAction extends RuntimeClasspathAction { 27 28 public AddLibraryAction(IClasspathViewer viewer) { 29 super(ActionMessages.AddLibraryAction_0, viewer); 30 } 31 32 37 public void run() { 38 39 IClasspathEntry[] newEntries = BuildPathDialogAccess.chooseContainerEntries(getShell(), null, new IClasspathEntry[0]); 40 if (newEntries != null) { 41 IRuntimeClasspathEntry[] res= new IRuntimeClasspathEntry[newEntries.length]; 42 for (int i = 0; i < newEntries.length; i++) { 43 IClasspathEntry entry = newEntries[i]; 44 try { 45 res[i] = JavaRuntime.newRuntimeContainerClasspathEntry(entry.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES); 46 } catch (CoreException e) { 47 JDIDebugUIPlugin.statusDialog(LauncherMessages.RuntimeClasspathAdvancedDialog_Unable_to_create_new_entry__3, e.getStatus()); 48 return; 49 } 50 } 51 getViewer().addEntries(res); 52 } 53 } 54 55 protected int getActionType() { 56 return ADD; 57 } 58 } 59 | Popular Tags |