KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > RemoveMemoryRenderingAction


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.debug.internal.ui.views.memory;
13
14 import org.eclipse.debug.internal.ui.DebugPluginImages;
15 import org.eclipse.debug.internal.ui.DebugUIMessages;
16 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
17 import org.eclipse.debug.ui.memory.IMemoryRendering;
18 import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
19 import org.eclipse.jface.action.Action;
20
21
22 /**
23  * Remove Memory Rendering action
24  * This action serves two purposes:
25  * - remove memory rendering from Memory Rendering Pane
26  * - quck way to remove a memory block from Memory Rendering Pane
27  *
28  * When user clicks on the this tool bar action, it simply removes
29  * the top view tab from Memory Rendering Pane.
30  * @since 3.0
31  */

32 public class RemoveMemoryRenderingAction extends Action
33 {
34     private IMemoryRenderingContainer fViewPane;
35     public RemoveMemoryRenderingAction(IMemoryRenderingContainer viewPane)
36     {
37         // create action as drop down
38
super(DebugUIMessages.RemoveMemoryRenderingAction_Remove_rendering, AS_PUSH_BUTTON);
39         setText(DebugUIMessages.RemoveMemoryRenderingAction_Remove_rendering);
40
41         setToolTipText(DebugUIMessages.RemoveMemoryRenderingAction_Remove_rendering);
42         setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_REMOVE_MEMORY));
43         setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_REMOVE_MEMORY));
44         setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE_MEMORY));
45         fViewPane = viewPane;
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.jface.action.IAction#run()
50      */

51     public void run() {
52         
53         // user has click on the RemoveMemoryRendering button
54
IMemoryViewTab topTab = getViewTab();
55         
56         if (topTab != null)
57         {
58             IMemoryRendering rendering = topTab.getRendering();
59             
60             if (rendering != null)
61             {
62                 fViewPane.removeMemoryRendering(rendering);
63             }
64         }
65     }
66
67     /* (non-Javadoc)
68      * @see com.ibm.debug.defaultrenderings.internal.actions.AbstractMemoryAction#getViewTab()
69      */

70     IMemoryViewTab getViewTab() {
71         if (fViewPane instanceof IMemoryView)
72         {
73             return ((IMemoryView)fViewPane).getTopMemoryTab();
74         }
75         return null;
76     }
77 }
78
Popular Tags