1 11 package org.eclipse.team.internal.ui.mapping; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.compare.CompareConfiguration; 16 import org.eclipse.jface.dialogs.IDialogConstants; 17 import org.eclipse.jface.dialogs.ProgressMonitorDialog; 18 import org.eclipse.jface.operation.IRunnableContext; 19 import org.eclipse.jface.operation.IRunnableWithProgress; 20 import org.eclipse.swt.widgets.*; 21 import org.eclipse.team.core.mapping.IMergeContext; 22 import org.eclipse.team.core.mapping.ISynchronizationContext; 23 import org.eclipse.team.internal.ui.TeamUIMessages; 24 import org.eclipse.team.ui.SaveablePartAdapter; 25 import org.eclipse.team.ui.synchronize.*; 26 27 public final class ModelParticipantPageDialog extends ParticipantPageDialog { 28 29 32 private static final int DONE_ID = IDialogConstants.CLIENT_ID + 1; 33 private static final int REPLACE_ID = IDialogConstants.CLIENT_ID + 2; 34 35 private final ModelSynchronizeParticipant participant; 36 private Button doneButton; 37 private Button replaceButton; 38 39 public ModelParticipantPageDialog(Shell shell, ModelSynchronizeParticipant participant, CompareConfiguration cc, ISynchronizePageConfiguration pc) { 40 super(shell, createInput(shell, participant, cc, pc), participant); 41 this.participant = participant; 42 pc.setRunnableContext(new IRunnableContext() { 43 public void run(boolean fork, boolean cancelable, 44 IRunnableWithProgress runnable) throws InvocationTargetException , 45 InterruptedException { 46 ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); 47 dialog.run(fork, cancelable, runnable); 48 } 49 }); 50 } 51 52 private static SaveablePartAdapter createInput(Shell shell, ModelSynchronizeParticipant participant, CompareConfiguration cc, ISynchronizePageConfiguration pc) { 53 ParticipantPageSaveablePart input = new ParticipantPageSaveablePart(shell, cc, pc, participant); 54 return input; 55 } 56 57 60 public boolean close() { 61 boolean close = super.close(); 62 if (close) { 63 getInput().dispose(); 64 } 65 return close; 66 } 67 68 71 protected boolean isOfferToRememberParticipant() { 72 if (isReplace()) 73 return false; 74 return super.isOfferToRememberParticipant(); 75 } 76 77 private boolean isReplace() { 78 return ((IMergeContext)participant.getContext()).getMergeType() == ISynchronizationContext.TWO_WAY; 79 } 80 81 84 protected void createButtonsForButtonBar(Composite parent) { 85 boolean isReplace = isReplace(); 86 isReplace = false; if (isReplace) { 88 replaceButton = createButton(parent, REPLACE_ID, TeamUIMessages.ModelParticipantPageDialog_0, true); 89 replaceButton.setEnabled(true); 90 } 91 doneButton = createButton(parent, DONE_ID, TeamUIMessages.ResourceMappingMergeOperation_2, !isReplace); 92 doneButton.setEnabled(true); 93 } 95 96 99 protected void buttonPressed(int buttonId) { 100 if (buttonId == DONE_ID) { 101 super.buttonPressed(IDialogConstants.OK_ID); 102 } else if (buttonId == REPLACE_ID) { 103 super.buttonPressed(IDialogConstants.OK_ID); 134 } else { 135 super.buttonPressed(buttonId); 136 } 137 } 138 } | Popular Tags |