Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
*******************************************************************************/
package org.eclipse.compare.contentmergeviewer;

import static org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR;
import static org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR;
import static org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR;
import static org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
Expand Down Expand Up @@ -1870,6 +1875,24 @@ private void updateColors(Display display) {
fRight.setForegroundColor(fgColor);
}

Color selectionBackgroundColor = getSelectionBackgroundColor();
Color selectionForegroundColor = getSelectionForegroundColor();
StyledText ancestorSourceViewerWidget = getAncestorSourceViewerWidget();
if (ancestorSourceViewerWidget != null) {
ancestorSourceViewerWidget.setSelectionBackground(selectionBackgroundColor);
ancestorSourceViewerWidget.setSelectionForeground(selectionForegroundColor);
}
StyledText leftSourceViewerWidget = getLeftSourceViewerWidget();
if (leftSourceViewerWidget != null) {
leftSourceViewerWidget.setSelectionBackground(selectionBackgroundColor);
leftSourceViewerWidget.setSelectionForeground(selectionForegroundColor);
}
StyledText rightSourceViewerWidget = getRightSourceViewerWidget();
if (rightSourceViewerWidget != null) {
rightSourceViewerWidget.setSelectionBackground(selectionBackgroundColor);
rightSourceViewerWidget.setSelectionForeground(selectionForegroundColor);
}

ColorRegistry registry= JFaceResources.getColorRegistry();

RGB bg= getBackground(display);
Expand All @@ -1890,6 +1913,51 @@ private void updateColors(Display display) {
updatePresentation();
}

private StyledText getAncestorSourceViewerWidget() {
if (fAncestor == null) {
return null;
}
SourceViewer sourceViewer = fAncestor.getSourceViewer();
if (sourceViewer == null) {
return null;
}
return sourceViewer.getTextWidget();
}

private StyledText getLeftSourceViewerWidget() {
if (fLeft == null) {
return null;
}
SourceViewer sourceViewer = fLeft.getSourceViewer();
if (sourceViewer == null) {
return null;
}
return sourceViewer.getTextWidget();
}

private StyledText getRightSourceViewerWidget() {
if (fRight == null) {
return null;
}
SourceViewer sourceViewer = fRight.getSourceViewer();
if (sourceViewer == null) {
return null;
}
return sourceViewer.getTextWidget();
}

private Color getSelectionBackgroundColor() {
RGB rgb = fPreferenceStore.getBoolean(EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR) ? null
: PreferenceConverter.getColor(fPreferenceStore, EDITOR_SELECTION_BACKGROUND_COLOR);
return getColor(rgb);
}

private Color getSelectionForegroundColor() {
RGB rgb = fPreferenceStore.getBoolean(EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR) ? null
: PreferenceConverter.getColor(fPreferenceStore, EDITOR_SELECTION_FOREGROUND_COLOR);
return getColor(rgb);
}

private void updatePresentation() {
refreshBirdsEyeView();
invalidateLines();
Expand Down Expand Up @@ -4226,6 +4294,12 @@ protected void handlePropertyChangeEvent(PropertyChangeEvent event) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
setSyncScrolling(b);

} else if (key.equals(EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
|| key.equals(EDITOR_SELECTION_BACKGROUND_COLOR)
|| key.equals(EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
|| key.equals(EDITOR_SELECTION_FOREGROUND_COLOR)) {
updateColors(null);

} else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
if (!fIsUsingSystemBackground) {
setBackgroundColor(createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND));
Expand Down
Loading