提交 fc1adc3a 编写于 作者: S serge-rider

UI theme change reflection was fixed (SQL editor + results viewer)

上级 2c54f357
...@@ -57,6 +57,7 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS ...@@ -57,6 +57,7 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS
private final List<ISelectionChangedListener> selectionChangedListenerList = new ArrayList<>(); private final List<ISelectionChangedListener> selectionChangedListenerList = new ArrayList<>();
protected IThemeManager themeManager; protected IThemeManager themeManager;
private IPropertyChangeListener themeChangeListener; private IPropertyChangeListener themeChangeListener;
private long lastThemeUpdateTime;
@Override @Override
@NotNull @NotNull
...@@ -84,8 +85,15 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS ...@@ -84,8 +85,15 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS
this.themeManager = controller.getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); this.themeManager = controller.getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
this.themeChangeListener = event -> { this.themeChangeListener = event -> {
if (event.getProperty().startsWith(ThemeConstants.RESULTS_PROP_PREFIX)) { if (event.getProperty().equals(IThemeManager.CHANGE_CURRENT_THEME) ||
applyThemeSettings(); event.getProperty().startsWith(ThemeConstants.RESULTS_PROP_PREFIX))
{
if (lastThemeUpdateTime > 0 && System.currentTimeMillis() - lastThemeUpdateTime < 500) {
// Do not update too often (theme change may trigger this hundreds of times)
return;
}
lastThemeUpdateTime = System.currentTimeMillis();
UIUtils.asyncExec(this::applyThemeSettings);
} }
}; };
this.themeManager.addPropertyChangeListener(themeChangeListener); this.themeManager.addPropertyChangeListener(themeChangeListener);
......
...@@ -123,9 +123,11 @@ public abstract class SQLEditorBase extends BaseTextEditor implements IErrorVisu ...@@ -123,9 +123,11 @@ public abstract class SQLEditorBase extends BaseTextEditor implements IErrorVisu
return; return;
} }
lastUpdateTime = System.currentTimeMillis(); lastUpdateTime = System.currentTimeMillis();
reloadSyntaxRules(); UIUtils.asyncExec(() -> {
// Reconfigure to let comments/strings colors to take effect reloadSyntaxRules();
getSourceViewer().configure(getSourceViewerConfiguration()); // Reconfigure to let comments/strings colors to take effect
getSourceViewer().configure(getSourceViewerConfiguration());
});
} }
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册