1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.compare.CompareConfiguration; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.swt.widgets.Shell; 17 import org.eclipse.team.internal.ui.TeamUIMessages; 18 import org.eclipse.team.internal.ui.Utils; 19 import org.eclipse.team.ui.TeamUI; 20 import org.eclipse.team.ui.synchronize.*; 21 import org.eclipse.ui.actions.ActionFactory; 22 23 public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubscriberListener { 24 25 private SubscriberParticipant participant; 26 private ISynchronizePageConfiguration configuration; 27 private Shell shell; 28 private String title; 29 30 public RefreshUserNotificationPolicyInModalDialog(Shell shell, String title, ISynchronizePageConfiguration configuration, SubscriberParticipant participant) { 31 this.title = title; 32 this.configuration = configuration; 33 this.participant = participant; 34 this.shell = shell; 35 } 36 37 public void refreshStarted(IRefreshEvent event) { 38 } 39 40 public ActionFactory.IWorkbenchAction refreshDone(final IRefreshEvent event) { 41 if (event.getParticipant() != participant) 43 return null; 44 int severity = event.getStatus().getSeverity(); 46 if(severity == IStatus.CANCEL || severity == IStatus.ERROR) 47 return null; 48 49 return new WorkbenchAction() { 50 public void run() { 51 if (event.getStatus().getCode() == IRefreshEvent.STATUS_NO_CHANGES) { 53 MessageDialog.openInformation(shell, TeamUIMessages.OpenComparedDialog_noChangeTitle, TeamUIMessages.OpenComparedDialog_noChangesMessage); return; 55 } 56 compareAndOpenDialog(event, participant); 57 setEnabled(false); 58 } 59 public void dispose() { 60 if (TeamUI.getSynchronizeManager().get(participant.getId(), participant.getSecondaryId()) == null) { 61 participant.dispose(); 62 } 63 } 64 }; 65 } 66 67 protected void compareAndOpenDialog(final IRefreshEvent event, final SubscriberParticipant participant) { 68 CompareConfiguration cc = new CompareConfiguration(); 69 ParticipantPageSaveablePart input = new ParticipantPageSaveablePart(Utils.getShell(null), cc, configuration, participant) { 70 public String getTitle() { 71 return RefreshUserNotificationPolicyInModalDialog.this.title; 72 } 73 }; 74 try { 75 ParticipantPageDialog dialog = new ParticipantPageDialog(shell, input, participant); 76 dialog.setBlockOnOpen(true); 77 dialog.open(); 78 } finally { 79 input.dispose(); 80 } 81 } 82 } 83 | Popular Tags |