1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import org.eclipse.core.runtime.IPath; 15 import org.eclipse.core.runtime.Path; 16 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer; 17 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; 18 import org.eclipse.jdt.launching.JavaRuntime; 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.widgets.DirectoryDialog; 21 22 25 public class AddExternalFolderAction extends OpenDialogAction { 26 27 public AddExternalFolderAction(IClasspathViewer viewer, String dialogSettingsPrefix) { 28 super(ActionMessages.AddExternalFolderAction_Add_External_Folder_1, viewer, dialogSettingsPrefix); 29 } 30 31 36 public void run() { 37 38 String lastUsedPath= getDialogSetting(LAST_PATH_SETTING); 39 if (lastUsedPath == null) { 40 lastUsedPath= ""; } 42 DirectoryDialog dialog= new DirectoryDialog(getShell(), SWT.MULTI); 43 dialog.setText(ActionMessages.AddExternalFolderAction_Folder_Selection_3); 44 dialog.setFilterPath(lastUsedPath); 45 String res= dialog.open(); 46 if (res == null) { 47 return; 48 } 49 50 IPath filterPath= new Path(dialog.getFilterPath()); 51 IRuntimeClasspathEntry[] elems= new IRuntimeClasspathEntry[1]; 52 IPath path= new Path(res).makeAbsolute(); 53 elems[0]= JavaRuntime.newArchiveRuntimeClasspathEntry(path); 54 55 setDialogSetting(LAST_PATH_SETTING, filterPath.toOSString()); 56 57 getViewer().addEntries(elems); 58 } 59 } 60 | Popular Tags |