KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > CVSFilePropertiesPage


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

11 package org.eclipse.team.internal.ccvs.ui;
12
13 import com.ibm.icu.text.DateFormat;
14 import java.util.Date JavaDoc;
15
16 import org.eclipse.core.resources.IFile;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.jface.dialogs.Dialog;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.layout.GridData;
21 import org.eclipse.swt.layout.GridLayout;
22 import org.eclipse.swt.widgets.*;
23 import org.eclipse.team.core.TeamException;
24 import org.eclipse.team.internal.ccvs.core.CVSTag;
25 import org.eclipse.team.internal.ccvs.core.ICVSFile;
26 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
27 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
28 import org.eclipse.team.internal.ccvs.core.util.Util;
29 import org.eclipse.ui.PlatformUI;
30
31 public class CVSFilePropertiesPage extends CVSPropertiesPage {
32     IFile file;
33
34     /*
35      * @see PreferencesPage#createContents
36      */

37     protected Control createContents(Composite parent) {
38         initialize();
39         noDefaultAndApplyButton();
40         Composite composite = new Composite(parent, SWT.NULL);
41         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
42         GridLayout layout = new GridLayout();
43         layout.numColumns = 2;
44         composite.setLayout(layout);
45         
46         try {
47             ICVSFile cvsResource = CVSWorkspaceRoot.getCVSFileFor(file);
48             if (!cvsResource.isManaged()) {
49                 if (cvsResource.isIgnored()) {
50                     createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_ignored);
51                 } else {
52                     createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_notManaged);
53                 }
54                 createLabel(composite, ""); //$NON-NLS-1$
55
return composite;
56             }
57             ResourceSyncInfo syncInfo = cvsResource.getSyncInfo();
58             
59
60             
61             if (syncInfo.isAdded()) {
62                 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_isAdded, 2);
63             } else {
64                 // Base
65
createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_baseRevision);
66                 createLabel(composite, syncInfo.getRevision());
67                 Date JavaDoc baseTime = syncInfo.getTimeStamp();
68                 if (baseTime != null) {
69                     createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_baseTimestamp);
70                     createLabel(composite, DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(syncInfo.getTimeStamp()));
71                 }
72                 
73                 // Modified
74
createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_modified);
75                 createLabel(composite, cvsResource.isModified(null) ? CVSUIMessages.yes : CVSUIMessages.no); //
76
}
77             
78             // Keyword Mode
79
createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_keywordMode);
80             createLabel(composite, syncInfo.getKeywordMode().getLongDisplayText());
81             
82             // Tag
83
createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_tag);
84             CVSTag tag = Util.getAccurateFileTag(cvsResource);
85             createLabel(composite, getTagLabel(tag));
86         } catch (TeamException e) {
87             // Display error text
88
createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_error);
89             createLabel(composite, ""); //$NON-NLS-1$
90
}
91         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FILE_PROPERTY_PAGE);
92         Dialog.applyDialogFont(parent);
93         return composite;
94     }
95     /**
96      * Utility method that creates a label instance
97      * and sets the default layout data.
98      *
99      * @param parent the parent for the new label
100      * @param text the text for the new label
101      * @return the new label
102      */

103     protected Label createLabel(Composite parent, String JavaDoc text, int span) {
104         Label label = new Label(parent, SWT.LEFT);
105         label.setText(text);
106         GridData data = new GridData();
107         data.horizontalSpan = span;
108         data.horizontalAlignment = GridData.FILL;
109         label.setLayoutData(data);
110         return label;
111     }
112     protected Label createLabel(Composite parent, String JavaDoc text) {
113         return createLabel(parent, text, 1);
114     }
115     /**
116      * Initializes the page
117      */

118     private void initialize() {
119         // Get the file that is the source of this property page
120
file = null;
121         IAdaptable element = getElement();
122         if (element instanceof IFile) {
123             file = (IFile)element;
124         } else {
125             Object JavaDoc adapter = element.getAdapter(IFile.class);
126             if (adapter instanceof IFile) {
127                 file = (IFile)adapter;
128             }
129         }
130     }
131 }
132
133
Popular Tags