KickJava   Java API By Example, From Geeks To Geeks.

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


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 uncommitted outgoing changes.
34  */

35 public class KSubstWizardDirtyFilesPage extends CVSWizardPage {
36     private boolean includeDirtyFiles;
37     private Button includeDirtyFilesButton;
38     private ListViewer listViewer;
39
40     public KSubstWizardDirtyFilesPage(String JavaDoc pageName, String JavaDoc 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         // set F1 help
51
WorkbenchHelp.setHelp(top, IHelpContextIds.KEYWORD_SUBSTITUTION_CHANGED_PAGE);
52             
53         createWrappingLabel(top, Policy.bind("KSubstWizardDirtyFilesPage.contents"), 0); //$NON-NLS-1$
54

55         includeDirtyFilesButton = new Button(top, SWT.CHECK);
56         includeDirtyFilesButton.setText(Policy.bind("KSubstWizardDirtyFilesPage.includeDirtyFiles")); //$NON-NLS-1$
57
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); //$NON-NLS-1$
67
Dialog.applyDialogFont(parent);
68     }
69     
70     public boolean includeDirtyFiles() {
71         return includeDirtyFiles;
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)) {
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             includeDirtyFilesButton.setFocus();
93         }
94     }
95 }
96
Popular Tags