1 11 package org.eclipse.debug.internal.ui.sourcelookup.browsers; 12 13 import org.eclipse.core.runtime.IPath; 14 import org.eclipse.core.runtime.Path; 15 import org.eclipse.debug.core.sourcelookup.ISourceContainer; 16 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 17 import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer; 18 import org.eclipse.debug.internal.ui.DebugUIPlugin; 19 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; 20 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.widgets.FileDialog; 23 import org.eclipse.swt.widgets.Shell; 24 25 29 public class ExternalArchiveSourceContainerBrowser extends AbstractSourceContainerBrowser { 30 31 private static final String ROOT_DIR = ExternalArchiveSourceContainerBrowser.class.getName() + ".rootDir"; 33 36 public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { 37 FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); 38 String rootDir = DebugUIPlugin.getDefault().getDialogSettings().get(ROOT_DIR); 39 dialog.setText(SourceLookupUIMessages.ExternalArchiveSourceContainerBrowser_2); 40 dialog.setFilterExtensions(new String []{"*.jar;*.zip"}); if (rootDir != null) { 42 dialog.setFilterPath(rootDir); 43 } 44 dialog.open(); 45 String [] fileNames= dialog.getFileNames(); 46 int nChosen= fileNames.length; 47 if (nChosen > 0) { 48 rootDir = dialog.getFilterPath(); 49 IPath filterPath= new Path(rootDir); 50 ISourceContainer[] containers= new ISourceContainer[nChosen]; 51 for (int i= 0; i < nChosen; i++) { 52 IPath path= filterPath.append(fileNames[i]).makeAbsolute(); 53 containers[i]= new ExternalArchiveSourceContainer(path.toOSString(), true); 55 } 56 DebugUIPlugin.getDefault().getDialogSettings().put(ROOT_DIR, rootDir); 57 return containers; 58 } 59 return new ISourceContainer[0]; 60 } 61 62 } 63 | Popular Tags |