Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-04-25 11:54:54 -0400
committerDoug Schaefer2019-04-26 13:15:56 -0400
commit225ee8550a5eae96fc71b408de5eed19a6ae2984 (patch)
tree651dbf7047e69b7d167d7706c159284a830d3cf7
parentfc2543362190076be37843e4f7f556e2f25fe538 (diff)
downloadorg.eclipse.cdt-225ee8550a5eae96fc71b408de5eed19a6ae2984.tar.gz
org.eclipse.cdt-225ee8550a5eae96fc71b408de5eed19a6ae2984.tar.xz
org.eclipse.cdt-225ee8550a5eae96fc71b408de5eed19a6ae2984.zip
Bug 501609 - Fix colors for disassembly view
All colors were hard-coded and it was nearly impossible to use the view with a dark theme. Added colors to the preferences and changed the main view background according to the theme. Change-Id: Ic35df1e272e8b2a90f11c1af3cb3b105cd535fe5 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF2
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java4
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java8
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties8
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java31
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java4
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java4
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java10
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java68
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java124
10 files changed, 252 insertions, 11 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF
index 7a3ceb0f12..b6c30d5553 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF
+++ b/dsf/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
-Bundle-Version: 2.5.1.qualifier
+Bundle-Version: 2.5.100.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
index 7c4263ded5..b4c0dbeb56 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java
@@ -54,6 +54,7 @@ public class AddressRulerColumn extends DisassemblyRulerColumn
setForeground(getColor(DisassemblyPreferenceConstants.ADDRESS_COLOR));
setRadix(prefs.getInt(DisassemblyPreferenceConstants.ADDRESS_RADIX));
setShowRadixPrefix(prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX));
+ setBackground(getColor(DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR));
setAddressSize(32);
}
@@ -199,6 +200,9 @@ public class AddressRulerColumn extends DisassemblyRulerColumn
computeIndentations();
layout(false);
needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR.equals(property)) {
+ setBackground(getColor(property));
+ needRedraw = true;
}
if (needRedraw) {
redraw();
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
index b3a0a09d9d..5812994e0a 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java
@@ -68,6 +68,14 @@ public final class DisassemblyMessages extends NLS {
public static String DisassemblyPreferencePage_OpcodeFormat;
public static String DisassemblyPreferencePage_OpcodeFormatTooltip;
public static String DisassemblyPreferencePage_showRadixTooltip;
+ public static String DisassemblyPreferencePage_addressColor;
+ public static String DisassemblyPreferencePage_rulerBackgroundColor;
+ public static String DisassemblyPreferencePage_errorColor;
+ public static String DisassemblyPreferencePage_instructionColor;
+ public static String DisassemblyPreferencePage_sourceColor;
+ public static String DisassemblyPreferencePage_labelColor;
+ public static String DisassemblyPreferencePage_codeBytesColor;
+ public static String DisassemblyPreferencePage_offsetsColor;
public static String DisassemblyIPAnnotation_primary;
public static String DisassemblyIPAnnotation_secondary;
public static String SourceReadingJob_name;
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
index 189448e0c7..dea56eafa6 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties
@@ -64,6 +64,14 @@ DisassemblyPreferencePage_radix_hexadecimal=Hexadecimal
DisassemblyPreferencePage_OpcodeFormatTooltip=Use this format for the instruction value
DisassemblyPreferencePage_OpcodeFormat=Opcode display format:
DisassemblyPreferencePage_showRadixTooltip=Show '0x' with hexadecimal addresses
+DisassemblyPreferencePage_addressColor=Address color
+DisassemblyPreferencePage_codeBytesColor=Code bytes color
+DisassemblyPreferencePage_offsetsColor=Offsets color
+DisassemblyPreferencePage_rulerBackgroundColor=Ruler background color
+DisassemblyPreferencePage_errorColor=Error color
+DisassemblyPreferencePage_instructionColor=Instruction color
+DisassemblyPreferencePage_sourceColor=Source color
+DisassemblyPreferencePage_labelColor=Label color
DisassemblyIPAnnotation_primary=Debug Current Instruction Pointer
DisassemblyIPAnnotation_secondary=Debug Call Stack
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
index f855d49a4a..d23e0576b5 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
@@ -725,8 +725,23 @@ public abstract class DisassemblyPart extends WorkbenchPart
support.setColumnVisible(desc, newState);
}
}
+ } else if (property.equals(DisassemblyPreferenceConstants.ERROR_COLOR)) {
+ fErrorColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.ERROR_COLOR));
+ refreshView(10);
+ } else if (property.equals(DisassemblyPreferenceConstants.INSTRUCTION_COLOR)) {
+ fInstructionColor = EditorsUI.getSharedTextColors().getColor(PreferenceConverter
+ .getColor(getPreferenceStore(), DisassemblyPreferenceConstants.INSTRUCTION_COLOR));
+ refreshView(10);
+ } else if (property.equals(DisassemblyPreferenceConstants.SOURCE_COLOR)) {
+ fSourceColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.SOURCE_COLOR));
+ refreshView(10);
+ } else if (property.equals(DisassemblyPreferenceConstants.LABEL_COLOR)) {
+ fLabelColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.LABEL_COLOR));
+ refreshView(10);
}
-
}
/**
@@ -741,7 +756,7 @@ public abstract class DisassemblyPart extends WorkbenchPart
parent.setLayout(layout);
fVerticalRuler = createVerticalRuler();
int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
- fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles);
+ fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles, getPreferenceStore());
SourceViewerConfiguration sourceViewerConfig = new DisassemblyViewerConfiguration(this);
fViewer.addTextPresentationListener(this);
fViewer.configure(sourceViewerConfig);
@@ -785,10 +800,14 @@ public abstract class DisassemblyPart extends WorkbenchPart
}
});
- fErrorColor = getSharedColors().getColor(new RGB(96, 0, 0));
- fInstructionColor = getSharedColors().getColor(new RGB(0, 0, 96));
- fSourceColor = getSharedColors().getColor(new RGB(64, 0, 80));
- fLabelColor = getSharedColors().getColor(new RGB(0, 0, 96));
+ fErrorColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.ERROR_COLOR));
+ fInstructionColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.INSTRUCTION_COLOR));
+ fSourceColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.SOURCE_COLOR));
+ fLabelColor = EditorsUI.getSharedTextColors().getColor(
+ PreferenceConverter.getColor(getPreferenceStore(), DisassemblyPreferenceConstants.LABEL_COLOR));
IVerticalRuler ruler = getVerticalRuler();
if (ruler instanceof CompositeRuler) {
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
index 1e314e637a..9f67aae49c 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java
@@ -37,6 +37,7 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn {
public FunctionOffsetRulerColumn() {
super();
setForeground(getColor(DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR));
+ setBackground(getColor(DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR));
}
/*
@@ -78,6 +79,9 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn {
if (DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR.equals(property)) {
setForeground(getColor(property));
needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR.equals(property)) {
+ setBackground(getColor(property));
+ needRedraw = true;
}
if (needRedraw) {
redraw();
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
index a62c300e2d..43a0985682 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
@@ -40,6 +40,7 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
*/
public OpcodeRulerColumn() {
super();
+ setBackground(getColor(DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR));
setForeground(getColor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR));
setRadix(getPreferenceStore().getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
}
@@ -120,6 +121,9 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn {
setRadix(store.getInt(property));
layout(false);
needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR.equals(property)) {
+ setBackground(getColor(property));
+ needRedraw = true;
}
if (needRedraw) {
redraw();
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
index e8e0544c03..44687f1666 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java
@@ -41,6 +41,11 @@ public class DisassemblyPreferenceConstants {
public static final String AVOID_READ_BEFORE_PC = "disassembly.avoidReadBeforePC"; //$NON-NLS-1$
public static final String TRACK_EXPRESSION = "disassembly.trackExpression"; //$NON-NLS-1$
public static final String SYNC_ACTIVE_CONTEXT = "disassembly.syncActiveContext"; //$NON-NLS-1$
+ public static final String RULER_BACKGROUND_COLOR = "disassembly.rulerBackgroundColor"; //$NON-NLS-1$
+ public static final String ERROR_COLOR = "disassembly.errorColor"; //$NON-NLS-1$
+ public static final String INSTRUCTION_COLOR = "disassembly.instructionColor"; //$NON-NLS-1$
+ public static final String SOURCE_COLOR = "disassembly.sourceColor"; //$NON-NLS-1$
+ public static final String LABEL_COLOR = "disassembly.labelColor"; //$NON-NLS-1$
/**
*
@@ -66,6 +71,11 @@ public class DisassemblyPreferenceConstants {
PreferenceConverter.setDefault(store, ADDRESS_COLOR, new RGB(0, 96, 0));
PreferenceConverter.setDefault(store, FUNCTION_OFFSETS_COLOR, new RGB(96, 0, 0));
PreferenceConverter.setDefault(store, CODE_BYTES_COLOR, new RGB(96, 0, 0));
+ PreferenceConverter.setDefault(store, RULER_BACKGROUND_COLOR, new RGB(255, 255, 255));
+ PreferenceConverter.setDefault(store, ERROR_COLOR, new RGB(96, 0, 0));
+ PreferenceConverter.setDefault(store, INSTRUCTION_COLOR, new RGB(0, 0, 96));
+ PreferenceConverter.setDefault(store, SOURCE_COLOR, new RGB(64, 0, 80));
+ PreferenceConverter.setDefault(store, LABEL_COLOR, new RGB(0, 0, 96));
}
public static class Initializer extends AbstractPreferenceInitializer {
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
index f8e509309b..b63e96698f 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java
@@ -21,8 +21,11 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyHelpContextIds;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.DataFormatException;
+import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -46,6 +49,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
private List<Button> fCheckBoxes = new ArrayList<>();
private List<Combo> fComboBoxes = new ArrayList<>();
private ArrayList<Text> fNumberFields = new ArrayList<>();
+ private List<ColorSelector> colors = new ArrayList<>();
private ModifyListener fNumberFieldListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -111,6 +115,31 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
Button showSymbolsCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_SYMBOLS, 0);
showSymbolsCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showSymbolsTooltip);
+ Composite stylesComposite = new Composite(parent, SWT.NONE);
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ stylesComposite.setLayout(layout);
+ stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.ERROR_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_errorColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.INSTRUCTION_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_instructionColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.SOURCE_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_sourceColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.LABEL_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_labelColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.RULER_BACKGROUND_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_rulerBackgroundColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.ADDRESS_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_addressColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_codeBytesColor, stylesComposite));
+ colors.add(createColorFieldEditor(DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR,
+ DisassemblyMessages.DisassemblyPreferencePage_offsetsColor, stylesComposite));
+
Dialog.applyDialogFont(parent);
initialize();
@@ -118,6 +147,25 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
return composite;
}
+ /**
+ * Creates a new color field editor.
+ */
+ private ColorSelector createColorFieldEditor(String preferenceName, String label, Composite parent) {
+ Label labelControl = new Label(parent, SWT.LEFT);
+ labelControl.setText(label);
+ GridData gd = new GridData();
+ gd.horizontalIndent = GridData.BEGINNING;
+ labelControl.setLayoutData(gd);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.END;
+ ColorSelector colorSelector = new ColorSelector(parent);
+ colorSelector.getButton().setLayoutData(gd);
+ colorSelector.getButton().setData(preferenceName);
+
+ return colorSelector;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
@@ -216,7 +264,10 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
Combo combo = iter.next();
store.setValue((String) combo.getData(), fcRadixValues[combo.getSelectionIndex()]);
}
- return super.performOk();
+ for (ColorSelector c : colors) {
+ store.setValue((String) c.getButton().getData(), StringConverter.asString(c.getColorValue()));
+ }
+ return true;
}
/* (non-Javadoc)
@@ -243,7 +294,13 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
}
}
}
- super.performDefaults();
+ for (ColorSelector c : colors) {
+ try {
+ c.setColorValue(StringConverter.asRGB(store.getDefaultString((String) c.getButton().getData())));
+ } catch (DataFormatException e) {
+ DsfUIPlugin.log(e);
+ }
+ }
}
/**
@@ -270,6 +327,13 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
}
}
}
+ for (ColorSelector c : colors) {
+ try {
+ c.setColorValue(StringConverter.asRGB(store.getString((String) c.getButton().getData())));
+ } catch (DataFormatException e) {
+ DsfUIPlugin.log(e);
+ }
+ }
}
/**
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java
index c0cc995114..1ba5b864da 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java
@@ -19,6 +19,8 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocume
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -27,20 +29,27 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
/**
* DisassemblyViewer
*/
-public class DisassemblyViewer extends SourceViewer {
+public class DisassemblyViewer extends SourceViewer implements IPropertyChangeListener {
class ResizeListener implements ControlListener {
@Override
@@ -53,8 +62,12 @@ public class DisassemblyViewer extends SourceViewer {
}
}
+ private Color fForegroundColor;
+ private Color fBackgroundColor;
private boolean fUserTriggeredScrolling;
private int fCachedLastTopPixel;
+ private IPreferenceStore fPreferenceStore;
+ private boolean fIsConfigured = false;
/**
* Create a new DisassemblyViewer.
@@ -65,10 +78,107 @@ public class DisassemblyViewer extends SourceViewer {
* @param styles
*/
public DisassemblyViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
- boolean showsAnnotationOverview, int styles) {
+ boolean showsAnnotationOverview, int styles, IPreferenceStore store) {
super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
// always readonly
setEditable(false);
+ setPreferenceStore(store);
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ *
+ * @param store the store to read from
+ * @param key the key used for the lookup in the preference store
+ * @param display the display used create the color
+ * @return the created color according to the specification in the preference store
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+ RGB rgb = null;
+
+ if (store.contains(key)) {
+ if (store.isDefault(key)) {
+ rgb = PreferenceConverter.getDefaultColor(store, key);
+ } else {
+ rgb = PreferenceConverter.getColor(store, key);
+ }
+
+ if (rgb != null)
+ return new Color(display, rgb);
+ }
+
+ return null;
+ }
+
+ protected void initializeViewerColors() {
+ if (fPreferenceStore != null) {
+ StyledText styledText = getTextWidget();
+
+ // ----------- foreground color --------------------
+ Color color = fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
+ styledText.getDisplay());
+ styledText.setForeground(color);
+
+ if (fForegroundColor != null)
+ fForegroundColor.dispose();
+
+ fForegroundColor = color;
+
+ // ---------- background color ----------------------
+ color = fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
+ : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
+ styledText.getDisplay());
+ styledText.setBackground(color);
+
+ if (fBackgroundColor != null)
+ fBackgroundColor.dispose();
+
+ fBackgroundColor = color;
+ }
+ }
+
+ public void setPreferenceStore(IPreferenceStore store) {
+ if (fIsConfigured && fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(this);
+
+ fPreferenceStore = store;
+
+ if (fIsConfigured && fPreferenceStore != null) {
+ fPreferenceStore.addPropertyChangeListener(this);
+ initializeViewerColors();
+ }
+ }
+
+ @Override
+ public void unconfigure() {
+ if (fForegroundColor != null) {
+ fForegroundColor.dispose();
+ fForegroundColor = null;
+ }
+ if (fBackgroundColor != null) {
+ fBackgroundColor.dispose();
+ fBackgroundColor = null;
+ }
+
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(this);
+
+ super.unconfigure();
+
+ fIsConfigured = false;
+ }
+
+ @Override
+ public void configure(SourceViewerConfiguration configuration) {
+ super.configure(configuration);
+ if (fPreferenceStore != null) {
+ fPreferenceStore.addPropertyChangeListener(this);
+ initializeViewerColors();
+ }
+ fIsConfigured = true;
}
/*
@@ -273,4 +383,14 @@ public class DisassemblyViewer extends SourceViewer {
super.updateViewportListeners(origin);
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
+ initializeViewerColors();
+ }
+ }
}

Back to the top