1 11 package org.eclipse.ui.internal.cheatsheets.views; 12 13 import org.eclipse.core.runtime.IPath; 14 import org.eclipse.help.ui.internal.views.IHelpPart; 15 import org.eclipse.help.ui.internal.views.ReusableHelpPart; 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.jface.action.IMenuManager; 18 import org.eclipse.jface.action.IToolBarManager; 19 import org.eclipse.jface.action.Separator; 20 import org.eclipse.jface.resource.ImageDescriptor; 21 import org.eclipse.swt.widgets.Composite; 22 import org.eclipse.swt.widgets.Control; 23 import org.eclipse.ui.IMemento; 24 import org.eclipse.ui.forms.AbstractFormPart; 25 import org.eclipse.ui.forms.widgets.FormToolkit; 26 import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; 27 import org.eclipse.ui.internal.cheatsheets.Messages; 28 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement; 29 import org.eclipse.ui.internal.cheatsheets.state.ICheatSheetStateManager; 30 31 35 public class CheatSheetHelpPart extends AbstractFormPart implements IHelpPart { 36 37 public static final String ID = "cheatsheet-page"; 39 private CheatSheetViewer viewer; 40 private String id; 41 42 50 public CheatSheetHelpPart(Composite parent, FormToolkit toolkit, IToolBarManager tbm, CheatSheetElement content, ICheatSheetStateManager trayManager) { 51 id = content.getID(); 52 viewer = new CheatSheetViewer(true); 53 viewer.createPartControl(parent); 54 viewer.setContent(content, trayManager); 55 contributeToToolBar(tbm); 56 } 57 58 63 private void contributeToToolBar(IToolBarManager tbm) { 64 IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("collapseall.gif"); ImageDescriptor collapseImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path); 66 CheatSheetExpandRestoreAction expandRestoreAction = new CheatSheetExpandRestoreAction(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP, false, viewer); 67 expandRestoreAction.setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP); 68 expandRestoreAction.setImageDescriptor(collapseImage); 69 tbm.insertBefore("back", expandRestoreAction); tbm.insertBefore("back", new Separator()); viewer.setExpandRestoreAction(expandRestoreAction); 72 } 73 74 77 public boolean fillContextMenu(IMenuManager manager) { 78 return false; 79 } 80 81 84 public Control getControl() { 85 return viewer.getControl(); 86 } 87 88 91 public IAction getGlobalAction(String id) { 92 return null; 93 } 94 95 100 public String getId() { 101 return id; 102 } 103 104 110 public boolean hasFocusControl(Control control) { 111 return viewer.hasFocusControl(control); 112 } 113 114 117 public void init(ReusableHelpPart parent, String id, IMemento memento) { 118 this.id = id; 119 } 120 121 124 public void refilter() { 125 } 126 127 130 public void saveState(IMemento memento) { 131 } 132 133 138 public void setVisible(boolean visible) { 139 viewer.getControl().setVisible(visible); 140 } 141 142 145 public void stop() { 146 } 147 148 151 public void toggleRoleFilter() { 152 } 153 } 154 | Popular Tags |