1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.IAdaptable; 16 import org.eclipse.jface.dialogs.Dialog; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.layout.GridData; 19 import org.eclipse.swt.layout.GridLayout; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Control; 22 import org.eclipse.swt.widgets.Label; 23 import org.eclipse.team.core.TeamException; 24 import org.eclipse.team.internal.ccvs.core.ICVSFolder; 25 import org.eclipse.team.internal.ccvs.core.ICVSResource; 26 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 27 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; 28 import org.eclipse.ui.dialogs.PropertyPage; 29 30 34 public class ResourcePropertiesPage extends PropertyPage { 35 IResource resource; 37 38 41 protected Control createContents(Composite parent) { 42 Composite composite = new Composite(parent, SWT.NONE); 43 GridLayout layout = new GridLayout(); 44 layout.numColumns = 2; 45 layout.marginHeight = layout.marginWidth = 0; 46 composite.setLayout(layout); 47 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 48 49 try { 50 IResource resource = getSelectedElement(); 51 if (resource != null) { 52 ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); 53 if (!cvsResource.isManaged()) { 54 createPair(composite, CVSUIMessages.ResourcePropertiesPage_status, CVSUIMessages.ResourcePropertiesPage_notManaged); } else { 56 boolean hasRemote = false; 57 if(cvsResource.isFolder()) { 58 hasRemote = ((ICVSFolder)cvsResource).isCVSFolder(); 59 } else { 60 ResourceSyncInfo info = cvsResource.getSyncInfo(); 61 if(info!=null && !info.isAdded()) { 62 hasRemote = true; 63 } 64 } 65 createPair(composite, CVSUIMessages.ResourcePropertiesPage_status, hasRemote ? CVSUIMessages.ResourcePropertiesPage_versioned : CVSUIMessages.ResourcePropertiesPage_notVersioned); } 67 } 68 } catch (TeamException e) { 69 createPair(composite, CVSUIMessages.ResourcePropertiesPage_error, e.getMessage()); 70 } 71 Dialog.applyDialogFont(parent); 72 return composite; 73 } 74 75 82 protected void createPair(Composite parent, String left, String right) { 83 Label label = new Label(parent, SWT.NONE); 84 label.setText(left); 85 86 label = new Label(parent, SWT.NONE); 87 label.setText(right); 88 label.setToolTipText(right); 89 label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 90 } 91 92 97 protected IResource getSelectedElement() { 98 IResource resource = null; 100 IAdaptable element = getElement(); 101 if (element instanceof IResource) { 102 resource = (IResource)element; 103 } else { 104 Object adapter = element.getAdapter(IResource.class); 105 if (adapter instanceof IResource) { 106 resource = (IResource)adapter; 107 } 108 } 109 return resource; 110 } 111 } 112 | Popular Tags |