KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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.renderings;
12
13 import org.eclipse.debug.core.model.IMemoryBlockExtension;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.viewers.ISelection;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.ui.IObjectActionDelegate;
18 import org.eclipse.ui.IWorkbenchPart;
19
20 /**
21  * Restore default endianess.
22  * For IMemoryBlockExtension, default is governed by the attributes set
23  * in its memory bytes.
24  * For IMemoryBlock, default is big endian.
25  *
26  */

27 public class DefaultEndianessAction implements IObjectActionDelegate {
28
29     AbstractIntegerRendering fRendering;
30     public DefaultEndianessAction() {
31         super();
32     }
33
34     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
35     }
36
37     public void run(IAction action) {
38         if (fRendering != null)
39         {
40             if (fRendering.getMemoryBlock() instanceof IMemoryBlockExtension)
41             {
42                 fRendering.setDisplayEndianess(RenderingsUtil.ENDIANESS_UNKNOWN);
43             }
44             else
45             {
46                 fRendering.setDisplayEndianess(RenderingsUtil.BIG_ENDIAN);
47             }
48             fRendering.refresh();
49         }
50
51     }
52
53     public void selectionChanged(IAction action, ISelection selection) {
54         if (selection == null)
55             return;
56         
57         if (selection instanceof IStructuredSelection)
58         {
59             Object JavaDoc obj = ((IStructuredSelection)selection).getFirstElement();
60             if (obj == null)
61                 return;
62             
63             if (obj instanceof AbstractIntegerRendering)
64             {
65                 fRendering = (AbstractIntegerRendering)obj;
66             }
67         }
68     }
69
70 }
71
Popular Tags