1 11 package org.eclipse.ui.internal.cheatsheets.views; 12 13 14 import org.eclipse.core.runtime.IPath; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.ui.internal.cheatsheets.*; 18 19 22 public class CheatSheetExpandRestoreAction extends Action { 23 private CheatSheetViewer viewer; 24 private boolean collapsed = false; 25 26 private ImageDescriptor collapseImage; 27 private ImageDescriptor disabledImage; 28 29 public CheatSheetExpandRestoreAction(String title, boolean initValue, CheatSheetViewer viewer) { 30 super(title); 31 this.viewer = viewer; 32 33 IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("collapse_expand_all.gif"); collapseImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path); 35 path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_DLCL).append("collapse_expand_all.gif"); disabledImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path); 37 setDisabledImageDescriptor(disabledImage); 38 setImageDescriptor(collapseImage); 39 setCollapsed(initValue); 40 } 41 42 45 public void run() { 46 viewer.toggleExpandRestore(); 47 } 48 49 public boolean isCollapsed() { 50 return collapsed; 51 } 52 53 public void setCollapsed(boolean value) { 54 super.setChecked(value); 55 collapsed = value; 56 if(value) { 57 setToolTipText(Messages.RESTORE_ALL_TOOLTIP); 58 } else { 59 setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP); 60 } 61 } 62 } 63 | Popular Tags |