1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.resources.IFolder; 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.jface.dialogs.*; 19 import org.eclipse.jface.dialogs.Dialog; 20 import org.eclipse.jface.operation.IRunnableWithProgress; 21 import org.eclipse.jface.preference.PreferencePage; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.layout.GridData; 24 import org.eclipse.swt.layout.GridLayout; 25 import org.eclipse.swt.widgets.*; 26 import org.eclipse.team.core.TeamException; 27 import org.eclipse.team.internal.ccvs.core.*; 28 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 29 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; 30 import org.eclipse.team.internal.ccvs.core.util.Util; 31 import org.eclipse.ui.PlatformUI; 32 33 public class CVSFolderPropertiesPage extends CVSPropertiesPage { 34 35 IFolder folder; 36 private Label root; 37 private Label repository; 38 39 42 protected Control createContents(Composite parent) { 43 initialize(); 44 noDefaultAndApplyButton(); 45 Composite composite = new Composite(parent, SWT.NULL); 46 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 47 GridLayout layout = new GridLayout(); 48 layout.numColumns = 2; 49 composite.setLayout(layout); 50 51 try { 52 ICVSFolder cvsResource = CVSWorkspaceRoot.getCVSFolderFor(folder); 53 if (!cvsResource.isManaged()) { 54 if (cvsResource.isIgnored()) { 55 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_ignored, 2); 56 } else { 57 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_notManaged, 2); 58 } 59 } else if (!cvsResource.isCVSFolder()) { 60 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_notCVSFolder, 2); 63 } else { 64 FolderSyncInfo syncInfo = cvsResource.getFolderSyncInfo(); 65 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_root); 66 root = createLabel(composite, syncInfo.getRoot()); 67 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_repository); 68 repository = createLabel(composite, syncInfo.getRepository()); 69 70 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_tag); 72 CVSTag tag = syncInfo.getTag(); 73 74 if (tag != null && tag.getType() == CVSTag.BRANCH) { 75 tag = Util.getAccurateFolderTag(folder, tag); 76 } 77 78 createLabel(composite, getTagLabel(tag)); 79 80 if (syncInfo.getIsStatic()) { 82 createLabel(composite, CVSUIMessages.CVSFolderPropertiesPage_static); 83 createLabel(composite, syncInfo.getIsStatic() ? CVSUIMessages.yes : CVSUIMessages.no); } 85 86 createLabel(composite, "", 2); 88 final Button disconnect = new Button(composite, SWT.NONE); 90 disconnect.setText(CVSUIMessages.CVSFolderPropertiesPage_disconnect); 91 GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); 92 int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); 93 data.widthHint = Math.max(widthHint, disconnect.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); 94 disconnect.setLayoutData(data); 95 disconnect.addListener(SWT.Selection, new Listener() { 96 public void handleEvent (Event event) { 97 if (disconnectFolder()) { 99 root.setText(CVSUIMessages.CVSFilePropertiesPage_none); 100 repository.setText(CVSUIMessages.CVSFilePropertiesPage_none); 101 disconnect.setEnabled(false); 102 } 103 } 104 }); 105 } 106 } catch (TeamException e) { 107 createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_error, 2); 109 } 110 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FOLDER_PROPERTY_PAGE); 111 Dialog.applyDialogFont(parent); 112 return composite; 113 } 114 115 123 protected Label createLabel(Composite parent, String text, int span) { 124 Label label = new Label(parent, SWT.LEFT); 125 label.setText(text); 126 GridData data = new GridData(); 127 data.horizontalSpan = span; 128 data.horizontalAlignment = GridData.FILL; 129 label.setLayoutData(data); 130 return label; 131 } 132 133 protected Label createLabel(Composite parent, String text) { 134 return createLabel(parent, text, 1); 135 } 136 139 private void initialize() { 140 folder = null; 142 IAdaptable element = getElement(); 143 if (element instanceof IFolder) { 144 folder = (IFolder)element; 145 } else { 146 Object adapter = element.getAdapter(IFolder.class); 147 if (adapter instanceof IFolder) { 148 folder = (IFolder)adapter; 149 } 150 } 151 } 152 153 private boolean disconnectFolder() { 154 if (MessageDialog.openQuestion(getShell(), CVSUIMessages.CVSFolderPropertiesPage_disconnectTitle, CVSUIMessages.CVSFolderPropertiesPage_disconnectQuestion)) { final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); 156 try { 157 PlatformUI.getWorkbench().getProgressService().run(true, false, new IRunnableWithProgress() { 158 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 159 try { 160 cvsFolder.unmanage(null); 161 } catch (CVSException e) { 162 throw new InvocationTargetException (e); 163 } 164 } 165 }); 166 } catch (InvocationTargetException e) { 167 CVSUIPlugin.openError(getShell(), null, null, e); 168 return false; 169 } catch (InterruptedException e) { 170 } 172 return true; 173 } else { 174 return false; 175 } 176 } 177 } 178 | Popular Tags |