Compare commits

...

3 Commits

5 changed files with 23 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ package org.talend.commons.ui.runtime;
import java.util.Optional;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.graphics.Color;
import org.osgi.framework.BundleContext;
@@ -29,6 +30,8 @@ public interface ITalendThemeService {
public static String DEFAULT_PREFERENCE_ID = "org.eclipse.ui.workbench";
public static String THEME_PREFERENCE_ID = "org.eclipse.e4.ui.css.swt.theme";
/**
* Get color from instance scope preference of default bundleId, which managed by theme; the standard way eclipse
* uses
@@ -132,6 +135,8 @@ public interface ITalendThemeService {
void removePropertyChangeListenerFor(String bundleId, IPropertyChangeListener listener);
IPreferenceStore getThemePreferenceStore();
static ITalendThemeService get() {
try {
BundleContext bc = FrameworkUtil.getBundle(ITalendThemeService.class).getBundleContext();

View File

@@ -106,6 +106,11 @@ public class TalendThemeService implements ITalendThemeService {
}
}
@Override
public IPreferenceStore getThemePreferenceStore() {
return getPreferenceStore(ITalendThemeService.THEME_PREFERENCE_ID);
}
private IPreferenceStore getPreferenceStore(String bundleId) {
IPreferenceStore prefStore = storeMap.get(bundleId);
if (prefStore == null) {

View File

@@ -21,4 +21,6 @@ public class TalendThemeConstants {
public static final String TALEND_THEME_PREFIX = "org.talend.themes."; //$NON-NLS-1$
public static final String TALEND_DEFAULT_THEME_ID = TALEND_THEME_PREFIX + "css.talend.default"; //$NON-NLS-1$
public static final String TALEND_DARK_THEME_ID = "org.eclipse.e4.ui.css.theme.e4_dark"; //$NON-NLS-1$
}

View File

@@ -12,6 +12,8 @@
// ============================================================================
package org.talend.themes.core.elements.utils;
import org.eclipse.jface.preference.IPreferenceStore;
import org.talend.commons.ui.runtime.ITalendThemeService;
import org.talend.themes.core.elements.constants.TalendThemeConstants;
/**
@@ -26,4 +28,13 @@ public class TalendThemeUtils {
}
return themeId.startsWith(TalendThemeConstants.TALEND_THEME_PREFIX);
}
public static boolean isDarkModeTheme() {
IPreferenceStore themePreferenceStore = ITalendThemeService.get().getThemePreferenceStore();
if (themePreferenceStore != null
&& TalendThemeConstants.TALEND_DARK_THEME_ID.equals(themePreferenceStore.getString("themeid"))) {
return true;
}
return false;
}
}

View File

@@ -10,7 +10,6 @@
label="%theme.default">
<!-- please see: TalendThemeConstants.TALEND_DEFAULT_THEME_ID -->
</theme>
<!--
<theme
basestylesheeturi="themes/dark/e4-dark_linux.css"
id="org.eclipse.e4.ui.css.theme.e4_dark"
@@ -36,7 +35,6 @@
os="macosx"
os_version="10.11,10.12,10.13">
</theme>
-->
<stylesheet
uri="themes/dark/dark/e4-dark_preferencestyle.css">
<themeid