1 11 12 package org.eclipse.ui.internal.cheatsheets.state; 13 14 import java.util.Hashtable ; 15 import java.util.Properties ; 16 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.ui.IMemento; 20 import org.eclipse.ui.cheatsheets.ICheatSheetManager; 21 import org.eclipse.ui.internal.cheatsheets.data.CheatSheetSaveHelper; 22 import org.eclipse.ui.internal.cheatsheets.data.IParserTags; 23 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement; 24 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; 25 26 30 31 public class MementoStateManager implements ICheatSheetStateManager { 32 33 private IMemento memento; 34 private CheatSheetElement element; 35 private CheatSheetSaveHelper saveHelper = new CheatSheetSaveHelper(); 36 private Properties props; 37 private ICheatSheetManager parentCsm; 38 39 43 public MementoStateManager(IMemento memento, ICheatSheetManager parentCsm) { 44 this.memento = memento; 45 this.parentCsm = parentCsm; 46 } 47 48 51 public Properties getProperties() { 52 if (memento == null) { 53 return null; 54 } 55 if (props == null) { 56 props = saveHelper.loadFromMemento(memento); 57 } 58 return props; 59 } 60 61 public CheatSheetManager getCheatSheetManager() { 62 CheatSheetManager result = new CheatSheetManager(element); 63 if (getProperties() != null) { 64 result.setData((Hashtable ) getProperties().get(IParserTags.MANAGERDATA)); 65 } 66 result.setParent(parentCsm); 67 return result; 68 } 69 70 public void setElement(CheatSheetElement element) { 71 this.element = element; 72 } 73 74 public IStatus saveState(Properties properties, CheatSheetManager manager) { 75 return Status.OK_STATUS; 77 } 78 79 } 80 | Popular Tags |