KickJava   Java API By Example, From Geeks To Geeks.

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


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.IMemoryRenderingSite;
14 import org.eclipse.debug.ui.memory.IMemoryRenderingSynchronizationService;
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  * Action to link/unlink rendering view panes
22  */

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

31     public void init(IViewPart view) {
32         
33         if (view instanceof IMemoryRenderingSite)
34         {
35             fRenderingSite = (IMemoryRenderingSite)view;
36             
37             IMemoryRenderingSynchronizationService syncService = fRenderingSite.getSynchronizationService();
38             
39             if (syncService instanceof MemoryViewSynchronizationService)
40                 fMemSyncService = (MemoryViewSynchronizationService)syncService;
41         }
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
46      */

47     public void run(IAction action) {
48         
49         if (fMemSyncService == null)
50             return;
51         
52         fMemSyncService.setEnabled(!fMemSyncService.isEnabled());
53         updateActionState(action);
54     }
55
56     /**
57      * @param action
58      */

59     private void updateActionState(IAction action) {
60         
61         if (fMemSyncService == null)
62             return;
63         
64         if (fMemSyncService.isEnabled())
65             action.setChecked(true);
66         else
67             action.setChecked(false);
68     }
69
70     /* (non-Javadoc)
71      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
72      */

73     public void selectionChanged(IAction action, ISelection selection) {
74         updateActionState(action);
75     }
76 }
77
Popular Tags