diff options
| author | Paul Elder | 2014-02-10 18:19:07 +0000 |
|---|---|---|
| committer | Gerrit Code Review @ Eclipse.org | 2014-02-12 20:00:46 +0000 |
| commit | 14734da604e6240048c4d62ef1279c9c7787d6a2 (patch) | |
| tree | 242a05e8d662b136240a31b108d03629f71152ce | |
| parent | fd0b26907e29078831273c078e6814cd37adb9ed (diff) | |
| download | eclipse.platform.ui-14734da604e6240048c4d62ef1279c9c7787d6a2.tar.gz eclipse.platform.ui-14734da604e6240048c4d62ef1279c9c7787d6a2.tar.xz eclipse.platform.ui-14734da604e6240048c4d62ef1279c9c7787d6a2.zip | |
Bug 396318: Save Resources dialog missing when selecting Close All from
editor tab
A simple fix that takes advantage of an ISaveHandler, if present.
Change-Id: I4f908d68367cd50dbfee24e37432ab3419f72cf4
| -rw-r--r-- | bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java index 969c1616dc5..34be5553b9c 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,6 +51,8 @@ import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.e4.ui.workbench.UIEvents.EventTags; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.eclipse.e4.ui.workbench.modeling.ISaveHandler; +import org.eclipse.e4.ui.workbench.modeling.ISaveHandler.Save; import org.eclipse.e4.ui.workbench.swt.util.ISWTResourceUtilities; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.LegacyActionTools; @@ -1359,6 +1361,7 @@ public class StackRenderer extends LazyStackRenderer { EPartService.class); if (partService.savePart(part, true)) partService.hidePart(part); + } }); closeableElements++; @@ -1461,6 +1464,34 @@ public class StackRenderer extends LazyStackRenderer { EPartService partService = getContextForParent(part).get( EPartService.class); + // try using the ISaveHandler first... This gives better control of + // dialogs... + ISaveHandler saveHandler = getContextForParent(part).get( + ISaveHandler.class); + if (saveHandler != null) { + final List<MPart> toPrompt = new ArrayList<MPart>(others); + toPrompt.retainAll(partService.getDirtyParts()); + + final Save[] response = saveHandler.promptToSave(toPrompt); + final List<MPart> toSave = new ArrayList<MPart>(toPrompt.size()); + for (int i = 0; i < response.length; i++) { + final Save save = response[i]; + final MPart mPart = toPrompt.get(i); + if (save == Save.CANCEL) { + return; + } else if (save == Save.YES) { + toSave.add(mPart); + } + } + saveHandler.saveParts(toSave, false); + + for (MPart other : others) { + partService.hidePart(other); + } + return; + } + + // No ISaveHandler, fall back to just using the part service... for (MPart otherPart : others) { if (partService.savePart(otherPart, true)) partService.hidePart(otherPart); |
