1 11 package org.eclipse.debug.internal.ui.sourcelookup.browsers; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.resources.IFolder; 16 import org.eclipse.debug.core.sourcelookup.ISourceContainer; 17 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 18 import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; 19 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; 20 import org.eclipse.jface.window.Window; 21 import org.eclipse.swt.widgets.Shell; 22 import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; 23 import org.eclipse.ui.model.WorkbenchContentProvider; 24 import org.eclipse.ui.model.WorkbenchLabelProvider; 25 26 31 public class FolderSourceContainerBrowser extends AbstractSourceContainerBrowser { 32 33 36 public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { 37 FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); 38 39 if (dialog.open() == Window.OK) { 40 Object [] selection= ((ElementTreeSelectionDialog)dialog).getResult(); 41 ArrayList containers = new ArrayList (); 42 for (int i= 0; i < selection.length; i++) { 43 if(selection[i] instanceof IFolder) { 44 containers.add(new FolderSourceContainer((IFolder)selection[i], dialog.isSearchSubfolders())); 45 } 46 } 47 return (ISourceContainer[])containers.toArray(new ISourceContainer[containers.size()]); 48 } 49 return new ISourceContainer[0]; 50 } 51 52 55 public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { 56 return containers.length == 1 && containers[0].getType().getId().equals(FolderSourceContainer.TYPE_ID); 57 } 58 59 62 public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { 63 FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); 64 FolderSourceContainer container = (FolderSourceContainer) containers[0]; 65 dialog.setSearchSubfolders(container.isComposite()); 66 dialog.setInitialSelection(container.getContainer()); 67 if (dialog.open() == Window.OK) { 68 container.dispose(); 69 Object [] selection= ((ElementTreeSelectionDialog)dialog).getResult(); 70 ArrayList list = new ArrayList (); 71 for (int i= 0; i < selection.length; i++) { 72 if(selection[i] instanceof IFolder) { 73 list.add(new FolderSourceContainer((IFolder)selection[i], dialog.isSearchSubfolders())); 74 } 75 } 76 return (ISourceContainer[])list.toArray(new ISourceContainer[list.size()]); 77 } 78 return new ISourceContainer[0]; 79 } 80 81 82 83 } 84 | Popular Tags |