mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 489516 - Traditional mem., choose visibility of the cross ref
information This facility is dependent of the issues below. Bug 489512 - Show local variables in the traditional memory render Bug 489513 - Show registers in the traditional memory render Allow the user to choose visibility of the available cross reference information e.g. Variables, Registers In addition to the preferences at a instance level, a global preference is introduced to disable the resolution of additional information altogether. Change-Id: I9f8b9b612ff288b369ba6fca3402c0c911aa5f48
This commit is contained in:
parent
c73978c03a
commit
3822ee7b43
7 changed files with 165 additions and 23 deletions
|
@ -39,6 +39,7 @@ import org.eclipse.debug.core.model.MemoryByte;
|
|||
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
|
||||
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
||||
import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -2338,9 +2339,23 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
|||
*
|
||||
* @param addTypeHeaders
|
||||
* Indicates if the string shall include a data type name before each list of items of the same
|
||||
* type e.g. Variables, Regitsters, etc.
|
||||
* type e.g. Variables, Registers, etc.
|
||||
*/
|
||||
String buildAddressInfoString(BigInteger address, String separator, boolean addTypeHeaders) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Dynamic context menu actions to this render, No actions by default
|
||||
* @since 1.4
|
||||
*/
|
||||
Action[] getDynamicActions() {
|
||||
return new Action[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the resolution of additional address information - No action by default
|
||||
*/
|
||||
void resolveAddressInfoForCurrentSelection() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.debug.ui.DebugUITools;
|
|||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
|
@ -58,6 +60,10 @@ public class RenderingAddressInfo extends Rendering
|
|||
*/
|
||||
private volatile IMemoryBlockAddressInfoItem[] fAddressInfoItems;
|
||||
|
||||
|
||||
private final AddressInfoTypeMap fAddressInfoTypeStatusMap = new AddressInfoTypeMap();
|
||||
|
||||
|
||||
public RenderingAddressInfo(Composite parent, TraditionalRendering renderingParent) {
|
||||
super(parent, renderingParent);
|
||||
|
||||
|
@ -71,10 +77,62 @@ public class RenderingAddressInfo extends Rendering
|
|||
resolveAddressInfoForCurrentSelection(contextService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps a map from information type to its state and to a corresponding Action instance
|
||||
* needed to update the actual state from UI interactions
|
||||
*/
|
||||
class AddressInfoTypeMap extends HashMap<String, Boolean> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Map<String, Action> fTypeToActionMap = new HashMap<>();
|
||||
|
||||
public Action getAction(final String infoType) {
|
||||
if (!containsKey(infoType)) {
|
||||
if (fTypeToActionMap.containsKey(infoType)) {
|
||||
// The key status has been removed, clean the action map
|
||||
fTypeToActionMap.remove(infoType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Action action = fTypeToActionMap.get(infoType);
|
||||
if (action != null) {
|
||||
return action;
|
||||
} else {
|
||||
action = new Action(infoType, IAction.AS_CHECK_BOX) {
|
||||
@Override
|
||||
public void run() {
|
||||
put(infoType, Boolean.valueOf(isChecked()));
|
||||
redrawPanes();
|
||||
}
|
||||
};
|
||||
action.setChecked(get(infoType));
|
||||
fTypeToActionMap.put(infoType, action);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
fTypeToActionMap.clear();
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void resolveAddressInfoForCurrentSelection() {
|
||||
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
||||
IDebugContextService contextService = DebugUITools.getDebugContextManager()
|
||||
.getContextService(site.getWorkbenchWindow());
|
||||
resolveAddressInfoForCurrentSelection(contextService);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
||||
fSelectedContext = null;
|
||||
fMapStartAddrToInfoItems.clear();
|
||||
fAddressInfoTypeStatusMap.clear();
|
||||
fAddressInfoItems = null;
|
||||
|
||||
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
||||
|
@ -158,8 +216,8 @@ public class RenderingAddressInfo extends Rendering
|
|||
}
|
||||
|
||||
private void handleDebugContextChanged(final Object context) {
|
||||
if (isDisposed() || context == null) {
|
||||
// Invalid context or Data pane is not visible
|
||||
if (isDisposed() || context == null || !fParent.isShowCrossRefInfoGlobalPref()) {
|
||||
// Invalid context or user has chosen not to see additional address information
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,10 +243,21 @@ public class RenderingAddressInfo extends Rendering
|
|||
// If the context is still valid
|
||||
if (getContext().equals(fSelectedContext)) {
|
||||
final IMemoryBlockAddressInfoItem[] addressInfoItems = getAllAddressInfoItems();
|
||||
|
||||
|
||||
if (fParent.isShowCrossRefInfoGlobalPref()) {
|
||||
final String[] types = getAddressInfoItemTypes();
|
||||
|
||||
if (!display.isDisposed()) {
|
||||
display.asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String type : types) {
|
||||
if (!fAddressInfoTypeStatusMap.containsKey(type)) {
|
||||
fAddressInfoTypeStatusMap.put(type, Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// The selection has changed, so our Address information may no longer be valid
|
||||
fAddressInfoItems = addressInfoItems;
|
||||
fMapStartAddrToInfoItems.clear();
|
||||
|
@ -203,6 +272,7 @@ public class RenderingAddressInfo extends Rendering
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshUpdateListener(final IMemoryBlockAddressInfoRetrieval addrInfo) {
|
||||
if (fAddressInfoRetrieval == null) {
|
||||
|
@ -256,16 +326,13 @@ public class RenderingAddressInfo extends Rendering
|
|||
@Override
|
||||
public void handleAddressInfoUpdate(EventType type, Object update) {
|
||||
fAddressInfoItems = null;
|
||||
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
||||
IDebugContextService contextService = DebugUITools.getDebugContextManager()
|
||||
.getContextService(site.getWorkbenchWindow());
|
||||
resolveAddressInfoForCurrentSelection(contextService);
|
||||
resolveAddressInfoForCurrentSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
Map<BigInteger, List<IMemoryBlockAddressInfoItem>> getVisibleValueToAddressInfoItems() {
|
||||
IMemoryBlockAddressInfoItem[] items = fAddressInfoItems;
|
||||
if (items == null) {
|
||||
if (items == null || !fParent.isShowCrossRefInfoGlobalPref()) {
|
||||
fMapStartAddrToInfoItems.clear();
|
||||
return fMapStartAddrToInfoItems;
|
||||
}
|
||||
|
@ -302,6 +369,13 @@ public class RenderingAddressInfo extends Rendering
|
|||
BigInteger endAddress = getViewportEndAddressSingleHeight();
|
||||
|
||||
for (IMemoryBlockAddressInfoItem item : items) {
|
||||
// Skip information types not wanted by the user
|
||||
String itemType = item.getInfoType();
|
||||
if (!fAddressInfoTypeStatusMap.containsKey(itemType)
|
||||
|| fAddressInfoTypeStatusMap.get(itemType).equals(Boolean.FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<IMemoryBlockAddressInfoItem> containers = allValuesMap.get(item.getAddress());
|
||||
if (containers == null) {
|
||||
containers = new ArrayList<>();
|
||||
|
@ -392,4 +466,18 @@ public class RenderingAddressInfo extends Rendering
|
|||
return (fBinaryPane.fPaneVisible && fMapStartAddrToInfoItems.size() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action[] getDynamicActions() {
|
||||
List<Action> actionList = new ArrayList<Action>(fAddressInfoTypeStatusMap.size());
|
||||
if (getPaneVisible(Rendering.PANE_BINARY)) {
|
||||
for (final String infoType : fAddressInfoTypeStatusMap.keySet()) {
|
||||
Action action = fAddressInfoTypeStatusMap.getAction(infoType);
|
||||
if (action != null) {
|
||||
actionList.add(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return actionList.toArray(new Action[actionList.size()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -645,6 +645,9 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
panes[i].setBackground(getColorBackground());
|
||||
|
||||
setRenderingPadding(TraditionalRenderingPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR));
|
||||
if (store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO)) {
|
||||
fRendering.resolveAddressInfoForCurrentSelection();
|
||||
}
|
||||
|
||||
fRendering.redrawPanes();
|
||||
}
|
||||
|
@ -777,6 +780,14 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
return colorTextAlternate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public boolean isShowCrossRefInfoGlobalPref() {
|
||||
IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore();
|
||||
return store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO);
|
||||
}
|
||||
|
||||
public void createMenus()
|
||||
{
|
||||
// add the menu to each of the rendering panes
|
||||
|
@ -1251,6 +1262,21 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
|||
sub.add(displayTextPaneAction);
|
||||
manager.add(sub);
|
||||
|
||||
// if there is cross reference info types available
|
||||
// add Actions to allow the user to toggle the visibility for each of them
|
||||
if (isShowCrossRefInfoGlobalPref()) {
|
||||
Action[] dynamicActions = fRendering.getDynamicActions();
|
||||
if (dynamicActions != null) {
|
||||
sub = new MenuManager(TraditionalRenderingMessages
|
||||
.getString("TraditionalRenderingPreferencePage_ShowCrossRefInfo_Label")); //$NON-NLS-1$
|
||||
for (Action action : dynamicActions) {
|
||||
sub.add(action);
|
||||
}
|
||||
|
||||
manager.add(sub);
|
||||
}
|
||||
}
|
||||
|
||||
sub = new MenuManager(TraditionalRenderingMessages
|
||||
.getString("TraditionalRendering.ENDIAN")); //$NON-NLS-1$
|
||||
sub.add(displayEndianBigAction);
|
||||
|
|
|
@ -62,4 +62,8 @@ public class TraditionalRenderingPreferenceConstants {
|
|||
*/
|
||||
public static final String MEM_MEMORY_SPACE_ID_PREFIX = MEM_COLOR_BACKGROUND + "MemorySpace-";
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public static final String MEM_CROSS_REFERENCE_INFO = "memCrossReferenceInfo";
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenc
|
|||
TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY);
|
||||
|
||||
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT, "1");
|
||||
|
||||
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,6 +113,11 @@ public class TraditionalRenderingPreferencePage
|
|||
|
||||
addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT,
|
||||
TraditionalRenderingMessages.getString("TraditionalRenderingPreferencePage_HistoryTrailLevels"), getFieldEditorParent(), 1, 10, 1, 1)); //$NON-NLS-1$
|
||||
|
||||
addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO,
|
||||
TraditionalRenderingMessages
|
||||
.getString("TraditionalRenderingPreferencePage_ShowCrossRefInfo"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -84,6 +84,8 @@ TraditionalRenderingPreferencePage_TextColor=&Text Color:
|
|||
TraditionalRenderingPreferencePage_UseGlobalBackgroundColor=Use Global B&ackground Color
|
||||
TraditionalRenderingPreferencePage_UseGlobalSelectionColor=Use Global Se&lection Color
|
||||
TraditionalRenderingPreferencePage_UseGlobalTextColor=Use Global Te&xt Color
|
||||
TraditionalRenderingPreferencePage_ShowCrossRefInfo=Show cross reference information
|
||||
TraditionalRenderingPreferencePage_ShowCrossRefInfo_Label=Cross Reference Information
|
||||
ColorAndEffectFieldEditor.bold=Bold
|
||||
ColorAndEffectFieldEditor.italic=Italic
|
||||
ColorAndEffectFieldEditor.box=Box
|
||||
|
|
Loading…
Add table
Reference in a new issue