|
Lines 13-19
Link Here
|
| 13 |
|
13 |
|
| 14 |
import org.eclipse.core.runtime.CoreException; |
14 |
import org.eclipse.core.runtime.CoreException; |
| 15 |
import org.eclipse.core.runtime.IProgressMonitor; |
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
16 |
import org.eclipse.core.runtime.IStatus; |
| 17 |
import org.eclipse.core.runtime.jobs.Job; |
| 16 |
import org.eclipse.jface.resource.ImageDescriptor; |
18 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
|
19 |
import org.eclipse.jface.window.IShellProvider; |
| 17 |
|
20 |
|
| 18 |
/** |
21 |
/** |
| 19 |
* A <code>Saveable</code> represents a unit of saveability, e.g. an editable |
22 |
* A <code>Saveable</code> represents a unit of saveability, e.g. an editable |
|
Lines 43-48
Link Here
|
| 43 |
* @since 3.3 |
46 |
* @since 3.3 |
| 44 |
*/ |
47 |
*/ |
| 45 |
public boolean show(IWorkbenchPage page) { |
48 |
public boolean show(IWorkbenchPage page) { |
|
|
49 |
if (page == null) { |
| 50 |
// I wish it was easier to avoid warnings about unused parameters |
| 51 |
} |
| 46 |
return false; |
52 |
return false; |
| 47 |
} |
53 |
} |
| 48 |
|
54 |
|
|
Lines 142-145
Link Here
|
| 142 |
*/ |
148 |
*/ |
| 143 |
public abstract int hashCode(); |
149 |
public abstract int hashCode(); |
| 144 |
|
150 |
|
|
|
151 |
/** |
| 152 |
* Saves this saveable, or prepares this saveable for a background save |
| 153 |
* operation. Returns null if this saveable has been successfully saved, or |
| 154 |
* a job that needs to be run to complete the save in the background. This |
| 155 |
* method is called in the UI thread. If this saveable supports saving in |
| 156 |
* the background, it should do only minimal work. However, since the job |
| 157 |
* returned by this method (if any) will not run on the UI thread, this |
| 158 |
* method should copy any state that can only be accessed from the UI thread |
| 159 |
* so that the background job will be able to access it. |
| 160 |
* <p> |
| 161 |
* The supplied shell provider can be used from within this method and from |
| 162 |
* within the job for the purpose of parenting dialogs. Care should be taken |
| 163 |
* not to open dialogs gratuitously and only if user input is required for |
| 164 |
* cases where the save cannot otherwise proceed - note that in any given |
| 165 |
* save operation, many saveable objects may be saved at the same time. In |
| 166 |
* particular, errors should be signaled by throwing an exception, or if an |
| 167 |
* error occurs while running the background job, an error status should be |
| 168 |
* returned. |
| 169 |
* </p> |
| 170 |
* <p> |
| 171 |
* Saveables that can be saved in the background should ensure that the user |
| 172 |
* cannot make changes to their data from the UI, for example by disabling |
| 173 |
* controls, unless they are prepared to handle this case. The |
| 174 |
* <code>closing</code> flag indicates that this saveable is saved in |
| 175 |
* response to closing a workbench part, in which case further changes to |
| 176 |
* this saveable through the UI must be prevented if a background save job |
| 177 |
* is returned. |
| 178 |
* </p> |
| 179 |
* <p> |
| 180 |
* If the foreground part of the save is cancelled through user action, or |
| 181 |
* for any other reason, the part should invoke <code>setCancelled</code> |
| 182 |
* on the <code>IProgressMonitor</code> to inform the caller. If the |
| 183 |
* background part of the save is cancelled, the job should return a |
| 184 |
* {@link IStatus#CANCEL} status. |
| 185 |
* </p> |
| 186 |
* <p> |
| 187 |
* This method is long-running; progress and cancellation are provided by |
| 188 |
* the given progress monitor. |
| 189 |
* </p> |
| 190 |
* <p> |
| 191 |
* The default implementation of this method calls |
| 192 |
* {@link #doSave(IProgressMonitor)} and returns <code>null</code>. |
| 193 |
* </p> |
| 194 |
* |
| 195 |
* @param monitor |
| 196 |
* a progress monitor used for reporting progress and |
| 197 |
* cancellation |
| 198 |
* @param shellProvider |
| 199 |
* an object that can provide a shell for parenting dialogs |
| 200 |
* @param closing |
| 201 |
* a boolean flag indicating whether the save was triggered by a |
| 202 |
* request to close a workbench part |
| 203 |
* @return <code>null</code> if this saveable has been saved successfully, |
| 204 |
* or a job that needs to be run to complete the save in the |
| 205 |
* background. |
| 206 |
* |
| 207 |
* @since 3.3 |
| 208 |
*/ |
| 209 |
public Job doSave(IProgressMonitor monitor, IShellProvider shellProvider, |
| 210 |
boolean closing) throws CoreException { |
| 211 |
doSave(monitor); |
| 212 |
return null; |
| 213 |
} |
| 214 |
|
| 145 |
} |
215 |
} |