1 11 package org.eclipse.debug.internal.ui.sourcelookup.browsers; 12 13 import org.eclipse.core.resources.IFolder; 14 import org.eclipse.core.resources.ResourcesPlugin; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.debug.internal.ui.DebugUIPlugin; 18 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 19 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; 20 import org.eclipse.jface.viewers.ILabelProvider; 21 import org.eclipse.jface.viewers.ITreeContentProvider; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.widgets.Button; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Control; 26 import org.eclipse.swt.widgets.Shell; 27 import org.eclipse.ui.PlatformUI; 28 import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; 29 import org.eclipse.ui.dialogs.ISelectionStatusValidator; 30 import org.eclipse.ui.views.navigator.ResourceComparator; 31 32 37 public class FolderSourceContainerDialog extends ElementTreeSelectionDialog { 38 39 44 private static final String LAST_SUBDIR_SETTING = "EXT_FOLDER_SOURCE_LAST_SUBDIR_SETTING"; 46 51 private Button fSubfoldersButton; 52 53 58 private boolean fSearchSubfolders = false; 59 60 65 protected Control createDialogArea(Composite parent) { 66 Composite parentc = (Composite)super.createDialogArea(parent); 67 fSubfoldersButton = new Button(parentc, SWT.CHECK); 68 fSubfoldersButton.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_6); 69 fSubfoldersButton.setSelection(fSearchSubfolders); 70 return parentc; 71 } 72 73 79 public FolderSourceContainerDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) { 80 super(parent, labelProvider, contentProvider); 81 setTitle(SourceLookupUIMessages.folderSelection_title); setInput(ResourcesPlugin.getWorkspace().getRoot()); 83 setComparator(new ResourceComparator(ResourceComparator.NAME)); 84 ISelectionStatusValidator validator= new ISelectionStatusValidator() { 85 public IStatus validate(Object [] selection) { 86 for (int i= 0; i < selection.length; i++) { 87 if (!(selection[i] instanceof IFolder)) { 88 return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), -1, SourceLookupUIMessages.sourceSearch_folderSelectionError, null); } 90 } 91 return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, "", null); } 93 }; 94 setValidator(validator); 95 setDoubleClickSelects(true); 96 setAllowMultiple(true); 97 setMessage(SourceLookupUIMessages.folderSelection_label); 98 PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.ADD_FOLDER_CONTAINER_DIALOG); 99 setSearchSubfolders(DebugUIPlugin.getDefault().getDialogSettings().getBoolean(LAST_SUBDIR_SETTING)); 100 } 101 102 108 public boolean isSearchSubfolders() { 109 return fSearchSubfolders; 110 } 111 112 118 public void setSearchSubfolders(boolean subfolders) { 119 fSearchSubfolders = subfolders; 120 } 121 122 125 protected void okPressed() { 126 fSearchSubfolders = fSubfoldersButton.getSelection(); 127 DebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fSearchSubfolders); 128 super.okPressed(); 129 } 130 131 } 132 | Popular Tags |