diff options
author | Michael Valenta | 2004-05-11 14:59:28 +0000 |
---|---|---|
committer | Michael Valenta | 2004-05-11 14:59:28 +0000 |
commit | c8f32e909541c63f10642cd6bfa9f42bcc840dbf (patch) | |
tree | e6f276ac393f7c6a5e9ed17aaeeac94aa5a06068 | |
parent | 40108d3b19d8f8178d70c8b31c56ae69c61348dc (diff) | |
download | eclipse.platform.team-c8f32e909541c63f10642cd6bfa9f42bcc840dbf.tar.gz eclipse.platform.team-c8f32e909541c63f10642cd6bfa9f42bcc840dbf.tar.xz eclipse.platform.team-c8f32e909541c63f10642cd6bfa9f42bcc840dbf.zip |
Use IDE API for saving dirty editors
-rw-r--r-- | bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java index eb080c251..8c7ca2a8f 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java @@ -12,15 +12,9 @@ package org.eclipse.team.ui.synchronize; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.List; import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; @@ -32,12 +26,8 @@ import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.BaseSelectionListenerAction; -import org.eclipse.ui.internal.EditorManager; +import org.eclipse.ui.ide.IDE; /** * This action provides utilities for performing operations on selections that @@ -234,44 +224,6 @@ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction * @return boolean false if the operation was cancelled. */ public final boolean saveAllEditors(boolean confirm) { - final boolean finalConfirm = confirm; - final boolean[] result = new boolean[1]; - result[0] = true; - - Platform.run(new SafeRunnable("Error") { //$NON-NLS-1$ - public void run() { - IResource[] resources = Utils.getResources(getFilteredDiffElements()); - if (resources.length == 0) return; - List dirtyEditors = getDirtyFileEditors(Arrays.asList(resources)); - if (dirtyEditors.size() > 0) { - IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (w == null && PlatformUI.getWorkbench().getWorkbenchWindowCount() > 0) - w = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; - result[0] = EditorManager.saveAll(dirtyEditors, finalConfirm, w); - } - } - }); - return result[0]; - } - - /* private */ List getDirtyFileEditors(Collection resources) { - ArrayList dirtyFileEditors = new ArrayList(); - IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - for (int i = 0; i < windows.length; i++) { - IWorkbenchWindow window = windows[i]; - IWorkbenchPage[] pages = window.getPages(); - for (int j = 0; j < pages.length; j++) { - IWorkbenchPage page = pages[j]; - IEditorPart[] dirtyEditors = page.getDirtyEditors(); - for (int k = 0; k < dirtyEditors.length; k++) { - IEditorPart part = dirtyEditors[k]; - IFile file = (IFile) part.getEditorInput().getAdapter(IFile.class); - if (file != null && resources.contains(file)) { - dirtyFileEditors.add(part); - } - } - } - } - return dirtyFileEditors; + return IDE.saveAllEditors(Utils.getResources(getFilteredDiffElements()), confirm); } }
\ No newline at end of file |