Bug 270007 - [GlobalActions] Registering actions should not be required to Modify the Save/Save All to work in 4.2
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java index 20a447e..2e0f4f0 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java
@@ -2186,6 +2186,23 @@ return dirtyEditors.toArray(new IEditorPart[dirtyEditors.size()]); } + public ISaveablePart[] getDirtyParts() { + List result = new ArrayList(3); + IWorkbenchPartReference[] allParts = getSortedParts(); + for (int i = 0; i < allParts.length; i++) { + IWorkbenchPartReference reference = allParts[i]; + + IWorkbenchPart part = reference.getPart(false); + if (part != null && part instanceof ISaveablePart) { + ISaveablePart saveable = (ISaveablePart) part; + if (saveable.isDirty()) { + result.add(saveable); + } + } + } + + return (ISaveablePart[]) result.toArray(new ISaveablePart[result.size()]); + } /* * (non-Javadoc) * @@ -3375,7 +3392,7 @@ return saveAllEditors(confirm, false); } - boolean saveAllEditors(boolean confirm, boolean closing) { + public boolean saveAllEditors(boolean confirm, boolean closing) { List<MPart> dirtyParts = new ArrayList<MPart>(); // find all the dirty parts in this window for (MPart currentPart : modelService.findElements(window, null, MPart.class, null)) {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java index 0214be7..f3da25d 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/SaveHandler.java
@@ -58,7 +58,7 @@ // if view IWorkbenchPart activePart = HandlerUtil.getActivePart(event); WorkbenchPage page = (WorkbenchPage) activePart.getSite().getPage(); - page.savePart(saveablePart, activePart, false); + page.saveSaveable(saveablePart, false, false); return null;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java index 76311c4..1982e9f 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
@@ -75,7 +75,6 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchCommandConstants; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; @@ -83,7 +82,6 @@ import org.eclipse.ui.commands.ICommandImageService; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.internal.ActionDescriptor; -import org.eclipse.ui.internal.OpenPreferencesAction; import org.eclipse.ui.internal.PluginAction; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.WorkbenchWindow; @@ -953,42 +951,7 @@ public static MMenuItem createItem(MApplication application, ActionContributionItem item) { IAction action = item.getAction(); String id = action.getActionDefinitionId(); - if (action instanceof OpenPreferencesAction) { - for (MCommand command : application.getCommands()) { - if (IWorkbenchCommandConstants.WINDOW_PREFERENCES.equals(command.getElementId())) { - MHandledMenuItem menuItem = MenuFactoryImpl.eINSTANCE.createHandledMenuItem(); - menuItem.setCommand(command); - menuItem.setLabel(command.getCommandName()); - menuItem.setIconURI(getIconURI(action.getImageDescriptor(), - application.getContext())); - - // extract the mnemonic definition - String text = action.getText(); - int index = text.indexOf('&'); - if (index != -1 && index != text.length() - 1) { - menuItem.setMnemonics(text.substring(index + 1, index + 2)); - } - - switch (action.getStyle()) { - case IAction.AS_CHECK_BOX: - menuItem.setType(ItemType.CHECK); - menuItem.setSelected(action.isChecked()); - break; - case IAction.AS_RADIO_BUTTON: - menuItem.setType(ItemType.RADIO); - menuItem.setSelected(action.isChecked()); - break; - default: - menuItem.setType(ItemType.PUSH); - break; - } - - String itemId = item.getId(); - menuItem.setElementId(itemId == null ? id : itemId); - return menuItem; - } - } - } else if (id != null) { + if (id != null) { for (MCommand command : application.getCommands()) { if (id.equals(command.getElementId())) {