diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/model/DsfMemoryBlock.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/model/DsfMemoryBlock.java index 08641104c32..a2065fa6e5e 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/model/DsfMemoryBlock.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/model/DsfMemoryBlock.java @@ -130,6 +130,9 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens if (adapter.isAssignableFrom(DsfMemoryBlockRetrieval.class)) { return fRetrieval; } + if (adapter.isAssignableFrom(IMemoryDMContext.class)) { + return getContext(); + } return super.getAdapter(adapter); } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/META-INF/MANIFEST.MF b/memory/org.eclipse.cdt.debug.ui.memory.traditional/META-INF/MANIFEST.MF index 9ac9aee28f3..3d1406f2c7e 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/META-INF/MANIFEST.MF +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.ui.memory.traditional;singleton:=true -Bundle-Version: 1.3.0.qualifier +Bundle-Version: 1.4.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.debug.core, org.eclipse.debug.ui, @@ -16,4 +16,5 @@ Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.cdt.debug.ui.memory.traditional.TraditionalRenderingPlugin Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Export-Package: org.eclipse.cdt.debug.ui.memory.traditional +Export-Package: org.eclipse.cdt.debug.ui.memory.traditional, + org.eclipse.cdt.debug.ui.internal diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml b/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml index 7ccaffb7831..2ee1f5d3dbc 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT org.eclipse.cdt.debug.ui.memory.traditional eclipse-plugin diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/internal/MemorySpacePreferencesHelper.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/internal/MemorySpacePreferencesHelper.java new file mode 100644 index 00000000000..99e2a664ddb --- /dev/null +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/internal/MemorySpacePreferencesHelper.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2016 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Dumais (Ericsson) - initial implementation + *******************************************************************************/ + +package org.eclipse.cdt.debug.ui.internal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.debug.ui.memory.traditional.IMemorySpacePreferencesHelper; +import org.eclipse.cdt.debug.ui.memory.traditional.TraditionalRenderingMessages; +import org.eclipse.cdt.debug.ui.memory.traditional.TraditionalRenderingPlugin; +import org.eclipse.cdt.debug.ui.memory.traditional.TraditionalRenderingPreferenceConstants; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * This class encapsulates the messy details of dealing with preferences + * entries that have unpredictable key names. This is necessary because the + * preference store does not allow getting a list of the keys, just a lookup + * by exact key. So the work-around is to use one key to save a csv string, + * containing the information necessary to reconstruct the keys for the + * unpredictable entries. + * + */ +public class MemorySpacePreferencesHelper implements IMemorySpacePreferencesHelper { + /** Reference to the plugin's preference store */ + private final IPreferenceStore fStore; + + // List of RGB colors that we can use, by default, for memory space backgrounds + private static final String[] fColorPool = { + "238,192,192", "250,238,195", "255,179,0", + "122,245,0", "184,242,255", "166,189,215", + "206,162,98", "245,138,157", "244,200,0", + "255,136,56", "244,255,128" + }; + + /** Constructor */ + public MemorySpacePreferencesHelper() { + fStore = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + } + + /** + * @return an array of the currently known memory spaces ids, for which + * a background color preference was created. + */ + private String[] getMemorySpaceIds() { + String csv = fStore.getString(TraditionalRenderingPreferenceConstants.MEM_KNOWN_MEMORY_SPACE_ID_LIST_CSV); + return csv.isEmpty() ? new String[0] : csv.split(","); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.internal.IMemorySpacesPreferencesUtil#updateMemorySpaces(java.lang.String[]) + */ + @Override +public void updateMemorySpaces(String[] ids) { + List inputIdList = new ArrayList(Arrays.asList(ids)); + List knownIdList = new ArrayList(Arrays.asList(getMemorySpaceIds())); + int nextIdIndex = knownIdList.size(); + boolean newIds; + + // Remove ids already known + inputIdList.removeAll(knownIdList); + newIds = inputIdList.size() > 0 ? true : false; + + // remaining ids are new + for (String id : inputIdList) { + knownIdList.add(id); + // set default color for this memory space id + setDefaultColorPreference(id, nextIdIndex); + nextIdIndex++; + } + // Save set of known memory space ids, if new ones were added + if (newIds) { + setMemorySpaceIds(knownIdList.toArray(new String[knownIdList.size()])); + } + } + + /** + * Saves a set of memory space ids, as a CSV string, into the + * preferences store + */ + private void setMemorySpaceIds(String[] memorySpaces) { + StringBuffer csv = new StringBuffer(); + for (int i = 0; i < memorySpaces.length; i++) { + csv.append(memorySpaces[i]); + if (i < memorySpaces.length - 1) { + csv.append(","); + } + } + + fStore.setValue(TraditionalRenderingPreferenceConstants.MEM_KNOWN_MEMORY_SPACE_ID_LIST_CSV, + csv.toString()); + } + + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.ui.internal.IMemorySpacesPreferencesUtil#getMemorySpaceKey(java.lang.String) + */ + @Override +public String getMemorySpaceKey(String id) { + return TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX + id; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.debug.ui.internal.IMemorySpacesPreferencesUtil#getMemorySpacesLabels() + */ + @Override + public Map getMemorySpaceLabels() { + String prefix = TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX; + String labelPrefix = TraditionalRenderingMessages + .getString("TraditionalRenderingPreferencePage_BackgroundColorMemorySpacePrefix"); + String[] ids = getMemorySpaceIds(); + + Map keysToLabels = new HashMap<>(); + String key, label; + for (int i = 0; i < ids.length; i++) { + key = prefix + ids[i]; + label = labelPrefix + " " + ids[i]; + keysToLabels.put(key, label); + } + return keysToLabels; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.debug.ui.internal.IMemorySpacesPreferencesUtil#getMemorySpaceDefaultColors() + */ + @Override + public Map getMemorySpaceDefaultColors() { + String prefix = TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX; + String[] ids = getMemorySpaceIds(); + Map mapKeyToColor = new HashMap(); + String key, color; + for (int i = 0; i < ids.length; i++) { + key = prefix + ids[i]; + color = getColor(i); + mapKeyToColor.put(key, color); + } + return mapKeyToColor; + } + + /** Adds a preference for a memory space id and assign it a unique color */ + private void setDefaultColorPreference(String id, int index) { + String prefix = TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX; + String key = prefix + id; + fStore.setValue(key, getColor(index)); + // Setting the default here prevents not having a default defined at first. + fStore.setDefault(key, getColor(index)); + } + + /** + * @return a csv string representation of a color. A color array is defined + * in this class. The entry returned corresponds to the index parameter, and + * wraps around if the index is greater than the number of defined colors + */ + private String getColor(int index) { + // wrap-around if we have exhausted the pool + if (index >= fColorPool.length) { + index = index % (fColorPool.length); + } + return fColorPool[index]; + } + +} diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/IMemorySpacePreferencesHelper.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/IMemorySpacePreferencesHelper.java new file mode 100644 index 00000000000..0b6ecc5acf3 --- /dev/null +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/IMemorySpacePreferencesHelper.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2016 Ericsson AB and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alvaro Sanchez-Leon (Ericsson AB) - Initial API + *******************************************************************************/ + +package org.eclipse.cdt.debug.ui.memory.traditional; + +import java.util.Map; + +/** + * @since 1.4 + */ +public interface IMemorySpacePreferencesHelper { + + /** + * Updates the list of known memory space ids. For each new memory space, + * a preference is set, assigning it a distinct background color, from + * a pool. Ids that are already known will be ignored. + * @param ids an array of memory spaces ids, for the current platform. + */ + void updateMemorySpaces(String[] ids); + + /** + * @return the preference store key used to lookup the default color for a + * given memory space id + */ + String getMemorySpaceKey(String id); + + /** + * @return a map of each known memory space key to corresponding label entries + */ + Map getMemorySpaceLabels(); + + /** + * @return a map of each known memory space key to corresponding csv representation of an RGB color + */ + Map getMemorySpaceDefaultColors(); +} \ No newline at end of file diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalMemoryRenderingFactory.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalMemoryRenderingFactory.java new file mode 100644 index 00000000000..53bd0ca1d41 --- /dev/null +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalMemoryRenderingFactory.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2016 Ericsson AB and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alvaro Sanchez-Leon (Ericsson AB) - First Implementation and API + *******************************************************************************/ + +package org.eclipse.cdt.debug.ui.memory.traditional; + +import org.eclipse.cdt.debug.ui.internal.MemorySpacePreferencesHelper; + +/** + * @since 1.4 + */ +public class TraditionalMemoryRenderingFactory { + private static IMemorySpacePreferencesHelper fMemSpaceHelper = null; + private final static Object fLock = new Object(); + + public static IMemorySpacePreferencesHelper getMemorySpacesPreferencesHelper() { + synchronized (fLock) { + if (fMemSpaceHelper == null) { + fMemSpaceHelper = new MemorySpacePreferencesHelper(); + } + } + + return fMemSpaceHelper; + } + + public static void setMemorySpacesPreferencesHelper(IMemorySpacePreferencesHelper helper) { + synchronized (fLock) { + fMemSpaceHelper = helper; + } + } +} diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering.java index 30ee00205d8..86fed6ee615 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,9 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.cdt.debug.core.model.provisional.IMemoryRenderingViewportProvider; +import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlock; +import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval; +import org.eclipse.cdt.debug.internal.core.CRequest; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ExecutionEvent; @@ -29,6 +32,7 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.IMemoryBlockRetrieval; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; @@ -107,9 +111,23 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe private IWorkbenchAdapter fWorkbenchAdapter; private IMemoryBlockConnection fConnection; + + private String fMemorySpaceId; private final static int MAX_MENU_COLUMN_COUNT = 8; + private IMemorySpacePreferencesHelper fMemSpacePreferenceHelper; + + private class GetMemorySpacesRequest extends CRequest implements IMemorySpaceAwareMemoryBlockRetrieval.GetMemorySpacesRequest { + String [] fMemorySpaces; + public String[] getMemorySpaces() { + return fMemorySpaces; + } + public void setMemorySpaces(String[] memorySpaceIds) { + fMemorySpaces = memorySpaceIds; + } + } + public TraditionalRendering(String id) { super(id); @@ -254,6 +272,33 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void init(final IMemoryRenderingContainer container, final IMemoryBlock block) { super.init(container, block); + + fMemSpacePreferenceHelper = TraditionalMemoryRenderingFactory.getMemorySpacesPreferencesHelper(); + + // resolve memory space, if any + if (block instanceof IMemorySpaceAwareMemoryBlock) { + IMemorySpaceAwareMemoryBlock memBlock = (IMemorySpaceAwareMemoryBlock) block; + String id = memBlock.getMemorySpaceID(); + fMemorySpaceId = id; + } + + // extract memory space info, if applicable + if (block instanceof IMemorySpaceAwareMemoryBlock) { + IMemoryBlockRetrieval retrieval = ((IMemorySpaceAwareMemoryBlock) block).getMemoryBlockRetrieval(); + ((IMemorySpaceAwareMemoryBlockRetrieval)retrieval).getMemorySpaces(block, new GetMemorySpacesRequest(){ + @Override + public void done() { + final String[] spaces = isSuccess() ? getMemorySpaces() : new String[0]; + // remember memory spaces + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + fMemSpacePreferenceHelper.updateMemorySpaces(spaces); + } + }); + } + }); + } /* * Working with the model proxy must be done on the UI dispatch thread. @@ -505,11 +550,23 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void allocateColors() { - IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); - - colorBackground = new Color(Display.getDefault(), PreferenceConverter.getColor(store, - TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND)); - + + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + colorBackground = null; + // has a memory-space-specific background color been set for the associated memory space? + if (fMemorySpaceId != null) + { + String key = fMemSpacePreferenceHelper.getMemorySpaceKey(fMemorySpaceId); + if (store.getString(key) != "") { + colorBackground = new Color(Display.getDefault(), + PreferenceConverter.getColor(store, key)); + } + } + // no - then use default + if (colorBackground == null) { + colorBackground = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND)); + } colorChanged = new Color(Display.getDefault(), PreferenceConverter.getColor(store, TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED)); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceConstants.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceConstants.java index f78243358b9..74b844b0e98 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceConstants.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006-2013 Wind River Systems, Inc. and others. + * Copyright (c) 2006-2016 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,5 +50,16 @@ public class TraditionalRenderingPreferenceConstants { public static final String MEM_HISTORY_TRAILS_COUNT = "memoryHistoryTrailsCount"; public static final String MEM_DEFAULT_COPY_ACTION = "memoryDefaultCopyAction"; + + // support for memory space - specific coloring + /** + * @since 1.4 + */ + public static final String MEM_KNOWN_MEMORY_SPACE_ID_LIST_CSV = "memorySpaceIdList"; + + /** + * @since 1.4 + */ + public static final String MEM_MEMORY_SPACE_ID_PREFIX = MEM_COLOR_BACKGROUND + "MemorySpace-"; } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceInitializer.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceInitializer.java index 730387c4234..e36a1ebd8be 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceInitializer.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006-2013 Wind River Systems, Inc. and others. + * Copyright (c) 2006-2016 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,8 @@ package org.eclipse.cdt.debug.ui.memory.traditional; +import java.util.Map; + import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; @@ -61,6 +63,18 @@ public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenc store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND, systemBackground.getRed() + "," + systemBackground.getGreen() + "," + systemBackground.getBlue()); + // Set the default background colors, for known memory spaces + IMemorySpacePreferencesHelper util = TraditionalMemoryRenderingFactory.getMemorySpacesPreferencesHelper(); + Map prefKeyToColor = util.getMemorySpaceDefaultColors(); + + if (prefKeyToColor.size() > 0) { + // If there are memory spaces present, set no global background as default + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND, false); + for (String key : prefKeyToColor.keySet()) { + store.setDefault(key, prefKeyToColor.get(key)); + } + } + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE, TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferencePage.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferencePage.java index d81d3916427..b39e97c7294 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferencePage.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,8 @@ package org.eclipse.cdt.debug.ui.memory.traditional; +import java.util.Map; + import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ColorFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; @@ -76,6 +78,14 @@ public class TraditionalRenderingPreferencePage addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND, TraditionalRenderingMessages.getString("TraditionalRenderingPreferencePage_BackgroundColor"), getFieldEditorParent())); //$NON-NLS-1$ + + // are there known memory spaces? If so make their background color configurable + IMemorySpacePreferencesHelper util = TraditionalMemoryRenderingFactory.getMemorySpacesPreferencesHelper(); + + Map memSpacesLabels = util.getMemorySpaceLabels(); + for (String key : memSpacesLabels.keySet()) { + addField(new ColorFieldEditor(key, memSpacesLabels.get(key), getFieldEditorParent())); + } addField(new ColorAndEffectFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED, TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED_BOLD, diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering_messages.properties b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering_messages.properties index 06e5334ef0c..657dffe0dbd 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering_messages.properties +++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering_messages.properties @@ -70,6 +70,7 @@ TraditionalRendering.UPDATE_ALWAYS=Always TraditionalRendering.UPDATE_ON_BREAKPOINT=On Breakpoint TraditionalRendering.UPDATE_MANUAL=Manual TraditionalRenderingPreferencePage_BackgroundColor=&Background Color: +TraditionalRenderingPreferencePage_BackgroundColorMemorySpacePrefix=Background Color for Memory Space: TraditionalRenderingPreferencePage_BrightenAlternateCells=Brighten Alternate Cells TraditionalRenderingPreferencePage_ChangedColor=&Changed Color: TraditionalRenderingPreferencePage_description=Traditional Memory Rendering