1 11 package org.eclipse.team.internal.ccvs.ui.wizards; 12 13 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 18 import org.eclipse.jface.dialogs.Dialog; 19 import org.eclipse.jface.resource.ImageDescriptor; 20 import org.eclipse.jface.viewers.ListViewer; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.Button; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Event; 26 import org.eclipse.swt.widgets.Listener; 27 import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; 28 import org.eclipse.team.internal.ccvs.ui.Policy; 29 import org.eclipse.team.internal.ccvs.ui.wizards.KSubstWizard.KSubstChangeElement; 30 import org.eclipse.ui.help.WorkbenchHelp; 31 32 35 public class KSubstWizardDirtyFilesPage extends CVSWizardPage { 36 private boolean includeDirtyFiles; 37 private Button includeDirtyFilesButton; 38 private ListViewer listViewer; 39 40 public KSubstWizardDirtyFilesPage(String pageName, String title, ImageDescriptor image, boolean includeDirtyFiles) { 41 super(pageName, title, image); 42 this.includeDirtyFiles = includeDirtyFiles; 43 } 44 45 public void createControl(Composite parent) { 46 Composite top = new Composite(parent, SWT.NONE); 47 top.setLayout(new GridLayout()); 48 setControl(top); 49 50 WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_CHANGED_PAGE); 52 53 createWrappingLabel(top, Policy.bind("KSubstWizardDirtyFilesPage.contents"), 0); 55 includeDirtyFilesButton = new Button(top, SWT.CHECK); 56 includeDirtyFilesButton.setText(Policy.bind("KSubstWizardDirtyFilesPage.includeDirtyFiles")); includeDirtyFilesButton.setSelection(includeDirtyFiles); 58 includeDirtyFilesButton.addListener(SWT.Selection, new Listener() { 59 public void handleEvent(Event e) { 60 includeDirtyFiles = includeDirtyFilesButton.getSelection(); 61 } 62 }); 63 64 createSeparator(top, SPACER_HEIGHT); 65 listViewer = createFileListViewer(top, 66 Policy.bind("KSubstWizardDirtyFilesPage.dirtyFilesViewer.title"), LIST_HEIGHT_HINT); Dialog.applyDialogFont(parent); 68 } 69 70 public boolean includeDirtyFiles() { 71 return includeDirtyFiles; 72 } 73 74 public void setChangeList(List changes) { 75 List filteredFiles = new ArrayList (); 76 for (Iterator it = changes.iterator(); it.hasNext();) { 77 KSubstChangeElement change = (KSubstChangeElement) it.next(); 78 if (change.matchesFilter(KSubstChangeElement.CHANGED_FILE)) { 79 filteredFiles.add(change.getFile()); 80 } 81 } 82 listViewer.setInput(filteredFiles.toArray()); 83 } 84 85 public boolean isListEmpty() { 86 return listViewer.getList().getItemCount() == 0; 88 } 89 public void setVisible(boolean visible) { 90 super.setVisible(visible); 91 if (visible) { 92 includeDirtyFilesButton.setFocus(); 93 } 94 } 95 } 96 | Popular Tags |