From 2330af998333bdda35f3c1959db384602fc9f58f Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Wed, 31 Jan 2024 14:52:42 -0500 Subject: [PATCH 01/24] Remove extra space at the bottom of the canvas --- .../client/widget/panel/impl/ScrollablePanel.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/lienzo-core/src/main/java/com/ait/lienzo/client/widget/panel/impl/ScrollablePanel.java b/packages/serverless-workflow-diagram-editor/lienzo-core/src/main/java/com/ait/lienzo/client/widget/panel/impl/ScrollablePanel.java index bbbbc1fccbe..3adaf87e2b4 100644 --- a/packages/serverless-workflow-diagram-editor/lienzo-core/src/main/java/com/ait/lienzo/client/widget/panel/impl/ScrollablePanel.java +++ b/packages/serverless-workflow-diagram-editor/lienzo-core/src/main/java/com/ait/lienzo/client/widget/panel/impl/ScrollablePanel.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package com.ait.lienzo.client.widget.panel.impl; @@ -49,7 +49,6 @@ public class ScrollablePanel extends LienzoBoundsPanel { private static final Bounds EMPTY = Bounds.empty(); private static final int DRAG_BOUNDS_LIMIT_SIZE = 50; - private static final int PADDING_OFFSET = 4; private final HTMLDivElement domElementContainer = createDiv(); private final HTMLDivElement internalScrollPanel = createDiv(); @@ -491,12 +490,9 @@ public double getVerticalScrollRate() { private void updatePanelsSizes(final int widePx, final int highPx) { - // Adjust high to avoid horizontal scrollbar overlap - final int highPxFixed = highPx - PADDING_OFFSET; - - setPanelSize(scrollPanel, widePx, highPxFixed); + setPanelSize(scrollPanel, widePx, highPx); final int w = widePx - scrollbarWidth(); - final int h = highPxFixed - scrollbarHeight(); + final int h = highPx - scrollbarHeight(); setPanelSize(domElementContainer, w, h); getLienzoPanel().setPixelSize(w, h); } From d436372c38308f1a1ca5359712a4f67355e25e94 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Wed, 31 Jan 2024 17:44:23 -0500 Subject: [PATCH 02/24] Add theme support to stunner --- .../mediators/ZoomLevelSelector.java | 6 ++ .../mediators/ZoomLevelSelectorPresenter.java | 1 + .../mediators/ZoomLevelSelectorView.css | 76 ++++++++++++++++ .../mediators/ZoomLevelSelectorView.html | 13 +-- .../mediators/ZoomLevelSelectorView.java | 15 ++++ .../view/wires/ext/WiresConnectorViewExt.java | 12 +-- .../ZoomLevelSelectorPresenterTest.java | 1 + .../mediators/ZoomLevelSelectorViewTest.java | 33 +++++++ .../impl/ShapeStateAttributesFactory.java | 24 ++---- .../core/client/theme/DefaultTheme.java | 86 +++++++++++++++++++ .../core/client/theme/StunnerColorTheme.java | 39 +++++++++ .../core/client/theme/StunnerTheme.java | 34 ++++++++ .../impl/ShapeStateAttributesFactoryTest.java | 40 ++++++--- .../core/client/theme/StunnerThemeTest.java | 46 ++++++++++ 14 files changed, 386 insertions(+), 40 deletions(-) create mode 100644 packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/DefaultTheme.java create mode 100644 packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerColorTheme.java create mode 100644 packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerTheme.java create mode 100644 packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelector.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelector.java index 6d16ba4e2bf..efa9f7cb0d9 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelector.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelector.java @@ -48,6 +48,8 @@ void add(String text, void updatePreviewButton(boolean enabled); void dropUp(); + + void applyTheme(); } private final View view; @@ -155,6 +157,10 @@ void onDecreaseLevel() { onDecreaseLevel.execute(); } + void applyTheme() { + view.applyTheme(); + } + @PreDestroy public void destroy() { onIncreaseLevel = null; diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenter.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenter.java index 6e3390b7a15..87be94e4104 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenter.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenter.java @@ -185,6 +185,7 @@ public ZoomLevelSelectorPresenter show() { zoomLevelInit = false; } else { cancelHide(); + selector.applyTheme(); floatingView.show(); reposition(); } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css index abcd46e2ea4..6f7adc5b4a0 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css @@ -27,3 +27,79 @@ max-height: 250px; overflow-y: auto; } + +.button-light { + color: #212529; + background-color: #f8f9fa; + border-color: #f8f9fa; +} + +.button-light:hover { + color: #212529; + background-color: #e2e6ea; + border-color: #dae0e5; +} + +.button-light:focus, +.button-light.focus { + box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); +} + +.button-light.disabled, +.button-light:disabled { + color: #a8a8a8; + background-color: #f8f9fa; + border-color: #f8f9fa; +} + +.button-light:not(:disabled):not(.disabled):active, +.button-light:not(:disabled):not(.disabled).active, +.show > .button-light.dropdown-toggle { + color: #212529; + background-color: #dae0e5; + border-color: #d3d9df; +} + +.button-light:not(:disabled):not(.disabled):active:focus, +.button-light:not(:disabled):not(.disabled).active:focus, +.show > .button-light.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); +} + +.button-dark { + color: #fff; + background-color: #292a2d; + border-color: #343a40; +} + +.button-dark:hover { + color: #fff; + background-color: #000000; + border-color: #1d2124; +} + +.button-dark:focus, +.button-dark.focus { + box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); +} + +.button-dark.disabled, +.button-dark:disabled { + color: #909090; + background-color: #343a40; + border-color: #343a40; +} + +.button-dark:not(:disabled):not(.disabled):active, +.button-dark:not(:disabled):not(.disabled).active, +.show > .button-dark.dropdown-toggle { + color: #fff; + background-color: #1d2124; + border-color: #171a1d; +} + +.button-dark:not(:disabled):not(.disabled):active:focus, +.button-dark:not(:disabled):not(.disabled).active:focus, +.show > .button-dark.dropdown-toggle:focus { + box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); +} diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html index 8f881b63824..cb4144b3bb6 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html @@ -23,7 +23,7 @@ style="display: inline-flex" data-ouia-component-id="zoom-controls-panel" > - - -
- diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java index f397ec3b5b0..f6a1e8eed71 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java @@ -38,6 +38,7 @@ import jakarta.inject.Named; import org.jboss.errai.common.client.dom.DOMUtil; import org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.i18n.CoreTranslationMessages; import org.uberfire.mvp.Command; @@ -47,6 +48,8 @@ public class ZoomLevelSelectorView implements ZoomLevelSelector.View { static final String CSS_DROP_UP = "dropup"; + static final String LIGHT_STYLE = "button-light"; + static final String DARK_STYLE = "button-dark"; @Inject @DataField @@ -144,6 +147,18 @@ public void updatePreviewButton(boolean enabled) { previewButton.disabled = (!enabled); } + @Override + public void applyTheme() { + String className = StunnerTheme.getTheme().isDarkTheme() ? DARK_STYLE : LIGHT_STYLE; + + if (null == previewButton.className || !previewButton.className.equals(className)) { + previewButton.className = + resetButton.className = + increaseButton.className = + decreaseButton.className = className; + } + } + @EventHandler("previewButton") void onPreview(@ForEvent("click") Event event) { presenter.onPreview(); diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/shape/view/wires/ext/WiresConnectorViewExt.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/shape/view/wires/ext/WiresConnectorViewExt.java index 13530ece6a4..c6b0a07edd5 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/shape/view/wires/ext/WiresConnectorViewExt.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/shape/view/wires/ext/WiresConnectorViewExt.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -34,6 +34,7 @@ import org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent; import org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType; import org.kie.workbench.common.stunner.core.client.shape.view.event.ViewHandler; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; public class WiresConnectorViewExt extends WiresConnectorView @@ -107,8 +108,9 @@ public T enableHandlers() { public T setTitle(final String title) { return Optional.ofNullable(title) .map(t -> label.map(l -> l.configure(text -> { - text.setFillColor("white"); - text.setStrokeColor("white"); + text.setFillColor(StunnerTheme.getTheme().getEdgeTextFillColor()); + text.setStrokeColor(StunnerTheme.getTheme().getEdgeTextStrokeColor()); + text.setStrokeWidth(0.70); text.setFontFamily("Verdana"); text.setFontSize(10); text.setText(t); diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenterTest.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenterTest.java index 2e58bbf87bc..16bb839cc66 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenterTest.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorPresenterTest.java @@ -190,6 +190,7 @@ public void testAt() { public void testShow() { tested.show(); verify(floatingView, times(1)).show(); + verify(selector, times(1)).applyTheme(); } @Test diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorViewTest.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorViewTest.java index bb242cb2168..5af9be0cbc4 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorViewTest.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/test/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorViewTest.java @@ -33,11 +33,14 @@ import org.junit.runner.RunWith; import org.kie.workbench.common.stunner.core.client.api.SessionManager; import org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService; +import org.kie.workbench.common.stunner.core.client.theme.StunnerColorTheme; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.util.DefinitionUtils; import org.kie.workbench.common.stunner.core.validation.DiagramElementNameProvider; import org.mockito.Mock; import org.uberfire.mvp.Command; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -166,4 +169,34 @@ public void testDestroy() { tested.destroy(); verify(items, times(1)).destroyAll(); } + + @Test + public void testApplyThemeLight() { + StunnerColorTheme theme = mock(StunnerColorTheme.class); + when(theme.isDarkTheme()).thenReturn(false); + StunnerTheme.setTheme(theme); + + tested.init(presenter); + tested.applyTheme(); + + assertEquals(ZoomLevelSelectorView.LIGHT_STYLE, tested.previewButton.className); + assertEquals(ZoomLevelSelectorView.LIGHT_STYLE, tested.resetButton.className); + assertEquals(ZoomLevelSelectorView.LIGHT_STYLE, tested.increaseButton.className); + assertEquals(ZoomLevelSelectorView.LIGHT_STYLE, tested.decreaseButton.className); + } + + @Test + public void testApplyThemeDark() { + StunnerColorTheme theme = mock(StunnerColorTheme.class); + when(theme.isDarkTheme()).thenReturn(true); + StunnerTheme.setTheme(theme); + + tested.init(presenter); + tested.applyTheme(); + + assertEquals(ZoomLevelSelectorView.DARK_STYLE, tested.previewButton.className); + assertEquals(ZoomLevelSelectorView.DARK_STYLE, tested.resetButton.className); + assertEquals(ZoomLevelSelectorView.DARK_STYLE, tested.increaseButton.className); + assertEquals(ZoomLevelSelectorView.DARK_STYLE, tested.decreaseButton.className); + } } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactory.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactory.java index d95a08666f3..3743afdf136 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactory.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactory.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -23,16 +23,10 @@ import org.kie.workbench.common.stunner.core.client.shape.ShapeState; import org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttribute; import org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttributes; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; public class ShapeStateAttributesFactory { - static final String COLOR_SELECTED = "#0066CC"; - static final String COLOR_HIGHLIGHT = "#4F5255"; - static final String COLOR_INVALID = "#FF0000"; - - static final String FILL_COLOR_SELECTED = "#E7F1FA"; - static final String FILL_COLOR_INVALID = "#fff"; - public static ShapeStateAttributes buildStateAttributes(final ShapeState state) { final String COLOR = getAttributeColorByState(state); final String FILL_COLOR = getFillAttributeColorByState(state); @@ -56,11 +50,11 @@ public static ShapeStateAttributes buildStateAttributes(final ShapeState state) private static String getAttributeColorByState(final ShapeState state) { switch (state) { case SELECTED: - return COLOR_SELECTED; + return StunnerTheme.getTheme().getShapeStrokeColorSelected(); case HIGHLIGHT: - return COLOR_HIGHLIGHT; + return StunnerTheme.getTheme().getShapeStrokeColorHighlight(); case INVALID: - return COLOR_INVALID; + return StunnerTheme.getTheme().getShapeStrokeColorInvalid(); default: return null; } @@ -69,9 +63,9 @@ private static String getAttributeColorByState(final ShapeState state) { private static String getFillAttributeColorByState(final ShapeState state) { switch (state) { case SELECTED: - return FILL_COLOR_SELECTED; + return StunnerTheme.getTheme().getShapeFillColorSelected(); case INVALID: - return FILL_COLOR_INVALID; + return StunnerTheme.getTheme().getShapeFillColorInvalid(); default: return null; } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/DefaultTheme.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/DefaultTheme.java new file mode 100644 index 00000000000..aa73901ebb4 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/DefaultTheme.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.core.client.theme; + +public class DefaultTheme implements StunnerColorTheme { + + static StunnerColorTheme instance; + + // Shape states + static final String SHAPE_STROKE_COLOR_SELECTED = "#0066CC"; + static final String SHAPE_STROKE_COLOR_HIGHLIGHT = "#4F5255"; + static final String SHAPE_STROKE_COLOR_INVALID = "#FF0000"; + static final String SHAPE_FILL_COLOR_SELECTED = "#E7F1FA"; + static final String SHAPE_FILL_COLOR_INVALID = "#fff"; + // Transition text box + static final String EDGE_TEXT_FILL_COLOR = "white"; + static final String EDGE_TEXT_STROKE_COLOR = "white"; + + private DefaultTheme() { + } + + public static StunnerColorTheme getInstance() { + if (null == instance) { + instance = new DefaultTheme(); + } + + return instance; + } + + @Override + public String getShapeStrokeColorSelected() { + return SHAPE_STROKE_COLOR_SELECTED; + } + + @Override + public String getShapeStrokeColorHighlight() { + return SHAPE_STROKE_COLOR_HIGHLIGHT; + } + + @Override + public String getShapeStrokeColorInvalid() { + return SHAPE_STROKE_COLOR_INVALID; + } + + @Override + public String getShapeFillColorSelected() { + return SHAPE_FILL_COLOR_SELECTED; + } + + @Override + public String getShapeFillColorInvalid() { + return SHAPE_FILL_COLOR_INVALID; + } + + @Override + public String getEdgeTextFillColor() { + return EDGE_TEXT_FILL_COLOR; + } + + @Override + public String getEdgeTextStrokeColor() { + return EDGE_TEXT_STROKE_COLOR; + } + + @Override + public boolean isDarkTheme() { + return false; + } +} diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerColorTheme.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerColorTheme.java new file mode 100644 index 00000000000..ecbac7592f5 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerColorTheme.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.core.client.theme; + +public interface StunnerColorTheme { + + String getShapeStrokeColorSelected(); + + String getShapeStrokeColorHighlight(); + + String getShapeStrokeColorInvalid(); + + String getShapeFillColorSelected(); + + String getShapeFillColorInvalid(); + + String getEdgeTextFillColor(); + + String getEdgeTextStrokeColor(); + + boolean isDarkTheme(); +} diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerTheme.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerTheme.java new file mode 100644 index 00000000000..7d02899436f --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/main/java/org/kie/workbench/common/stunner/core/client/theme/StunnerTheme.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.core.client.theme; + +public class StunnerTheme { + + // Initialize stunner default theme + private static StunnerColorTheme theme = DefaultTheme.getInstance(); + + public static void setTheme(StunnerColorTheme colorTheme) { + theme = colorTheme; + } + + public static StunnerColorTheme getTheme() { + return theme; + } +} diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactoryTest.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactoryTest.java index f73d77972be..800a6932820 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactoryTest.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/shape/impl/ShapeStateAttributesFactoryTest.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -25,6 +25,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.kie.workbench.common.stunner.core.client.shape.ShapeState; +import org.kie.workbench.common.stunner.core.client.theme.StunnerColorTheme; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.mockito.junit.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; @@ -32,31 +34,47 @@ import static org.kie.workbench.common.stunner.core.client.shape.ShapeState.INVALID; import static org.kie.workbench.common.stunner.core.client.shape.ShapeState.NONE; import static org.kie.workbench.common.stunner.core.client.shape.ShapeState.SELECTED; +import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttribute.FILL_ALPHA; +import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttribute.FILL_COLOR; import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttribute.STROKE_ALPHA; import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributeHandler.ShapeStateAttribute.STROKE_COLOR; -import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributesFactory.COLOR_HIGHLIGHT; -import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributesFactory.COLOR_INVALID; -import static org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateAttributesFactory.COLOR_SELECTED; @RunWith(MockitoJUnitRunner.class) public class ShapeStateAttributesFactoryTest { - private Function strokeAttributes = ShapeStateAttributesFactory::buildStateAttributes; + private StunnerColorTheme theme = StunnerTheme.getTheme(); + private Function stateAttributes = ShapeStateAttributesFactory::buildStateAttributes; @Test public void testBuildStrokeAttributes() { - ShapeStateAttributeHandler.ShapeStateAttributes attributes = strokeAttributes.apply(NONE); + ShapeStateAttributeHandler.ShapeStateAttributes attributes = stateAttributes.apply(NONE); attributes.getValues().values().forEach( state -> assertEquals(null, state) ); - assertStrokeAttributes(strokeAttributes.apply(SELECTED), COLOR_SELECTED); - assertStrokeAttributes(strokeAttributes.apply(HIGHLIGHT), COLOR_HIGHLIGHT); - assertStrokeAttributes(strokeAttributes.apply(INVALID), COLOR_INVALID); + assertStrokeAttributes(stateAttributes.apply(SELECTED), theme.getShapeStrokeColorSelected()); + assertStrokeAttributes(stateAttributes.apply(HIGHLIGHT), theme.getShapeStrokeColorHighlight()); + assertStrokeAttributes(stateAttributes.apply(INVALID), theme.getShapeStrokeColorInvalid()); + } + + @Test + public void testBuildFillAttributes() { + ShapeStateAttributeHandler.ShapeStateAttributes attributes = stateAttributes.apply(NONE); + attributes.getValues().values().forEach( + state -> assertEquals(null, state) + ); + + assertFillAttributes(stateAttributes.apply(SELECTED), theme.getShapeFillColorSelected()); + assertFillAttributes(stateAttributes.apply(INVALID), theme.getShapeFillColorInvalid()); } private void assertStrokeAttributes(ShapeStateAttributeHandler.ShapeStateAttributes attributes, String color) { assertEquals(1d, attributes.getValues().get(STROKE_ALPHA)); assertEquals(color, attributes.getValues().get(STROKE_COLOR)); } + + private void assertFillAttributes(ShapeStateAttributeHandler.ShapeStateAttributes attributes, String color) { + assertEquals(1d, attributes.getValues().get(FILL_ALPHA)); + assertEquals(color, attributes.getValues().get(FILL_COLOR)); + } } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java new file mode 100644 index 00000000000..3b1a9599e0d --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.core.client.theme; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +@RunWith(MockitoJUnitRunner.class) +public class StunnerThemeTest { + + private StunnerColorTheme theme = StunnerTheme.getTheme(); + + @Test + public void testDefaultTheme() { + assertTrue(theme instanceof DefaultTheme); + } + + @Test + public void testSetTheme() { + final StunnerColorTheme someTheme = mock(StunnerColorTheme.class); + StunnerTheme.setTheme(someTheme); + assertEquals(someTheme, StunnerTheme.getTheme()); + } + +} From 196e28bf69c4fd7008997c1a1db9c5fec6421faa Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Thu, 1 Feb 2024 15:03:50 -0500 Subject: [PATCH 03/24] Fix import order --- .../common/stunner/core/client/theme/StunnerThemeTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java index 3b1a9599e0d..9828d9d8c3b 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-core/kie-wb-common-stunner-commons/kie-wb-common-stunner-client-common/src/test/java/org/kie/workbench/common/stunner/core/client/theme/StunnerThemeTest.java @@ -22,8 +22,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; -import static org.junit.Assert.assertTrue; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @RunWith(MockitoJUnitRunner.class) @@ -42,5 +43,4 @@ public void testSetTheme() { StunnerTheme.setTheme(someTheme); assertEquals(someTheme, StunnerTheme.getTheme()); } - } From e1b8d4088a8d00010f2562049c6ac467658ab69f Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Thu, 1 Feb 2024 15:25:32 -0500 Subject: [PATCH 04/24] Expose setTheme method in js --- .../main/java/org/uberfire/client/mvp/EditorActivity.java | 8 +++++--- .../src/main/java/org/uberfire/client/util/GWTEditor.java | 4 ++++ .../java/org/uberfire/client/util/GWTEditor.native.js | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java index d02d1ef7228..156bebc0e2f 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.uberfire.client.mvp; @@ -27,6 +27,8 @@ public interface EditorActivity extends Activity { + Promise setTheme(String theme); + Promise setContent(String path, String value); default Promise selectStateByName(String name) { diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java index 2f4653d0dee..0b44e248df5 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java @@ -40,6 +40,10 @@ public final void onOpen() { instance.onOpen(); } + public final Promise setTheme(String theme) { + return instance.setTheme(theme); + } + public final Promise setContent(String path, String value) { return instance.setContent(path, value); } diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js index f12fe469681..6ba5ab9eec8 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js @@ -1,4 +1,5 @@ goog.exportProperty(GWTEditor.prototype, "onOpen", GWTEditor.prototype.onOpen); +goog.exportProperty(GWTEditor.prototype, "setTheme", GWTEditor.prototype.setTheme); goog.exportProperty(GWTEditor.prototype, "setContent", GWTEditor.prototype.setContent); goog.exportProperty(GWTEditor.prototype, "selectStateByName", GWTEditor.prototype.selectStateByName); goog.exportProperty(GWTEditor.prototype, "getContent", GWTEditor.prototype.getContent); From 414af6f28482f96f9b2832604ceab397c2bb53dd Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Thu, 1 Feb 2024 15:37:35 -0500 Subject: [PATCH 05/24] SWF Theme support --- .../mediators/ZoomLevelSelectorView.css | 50 ++-- .../mediators/ZoomLevelSelectorView.java | 4 +- .../sw/client/shapes/CallbackStateShape.java | 5 +- .../sw/client/shapes/EventStateShape.java | 11 +- .../sw/client/shapes/ForEachStateShape.java | 5 +- .../sw/client/shapes/InjectStateShape.java | 5 +- .../sw/client/shapes/OperationStateShape.java | 5 +- .../sw/client/shapes/ParallelStateShape.java | 5 +- .../shapes/ServerlessWorkflowShapeView.java | 14 +- .../sw/client/shapes/SleepStateShape.java | 5 +- .../sw/client/shapes/StateShapeView.java | 20 +- .../sw/client/shapes/SwitchStateShape.java | 5 +- .../sw/client/shapes/TransitionShape.java | 28 +- .../client/shapes/icons/BottomDepiction.java | 12 +- .../sw/client/shapes/icons/BottomText.java | 10 +- .../sw/client/shapes/icons/CornerIcon.java | 9 +- .../sw/client/shapes/icons/DataDepiction.java | 4 +- .../stunner/sw/client/theme/ColorTheme.java | 85 ++++++ .../stunner/sw/client/theme/DarkMode.java | 277 ++++++++++++++++++ .../stunner/sw/client/theme/LightMode.java | 277 ++++++++++++++++++ .../sw/client/shapes/StateShapeTest.java | 38 +-- .../sw/client/editor/DiagramEditor.java | 39 ++- .../client/editor/DiagramEditorActivity.java | 5 + .../sw/client/editor/DiagramEditorTest.java | 26 ++ 24 files changed, 835 insertions(+), 109 deletions(-) create mode 100644 packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java create mode 100644 packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java create mode 100644 packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css index 6f7adc5b4a0..7d23b5e39b9 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css @@ -28,78 +28,78 @@ overflow-y: auto; } -.button-light { +.zoom-button-light { color: #212529; background-color: #f8f9fa; border-color: #f8f9fa; } -.button-light:hover { +.zoom-button-light:hover { color: #212529; background-color: #e2e6ea; border-color: #dae0e5; } -.button-light:focus, -.button-light.focus { +.zoom-button-light:focus, +.zoom-button-light.focus { box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); } -.button-light.disabled, -.button-light:disabled { +.zoom-button-light.disabled, +.zoom-button-light:disabled { color: #a8a8a8; background-color: #f8f9fa; border-color: #f8f9fa; } -.button-light:not(:disabled):not(.disabled):active, -.button-light:not(:disabled):not(.disabled).active, -.show > .button-light.dropdown-toggle { +.zoom-button-light:not(:disabled):not(.disabled):active, +.zoom-button-light:not(:disabled):not(.disabled).active, +.show > .zoom-button-light.dropdown-toggle { color: #212529; background-color: #dae0e5; border-color: #d3d9df; } -.button-light:not(:disabled):not(.disabled):active:focus, -.button-light:not(:disabled):not(.disabled).active:focus, -.show > .button-light.dropdown-toggle:focus { +.zoom-button-light:not(:disabled):not(.disabled):active:focus, +.zoom-button-light:not(:disabled):not(.disabled).active:focus, +.show > .zoom-button-light.dropdown-toggle:focus { box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); } -.button-dark { +.zoom-button-dark { color: #fff; - background-color: #292a2d; + background-color: #1f1f1f; border-color: #343a40; } -.button-dark:hover { +.zoom-button-dark:hover { color: #fff; background-color: #000000; border-color: #1d2124; } -.button-dark:focus, -.button-dark.focus { +.zoom-button-dark:focus, +.zoom-button-dark.focus { box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); } -.button-dark.disabled, -.button-dark:disabled { +.zoom-button-dark.disabled, +.zoom-button-dark:disabled { color: #909090; background-color: #343a40; border-color: #343a40; } -.button-dark:not(:disabled):not(.disabled):active, -.button-dark:not(:disabled):not(.disabled).active, -.show > .button-dark.dropdown-toggle { +.zoom-button-dark:not(:disabled):not(.disabled):active, +.zoom-button-dark:not(:disabled):not(.disabled).active, +.show > .zoom-button-dark.dropdown-toggle { color: #fff; background-color: #1d2124; border-color: #171a1d; } -.button-dark:not(:disabled):not(.disabled):active:focus, -.button-dark:not(:disabled):not(.disabled).active:focus, -.show > .button-dark.dropdown-toggle:focus { +.zoom-button-dark:not(:disabled):not(.disabled):active:focus, +.zoom-button-dark:not(:disabled):not(.disabled).active:focus, +.show > .zoom-button-dark.dropdown-toggle:focus { box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5); } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java index f6a1e8eed71..bfdf16507e1 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.java @@ -48,8 +48,8 @@ public class ZoomLevelSelectorView implements ZoomLevelSelector.View { static final String CSS_DROP_UP = "dropup"; - static final String LIGHT_STYLE = "button-light"; - static final String DARK_STYLE = "button-dark"; + static final String LIGHT_STYLE = "zoom-button-light"; + static final String DARK_STYLE = "zoom-button-dark"; @Inject @DataField diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java index c1a73613f3c..80f23336370 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/CallbackStateShape.java @@ -22,11 +22,13 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.ActionNode; import org.kie.workbench.common.stunner.sw.definition.CallbackState; import org.kie.workbench.common.stunner.sw.definition.State; @@ -50,7 +52,6 @@ public class CallbackStateShape extends StateShape implements HasActions, HasEventAndDataFilter { - public static final String ICON_COLOR = "#EC7A08"; public static final String ICON_SVG = "M63.97,36.13c0-2.13-1.64-3.95-3.76-4.07-2.31-.13-4.23,1.7-4.23,3.99,0,6.61-5.37,11.98-11.98,11.98H24.03v-4.99c0-1.18-.7-2.25-1.78-2.74-1.08-.47-2.34-.28-3.23,.52l-9.98,8.98c-.63,.56-.99,1.37-.99,2.22s.36,1.66,.99,2.23l9.98,8.98c.56,.51,1.28,.77,2,.77,.41,0,.83-.09,1.22-.26,1.08-.48,1.78-1.55,1.78-2.74v-4.99h19.97c10.98,0,19.92-8.91,19.97-19.89ZM20,16.08h19.85l.11,4.99c0,1.18,.7,2.25,1.78,2.74,.4,.17,.81,.26,1.11,.26,.73,0,1.44-.27,2.01-.77l9.98-8.98c.74-.57,1.1-1.38,1.1-2.34s-.36-1.66-.99-2.23L44.97,.76c-.88-.79-2.15-.98-3.22-.51-1.08,.6-1.89,1.67-1.89,2.85l.11,4.99H20C8.99,8.09,.03,17.05,.03,28.06c0,2.21,1.79,3.99,3.99,3.99s3.99-1.79,3.99-3.99c0-6.6,5.38-11.98,11.98-11.98Z"; public CallbackStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -92,7 +93,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getCallbackStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java index 9caae4392cb..e62e97f82ac 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/EventStateShape.java @@ -22,10 +22,12 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.EventState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -40,7 +42,6 @@ public class EventStateShape extends StateShape implements HasDataFilter { - public static final String ICON_COLOR = "#F4C145"; public static final String ICON_SVG = "M 45.254 45.197 L 36.216 45.197 L 42.206 31.792 C 42.613 30.98 42.307 29.965 41.597 29.355 C 40.887 28.746 39.768 28.849 39.06 29.457 L 19.561 45.705 C 18.953 46.215 18.646 47.128 18.953 47.939 C 19.258 48.754 19.968 49.262 20.883 49.262 L 29.921 49.262 L 23.928 62.667 C 23.521 63.478 23.825 64.493 24.538 65.103 C 24.943 65.51 25.247 65.609 25.756 65.609 C 26.263 65.609 26.67 65.406 27.076 65.103 L 46.573 48.854 C 47.183 48.347 47.488 47.431 47.183 46.62 C 46.879 45.808 46.066 45.197 45.254 45.197 Z M 53.378 16.865 C 53.275 16.865 53.275 16.865 53.175 16.865 C 53.275 16.153 53.378 15.543 53.378 14.834 C 53.378 9.247 48.808 4.679 43.222 4.679 C 40.073 4.679 37.333 6.101 35.505 8.334 C 33.068 3.765 28.394 0.615 22.911 0.615 C 15.094 0.615 8.694 7.014 8.694 14.834 C 8.694 15.747 8.794 16.661 8.997 17.575 C 4.023 19.2 0.469 23.872 0.571 29.355 C 0.773 36.057 6.258 41.237 12.858 41.237 L 18.646 41.237 L 36.419 26.41 C 37.535 25.496 38.856 24.989 40.276 24.989 C 41.597 24.989 42.919 25.396 43.932 26.207 C 46.169 27.933 46.981 30.98 45.761 33.521 L 42.511 41.237 L 53.275 41.237 C 59.878 41.237 65.36 36.057 65.563 29.457 C 65.766 22.552 60.285 16.865 53.378 16.865 Z"; public EventStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -54,9 +55,9 @@ public void applyProperties(Node, Edge> element, MutationContext mut if (state.getTimeouts() != null && state.getTimeouts() instanceof WorkflowTimeouts) { getView().addChild(new CornerIcon(CLOCK, RIGHT_TOP_CORNER, - getTranslation(TIMEOUT_EVENT) + ": " + truncate(((WorkflowTimeouts)state.getTimeouts()).getEventTimeout()) + "\r\n" - + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts)state.getTimeouts()).getStateExecTimeout()) + "\r\n" - + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts)state.getTimeouts()).getActionExecTimeout()))); + getTranslation(TIMEOUT_EVENT) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getEventTimeout()) + "\r\n" + + getTranslation(TIMEOUT_STATE) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getStateExecTimeout()) + "\r\n" + + getTranslation(TIMEOUT_ACTION) + ": " + truncate(((WorkflowTimeouts) state.getTimeouts()).getActionExecTimeout()))); } if (state.getStateDataFilter() != null) { @@ -68,7 +69,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getEventStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java index 44e372f4e9e..cb657cfb082 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ForEachStateShape.java @@ -22,12 +22,14 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomDepiction; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.ForEachState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -50,7 +52,6 @@ public class ForEachStateShape extends StateShape implements HasActions, HasCollections { - public static final String ICON_COLOR = "#8F4700"; public static final String ICON_SVG = "M64,32.22v27.24c0,2.34-1.91,4.49-4.24,4.65-2.68,.19-4.9-1.92-4.9-4.56v-27.43c0-2.64,2.22-4.75,4.9-4.56,2.34,.16,4.24,2.31,4.24,4.65M45.71,59.56c0,2.64-2.22,4.75-4.9,4.56-2.34-.16-4.24-2.31-4.24-4.65v-27.24c0-2.34,1.91-4.49,4.24-4.65,2.68-.19,4.9,1.92,4.9,4.56v27.43M27.43,4.79v27.24c0,2.34-1.91,4.49-4.24,4.65-2.68,.19-4.9-1.92-4.9-4.56V4.7C18.29,2.07,20.51-.04,23.18,.14c2.34,.16,4.24,2.31,4.24,4.65M9.14,32.13c0,2.64-2.22,4.75-4.9,4.56C1.91,36.53,0,34.38,0,32.04V4.79C0,2.45,1.91,.3,4.24,.14c2.68-.19,4.9,1.92,4.9,4.56v27.43Z"; public ForEachStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -91,7 +92,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getForeachStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/InjectStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/InjectStateShape.java index 9b1ceade930..e556f7e4444 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/InjectStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/InjectStateShape.java @@ -22,10 +22,12 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.InjectState; import org.kie.workbench.common.stunner.sw.definition.State; @@ -34,7 +36,6 @@ public class InjectStateShape extends StateShape implements HasDataFilter { - public static final String ICON_COLOR = "#8BC1F7"; public static final String ICON_SVG = "M35.02,28.49s-.03-.03-.05-.04l-10.29-10.29c-1.78-1.78-4.68-1.79-6.46,0-1.79,1.79-1.78,4.68,0,6.46l2.81,2.81H4.57c-2.52,0-4.57,2.04-4.57,4.57s2.05,4.57,4.57,4.57H20.94l-2.75,2.75c-1.78,1.78-1.79,4.68,0,6.46s4.68,1.78,6.46,0l10.09-10.09c.28-.2,.54-.44,.77-.71,.5-.58,.82-1.27,.97-2,.37-1.59-.11-3.33-1.46-4.5M.01,4.23C.19,1.83,2.25,0,4.66,0H59.43c2.53,0,4.57,2.05,4.57,4.57s-2.04,4.57-4.57,4.57H4.57C1.93,9.14-.18,6.91,.01,4.23M46.09,18.29h13.24c2.34,0,4.49,1.91,4.65,4.24,.19,2.68-1.92,4.9-4.56,4.9h-13.43c-2.64,0-4.75-2.22-4.56-4.9,.16-2.34,2.31-4.24,4.65-4.24M59.43,36.57c2.64,0,4.75,2.22,4.56,4.9-.16,2.34-2.31,4.24-4.65,4.24h-13.24c-2.34,0-4.49-1.91-4.65-4.24-.19-2.68,1.92-4.9,4.56-4.9h13.43M0,59.43c0-2.53,2.05-4.57,4.57-4.57H59.34c2.34,0,4.49,1.91,4.65,4.24,.19,2.68-1.92,4.9-4.56,4.9H4.57c-2.52,0-4.57-2.04-4.57-4.57Z"; public InjectStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -55,7 +56,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getInjectStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java index 24730c3a7d6..f16fb0b6d36 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/OperationStateShape.java @@ -22,12 +22,14 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomDepiction; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.OperationState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -48,7 +50,6 @@ public class OperationStateShape extends StateShape implements HasActions, HasDataFilter { - public static final String ICON_COLOR = "#0066CC"; public static final String ICON_SVG = "M61.99,20.83c.41,1.07,.06,2.29-.79,3.07l-5.41,4.93c.14,1.04,.21,2.1,.21,3.17s-.08,2.14-.21,3.17l5.41,4.92c.85,.79,1.2,2,.79,3.08-.55,1.49-1.21,2.92-1.96,4.29l-.59,1.01c-.83,1.38-1.75,2.68-2.76,3.91-.75,.89-1.96,1.2-3.06,.85l-6.96-2.22c-1.68,1.29-3.64,2.36-5.5,3.19l-1.56,7.14c-.25,1.12-1.12,1.92-2.28,2.22-1.72,.29-3.5,.44-5.42,.44-1.7,0-3.48-.15-5.2-.44-1.15-.3-2.02-1.1-2.27-2.22l-1.56-7.14c-1.98-.83-3.83-1.9-5.5-3.19l-6.96,2.22c-1.1,.35-2.32,.04-3.06-.85-1.01-1.24-1.94-2.54-2.76-3.91l-.59-1.01c-.76-1.36-1.42-2.8-1.97-4.29-.4-1.08-.06-2.29,.79-3.08l5.41-4.92c-.14-1.04-.21-2.1-.21-3.17s.07-2.14,.21-3.17l-5.41-4.93c-.86-.79-1.2-1.99-.79-3.07,.55-1.49,1.22-2.93,1.97-4.29l.58-1.01c.83-1.38,1.75-2.67,2.77-3.91,.74-.89,1.96-1.2,3.06-.85l6.96,2.22c1.67-1.29,3.52-2.37,5.5-3.18l1.56-7.14c.25-1.13,1.12-2.04,2.27-2.23,1.73-.29,3.5-.44,5.31-.44s3.59,.15,5.31,.44c1.15,.19,2.03,1.09,2.28,2.23l1.56,7.14c1.86,.82,3.82,1.89,5.5,3.18l6.96-2.22c1.1-.35,2.31-.04,3.06,.85,1.01,1.23,1.94,2.53,2.76,3.91l.59,1.01c.75,1.36,1.41,2.8,1.96,4.29h0Zm-29.99,21.17c5.53,0,10-4.47,10-10.11s-4.47-10-10-10-10,4.59-10,10,4.48,10.11,10,10.11Z"; public OperationStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -85,7 +86,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getOperationStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java index 0cacd508e1a..72d0d6f169d 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ParallelStateShape.java @@ -22,12 +22,14 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.BottomText; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; import org.kie.workbench.common.stunner.sw.client.shapes.icons.DataDepiction; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.ParallelState; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -46,7 +48,6 @@ public class ParallelStateShape extends StateShape implements HasDataFilter, HasBranches { - public static final String ICON_COLOR = "#4CB140"; public static final String ICON_SVG = "M50.54,.01c2.34,.16,4.24,2.31,4.24,4.65V59.43c0,2.64-2.23,4.75-4.91,4.56-2.33-.17-4.23-2.31-4.23-4.65V4.57c0-2.63,2.22-4.75,4.9-4.56M13.46,63.99c-2.34-.16-4.24-2.31-4.24-4.65V4.57c0-2.52,2.04-4.57,4.57-4.57s4.57,2.05,4.57,4.57V59.43c0,2.64-2.22,4.75-4.9,4.56Z"; public ParallelStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -86,7 +87,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getParallelStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ServerlessWorkflowShapeView.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ServerlessWorkflowShapeView.java index 4d944df1968..e9bc7567de5 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ServerlessWorkflowShapeView.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/ServerlessWorkflowShapeView.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes; @@ -34,12 +34,12 @@ import org.kie.workbench.common.stunner.core.client.shape.impl.AbstractShape; import org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateHandler; import org.kie.workbench.common.stunner.core.client.shape.view.event.ShapeViewSupportedEvents; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; public abstract class ServerlessWorkflowShapeView> extends StunnerWiresShapeView { - protected final static String SHAPE_STROKE_COLOR = "#ccc"; - protected final static String SHAPE_FILL_COLOR = "#fff"; protected final static double SHAPE_STROKE_WIDTH = 2.00; private ServerlessWorkflowShape controller; @@ -56,8 +56,8 @@ public ServerlessWorkflowShapeView(MultiPath path) { .setAlpha(1.00) .setDraggable(false) .setListening(true) - .setFillColor(SHAPE_FILL_COLOR) - .setStrokeColor(SHAPE_STROKE_COLOR) + .setFillColor(((ColorTheme)StunnerTheme.getTheme()).getShapeFillColor()) + .setStrokeColor(((ColorTheme)StunnerTheme.getTheme()).getShapeStrokeColor()) .setStrokeWidth(SHAPE_STROKE_WIDTH), new WiresLayoutContainer()); setEventHandlerManager(new ViewEventHandlerManager(getShape(), getShape(), ShapeViewSupportedEvents.ALL_DESKTOP_EVENT_TYPES)); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SleepStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SleepStateShape.java index 5aedcdce577..4eb7c5e1525 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SleepStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SleepStateShape.java @@ -22,10 +22,12 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.SleepState; import org.kie.workbench.common.stunner.sw.definition.State; @@ -35,7 +37,6 @@ public class SleepStateShape extends StateShape implements IsTruncatable { - public static final String ICON_COLOR = "#5752D1"; public static final String ICON_SVG = "M54.24,53.11c3.71-4.77,5.92-10.77,5.92-17.28,0-15.56-12.61-28.17-28.17-28.17S3.83,20.27,3.83,35.83c0,6.49,2.19,12.46,5.87,17.22l-2.53,2.53c-1.63,1.63-1.8,4.46-.28,6.2,1.74,2,4.76,2.07,6.59,.24l2.8-2.8c4.49,3.02,9.9,4.79,15.71,4.79s11.17-1.75,15.65-4.74l2.75,2.75c1.63,1.63,4.46,1.8,6.2,.28,2-1.74,2.07-4.76,.24-6.59l-2.59-2.59Zm-13.09-8.11l-10.59-7.06c-.74-.4-1.18-1.22-1.18-2.11l-.1-15c0-1.47,1.28-2.65,2.65-2.65,1.57,0,2.75,1.18,2.75,2.65v13.58l9.41,6.26c1.21,.82,1.54,2.46,.64,3.67-.72,1.21-2.36,1.54-3.57,.64M23.86,3.69C19.89-.5,13.34-1.27,8.47,2.14c-4.87,3.41-6.39,9.82-3.81,14.99L23.86,3.69M40.14,3.69c3.97-4.19,10.52-4.95,15.39-1.54,4.87,3.41,6.39,9.82,3.81,14.99L40.14,3.69Z"; public SleepStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -53,7 +54,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getSleepStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeView.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeView.java index 9465bb101ca..6895822f930 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeView.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeView.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -30,7 +30,9 @@ import com.ait.lienzo.client.core.shape.TextLineBreakTruncateWrapper; import com.ait.lienzo.client.core.types.BoundingBox; import org.kie.workbench.common.stunner.core.client.shape.view.HasTitle; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.content.view.Point2D; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import static com.ait.lienzo.shared.core.types.TextAlign.CENTER; import static com.ait.lienzo.shared.core.types.TextBaseLine.MIDDLE; @@ -81,7 +83,7 @@ private void initialize(String name) { .setX(LABEL_POSITION_X) // Y is set based on the size of the Text widget after it is initialized, see calculateTitleCenterY() .setStrokeWidth(0) - .setFillColor("#383B3D") + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getShapeTextColor()) .setFontFamily("Open Sans") .setTextAlign(CENTER) .setTextBaseLine(MIDDLE) @@ -97,7 +99,7 @@ private void initialize(String name) { addChild(icon); backgroundCircle = newCircle(STATE_SHAPE_ICON_RADIUS) - .setStrokeColor("#d5d5d5"); + .setStrokeColor(((ColorTheme) StunnerTheme.getTheme()).getBackgroundIconCircleStrokeColor()); icon.add(backgroundCircle); iconImage = newGroup(); @@ -105,7 +107,7 @@ private void initialize(String name) { } public void setIconPicture(Picture picture) { - backgroundCircle.setFillColor("#FFF"); + backgroundCircle.setFillColor(((ColorTheme) StunnerTheme.getTheme()).getBackgroundIconCircleFillColor()); picture.setX(-STATE_SHAPE_ICON_RADIUS); // PathClipper is a circle with center at [0.0], we need to compensate radius picture.setY(-STATE_SHAPE_ICON_RADIUS); // on both X and Y axis. @@ -123,9 +125,9 @@ public void setSvgIcon(String backgroundColor, String path) { .setScale(0.35) .setX(-11) .setY(-11) - .setFillColor("#fff") - .setStrokeColor("#fff") - .setStrokeWidth(2.00)); + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getIconPictureFillColor()) + .setStrokeColor(((ColorTheme) StunnerTheme.getTheme()).getIconPictureStrokeColor()) + .setStrokeWidth(1.00)); } public String getIconBackgroundColor() { diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java index 1e84fd48fc8..d589efb2361 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/SwitchStateShape.java @@ -22,10 +22,12 @@ import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.kie.workbench.common.stunner.core.client.shape.MutationContext; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.client.shapes.icons.CornerIcon; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.State; import org.kie.workbench.common.stunner.sw.definition.SwitchState; import org.kie.workbench.common.stunner.sw.definition.WorkflowTimeouts; @@ -41,7 +43,6 @@ public class SwitchStateShape extends StateShape implements HasConditionsAndHasDataFilter { - public static final String ICON_COLOR = "#009596"; public static final String ICON_SVG = "M60.6,46.54h-6.53v-8.71c-.06-1.38-.72-2.69-1.83-3.52l-7.42-5.56h0l-8.41-6.36V4.4C36.4,1.87,34.26-.17,31.69,.01c-2.25,.16-4.09,2.22-4.09,4.48V22.41l-8.41,6.31h0l-7.42,5.55c-1.11,.83-1.76,2.14-1.83,3.52v8.71H3.4c-2.94-.03-4.42,3.53-2.34,5.61l11.01,10.89c1.29,1.29,3.38,1.29,4.68,0l11.01-10.89c2.08-1.96,.61-5.52-2.34-5.47h-6.67v-6.63s8.22-6.08,13.28-9.87c4.96,3.73,13.2,9.92,13.24,9.9v6.63h-6.67c-2.94-.05-4.42,3.51-2.34,5.47l11.01,10.89c1.29,1.29,3.38,1.29,4.68,0l11.01-10.89c2.08-2.08,.6-5.64-2.34-5.61Z"; public SwitchStateShape(State state, ResourceContentService resourceContentService, TranslationService translationService) { @@ -72,7 +73,7 @@ public void applyProperties(Node, Edge> element, MutationContext mut @Override public String getIconColor() { - return ICON_COLOR; + return ((ColorTheme) StunnerTheme.getTheme()).getSwitchStateIconFillColor(); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/TransitionShape.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/TransitionShape.java index 1bd78490196..22bf1f5c9c3 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/TransitionShape.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/TransitionShape.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -23,7 +23,9 @@ import org.kie.workbench.common.stunner.client.lienzo.shape.impl.ShapeStateDefaultHandler; import org.kie.workbench.common.stunner.core.client.shape.common.DashArray; import org.kie.workbench.common.stunner.core.client.shape.impl.ConnectorShape; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.util.StringUtils; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import org.kie.workbench.common.stunner.sw.definition.CompensationTransition; import org.kie.workbench.common.stunner.sw.definition.DataConditionTransition; import org.kie.workbench.common.stunner.sw.definition.DefaultConditionTransition; @@ -50,13 +52,13 @@ public TransitionShape setAppearance(Object transitionType) { getShapeView().setDashArray(DASH_ARRAY); final ErrorTransition definition = (ErrorTransition) transitionType; getShapeView().setTitle(definition.getErrorRef()); - getShapeView().setTitleBackgroundColor("red"); + getShapeView().setTitleBackgroundColor(((ColorTheme) StunnerTheme.getTheme()).getErrorTransitionBoxColor()); } else if (transitionType instanceof CompensationTransition) { getShapeView().setDashArray(DOT_ARRAY); } else if (transitionType instanceof EventConditionTransition) { final EventConditionTransition definition = (EventConditionTransition) transitionType; getShapeView().setTitle(definition.getEventRef()); - getShapeView().setTitleBackgroundColor("orange"); + getShapeView().setTitleBackgroundColor(((ColorTheme) StunnerTheme.getTheme()).getEventConditionTransitionBoxColor()); } else if (transitionType instanceof DataConditionTransition) { final DataConditionTransition definition = (DataConditionTransition) transitionType; if (StringUtils.nonEmpty(definition.getName())) { @@ -64,7 +66,7 @@ public TransitionShape setAppearance(Object transitionType) { } else { getShapeView().setTitle(definition.getCondition()); } - getShapeView().setTitleBackgroundColor("gray"); + getShapeView().setTitleBackgroundColor(((ColorTheme) StunnerTheme.getTheme()).getTransitionBoxColor()); } return this; @@ -78,19 +80,19 @@ public static String getColor(Object transition) { Class clazz = transition.getClass(); if (clazz.equals(StartTransition.class)) { - return "#757575"; + return ((ColorTheme) StunnerTheme.getTheme()).getStartTransitionColor(); } else if (clazz.equals(ErrorTransition.class)) { - return "#c9190b"; + return ((ColorTheme) StunnerTheme.getTheme()).getErrorTransitionColor(); } else if (clazz.equals(EventConditionTransition.class)) { - return "#828282"; + return ((ColorTheme) StunnerTheme.getTheme()).getEventConditionTransitionColor(); } else if (clazz.equals(DataConditionTransition.class)) { - return "#757575"; + return ((ColorTheme) StunnerTheme.getTheme()).getDataConditionTransitionColor(); } else if (clazz.equals(DefaultConditionTransition.class)) { - return "#12DE70"; + return ((ColorTheme) StunnerTheme.getTheme()).getDefaultConditionTransitionColor(); } else if (clazz.equals(CompensationTransition.class)) { - return "#f0ab00"; + return ((ColorTheme) StunnerTheme.getTheme()).getCompensationTransitionColor(); } - return "#757575"; + return ((ColorTheme) StunnerTheme.getTheme()).getStartTransitionColor(); } public static boolean isTransition(Object object) { diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomDepiction.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomDepiction.java index 67789ff7dcd..00674d3fadb 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomDepiction.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomDepiction.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ @@ -25,6 +25,8 @@ import com.ait.lienzo.client.core.shape.Rectangle; import com.ait.lienzo.client.core.types.Point2D; import com.ait.lienzo.tools.client.event.HandlerRegistration; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import static org.kie.workbench.common.stunner.sw.client.shapes.StateShapeView.STATE_SHAPE_HEIGHT; import static org.kie.workbench.common.stunner.sw.client.shapes.StateShapeView.STATE_SHAPE_WIDTH; @@ -47,8 +49,8 @@ public BottomDepiction(String icon) { MultiPath multiPath = new MultiPath(icon) .setStrokeWidth(1) - .setStrokeColor("#4F5255") - .setFillColor("#4F5255") + .setStrokeColor(((ColorTheme) StunnerTheme.getTheme()).getStaticIconFillColor()) + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getStaticIconFillColor()) .setListening(false); add(multiPath); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomText.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomText.java index d5570151b62..2b928b6c1c9 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomText.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/BottomText.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.kie.workbench.common.stunner.sw.client.shapes.icons; @@ -24,6 +24,8 @@ import com.ait.lienzo.client.core.shape.Text; import com.ait.lienzo.client.core.types.Point2D; import com.ait.lienzo.shared.core.types.TextAlign; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; import static org.kie.workbench.common.stunner.sw.client.shapes.StateShapeView.STATE_SHAPE_HEIGHT; import static org.kie.workbench.common.stunner.sw.client.shapes.StateShapeView.STATE_SHAPE_WIDTH; @@ -45,7 +47,7 @@ public BottomText(String text) { Text textElement = new Text(text) .setFontSize(11) .setStrokeWidth(0) - .setFillColor("#4F5255") + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getBottomTextFillColor()) .setTextAlign(TextAlign.CENTER) .setListening(false); add(textElement); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/CornerIcon.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/CornerIcon.java index a0be50fc10e..52aa92fefda 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/CornerIcon.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/CornerIcon.java @@ -26,6 +26,8 @@ import com.ait.lienzo.client.core.shape.toolbox.items.tooltip.PrimitiveTextTooltip; import com.ait.lienzo.client.core.types.Point2D; import com.ait.lienzo.tools.client.event.HandlerRegistration; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; public class CornerIcon extends Group { @@ -52,19 +54,19 @@ public CornerIcon(String icon, Point2D position, final String tooltip) { MultiPath clockIcon = new MultiPath(icon) .setScale(2) .setStrokeWidth(0) - .setFillColor("#CCC") + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getCornerIconFillColor()) .setListening(false); add(clockIcon); mouseEnterHandler = border.addNodeMouseEnterHandler(event -> { createToolTip(); - clockIcon.setFillColor("#4F5255"); + clockIcon.setFillColor(((ColorTheme) StunnerTheme.getTheme()).getCornerIconHoverFillColor()); border.getLayer().batch(); }); mouseExitHandler = border.addNodeMouseExitHandler(event -> { tooltipElement.destroy(); tooltipElement = null; - clockIcon.setFillColor("#CCC"); + clockIcon.setFillColor(((ColorTheme) StunnerTheme.getTheme()).getCornerIconFillColor()); border.getLayer().batch(); }); mouseClickHandler = border.addNodeMouseClickHandler( @@ -82,6 +84,7 @@ private void createToolTip() { tooltipElement.withText(t -> { t.setText(tooltipText); t.setFontSize(12); + t.setFillColor(((ColorTheme) StunnerTheme.getTheme()).getTooltipTextColor()); }); final Layer topLayer = getLayer().getScene().getTopLayer(); topLayer.add(tooltipElement.asPrimitive()); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java index 764da6e9cb0..cceb0f78bd3 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/shapes/icons/DataDepiction.java @@ -23,6 +23,8 @@ import com.ait.lienzo.client.core.shape.Group; import com.ait.lienzo.client.core.shape.MultiPath; import com.ait.lienzo.client.core.types.Point2D; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; public class DataDepiction extends Group { @@ -32,7 +34,7 @@ public DataDepiction(final String icon, final Point2D location) { MultiPath multiPath = new MultiPath(icon) .setStrokeWidth(0) - .setFillColor("#4F5255") + .setFillColor(((ColorTheme) StunnerTheme.getTheme()).getStaticIconFillColor()) .setListening(false); add(multiPath); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java new file mode 100644 index 00000000000..8b2c63fe59f --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.sw.client.theme; + +import org.kie.workbench.common.stunner.core.client.theme.StunnerColorTheme; + +public interface ColorTheme extends StunnerColorTheme { + + String getCanvasBackgroundColor(); + + String getShapeStrokeColor(); + + String getShapeFillColor(); + + String getShapeTextColor(); + + String getTooltipTextColor(); + + String getBackgroundIconCircleStrokeColor(); + + String getBackgroundIconCircleFillColor(); + + String getIconPictureStrokeColor(); + + String getIconPictureFillColor(); + + String getStaticIconFillColor(); + + String getBottomTextFillColor(); + + String getCornerIconFillColor(); + + String getCornerIconHoverFillColor(); + + String getCallbackStateIconFillColor(); + + String getEventStateIconFillColor(); + + String getForeachStateIconFillColor(); + + String getInjectStateIconFillColor(); + + String getOperationStateIconFillColor(); + + String getParallelStateIconFillColor(); + + String getSleepStateIconFillColor(); + + String getSwitchStateIconFillColor(); + + String getStartTransitionColor(); + + String getErrorTransitionColor(); + + String getEventConditionTransitionColor(); + + String getDataConditionTransitionColor(); + + String getDefaultConditionTransitionColor(); + + String getCompensationTransitionColor(); + + String getTransitionBoxColor(); + + String getErrorTransitionBoxColor(); + + String getEventConditionTransitionBoxColor(); +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java new file mode 100644 index 00000000000..259a54496c5 --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java @@ -0,0 +1,277 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.sw.client.theme; + +public class DarkMode implements ColorTheme { + + private static ColorTheme instance; + + public static final String NAME = "dark"; + + // Canvas + private static final String CANVAS_BACKGROUND_COLOR = "#1F1F1F"; + // Shape + private static final String SHAPE_STROKE_COLOR = "#9876AA"; + private static final String SHAPE_FILL_COLOR = "#292A2D"; + // Shape text + private static final String SHAPE_TEXT_COLOR = "#FBAF4F"; + // Shape states + private static final String SHAPE_STROKE_COLOR_SELECTED = "#3988BD"; + private static final String SHAPE_STROKE_COLOR_HIGHLIGHT = "#BA55D3"; + private static final String SHAPE_STROKE_COLOR_INVALID = "#9876AA"; + private static final String SHAPE_FILL_COLOR_SELECTED = "#424242"; + private static final String SHAPE_FILL_COLOR_INVALID = "#292A2D"; + // State icon + private static final String BACKGROUND_ICON_CIRCLE_STROKE_COLOR = "#909090"; + private static final String BACKGROUND_ICON_CIRCLE_FILL_COLOR = "#909090"; + private static final String ICON_PICTURE_STROKE_COLOR = "#505050"; + private static final String ICON_PICTURE_FILL_COLOR = "#C4C4C4"; + private static final String CALLBACK_STATE_ICON_FILL_COLOR = "#C97330"; + private static final String EVENT_STATE_ICON_FILL_COLOR = "#BE9117"; + private static final String FOREACH_STATE_ICON_FILL_COLOR = "#65350F"; + private static final String INJECT_STATE_ICON_FILL_COLOR = "#434D54"; + private static final String OPERATION_STATE_ICON_FILL_COLOR = "#2A4E6C"; + private static final String PARALLEL_STATE_ICON_FILL_COLOR = "#3E5030"; + private static final String SLEEP_STATE_ICON_FILL_COLOR = "#5B4766"; + private static final String SWITCH_STATE_ICON_FILL_COLOR = "#00595A"; + // Static icons + private static final String STATIC_ICON_FILL_COLOR = "#3E86A0"; + // Corner icons with tooltip + private static final String CORNER_ICON_FILL_COLOR = "#C97330"; + private static final String CORNER_ICON_HOVER_FILL_COLOR = "#909090"; + // Tooltip + private static final String TOOLTIP_TEXT_COLOR = "#C4C4C4"; //"#FBAF4F"; + // Bottom text + private static final String BOTTOM_TEXT_FILL_COLOR = "#3E86A0"; + // Transitions + private static final String START_TRANSITION_COLOR = "#757575"; + private static final String ERROR_TRANSITION_COLOR = "#D1675A"; + private static final String EVENT_CONDITION_TRANSITION_COLOR = "#828282"; + private static final String DATA_CONDITION_TRANSITION_COLOR = "#757575"; + private static final String DEFAULT_CONDITION_TRANSITION_COLOR = "#678550"; + private static final String COMPENSATION_TRANSITION_COLOR = "#F0BD69"; + // Transition text box + private static final String EDGE_TEXT_FILL_COLOR = "#C4C4C4"; + private static final String EDGE_TEXT_STROKE_COLOR = "#C4C4C4"; + private static final String TRANSITION_BOX_COLOR = "gray"; + private static final String ERROR_TRANSITION_BOX_COLOR = "#9F3A3A"; + private static final String EVENT_CONDITION_TRANSITION_BOX_COLOR = "#C97330"; + + private DarkMode() { + } + + public static ColorTheme getInstance() { + if (null == instance) { + instance = new DarkMode(); + } + + return instance; + } + + @Override + public String getCanvasBackgroundColor() { + return CANVAS_BACKGROUND_COLOR; + } + + @Override + public String getShapeStrokeColor() { + return SHAPE_STROKE_COLOR; + } + + @Override + public String getShapeFillColor() { + return SHAPE_FILL_COLOR; + } + + @Override + public String getShapeStrokeColorSelected() { + return SHAPE_STROKE_COLOR_SELECTED; + } + + @Override + public String getShapeStrokeColorHighlight() { + return SHAPE_STROKE_COLOR_HIGHLIGHT; + } + + @Override + public String getShapeStrokeColorInvalid() { + return SHAPE_STROKE_COLOR_INVALID; + } + + @Override + public String getShapeFillColorSelected() { + return SHAPE_FILL_COLOR_SELECTED; + } + + @Override + public String getShapeFillColorInvalid() { + return SHAPE_FILL_COLOR_INVALID; + } + + @Override + public String getShapeTextColor() { + return SHAPE_TEXT_COLOR; + } + + @Override + public String getTooltipTextColor() { + return TOOLTIP_TEXT_COLOR; + } + + @Override + public String getBackgroundIconCircleStrokeColor() { + return BACKGROUND_ICON_CIRCLE_STROKE_COLOR; + } + + @Override + public String getBackgroundIconCircleFillColor() { + return BACKGROUND_ICON_CIRCLE_FILL_COLOR; + } + + @Override + public String getIconPictureStrokeColor() { + return ICON_PICTURE_STROKE_COLOR; + } + + @Override + public String getIconPictureFillColor() { + return ICON_PICTURE_FILL_COLOR; + } + + @Override + public String getStaticIconFillColor() { + return STATIC_ICON_FILL_COLOR; + } + + @Override + public String getBottomTextFillColor() { + return BOTTOM_TEXT_FILL_COLOR; + } + + @Override + public String getCornerIconFillColor() { + return CORNER_ICON_FILL_COLOR; + } + + @Override + public String getCornerIconHoverFillColor() { + return CORNER_ICON_HOVER_FILL_COLOR; + } + + @Override + public String getCallbackStateIconFillColor() { + return CALLBACK_STATE_ICON_FILL_COLOR; + } + + @Override + public String getEventStateIconFillColor() { + return EVENT_STATE_ICON_FILL_COLOR; + } + + @Override + public String getForeachStateIconFillColor() { + return FOREACH_STATE_ICON_FILL_COLOR; + } + + @Override + public String getInjectStateIconFillColor() { + return INJECT_STATE_ICON_FILL_COLOR; + } + + @Override + public String getOperationStateIconFillColor() { + return OPERATION_STATE_ICON_FILL_COLOR; + } + + @Override + public String getParallelStateIconFillColor() { + return PARALLEL_STATE_ICON_FILL_COLOR; + } + + @Override + public String getSleepStateIconFillColor() { + return SLEEP_STATE_ICON_FILL_COLOR; + } + + @Override + public String getSwitchStateIconFillColor() { + return SWITCH_STATE_ICON_FILL_COLOR; + } + + @Override + public String getStartTransitionColor() { + return START_TRANSITION_COLOR; + } + + @Override + public String getErrorTransitionColor() { + return ERROR_TRANSITION_COLOR; + } + + @Override + public String getEventConditionTransitionColor() { + return EVENT_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getDataConditionTransitionColor() { + return DATA_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getDefaultConditionTransitionColor() { + return DEFAULT_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getCompensationTransitionColor() { + return COMPENSATION_TRANSITION_COLOR; + } + + @Override + public String getTransitionBoxColor() { + return TRANSITION_BOX_COLOR; + } + + @Override + public String getErrorTransitionBoxColor() { + return ERROR_TRANSITION_BOX_COLOR; + } + + @Override + public String getEventConditionTransitionBoxColor() { + return EVENT_CONDITION_TRANSITION_BOX_COLOR; + } + + @Override + public String getEdgeTextFillColor() { + return EDGE_TEXT_FILL_COLOR; + } + + @Override + public String getEdgeTextStrokeColor() { + return EDGE_TEXT_STROKE_COLOR; + } + + @Override + public boolean isDarkTheme() { + return true; + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java new file mode 100644 index 00000000000..6269a8c31fb --- /dev/null +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java @@ -0,0 +1,277 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.workbench.common.stunner.sw.client.theme; + +public class LightMode implements ColorTheme { + + private static ColorTheme instance; + + public static final String NAME = "light"; + + // Canvas + private static final String CANVAS_BACKGROUND_COLOR = "#f2f2f2"; + // Shape + private static final String SHAPE_STROKE_COLOR = "#ccc"; + private static final String SHAPE_FILL_COLOR = "#fff"; + // Shape text + private static final String SHAPE_TEXT_COLOR = "#383B3D"; + // Shape states + private static final String SHAPE_STROKE_COLOR_SELECTED = "#0066CC"; + private static final String SHAPE_STROKE_COLOR_HIGHLIGHT = "#4F5255"; + private static final String SHAPE_STROKE_COLOR_INVALID = "#FF0000"; + private static final String SHAPE_FILL_COLOR_SELECTED = "#E7F1FA"; + private static final String SHAPE_FILL_COLOR_INVALID = "#fff"; + // State icon + private static final String BACKGROUND_ICON_CIRCLE_STROKE_COLOR = "#D5D5D5"; + private static final String BACKGROUND_ICON_CIRCLE_FILL_COLOR = "#D5D5D5"; + private static final String ICON_PICTURE_STROKE_COLOR = "#FFF"; + private static final String ICON_PICTURE_FILL_COLOR = "#FFF"; + private static final String CALLBACK_STATE_ICON_FILL_COLOR = "#EC7A08"; + private static final String EVENT_STATE_ICON_FILL_COLOR = "#F4C145"; + private static final String FOREACH_STATE_ICON_FILL_COLOR = "#8F4700"; + private static final String INJECT_STATE_ICON_FILL_COLOR = "#8BC1F7"; + private static final String OPERATION_STATE_ICON_FILL_COLOR = "#0066CC"; + private static final String PARALLEL_STATE_ICON_FILL_COLOR = "#4CB140"; + private static final String SLEEP_STATE_ICON_FILL_COLOR = "#5752D1"; + private static final String SWITCH_STATE_ICON_FILL_COLOR = "#009596"; + // Static icons + private static final String STATIC_ICON_FILL_COLOR = "#4F5255"; + // Corner icons with tooltip + private static final String CORNER_ICON_FILL_COLOR = "#CCC"; + private static final String CORNER_ICON_HOVER_FILL_COLOR = "#4F5255"; + // Tooltip + private static final String TOOLTIP_TEXT_COLOR = "#FFF"; + // Bottom text + private static final String BOTTOM_TEXT_FILL_COLOR = "#4F5255"; + // Transitions + private static final String START_TRANSITION_COLOR = "#757575"; + private static final String ERROR_TRANSITION_COLOR = "#c9190b"; + private static final String EVENT_CONDITION_TRANSITION_COLOR = "#828282"; + private static final String DATA_CONDITION_TRANSITION_COLOR = "#757575"; + private static final String DEFAULT_CONDITION_TRANSITION_COLOR = "#12DE70"; + private static final String COMPENSATION_TRANSITION_COLOR = "#f0ab00"; + // Transition text box + private static final String EDGE_TEXT_FILL_COLOR = "white"; + private static final String EDGE_TEXT_STROKE_COLOR = "white"; + private static final String TRANSITION_BOX_COLOR = "gray"; + private static final String ERROR_TRANSITION_BOX_COLOR = "red"; + private static final String EVENT_CONDITION_TRANSITION_BOX_COLOR = "orange"; + + private LightMode() { + } + + public static ColorTheme getInstance() { + if (null == instance) { + instance = new LightMode(); + } + + return instance; + } + + @Override + public String getCanvasBackgroundColor() { + return CANVAS_BACKGROUND_COLOR; + } + + @Override + public String getShapeStrokeColor() { + return SHAPE_STROKE_COLOR; + } + + @Override + public String getShapeFillColor() { + return SHAPE_FILL_COLOR; + } + + @Override + public String getShapeStrokeColorSelected() { + return SHAPE_STROKE_COLOR_SELECTED; + } + + @Override + public String getShapeStrokeColorHighlight() { + return SHAPE_STROKE_COLOR_HIGHLIGHT; + } + + @Override + public String getShapeStrokeColorInvalid() { + return SHAPE_STROKE_COLOR_INVALID; + } + + @Override + public String getShapeFillColorSelected() { + return SHAPE_FILL_COLOR_SELECTED; + } + + @Override + public String getShapeFillColorInvalid() { + return SHAPE_FILL_COLOR_INVALID; + } + + @Override + public String getShapeTextColor() { + return SHAPE_TEXT_COLOR; + } + + @Override + public String getTooltipTextColor() { + return TOOLTIP_TEXT_COLOR; + } + + @Override + public String getBackgroundIconCircleStrokeColor() { + return BACKGROUND_ICON_CIRCLE_STROKE_COLOR; + } + + @Override + public String getBackgroundIconCircleFillColor() { + return BACKGROUND_ICON_CIRCLE_FILL_COLOR; + } + + @Override + public String getIconPictureStrokeColor() { + return ICON_PICTURE_STROKE_COLOR; + } + + @Override + public String getIconPictureFillColor() { + return ICON_PICTURE_FILL_COLOR; + } + + @Override + public String getStaticIconFillColor() { + return STATIC_ICON_FILL_COLOR; + } + + @Override + public String getBottomTextFillColor() { + return BOTTOM_TEXT_FILL_COLOR; + } + + @Override + public String getCornerIconFillColor() { + return CORNER_ICON_FILL_COLOR; + } + + @Override + public String getCornerIconHoverFillColor() { + return CORNER_ICON_HOVER_FILL_COLOR; + } + + @Override + public String getCallbackStateIconFillColor() { + return CALLBACK_STATE_ICON_FILL_COLOR; + } + + @Override + public String getEventStateIconFillColor() { + return EVENT_STATE_ICON_FILL_COLOR; + } + + @Override + public String getForeachStateIconFillColor() { + return FOREACH_STATE_ICON_FILL_COLOR; + } + + @Override + public String getInjectStateIconFillColor() { + return INJECT_STATE_ICON_FILL_COLOR; + } + + @Override + public String getOperationStateIconFillColor() { + return OPERATION_STATE_ICON_FILL_COLOR; + } + + @Override + public String getParallelStateIconFillColor() { + return PARALLEL_STATE_ICON_FILL_COLOR; + } + + @Override + public String getSleepStateIconFillColor() { + return SLEEP_STATE_ICON_FILL_COLOR; + } + + @Override + public String getSwitchStateIconFillColor() { + return SWITCH_STATE_ICON_FILL_COLOR; + } + + @Override + public String getStartTransitionColor() { + return START_TRANSITION_COLOR; + } + + @Override + public String getErrorTransitionColor() { + return ERROR_TRANSITION_COLOR; + } + + @Override + public String getEventConditionTransitionColor() { + return EVENT_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getDataConditionTransitionColor() { + return DATA_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getDefaultConditionTransitionColor() { + return DEFAULT_CONDITION_TRANSITION_COLOR; + } + + @Override + public String getCompensationTransitionColor() { + return COMPENSATION_TRANSITION_COLOR; + } + + @Override + public String getTransitionBoxColor() { + return TRANSITION_BOX_COLOR; + } + + @Override + public String getErrorTransitionBoxColor() { + return ERROR_TRANSITION_BOX_COLOR; + } + + @Override + public String getEventConditionTransitionBoxColor() { + return EVENT_CONDITION_TRANSITION_BOX_COLOR; + } + + @Override + public String getEdgeTextFillColor() { + return EDGE_TEXT_FILL_COLOR; + } + + @Override + public String getEdgeTextStrokeColor() { + return EDGE_TEXT_STROKE_COLOR; + } + + @Override + public boolean isDarkTheme() { + return false; + } +} diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeTest.java index f716a926662..023bf733466 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/test/java/org/kie/workbench/common/stunner/sw/client/shapes/StateShapeTest.java @@ -26,13 +26,17 @@ import elemental2.promise.Promise; import io.crysknife.ui.translation.client.TranslationService; import org.appformer.kogito.bridge.client.resource.ResourceContentService; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.kie.workbench.common.stunner.core.client.shape.ShapeState; import org.kie.workbench.common.stunner.core.client.shape.impl.ShapeStateHandler; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.graph.Edge; import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.core.graph.content.view.View; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; +import org.kie.workbench.common.stunner.sw.client.theme.LightMode; import org.kie.workbench.common.stunner.sw.definition.CallbackState; import org.kie.workbench.common.stunner.sw.definition.EventState; import org.kie.workbench.common.stunner.sw.definition.ForEachState; @@ -75,18 +79,11 @@ public class StateShapeTest { private final String ANSIBLE = "ansible"; private final String KAOTO = "kaoto"; private final String IMAGE_DATA = "imageData"; - private final String INJECT_COLOR = "#8BC1F7"; - private final String SWITCH_COLOR = "#009596"; - private final String OPERATION_COLOR = "#0066CC"; - private final String EVENT_COLOR = "#F4C145"; - private final String CALLBACK_COLOR = "#EC7A08"; - private final String FOR_EACH_COLOR = "#8F4700"; - private final String PARALLEL_COLOR = "#4CB140"; - private final String SLEEP_COLOR = "#5752D1"; private final String ANSIBLE_COLOR = "#BB271A"; private final String KAOTO_COLOR = "#332174"; private final int SHAPE_X = 50; private final int SHAPE_Y = 50; + private final ColorTheme theme = LightMode.getInstance(); @Mock ResourceContentService kogitoService; @@ -94,44 +91,49 @@ public class StateShapeTest { @Mock private TranslationService translationService; + @Before + public void setup() { + StunnerTheme.setTheme(LightMode.getInstance()); + } + @Test public void injectStateColorTest() { - simpleStateIconTest(INJECT, INJECT_COLOR); + simpleStateIconTest(INJECT, theme.getInjectStateIconFillColor()); } @Test public void switchStateColorTest() { - simpleStateIconTest(SWITCH, SWITCH_COLOR); + simpleStateIconTest(SWITCH, theme.getSwitchStateIconFillColor()); } @Test public void operationStateColorTest() { - simpleStateIconTest(OPERATION, OPERATION_COLOR); + simpleStateIconTest(OPERATION, theme.getOperationStateIconFillColor()); } @Test public void eventStateColorTest() { - simpleStateIconTest(EVENT, EVENT_COLOR); + simpleStateIconTest(EVENT, theme.getEventStateIconFillColor()); } @Test public void callbackStateColorTest() { - simpleStateIconTest(CALLBACK, CALLBACK_COLOR); + simpleStateIconTest(CALLBACK, theme.getCallbackStateIconFillColor()); } @Test public void forEachStateColorTest() { - simpleStateIconTest(FOREACH, FOR_EACH_COLOR); + simpleStateIconTest(FOREACH, theme.getForeachStateIconFillColor()); } @Test public void parallelStateColorTest() { - simpleStateIconTest(PARALLEL, PARALLEL_COLOR); + simpleStateIconTest(PARALLEL, theme.getParallelStateIconFillColor()); } @Test public void sleepStateColorTest() { - simpleStateIconTest(SLEEP, SLEEP_COLOR); + simpleStateIconTest(SLEEP, theme.getSleepStateIconFillColor()); } @Test @@ -181,7 +183,7 @@ public void customBase64IconStateIconTest() { shape.applyProperties(createElement(state), null); assertFalse(shape.getView().isIconEmpty()); - assertEquals("#FFF", shape.getView().getIconBackgroundColor()); + assertEquals(theme.getBackgroundIconCircleFillColor(), shape.getView().getIconBackgroundColor()); } @Test @@ -200,7 +202,7 @@ public void invalidIconStateTest() { shape.applyProperties(createElement(state), null); assertFalse(shape.getView().isIconEmpty()); - assertEquals(INJECT_COLOR, shape.getView().getIconBackgroundColor()); + assertEquals(theme.getInjectStateIconFillColor(), shape.getView().getIconBackgroundColor()); } @Test diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index 28ba4b2ab4a..3266332a1ff 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -53,6 +53,7 @@ import org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError; import org.kie.workbench.common.stunner.core.client.service.ServiceCallback; import org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.command.CommandResult; import org.kie.workbench.common.stunner.core.command.util.CommandUtils; import org.kie.workbench.common.stunner.core.diagram.Diagram; @@ -64,6 +65,9 @@ import org.kie.workbench.common.stunner.core.graph.content.view.View; import org.kie.workbench.common.stunner.sw.SWDomainInitializer; import org.kie.workbench.common.stunner.sw.client.services.ClientDiagramService; +import org.kie.workbench.common.stunner.sw.client.theme.ColorTheme; +import org.kie.workbench.common.stunner.sw.client.theme.DarkMode; +import org.kie.workbench.common.stunner.sw.client.theme.LightMode; import org.kie.workbench.common.stunner.sw.marshall.DocType; import org.kie.workbench.common.stunner.sw.marshall.Message; import org.kie.workbench.common.stunner.sw.marshall.ParseResult; @@ -79,7 +83,6 @@ public class DiagramEditor { public static final String EDITOR_ID = "SWDiagramEditor"; - public static final String BACKGROUND_COLOR = "#f2f2f2"; static String ID_SEARCH_PATTERN_JSON = "(?:\\\"|\\')(?[^\"]*)(?:\\\"|\\')(?=:)(?:\\:\\s*)(?:\\\"|\\')" + "?(?true|false|[0-9a-zA-Z\\+\\-\\,\\.\\$]*)"; @@ -95,6 +98,8 @@ public class DiagramEditor { private final Event togglePreviewEvent; private final DiagramApi diagramApi; private DocType currentDocType = DocType.JSON; + private String currentPath; + private String currentValue; @Inject private TranslationService translationService; @@ -120,6 +125,8 @@ public DiagramEditor(Promises promises, public void onStartup(final PlaceRequest place) { domainInitializer.initialize(); stunnerEditor.setReadOnly(true); + // Set default theme on startup + StunnerTheme.setTheme(LightMode.getInstance()); } @SuppressWarnings("all") @@ -149,6 +156,30 @@ public Promise getContentJSON() { return diagramService.transform(stunnerEditor.getDiagram(), DocType.JSON); } + public final Promise setTheme(String theme) { + if (theme.equals(DarkMode.NAME)) { + StunnerTheme.setTheme(DarkMode.getInstance()); + } else { + StunnerTheme.setTheme(LightMode.getInstance()); + } + + reloadEditorContent(); + + return null; + } + + void reloadEditorContent() { + if (null != stunnerEditor.getSession()) { + setCanvasBackgroundColor(); + Promise.resolve(setContent(currentPath, currentValue)); + } + } + + private void setCanvasBackgroundColor() { + ((WiresCanvas) stunnerEditor.getCanvasHandler().getCanvas()) + .setBackgroundColor(((ColorTheme) StunnerTheme.getTheme()).getCanvasBackgroundColor()); + } + public Promise setContent(final String path, final String value) { if (value == null || value.trim().isEmpty()) { return setContent(path, "{}", DocType.JSON); @@ -160,6 +191,9 @@ public Promise setContent(final String path, final String value) { } private Promise setContent(final String path, final String value, final DocType docType) { + this.currentPath = path; + this.currentValue = value; + this.currentDocType = docType; TogglePreviewEvent event = new TogglePreviewEvent(TogglePreviewEvent.EventType.HIDE); togglePreviewEvent.fire(event); @@ -214,8 +248,7 @@ public void onError(ClientRuntimeError error) { @Override public void afterCanvasInitialized() { - ((WiresCanvas) stunnerEditor.getCanvasHandler().getCanvas()) - .setBackgroundColor(BACKGROUND_COLOR); + setCanvasBackgroundColor(); } }); } diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java index bc49fc0c5ce..1ad6da12169 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java @@ -55,6 +55,11 @@ public void onOpen() { realPresenter.onOpen(); } + @Override + public final Promise setTheme(String theme) { + return realPresenter.setTheme(theme); + } + @Override public Promise setContent(String path, String value) { return realPresenter.setContent(path, value); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java index a243fcdfdd1..dd369d14556 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java @@ -53,6 +53,7 @@ import org.kie.workbench.common.stunner.core.client.command.ClearAllCommand; import org.kie.workbench.common.stunner.core.client.session.ClientSession; import org.kie.workbench.common.stunner.core.client.session.impl.ViewerSession; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.diagram.DiagramImpl; import org.kie.workbench.common.stunner.core.diagram.Metadata; import org.kie.workbench.common.stunner.core.diagram.MetadataImpl; @@ -60,6 +61,8 @@ import org.kie.workbench.common.stunner.core.graph.Node; import org.kie.workbench.common.stunner.sw.SWDomainInitializer; import org.kie.workbench.common.stunner.sw.client.services.ClientDiagramService; +import org.kie.workbench.common.stunner.sw.client.theme.DarkMode; +import org.kie.workbench.common.stunner.sw.client.theme.LightMode; import org.kie.workbench.common.stunner.sw.marshall.Context; import org.kie.workbench.common.stunner.sw.marshall.DocType; import org.kie.workbench.common.stunner.sw.marshall.Marshaller; @@ -71,10 +74,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -244,6 +249,27 @@ public void setUp() { doReturn(jsCanvas).when(tested).getJsCanvas(); } + @Test + public void testSetDefaultTheme() { + tested.onStartup(new DefaultPlaceRequest()); + assertTrue(StunnerTheme.getTheme() instanceof LightMode); + } + + @Test + public void testSetTheme() { + when(jsRegExp.exec(rawJSON)).thenReturn(regExpResult); + when(regExpResult.getAt(2)).thenReturn("injectExample"); + when(graph.getUUID()).thenReturn("injectExample"); + doNothing().when(tested).reloadEditorContent(); + + tested.onStartup(new DefaultPlaceRequest()); + tested.setContent("", rawJSON); + tested.setTheme("dark"); + + verify(tested, times(1)).reloadEditorContent(); + assertTrue(StunnerTheme.getTheme() instanceof DarkMode); + } + @Test public void testScaleToFitWorkflow() { when(lienzoPanel.getWidePx()).thenReturn(500); From 452ebf1b0e5278c8d803ec5a7499a6e135e27a41 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Fri, 2 Feb 2024 13:44:39 -0500 Subject: [PATCH 06/24] Stunner alert's dark mode --- .../components/alerts/AlertsPresenter.java | 4 +- .../lienzo/components/alerts/AlertsView.less | 59 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsPresenter.java b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsPresenter.java index 36b57a7f651..72dec4b4f90 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsPresenter.java +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsPresenter.java @@ -43,6 +43,7 @@ import org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel; import org.kie.workbench.common.stunner.core.client.components.views.FloatingView; import org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService; +import org.kie.workbench.common.stunner.core.client.theme.StunnerTheme; import org.kie.workbench.common.stunner.core.i18n.CoreTranslationMessages; @Dependent @@ -287,6 +288,7 @@ private static String buildHtmlEscapedText(final List messageList) { } private static String kieNotificationCssClass(final NotifyType notifyType) { - return notifyType.getCssName() + " kie-alert-notification"; + final String cssName = StunnerTheme.getTheme().isDarkTheme() ? notifyType.getCssName() + "-dark" : notifyType.getCssName(); + return cssName + " kie-alert-notification"; } } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsView.less b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsView.less index b3132b48f84..3083387e6b7 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsView.less +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/alerts/AlertsView.less @@ -14,3 +14,62 @@ margin-top: 0.5rem; } } + +// Success +.alert-success-dark { + background-color: #37892f; + border-color: #37892f; + color: #ffffff; +} + +.alert-success-dark hr { + border-top-color: #37892f; +} + +.alert-success-dark .alert-link { + color: #ffffff; +} + +// Info +.alert-info-dark { + background-color: #7e8082; + border-color: #7e8082; + color: #ffffff; +} + +.alert-info-dark hr { + border-top-color: #7e8082; +} + +.alert-info-dark .alert-link { + color: #ffffff; +} + +// Warning +.alert-warning-dark { + background-color: #d36d07; + border-color: #d36d07; + color: #ffffff; +} + +.alert-warning-dark hr { + border-top-color: #d36d07; +} + +.alert-warning-dark .alert-link { + color: #ffffff; +} + +// Danger +.alert-danger-dark { + background-color: #b30000; + border-color: #b30000; + color: #ffffff; +} +.alert-danger-dark hr { + border-top-color: #b30000; +} + +.alert-danger-dark .alert-link { + color: #ffffff; +} From 9a344afac4fd50c854e129a7478905e388e02e21 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 6 Feb 2024 16:55:35 -0500 Subject: [PATCH 07/24] Fix setTheme nullpointer --- .../stunner/sw/client/editor/DiagramEditor.java | 15 +++++++++------ .../sw/client/editor/DiagramEditorTest.java | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index 3266332a1ff..b3647ed401b 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -157,15 +157,18 @@ public Promise getContentJSON() { } public final Promise setTheme(String theme) { - if (theme.equals(DarkMode.NAME)) { - StunnerTheme.setTheme(DarkMode.getInstance()); - } else { - StunnerTheme.setTheme(LightMode.getInstance()); - } + if (null != theme) { + if (theme.equals(DarkMode.NAME)) { + StunnerTheme.setTheme(DarkMode.getInstance()); + } else { + StunnerTheme.setTheme(LightMode.getInstance()); + } - reloadEditorContent(); + reloadEditorContent(); + } return null; + } void reloadEditorContent() { diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java index dd369d14556..76dcfaf1d96 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java @@ -270,6 +270,21 @@ public void testSetTheme() { assertTrue(StunnerTheme.getTheme() instanceof DarkMode); } + @Test + public void testSetThemeNull() { + when(jsRegExp.exec(rawJSON)).thenReturn(regExpResult); + when(regExpResult.getAt(2)).thenReturn("injectExample"); + when(graph.getUUID()).thenReturn("injectExample"); + doNothing().when(tested).reloadEditorContent(); + + tested.onStartup(new DefaultPlaceRequest()); + tested.setContent("", rawJSON); + tested.setTheme(null); + + verify(tested, times(0)).reloadEditorContent(); + assertTrue(StunnerTheme.getTheme() instanceof LightMode); + } + @Test public void testScaleToFitWorkflow() { when(lienzoPanel.getWidePx()).thenReturn(500); From 8da129336cf8f08dfcb704fbe56c8b180ed11f52 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 6 Feb 2024 16:57:24 -0500 Subject: [PATCH 08/24] Remove extra space --- .../workbench/common/stunner/sw/client/editor/DiagramEditor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index b3647ed401b..37f4c7a75ec 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -168,7 +168,6 @@ public final Promise setTheme(String theme) { } return null; - } void reloadEditorContent() { From 42a4d39ceb6b8e9b1de575627416ec54e5e4837c Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 6 Feb 2024 17:57:53 -0500 Subject: [PATCH 09/24] Do not set same theme --- .../stunner/sw/client/editor/DiagramEditor.java | 6 +++++- .../sw/client/editor/DiagramEditorTest.java | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index 37f4c7a75ec..bb3415c96e9 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -100,6 +100,7 @@ public class DiagramEditor { private DocType currentDocType = DocType.JSON; private String currentPath; private String currentValue; + private String currentTheme = LightMode.NAME; @Inject private TranslationService translationService; @@ -125,6 +126,7 @@ public DiagramEditor(Promises promises, public void onStartup(final PlaceRequest place) { domainInitializer.initialize(); stunnerEditor.setReadOnly(true); + // Set default theme on startup StunnerTheme.setTheme(LightMode.getInstance()); } @@ -157,11 +159,13 @@ public Promise getContentJSON() { } public final Promise setTheme(String theme) { - if (null != theme) { + if (null != theme && !theme.equals(currentTheme)) { if (theme.equals(DarkMode.NAME)) { StunnerTheme.setTheme(DarkMode.getInstance()); + currentTheme = DarkMode.NAME; } else { StunnerTheme.setTheme(LightMode.getInstance()); + currentTheme = LightMode.NAME; } reloadEditorContent(); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java index 76dcfaf1d96..46509afd2ff 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java @@ -264,7 +264,7 @@ public void testSetTheme() { tested.onStartup(new DefaultPlaceRequest()); tested.setContent("", rawJSON); - tested.setTheme("dark"); + tested.setTheme(DarkMode.NAME); verify(tested, times(1)).reloadEditorContent(); assertTrue(StunnerTheme.getTheme() instanceof DarkMode); @@ -285,6 +285,21 @@ public void testSetThemeNull() { assertTrue(StunnerTheme.getTheme() instanceof LightMode); } + @Test + public void testSetThemeSame() { + when(jsRegExp.exec(rawJSON)).thenReturn(regExpResult); + when(regExpResult.getAt(2)).thenReturn("injectExample"); + when(graph.getUUID()).thenReturn("injectExample"); + doNothing().when(tested).reloadEditorContent(); + + tested.onStartup(new DefaultPlaceRequest()); + tested.setContent("", rawJSON); + tested.setTheme(LightMode.NAME); + + verify(tested, times(0)).reloadEditorContent(); + assertTrue(StunnerTheme.getTheme() instanceof LightMode); + } + @Test public void testScaleToFitWorkflow() { when(lienzoPanel.getWidePx()).thenReturn(500); From 6d71b32874c52b33b3531b3be2bc64c40f589c14 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 27 Feb 2024 16:48:43 -0500 Subject: [PATCH 10/24] Fix conflicting method names --- .../workbench/common/stunner/sw/client/theme/DarkMode.java | 2 +- .../common/stunner/sw/client/editor/DiagramEditor.java | 2 +- .../stunner/sw/client/editor/DiagramEditorActivity.java | 4 ++-- .../common/stunner/sw/client/editor/DiagramEditorTest.java | 6 +++--- .../main/java/org/uberfire/client/mvp/EditorActivity.java | 2 +- .../src/main/java/org/uberfire/client/util/GWTEditor.java | 4 ++-- .../main/java/org/uberfire/client/util/GWTEditor.native.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java index 259a54496c5..f25f8b4efd3 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java @@ -57,7 +57,7 @@ public class DarkMode implements ColorTheme { private static final String CORNER_ICON_FILL_COLOR = "#C97330"; private static final String CORNER_ICON_HOVER_FILL_COLOR = "#909090"; // Tooltip - private static final String TOOLTIP_TEXT_COLOR = "#C4C4C4"; //"#FBAF4F"; + private static final String TOOLTIP_TEXT_COLOR = "#C4C4C4"; // Bottom text private static final String BOTTOM_TEXT_FILL_COLOR = "#3E86A0"; // Transitions diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index bb3415c96e9..dfd75c3951f 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -158,7 +158,7 @@ public Promise getContentJSON() { return diagramService.transform(stunnerEditor.getDiagram(), DocType.JSON); } - public final Promise setTheme(String theme) { + public final Promise applyTheme(String theme) { if (null != theme && !theme.equals(currentTheme)) { if (theme.equals(DarkMode.NAME)) { StunnerTheme.setTheme(DarkMode.getInstance()); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java index 1ad6da12169..f1278d481c6 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorActivity.java @@ -56,8 +56,8 @@ public void onOpen() { } @Override - public final Promise setTheme(String theme) { - return realPresenter.setTheme(theme); + public final Promise applyTheme(String theme) { + return realPresenter.applyTheme(theme); } @Override diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java index 46509afd2ff..b9c73a48eba 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java @@ -264,7 +264,7 @@ public void testSetTheme() { tested.onStartup(new DefaultPlaceRequest()); tested.setContent("", rawJSON); - tested.setTheme(DarkMode.NAME); + tested.applyTheme(DarkMode.NAME); verify(tested, times(1)).reloadEditorContent(); assertTrue(StunnerTheme.getTheme() instanceof DarkMode); @@ -279,7 +279,7 @@ public void testSetThemeNull() { tested.onStartup(new DefaultPlaceRequest()); tested.setContent("", rawJSON); - tested.setTheme(null); + tested.applyTheme(null); verify(tested, times(0)).reloadEditorContent(); assertTrue(StunnerTheme.getTheme() instanceof LightMode); @@ -294,7 +294,7 @@ public void testSetThemeSame() { tested.onStartup(new DefaultPlaceRequest()); tested.setContent("", rawJSON); - tested.setTheme(LightMode.NAME); + tested.applyTheme(LightMode.NAME); verify(tested, times(0)).reloadEditorContent(); assertTrue(StunnerTheme.getTheme() instanceof LightMode); diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java index 156bebc0e2f..ad43735e610 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/mvp/EditorActivity.java @@ -27,7 +27,7 @@ public interface EditorActivity extends Activity { - Promise setTheme(String theme); + Promise applyTheme(String theme); Promise setContent(String path, String value); diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java index 0b44e248df5..d981d057efe 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.java @@ -40,8 +40,8 @@ public final void onOpen() { instance.onOpen(); } - public final Promise setTheme(String theme) { - return instance.setTheme(theme); + public final Promise applyTheme(String theme) { + return instance.applyTheme(theme); } public final Promise setContent(String path, String value) { diff --git a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js index 6ba5ab9eec8..058872aeb10 100644 --- a/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js +++ b/packages/serverless-workflow-diagram-editor/uberfire-workbench/uberfire-workbench-client/src/main/java/org/uberfire/client/util/GWTEditor.native.js @@ -1,5 +1,5 @@ goog.exportProperty(GWTEditor.prototype, "onOpen", GWTEditor.prototype.onOpen); -goog.exportProperty(GWTEditor.prototype, "setTheme", GWTEditor.prototype.setTheme); +goog.exportProperty(GWTEditor.prototype, "applyTheme", GWTEditor.prototype.applyTheme); goog.exportProperty(GWTEditor.prototype, "setContent", GWTEditor.prototype.setContent); goog.exportProperty(GWTEditor.prototype, "selectStateByName", GWTEditor.prototype.selectStateByName); goog.exportProperty(GWTEditor.prototype, "getContent", GWTEditor.prototype.getContent); From 63236f95a4100fe859d03fb5cfb5bfb89e4b0ee2 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 27 Feb 2024 17:21:36 -0500 Subject: [PATCH 11/24] Add GWT setTheme->applyTheme call --- .../kie-bc-editors/src/common/GwtEditorWrapper.tsx | 14 ++++++++++++-- .../GwtAppFormerConsumedInteropApi.ts | 1 + packages/kie-bc-editors/tests/DummyEditor.tsx | 6 +++++- .../kie-bc-editors/tests/GwtEditorWrapper.test.ts | 13 ++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx index 951924a0136..02066e01f15 100644 --- a/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx +++ b/packages/kie-bc-editors/src/common/GwtEditorWrapper.tsx @@ -106,8 +106,18 @@ export class GwtEditorWrapper implements Editor { } public setTheme(theme: EditorTheme): Promise { - // Only default theme is supported - return Promise.resolve(); + if (!theme) { + Promise.resolve(); + } + + switch (theme) { + case EditorTheme.DARK: { + return Promise.resolve(this.gwtEditor.applyTheme("dark")); + } + default: { + return Promise.resolve(this.gwtEditor.applyTheme("light")); + } + } } private removeBusinessCentralHeaderPanel() { diff --git a/packages/kie-bc-editors/src/common/consumedInteropApi/GwtAppFormerConsumedInteropApi.ts b/packages/kie-bc-editors/src/common/consumedInteropApi/GwtAppFormerConsumedInteropApi.ts index 0a4fdd1c2b5..439120b8548 100644 --- a/packages/kie-bc-editors/src/common/consumedInteropApi/GwtAppFormerConsumedInteropApi.ts +++ b/packages/kie-bc-editors/src/common/consumedInteropApi/GwtAppFormerConsumedInteropApi.ts @@ -35,6 +35,7 @@ export interface GwtEditor { getPreview(): Promise; validate(): Promise; selectStateByName(name: string | null): Promise; + applyTheme(name: string | null): Promise; } export class GwtAppFormerConsumedInteropApi { diff --git a/packages/kie-bc-editors/tests/DummyEditor.tsx b/packages/kie-bc-editors/tests/DummyEditor.tsx index 7c313813a73..370adbe0825 100644 --- a/packages/kie-bc-editors/tests/DummyEditor.tsx +++ b/packages/kie-bc-editors/tests/DummyEditor.tsx @@ -56,7 +56,11 @@ export class DummyEditor implements Editor, GwtEditor { return Promise.resolve([]); } - public setTheme(theme: EditorTheme): Promise { + public setTheme(_theme: EditorTheme): Promise { + return Promise.resolve(); + } + + public applyTheme(_name: string | null): Promise { return Promise.resolve(); } diff --git a/packages/kie-bc-editors/tests/GwtEditorWrapper.test.ts b/packages/kie-bc-editors/tests/GwtEditorWrapper.test.ts index 47041d59aa7..91356033e51 100644 --- a/packages/kie-bc-editors/tests/GwtEditorWrapper.test.ts +++ b/packages/kie-bc-editors/tests/GwtEditorWrapper.test.ts @@ -19,7 +19,7 @@ import { GwtEditorWrapper } from "@kie-tools/kie-bc-editors/dist/common/GwtEditorWrapper"; import { GwtStateControlService } from "@kie-tools/kie-bc-editors/dist/common/gwtStateControl"; -import { KogitoEditorChannelApi } from "@kie-tools-core/editor/dist/api"; +import { EditorTheme, KogitoEditorChannelApi } from "@kie-tools-core/editor/dist/api"; import { messageBusClientApiMock } from "@kie-tools-core/envelope-bus/dist-tests/common"; import { I18n } from "@kie-tools-core/i18n/dist/core"; import { kieBcEditorsI18nDefaults, kieBcEditorsI18nDictionaries } from "@kie-tools/kie-bc-editors/dist/common/i18n"; @@ -33,6 +33,7 @@ const MockEditor = jest.fn(() => ({ getPreview: jest.fn(), validate: jest.fn(), selectStateByName: jest.fn(() => Promise.resolve()), + applyTheme: jest.fn(() => Promise.resolve()), })); const mockEditor = new MockEditor(); @@ -66,6 +67,16 @@ describe("GwtEditorWrapper", () => { expect(mockEditor.selectStateByName).toHaveBeenCalledWith("stateName"); }); + test("setTheme", async () => { + await wrapper.setTheme(EditorTheme.DARK); + expect(mockEditor.applyTheme).toHaveBeenCalledWith("dark"); + }); + + test("setTheme", async () => { + await wrapper.setTheme(EditorTheme.LIGHT); + expect(mockEditor.applyTheme).toHaveBeenCalledWith("light"); + }); + test("af_onOpen removes header", () => { const parent = document.createElement("div"); const workbenchHeaderPanel = document.createElement("div"); From 8a184f8c8aee9fa7db18ff1f8cc35423ced42b56 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 27 Feb 2024 17:34:38 -0500 Subject: [PATCH 12/24] Add dark theme to keyboard shortcuts icon --- packages/editor/src/envelope/styles.scss | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/envelope/styles.scss b/packages/editor/src/envelope/styles.scss index e5e5f580657..7302acc9838 100644 --- a/packages/editor/src/envelope/styles.scss +++ b/packages/editor/src/envelope/styles.scss @@ -75,9 +75,15 @@ /* PF3 -> PF4 overrides */ -.kie-tools--keyboard-shortcuts { - font-family: var(--pf-global--FontFamily--sans-serif); - color: var(--pf-global--Color--dark-100); +:not(.vscode-dark) { + .kie-tools--keyboard-shortcuts { + font-family: var(--pf-global--FontFamily--sans-serif); + color: var(--pf-global--Color--dark-100); + } +} + +.vscode-dark .kie-tools--keyboard-shortcuts { + color: #343a40; } body { From 40dc3700c2603663e0dc578e364401426ba8d173 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Wed, 28 Feb 2024 15:57:03 -0500 Subject: [PATCH 13/24] Do not apply theme if there are errors in the diagram, do it when it gets valid --- .../stunner/sw/client/theme/ColorTheme.java | 2 + .../stunner/sw/client/theme/DarkMode.java | 5 +++ .../stunner/sw/client/theme/LightMode.java | 5 +++ .../sw/client/editor/DiagramEditor.java | 41 +++++++++++++------ .../sw/client/editor/DiagramEditorTest.java | 26 ++++++++++++ 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java index 8b2c63fe59f..570b9884df9 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/ColorTheme.java @@ -23,6 +23,8 @@ public interface ColorTheme extends StunnerColorTheme { + String getName(); + String getCanvasBackgroundColor(); String getShapeStrokeColor(); diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java index f25f8b4efd3..2726f5237a3 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/DarkMode.java @@ -85,6 +85,11 @@ public static ColorTheme getInstance() { return instance; } + @Override + public String getName() { + return NAME; + } + @Override public String getCanvasBackgroundColor() { return CANVAS_BACKGROUND_COLOR; diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java index 6269a8c31fb..ee1c33d734a 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-client/src/main/java/org/kie/workbench/common/stunner/sw/client/theme/LightMode.java @@ -85,6 +85,11 @@ public static ColorTheme getInstance() { return instance; } + @Override + public String getName() { + return NAME; + } + @Override public String getCanvasBackgroundColor() { return CANVAS_BACKGROUND_COLOR; diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java index dfd75c3951f..ec35f4180a0 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/main/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditor.java @@ -100,7 +100,7 @@ public class DiagramEditor { private DocType currentDocType = DocType.JSON; private String currentPath; private String currentValue; - private String currentTheme = LightMode.NAME; + ColorTheme themeToBeApplied = null; @Inject private TranslationService translationService; @@ -159,29 +159,41 @@ public Promise getContentJSON() { } public final Promise applyTheme(String theme) { - if (null != theme && !theme.equals(currentTheme)) { - if (theme.equals(DarkMode.NAME)) { - StunnerTheme.setTheme(DarkMode.getInstance()); - currentTheme = DarkMode.NAME; - } else { - StunnerTheme.setTheme(LightMode.getInstance()); - currentTheme = LightMode.NAME; + if (null != theme && !theme.isEmpty() && + !theme.equals(((ColorTheme) StunnerTheme.getTheme()).getName())) { + + themeToBeApplied = getTheme(theme); + + // Do not apply theme if there are errors, keep it to apply when the diagram is valid + if (!stunnerEditor.hasErrors()) { + setTheme(); + reloadEditorContent(); } + } + return null; + } - reloadEditorContent(); + private ColorTheme getTheme(final String theme) { + if (theme.equals(DarkMode.NAME)) { + return DarkMode.getInstance(); + } else { + return LightMode.getInstance(); } + } - return null; + private void setTheme() { + StunnerTheme.setTheme(themeToBeApplied); + setCanvasBackgroundColor(); + themeToBeApplied = null; } void reloadEditorContent() { if (null != stunnerEditor.getSession()) { - setCanvasBackgroundColor(); Promise.resolve(setContent(currentPath, currentValue)); } } - private void setCanvasBackgroundColor() { + void setCanvasBackgroundColor() { ((WiresCanvas) stunnerEditor.getCanvasHandler().getCanvas()) .setBackgroundColor(((ColorTheme) StunnerTheme.getTheme()).getCanvasBackgroundColor()); } @@ -282,6 +294,11 @@ public Promise updateContent(final String path, final String value, final @Override public void onSuccess(final ParseResult parseResult) { + // Apply theme if pending due to errors + if (null != themeToBeApplied) { + setTheme(); + } + renderDiagram = parseResult.getDiagram(); updateDiagram(parseResult.getDiagram()); if (parseResult.getMessages().length > 0) { diff --git a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java index b9c73a48eba..78b350cbf35 100644 --- a/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java +++ b/packages/serverless-workflow-diagram-editor/sw-editor/sw-editor-kogito-app/src/test/java/org/kie/workbench/common/stunner/sw/client/editor/DiagramEditorTest.java @@ -74,6 +74,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; @@ -230,6 +231,7 @@ public void setUp() { diagram = spy(d); when(session.getCanvasHandler()).thenReturn(canvasHandler2); when(canvasHandler2.getDiagram()).thenReturn(diagram); + when(canvasHandler2.getCanvas()).thenReturn(canvas); doReturn(stunnerEditor2).when(stunnerEditor2).close(); when(stunnerEditor2.getSession()).thenReturn(viewerSession); when(selectionControl.clearSelection()).thenReturn(selectionControl); @@ -267,9 +269,29 @@ public void testSetTheme() { tested.applyTheme(DarkMode.NAME); verify(tested, times(1)).reloadEditorContent(); + verify(tested, times(1)).setCanvasBackgroundColor(); + assertNull(tested.themeToBeApplied); assertTrue(StunnerTheme.getTheme() instanceof DarkMode); } + @Test + public void testSetThemeBrokenDiagram() { + when(jsRegExp.exec(rawJSON)).thenReturn(regExpResult); + when(regExpResult.getAt(2)).thenReturn("injectExample"); + when(graph.getUUID()).thenReturn("injectExample"); + doNothing().when(tested).reloadEditorContent(); + + when(stunnerEditor2.hasErrors()).thenReturn(true); + + tested.onStartup(new DefaultPlaceRequest()); + tested.setContent("", rawJSON); + tested.applyTheme(DarkMode.NAME); + + verify(tested, times(0)).reloadEditorContent(); + verify(tested, times(0)).setCanvasBackgroundColor(); + assertTrue(tested.themeToBeApplied instanceof DarkMode); + } + @Test public void testSetThemeNull() { when(jsRegExp.exec(rawJSON)).thenReturn(regExpResult); @@ -282,6 +304,8 @@ public void testSetThemeNull() { tested.applyTheme(null); verify(tested, times(0)).reloadEditorContent(); + verify(tested, times(0)).setCanvasBackgroundColor(); + assertNull(tested.themeToBeApplied); assertTrue(StunnerTheme.getTheme() instanceof LightMode); } @@ -297,6 +321,8 @@ public void testSetThemeSame() { tested.applyTheme(LightMode.NAME); verify(tested, times(0)).reloadEditorContent(); + verify(tested, times(0)).setCanvasBackgroundColor(); + assertNull(tested.themeToBeApplied); assertTrue(StunnerTheme.getTheme() instanceof LightMode); } From f356821a8282809cd42e21a51fd8e09fd1eecd28 Mon Sep 17 00:00:00 2001 From: Handrey Cunha Date: Tue, 5 Mar 2024 20:56:04 -0500 Subject: [PATCH 14/24] Apply dark theme to zoombar combobox --- .../mediators/ZoomLevelSelectorView.css | 61 +++++++++++++++---- .../mediators/ZoomLevelSelectorView.html | 8 +-- .../mediators/ZoomLevelSelectorView.java | 41 +++++++++++-- 3 files changed, 88 insertions(+), 22 deletions(-) diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css index 7d23b5e39b9..381f5b3de25 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.css @@ -23,46 +23,83 @@ text-overflow: ellipsis; } +.zoom-selector-button-text-dark { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #fff; +} + .zoom-selector-menu { max-height: 250px; overflow-y: auto; } -.zoom-button-light { +.zoom-selector-menu-dark { + background-color: black; +} + +button.btn.dropdown-toggle.btn-default-dark { + background: black; + border-color: #343a40; +} + +button.btn.dropdown-toggle.btn-default-dark:focus { + background: black; + border-color: #343a40; +} + +.dropdown-menu-dark.open { + color: #fff; + background: black; + border-color: #343a40; +} + +.dropdown-menu-dark > li > a { + color: #fff; +} + +.dropdown-menu-dark > li > a:hover { + color: #fff; + background-color: #343a40; + border-color: #343a40; +} + +.zoom-button { color: #212529; background-color: #f8f9fa; border-color: #f8f9fa; } -.zoom-button-light:hover { +.zoom-button:hover { color: #212529; background-color: #e2e6ea; border-color: #dae0e5; } -.zoom-button-light:focus, -.zoom-button-light.focus { +.zoom-button:focus, +.zoom-button.focus { box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); } -.zoom-button-light.disabled, -.zoom-button-light:disabled { +.zoom-button.disabled, +.zoom-button:disabled { color: #a8a8a8; background-color: #f8f9fa; border-color: #f8f9fa; } -.zoom-button-light:not(:disabled):not(.disabled):active, -.zoom-button-light:not(:disabled):not(.disabled).active, -.show > .zoom-button-light.dropdown-toggle { +.zoom-button:not(:disabled):not(.disabled):active, +.zoom-button:not(:disabled):not(.disabled).active, +.show > .zoom-button.dropdown-toggle { color: #212529; background-color: #dae0e5; border-color: #d3d9df; } -.zoom-button-light:not(:disabled):not(.disabled):active:focus, -.zoom-button-light:not(:disabled):not(.disabled).active:focus, -.show > .zoom-button-light.dropdown-toggle:focus { +.zoom-button:not(:disabled):not(.disabled):active:focus, +.zoom-button:not(:disabled):not(.disabled).active:focus, +.show > .zoom-button.dropdown-toggle:focus { box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5); } diff --git a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html index cb4144b3bb6..bf1dc436dfa 100644 --- a/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html +++ b/packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/java/org/kie/workbench/common/stunner/client/lienzo/components/mediators/ZoomLevelSelectorView.html @@ -50,14 +50,14 @@ style="width: auto" data-ouia-component-id="select-zoom-button" > - -