Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8144af82aa84dc0107b13b6f8d016e84181fe23e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package org.eclipse.team.internal.ccvs.ui;

/*
 * (c) Copyright IBM Corp. 2000, 2002.
 * All Rights Reserved.
 */

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
import org.eclipse.team.internal.ccvs.core.resources.ResourceSyncInfo;
import org.eclipse.ui.dialogs.PropertyPage;

public class CVSFilePropertiesPage extends PropertyPage {
	IFile file;

	/*
	 * @see PreferencesPage#createContents
	 */
	protected Control createContents(Composite parent) {
		initialize();
		noDefaultAndApplyButton();
		Composite composite = new Composite(parent, SWT.NULL);
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		composite.setLayout(layout);
		
		try {
			LocalFile cvsResource = new LocalFile(file.getLocation().toFile());
			if (!cvsResource.isManaged()) {
				if (cvsResource.isIgnored()) {
					createLabel(composite, Policy.bind("CVSFilePropertiesPage.ignored"));
				} else {
					createLabel(composite, Policy.bind("CVSFilePropertiesPage.notManaged"));
				}
				createLabel(composite, "");
				return composite;
			}
			ResourceSyncInfo syncInfo = cvsResource.getSyncInfo();
			
			// Base
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseRevision"));
			createLabel(composite, syncInfo.getRevision());
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseTimestamp"));
			createLabel(composite, syncInfo.getTimeStamp());
			
			// Dirty and Modified
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.dirty"));
			createLabel(composite, cvsResource.isDirty() ? Policy.bind("yes") : Policy.bind("no"));
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.modified"));
			createLabel(composite, cvsResource.isModified() ? Policy.bind("yes") : Policy.bind("no"));
			
			// Keyword Mode
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.keywordMode"));
			String keywordMode = syncInfo.getKeywordMode();
			if (keywordMode.equals("-kb")) {
				createLabel(composite, Policy.bind("CVSFilePropertiesPage.binary")); 
			} else if (keywordMode.equals("-ko")) {
				createLabel(composite, Policy.bind("CVSFilePropertiesPage.textNoKeyword"));
			} else if (keywordMode.equals("")) {
				createLabel(composite, Policy.bind("CVSFilePropertiesPage.text"));
			} else {
				createLabel(composite, keywordMode);
			}
			
			// Tag
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.tag"));
			CVSTag tag = syncInfo.getTag();
			if (tag == null) {
				createLabel(composite, Policy.bind("CVSFilePropertiesPage.none"));
			} else {
				switch (tag.getType()) {
					case CVSTag.HEAD:
						createLabel(composite, tag.getName());
						break;
					case CVSTag.VERSION:
						createLabel(composite, Policy.bind("CVSFilePropertiesPage.version", tag.getName()));
						break;
					case CVSTag.BRANCH:
						createLabel(composite, Policy.bind("CVSFilePropertiesPage.branch", tag.getName()));
						break;
					case CVSTag.DATE:
						createLabel(composite, Policy.bind("CVSFilePropertiesPage.date", tag.getName()));
						break;
				}
			}
			
			// Permissions
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.permissions"));
			String permissions = syncInfo.getPermissions();
			if (permissions == null) {
				createLabel(composite, Policy.bind("CVSFilePropertiesPage.notAvailable"));
			} else {
				createLabel(composite, syncInfo.getPermissions());
			}
		} catch (TeamException e) {
			// Display error text
			createLabel(composite, Policy.bind("CVSFilePropertiesPage.error"));
			createLabel(composite, "");
		}
		return composite;
	}
	/**
	 * Utility method that creates a label instance
	 * and sets the default layout data.
	 *
	 * @param parent  the parent for the new label
	 * @param text  the text for the new label
	 * @return the new label
	 */
	protected Label createLabel(Composite parent, String text) {
		Label label = new Label(parent, SWT.LEFT);
		label.setText(text);
		GridData data = new GridData();
		data.horizontalSpan = 1;
		data.horizontalAlignment = GridData.FILL;
		label.setLayoutData(data);
		return label;
	}
	/**
	 * Initializes the page
	 */
	private void initialize() {
		// Get the file that is the source of this property page
		file = null;
		IAdaptable element = getElement();
		if (element instanceof IFile) {
			file = (IFile)element;
		} else {
			Object adapter = element.getAdapter(IFile.class);
			if (adapter instanceof IFile) {
				file = (IFile)adapter;
			}
		}
	}
}

Back to the top