KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > wizards > KSubstWizardSharedFilesPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.wizards;
12
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.Iterator JavaDoc;
16 import java.util.List JavaDoc;
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 /**
33  * Page to warn user about the side-effects of changing keyword
34  * substitution on already committed files.
35  */

36 public class KSubstWizardSharedFilesPage extends CVSWizardPage {
37     private boolean includeSharedFiles;
38     private Button includeSharedFilesButton;
39     private ListViewer listViewer;
40
41     public KSubstWizardSharedFilesPage(String JavaDoc pageName, String JavaDoc 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); //$NON-NLS-1$
51

52         // set F1 help
53
WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_SHARED_PAGE);
54                 
55         includeSharedFilesButton = new Button(top, SWT.CHECK);
56         includeSharedFilesButton.setText(Policy.bind("KSubstWizardSharedFilesPage.includeSharedFiles")); //$NON-NLS-1$
57
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); //$NON-NLS-1$
67
Dialog.applyDialogFont(parent);
68     }
69     
70     public boolean includeSharedFiles() {
71         return includeSharedFiles;
72     }
73
74     public void setChangeList(List JavaDoc changes) {
75         List JavaDoc filteredFiles = new ArrayList JavaDoc();
76         for (Iterator JavaDoc 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         // returns true iff the list is empty after filtering
87
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