Skip to content

Commit

Permalink
Update preference page in case the colors have been changed in a diff…
Browse files Browse the repository at this point in the history
…erent page
  • Loading branch information
gzsombor committed Sep 6, 2022
1 parent babdd04 commit 81c36cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
Expand All @@ -53,7 +54,7 @@
*
* @since 3.19
*/
public class JavaStackFramePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
public class JavaStackFramePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IPropertyChangeListener {

private static class CategoryColors {
final IJavaStackFrame.Category category;
Expand Down Expand Up @@ -300,6 +301,7 @@ private void createAppearanceList(Composite container) {
}
});


Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
Expand Down Expand Up @@ -329,6 +331,8 @@ private void createAppearanceList(Composite container) {
fAppearanceList.update(selection, null);
}
});

PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().addListener(this);
}

private CategoryColors getSelected() {
Expand Down Expand Up @@ -438,4 +442,18 @@ protected void performDefaults() {
super.performDefaults();
}

@Override
public void propertyChange(PropertyChangeEvent event) {
var propertyName = event.getProperty();
if (StackFramePresentationProvider.isColorName(propertyName)) {
fAppearanceList.update(colors.toArray(), null);
fAppearanceList.setSelection(new StructuredSelection(colors.get(0)));
}
}

@Override
public void dispose() {
PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().removeListener(this);
super.dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,7 @@ public boolean isCollapseStackFrames() {
return collapseStackFrames;
}

static boolean isColorName(String propertyName) {
return fgKeyMap.containsValue(propertyName) || bgKeyMap.containsValue(propertyName);
}
}

0 comments on commit 81c36cc

Please sign in to comment.