1 11 package org.eclipse.team.internal.ui.synchronize.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.compare.structuremergeviewer.IDiffElement; 16 import org.eclipse.core.resources.IWorkspaceRunnable; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.jface.dialogs.MessageDialogWithToggle; 20 import org.eclipse.jface.preference.IPreferenceStore; 21 import org.eclipse.jface.window.Window; 22 import org.eclipse.team.core.synchronize.SyncInfoSet; 23 import org.eclipse.team.internal.core.subscribers.WorkingSetFilteredSyncInfoCollector; 24 import org.eclipse.team.internal.ui.*; 25 import org.eclipse.team.internal.ui.synchronize.SubscriberParticipantPage; 26 import org.eclipse.team.ui.synchronize.ISynchronizePage; 27 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 28 import org.eclipse.team.ui.synchronize.SynchronizeModelAction; 29 import org.eclipse.team.ui.synchronize.SynchronizeModelOperation; 30 31 34 public class RemoveFromViewAction extends SynchronizeModelAction { 35 36 public RemoveFromViewAction(ISynchronizePageConfiguration configuration) { 37 super(null, configuration); 38 Utils.initAction(this, "action.removeFromView."); } 40 41 44 public void run() { 45 if (confirmRemove()) { 46 super.run(); 47 } 48 } 49 50 53 protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { 54 return new SynchronizeModelOperation(configuration, elements) { 55 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 56 SyncInfoSet set = getSyncInfoSet(); 57 removeFromView(set); 58 } 59 protected boolean canRunAsJob() { 60 return false; 61 } 62 66 private void removeFromView(final SyncInfoSet set) { 67 ISynchronizePage page = getConfiguration().getPage(); 68 if (page instanceof SubscriberParticipantPage) { 69 final WorkingSetFilteredSyncInfoCollector collector = ((SubscriberParticipantPage)page).getCollector(); 70 collector.run(new IWorkspaceRunnable() { 71 public void run(IProgressMonitor monitor) throws CoreException { 72 collector.getWorkingSetSyncInfoSet().removeAll(set.getResources()); 73 } 74 }); 75 } 76 } 77 }; 78 } 79 80 83 protected boolean needsToSaveDirtyEditors() { 84 return false; 85 } 86 87 private boolean confirmRemove() { 88 IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); 89 if (store.getBoolean(IPreferenceIds.SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT)) { 90 return true; 91 } else { 92 MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm( 93 getConfiguration().getSite().getShell(), 94 TeamUIMessages.RemoveFromView_warningTitle, 95 TeamUIMessages.RemoveFromView_warningMessage, 96 TeamUIMessages.RemoveFromView_warningDontShow, 97 false, 98 null, 99 null); 100 store.setValue(IPreferenceIds.SYNCVIEW_REMOVE_FROM_VIEW_NO_PROMPT, dialog.getToggleState()); 101 return dialog.getReturnCode() == Window.OK; 102 } 103 } 104 } 105 | Popular Tags |