1 12 package org.eclipse.debug.internal.ui.sourcelookup.browsers; 13 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.DirectorySourceContainer; 18 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; 19 import org.eclipse.jface.window.Window; 20 import org.eclipse.swt.widgets.Shell; 21 22 26 public class DirectorySourceContainerBrowser extends AbstractSourceContainerBrowser { 27 28 31 public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { 32 ISourceContainer[] containers = new ISourceContainer[1]; 33 DirectorySourceContainerDialog dialog = new DirectorySourceContainerDialog(shell); 34 if (dialog.open() == Window.OK) { 35 String directory = dialog.getDirectory(); 36 if(directory !=null) { 37 containers[0] = new DirectorySourceContainer(new Path(directory), dialog.isSearchSubfolders()); 38 return containers; 39 } 40 } 41 return new ISourceContainer[0]; 42 } 43 44 47 public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { 48 return containers.length == 1 && DirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()); 49 } 50 51 54 public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { 55 if (containers.length == 1 && DirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()) ) { 56 DirectorySourceContainer c = (DirectorySourceContainer)containers[0]; 57 DirectorySourceContainerDialog dialog = new DirectorySourceContainerDialog(shell, c.getDirectory().getPath(), c.isComposite()); 58 if (dialog.open() == Window.OK) { 59 String directory = dialog.getDirectory(); 60 if(directory !=null) { 61 containers[0].dispose(); 62 return new ISourceContainer[]{ new DirectorySourceContainer(new Path(directory), dialog.isSearchSubfolders())}; 63 } 64 } 65 } 66 return containers; 67 } 68 69 } 70 | Popular Tags |