1 11 package org.eclipse.team.ui.synchronize; 12 13 import org.eclipse.compare.CompareUI; 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.jface.dialogs.IDialogConstants; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.widgets.*; 18 import org.eclipse.team.internal.ui.TeamUIMessages; 19 import org.eclipse.team.ui.*; 20 21 32 public class ParticipantPageDialog extends SaveablePartDialog { 33 34 private ISynchronizeParticipant participant; 35 private Button rememberParticipantButton; 36 37 45 public ParticipantPageDialog(Shell shell, SaveablePartAdapter input, ISynchronizeParticipant participant) { 46 super(shell, input); 47 this.participant = participant; 48 } 49 50 53 protected Control createDialogArea(Composite parent2) { 54 Composite parent = (Composite) super.createDialogArea(parent2); 55 if (isOfferToRememberParticipant() && participant != null && ! particantRegisteredWithSynchronizeManager(participant)) { 56 rememberParticipantButton = new Button(parent, SWT.CHECK); 57 rememberParticipantButton.setText(TeamUIMessages.ParticipantCompareDialog_1); 58 } 59 Dialog.applyDialogFont(parent2); 60 return parent; 61 } 62 63 66 protected void buttonPressed(int buttonId) { 67 if(buttonId == IDialogConstants.OK_ID && isRememberParticipant()) { 68 rememberParticipant(); 69 } 70 super.buttonPressed(buttonId); 71 } 72 73 private boolean isRememberParticipant() { 74 return getParticipant() != null && rememberParticipantButton != null && rememberParticipantButton.getSelection(); 75 } 76 77 private boolean particantRegisteredWithSynchronizeManager(ISynchronizeParticipant participant) { 78 return TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) != null; 79 } 80 81 private void rememberParticipant() { 82 if(getParticipant() != null) { 83 ISynchronizeManager mgr = TeamUI.getSynchronizeManager(); 84 ISynchronizeView view = mgr.showSynchronizeViewInActivePage(); 85 mgr.addSynchronizeParticipants(new ISynchronizeParticipant[] {getParticipant()}); 86 view.display(participant); 87 } 88 } 89 90 95 protected ISynchronizeParticipant getParticipant() { 96 return participant; 97 } 98 99 107 protected boolean isOfferToRememberParticipant() { 108 return true; 109 } 110 } 111 | Popular Tags |