Skip to content

Commit

Permalink
[GEF] Externalise palette background color into CSS Theme ColorDefini…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Phillipus committed Sep 3, 2021
1 parent efdd12c commit b79e907
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 11 deletions.
8 changes: 8 additions & 0 deletions com.archimatetool.editor.themes/themes/archi/css/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ FigureCanvas.ArchiFigureCanvas,
Graph.ArchiGraph {
background-color: #FFFFFF;
}

ThemesExtension {
color-definition: '#org-eclipse-gef-PALETTE_BACKGROUND';
}

ColorDefinition#org-eclipse-gef-PALETTE_BACKGROUND {
color: #FFFFFF;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ ThemesExtension { color-definition:
'#org-eclipse-ui-workbench-ACTIVE_NOFOCUS_TAB_BG_END',
'#org-eclipse-ui-workbench-ACTIVE_NOFOCUS_TAB_TEXT_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_NOFOCUS_TAB_SELECTED_TEXT_COLOR',
'#org-eclipse-ui-workbench-LINK_COLOR';
'#org-eclipse-ui-workbench-LINK_COLOR',
'#org-eclipse-gef-PALETTE_BACKGROUND'; /* Added by Archi for GEF Palette */
}

/* Added by Archi for GEF Palette */
ColorDefinition#org-eclipse-gef-PALETTE_BACKGROUND {
color: #EEEEEE;
}

ColorDefinition#org-eclipse-ui-workbench-DARK_BACKGROUND {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ ThemesExtension { color-definition:
'#org-eclipse-ui-workbench-ACTIVE_TAB_OUTER_KEYLINE_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_TAB_INNER_KEYLINE_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_TAB_OUTLINE_COLOR',
'#org-eclipse-ui-workbench-INACTIVE_TAB_TEXT_COLOR';
'#org-eclipse-ui-workbench-INACTIVE_TAB_TEXT_COLOR',
'#org-eclipse-gef-PALETTE_BACKGROUND'; /* Added by Archi for GEF Palette */
}

/* Added by Archi for GEF Palette */
ColorDefinition#org-eclipse-gef-PALETTE_BACKGROUND {
color: #FFFFFF;
}

ColorDefinition#org-eclipse-ui-workbench-INACTIVE_UNSELECTED_TABS_COLOR_START {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ ThemesExtension { color-definition:
'#org-eclipse-ui-workbench-ACTIVE_TAB_OUTER_KEYLINE_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_TAB_INNER_KEYLINE_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_TAB_OUTLINE_COLOR',
'#org-eclipse-ui-workbench-ACTIVE_TAB_SELECTED_TEXT_COLOR';
'#org-eclipse-ui-workbench-ACTIVE_TAB_SELECTED_TEXT_COLOR',
'#org-eclipse-gef-PALETTE_BACKGROUND'; /* Added by Archi for GEF Palette */
}

/* Added by Archi for GEF Palette */
ColorDefinition#org-eclipse-gef-PALETTE_BACKGROUND {
color: #FFFFFF;
}

ColorDefinition#org-eclipse-ui-workbench-INACTIVE_UNSELECTED_TABS_COLOR_START {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,39 @@

package org.eclipse.gef.internal.ui.palette;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.themes.ColorDefinition;
import org.eclipse.ui.internal.themes.IThemeRegistry;

/**
* A class to keep miscellaneous palette color utilities.
*
* @author crevells
* @since 3.4
*/
@SuppressWarnings({"nls", "restriction"})
public class PaletteColorUtil {

/**
* Added by Phillipus - get a theme color from the theme registry
*/
private static Color getThemeColor(final String id, RGB defaultColor) {
IThemeRegistry reg = WorkbenchPlugin.getDefault().getThemeRegistry();
ColorDefinition colorDef = reg.findColor(id);
if(colorDef != null && colorDef.getValue() != null) {
defaultColor = colorDef.getValue();
}

return new Color(defaultColor);
}

public static final Color PALETTE_BACKGROUND = getThemeColor("org.eclipse.gef.PALETTE_BACKGROUND", new RGB(255, 255, 255));

public static final Color WIDGET_BACKGROUND = ColorConstants.button;

public static final Color WIDGET_NORMAL_SHADOW = ColorConstants.buttonDarker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,11 @@ private void createScrollpane() {
scrollpane.setLayoutManager(new OverlayScrollPaneLayout());
scrollpane.setContents(new Figure());
scrollpane.getContents().setOpaque(true);
// Added by Phillipus - use CSS theme defined color
//scrollpane.getContents().setBackgroundColor(
// PaletteColorUtil.WIDGET_LIST_BACKGROUND);
scrollpane.getContents().setBackgroundColor(
PaletteColorUtil.WIDGET_LIST_BACKGROUND);
PaletteColorUtil.PALETTE_BACKGROUND);
}

IFigure buildTooltip() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public GroupEditPart(PaletteContainer group) {
public IFigure createFigure() {
Figure figure = new Figure();
figure.setOpaque(true);
figure.setBackgroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND);
// Added by Phillipus - use CSS theme defined color
// figure.setBackgroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND);
figure.setBackgroundColor(PaletteColorUtil.PALETTE_BACKGROUND);
return figure;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.ToolbarLayout;

import org.eclipse.gef.internal.ui.palette.PaletteColorUtil;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.palette.PaletteViewer;
import org.eclipse.gef.ui.palette.editparts.PaletteAnimator;
Expand All @@ -34,7 +34,9 @@ public IFigure createFigure() {
Figure figure = new Figure();
figure.setOpaque(true);
figure.setForegroundColor(ColorConstants.listForeground);
figure.setBackgroundColor(ColorConstants.listBackground);
// Added by Phillipus - use CSS theme defined color
// figure.setBackgroundColor(ColorConstants.listBackground);
figure.setBackgroundColor(PaletteColorUtil.PALETTE_BACKGROUND);
return figure;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ protected void paintFigure(Graphics graphics) {

};
figure.setOpaque(true);
figure.setBackgroundColor(PaletteColorUtil.WIDGET_BACKGROUND);
// Added by Phillipus - use CSS theme defined color
// figure.setBackgroundColor(PaletteColorUtil.WIDGET_BACKGROUND);
figure.setBackgroundColor(PaletteColorUtil.PALETTE_BACKGROUND);
figure.setBorder(new MarginBorder(2, 1, 1, 1));

return figure;
Expand Down

0 comments on commit b79e907

Please sign in to comment.