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 36 public class KSubstWizardSharedFilesPage extends CVSWizardPage { 37 private boolean includeSharedFiles; 38 private Button includeSharedFilesButton; 39 private ListViewer listViewer; 40 41 public KSubstWizardSharedFilesPage(String pageName, String title, ImageDescriptor image, boolean includeSharedFiles) { 42 super(pageName, title, image); 43 this.includeSharedFiles = includeSharedFiles; 44 } 45 46 public void createControl(Composite parent) { 47 Composite top = new Composite(parent, SWT.NONE); 48 top.setLayout(new GridLayout()); 49 setControl(top); 50 createWrappingLabel(top, Policy.bind("KSubstWizardSharedFilesPage.contents"), 0); 52 WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_SHARED_PAGE); 54 55 includeSharedFilesButton = new Button(top, SWT.CHECK); 56 includeSharedFilesButton.setText(Policy.bind("KSubstWizardSharedFilesPage.includeSharedFiles")); includeSharedFilesButton.setSelection(includeSharedFiles); 58 includeSharedFilesButton.addListener(SWT.Selection, new Listener() { 59 public void handleEvent(Event e) { 60 includeSharedFiles = includeSharedFilesButton.getSelection(); 61 } 62 }); 63 64 createSeparator(top, SPACER_HEIGHT); 65 listViewer = createFileListViewer(top, 66 Policy.bind("KSubstWizardSharedFilesPage.sharedFilesViewer.title"), LIST_HEIGHT_HINT); Dialog.applyDialogFont(parent); 68 } 69 70 public boolean includeSharedFiles() { 71 return includeSharedFiles; 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 | KSubstChangeElement.UNCHANGED_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 includeSharedFilesButton.setFocus(); 93 } 94 } 95 } 96 | Popular Tags |