KickJava   Java API By Example, From Geeks To Geeks.

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


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.renderings;
13
14 import org.eclipse.debug.internal.ui.DebugUIMessages;
15 import org.eclipse.debug.ui.IDebugUIConstants;
16 import org.eclipse.debug.ui.memory.AbstractTableRendering;
17 import org.eclipse.jface.action.Action;
18 import org.eclipse.ui.PlatformUI;
19
20
21 /**
22  * Action for formatting Memory View Tab
23  *
24  * @since 3.0
25  */

26 public class FormatColumnAction extends Action
27 {
28     AbstractTableRendering fRendering;
29     int fNumBytesPerCol;
30     
31     public FormatColumnAction(int numUnits, int addressableSize, AbstractTableRendering rendering)
32     {
33         String JavaDoc label;
34         if (numUnits == 1)
35             label = String.valueOf(numUnits) + " " + DebugUIMessages.FormatColumnAction_unit; //$NON-NLS-1$
36
else
37             label = String.valueOf(numUnits) + " " + DebugUIMessages.FormatColumnAction_units; //$NON-NLS-1$
38

39         super.setText(label);
40         
41         fRendering = rendering;
42         
43         // check this action if the view tab is currently in this format
44
if (numUnits*addressableSize == fRendering.getBytesPerColumn())
45         {
46             setChecked(true);
47         }
48
49         fNumBytesPerCol = numUnits*addressableSize;
50         
51         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugUIConstants.PLUGIN_ID + ".FormatColumnAction_context"); //$NON-NLS-1$
52
}
53     /* (non-Javadoc)
54      * @see org.eclipse.jface.action.IAction#run()
55      */

56     public void run()
57     {
58         fRendering.format(fRendering.getBytesPerLine(), fNumBytesPerCol);
59     }
60     
61     public int getColumnSize()
62     {
63         return fNumBytesPerCol;
64     }
65
66 }
67
Popular Tags