KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.debug.internal.ui.views.memory;
12
13 import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
14 import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.ui.IViewActionDelegate;
18 import org.eclipse.ui.IViewPart;
19
20 /**
21  * @since 3.0
22  *
23  */

24 public class RemoveRenderingContextAction implements IViewActionDelegate {
25
26     private IMemoryRenderingSite fMemoryView;
27     
28     /* (non-Javadoc)
29      * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
30      */

31     public void init(IViewPart view) {
32         if (view instanceof IMemoryRenderingSite)
33         {
34             fMemoryView = (IMemoryRenderingSite)view;
35         }
36     }
37
38     /* (non-Javadoc)
39      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
40      */

41     public void run(IAction action) {
42         if (fMemoryView == null)
43             return;
44         
45         IMemoryRenderingContainer[] viewPanes = fMemoryView.getMemoryRenderingContainers();
46         String JavaDoc actionId = action.getId();
47         IMemoryRenderingContainer selectedPane = null;
48         
49         for (int i=0; i<viewPanes.length; i++)
50         {
51             if (actionId.indexOf(viewPanes[i].getId()) != -1)
52             {
53                 selectedPane = viewPanes[i];
54                 break;
55             }
56         }
57         
58         if (selectedPane == null)
59             return;
60         
61         RemoveMemoryRenderingAction removeAction = new RemoveMemoryRenderingAction(selectedPane);
62         removeAction.run();
63     }
64
65     /* (non-Javadoc)
66      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
67      */

68     public void selectionChanged(IAction action, ISelection selection) {
69     }
70
71 }
72
Popular Tags