Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Dumais2016-02-26 14:38:21 +0000
committerMarc Dumais2016-03-30 14:00:00 +0000
commitb28d8e45d1d0e506ff54781be9d7a5e75e99c615 (patch)
tree3a58ca9e9c33a2f5a569cc5cc8220924ece76cc4
parent91f9730d27405e5f2fce81032300fcacf12c0ea8 (diff)
downloadorg.eclipse.cdt-b28d8e45d1d0e506ff54781be9d7a5e75e99c615.tar.gz
org.eclipse.cdt-b28d8e45d1d0e506ff54781be9d7a5e75e99c615.tar.xz
org.eclipse.cdt-b28d8e45d1d0e506ff54781be9d7a5e75e99c615.zip
bug 488469 - [traditional memory rendering] add preference for coloring
background independently for different memory spaces Change-Id: If61d909ef66b9c11aebe0863b787af465121dd59
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/model/DsfMemoryBlock.java3
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/META-INF/MANIFEST.MF5
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/pom.xml2
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/internal/MemorySpacePreferencesHelper.java177
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/IMemorySpacePreferencesHelper.java44
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalMemoryRenderingFactory.java38
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering.java69
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceConstants.java13
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferenceInitializer.java16
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRenderingPreferencePage.java12
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/TraditionalRendering_messages.properties1
11 files changed, 368 insertions, 12 deletions
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 08641104c3..a2065fa6e5 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 9ac9aee28f..3d1406f2c7 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 7ccaffb783..2ee1f5d3db 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 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.ui.memory.traditional</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
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 0000000000..99e2a664dd
--- /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<String> inputIdList = new ArrayList<String>(Arrays.asList(ids));
+ List<String> knownIdList = new ArrayList<String>(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<String, String> getMemorySpaceLabels() {
+ String prefix = TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX;
+ String labelPrefix = TraditionalRenderingMessages
+ .getString("TraditionalRenderingPreferencePage_BackgroundColorMemorySpacePrefix");
+ String[] ids = getMemorySpaceIds();
+
+ Map<String, String> 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<String, String> getMemorySpaceDefaultColors() {
+ String prefix = TraditionalRenderingPreferenceConstants.MEM_MEMORY_SPACE_ID_PREFIX;
+ String[] ids = getMemorySpaceIds();
+ Map<String, String> mapKeyToColor = new HashMap<String, String>();
+ 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 0000000000..0b6ecc5acf
--- /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<String, String> getMemorySpaceLabels();
+
+ /**
+ * @return a map of each known memory space key to corresponding csv representation of an RGB color
+ */
+ Map<String, String> 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 0000000000..53bd0ca1d4
--- /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 30ee00205d..86fed6ee61 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 f78243358b..74b844b0e9 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 730387c423..e36a1ebd8b 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<String, String> 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 d81d391642..b39e97c729 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<String, String> 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 06e5334ef0..657dffe0db 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

Back to the top