KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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 java.math.BigInteger JavaDoc;
15
16 import org.eclipse.debug.core.DebugException;
17 import org.eclipse.debug.core.model.MemoryByte;
18 import org.eclipse.debug.ui.memory.AbstractMemoryRendering;
19 import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering;
20
21 /**
22  * Internal base class to allow AbstractTableRendering and AbstractAsyncTableRendering
23  * to share actions and dialogs. This abstract class is not to be published.
24  *
25  * @since 3.2
26  */

27 public abstract class AbstractBaseTableRendering extends AbstractMemoryRendering implements IRepositionableMemoryRendering{
28
29     public AbstractBaseTableRendering(String JavaDoc renderingId) {
30         super(renderingId);
31     }
32
33     /**
34      * Format view tab based on the bytes per line and column.
35      *
36      * @param bytesPerLine - number of bytes per line, possible values: (1 / 2 / 4 / 8 / 16) * addressableSize
37      * @param columnSize - number of bytes per column, possible values: (1 / 2 / 4 / 8 / 16) * addressableSize
38      * @return true if format is successful, false, otherwise
39      */

40     abstract public boolean format(int bytesPerLine, int columnSize);
41
42     /**
43      * Returns the addressible size of this rendering's memory block in bytes.
44      *
45      * @return the addressible size of this rendering's memory block in bytes
46      */

47     abstract public int getAddressableSize();
48
49     /**
50      * Resize column to the preferred size.
51      */

52     abstract public void resizeColumnsToPreferredSize();
53
54     /**
55      * Returns the number of addressable units per row.
56      *
57      * @return number of addressable units per row
58      */

59     abstract public int getAddressableUnitPerLine();
60
61     /**
62      * Returns the number of addressable units per column.
63      *
64      * @return number of addressable units per column
65      */

66     abstract public int getAddressableUnitPerColumn();
67
68     /**
69      * Returns the number of bytes displayed in a single column cell.
70      *
71      * @return the number of bytes displayed in a single column cell
72      */

73     abstract public int getBytesPerColumn();
74
75     /**
76      * Returns the number of bytes displayed in a row.
77      *
78      * @return the number of bytes displayed in a row
79      */

80     abstract public int getBytesPerLine();
81
82     /**
83      * Updates labels of this rendering.
84      */

85     abstract public void updateLabels();
86
87     /**
88      * @return the label of this rendering
89      */

90     abstract public String JavaDoc getLabel();
91
92     /**
93      * Refresh the table viewer with the current top visible address.
94      * Update labels in the memory rendering.
95      */

96     abstract public void refresh();
97
98     /**
99      * Moves the cursor to the specified address.
100      * Will load more memory if the address is not currently visible.
101      *
102      * @param address address to position cursor at
103      * @throws DebugException if an exception occurrs
104      */

105     abstract public void goToAddress(BigInteger JavaDoc address) throws DebugException;
106
107     /**
108      * Returns the currently selected address in this rendering.
109      *
110      * @return the currently selected address in this rendering
111      */

112     abstract public BigInteger JavaDoc getSelectedAddress();
113
114     /**
115      * Returns the currently selected content in this rendering as a String.
116      *
117      * @return the currently selected content in this rendering
118      */

119     abstract public String JavaDoc getSelectedAsString();
120
121     /**
122      * Returns the currently selected content in this rendering as MemoryByte.
123      *
124      * @return the currently selected content in array of MemoryByte.
125      * Returns an empty array if the selected address is out of buffered range.
126      */

127     abstract public MemoryByte[] getSelectedAsBytes();
128
129     /**
130      * Returns the number of characters a byte will convert to
131      * or -1 if unknown.
132      *
133      * @return the number of characters a byte will convert to
134      * or -1 if unknown
135      */

136     abstract public int getNumCharsPerByte();
137
138     /* (non-Javadoc)
139      * @see org.eclipse.debug.ui.memory.IResettableMemoryRendering#resetRendering()
140      */

141     abstract public void resetRendering() throws DebugException;
142
143     /**
144      * Returns text for the given memory bytes at the specified address for the specified
145      * rendering type. This is called by the label provider for.
146      * Subclasses must override.
147      *
148      * @param renderingTypeId rendering type identifier
149      * @param address address where the bytes belong to
150      * @param data the bytes
151      * @return a string to represent the memory. Cannot not return <code>null</code>.
152      * Returns a string to pad the cell if the memory cannot be converted
153      * successfully.
154      */

155     abstract public String JavaDoc getString(String JavaDoc renderingTypeId, BigInteger JavaDoc address,
156             MemoryByte[] data);
157
158     /**
159      * Returns bytes for the given text corresponding to bytes at the given
160      * address for the specified rendering type. This is called by the cell modifier
161      * when modifying bytes in a memory block.
162      * Subclasses must convert the string value to an array of bytes. The bytes will
163      * be passed to the debug adapter for memory block modification.
164      * Returns <code>null</code> if the bytes cannot be formatted properly.
165      *
166      * @param renderingTypeId rendering type identifier
167      * @param address address the bytes begin at
168      * @param currentValues current values of the data in bytes format
169      * @param newValue the string to be converted to bytes
170      * @return the bytes converted from a string
171      */

172     abstract public byte[] getBytes(String JavaDoc renderingTypeId, BigInteger JavaDoc address,
173             MemoryByte[] currentValues, String JavaDoc newValue);
174
175 }
176
Popular Tags