1 11 package org.eclipse.ui.views.framelist; 12 13 import org.eclipse.osgi.util.NLS; 14 import org.eclipse.ui.ISharedImages; 15 import org.eclipse.ui.PlatformUI; 16 import org.eclipse.ui.internal.views.framelist.FrameListMessages; 17 18 21 public class BackAction extends FrameAction { 22 23 28 public BackAction(FrameList frameList) { 29 super(frameList); 30 setText(FrameListMessages.Back_text); 31 ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); 32 setImageDescriptor(images 33 .getImageDescriptor(ISharedImages.IMG_TOOL_BACK)); 34 setDisabledImageDescriptor(images 35 .getImageDescriptor(ISharedImages.IMG_TOOL_BACK_DISABLED)); 36 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 37 IFrameListHelpContextIds.BACK_ACTION); 38 update(); 39 } 40 41 private Frame getPreviousFrame() { 42 FrameList list = getFrameList(); 43 return list.getFrame(list.getCurrentIndex() - 1); 44 } 45 46 private String getToolTipText(Frame previousFrame) { 47 if (previousFrame != null) { 48 String text = previousFrame.getToolTipText(); 49 if (text != null && text.length() > 0) { 50 return NLS.bind(FrameListMessages.Back_toolTipOneArg, text); 51 } 52 } 53 return FrameListMessages.Back_toolTip; 54 } 55 56 59 public void run() { 60 getFrameList().back(); 61 } 62 63 68 public void update() { 69 super.update(); 70 Frame previousFrame = getPreviousFrame(); 71 setEnabled(previousFrame != null); 72 setToolTipText(getToolTipText(previousFrame)); 73 } 74 75 } 76 | Popular Tags |