1 11 package org.eclipse.team.internal.ccvs.ui.merge; 12 13 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.jface.viewers.ISelectionChangedListener; 17 import org.eclipse.jface.viewers.IStructuredSelection; 18 import org.eclipse.jface.viewers.SelectionChangedEvent; 19 import org.eclipse.jface.viewers.TreeViewer; 20 import org.eclipse.jface.viewers.Viewer; 21 import org.eclipse.jface.viewers.ViewerSorter; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.layout.GridData; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Tree; 26 import org.eclipse.team.core.TeamException; 27 import org.eclipse.team.internal.ccvs.core.CVSTag; 28 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder; 29 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 30 import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; 31 import org.eclipse.team.internal.ccvs.ui.Policy; 32 import org.eclipse.team.internal.ccvs.ui.wizards.CVSWizardPage; 33 import org.eclipse.ui.help.WorkbenchHelp; 34 import org.eclipse.ui.model.WorkbenchContentProvider; 35 import org.eclipse.ui.model.WorkbenchLabelProvider; 36 37 public class MergeWizardEndPage extends CVSWizardPage { 38 IProject project; 39 TreeViewer tree; 40 CVSTag result; 41 ICVSRemoteFolder remote; 42 MergeWizardStartPage startPage; 44 45 52 public MergeWizardEndPage(String pageName, String title, ImageDescriptor titleImage, MergeWizardStartPage startPage) { 53 super(pageName, title, titleImage); 54 setDescription(Policy.bind("MergeWizardEndPage.description")); this.startPage = startPage; 56 } 57 60 public void createControl(Composite parent) { 61 Composite composite = createComposite(parent, 2); 62 WorkbenchHelp.setHelp(composite, IHelpContextIds.MERGE_END_PAGE); 64 65 tree = createTree(composite); 66 tree.setContentProvider(new WorkbenchContentProvider()); 67 tree.setLabelProvider(new WorkbenchLabelProvider()); 68 tree.setSorter(new ViewerSorter() { 69 public int compare(Viewer v, Object o1, Object o2) { 70 int result = super.compare(v, o1, o2); 71 if (o1 instanceof TagElement && o2 instanceof TagElement) { 72 return -result; 73 } 74 return result; 75 } 76 }); 77 tree.addSelectionChangedListener(new ISelectionChangedListener() { 78 public void selectionChanged(SelectionChangedEvent event) { 79 Object selected = ((IStructuredSelection)tree.getSelection()).getFirstElement(); 80 if (selected instanceof TagElement) { 81 result = ((TagElement)selected).getTag(); 82 if(!result.equals(startPage.getTag())) { 83 setPageComplete(true); 84 setMessage(null); 85 } else { 86 setMessage(Policy.bind("MergeWizardEndPage.duplicateTagSelected", result.getName()), WARNING); setPageComplete(false); 88 } 89 } else { 90 setMessage(null); 91 result = null; 92 setPageComplete(false); 93 } 94 } 95 }); 96 setControl(composite); 97 tree.setInput(new ProjectElement(CVSWorkspaceRoot.getCVSFolderFor(project), ProjectElement.INCLUDE_ALL_TAGS)); 98 setPageComplete(false); 99 } 100 protected TreeViewer createTree(Composite parent) { 101 Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE); 102 tree.setLayoutData(new GridData(GridData.FILL_BOTH)); 103 return new TreeViewer(tree); 104 } 105 public void setProject(IProject project) { 106 this.project = project; 107 try { 108 this.remote = (ICVSRemoteFolder) CVSWorkspaceRoot.getRemoteResourceFor(project); 109 } catch (TeamException e) { 110 } 112 } 113 public CVSTag getTag() { 114 return result; 115 } 116 119 public void setVisible(boolean visible) { 120 super.setVisible(visible); 121 tree.refresh(); 123 if (visible) { 124 tree.getControl().setFocus(); 125 } 126 } 127 } 128 | Popular Tags |