# Class SaveableHelper

java.lang.Object
org.eclipse.ui.internal.SaveableHelper

public class SaveableHelper extends Object
Helper class for prompting to save dirty views or editors.

Since:
  3.0.1

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`USER_RESPONSE`
The helper must prompt.

## Constructor Summary

Constructors
Constructor
Description
`SaveableHelper()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`doSaveModel(Saveable model, IProgressMonitor progressMonitor, IShellProvider shellProvider, boolean blockUntilSaved)`
`static ISaveablePart`
`getSaveable(Object o)`
`static ISaveablePart2`
`getSaveable2(Object o)`
`static boolean`
`isDirtyStateSupported(IWorkbenchPart part)`
`static boolean`
`isSaveable(Object o)`
`static boolean`
`isSaveable2(Object o)`
`static boolean`
`needsSave(ISaveablesSource modelSource)`
Returns whether the model source needs saving.
`static boolean`
`savePart(ISaveablePart saveable, IWorkbenchPart part, IWorkbenchWindow window, boolean confirm)`
Saves the workbench part.
`static int`
`testGetAutomatedResponse()`
FOR USE BY THE AUTOMATED TEST HARNESS ONLY.
`static void`
`testSetAutomatedResponse(int response)`
FOR USE BY THE AUTOMATED TEST HARNESS ONLY.
`static boolean`
`waitForBackgroundSaveJobs(List modelsToSave)`
Waits for the background save jobs (if any) of the given saveables to complete.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### USER_RESPONSE

public static final int USER_RESPONSE
The helper must prompt.

See Also:
  - Constant Field Values

## Constructor Details

### SaveableHelper

public SaveableHelper()

## Method Details

### testSetAutomatedResponse

public static void testSetAutomatedResponse(int response)
FOR USE BY THE AUTOMATED TEST HARNESS ONLY. Sets the response to use when `savePart` is called with `confirm=true`.

Parameters:
  `response` - 0 for yes, 1 for no, 2 for cancel, -1 for default (prompt)

### testGetAutomatedResponse

public static int testGetAutomatedResponse()
FOR USE BY THE AUTOMATED TEST HARNESS ONLY. Sets the response to use when `savePart` is called with `confirm=true`.

Returns:
  0 for yes, 1 for no, 2 for cancel, -1 for default (prompt)

### savePart

public static boolean savePart(ISaveablePart saveable, IWorkbenchPart part, IWorkbenchWindow window, boolean confirm)
Saves the workbench part.

Parameters:
  `saveable` - the part
  `part` - the same part
  `window` - the workbench window
  `confirm` - request confirmation
Returns:
  `true` for continue, `false` if the operation was canceled.

### needsSave

public static boolean needsSave(ISaveablesSource modelSource)
Returns whether the model source needs saving. This is true if any of the active models are dirty. This logic must correspond with `saveModels(ISaveablesSource, IWorkbenchWindow, boolean)` above.

Parameters:
  `modelSource` - the model source
Returns:
  `true` if save is required, `false` otherwise
Since:
  3.2

### doSaveModel

public static void doSaveModel(Saveable model, IProgressMonitor progressMonitor, IShellProvider shellProvider, boolean blockUntilSaved)

### waitForBackgroundSaveJobs

public static boolean waitForBackgroundSaveJobs(List modelsToSave)
Waits for the background save jobs (if any) of the given saveables to complete. This may open a progress dialog with the option to cancel.

Returns:
  true if the user canceled.

### getSaveable

public static ISaveablePart getSaveable(Object o)

### isSaveable

public static boolean isSaveable(Object o)

### getSaveable2

public static ISaveablePart2 getSaveable2(Object o)

### isSaveable2

public static boolean isSaveable2(Object o)

### isDirtyStateSupported

public static boolean isDirtyStateSupported(IWorkbenchPart part)