1 11 12 package org.eclipse.team.ui.synchronize; 13 14 import org.eclipse.compare.CompareViewerPane; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.jface.action.ToolBarManager; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.graphics.Image; 19 import org.eclipse.swt.layout.GridLayout; 20 import org.eclipse.swt.widgets.*; 21 import org.eclipse.team.internal.ui.*; 22 import org.eclipse.team.internal.ui.synchronize.*; 23 import org.eclipse.ui.PartInitException; 24 import org.eclipse.ui.part.IPageBookViewPage; 25 26 33 public final class ParticipantPagePane { 34 35 private ISynchronizeParticipant participant; 36 private ISynchronizePageConfiguration pageConfiguration; 37 private Image titleImage; 38 private Shell shell; 39 private boolean isModal; 40 41 private CompareViewerPane fEditionPane; 43 private IPageBookViewPage fPage; 44 private DialogSynchronizePageSite site; 45 46 58 public ParticipantPagePane(Shell shell, boolean isModal, ISynchronizePageConfiguration pageConfiguration, ISynchronizeParticipant participant) { 59 this.isModal = isModal; 60 this.shell = shell; 61 this.participant = participant; 62 this.pageConfiguration = pageConfiguration; 63 } 64 65 68 public void dispose() { 69 if(titleImage != null) { 70 titleImage.dispose(); 71 } 72 if (fPage != null) { 73 fPage.dispose(); 74 } 75 if (site != null) 76 site.dispose(); 77 } 78 79 82 public Image getTitleImage() { 83 if(titleImage == null) { 84 titleImage = participant.getImageDescriptor().createImage(); 85 } 86 return titleImage; 87 } 88 89 92 public String getTitle() { 93 return Utils.shortenText(SynchronizeView.MAX_NAME_LENGTH, participant.getName()); 94 } 95 96 99 public Control createPartControl(Composite parent) { 100 Composite top = new Composite(parent, SWT.NULL); 101 GridLayout layout = new GridLayout(); 102 layout.marginHeight = 0; 103 layout.marginWidth = 0; 104 layout.verticalSpacing = 0; 105 top.setLayout(layout); 106 107 shell = parent.getShell(); 108 109 fEditionPane = new CompareViewerPane(top, SWT.BORDER | SWT.FLAT); 110 fEditionPane.setText(TeamUIMessages.ParticipantPageSaveablePart_0); 112 fEditionPane.setLayoutData(SWTUtils.createHVFillGridData()); 113 114 fPage = participant.createPage(pageConfiguration); 115 site = new DialogSynchronizePageSite(shell, isModal); 116 ((SynchronizePageConfiguration)pageConfiguration).setSite(site); 117 ToolBarManager tbm = CompareViewerPane.getToolBarManager(fEditionPane); 118 site.createActionBars(tbm); 119 try { 120 ((ISynchronizePage)fPage).init(pageConfiguration.getSite()); 121 } catch (PartInitException e1) { 122 TeamUIPlugin.log(IStatus.ERROR, TeamUIMessages.ParticipantPagePane_0, e1); 123 } 124 125 fPage.createControl(fEditionPane); 126 fPage.setActionBars(site.getActionBars()); 127 fEditionPane.setContent(fPage.getControl()); 128 tbm.update(true); 129 130 return top; 131 } 132 133 138 public ISynchronizePageConfiguration getPageConfiguration() { 139 return pageConfiguration; 140 } 141 142 147 public ISynchronizeParticipant getParticipant() { 148 return participant; 149 } 150 } 151 | Popular Tags |