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

#8366 Default connection types for light/dark themes


Former-commit-id: 1b385edb
上级 2457bfea
......@@ -111,8 +111,10 @@ page.org.jkiss.dbeaver.preferences.main.qm.name = Query Manager
page.org.jkiss.dbeaver.preferences.connectionTypes.name = Connection Types
page.org.jkiss.dbeaver.project.settings.networkProfiles.name = Network Profiles
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.label = Transactions
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.description = Transactions colors
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.label = Database Transactions
themeElementCategory.org.jkiss.dbeaver.ui.presentation.txn.description = Database transaction state colors
themeElementCategory.org.jkiss.dbeaver.ui.presentation.colors.connectionTypes.label = Database connection types
themeElementCategory.org.jkiss.dbeaver.ui.presentation.colors.connectionTypes.description = Colors for predefined connection types
colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.label = Committed transaction
colorDefinition.org.jkiss.dbeaver.txn.color.committed.background.description = Committed transaction background
......
......@@ -50,4 +50,8 @@
'org.jkiss.dbeaver.hex.editor.color.caret=80,80,80'
'org.jkiss.dbeaver.hex.editor.color.text=255,255,255'
'org.jkiss.dbeaver.color.connectionType.qa.background=0,115,0'
'org.jkiss.dbeaver.color.connectionType.prod.background=140,0,0'
}
......@@ -1076,6 +1076,26 @@
<description>%colorDefinition.org.jkiss.dbeaver.txn.color.transaction.background.description</description>
</colorDefinition>
<!-- Colors for connection types -->
<themeElementCategory label="%themeElementCategory.org.jkiss.dbeaver.ui.presentation.colors.connectionTypes.label" id="org.jkiss.dbeaver.ui.presentation.colors.connectionTypes">
<description>%themeElementCategory.org.jkiss.dbeaver.ui.presentation.colors.connectionTypes.description</description>
</themeElementCategory>
<colorDefinition
label="Test"
categoryId="org.jkiss.dbeaver.ui.presentation.colors.connectionTypes"
id="org.jkiss.dbeaver.color.connectionType.qa.background"
value="196,255,181">
<description>QA/Test/Stage server</description>
</colorDefinition>
<colorDefinition
label="Production"
categoryId="org.jkiss.dbeaver.ui.presentation.colors.connectionTypes"
id="org.jkiss.dbeaver.color.connectionType.prod.background"
value="247,159,129">
<description>Production server</description>
</colorDefinition>
</extension>
<extension point="org.eclipse.ui.exportWizards">
......
......@@ -17,8 +17,8 @@ import java.util.List;
public class DBPConnectionType implements DBPDataSourcePermissionOwner {
public static final DBPConnectionType DEV = new DBPConnectionType("dev", ModelMessages.dbp_connection_type_table_development, "255,255,255", ModelMessages.dbp_connection_type_table_regular_development_database, true, false, false, true, null); //$NON-NLS-1$ //$NON-NLS-3$
public static final DBPConnectionType TEST = new DBPConnectionType("test", ModelMessages.dbp_connection_type_table_test, "196,255,181", ModelMessages.dbp_connection_type_table_test_database, true, false, true, true, null); //$NON-NLS-1$ //$NON-NLS-3$
public static final DBPConnectionType PROD = new DBPConnectionType("prod", ModelMessages.dbp_connection_type_table_production, "247,159,129", ModelMessages.dbp_connection_type_table_production_database, false, true, true, true, null); //$NON-NLS-1$ //$NON-NLS-3$
public static final DBPConnectionType TEST = new DBPConnectionType("test", ModelMessages.dbp_connection_type_table_test, "org.jkiss.dbeaver.color.connectionType.qa.background", ModelMessages.dbp_connection_type_table_test_database, true, false, true, true, null); //$NON-NLS-1$ //$NON-NLS-3$
public static final DBPConnectionType PROD = new DBPConnectionType("prod", ModelMessages.dbp_connection_type_table_production, "org.jkiss.dbeaver.color.connectionType.prod.background", ModelMessages.dbp_connection_type_table_production_database, false, true, true, true, null); //$NON-NLS-1$ //$NON-NLS-3$
public static final DBPConnectionType[] SYSTEM_TYPES = {DEV, TEST, PROD};
public static final DBPConnectionType DEFAULT_TYPE = DEV;
......
......@@ -1793,25 +1793,34 @@ public class UIUtils {
if (CommonUtils.isEmpty(rgbString)) {
return null;
}
return getColorByRGB(rgbString);
return getConnectionColorByRGB(rgbString);
}
public static Color getColorByRGB(String rgbString) {
Color connectionColor = sharedTextColors.getColor(rgbString);
if (connectionColor.getBlue() == 255 && connectionColor.getRed() == 255 && connectionColor.getGreen() == 255) {
// For white color return just null to avoid explicit color set.
// It is important for dark themes
public static Color getConnectionTypeColor(DBPConnectionType connectionType) {
String rgbString = connectionType.getColor();
if (CommonUtils.isEmpty(rgbString)) {
return null;
}
return connectionColor;
return getConnectionColorByRGB(rgbString);
}
public static Color getConnectionTypeColor(DBPConnectionType connectionType) {
String rgbString = connectionType.getColor();
if (CommonUtils.isEmpty(rgbString)) {
public static Color getConnectionColorByRGB(String rgbStringOrId) {
if (rgbStringOrId.isEmpty()) {
return null;
}
return getColorByRGB(rgbString);
if (Character.isAlphabetic(rgbStringOrId.charAt(0))) {
// Some color constant
RGB rgb = getActiveWorkbenchWindow().getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().getRGB(rgbStringOrId);
return sharedTextColors.getColor(rgb);
} else {
Color connectionColor = sharedTextColors.getColor(rgbStringOrId);
if (connectionColor.getBlue() == 255 && connectionColor.getRed() == 255 && connectionColor.getGreen() == 255) {
// For white color return just null to avoid explicit color set.
// It is important for dark themes
return null;
}
return connectionColor;
}
}
public static Shell createCenteredShell(Shell parent) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册