1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import com.ibm.icu.text.DateFormat; 14 import java.util.Date ; 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 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, ""); 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 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_baseRevision); 66 createLabel(composite, syncInfo.getRevision()); 67 Date 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 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_modified); 75 createLabel(composite, cvsResource.isModified(null) ? CVSUIMessages.yes : CVSUIMessages.no); } 77 78 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_keywordMode); 80 createLabel(composite, syncInfo.getKeywordMode().getLongDisplayText()); 81 82 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_tag); 84 CVSTag tag = Util.getAccurateFileTag(cvsResource); 85 createLabel(composite, getTagLabel(tag)); 86 } catch (TeamException e) { 87 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_error); 89 createLabel(composite, ""); } 91 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FILE_PROPERTY_PAGE); 92 Dialog.applyDialogFont(parent); 93 return composite; 94 } 95 103 protected Label createLabel(Composite parent, String 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 text) { 113 return createLabel(parent, text, 1); 114 } 115 118 private void initialize() { 119 file = null; 121 IAdaptable element = getElement(); 122 if (element instanceof IFile) { 123 file = (IFile)element; 124 } else { 125 Object adapter = element.getAdapter(IFile.class); 126 if (adapter instanceof IFile) { 127 file = (IFile)adapter; 128 } 129 } 130 } 131 } 132 133 | Popular Tags |