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 UpAction extends FrameAction { 22 23 28 public UpAction(FrameList frameList) { 29 super(frameList); 30 setText(FrameListMessages.Up_text); 31 ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); 32 setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_UP)); 33 setDisabledImageDescriptor(images 34 .getImageDescriptor(ISharedImages.IMG_TOOL_UP_DISABLED)); 35 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 36 IFrameListHelpContextIds.UP_ACTION); 37 update(); 38 } 39 40 Frame getParentFrame(int flags) { 41 return getFrameList().getSource().getFrame(IFrameSource.PARENT_FRAME, 42 flags); 43 } 44 45 String getToolTipText(Frame parentFrame) { 46 if (parentFrame != null) { 47 String text = parentFrame.getToolTipText(); 48 if (text != null && text.length() > 0) { 49 return NLS.bind(FrameListMessages.Up_toolTipOneArg, text); 50 } 51 } 52 return FrameListMessages.Up_toolTip; 53 54 } 55 56 60 public void run() { 61 Frame parentFrame = getParentFrame(IFrameSource.FULL_CONTEXT); 62 if (parentFrame != null) { 63 getFrameList().gotoFrame(parentFrame); 64 } 65 } 66 67 74 public void update() { 75 super.update(); 76 Frame parentFrame = getParentFrame(0); 77 setEnabled(parentFrame != null); 78 setToolTipText(getToolTipText(parentFrame)); 79 } 80 } 81 | Popular Tags |