Search in sources :

Example 1 with WWinPartServiceSaveHandler

use of org.eclipse.ui.internal.WorkbenchWindow.WWinPartServiceSaveHandler in project eclipse.platform.ui by eclipse-platform.

the class Workbench method saveAllParts.

private boolean saveAllParts(boolean confirm, boolean closing) {
    // Code to handle dirtied Editors and E4 parts too.
    EPartService partService = e4Context.get(EPartService.class);
    if (partService != null) {
        Collection<MPart> parts = getDirtyMParts();
        if (parts != null && parts.size() > 0) {
            MPart selected = null;
            for (MPart part : parts) {
                selected = part;
                break;
            }
            EModelService modelService = e4Context.get(EModelService.class);
            if (modelService != null) {
                IEclipseContext context = modelService.getContainingContext(selected);
                if (context != null) {
                    ISaveHandler saveHandler = context.get(ISaveHandler.class);
                    if (saveHandler != null) {
                        if (saveHandler instanceof WWinPartServiceSaveHandler) {
                            try {
                                return ((WWinPartServiceSaveHandler) saveHandler).saveParts(parts, confirm, true, true);
                            } catch (UnsupportedOperationException e) {
                            // do nothing
                            }
                        }
                    }
                }
            }
        }
    }
    // of E4 parts too.
    return saveAllEditors(confirm, closing);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) ISaveHandler(org.eclipse.e4.ui.workbench.modeling.ISaveHandler) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) WWinPartServiceSaveHandler(org.eclipse.ui.internal.WorkbenchWindow.WWinPartServiceSaveHandler)

Aggregations

IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 EModelService (org.eclipse.e4.ui.workbench.modeling.EModelService)1 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)1 ISaveHandler (org.eclipse.e4.ui.workbench.modeling.ISaveHandler)1 WWinPartServiceSaveHandler (org.eclipse.ui.internal.WorkbenchWindow.WWinPartServiceSaveHandler)1