1 11 package org.eclipse.team.internal.ui.dialogs; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.jface.window.IShellProvider; 18 import org.eclipse.swt.widgets.Shell; 19 20 25 public class PromptingDialog extends MultipleYesNoPrompter { 26 private IPromptCondition condition; 27 private IResource[] resources; 28 36 public PromptingDialog(Shell shell, IResource[] resources, IPromptCondition condition, String title) { 37 this(shell, resources, condition, title, false ); 38 } 39 40 public PromptingDialog(final Shell shell, IResource[] resources, IPromptCondition condition, String title, boolean allOrNothing) { 41 super(new IShellProvider() { 42 public Shell getShell() { 43 return shell; 44 } 45 }, title, resources.length > 1, allOrNothing); 46 this.resources = resources; 47 this.condition = condition; 48 } 49 58 public IResource[] promptForMultiple() throws InterruptedException { 59 List targetResources = new ArrayList (); 60 for (int i = 0; i < resources.length; i++) { 61 IResource resource = resources[i]; 62 if (!condition.needsPrompt(resource) || shouldInclude(condition.promptMessage(resource))) { 63 targetResources.add(resource); 64 } 65 } 66 return (IResource[]) targetResources.toArray(new IResource[targetResources.size()]); 67 } 68 } 69 | Popular Tags |