KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class AddMemoryRenderingContextAction implements IViewActionDelegate {
22
23     private IMemoryRenderingSite fMemoryView;
24     
25     /* (non-Javadoc)
26      * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
27      */

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

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

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