1 11 package org.eclipse.platform.internal; 12 13 import org.eclipse.swt.layout.*; 14 import org.eclipse.swt.widgets.*; 15 import org.eclipse.ui.*; 16 import org.eclipse.ui.cheatsheets.*; 17 import org.eclipse.ui.forms.widgets.*; 18 import org.eclipse.ui.intro.*; 19 import org.eclipse.ui.intro.config.*; 20 21 public final class CheatSheetStandbyContent implements IStandbyContentPart { 22 23 private static String MEMENTO_CHEATSHEET_ID_ATT = "cheatsheetId"; 25 private ICheatSheetViewer viewer; 27 private Composite container; 28 private String input; 29 30 35 public void init(IIntroPart introPart, IMemento memento) { 36 input = getCachedInput(memento); 39 } 40 41 47 public void createPartControl(Composite parent, FormToolkit toolkit) { 48 container = toolkit.createComposite(parent); 49 FillLayout layout = new FillLayout(); 50 layout.marginWidth = layout.marginHeight = 0; 51 container.setLayout(layout); 52 53 viewer = CheatSheetViewerFactory.createCheatSheetView(); 54 viewer.createPartControl(container); 55 } 56 57 62 public Control getControl() { 63 return container; 64 } 65 66 67 72 public void setInput(Object input) { 73 if (input != null) 75 this.input = (String ) input; 76 viewer.setInput(this.input); 77 } 78 79 84 public void setFocus() { 85 viewer.setFocus(); 86 } 87 88 93 public void dispose() { 94 95 } 96 97 102 public void saveState(IMemento memento) { 103 String currentCheatSheetId = viewer.getCheatSheetID(); 104 if (currentCheatSheetId != null) 105 memento.putString(MEMENTO_CHEATSHEET_ID_ATT, currentCheatSheetId); 106 } 107 108 114 private String getCachedInput(IMemento memento) { 115 if (memento == null) 116 return null; 117 return memento.getString(MEMENTO_CHEATSHEET_ID_ATT); 118 119 } 120 121 } 122 | Popular Tags |