1 11 12 package org.eclipse.ui; 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IAdaptable; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.jface.resource.ImageDescriptor; 19 import org.eclipse.jface.window.IShellProvider; 20 import org.eclipse.swt.SWT; 21 import org.eclipse.swt.graphics.Cursor; 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.swt.widgets.Control; 24 import org.eclipse.ui.internal.InternalSaveable; 25 import org.eclipse.ui.internal.PartSite; 26 import org.eclipse.ui.progress.IJobRunnable; 27 28 45 public abstract class Saveable extends InternalSaveable implements IAdaptable { 46 47 private Cursor waitCursor; 48 private Cursor originalCursor; 49 50 60 public boolean show(IWorkbenchPage page) { 61 if (page == null) { 62 } 64 return false; 65 } 66 67 72 public abstract String getName(); 73 74 82 public abstract String getToolTipText(); 83 84 90 public abstract ImageDescriptor getImageDescriptor(); 91 92 110 public abstract void doSave(IProgressMonitor monitor) throws CoreException; 111 112 124 public abstract boolean isDirty(); 125 126 137 public abstract boolean equals(Object object); 138 139 161 public abstract int hashCode(); 162 163 210 public IJobRunnable doSave(IProgressMonitor monitor, 211 IShellProvider shellProvider) throws CoreException { 212 doSave(monitor); 213 return null; 214 } 215 216 245 public void disableUI(IWorkbenchPart[] parts, boolean closing) { 246 for (int i = 0; i < parts.length; i++) { 247 IWorkbenchPart workbenchPart = parts[i]; 248 Composite paneComposite = (Composite) ((PartSite) workbenchPart 249 .getSite()).getPane().getControl(); 250 Control[] paneChildren = paneComposite.getChildren(); 251 Composite toDisable = ((Composite) paneChildren[0]); 252 toDisable.setEnabled(false); 253 if (waitCursor == null) { 254 waitCursor = new Cursor(workbenchPart.getSite().getWorkbenchWindow().getShell().getDisplay(), SWT.CURSOR_WAIT); 255 } 256 originalCursor = paneComposite.getCursor(); 257 paneComposite.setCursor(waitCursor); 258 } 259 } 260 261 275 public void enableUI(IWorkbenchPart[] parts) { 276 for (int i = 0; i < parts.length; i++) { 277 IWorkbenchPart workbenchPart = parts[i]; 278 Composite paneComposite = (Composite) ((PartSite) workbenchPart 279 .getSite()).getPane().getControl(); 280 Control[] paneChildren = paneComposite.getChildren(); 281 Composite toEnable = ((Composite) paneChildren[0]); 282 paneComposite.setCursor(originalCursor); 283 if (waitCursor!=null && !waitCursor.isDisposed()) { 284 waitCursor.dispose(); 285 waitCursor = null; 286 } 287 toEnable.setEnabled(true); 288 } 289 } 290 291 300 public Object getAdapter(Class adapter) { 301 return null; 302 } 303 } 304 | Popular Tags |