Compare commits

...

2 Commits

Author SHA1 Message Date
Chao MENG
25d85e037c chore: support dark theme 2022-09-17 19:31:44 +08:00
zyuan-talend
04398681f2 fix(TUP-35745): Research: Bring a dark mode for Talend Studio. (#7966) 2022-09-17 19:31:36 +08:00
3 changed files with 70 additions and 5 deletions

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.designer.core.ui.editor;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.FreeformFigure;
import org.eclipse.draw2d.Graphics;
@@ -19,9 +20,9 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.editparts.GridLayer;
import org.eclipse.swt.graphics.Color;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.runtime.service.ITalendThemeService;
import org.talend.commons.ui.gmf.draw2d.AnimatableZoomManager;
import org.talend.commons.ui.runtime.image.EImage;
import org.talend.commons.ui.runtime.image.ImageProvider;
/**
* Grid that will be used for the designer. (modification of the default grid to have black points)
@@ -33,9 +34,64 @@ public class TalendGridLayer extends GridLayer {
public static final Color GRID_COLOR = ColorConstants.black;
private static final Color GRID_COLOR_1 = new Color(131, 131, 131);
private static final Color GRID_COLOR_2 = new Color(255, 255, 255);
private static ITalendThemeService themeServ;
public TalendGridLayer() {
super();
setForegroundColor(GRID_COLOR);
setForegroundColor(ColorConstants.red);
}
private static ITalendThemeService getTheme() {
if (themeServ == null) {
themeServ = ITalendThemeService.get();
}
return themeServ;
}
private Color getThemeColor(String prop) {
ITalendThemeService theme = getTheme();
if (theme == null) {
return null;
}
return (Color) theme.getGlobalThemeColor(prop);
}
private Color getColor1() {
Color themeColor = getThemeColor("DESIGNER_COLOR_A");
if (themeColor == null) {
themeColor = GRID_COLOR_1;
}
return themeColor;
}
private Color getColor2() {
Color themeColor = getThemeColor("DESIGNER_COLOR_B");
if (themeColor == null) {
themeColor = GRID_COLOR_2;
}
return themeColor;
}
private int getColorAlpha() {
final int defaultAlpha = 30;
ITalendThemeService theme = getTheme();
if (theme == null) {
return defaultAlpha;
}
String alpha = theme.getGlobalThemeProp("DESIGNER_COLOR_ALPHA");
if (StringUtils.isBlank(alpha)) {
return defaultAlpha;
}
try {
return Integer.valueOf(alpha);
} catch (Exception e) {
ExceptionHandler.process(e);
}
return defaultAlpha;
}
@Override
@@ -71,13 +127,18 @@ public class TalendGridLayer extends GridLayer {
origin.y += distanceY;
}
}
g.setAlpha(getColorAlpha());
for (int i = origin.x - distanceX; i < clip.x + clip.width; i += distanceX) {
for (int j = origin.y - distanceY; j < clip.y + clip.height; j += distanceY) {
// g.drawPoint(i, j);
// g.drawPoint(i, j);
int re = Math.abs(i - j);
if (re / distanceY % 2 == 0) {
g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
g.setBackgroundColor(getColor1());
// g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
} else {
g.setBackgroundColor(getColor2());
}
g.fillRectangle(i, j, 32, 32);
}
}
}

View File

@@ -107,6 +107,8 @@ public class TalendDrawerFigure extends DrawerFigure {
drawerLabelField.setAccessible(true);
talendDrawerLabel = new Label();
talendDrawerLabel.setFont(JFaceResources.getFontRegistry().getBold("TalendDrawerFigureSymbolicName"));
// TUP-35745
talendDrawerLabel.setForegroundColor(cssStyleSetting.getMouseOverForgroundColor3());
talendDrawerLabel.setLabelAlignment(Label.LEFT);
drawerLabelField.set(this, talendDrawerLabel);

View File

@@ -80,6 +80,8 @@ public class TalendEntryEditPart extends ToolEntryEditPart {
customLabelField = ToolEntryEditPart.class.getDeclaredField("customLabel"); //$NON-NLS-1$
customLabelField.setAccessible(true);
customLabelField.set(this, talendCustomLabel);
// TUP-35745
talendCustomLabel.setForegroundColor(cssStyleSetting.getMouseOverForgroundColor3());
} catch (Exception e) {
CommonExceptionHandler.process(e);
}