1 11 12 package org.eclipse.ui.navigator; 13 14 import org.eclipse.core.runtime.IAdaptable; 15 import org.eclipse.ui.ISaveablesLifecycleListener; 16 import org.eclipse.ui.Saveable; 17 import org.eclipse.ui.SaveablesLifecycleEvent; 18 import org.eclipse.ui.services.IDisposable; 19 20 32 public abstract class SaveablesProvider implements IDisposable { 33 34 private ISaveablesLifecycleListener listener; 35 36 40 protected SaveablesProvider() { 41 } 42 43 48 final public void init(ISaveablesLifecycleListener listener) { 49 this.listener = listener; 50 doInit(); 51 } 52 53 56 protected void doInit() { 57 } 58 59 65 final protected void fireSaveablesOpened(Saveable[] models) { 66 listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, 67 SaveablesLifecycleEvent.POST_OPEN, models, false)); 68 } 69 70 80 final protected boolean fireSaveablesClosing(Saveable[] models, 81 boolean force) { 82 SaveablesLifecycleEvent saveablesLifecycleEvent = new SaveablesLifecycleEvent( 83 this, SaveablesLifecycleEvent.PRE_CLOSE, models, force); 84 listener.handleLifecycleEvent(saveablesLifecycleEvent); 85 return saveablesLifecycleEvent.isVeto(); 86 } 87 88 94 final protected void fireSaveablesClosed(Saveable[] models) { 95 listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, 96 SaveablesLifecycleEvent.POST_CLOSE, models, false)); 97 } 98 99 105 final protected void fireSaveablesDirtyChanged(Saveable[] models) { 106 listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, 107 SaveablesLifecycleEvent.DIRTY_CHANGED, models, false)); 108 } 109 110 117 public abstract Saveable[] getSaveables(); 118 119 126 public abstract Object [] getElements(Saveable saveable); 127 128 135 public abstract Saveable getSaveable(Object element); 136 137 141 public void dispose() { 142 listener = null; 143 } 144 145 } 146 | Popular Tags |