KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.debug.internal.ui.views.memory;
13
14 import org.eclipse.debug.internal.ui.DebugUIMessages;
15 import org.eclipse.debug.ui.IDebugUIConstants;
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.ui.help.WorkbenchHelp;
18
19
20 /**
21  * Action for formatting Memory View Tab
22  *
23  * @since 3.0
24  */

25 public class FormatColumnAction extends Action
26 {
27     private static final String JavaDoc PREFIX = "FormatColumnAction."; //$NON-NLS-1$
28
private static final String JavaDoc BYTE = PREFIX + "byte"; //$NON-NLS-1$
29
private static final String JavaDoc BYTES = PREFIX + "bytes"; //$NON-NLS-1$
30

31     ITableMemoryViewTab fViewTab;
32     int fNumBytesPerCol;
33     
34     public FormatColumnAction(int numBytes, ITableMemoryViewTab viewTab)
35     {
36         super();
37         
38         String JavaDoc label;
39         if (numBytes > 1)
40             label = String.valueOf(numBytes) + " " + DebugUIMessages.getString(BYTES); //$NON-NLS-1$
41
else
42             label = String.valueOf(numBytes) + " " + DebugUIMessages.getString(BYTE); //$NON-NLS-1$
43

44         super.setText(label);
45         
46         fViewTab = viewTab;
47         
48         // check this action if the view tab is currently in this format
49
if (numBytes == fViewTab.getColumnSize())
50         {
51             setChecked(true);
52         }
53
54         fNumBytesPerCol = numBytes;
55         
56         WorkbenchHelp.setHelp(this, IDebugUIConstants.PLUGIN_ID + ".FormatColumnAction_context"); //$NON-NLS-1$
57
}
58     /* (non-Javadoc)
59      * @see org.eclipse.jface.action.IAction#run()
60      */

61     public void run()
62     {
63         fViewTab.format(fViewTab.getBytesPerLine(), fNumBytesPerCol);
64     }
65     
66     public int getColumnSize()
67     {
68         return fNumBytesPerCol;
69     }
70
71 }
72
Popular Tags