diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4237b7bfd1..9b13674137 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -57,6 +57,7 @@ This allows representation precondition expressions to be more precise as they k - https://github.com/eclipse-sirius/sirius-components/issues/1265[#1265] [form] Add support for flexbox containers on FormDescriptionEditors - https://github.com/eclipse-sirius/sirius-components/issues/1272[#1272] [form] Add support for button widget on FormDescriptions - https://github.com/eclipse-sirius/sirius-components/issues/1273[#1273] [form] Add support for button widget on FormDescriptionEditors +- https://github.com/eclipse-sirius/sirius-components/issues/1266[#1266] [form] Add styling support on bar-chart and pie-chart Widgets in View DSL == v2022.7.0 diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChart.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChart.java index 028d106a48..7c4c0fbdac 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChart.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChart.java @@ -17,14 +17,17 @@ import java.util.List; import java.util.Objects; +import org.eclipse.sirius.components.annotations.Immutable; import org.eclipse.sirius.components.charts.IChart; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; /** * Root concept of the bar-chart representation. * * @author fbarbin */ -public class BarChart implements IChart { +@Immutable +public final class BarChart implements IChart { public static final String KIND = "BarChart"; //$NON-NLS-1$ private String id; @@ -37,16 +40,10 @@ public class BarChart implements IChart { private List entries; - public BarChart() { - // Used by Jackson - } + private BarChartStyle style; - public BarChart(String id, String descriptionId, String label, List entries) { - this.id = Objects.requireNonNull(id); - this.descriptionId = Objects.requireNonNull(descriptionId); - this.label = Objects.requireNonNull(label); - this.kind = KIND; - this.entries = new ArrayList<>(Objects.requireNonNull(entries)); + private BarChart() { + // Prevent instantiation } @Override @@ -73,10 +70,73 @@ public List getEntries() { return this.entries; } + public BarChartStyle getStyle() { + return this.style; + } + + public static Builder newBarChart(String id) { + return new Builder(id); + } + @Override public String toString() { String pattern = "{0} '{'id: {1}, descriptionId: {2}, label: {3}, kind: {4}'}'"; //$NON-NLS-1$ return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.descriptionId, this.label, this.kind); } + /** + * The builder of the bar-chart element props. + * + * @author fbarbin + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private String id; + + private String descriptionId; + + private String label; + + private String kind = KIND; + + private List entries; + + private BarChartStyle style; + + public Builder(String id) { + this.id = Objects.requireNonNull(id); + } + + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + + public Builder label(String label) { + this.label = Objects.requireNonNull(label); + return this; + } + + public Builder entries(List entries) { + this.entries = new ArrayList<>(entries); + return this; + } + + public Builder style(BarChartStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + + public BarChart build() { + BarChart barChart = new BarChart(); + barChart.id = Objects.requireNonNull(this.id); + barChart.descriptionId = Objects.requireNonNull(this.descriptionId); + barChart.label = Objects.requireNonNull(this.label); + barChart.kind = Objects.requireNonNull(this.kind); + barChart.entries = Objects.requireNonNull(this.entries); + barChart.style = this.style; + return barChart; + } + } } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponent.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponent.java index 63f70f4557..5986931244 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponent.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponent.java @@ -18,8 +18,9 @@ import java.util.UUID; import org.eclipse.sirius.components.charts.barchart.BarChart; -import org.eclipse.sirius.components.charts.barchart.BarChartDescription; +import org.eclipse.sirius.components.charts.barchart.descriptions.BarChartDescription; import org.eclipse.sirius.components.charts.barchart.elements.BarChartElementProps; +import org.eclipse.sirius.components.charts.barchart.elements.BarChartElementProps.Builder; import org.eclipse.sirius.components.representations.Element; import org.eclipse.sirius.components.representations.IComponent; import org.eclipse.sirius.components.representations.VariableManager; @@ -47,16 +48,20 @@ public Element render() { String label = barChartDescription.getLabelProvider().apply(variableManager); List values = barChartDescription.getValuesProvider().apply(variableManager); List keys = barChartDescription.getKeysProvider().apply(variableManager); + BarChartStyle barChartStyle = barChartDescription.getStyleProvider().apply(variableManager); // @formatter:off - BarChartElementProps barChartElementProps = BarChartElementProps.newBarChartElementProps(id) + Builder builder = BarChartElementProps.newBarChartElementProps(id) .label(label) .descriptionId(barChartDescription.getId()) .values(values) - .keys(keys) - .build(); + .keys(keys); // @formatter:on + if (barChartStyle != null) { + builder.style(barChartStyle); + } + BarChartElementProps barChartElementProps = builder.build(); return new Element(BarChartElementProps.TYPE, barChartElementProps); } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponentProps.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponentProps.java index c855936bb6..4896d4e9ca 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponentProps.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartComponentProps.java @@ -16,7 +16,7 @@ import java.util.Optional; import org.eclipse.sirius.components.charts.barchart.BarChart; -import org.eclipse.sirius.components.charts.barchart.BarChartDescription; +import org.eclipse.sirius.components.charts.barchart.descriptions.BarChartDescription; import org.eclipse.sirius.components.representations.IProps; import org.eclipse.sirius.components.representations.VariableManager; diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartStyle.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartStyle.java new file mode 100644 index 0000000000..d0105aba39 --- /dev/null +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/components/BarChartStyle.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.charts.barchart.components; + +import java.text.MessageFormat; +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * The style of a BarChart. + * + * @author fbarbin + */ +@Immutable +public final class BarChartStyle { + + private String barsColor; + + private int fontSize; + + private boolean italic; + + private boolean bold; + + private boolean underline; + + private boolean strikeThrough; + + private BarChartStyle() { + // prevent instantiation + } + + public String getBarsColor() { + return this.barsColor; + } + + public int getFontSize() { + return this.fontSize; + } + + public boolean isItalic() { + return this.italic; + } + + public boolean isBold() { + return this.bold; + } + + public boolean isUnderline() { + return this.underline; + } + + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + public static Builder newBarChartStyle() { + return new Builder(); + } + + @Override + public String toString() { + String pattern = "{0} '{'barsColor: {1}, fontSize: {2}, italic: {3}, bold: {4}, underline: {5}, strikeThrough: {6}'}'"; //$NON-NLS-1$ + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.barsColor, this.fontSize, this.italic, this.bold, this.underline, this.strikeThrough); + } + + /** + * Builder used to create the BarChart style. + * + * @author fbarbin + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + private String barsColor; + + private int fontSize; + + private boolean italic; + + private boolean bold; + + private boolean underline; + + private boolean strikeThrough; + + public Builder barsColor(String barsColor) { + this.barsColor = Objects.requireNonNull(barsColor); + return this; + } + + public Builder fontSize(int fontSize) { + this.fontSize = fontSize; + return this; + } + + public Builder italic(boolean italic) { + this.italic = italic; + return this; + } + + public Builder bold(boolean bold) { + this.bold = bold; + return this; + } + + public Builder underline(boolean underline) { + this.underline = underline; + return this; + } + + public Builder strikeThrough(boolean strikeThrough) { + this.strikeThrough = strikeThrough; + return this; + } + + public BarChartStyle build() { + BarChartStyle barChartStyle = new BarChartStyle(); + barChartStyle.barsColor = this.barsColor; + barChartStyle.fontSize = this.fontSize; + barChartStyle.italic = this.italic; + barChartStyle.bold = this.bold; + barChartStyle.underline = this.underline; + barChartStyle.strikeThrough = this.strikeThrough; + return barChartStyle; + } + } + +} diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChartDescription.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/descriptions/BarChartDescription.java similarity index 83% rename from packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChartDescription.java rename to packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/descriptions/BarChartDescription.java index 68ed40d3fc..b37e2fd597 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/BarChartDescription.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/descriptions/BarChartDescription.java @@ -10,13 +10,14 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.sirius.components.charts.barchart; +package org.eclipse.sirius.components.charts.barchart.descriptions; import java.util.List; import java.util.Objects; import java.util.function.Function; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; import org.eclipse.sirius.components.charts.descriptions.IChartDescription; import org.eclipse.sirius.components.representations.VariableManager; @@ -38,8 +39,10 @@ public final class BarChartDescription implements IChartDescription { private Function> keysProvider; + private Function styleProvider; + private BarChartDescription() { - // prevent instantiation; + // prevent instantiation } @Override @@ -64,6 +67,10 @@ public Function> getKeysProvider() { return this.keysProvider; } + public Function getStyleProvider() { + return this.styleProvider; + } + public static Builder newBarChartDescription(String id) { return new Builder(id); } @@ -85,6 +92,8 @@ public static final class Builder { private Function> keysProvider; + private Function styleProvider = variableManager -> null; + public Builder(String id) { this.id = Objects.requireNonNull(id); } @@ -109,6 +118,11 @@ public Builder keysProvider(Function> keysProvider return this; } + public Builder styleProvider(Function styleProvider) { + this.styleProvider = Objects.requireNonNull(styleProvider); + return this; + } + public BarChartDescription build() { BarChartDescription barChartDescription = new BarChartDescription(); barChartDescription.id = Objects.requireNonNull(this.id); @@ -116,6 +130,7 @@ public BarChartDescription build() { barChartDescription.labelProvider = Objects.requireNonNull(this.labelProvider); barChartDescription.valuesProvider = Objects.requireNonNull(this.valuesProvider); barChartDescription.keysProvider = Objects.requireNonNull(this.keysProvider); + barChartDescription.styleProvider = Objects.requireNonNull(this.styleProvider); return barChartDescription; } } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/elements/BarChartElementProps.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/elements/BarChartElementProps.java index d51d461734..7834ae202a 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/elements/BarChartElementProps.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/barchart/elements/BarChartElementProps.java @@ -16,6 +16,7 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; import org.eclipse.sirius.components.representations.IProps; /** @@ -38,6 +39,8 @@ public final class BarChartElementProps implements IProps { private List keys; + private BarChartStyle style; + private BarChartElementProps() { // prevent instantiation } @@ -62,6 +65,10 @@ public List getKeys() { return this.keys; } + public BarChartStyle getStyle() { + return this.style; + } + public static Builder newBarChartElementProps(String id) { return new Builder(id); } @@ -83,6 +90,8 @@ public static final class Builder { private List keys; + private BarChartStyle style; + public Builder(String id) { this.id = Objects.requireNonNull(id); } @@ -107,6 +116,11 @@ public Builder keys(List keys) { return this; } + public Builder style(BarChartStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public BarChartElementProps build() { BarChartElementProps barChartElementProps = new BarChartElementProps(); barChartElementProps.id = Objects.requireNonNull(this.id); @@ -114,6 +128,7 @@ public BarChartElementProps build() { barChartElementProps.label = Objects.requireNonNull(this.label); barChartElementProps.values = Objects.requireNonNull(this.values); barChartElementProps.keys = Objects.requireNonNull(this.keys); + barChartElementProps.style = this.style; // Optional on purpose return barChartElementProps; } } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChart.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChart.java index c439d66fa4..adf3cbbea2 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChart.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChart.java @@ -17,14 +17,17 @@ import java.util.List; import java.util.Objects; +import org.eclipse.sirius.components.annotations.Immutable; import org.eclipse.sirius.components.charts.IChart; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; /** * Root concept of the pie-chart representation. * * @author fbarbin */ -public class PieChart implements IChart { +@Immutable +public final class PieChart implements IChart { public static final String KIND = "PieChart"; //$NON-NLS-1$ private String id; @@ -37,16 +40,10 @@ public class PieChart implements IChart { private List entries; - public PieChart() { - // Used by Jackson - } + private PieChartStyle style; - public PieChart(String id, String descriptionId, String label, List entries) { - this.id = Objects.requireNonNull(id); - this.descriptionId = Objects.requireNonNull(descriptionId); - this.label = Objects.requireNonNull(label); - this.kind = KIND; - this.entries = new ArrayList<>(Objects.requireNonNull(entries)); + private PieChart() { + // prevent instantiation } @Override @@ -73,10 +70,74 @@ public List getEntries() { return this.entries; } + public PieChartStyle getStyle() { + return this.style; + } + + public static Builder newPieChart(String id) { + return new Builder(id); + } + @Override public String toString() { String pattern = "{0} '{'id: {1}, descriptionId: {2}, label: {3}, kind: {4}'}'"; //$NON-NLS-1$ return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.id, this.descriptionId, this.label, this.kind); } + /** + * The builder of the pie-chart. + * + * @author fbarbin + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + + private String id; + + private String descriptionId; + + private String label; + + private String kind = KIND; + + private List entries; + + private PieChartStyle style; + + public Builder(String id) { + this.id = Objects.requireNonNull(id); + } + + public Builder descriptionId(String descriptionId) { + this.descriptionId = Objects.requireNonNull(descriptionId); + return this; + } + + public Builder label(String label) { + this.label = Objects.requireNonNull(label); + return this; + } + + public Builder entries(List entries) { + this.entries = new ArrayList<>(Objects.requireNonNull(entries)); + return this; + } + + public Builder style(PieChartStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + + public PieChart build() { + PieChart pieChart = new PieChart(); + pieChart.id = Objects.requireNonNull(this.id); + pieChart.label = Objects.requireNonNull(this.label); + pieChart.descriptionId = Objects.requireNonNull(this.descriptionId); + pieChart.kind = Objects.requireNonNull(this.kind); + pieChart.entries = Objects.requireNonNull(this.entries); + pieChart.style = this.style; // Optional on purpose + return pieChart; + } + } + } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChartDescription.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChartDescription.java index b3da3ac1c7..a0d12e1d6a 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChartDescription.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/PieChartDescription.java @@ -18,6 +18,7 @@ import org.eclipse.sirius.components.annotations.Immutable; import org.eclipse.sirius.components.charts.descriptions.IChartDescription; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; import org.eclipse.sirius.components.representations.VariableManager; /** @@ -36,8 +37,10 @@ public final class PieChartDescription implements IChartDescription { private Function> keysProvider; + private Function styleProvider; + private PieChartDescription() { - // prevent instantiation; + // prevent instantiation } @Override @@ -58,6 +61,10 @@ public Function> getKeysProvider() { return this.keysProvider; } + public Function getStyleProvider() { + return this.styleProvider; + } + public static Builder newPieChartDescription(String id) { return new Builder(id); } @@ -77,6 +84,8 @@ public static final class Builder { private Function> keysProvider; + private Function styleProvider; + public Builder(String id) { this.id = Objects.requireNonNull(id); } @@ -96,12 +105,18 @@ public Builder keysProvider(Function> keysProvider return this; } + public Builder styleProvider(Function styleProvider) { + this.styleProvider = Objects.requireNonNull(styleProvider); + return this; + } + public PieChartDescription build() { PieChartDescription pieChartDescription = new PieChartDescription(); pieChartDescription.id = Objects.requireNonNull(this.id); pieChartDescription.label = Objects.requireNonNull(this.label); pieChartDescription.valuesProvider = Objects.requireNonNull(this.valuesProvider); pieChartDescription.keysProvider = Objects.requireNonNull(this.keysProvider); + pieChartDescription.styleProvider = Objects.requireNonNull(this.styleProvider); return pieChartDescription; } } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartComponent.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartComponent.java index 265a920266..80cc19f596 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartComponent.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartComponent.java @@ -20,6 +20,7 @@ import org.eclipse.sirius.components.charts.piechart.PieChart; import org.eclipse.sirius.components.charts.piechart.PieChartDescription; import org.eclipse.sirius.components.charts.piechart.elements.PieChartElementProps; +import org.eclipse.sirius.components.charts.piechart.elements.PieChartElementProps.Builder; import org.eclipse.sirius.components.representations.Element; import org.eclipse.sirius.components.representations.IComponent; import org.eclipse.sirius.components.representations.VariableManager; @@ -46,15 +47,18 @@ public Element render() { String id = optionalPreviousPieChart.map(PieChart::getId).orElseGet(() -> UUID.randomUUID().toString()); List values = pieChartDescription.getValuesProvider().apply(variableManager); List keys = pieChartDescription.getKeysProvider().apply(variableManager); + PieChartStyle pieChartStyle = pieChartDescription.getStyleProvider().apply(variableManager); // @formatter:off - PieChartElementProps pieChartElementProps = PieChartElementProps.newPieChartElementProps(id) + Builder builder = PieChartElementProps.newPieChartElementProps(id) .descriptionId(pieChartDescription.getId()) .values(values) - .keys(keys) - .build(); + .keys(keys); // @formatter:on - + if (pieChartStyle != null) { + builder.style(pieChartStyle); + } + PieChartElementProps pieChartElementProps = builder.build(); return new Element(PieChartElementProps.TYPE, pieChartElementProps); } diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartStyle.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartStyle.java new file mode 100644 index 0000000000..3691a05785 --- /dev/null +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/components/PieChartStyle.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.charts.piechart.components; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.Immutable; + +/** + * The style of a PieChart. + * + * @author fbarbin + */ +@Immutable +public final class PieChartStyle { + + private List colors; + + private int strokeWidth; + + private String strokeColor; + + private int fontSize; + + private boolean italic; + + private boolean bold; + + private boolean underline; + + private boolean strikeThrough; + + private PieChartStyle() { + // prevent instantiation + } + + public List getColors() { + return this.colors; + } + + public int getStrokeWidth() { + return this.strokeWidth; + } + + public String getStrokeColor() { + return this.strokeColor; + } + + public int getFontSize() { + return this.fontSize; + } + + public boolean isItalic() { + return this.italic; + } + + public boolean isBold() { + return this.bold; + } + + public boolean isUnderline() { + return this.underline; + } + + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + public static Builder newPieChartStyle() { + return new Builder(); + } + + @Override + public String toString() { + String pattern = "{0} '{'colors: {1}, strokeWidth: {2}, strokeColor: {3}, fontSize: {4}, italic: {5}, bold: {6}, underline: {7}, strikeThrough: {8}'}'"; //$NON-NLS-1$ + return MessageFormat.format(pattern, this.getClass().getSimpleName(), this.colors, this.strokeWidth, this.strokeColor, this.fontSize, this.italic, this.bold, this.underline, + this.strikeThrough); + } + + /** + * Builder used to create the BarChart style. + * + * @author fbarbin + */ + @SuppressWarnings("checkstyle:HiddenField") + public static final class Builder { + private List colors = new ArrayList<>(); + + private int strokeWidth; + + private String strokeColor; + + private int fontSize; + + private boolean italic; + + private boolean bold; + + private boolean underline; + + private boolean strikeThrough; + + public Builder colors(List colors) { + this.colors = new ArrayList<>(Objects.requireNonNull(colors)); + return this; + } + + public Builder strokeWidth(int strokeWidth) { + this.strokeWidth = Objects.requireNonNull(strokeWidth); + return this; + } + + public Builder strokeColor(String strokeColor) { + this.strokeColor = Objects.requireNonNull(strokeColor); + return this; + } + + public Builder fontSize(int fontSize) { + this.fontSize = fontSize; + return this; + } + + public Builder italic(boolean italic) { + this.italic = italic; + return this; + } + + public Builder bold(boolean bold) { + this.bold = bold; + return this; + } + + public Builder underline(boolean underline) { + this.underline = underline; + return this; + } + + public Builder strikeThrough(boolean strikeThrough) { + this.strikeThrough = strikeThrough; + return this; + } + + public PieChartStyle build() { + PieChartStyle pieChartStyle = new PieChartStyle(); + // All style attributes are optional. + pieChartStyle.colors = this.colors; + pieChartStyle.strokeWidth = this.strokeWidth; + pieChartStyle.strokeColor = this.strokeColor; + pieChartStyle.fontSize = this.fontSize; + pieChartStyle.italic = this.italic; + pieChartStyle.bold = this.bold; + pieChartStyle.underline = this.underline; + pieChartStyle.strikeThrough = this.strikeThrough; + return pieChartStyle; + } + } + +} diff --git a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/elements/PieChartElementProps.java b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/elements/PieChartElementProps.java index 33345e5518..16e109c5ad 100644 --- a/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/elements/PieChartElementProps.java +++ b/packages/charts/backend/sirius-components-charts/src/main/java/org/eclipse/sirius/components/charts/piechart/elements/PieChartElementProps.java @@ -16,6 +16,7 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.Immutable; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; import org.eclipse.sirius.components.representations.IProps; /** @@ -36,6 +37,8 @@ public final class PieChartElementProps implements IProps { private List keys; + private PieChartStyle style; + private PieChartElementProps() { // prevent instantiation } @@ -56,6 +59,10 @@ public List getKeys() { return this.keys; } + public PieChartStyle getStyle() { + return this.style; + } + public static Builder newPieChartElementProps(String id) { return new Builder(id); } @@ -75,6 +82,8 @@ public static final class Builder { private List keys; + private PieChartStyle style; + public Builder(String id) { this.id = Objects.requireNonNull(id); } @@ -94,12 +103,18 @@ public Builder keys(List keys) { return this; } + public Builder style(PieChartStyle style) { + this.style = Objects.requireNonNull(style); + return this; + } + public PieChartElementProps build() { PieChartElementProps pieChartElementProps = new PieChartElementProps(); pieChartElementProps.id = Objects.requireNonNull(this.id); pieChartElementProps.descriptionId = Objects.requireNonNull(this.descriptionId); pieChartElementProps.values = Objects.requireNonNull(this.values); pieChartElementProps.keys = Objects.requireNonNull(this.keys); + pieChartElementProps.style = this.style; // Optional on purpose return pieChartElementProps; } } diff --git a/packages/charts/backend/sirius-components-collaborative-charts/src/main/resources/schema/charts.graphqls b/packages/charts/backend/sirius-components-collaborative-charts/src/main/resources/schema/charts.graphqls index 7594d50c98..34b9cf8910 100644 --- a/packages/charts/backend/sirius-components-collaborative-charts/src/main/resources/schema/charts.graphqls +++ b/packages/charts/backend/sirius-components-collaborative-charts/src/main/resources/schema/charts.graphqls @@ -27,6 +27,7 @@ type BarChart implements Representation { metadata: RepresentationMetadata! label: String! entries: [BarChartEntry!]! + style: BarChartStyle } type BarChartEntry { @@ -34,10 +35,20 @@ type BarChartEntry { value: Float! } +type BarChartStyle { + barsColor: String + fontSize: Int + italic: Boolean + bold: Boolean + underline: Boolean + strikeThrough: Boolean +} + type PieChart implements Representation { id: ID! metadata: RepresentationMetadata! entries: [PieChartEntry!]! + style: PieChartStyle } type PieChartEntry { @@ -45,6 +56,18 @@ type PieChartEntry { value: Float! } + +type PieChartStyle { + colors: [String]! + strokeColor: String + strokeWidth: Float + fontSize: Int + italic: Boolean + bold: Boolean + underline: Boolean + strikeThrough: Boolean +} + type HierarchyNode { id: ID! label: String! diff --git a/packages/charts/frontend/sirius-components-charts/src/Charts.types.ts b/packages/charts/frontend/sirius-components-charts/src/Charts.types.ts new file mode 100644 index 0000000000..749485e2ec --- /dev/null +++ b/packages/charts/frontend/sirius-components-charts/src/Charts.types.ts @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +export interface FontStyle { + fontSize: number | null; + italic: boolean | null; + bold: boolean | null; + underline: boolean | null; + strikeThrough: boolean | null; +} diff --git a/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.tsx b/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.tsx index c41d520fb6..ec07090086 100644 --- a/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.tsx +++ b/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.tsx @@ -12,6 +12,7 @@ *******************************************************************************/ import * as d3 from 'd3'; import { useEffect, useRef } from 'react'; +import { getFontSize, getFontStyle, getFontWeight, getTextDecoration } from '../chartOperations'; import { BarChartProps } from './BarChart.types'; export const BarChart = ({ width, height, chart }: BarChartProps) => { @@ -29,10 +30,19 @@ export const BarChart = ({ width, height, chart }: BarChartProps) => { const yFormat = 'f'; if (d3Container.current && chart) { - const { entries: data, label: yLabel } = chart; + const { entries: data, label: yLabel, style } = chart; + const fontSize = getFontSize(style); + const fontStyle = getFontStyle(style); + const fontWeight = getFontWeight(style); + const textDecoration = getTextDecoration(style); const x = (d) => d.key; const y = (d) => d.value; - const color = 'steelblue'; + let color: string; + if (style?.barsColor != null && style?.barsColor.length > 0) { + color = style?.barsColor; + } else { + color = 'steelblue'; + } // Compute values. const X = d3.map(data, x); const Y = d3.map(data, y); @@ -63,6 +73,10 @@ export const BarChart = ({ width, height, chart }: BarChartProps) => { svg .append('g') .attr('transform', `translate(${marginLeft},0)`) + .attr( + 'style', + `font-size:${fontSize}; font-style: ${fontStyle}; text-decoration: ${textDecoration}; font-weight: ${fontWeight}` + ) .call(yAxis) .call((g) => g.select('.domain').remove()) .call((g) => @@ -100,6 +114,10 @@ export const BarChart = ({ width, height, chart }: BarChartProps) => { svg .append('g') .attr('transform', `translate(0,${height - marginBottom})`) + .attr( + 'style', + `font-size:${fontSize}; font-style: ${fontStyle}; text-decoration: ${textDecoration}; font-weight: ${fontWeight}` + ) .call(xAxis); } }, [width, height, chart, d3Container]); diff --git a/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.types.ts b/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.types.ts index 8d3b9c56ce..d06f997a07 100644 --- a/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.types.ts +++ b/packages/charts/frontend/sirius-components-charts/src/bar/BarChart.types.ts @@ -11,6 +11,8 @@ * Obeo - initial API and implementation *******************************************************************************/ +import { FontStyle } from '../Charts.types'; + export interface BarChartProps { width: number; height: number; @@ -20,8 +22,13 @@ export interface BarChartProps { export interface BarChartRepresentation { label: string; entries: BarChartRepresentationEntry[]; + style: BarChartStyle | null; } export interface BarChartRepresentationEntry { key: string; value: number; } + +export interface BarChartStyle extends FontStyle { + barsColor: string | null; +} diff --git a/packages/charts/frontend/sirius-components-charts/src/chartOperations.ts b/packages/charts/frontend/sirius-components-charts/src/chartOperations.ts new file mode 100644 index 0000000000..5e4d490cad --- /dev/null +++ b/packages/charts/frontend/sirius-components-charts/src/chartOperations.ts @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ + +import { FontStyle } from './Charts.types'; + +export const getFontWeight = (style: FontStyle | null): string => { + if (style?.bold != null) { + return style.bold ? 'bold' : 'normal'; + } + return 'normal'; +}; + +export const getFontSize = (style: FontStyle | null): number => { + //The default size is 10 in D3 but 14 is more confortable. + return style?.fontSize ?? 14; +}; + +export const getFontStyle = (style: FontStyle | null): string => { + if (style?.italic != null) { + return style.italic ? 'italic' : 'normal'; + } + return 'normal'; +}; + +export const getTextDecoration = (style: FontStyle | null): string => { + let decoration: string = ''; + if (style?.strikeThrough != null && style.strikeThrough) { + decoration = decoration + 'line-through'; + } + if (style?.underline != null && style.underline) { + let separator: string = decoration.length > 0 ? ' ' : ''; + decoration = decoration + separator + 'underline'; + } + return decoration.length > 0 ? decoration : 'none'; +}; diff --git a/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.tsx b/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.tsx index 2f6f435088..8e7889834e 100644 --- a/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.tsx +++ b/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.tsx @@ -11,27 +11,33 @@ * Obeo - initial API and implementation *******************************************************************************/ // This comment will be removed in the future but we should not have to wait to solve -// all d3 relatd typing issues in order to move forward with our TypeScript checks +// all d3 related typing issues in order to move forward with our TypeScript checks // @ts-nocheck +import { PieChartStyle } from 'charts/Charts.types'; import * as d3 from 'd3'; import { useEffect, useRef } from 'react'; +import { getFontSize, getFontStyle, getFontWeight, getTextDecoration } from '../chartOperations'; import { PieChartProps } from './PieChart.types'; export const PieChart = ({ width, height, chart }: PieChartProps) => { const d3Container = useRef(null); useEffect(() => { - const { entries: data } = chart; + const { entries: data, style } = chart; const name = (d) => d.key; // given d in data, returns the (ordinal) label const value = (d) => d.value; // given d in data, returns the (quantitative) value const innerRadius = 0; // inner radius of pie, in pixels (non-zero for donut) const outerRadius = Math.min(width, height) / 2; // outer radius of pie, in pixels const labelRadius = innerRadius * 0.2 + outerRadius * 0.8; // center radius of labels const format = ','; // a format specifier for values (in the label) - const stroke = innerRadius > 0 ? 'none' : 'white'; // stroke separating widths - const strokeWidth = 1; // width of stroke separating wedges const strokeLinejoin = 'round'; // line join of stroke separating wedges + const stroke = innerRadius > 0 ? 'none' : getStrokeColorValue(style); // stroke separating widths const padAngle = stroke === 'none' ? 1 / outerRadius : 0; // angular separation between wedges + const strokeWidth = getStrokeWidth(style); // width of stroke separating wedges + const fontWeight: string = getFontWeight(style); + const fontStyle: string = getFontStyle(style); + const textDecoration: string = getTextDecoration(style); + const fontSize: number = getFontSize(style); // Compute values. const N = d3.map(data, name); const V = d3.map(data, value); @@ -40,9 +46,10 @@ export const PieChart = ({ width, height, chart }: PieChartProps) => { // Unique the names. const names = new d3.InternSet(N); - // Chose a default color scheme based on cardinality. - let colors = d3.schemeSpectral[names.size]; - if (colors === undefined) colors = d3.quantize((t) => d3.interpolateSpectral(t * 0.8 + 0.1), names.size); + let colors: string[] = style?.colors; + if (colors === undefined || colors.length === 0) { + colors = d3.quantize((t) => d3.interpolateSpectral(t * 0.8 + 0.1), names.size); + } // Construct scales. const color = d3.scaleOrdinal(names, colors); @@ -95,7 +102,10 @@ export const PieChart = ({ width, height, chart }: PieChartProps) => { svg .append('g') .attr('font-family', 'sans-serif') - .attr('font-size', 10) + .attr('font-size', fontSize) + .attr('font-style', fontStyle) + .attr('text-decoration', textDecoration) + .attr('font-weight', fontWeight) .attr('text-anchor', 'middle') .selectAll('text') .data(arcs) @@ -112,5 +122,13 @@ export const PieChart = ({ width, height, chart }: PieChartProps) => { Object.assign(svg.node(), { scales: { color } }); }, [width, height, chart, d3Container]); + const getStrokeColorValue = (style: PieChartStyle | null): string => { + return style?.strokeColor ?? 'white'; + }; + + const getStrokeWidth = (style: PieChartStyle | null): number => { + return style?.strokeWidth ?? 1; + }; + return ; }; diff --git a/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.types.ts b/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.types.ts index 8c14378f2a..e7688d16c7 100644 --- a/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.types.ts +++ b/packages/charts/frontend/sirius-components-charts/src/pie/PieChart.types.ts @@ -11,6 +11,8 @@ * Obeo - initial API and implementation *******************************************************************************/ +import { FontStyle } from '../Charts.types'; + export interface PieChartProps { width: number; height: number; @@ -19,9 +21,16 @@ export interface PieChartProps { export interface PieChartRepresentation { entries: PieChartRepresentationEntry[]; + style: PieChartStyle | null; } export interface PieChartRepresentationEntry { key: string; value: number; } + +export interface PieChartStyle extends FontStyle { + colors: string[] | null; + strokeColor: string | null; + strokeWidth: number | null; +} diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/BarChartWidget.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/BarChartWidget.tsx index 22db5b9a39..9e5f34ce41 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/BarChartWidget.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/BarChartWidget.tsx @@ -54,6 +54,7 @@ export const BarChartWidget = ({ widget, selection }: WidgetProps) => { { key: 'Y', value: 0.01974 }, { key: 'Z', value: 0.00074 }, ], + style: null, }; const [selected, setSelected] = useState(false); diff --git a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PieChartWidget.tsx b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PieChartWidget.tsx index 40d8b727c3..0ad05121b1 100644 --- a/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PieChartWidget.tsx +++ b/packages/formdescriptioneditors/frontend/sirius-components-formdescriptioneditors/src/PieChartWidget.tsx @@ -45,6 +45,7 @@ export const PieChartWidget = ({ widget, selection }: WidgetProps) => { { key: '80-84', value: 5811429 }, { key: '≥85', value: 5938752 }, ], + style: null, }; const [selected, setSelected] = useState(false); diff --git a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/ChartWidgetComponent.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/ChartWidgetComponent.java index 878c099e43..670e816bc7 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/ChartWidgetComponent.java +++ b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/components/ChartWidgetComponent.java @@ -17,9 +17,9 @@ import java.util.Objects; import java.util.Optional; -import org.eclipse.sirius.components.charts.barchart.BarChartDescription; import org.eclipse.sirius.components.charts.barchart.components.BarChartComponent; import org.eclipse.sirius.components.charts.barchart.components.BarChartComponentProps; +import org.eclipse.sirius.components.charts.barchart.descriptions.BarChartDescription; import org.eclipse.sirius.components.charts.descriptions.IChartDescription; import org.eclipse.sirius.components.charts.piechart.PieChartDescription; import org.eclipse.sirius.components.charts.piechart.components.PieChartComponent; diff --git a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java index 28fb034fbf..21c16bbe23 100644 --- a/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java +++ b/packages/forms/backend/sirius-components-forms/src/main/java/org/eclipse/sirius/components/forms/renderer/FormElementFactory.java @@ -18,6 +18,7 @@ import org.eclipse.sirius.components.charts.IChart; import org.eclipse.sirius.components.charts.barchart.BarChart; +import org.eclipse.sirius.components.charts.barchart.BarChart.Builder; import org.eclipse.sirius.components.charts.barchart.BarChartEntry; import org.eclipse.sirius.components.charts.barchart.elements.BarChartElementProps; import org.eclipse.sirius.components.charts.piechart.PieChart; @@ -31,7 +32,6 @@ import org.eclipse.sirius.components.forms.Form; import org.eclipse.sirius.components.forms.Group; import org.eclipse.sirius.components.forms.Link; -import org.eclipse.sirius.components.forms.List.Builder; import org.eclipse.sirius.components.forms.MultiSelect; import org.eclipse.sirius.components.forms.Page; import org.eclipse.sirius.components.forms.Radio; @@ -110,18 +110,38 @@ public Object instantiateElement(String type, IProps props, List childre return object; } - public Object instantiateBarChart(BarChartElementProps props) { + private Object instantiateBarChart(BarChartElementProps props) { BarChartElementProps barChartElementProps = props; List entries = this.getBarChartEntries(barChartElementProps); - return new BarChart(barChartElementProps.getId(), barChartElementProps.getDescriptionId(), barChartElementProps.getLabel(), entries); + // @formatter:off + Builder builder = BarChart.newBarChart(barChartElementProps.getId()) + .descriptionId(barChartElementProps.getDescriptionId()) + .label(barChartElementProps.getLabel()) + .entries(entries); + // @formatter:on + + if (props.getStyle() != null) { + builder.style(props.getStyle()); + } + return builder.build(); } - public Object instantiatePieChart(PieChartElementProps props) { + private Object instantiatePieChart(PieChartElementProps props) { PieChartElementProps pieChartElementProps = props; List entries = this.getPieChartEntries(pieChartElementProps); // The label is not used for pieChart. This attribute is inherited from IRepresentation String label = "pieChart"; //$NON-NLS-1$ - return new PieChart(pieChartElementProps.getId(), pieChartElementProps.getDescriptionId(), label, entries); + // @formatter:off + org.eclipse.sirius.components.charts.piechart.PieChart.Builder builder = PieChart.newPieChart(pieChartElementProps.getId()) + .descriptionId(pieChartElementProps.getDescriptionId()) + .label(label) + .entries(entries); + // @formatter:on + + if (props.getStyle() != null) { + builder.style(props.getStyle()); + } + return builder.build(); } private List getBarChartEntries(BarChartElementProps barChartElementProps) { @@ -218,7 +238,7 @@ private org.eclipse.sirius.components.forms.List instantiateList(ListElementProp List diagnostics = this.getDiagnosticsFromChildren(children); // @formatter:off - Builder listBuilder = org.eclipse.sirius.components.forms.List.newList(props.getId()) + org.eclipse.sirius.components.forms.List.Builder listBuilder = org.eclipse.sirius.components.forms.List.newList(props.getId()) .label(props.getLabel()) .items(props.getItems()) .diagnostics(diagnostics); diff --git a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts index 375519c5cd..b5fe372a06 100644 --- a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts +++ b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.ts @@ -246,6 +246,14 @@ export const formRefreshedEventPayloadFragment = ` key value } + style { + barsColor + fontSize + italic + bold + underline + strikeThrough + } } ... on PieChart { metadata { @@ -256,6 +264,16 @@ export const formRefreshedEventPayloadFragment = ` key value } + style { + colors + strokeColor + strokeWidth + fontSize + italic + bold + underline + strikeThrough + } } } } diff --git a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts index b70d2b358f..fb810435ac 100644 --- a/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts +++ b/packages/forms/frontend/sirius-components-forms/src/form/FormEventFragments.types.ts @@ -270,6 +270,19 @@ export type GQLChart = GQLBarChart | GQLPieChart; export interface GQLBarChart extends GQLRepresentation { label: string; entries: GQLBarChartEntry[]; + style: GQLBarChartStyle | null; +} + +export interface GQLFontStyle { + fontSize: number | null; + italic: boolean | null; + bold: boolean | null; + underline: boolean | null; + strikeThrough: boolean | null; +} + +export interface GQLBarChartStyle extends GQLFontStyle { + barsColor: string | null; } export interface GQLBarChartEntry { @@ -280,6 +293,13 @@ export interface GQLBarChartEntry { export interface GQLPieChart extends GQLRepresentation { label: string; entries: GQLPieChartEntry[]; + style: GQLPieChartStyle | null; +} + +export interface GQLPieChartStyle extends GQLFontStyle { + colors: string[] | null; + strokeColor: string | null; + strokeWidth: number | null; } export interface GQLPieChartEntry { diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ChartWidgetPropertySection.test.tsx b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ChartWidgetPropertySection.test.tsx new file mode 100644 index 0000000000..145060a770 --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/ChartWidgetPropertySection.test.tsx @@ -0,0 +1,236 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +import { MockedProvider } from '@apollo/client/testing'; + +import { cleanup, render } from '@testing-library/react'; +import { afterEach, expect, test, vi } from 'vitest'; +import { + GQLBarChart, + GQLBarChartEntry, + GQLChartWidget, + GQLPieChart, + GQLPieChartEntry, + GQLRepresentationMetadata, +} from '../../form/FormEventFragments.types'; +import { ChartWidgetPropertySection } from '../ChartWidgetPropertySection'; + +vi.mock('uuid', () => ({ v4: () => '48be95fc-3422-45d3-b1f9-d590e847e9e1' })); + +afterEach(() => cleanup()); +const pieChartentries: GQLPieChartEntry[] = [ + { key: 'a', value: 10 }, + { key: 'b', value: 15 }, + { key: 'c', value: 5 }, + { key: 'd', value: 20 }, +]; + +const pieChartMetadata: GQLRepresentationMetadata = { + id: 'pieChartId', + label: 'PieChartLabel', + kind: 'PieChart', + description: { + id: 'descriptionId', + }, +}; + +const defaultPieChart: GQLPieChart = { + label: 'PieChartLabel', + metadata: pieChartMetadata, + entries: pieChartentries, + style: null, +}; + +const defaultPieChartWithStyle: GQLPieChart = { + label: 'PieChartLabel', + metadata: pieChartMetadata, + entries: pieChartentries, + style: { + strokeWidth: 2, + strokeColor: 'Aquamarine', + colors: ['CadetBlue', 'CornflowerBlue', 'Lavender', 'LightSteelBlue'], + bold: true, + italic: true, + fontSize: 15, + strikeThrough: true, + underline: true, + }, +}; + +const defaultPieChartWithEmptyStyle: GQLPieChart = { + label: 'PieChartLabel', + metadata: pieChartMetadata, + entries: pieChartentries, + style: { + strokeWidth: null, + strokeColor: '', + colors: [], + bold: false, + italic: false, + fontSize: null, + strikeThrough: false, + underline: false, + }, +}; + +const barChartentries: GQLBarChartEntry[] = [ + { key: 'a', value: 10 }, + { key: 'b', value: 15 }, + { key: 'c', value: 5 }, + { key: 'd', value: 20 }, +]; +const barChartMetadata: GQLRepresentationMetadata = { + id: 'BarChartId', + label: 'barChartLabel', + kind: 'BarChart', + description: { + id: 'descriptionId', + }, +}; +const defaultBarChart: GQLBarChart = { + label: 'values', + metadata: barChartMetadata, + entries: barChartentries, + style: null, +}; +const defaultBarChartWithStyle: GQLBarChart = { + label: 'values', + metadata: barChartMetadata, + entries: barChartentries, + style: { + barsColor: 'Aquamarine', + bold: true, + italic: true, + fontSize: 15, + strikeThrough: true, + underline: true, + }, +}; + +const defaultBarChartWithEmptyStyle: GQLBarChart = { + label: 'values', + metadata: barChartMetadata, + entries: barChartentries, + style: { + barsColor: '', + bold: false, + italic: false, + fontSize: 12, + strikeThrough: false, + underline: false, + }, +}; +const defaultPieChartWidget: GQLChartWidget = { + id: 'id', + label: 'myPieChart', + iconURL: null, + chart: defaultPieChart, + __typename: 'ChartWidget', + diagnostics: [], +}; +const defaultPieChartWidgetWithStyle: GQLChartWidget = { + id: 'id', + label: 'myPieChart', + iconURL: null, + chart: defaultPieChartWithStyle, + __typename: 'ChartWidget', + diagnostics: [], +}; +const defaultPieChartWidgetWithEmptyStyle: GQLChartWidget = { + id: 'id', + label: 'myPieChart', + iconURL: null, + chart: defaultPieChartWithEmptyStyle, + __typename: 'ChartWidget', + diagnostics: [], +}; + +const defaultBarChartWidget: GQLChartWidget = { + id: 'id', + label: 'myBarChart', + iconURL: null, + chart: defaultBarChart, + __typename: 'ChartWidget', + diagnostics: [], +}; + +const defaultBarChartWidgetWithStyle: GQLChartWidget = { + id: 'id', + label: 'myBarChart', + iconURL: null, + chart: defaultBarChartWithStyle, + __typename: 'ChartWidget', + diagnostics: [], +}; + +const defaultBarChartWidgetWithEmptyStyle: GQLChartWidget = { + id: 'id', + label: 'myBarChart', + iconURL: null, + chart: defaultBarChartWithEmptyStyle, + __typename: 'ChartWidget', + diagnostics: [], +}; + +test('render pie-chart widget', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render pie-chart widget with style', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render pie-chart widget with empty style', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render the bar-chart widget', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render the bar-chart widget with style', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); + +test('render the bar-chart widget with empty style', () => { + const { container } = render( + + + + ); + expect(container).toMatchSnapshot(); +}); diff --git a/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/ChartWidgetPropertySection.test.tsx.snap b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/ChartWidgetPropertySection.test.tsx.snap new file mode 100644 index 0000000000..9d778b9b37 --- /dev/null +++ b/packages/forms/frontend/sirius-components-forms/src/propertysections/__tests__/__snapshots__/ChartWidgetPropertySection.test.tsx.snap @@ -0,0 +1,1285 @@ +// Vitest Snapshot v1 + +exports[`render pie-chart widget 1`] = ` +
+
+
+
+ myPieChart +
+
+
+ + + + + a +10 + + + + + b +15 + + + + + c +5 + + + + + d +20 + + + + + + + a + + + 10 + + + + + b + + + 15 + + + + + c + + + 5 + + + + + d + + + 20 + + + + +
+
+`; + +exports[`render pie-chart widget with empty style 1`] = ` +
+
+
+
+ myPieChart +
+
+
+ + + + + a +10 + + + + + b +15 + + + + + c +5 + + + + + d +20 + + + + + + + a + + + 10 + + + + + b + + + 15 + + + + + c + + + 5 + + + + + d + + + 20 + + + + +
+
+`; + +exports[`render pie-chart widget with style 1`] = ` +
+
+
+
+ myPieChart +
+
+
+ + + + + a +10 + + + + + b +15 + + + + + c +5 + + + + + d +20 + + + + + + + a + + + 10 + + + + + b + + + 15 + + + + + c + + + 5 + + + + + d + + + 20 + + + + +
+
+`; + +exports[`render the bar-chart widget 1`] = ` +
+
+
+
+ myBarChart +
+
+
+ + + + + + + 0 + + + + + + + 5 + + + + + + + 10 + + + + + + + 15 + + + + + + + 20 + + + + values + + + + + + a +10.0 + + + + + b +15.0 + + + + + c +5.0 + + + + + d +20.0 + + + + + + + + + a + + + + + + b + + + + + + c + + + + + + d + + + + +
+
+`; + +exports[`render the bar-chart widget with empty style 1`] = ` +
+
+
+
+ myBarChart +
+
+
+ + + + + + + 0 + + + + + + + 5 + + + + + + + 10 + + + + + + + 15 + + + + + + + 20 + + + + values + + + + + + a +10.0 + + + + + b +15.0 + + + + + c +5.0 + + + + + d +20.0 + + + + + + + + + a + + + + + + b + + + + + + c + + + + + + d + + + + +
+
+`; + +exports[`render the bar-chart widget with style 1`] = ` +
+
+
+
+ myBarChart +
+
+
+ + + + + + + 0 + + + + + + + 5 + + + + + + + 10 + + + + + + + 15 + + + + + + + 20 + + + + values + + + + + + a +10.0 + + + + + b +15.0 + + + + + c +5.0 + + + + + d +20.0 + + + + + + + + + a + + + + + + b + + + + + + c + + + + + + d + + + + +
+
+`; diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionItemProvider.java index 17ba861eee..57a322b7fe 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionItemProvider.java @@ -17,11 +17,13 @@ import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ViewerNotification; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.ViewFactory; import org.eclipse.sirius.components.view.ViewPackage; /** @@ -94,6 +96,37 @@ protected void addYAxisLabelExpressionPropertyDescriptor(Object object) { ViewPackage.Literals.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (this.childrenFeatures == null) { + super.getChildrenFeatures(object); + this.childrenFeatures.add(ViewPackage.Literals.BAR_CHART_DESCRIPTION__STYLE); + this.childrenFeatures.add(ViewPackage.Literals.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + /** * This returns BarChartDescription.gif. * @@ -143,6 +176,10 @@ public void notifyChanged(Notification notification) { case ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; } super.notifyChanged(notification); } @@ -151,11 +188,33 @@ public void notifyChanged(Notification notification) { * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created * under this object. * - * @generated + * @generated NOT */ @Override protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { super.collectNewChildDescriptors(newChildDescriptors, object); + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.BAR_CHART_DESCRIPTION__STYLE, ViewFactory.eINSTANCE.createBarChartDescriptionStyle())); + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES, ViewFactory.eINSTANCE.createConditionalBarChartDescriptionStyle())); + } + + /** + * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. + * + * + * @generated + */ + @Override + public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) { + Object childFeature = feature; + Object childObject = child; + + boolean qualify = childFeature == ViewPackage.Literals.BAR_CHART_DESCRIPTION__STYLE || childFeature == ViewPackage.Literals.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES; + + if (qualify) { + return this.getString("_UI_CreateChild_text2", //$NON-NLS-1$ + new Object[] { this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner) }); + } + return super.getCreateChildText(owner, feature, child, selection); } } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..28518dc11a --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/BarChartDescriptionStyleItemProvider.java @@ -0,0 +1,201 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.BarChartDescriptionStyle} object. + * + * + * @generated + */ +public class BarChartDescriptionStyleItemProvider extends WidgetDescriptionStyleItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public BarChartDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addBarsColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bars Color feature. + * + * @generated + */ + protected void addBarsColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_BarChartDescriptionStyle_barsColor_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_BarChartDescriptionStyle_barsColor_feature", "_UI_BarChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns Style.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/Style.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + BarChartDescriptionStyle barChartDescriptionStyle = (BarChartDescriptionStyle) object; + return this.getString("_UI_BarChartDescriptionStyle_type") + " " + barChartDescriptionStyle.getFontSize(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(BarChartDescriptionStyle.class)) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalBarChartDescriptionStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalBarChartDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..d7d4c5abe7 --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalBarChartDescriptionStyleItemProvider.java @@ -0,0 +1,203 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a + * {@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle} object. + * + * @generated + */ +public class ConditionalBarChartDescriptionStyleItemProvider extends ConditionalItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public ConditionalBarChartDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addBarsColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bars Color feature. + * + * @generated + */ + protected void addBarsColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_BarChartDescriptionStyle_barsColor_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_BarChartDescriptionStyle_barsColor_feature", "_UI_BarChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns ConditionalStyle.svg. + * + * @generated NOt + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((ConditionalBarChartDescriptionStyle) object).getCondition(); + return label == null || label.length() == 0 ? this.getString("_UI_ConditionalBarChartDescriptionStyle_type") : //$NON-NLS-1$ + this.getString("_UI_ConditionalBarChartDescriptionStyle_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(ConditionalBarChartDescriptionStyle.class)) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalPieChartDescriptionStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalPieChartDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..471ea36ded --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ConditionalPieChartDescriptionStyleItemProvider.java @@ -0,0 +1,231 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a + * {@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle} object. + * + * @generated + */ +public class ConditionalPieChartDescriptionStyleItemProvider extends ConditionalItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public ConditionalPieChartDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addColorsPropertyDescriptor(object); + this.addStrokeWidthPropertyDescriptor(object); + this.addStrokeColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Colors feature. + * + * @generated + */ + protected void addColorsPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_colors_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_colors_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__COLORS, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Stroke Width feature. + * + * @generated + */ + protected void addStrokeWidthPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_strokeWidth_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_strokeWidth_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Stroke Color feature. + * + * @generated + */ + protected void addStrokeColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_strokeColor_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_strokeColor_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns ConditionalStyle.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((ConditionalPieChartDescriptionStyle) object).getCondition(); + return label == null || label.length() == 0 ? this.getString("_UI_ConditionalPieChartDescriptionStyle_type") : //$NON-NLS-1$ + this.getString("_UI_ConditionalPieChartDescriptionStyle_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(ConditionalPieChartDescriptionStyle.class)) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java index 29f65ec776..b4745eb7e8 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FlexboxContainerDescriptionItemProvider.java @@ -205,9 +205,11 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, buttonDescription)); BarChartDescription barChartDescription = ViewFactory.eINSTANCE.createBarChartDescription(); + barChartDescription.setStyle(ViewFactory.eINSTANCE.createBarChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, barChartDescription)); PieChartDescription pieChartDescription = ViewFactory.eINSTANCE.createPieChartDescription(); + pieChartDescription.setStyle(ViewFactory.eINSTANCE.createPieChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN, pieChartDescription)); FlexboxContainerDescription flexboxContainerDescription = ViewFactory.eINSTANCE.createFlexboxContainerDescription(); diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java index 09d855b112..9daa6a3b2e 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/FormDescriptionItemProvider.java @@ -184,9 +184,11 @@ protected void collectNewChildDescriptors(Collection newChildDescriptors newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, buttonDescription)); BarChartDescription barChartDescription = ViewFactory.eINSTANCE.createBarChartDescription(); + barChartDescription.setStyle(ViewFactory.eINSTANCE.createBarChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, barChartDescription)); PieChartDescription pieChartDescription = ViewFactory.eINSTANCE.createPieChartDescription(); + pieChartDescription.setStyle(ViewFactory.eINSTANCE.createPieChartDescriptionStyle()); newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.FORM_DESCRIPTION__WIDGETS, pieChartDescription)); FlexboxContainerDescription flexboxContainerDescription = ViewFactory.eINSTANCE.createFlexboxContainerDescription(); diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionItemProvider.java index 1867f29eba..268b517bc3 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionItemProvider.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionItemProvider.java @@ -17,11 +17,13 @@ import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; import org.eclipse.emf.edit.provider.ViewerNotification; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.ViewFactory; import org.eclipse.sirius.components.view.ViewPackage; /** @@ -80,6 +82,37 @@ protected void addKeysExpressionPropertyDescriptor(Object object) { ViewPackage.Literals.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); } + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (this.childrenFeatures == null) { + super.getChildrenFeatures(object); + this.childrenFeatures.add(ViewPackage.Literals.PIE_CHART_DESCRIPTION__STYLE); + this.childrenFeatures.add(ViewPackage.Literals.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + /** * This returns PieChartDescription.gif. * @@ -128,6 +161,10 @@ public void notifyChanged(Notification notification) { case ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION: this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; } super.notifyChanged(notification); } @@ -141,6 +178,32 @@ public void notifyChanged(Notification notification) { @Override protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.PIE_CHART_DESCRIPTION__STYLE, ViewFactory.eINSTANCE.createPieChartDescriptionStyle())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.PIE_CHART_DESCRIPTION__STYLE, ViewFactory.eINSTANCE.createConditionalPieChartDescriptionStyle())); + + newChildDescriptors.add(this.createChildParameter(ViewPackage.Literals.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES, ViewFactory.eINSTANCE.createConditionalPieChartDescriptionStyle())); + } + + /** + * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. + * + * + * @generated + */ + @Override + public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) { + Object childFeature = feature; + Object childObject = child; + + boolean qualify = childFeature == ViewPackage.Literals.PIE_CHART_DESCRIPTION__STYLE || childFeature == ViewPackage.Literals.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES; + + if (qualify) { + return this.getString("_UI_CreateChild_text2", //$NON-NLS-1$ + new Object[] { this.getTypeText(childObject), this.getFeatureText(childFeature), this.getTypeText(owner) }); + } + return super.getCreateChildText(owner, feature, child, selection); } } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionStyleItemProvider.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionStyleItemProvider.java new file mode 100644 index 0000000000..d4c9770320 --- /dev/null +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/PieChartDescriptionStyleItemProvider.java @@ -0,0 +1,229 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle} object. + * + * + * @generated + */ +public class PieChartDescriptionStyleItemProvider extends WidgetDescriptionStyleItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public PieChartDescriptionStyleItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (this.itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + this.addFontSizePropertyDescriptor(object); + this.addItalicPropertyDescriptor(object); + this.addBoldPropertyDescriptor(object); + this.addUnderlinePropertyDescriptor(object); + this.addStrikeThroughPropertyDescriptor(object); + this.addColorsPropertyDescriptor(object); + this.addStrokeWidthPropertyDescriptor(object); + this.addStrokeColorPropertyDescriptor(object); + } + return this.itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Font Size feature. + * + * @generated + */ + protected void addFontSizePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_fontSize_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Italic feature. + * + * @generated + */ + protected void addItalicPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Bold feature. + * + * @generated + */ + protected void addBoldPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add( + this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Underline feature. + * + * @generated + */ + protected void addUnderlinePropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_underline_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Strike Through feature. + * + * @generated + */ + protected void addStrikeThroughPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_LabelStyle_strikeThrough_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", "_UI_LabelStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Colors feature. + * + * @generated + */ + protected void addColorsPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_colors_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_colors_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__COLORS, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Stroke Width feature. + * + * @generated + */ + protected void addStrokeWidthPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_strokeWidth_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_strokeWidth_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Stroke Color feature. + * + * @generated + */ + protected void addStrokeColorPropertyDescriptor(Object object) { + this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), + this.getString("_UI_PieChartDescriptionStyle_strokeColor_feature"), //$NON-NLS-1$ + this.getString("_UI_PropertyDescriptor_description", "_UI_PieChartDescriptionStyle_strokeColor_feature", "_UI_PieChartDescriptionStyle_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR, true, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns Style.svg. + * + * @generated NOT + */ + @Override + public Object getImage(Object object) { + return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/Style.svg")); //$NON-NLS-1$ + } + + /** + * + * + * @generated + */ + @Override + protected boolean shouldComposeCreationImage() { + return true; + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) { + PieChartDescriptionStyle pieChartDescriptionStyle = (PieChartDescriptionStyle) object; + return this.getString("_UI_PieChartDescriptionStyle_type") + " " + pieChartDescriptionStyle.getFontSize(); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating + * a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + this.updateChildren(notification); + + switch (notification.getFeatureID(PieChartDescriptionStyle.class)) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created + * under this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + +} diff --git a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java index 04c3148821..e2207e6e03 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java +++ b/packages/view/backend/sirius-components-view-edit/src/main/java/org/eclipse/sirius/components/view/provider/ViewItemProviderAdapterFactory.java @@ -1034,6 +1034,102 @@ public Adapter createConditionalButtonDescriptionStyleAdapter() { return this.conditionalButtonDescriptionStyleItemProvider; } + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.BarChartDescriptionStyle} instances. + * + * @generated + */ + protected BarChartDescriptionStyleItemProvider barChartDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.BarChartDescriptionStyle}. + * + * @generated + */ + @Override + public Adapter createBarChartDescriptionStyleAdapter() { + if (this.barChartDescriptionStyleItemProvider == null) { + this.barChartDescriptionStyleItemProvider = new BarChartDescriptionStyleItemProvider(this); + } + + return this.barChartDescriptionStyleItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle} instances. + * + * + * @generated + */ + protected ConditionalBarChartDescriptionStyleItemProvider conditionalBarChartDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle}. + * + * + * @generated + */ + @Override + public Adapter createConditionalBarChartDescriptionStyleAdapter() { + if (this.conditionalBarChartDescriptionStyleItemProvider == null) { + this.conditionalBarChartDescriptionStyleItemProvider = new ConditionalBarChartDescriptionStyleItemProvider(this); + } + + return this.conditionalBarChartDescriptionStyleItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle} instances. + * + * @generated + */ + protected PieChartDescriptionStyleItemProvider pieChartDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle}. + * + * @generated + */ + @Override + public Adapter createPieChartDescriptionStyleAdapter() { + if (this.pieChartDescriptionStyleItemProvider == null) { + this.pieChartDescriptionStyleItemProvider = new PieChartDescriptionStyleItemProvider(this); + } + + return this.pieChartDescriptionStyleItemProvider; + } + + /** + * This keeps track of the one adapter used for all + * {@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle} instances. + * + * + * @generated + */ + protected ConditionalPieChartDescriptionStyleItemProvider conditionalPieChartDescriptionStyleItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle}. + * + * + * @generated + */ + @Override + public Adapter createConditionalPieChartDescriptionStyleAdapter() { + if (this.conditionalPieChartDescriptionStyleItemProvider == null) { + this.conditionalPieChartDescriptionStyleItemProvider = new ConditionalPieChartDescriptionStyleItemProvider(this); + } + + return this.conditionalPieChartDescriptionStyleItemProvider; + } + /** * This keeps track of the one adapter used for all {@link org.eclipse.sirius.components.view.BarChartDescription} * instances. @@ -1317,6 +1413,14 @@ public void dispose() { this.buttonDescriptionStyleItemProvider.dispose(); if (this.conditionalButtonDescriptionStyleItemProvider != null) this.conditionalButtonDescriptionStyleItemProvider.dispose(); + if (this.barChartDescriptionStyleItemProvider != null) + this.barChartDescriptionStyleItemProvider.dispose(); + if (this.conditionalBarChartDescriptionStyleItemProvider != null) + this.conditionalBarChartDescriptionStyleItemProvider.dispose(); + if (this.pieChartDescriptionStyleItemProvider != null) + this.pieChartDescriptionStyleItemProvider.dispose(); + if (this.conditionalPieChartDescriptionStyleItemProvider != null) + this.conditionalPieChartDescriptionStyleItemProvider.dispose(); } } diff --git a/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties b/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties index 1fbc78d765..2535afe72e 100644 --- a/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties +++ b/packages/view/backend/sirius-components-view-edit/src/main/resources/plugin.properties @@ -76,6 +76,10 @@ _UI_RadioDescriptionStyle_type = Radio Description Style _UI_ConditionalRadioDescriptionStyle_type = Conditional Radio Description Style _UI_ButtonDescriptionStyle_type = Button Description Style _UI_ConditionalButtonDescriptionStyle_type = Conditional Button Description Style +_UI_BarChartDescriptionStyle_type = Bar Chart Description Style +_UI_ConditionalBarChartDescriptionStyle_type = Conditional Bar Chart Description Style +_UI_PieChartDescriptionStyle_type = Pie Chart Description Style +_UI_ConditionalPieChartDescriptionStyle_type = Conditional Pie Chart Description Style _UI_Unknown_type = Object _UI_Unknown_datatype= Value @@ -182,8 +186,12 @@ _UI_RadioDescription_conditionalStyles_feature = Conditional Styles _UI_BarChartDescription_valuesExpression_feature = Values Expression _UI_BarChartDescription_keysExpression_feature = Keys Expression _UI_BarChartDescription_yAxisLabelExpression_feature = Y Axis Label Expression +_UI_BarChartDescription_style_feature = Style +_UI_BarChartDescription_conditionalStyles_feature = Conditional Styles _UI_PieChartDescription_valuesExpression_feature = Values Expression _UI_PieChartDescription_keysExpression_feature = Keys Expression +_UI_PieChartDescription_style_feature = Style +_UI_PieChartDescription_conditionalStyles_feature = Conditional Styles _UI_FlexboxContainerDescription_children_feature = Children _UI_FlexboxContainerDescription_flexDirection_feature = Flex Direction _UI_ButtonDescription_buttonLabelExpression_feature = Button Label Expression @@ -203,6 +211,10 @@ _UI_TextareaDescriptionStyle_foregroundColor_feature = Foreground Color _UI_RadioDescriptionStyle_color_feature = Color _UI_ButtonDescriptionStyle_backgroundColor_feature = Background Color _UI_ButtonDescriptionStyle_foregroundColor_feature = Foreground Color +_UI_BarChartDescriptionStyle_barsColor_feature = Bars Color +_UI_PieChartDescriptionStyle_colors_feature = Colors +_UI_PieChartDescriptionStyle_strokeWidth_feature = Stroke Width +_UI_PieChartDescriptionStyle_strokeColor_feature = Stroke Color _UI_Unknown_feature = Unspecified _UI_ArrowStyle_None_literal = None diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/BarChartStyleProvider.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/BarChartStyleProvider.java new file mode 100644 index 0000000000..612da80426 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/BarChartStyleProvider.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.view.emf.form; + +import java.util.Objects; +import java.util.function.Function; + +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle.Builder; +import org.eclipse.sirius.components.interpreter.AQLInterpreter; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; + +/** + * The style provider for the BarChart Description widget of the View DSL. + * + * @author fbarbin + */ +public class BarChartStyleProvider implements Function { + + private final BarChartDescription viewBarChartDescription; + + private final AQLInterpreter interpreter; + + public BarChartStyleProvider(AQLInterpreter interpreter, BarChartDescription viewBarChartDescription) { + this.viewBarChartDescription = Objects.requireNonNull(viewBarChartDescription); + this.interpreter = Objects.requireNonNull(interpreter); + } + + @Override + public BarChartStyle apply(VariableManager variableManager) { + var effectiveStyle = this.computeEffectiveStyle(variableManager); + if (effectiveStyle != null) { + Builder barChartStyleBuilder = BarChartStyle.newBarChartStyle(); + String barsColor = effectiveStyle.getBarsColor(); + if (barsColor != null && !barsColor.isBlank()) { + barChartStyleBuilder.barsColor(barsColor); + } + this.handleLabelStyle(barChartStyleBuilder, effectiveStyle); + return barChartStyleBuilder.build(); + } + return null; + } + + private void handleLabelStyle(Builder barChartStyleBuilder, BarChartDescriptionStyle effectiveStyle) { + // @formatter:off + barChartStyleBuilder.fontSize(effectiveStyle.getFontSize()) + .bold(effectiveStyle.isBold()) + .italic(effectiveStyle.isItalic()) + .strikeThrough(effectiveStyle.isStrikeThrough()) + .underline(effectiveStyle.isUnderline()); + // @formatter:on + } + + private BarChartDescriptionStyle computeEffectiveStyle(VariableManager variableManager) { + // @formatter:off + return this.viewBarChartDescription.getConditionalStyles().stream() + .filter(style -> this.matches(style.getCondition(), variableManager)) + .map(BarChartDescriptionStyle.class::cast) + .findFirst() + .orElseGet(this.viewBarChartDescription::getStyle); + // @formatter:on + } + + private boolean matches(String condition, VariableManager variableManager) { + return this.interpreter.evaluateExpression(variableManager.getVariables(), condition).asBoolean().orElse(Boolean.FALSE); + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/PieChartStyleProvider.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/PieChartStyleProvider.java new file mode 100644 index 0000000000..3d10ba92bb --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/PieChartStyleProvider.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.components.view.emf.form; + +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle.Builder; +import org.eclipse.sirius.components.interpreter.AQLInterpreter; +import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; + +/** + * The style provider for the PieChart Description widget of the View DSL. + * + * @author fbarbin + */ +public class PieChartStyleProvider implements Function { + + private final PieChartDescription viewPieChartDescription; + + private final AQLInterpreter interpreter; + + public PieChartStyleProvider(AQLInterpreter interpreter, PieChartDescription viewPieChartDescription) { + this.viewPieChartDescription = Objects.requireNonNull(viewPieChartDescription); + this.interpreter = Objects.requireNonNull(interpreter); + } + + @Override + public PieChartStyle apply(VariableManager variableManager) { + var effectiveStyle = this.computeEffectiveStyle(variableManager); + if (effectiveStyle != null) { + Builder pieChartStyleBuilder = PieChartStyle.newPieChartStyle(); + String colors = effectiveStyle.getColors(); + String strokeColor = effectiveStyle.getStrokeColor(); + String strokeWidth = effectiveStyle.getStrokeWidth(); + this.handleColors(variableManager, pieChartStyleBuilder, colors); + this.handleStrokeColor(pieChartStyleBuilder, strokeColor); + this.handleStrokeWidth(pieChartStyleBuilder, strokeWidth); + this.handleLabelStyle(pieChartStyleBuilder, effectiveStyle); + return pieChartStyleBuilder.build(); + } + return null; + } + + private void handleLabelStyle(Builder pieChartStyleBuilder, PieChartDescriptionStyle effectiveStyle) { + // @formatter:off + pieChartStyleBuilder.fontSize(effectiveStyle.getFontSize()) + .bold(effectiveStyle.isBold()) + .italic(effectiveStyle.isItalic()) + .strikeThrough(effectiveStyle.isStrikeThrough()) + .underline(effectiveStyle.isUnderline()); + // @formatter:on + } + + private void handleStrokeWidth(Builder pieChartStyleBuilder, String strokeWidth) { + if (strokeWidth != null && !strokeWidth.isBlank()) { + try { + int width = Integer.parseInt(strokeWidth); + pieChartStyleBuilder.strokeWidth(width); + } catch (NullPointerException | NumberFormatException e) { + // unexpected value. + } + } + } + + private void handleStrokeColor(Builder pieChartStyleBuilder, String strokeColor) { + if (strokeColor != null && !strokeColor.isBlank()) { + pieChartStyleBuilder.strokeColor(strokeColor); + } + } + + private void handleColors(VariableManager variableManager, Builder pieChartStyleBuilder, String colors) { + if (colors != null && !colors.isBlank()) { + // @formatter:off + List colorsObjects = this.interpreter.evaluateExpression(variableManager.getVariables(), colors).asObjects() + .orElse(List.of()); + List colorsValues = colorsObjects.stream() + .filter(String.class::isInstance) + .map(String.class::cast) + .collect(Collectors.toList()); + // @formatter:on + pieChartStyleBuilder.colors(colorsValues); + } + } + + private PieChartDescriptionStyle computeEffectiveStyle(VariableManager variableManager) { + // @formatter:off + return this.viewPieChartDescription.getConditionalStyles().stream() + .filter(style -> this.matches(style.getCondition(), variableManager)) + .map(PieChartDescriptionStyle.class::cast) + .findFirst() + .orElseGet(this.viewPieChartDescription::getStyle); + // @formatter:on + } + + private boolean matches(String condition, VariableManager variableManager) { + return this.interpreter.evaluateExpression(variableManager.getVariables(), condition).asBoolean().orElse(Boolean.FALSE); + } +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java index 4d4a373c95..6f5a6f8c3b 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/form/ViewFormDescriptionConverterSwitch.java @@ -23,9 +23,11 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.sirius.components.charts.barchart.BarChartDescription; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; +import org.eclipse.sirius.components.charts.barchart.descriptions.BarChartDescription; import org.eclipse.sirius.components.charts.descriptions.IChartDescription; import org.eclipse.sirius.components.charts.piechart.PieChartDescription; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; import org.eclipse.sirius.components.compatibility.forms.WidgetIdProvider; import org.eclipse.sirius.components.compatibility.utils.BooleanValueProvider; import org.eclipse.sirius.components.compatibility.utils.StringValueProvider; @@ -334,12 +336,16 @@ public AbstractWidgetDescription caseBarChartDescription(org.eclipse.sirius.comp String labelExpression = viewBarChartDescription.getYAxisLabelExpression(); String keysExpression = viewBarChartDescription.getKeysExpression(); String valuesExpression = viewBarChartDescription.getValuesExpression(); + + Function styleProvider = new BarChartStyleProvider(this.interpreter, viewBarChartDescription); + // @formatter:off IChartDescription chartDescription = BarChartDescription.newBarChartDescription(this.getDescriptionId(viewBarChartDescription)) .label(viewBarChartDescription.getName()) .labelProvider(this.getStringValueProvider(labelExpression)) .keysProvider(this.getMultiValueProvider(keysExpression, String.class)) .valuesProvider(this.getMultiValueProvider(valuesExpression, Number.class)) + .styleProvider(styleProvider) .build(); // @formatter:on return this.createChartWidgetDescription(viewBarChartDescription, chartDescription); @@ -349,11 +355,13 @@ public AbstractWidgetDescription caseBarChartDescription(org.eclipse.sirius.comp public AbstractWidgetDescription casePieChartDescription(org.eclipse.sirius.components.view.PieChartDescription viewPieChartDescription) { String keysExpression = viewPieChartDescription.getKeysExpression(); String valuesExpression = viewPieChartDescription.getValuesExpression(); + Function styleProvider = new PieChartStyleProvider(this.interpreter, viewPieChartDescription); // @formatter:off IChartDescription chartDescription = PieChartDescription.newPieChartDescription(this.getDescriptionId(viewPieChartDescription)) .label(viewPieChartDescription.getName()) .keysProvider(this.getMultiValueProvider(keysExpression, String.class)) .valuesProvider(this.getMultiValueProvider(valuesExpression, Number.class)) + .styleProvider(styleProvider) .build(); // @formatter:on return this.createChartWidgetDescription(viewPieChartDescription, chartDescription); diff --git a/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java b/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java index c9038bd99e..a458b6eac2 100644 --- a/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java +++ b/packages/view/backend/sirius-components-view-emf/src/test/java/org/eclipse/sirius/components/view/emf/view/DynamicFormsTests.java @@ -25,8 +25,10 @@ import org.eclipse.sirius.components.charts.IChart; import org.eclipse.sirius.components.charts.barchart.BarChart; import org.eclipse.sirius.components.charts.barchart.BarChartEntry; +import org.eclipse.sirius.components.charts.barchart.components.BarChartStyle; import org.eclipse.sirius.components.charts.piechart.PieChart; import org.eclipse.sirius.components.charts.piechart.PieChartEntry; +import org.eclipse.sirius.components.charts.piechart.components.PieChartStyle; import org.eclipse.sirius.components.core.api.IEditService; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; @@ -58,13 +60,16 @@ import org.eclipse.sirius.components.representations.IRepresentationDescription; import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; import org.eclipse.sirius.components.view.ButtonDescription; import org.eclipse.sirius.components.view.ButtonDescriptionStyle; import org.eclipse.sirius.components.view.CheckboxDescription; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalTextareaDescriptionStyle; @@ -75,6 +80,7 @@ import org.eclipse.sirius.components.view.MultiSelectDescription; import org.eclipse.sirius.components.view.MultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.SelectDescription; @@ -164,8 +170,8 @@ void testRenderEcoreForm() throws Exception { assertThat(radio.getLabel()).isEqualTo("ESuperTypes"); //$NON-NLS-1$ this.testNoStyle(radio); - this.checkBarChart(chartWidgetWithBarChart); - this.checkPieChart(chartWidgetWithPieChart); + this.checkBarChart(chartWidgetWithBarChart, false, false); + this.checkPieChart(chartWidgetWithPieChart, false, false); this.renderEcoreFormOnWidgetContainer(flexboxContainer); this.renderEcoreFormOnButton(button); @@ -177,7 +183,41 @@ private void renderEcoreFormOnButton(Button button) { this.testNoStyle(button); } - private void checkBarChart(ChartWidget chartWidgetWithBarChart) { + private void checkPieChart(ChartWidget chartWidgetWithPieChart, boolean checkStyle, boolean checkConditionalStyle) { + assertThat(chartWidgetWithPieChart.getLabel()).isEqualTo("The Chart Widget label"); //$NON-NLS-1$ + IChart chart = chartWidgetWithPieChart.getChart(); + assertThat(chart).isInstanceOf(PieChart.class); + PieChart pieChart = (PieChart) chart; + List pieChartEntries = pieChart.getEntries(); + this.checkPieChartEntry(pieChartEntries, 0, "a", 1); //$NON-NLS-1$ + this.checkPieChartEntry(pieChartEntries, 1, "b", 3); //$NON-NLS-1$ + this.checkPieChartEntry(pieChartEntries, 2, "c", 5); //$NON-NLS-1$ + this.checkPieChartEntry(pieChartEntries, 3, "d", 7); //$NON-NLS-1$ + PieChartStyle style = pieChart.getStyle(); + if (checkStyle) { + assertThat(style).isNotNull(); + assertThat(style.getColors()).isEqualTo(List.of("AliceBlue", "AntiqueWhite", "DarkMagenta", "DarkGreen")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + assertThat(style.getStrokeColor()).isEqualTo("Orchid"); //$NON-NLS-1$ + assertThat(style.getStrokeWidth()).isEqualTo(3); + assertThat(style.getFontSize()).isEqualTo(20); + assertThat(style.isItalic()).isTrue(); + assertThat(style.isBold()).isTrue(); + assertThat(style.isUnderline()).isTrue(); + assertThat(style.isStrikeThrough()).isTrue(); + } else if (checkConditionalStyle) { + assertThat(style).isNotNull(); + assertThat(style.getColors()).isEqualTo(List.of("CadetBlue", "AntiqueWhite", "DarkMagenta", "Coral")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + assertThat(style.getStrokeColor()).isEqualTo("PaleGoldenRod"); //$NON-NLS-1$ + assertThat(style.getStrokeWidth()).isEqualTo(2); + assertThat(style.getFontSize()).isEqualTo(30); + assertThat(style.isItalic()).isTrue(); + assertThat(style.isBold()).isFalse(); + assertThat(style.isUnderline()).isTrue(); + assertThat(style.isStrikeThrough()).isFalse(); + } + } + + private void checkBarChart(ChartWidget chartWidgetWithBarChart, boolean checkStyle, boolean checkConditionalStyle) { assertThat(chartWidgetWithBarChart.getLabel()).isEqualTo("The Chart Widget label"); //$NON-NLS-1$ IChart chart = chartWidgetWithBarChart.getChart(); assertThat(chart).isInstanceOf(BarChart.class); @@ -188,18 +228,24 @@ private void checkBarChart(ChartWidget chartWidgetWithBarChart) { this.checkBarChartEntry(barChartEntries, 1, "b", 3); //$NON-NLS-1$ this.checkBarChartEntry(barChartEntries, 2, "c", 5); //$NON-NLS-1$ this.checkBarChartEntry(barChartEntries, 3, "d", 7); //$NON-NLS-1$ - } - - private void checkPieChart(ChartWidget chartWidgetWithPieChart) { - assertThat(chartWidgetWithPieChart.getLabel()).isEqualTo("The Chart Widget label"); //$NON-NLS-1$ - IChart chart = chartWidgetWithPieChart.getChart(); - assertThat(chart).isInstanceOf(PieChart.class); - PieChart pieChart = (PieChart) chart; - List pieChartEntries = pieChart.getEntries(); - this.checkPieChartEntry(pieChartEntries, 0, "a", 1); //$NON-NLS-1$ - this.checkPieChartEntry(pieChartEntries, 1, "b", 3); //$NON-NLS-1$ - this.checkPieChartEntry(pieChartEntries, 2, "c", 5); //$NON-NLS-1$ - this.checkPieChartEntry(pieChartEntries, 3, "d", 7); //$NON-NLS-1$ + BarChartStyle style = barChart.getStyle(); + if (checkStyle) { + assertThat(style).isNotNull(); + assertThat(style.getBarsColor()).isEqualTo("Orchid"); //$NON-NLS-1$ + assertThat(style.getFontSize()).isEqualTo(20); + assertThat(style.isItalic()).isTrue(); + assertThat(style.isBold()).isTrue(); + assertThat(style.isUnderline()).isTrue(); + assertThat(style.isStrikeThrough()).isTrue(); + } else if (checkConditionalStyle) { + assertThat(style).isNotNull(); + assertThat(style.getBarsColor()).isEqualTo("PaleGoldenRod"); //$NON-NLS-1$ + assertThat(style.getFontSize()).isEqualTo(30); + assertThat(style.isItalic()).isTrue(); + assertThat(style.isBold()).isFalse(); + assertThat(style.isUnderline()).isTrue(); + assertThat(style.isStrikeThrough()).isFalse(); + } } private void checkBarChartEntry(List entries, int index, String expectedKey, Number expectedValue) { @@ -249,6 +295,8 @@ void testRenderEcoreFormWithStyle() throws Exception { Checkbox checkBox = (Checkbox) group.getWidgets().get(3); Select select = (Select) group.getWidgets().get(4); Radio radio = (Radio) group.getWidgets().get(5); + ChartWidget chartWidgetWithBarChart = (ChartWidget) group.getWidgets().get(6); + ChartWidget chartWidgetWithPieChart = (ChartWidget) group.getWidgets().get(7); FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); Button button = (Button) group.getWidgets().get(9); @@ -291,6 +339,9 @@ void testRenderEcoreFormWithStyle() throws Exception { assertThat(button.getButtonLabel()).isEqualTo("Class1"); //$NON-NLS-1$ assertThat(button.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ this.testStyle(button); + this.checkBarChart(chartWidgetWithBarChart, true, false); + + this.checkPieChart(chartWidgetWithPieChart, true, false); } private void renderEcoreFormWithStyleOnWidgetContainer(FlexboxContainer flexboxContainer) { @@ -330,6 +381,8 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { Checkbox checkBox = (Checkbox) group.getWidgets().get(3); Select select = (Select) group.getWidgets().get(4); Radio radio = (Radio) group.getWidgets().get(5); + ChartWidget chartWidgetWithBarChart = (ChartWidget) group.getWidgets().get(6); + ChartWidget chartWidgetWithPieChart = (ChartWidget) group.getWidgets().get(7); FlexboxContainer flexboxContainer = (FlexboxContainer) group.getWidgets().get(8); Button button = (Button) group.getWidgets().get(9); @@ -373,6 +426,9 @@ void testRenderEcoreFormWithConditionalStyle() throws Exception { assertThat(button.getLabel()).isEqualTo("EClass name"); //$NON-NLS-1$ this.testConditionalStyle(button); + this.checkBarChart(chartWidgetWithBarChart, false, true); + + this.checkPieChart(chartWidgetWithPieChart, false, true); } private void renderEcoreFormWithConditionalStyleOnWidgetContainer(FlexboxContainer flexboxContainer) { @@ -502,9 +558,9 @@ private FormDescription createClassFormDescription(boolean withStyle, boolean wi formDescription.getWidgets().add(selectDescription); RadioDescription radioDescription = this.createRadio(withStyle, withConditionalStyle); formDescription.getWidgets().add(radioDescription); - BarChartDescription barChartDescription = this.createBarChart(); + BarChartDescription barChartDescription = this.createBarChart(withStyle, withConditionalStyle); formDescription.getWidgets().add(barChartDescription); - PieChartDescription pieChartDescription = this.createPieChart(); + PieChartDescription pieChartDescription = this.createPieChart(withStyle, withConditionalStyle); formDescription.getWidgets().add(pieChartDescription); FlexboxContainerDescription flexboxContainerDescription = this.createFlexboxContainer(withStyle, withConditionalStyle); formDescription.getWidgets().add(flexboxContainerDescription); @@ -513,23 +569,55 @@ private FormDescription createClassFormDescription(boolean withStyle, boolean wi return formDescription; } - private BarChartDescription createBarChart() { + private BarChartDescription createBarChart(boolean withStyle, boolean withConditionalStyle) { BarChartDescription barChartDescription = ViewFactory.eINSTANCE.createBarChartDescription(); barChartDescription.setName("barChart"); //$NON-NLS-1$ barChartDescription.setLabelExpression("aql:'The Chart Widget label'"); //$NON-NLS-1$ barChartDescription.setYAxisLabelExpression("aql:'the values'"); //$NON-NLS-1$ barChartDescription.setKeysExpression("aql:Sequence{'a','b','c','d'}"); //$NON-NLS-1$ barChartDescription.setValuesExpression("aql:Sequence{1,3,5,7}"); //$NON-NLS-1$ + if (withStyle) { + BarChartDescriptionStyle style = ViewFactory.eINSTANCE.createBarChartDescriptionStyle(); + style.setBarsColor("Orchid"); //$NON-NLS-1$ + this.setFontStyle(style); + barChartDescription.setStyle(style); + } + if (withConditionalStyle) { + ConditionalBarChartDescriptionStyle conditionalStyle = ViewFactory.eINSTANCE.createConditionalBarChartDescriptionStyle(); + conditionalStyle.setCondition("aql:true"); //$NON-NLS-1$ + conditionalStyle.setBarsColor("PaleGoldenRod"); //$NON-NLS-1$ + this.setConditionalFontStyle(conditionalStyle); + barChartDescription.getConditionalStyles().add(conditionalStyle); + } + return barChartDescription; } - private PieChartDescription createPieChart() { + private PieChartDescription createPieChart(boolean withStyle, boolean withConditionalStyle) { PieChartDescription pieChartDescription = ViewFactory.eINSTANCE.createPieChartDescription(); pieChartDescription.setName("chartWidget"); //$NON-NLS-1$ pieChartDescription.setLabelExpression("aql:'The Chart Widget label'"); //$NON-NLS-1$ pieChartDescription.setName("pieChart"); //$NON-NLS-1$ pieChartDescription.setKeysExpression("aql:Sequence{'a','b','c','d'}"); //$NON-NLS-1$ pieChartDescription.setValuesExpression("aql:Sequence{1,3,5,7}"); //$NON-NLS-1$ + + if (withStyle) { + PieChartDescriptionStyle style = ViewFactory.eINSTANCE.createPieChartDescriptionStyle(); + style.setColors("aql:Sequence{'AliceBlue','AntiqueWhite','DarkMagenta','DarkGreen'}"); //$NON-NLS-1$ + style.setStrokeColor("Orchid"); //$NON-NLS-1$ + style.setStrokeWidth("3"); //$NON-NLS-1$ + this.setFontStyle(style); + pieChartDescription.setStyle(style); + } + if (withConditionalStyle) { + ConditionalPieChartDescriptionStyle conditionalStyle = ViewFactory.eINSTANCE.createConditionalPieChartDescriptionStyle(); + conditionalStyle.setCondition("aql:true"); //$NON-NLS-1$ + conditionalStyle.setColors("aql:Sequence{'CadetBlue','AntiqueWhite','DarkMagenta','Coral'}"); //$NON-NLS-1$ + conditionalStyle.setStrokeColor("PaleGoldenRod"); //$NON-NLS-1$ + conditionalStyle.setStrokeWidth("2"); //$NON-NLS-1$ + this.setConditionalFontStyle(conditionalStyle); + pieChartDescription.getConditionalStyles().add(conditionalStyle); + } return pieChartDescription; } diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescription.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescription.java index ccddbe939f..e742fe5dbc 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescription.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescription.java @@ -12,6 +12,8 @@ */ package org.eclipse.sirius.components.view; +import org.eclipse.emf.common.util.EList; + /** * A representation of the model object 'Bar Chart Description'. @@ -25,6 +27,9 @@ *
  • {@link org.eclipse.sirius.components.view.BarChartDescription#getKeysExpression Keys Expression}
  • *
  • {@link org.eclipse.sirius.components.view.BarChartDescription#getYAxisLabelExpression YAxis Label * Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.BarChartDescription#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.BarChartDescription#getConditionalStyles Conditional + * Styles}
  • * * * @see org.eclipse.sirius.components.view.ViewPackage#getBarChartDescription() @@ -101,4 +106,39 @@ public interface BarChartDescription extends WidgetDescription { */ void setYAxisLabelExpression(String value); + /** + * Returns the value of the 'Style' containment reference. + * + * @return the value of the 'Style' containment reference. + * @see #setStyle(BarChartDescriptionStyle) + * @see org.eclipse.sirius.components.view.ViewPackage#getBarChartDescription_Style() + * @model containment="true" + * @generated + */ + BarChartDescriptionStyle getStyle(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.BarChartDescription#getStyle Style}' + * containment reference. + * + * @param value + * the new value of the 'Style' containment reference. + * @see #getStyle() + * @generated + */ + void setStyle(BarChartDescriptionStyle value); + + /** + * Returns the value of the 'Conditional Styles' containment reference list. The list contents are + * of type {@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle}. + * + * + * @return the value of the 'Conditional Styles' containment reference list. + * @see org.eclipse.sirius.components.view.ViewPackage#getBarChartDescription_ConditionalStyles() + * @model containment="true" + * @generated + */ + EList getConditionalStyles(); + } // BarChartDescription diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescriptionStyle.java new file mode 100644 index 0000000000..281b69e1d1 --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/BarChartDescriptionStyle.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view; + +/** + * A representation of the model object 'Bar Chart Description Style'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.BarChartDescriptionStyle#getBarsColor Bars Color}
    • + *
    + * + * @see org.eclipse.sirius.components.view.ViewPackage#getBarChartDescriptionStyle() + * @model + * @generated + */ +public interface BarChartDescriptionStyle extends WidgetDescriptionStyle, LabelStyle { + /** + * Returns the value of the 'Bars Color' attribute. + * + * @return the value of the 'Bars Color' attribute. + * @see #setBarsColor(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getBarChartDescriptionStyle_BarsColor() + * @model + * @generated + */ + String getBarsColor(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.BarChartDescriptionStyle#getBarsColor Bars + * Color}' attribute. + * + * @param value + * the new value of the 'Bars Color' attribute. + * @see #getBarsColor() + * @generated + */ + void setBarsColor(String value); + +} // BarChartDescriptionStyle diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalBarChartDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalBarChartDescriptionStyle.java new file mode 100644 index 0000000000..5bbab89e4a --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalBarChartDescriptionStyle.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view; + +/** + * A representation of the model object 'Conditional Bar Chart Description + * Style'. + * + * + * @see org.eclipse.sirius.components.view.ViewPackage#getConditionalBarChartDescriptionStyle() + * @model + * @generated + */ +public interface ConditionalBarChartDescriptionStyle extends Conditional, BarChartDescriptionStyle { +} // ConditionalBarChartDescriptionStyle diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalPieChartDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalPieChartDescriptionStyle.java new file mode 100644 index 0000000000..d7fb2ef0ac --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ConditionalPieChartDescriptionStyle.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view; + +/** + * A representation of the model object 'Conditional Pie Chart Description + * Style'. + * + * + * @see org.eclipse.sirius.components.view.ViewPackage#getConditionalPieChartDescriptionStyle() + * @model + * @generated + */ +public interface ConditionalPieChartDescriptionStyle extends Conditional, PieChartDescriptionStyle { +} // ConditionalPieChartDescriptionStyle diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescription.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescription.java index 0ac213f6f1..705dc7acd2 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescription.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescription.java @@ -12,6 +12,8 @@ */ package org.eclipse.sirius.components.view; +import org.eclipse.emf.common.util.EList; + /** * A representation of the model object 'Pie Chart Description'. @@ -23,6 +25,9 @@ *
  • {@link org.eclipse.sirius.components.view.PieChartDescription#getValuesExpression Values * Expression}
  • *
  • {@link org.eclipse.sirius.components.view.PieChartDescription#getKeysExpression Keys Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.PieChartDescription#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.PieChartDescription#getConditionalStyles Conditional + * Styles}
  • * * * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescription() @@ -76,4 +81,39 @@ public interface PieChartDescription extends WidgetDescription { */ void setKeysExpression(String value); + /** + * Returns the value of the 'Style' containment reference. + * + * @return the value of the 'Style' containment reference. + * @see #setStyle(PieChartDescriptionStyle) + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescription_Style() + * @model containment="true" + * @generated + */ + PieChartDescriptionStyle getStyle(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.PieChartDescription#getStyle Style}' + * containment reference. + * + * @param value + * the new value of the 'Style' containment reference. + * @see #getStyle() + * @generated + */ + void setStyle(PieChartDescriptionStyle value); + + /** + * Returns the value of the 'Conditional Styles' containment reference list. The list contents are + * of type {@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle}. + * + * + * @return the value of the 'Conditional Styles' containment reference list. + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescription_ConditionalStyles() + * @model containment="true" + * @generated + */ + EList getConditionalStyles(); + } // PieChartDescription diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescriptionStyle.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescriptionStyle.java new file mode 100644 index 0000000000..147c7bf436 --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/PieChartDescriptionStyle.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view; + +/** + * A representation of the model object 'Pie Chart Description Style'. + * + *

    + * The following features are supported: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getColors Colors}
    • + *
    • {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeWidth Stroke Width}
    • + *
    • {@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeColor Stroke Color}
    • + *
    + * + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescriptionStyle() + * @model + * @generated + */ +public interface PieChartDescriptionStyle extends WidgetDescriptionStyle, LabelStyle { + /** + * Returns the value of the 'Colors' attribute. + * + * @return the value of the 'Colors' attribute. + * @see #setColors(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescriptionStyle_Colors() + * @model + * @generated + */ + String getColors(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getColors + * Colors}' attribute. + * + * @param value + * the new value of the 'Colors' attribute. + * @see #getColors() + * @generated + */ + void setColors(String value); + + /** + * Returns the value of the 'Stroke Width' attribute. + * + * @return the value of the 'Stroke Width' attribute. + * @see #setStrokeWidth(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescriptionStyle_StrokeWidth() + * @model + * @generated + */ + String getStrokeWidth(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeWidth + * Stroke Width}' attribute. + * + * @param value + * the new value of the 'Stroke Width' attribute. + * @see #getStrokeWidth() + * @generated + */ + void setStrokeWidth(String value); + + /** + * Returns the value of the 'Stroke Color' attribute. + * + * @return the value of the 'Stroke Color' attribute. + * @see #setStrokeColor(String) + * @see org.eclipse.sirius.components.view.ViewPackage#getPieChartDescriptionStyle_StrokeColor() + * @model + * @generated + */ + String getStrokeColor(); + + /** + * Sets the value of the '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeColor + * Stroke Color}' attribute. + * + * @param value + * the new value of the 'Stroke Color' attribute. + * @see #getStrokeColor() + * @generated + */ + void setStrokeColor(String value); + +} // PieChartDescriptionStyle diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java index d6a969b3a1..6ef20b99f7 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewFactory.java @@ -368,6 +368,42 @@ public interface ViewFactory extends EFactory { */ ConditionalButtonDescriptionStyle createConditionalButtonDescriptionStyle(); + /** + * Returns a new object of class 'Bar Chart Description Style'. + * + * @return a new object of class 'Bar Chart Description Style'. + * @generated + */ + BarChartDescriptionStyle createBarChartDescriptionStyle(); + + /** + * Returns a new object of class 'Conditional Bar Chart Description Style'. + * + * @return a new object of class 'Conditional Bar Chart Description Style'. + * @generated + */ + ConditionalBarChartDescriptionStyle createConditionalBarChartDescriptionStyle(); + + /** + * Returns a new object of class 'Pie Chart Description Style'. + * + * @return a new object of class 'Pie Chart Description Style'. + * @generated + */ + PieChartDescriptionStyle createPieChartDescriptionStyle(); + + /** + * Returns a new object of class 'Conditional Pie Chart Description Style'. + * + * @return a new object of class 'Conditional Pie Chart Description Style'. + * @generated + */ + ConditionalPieChartDescriptionStyle createConditionalPieChartDescriptionStyle(); + /** * Returns a new object of class 'Bar Chart Description'. * diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java index 8648a574ea..a6d2feb7a4 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/ViewPackage.java @@ -2886,6 +2886,24 @@ public interface ViewPackage extends EPackage { */ int BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION = WIDGET_DESCRIPTION_FEATURE_COUNT + 2; + /** + * The feature id for the 'Style' containment reference. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION__STYLE = WIDGET_DESCRIPTION_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Conditional Styles' containment reference list. + * + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES = WIDGET_DESCRIPTION_FEATURE_COUNT + 4; + /** * The number of structural features of the 'Bar Chart Description' class. @@ -2893,7 +2911,7 @@ public interface ViewPackage extends EPackage { * @generated * @ordered */ - int BAR_CHART_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 3; + int BAR_CHART_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 5; /** * The number of operations of the 'Bar Chart Description' class. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION__STYLE = WIDGET_DESCRIPTION_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Conditional Styles' containment reference list. + * + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES = WIDGET_DESCRIPTION_FEATURE_COUNT + 3; + /** * The number of structural features of the 'Pie Chart Description' class. @@ -2955,7 +2991,7 @@ public interface ViewPackage extends EPackage { * @generated * @ordered */ - int PIE_CHART_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 2; + int PIE_CHART_DESCRIPTION_FEATURE_COUNT = WIDGET_DESCRIPTION_FEATURE_COUNT + 4; /** * The number of operations of the 'Pie Chart Description' class. + * + * @see org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getBarChartDescriptionStyle() + * @generated + */ + int BAR_CHART_DESCRIPTION_STYLE = 55; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__ITALIC = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__BOLD = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__UNDERLINE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Bars Color' attribute. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 5; + + /** + * The number of structural features of the 'Bar Chart Description Style' class. + * + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE_FEATURE_COUNT = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 6; + + /** + * The number of operations of the 'Bar Chart Description Style' class. + * + * @generated + * @ordered + */ + int BAR_CHART_DESCRIPTION_STYLE_OPERATION_COUNT = WIDGET_DESCRIPTION_STYLE_OPERATION_COUNT + 0; + + /** + * The meta object id for the + * '{@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl Conditional Bar Chart + * Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalBarChartDescriptionStyle() + * @generated + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE = 56; + + /** + * The feature id for the 'Condition' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__CONDITION = CONDITIONAL__CONDITION; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE = CONDITIONAL_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC = CONDITIONAL_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD = CONDITIONAL_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE = CONDITIONAL_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH = CONDITIONAL_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Bars Color' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR = CONDITIONAL_FEATURE_COUNT + 5; + + /** + * The number of structural features of the 'Conditional Bar Chart Description Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE_FEATURE_COUNT = CONDITIONAL_FEATURE_COUNT + 6; + + /** + * The number of operations of the 'Conditional Bar Chart Description Style' class. + * + * + * @generated + * @ordered + */ + int CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE_OPERATION_COUNT = CONDITIONAL_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl Pie + * Chart Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getPieChartDescriptionStyle() + * @generated + */ + int PIE_CHART_DESCRIPTION_STYLE = 57; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__ITALIC = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__BOLD = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__UNDERLINE = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Colors' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__COLORS = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 5; + + /** + * The feature id for the 'Stroke Width' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 6; + + /** + * The feature id for the 'Stroke Color' attribute. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 7; + + /** + * The number of structural features of the 'Pie Chart Description Style' class. + * + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE_FEATURE_COUNT = WIDGET_DESCRIPTION_STYLE_FEATURE_COUNT + 8; + + /** + * The number of operations of the 'Pie Chart Description Style' class. + * + * @generated + * @ordered + */ + int PIE_CHART_DESCRIPTION_STYLE_OPERATION_COUNT = WIDGET_DESCRIPTION_STYLE_OPERATION_COUNT + 0; + + /** + * The meta object id for the + * '{@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl Conditional Pie Chart + * Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalPieChartDescriptionStyle() + * @generated + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE = 58; + + /** + * The feature id for the 'Condition' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__CONDITION = CONDITIONAL__CONDITION; + + /** + * The feature id for the 'Font Size' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE = CONDITIONAL_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Italic' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC = CONDITIONAL_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Bold' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD = CONDITIONAL_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Underline' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE = CONDITIONAL_FEATURE_COUNT + 3; + + /** + * The feature id for the 'Strike Through' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH = CONDITIONAL_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Colors' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS = CONDITIONAL_FEATURE_COUNT + 5; + + /** + * The feature id for the 'Stroke Width' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH = CONDITIONAL_FEATURE_COUNT + 6; + + /** + * The feature id for the 'Stroke Color' attribute. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR = CONDITIONAL_FEATURE_COUNT + 7; + + /** + * The number of structural features of the 'Conditional Pie Chart Description Style' class. + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE_FEATURE_COUNT = CONDITIONAL_FEATURE_COUNT + 8; + + /** + * The number of operations of the 'Conditional Pie Chart Description Style' class. + * + * + * @generated + * @ordered + */ + int CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE_OPERATION_COUNT = CONDITIONAL_OPERATION_COUNT + 0; + /** * The meta object id for the '{@link org.eclipse.sirius.components.view.ArrowStyle Arrow Style}' enum. * @@ -4164,7 +4554,7 @@ public interface ViewPackage extends EPackage { * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getArrowStyle() * @generated */ - int ARROW_STYLE = 55; + int ARROW_STYLE = 59; /** * The meta object id for the '{@link org.eclipse.sirius.components.view.LineStyle Line Style}' enum. + * + * @return the meta object for class 'Bar Chart Description Style'. + * @see org.eclipse.sirius.components.view.BarChartDescriptionStyle + * @generated + */ + EClass getBarChartDescriptionStyle(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.BarChartDescriptionStyle#getBarsColor Bars Color}'. + * + * @return the meta object for the attribute 'Bars Color'. + * @see org.eclipse.sirius.components.view.BarChartDescriptionStyle#getBarsColor() + * @see #getBarChartDescriptionStyle() + * @generated + */ + EAttribute getBarChartDescriptionStyle_BarsColor(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle + * Conditional Bar Chart Description Style}'. + * + * @return the meta object for class 'Conditional Bar Chart Description Style'. + * @see org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle + * @generated + */ + EClass getConditionalBarChartDescriptionStyle(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle Pie + * Chart Description Style}'. + * + * @return the meta object for class 'Pie Chart Description Style'. + * @see org.eclipse.sirius.components.view.PieChartDescriptionStyle + * @generated + */ + EClass getPieChartDescriptionStyle(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getColors Colors}'. + * + * @return the meta object for the attribute 'Colors'. + * @see org.eclipse.sirius.components.view.PieChartDescriptionStyle#getColors() + * @see #getPieChartDescriptionStyle() + * @generated + */ + EAttribute getPieChartDescriptionStyle_Colors(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeWidth Stroke Width}'. + * + * @return the meta object for the attribute 'Stroke Width'. + * @see org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeWidth() + * @see #getPieChartDescriptionStyle() + * @generated + */ + EAttribute getPieChartDescriptionStyle_StrokeWidth(); + + /** + * Returns the meta object for the attribute + * '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeColor Stroke Color}'. + * + * @return the meta object for the attribute 'Stroke Color'. + * @see org.eclipse.sirius.components.view.PieChartDescriptionStyle#getStrokeColor() + * @see #getPieChartDescriptionStyle() + * @generated + */ + EAttribute getPieChartDescriptionStyle_StrokeColor(); + + /** + * Returns the meta object for class '{@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle + * Conditional Pie Chart Description Style}'. + * + * @return the meta object for class 'Conditional Pie Chart Description Style'. + * @see org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle + * @generated + */ + EClass getConditionalPieChartDescriptionStyle(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.BarChartDescription Bar Chart * Description}'. @@ -6049,6 +6527,30 @@ public interface ViewPackage extends EPackage { */ EAttribute getBarChartDescription_YAxisLabelExpression(); + /** + * Returns the meta object for the containment reference + * '{@link org.eclipse.sirius.components.view.BarChartDescription#getStyle Style}'. + * + * + * @return the meta object for the containment reference 'Style'. + * @see org.eclipse.sirius.components.view.BarChartDescription#getStyle() + * @see #getBarChartDescription() + * @generated + */ + EReference getBarChartDescription_Style(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.BarChartDescription#getConditionalStyles Conditional + * Styles}'. + * + * @return the meta object for the containment reference list 'Conditional Styles'. + * @see org.eclipse.sirius.components.view.BarChartDescription#getConditionalStyles() + * @see #getBarChartDescription() + * @generated + */ + EReference getBarChartDescription_ConditionalStyles(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.PieChartDescription Pie Chart * Description}'. @@ -6083,6 +6585,30 @@ public interface ViewPackage extends EPackage { */ EAttribute getPieChartDescription_KeysExpression(); + /** + * Returns the meta object for the containment reference + * '{@link org.eclipse.sirius.components.view.PieChartDescription#getStyle Style}'. + * + * + * @return the meta object for the containment reference 'Style'. + * @see org.eclipse.sirius.components.view.PieChartDescription#getStyle() + * @see #getPieChartDescription() + * @generated + */ + EReference getPieChartDescription_Style(); + + /** + * Returns the meta object for the containment reference list + * '{@link org.eclipse.sirius.components.view.PieChartDescription#getConditionalStyles Conditional + * Styles}'. + * + * @return the meta object for the containment reference list 'Conditional Styles'. + * @see org.eclipse.sirius.components.view.PieChartDescription#getConditionalStyles() + * @see #getPieChartDescription() + * @generated + */ + EReference getPieChartDescription_ConditionalStyles(); + /** * Returns the meta object for class '{@link org.eclipse.sirius.components.view.FlexboxContainerDescription * Flexbox Container Description}'. @@ -7655,6 +8181,80 @@ interface Literals { */ EClass CONDITIONAL_BUTTON_DESCRIPTION_STYLE = eINSTANCE.getConditionalButtonDescriptionStyle(); + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl + * Bar Chart Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getBarChartDescriptionStyle() + * @generated + */ + EClass BAR_CHART_DESCRIPTION_STYLE = eINSTANCE.getBarChartDescriptionStyle(); + + /** + * The meta object literal for the 'Bars Color' attribute feature. + * + * @generated + */ + EAttribute BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR = eINSTANCE.getBarChartDescriptionStyle_BarsColor(); + + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl Conditional Bar + * Chart Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalBarChartDescriptionStyle() + * @generated + */ + EClass CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE = eINSTANCE.getConditionalBarChartDescriptionStyle(); + + /** + * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl + * Pie Chart Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getPieChartDescriptionStyle() + * @generated + */ + EClass PIE_CHART_DESCRIPTION_STYLE = eINSTANCE.getPieChartDescriptionStyle(); + + /** + * The meta object literal for the 'Colors' attribute feature. + * + * @generated + */ + EAttribute PIE_CHART_DESCRIPTION_STYLE__COLORS = eINSTANCE.getPieChartDescriptionStyle_Colors(); + + /** + * The meta object literal for the 'Stroke Width' attribute feature. + * + * + * @generated + */ + EAttribute PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH = eINSTANCE.getPieChartDescriptionStyle_StrokeWidth(); + + /** + * The meta object literal for the 'Stroke Color' attribute feature. + * + * + * @generated + */ + EAttribute PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR = eINSTANCE.getPieChartDescriptionStyle_StrokeColor(); + + /** + * The meta object literal for the + * '{@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl Conditional Pie + * Chart Description Style}' class. + * + * @see org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl + * @see org.eclipse.sirius.components.view.impl.ViewPackageImpl#getConditionalPieChartDescriptionStyle() + * @generated + */ + EClass CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE = eINSTANCE.getConditionalPieChartDescriptionStyle(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl * Bar Chart Description}' class. @@ -7689,6 +8289,22 @@ interface Literals { */ EAttribute BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION = eINSTANCE.getBarChartDescription_YAxisLabelExpression(); + /** + * The meta object literal for the 'Style' containment reference feature. + * + * @generated + */ + EReference BAR_CHART_DESCRIPTION__STYLE = eINSTANCE.getBarChartDescription_Style(); + + /** + * The meta object literal for the 'Conditional Styles' containment reference list feature. + * + * @generated + */ + EReference BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES = eINSTANCE.getBarChartDescription_ConditionalStyles(); + /** * The meta object literal for the '{@link org.eclipse.sirius.components.view.impl.PieChartDescriptionImpl * Pie Chart Description}' class. @@ -7715,6 +8331,22 @@ interface Literals { */ EAttribute PIE_CHART_DESCRIPTION__KEYS_EXPRESSION = eINSTANCE.getPieChartDescription_KeysExpression(); + /** + * The meta object literal for the 'Style' containment reference feature. + * + * @generated + */ + EReference PIE_CHART_DESCRIPTION__STYLE = eINSTANCE.getPieChartDescription_Style(); + + /** + * The meta object literal for the 'Conditional Styles' containment reference list feature. + * + * @generated + */ + EReference PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES = eINSTANCE.getPieChartDescription_ConditionalStyles(); + /** * The meta object literal for the * '{@link org.eclipse.sirius.components.view.impl.FlexboxContainerDescriptionImpl Flexbox Container diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionImpl.java index 01442fa6ec..6c6c17bc54 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionImpl.java @@ -12,10 +12,19 @@ */ package org.eclipse.sirius.components.view.impl; +import java.util.Collection; + import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ViewPackage; /** @@ -31,6 +40,9 @@ * Expression} *
  • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl#getYAxisLabelExpression YAxis Label * Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionImpl#getConditionalStyles Conditional + * Styles}
  • * * * @generated @@ -96,6 +108,26 @@ public class BarChartDescriptionImpl extends WidgetDescriptionImpl implements Ba */ protected String yAxisLabelExpression = YAXIS_LABEL_EXPRESSION_EDEFAULT; + /** + * The cached value of the '{@link #getStyle() Style}' containment reference. + * + * @see #getStyle() + * @generated + * @ordered + */ + protected BarChartDescriptionStyle style; + + /** + * The cached value of the '{@link #getConditionalStyles() Conditional Styles}' containment reference list. + * + * + * @see #getConditionalStyles() + * @generated + * @ordered + */ + protected EList conditionalStyles; + /** * * @@ -184,6 +216,83 @@ public void setYAxisLabelExpression(String newYAxisLabelExpression) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION, oldYAxisLabelExpression, this.yAxisLabelExpression)); } + /** + * + * + * @generated + */ + @Override + public BarChartDescriptionStyle getStyle() { + return this.style; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetStyle(BarChartDescriptionStyle newStyle, NotificationChain msgs) { + BarChartDescriptionStyle oldStyle = this.style; + this.style = newStyle; + if (this.eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION__STYLE, oldStyle, newStyle); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setStyle(BarChartDescriptionStyle newStyle) { + if (newStyle != this.style) { + NotificationChain msgs = null; + if (this.style != null) + msgs = ((InternalEObject) this.style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ViewPackage.BAR_CHART_DESCRIPTION__STYLE, null, msgs); + if (newStyle != null) + msgs = ((InternalEObject) newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ViewPackage.BAR_CHART_DESCRIPTION__STYLE, null, msgs); + msgs = this.basicSetStyle(newStyle, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION__STYLE, newStyle, newStyle)); + } + + /** + * + * + * @generated + */ + @Override + public EList getConditionalStyles() { + if (this.conditionalStyles == null) { + this.conditionalStyles = new EObjectContainmentEList<>(ConditionalBarChartDescriptionStyle.class, this, ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.conditionalStyles; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + return this.basicSetStyle(null, msgs); + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return ((InternalEList) this.getConditionalStyles()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + /** * * @@ -198,6 +307,10 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getKeysExpression(); case ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION: return this.getYAxisLabelExpression(); + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + return this.getStyle(); + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return this.getConditionalStyles(); } return super.eGet(featureID, resolve, coreType); } @@ -207,6 +320,7 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { * * @generated */ + @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { @@ -219,6 +333,13 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION: this.setYAxisLabelExpression((String) newValue); return; + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + this.setStyle((BarChartDescriptionStyle) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + this.getConditionalStyles().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -240,6 +361,12 @@ public void eUnset(int featureID) { case ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION: this.setYAxisLabelExpression(YAXIS_LABEL_EXPRESSION_EDEFAULT); return; + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + this.setStyle((BarChartDescriptionStyle) null); + return; + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + return; } super.eUnset(featureID); } @@ -258,6 +385,10 @@ public boolean eIsSet(int featureID) { return KEYS_EXPRESSION_EDEFAULT == null ? this.keysExpression != null : !KEYS_EXPRESSION_EDEFAULT.equals(this.keysExpression); case ViewPackage.BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION: return YAXIS_LABEL_EXPRESSION_EDEFAULT == null ? this.yAxisLabelExpression != null : !YAXIS_LABEL_EXPRESSION_EDEFAULT.equals(this.yAxisLabelExpression); + case ViewPackage.BAR_CHART_DESCRIPTION__STYLE: + return this.style != null; + case ViewPackage.BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return this.conditionalStyles != null && !this.conditionalStyles.isEmpty(); } return super.eIsSet(featureID); } diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionStyleImpl.java new file mode 100644 index 0000000000..2317a3adc1 --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/BarChartDescriptionStyleImpl.java @@ -0,0 +1,506 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * An implementation of the model object 'Bar Chart Description Style'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#getFontSize Font Size}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#isItalic Italic}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#isBold Bold}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#isUnderline Underline}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#isStrikeThrough Strike + * Through}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.BarChartDescriptionStyleImpl#getBarsColor Bars + * Color}
    • + *
    + * + * @generated + */ +public class BarChartDescriptionStyleImpl extends WidgetDescriptionStyleImpl implements BarChartDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getBarsColor() Bars Color}' attribute. + * + * @see #getBarsColor() + * @generated + * @ordered + */ + protected static final String BARS_COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getBarsColor() Bars Color}' attribute. + * + * @see #getBarsColor() + * @generated + * @ordered + */ + protected String barsColor = BARS_COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected BarChartDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.BAR_CHART_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getBarsColor() { + return this.barsColor; + } + + /** + * + * + * @generated + */ + @Override + public void setBarsColor(String newBarsColor) { + String oldBarsColor = this.barsColor; + this.barsColor = newBarsColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR, oldBarsColor, this.barsColor)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return this.getBarsColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.setBarsColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.setBarsColor(BARS_COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return BARS_COLOR_EDEFAULT == null ? this.barsColor != null : !BARS_COLOR_EDEFAULT.equals(this.barsColor); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", barsColor: "); //$NON-NLS-1$ + result.append(this.barsColor); + result.append(')'); + return result.toString(); + } + +} // BarChartDescriptionStyleImpl diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalBarChartDescriptionStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalBarChartDescriptionStyleImpl.java new file mode 100644 index 0000000000..6f562b7aac --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalBarChartDescriptionStyleImpl.java @@ -0,0 +1,539 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.ViewPackage; +import org.eclipse.sirius.components.view.WidgetDescriptionStyle; + +/** + * An implementation of the model object 'Conditional Bar Chart Description + * Style'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#getFontSize Font + * Size}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#isItalic + * Italic}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#isBold Bold}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#isUnderline + * Underline}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#isStrikeThrough Strike + * Through}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalBarChartDescriptionStyleImpl#getBarsColor Bars + * Color}
    • + *
    + * + * @generated + */ +public class ConditionalBarChartDescriptionStyleImpl extends ConditionalImpl implements ConditionalBarChartDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getBarsColor() Bars Color}' attribute. + * + * @see #getBarsColor() + * @generated + * @ordered + */ + protected static final String BARS_COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getBarsColor() Bars Color}' attribute. + * + * @see #getBarsColor() + * @generated + * @ordered + */ + protected String barsColor = BARS_COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected ConditionalBarChartDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getBarsColor() { + return this.barsColor; + } + + /** + * + * + * @generated + */ + @Override + public void setBarsColor(String newBarsColor) { + String oldBarsColor = this.barsColor; + this.barsColor = newBarsColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR, oldBarsColor, this.barsColor)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return this.getBarsColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.setBarsColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + this.setBarsColor(BARS_COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return BARS_COLOR_EDEFAULT == null ? this.barsColor != null : !BARS_COLOR_EDEFAULT.equals(this.barsColor); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (derivedFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == BarChartDescriptionStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (baseFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == BarChartDescriptionStyle.class) { + switch (baseFeatureID) { + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR: + return ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", barsColor: "); //$NON-NLS-1$ + result.append(this.barsColor); + result.append(')'); + return result.toString(); + } + +} // ConditionalBarChartDescriptionStyleImpl diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalPieChartDescriptionStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalPieChartDescriptionStyleImpl.java new file mode 100644 index 0000000000..35704d42fa --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ConditionalPieChartDescriptionStyleImpl.java @@ -0,0 +1,661 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; +import org.eclipse.sirius.components.view.WidgetDescriptionStyle; + +/** + * An implementation of the model object 'Conditional Pie Chart Description + * Style'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#getFontSize Font + * Size}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#isItalic + * Italic}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#isBold Bold}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#isUnderline + * Underline}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#isStrikeThrough Strike + * Through}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#getColors + * Colors}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#getStrokeWidth Stroke + * Width}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.ConditionalPieChartDescriptionStyleImpl#getStrokeColor Stroke + * Color}
    • + *
    + * + * @generated + */ +public class ConditionalPieChartDescriptionStyleImpl extends ConditionalImpl implements ConditionalPieChartDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getColors() Colors}' attribute. + * + * @see #getColors() + * @generated + * @ordered + */ + protected static final String COLORS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getColors() Colors}' attribute. + * + * @see #getColors() + * @generated + * @ordered + */ + protected String colors = COLORS_EDEFAULT; + + /** + * The default value of the '{@link #getStrokeWidth() Stroke Width}' attribute. + * + * + * @see #getStrokeWidth() + * @generated + * @ordered + */ + protected static final String STROKE_WIDTH_EDEFAULT = null; + + /** + * The cached value of the '{@link #getStrokeWidth() Stroke Width}' attribute. + * + * @see #getStrokeWidth() + * @generated + * @ordered + */ + protected String strokeWidth = STROKE_WIDTH_EDEFAULT; + + /** + * The default value of the '{@link #getStrokeColor() Stroke Color}' attribute. + * + * + * @see #getStrokeColor() + * @generated + * @ordered + */ + protected static final String STROKE_COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getStrokeColor() Stroke Color}' attribute. + * + * @see #getStrokeColor() + * @generated + * @ordered + */ + protected String strokeColor = STROKE_COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected ConditionalPieChartDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getColors() { + return this.colors; + } + + /** + * + * + * @generated + */ + @Override + public void setColors(String newColors) { + String oldColors = this.colors; + this.colors = newColors; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS, oldColors, this.colors)); + } + + /** + * + * + * @generated + */ + @Override + public String getStrokeWidth() { + return this.strokeWidth; + } + + /** + * + * + * @generated + */ + @Override + public void setStrokeWidth(String newStrokeWidth) { + String oldStrokeWidth = this.strokeWidth; + this.strokeWidth = newStrokeWidth; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH, oldStrokeWidth, this.strokeWidth)); + } + + /** + * + * + * @generated + */ + @Override + public String getStrokeColor() { + return this.strokeColor; + } + + /** + * + * + * @generated + */ + @Override + public void setStrokeColor(String newStrokeColor) { + String oldStrokeColor = this.strokeColor; + this.strokeColor = newStrokeColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR, oldStrokeColor, this.strokeColor)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + return this.getColors(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return this.getStrokeWidth(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return this.getStrokeColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + this.setColors((String) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + this.setStrokeWidth((String) newValue); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.setStrokeColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + this.setColors(COLORS_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + this.setStrokeWidth(STROKE_WIDTH_EDEFAULT); + return; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.setStrokeColor(STROKE_COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + return COLORS_EDEFAULT == null ? this.colors != null : !COLORS_EDEFAULT.equals(this.colors); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return STROKE_WIDTH_EDEFAULT == null ? this.strokeWidth != null : !STROKE_WIDTH_EDEFAULT.equals(this.strokeWidth); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return STROKE_COLOR_EDEFAULT == null ? this.strokeColor != null : !STROKE_COLOR_EDEFAULT.equals(this.strokeColor); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (derivedFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == PieChartDescriptionStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH; + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == WidgetDescriptionStyle.class) { + switch (baseFeatureID) { + default: + return -1; + } + } + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + if (baseClass == PieChartDescriptionStyle.class) { + switch (baseFeatureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__COLORS; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", colors: "); //$NON-NLS-1$ + result.append(this.colors); + result.append(", strokeWidth: "); //$NON-NLS-1$ + result.append(this.strokeWidth); + result.append(", strokeColor: "); //$NON-NLS-1$ + result.append(this.strokeColor); + result.append(')'); + return result.toString(); + } + +} // ConditionalPieChartDescriptionStyleImpl diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionImpl.java index 5fa6986187..aabd323619 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionImpl.java @@ -12,10 +12,19 @@ */ package org.eclipse.sirius.components.view.impl; +import java.util.Collection; + import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.ViewPackage; /** @@ -29,6 +38,9 @@ * Expression} *
  • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionImpl#getKeysExpression Keys * Expression}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionImpl#getStyle Style}
  • + *
  • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionImpl#getConditionalStyles Conditional + * Styles}
  • * * * @generated @@ -74,6 +86,26 @@ public class PieChartDescriptionImpl extends WidgetDescriptionImpl implements Pi */ protected String keysExpression = KEYS_EXPRESSION_EDEFAULT; + /** + * The cached value of the '{@link #getStyle() Style}' containment reference. + * + * @see #getStyle() + * @generated + * @ordered + */ + protected PieChartDescriptionStyle style; + + /** + * The cached value of the '{@link #getConditionalStyles() Conditional Styles}' containment reference list. + * + * + * @see #getConditionalStyles() + * @generated + * @ordered + */ + protected EList conditionalStyles; + /** * * @@ -139,6 +171,83 @@ public void setKeysExpression(String newKeysExpression) { this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION, oldKeysExpression, this.keysExpression)); } + /** + * + * + * @generated + */ + @Override + public PieChartDescriptionStyle getStyle() { + return this.style; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetStyle(PieChartDescriptionStyle newStyle, NotificationChain msgs) { + PieChartDescriptionStyle oldStyle = this.style; + this.style = newStyle; + if (this.eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION__STYLE, oldStyle, newStyle); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setStyle(PieChartDescriptionStyle newStyle) { + if (newStyle != this.style) { + NotificationChain msgs = null; + if (this.style != null) + msgs = ((InternalEObject) this.style).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ViewPackage.PIE_CHART_DESCRIPTION__STYLE, null, msgs); + if (newStyle != null) + msgs = ((InternalEObject) newStyle).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ViewPackage.PIE_CHART_DESCRIPTION__STYLE, null, msgs); + msgs = this.basicSetStyle(newStyle, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION__STYLE, newStyle, newStyle)); + } + + /** + * + * + * @generated + */ + @Override + public EList getConditionalStyles() { + if (this.conditionalStyles == null) { + this.conditionalStyles = new EObjectContainmentEList<>(ConditionalPieChartDescriptionStyle.class, this, ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES); + } + return this.conditionalStyles; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + return this.basicSetStyle(null, msgs); + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return ((InternalEList) this.getConditionalStyles()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + /** * * @@ -151,6 +260,10 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { return this.getValuesExpression(); case ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION: return this.getKeysExpression(); + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + return this.getStyle(); + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return this.getConditionalStyles(); } return super.eGet(featureID, resolve, coreType); } @@ -160,6 +273,7 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { * * @generated */ + @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { @@ -169,6 +283,13 @@ public void eSet(int featureID, Object newValue) { case ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION: this.setKeysExpression((String) newValue); return; + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + this.setStyle((PieChartDescriptionStyle) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + this.getConditionalStyles().addAll((Collection) newValue); + return; } super.eSet(featureID, newValue); } @@ -187,6 +308,12 @@ public void eUnset(int featureID) { case ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION: this.setKeysExpression(KEYS_EXPRESSION_EDEFAULT); return; + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + this.setStyle((PieChartDescriptionStyle) null); + return; + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + this.getConditionalStyles().clear(); + return; } super.eUnset(featureID); } @@ -203,6 +330,10 @@ public boolean eIsSet(int featureID) { return VALUES_EXPRESSION_EDEFAULT == null ? this.valuesExpression != null : !VALUES_EXPRESSION_EDEFAULT.equals(this.valuesExpression); case ViewPackage.PIE_CHART_DESCRIPTION__KEYS_EXPRESSION: return KEYS_EXPRESSION_EDEFAULT == null ? this.keysExpression != null : !KEYS_EXPRESSION_EDEFAULT.equals(this.keysExpression); + case ViewPackage.PIE_CHART_DESCRIPTION__STYLE: + return this.style != null; + case ViewPackage.PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES: + return this.conditionalStyles != null && !this.conditionalStyles.isEmpty(); } return super.eIsSet(featureID); } diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionStyleImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionStyleImpl.java new file mode 100644 index 0000000000..a8bd9d90f2 --- /dev/null +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/PieChartDescriptionStyleImpl.java @@ -0,0 +1,619 @@ +/** + * Copyright (c) 2021, 2022 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + */ +package org.eclipse.sirius.components.view.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.sirius.components.view.LabelStyle; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; +import org.eclipse.sirius.components.view.ViewPackage; + +/** + * An implementation of the model object 'Pie Chart Description Style'. + *

    + * The following features are implemented: + *

    + *
      + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#getFontSize Font Size}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#isItalic Italic}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#isBold Bold}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#isUnderline Underline}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#isStrikeThrough Strike + * Through}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#getColors Colors}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#getStrokeWidth Stroke + * Width}
    • + *
    • {@link org.eclipse.sirius.components.view.impl.PieChartDescriptionStyleImpl#getStrokeColor Stroke + * Color}
    • + *
    + * + * @generated + */ +public class PieChartDescriptionStyleImpl extends WidgetDescriptionStyleImpl implements PieChartDescriptionStyle { + /** + * The default value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected static final int FONT_SIZE_EDEFAULT = 14; + + /** + * The cached value of the '{@link #getFontSize() Font Size}' attribute. + * + * @see #getFontSize() + * @generated + * @ordered + */ + protected int fontSize = FONT_SIZE_EDEFAULT; + + /** + * The default value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected static final boolean ITALIC_EDEFAULT = false; + + /** + * The cached value of the '{@link #isItalic() Italic}' attribute. + * + * @see #isItalic() + * @generated + * @ordered + */ + protected boolean italic = ITALIC_EDEFAULT; + + /** + * The default value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected static final boolean BOLD_EDEFAULT = false; + + /** + * The cached value of the '{@link #isBold() Bold}' attribute. + * + * @see #isBold() + * @generated + * @ordered + */ + protected boolean bold = BOLD_EDEFAULT; + + /** + * The default value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected static final boolean UNDERLINE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isUnderline() Underline}' attribute. + * + * @see #isUnderline() + * @generated + * @ordered + */ + protected boolean underline = UNDERLINE_EDEFAULT; + + /** + * The default value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected static final boolean STRIKE_THROUGH_EDEFAULT = false; + + /** + * The cached value of the '{@link #isStrikeThrough() Strike Through}' attribute. + * + * + * @see #isStrikeThrough() + * @generated + * @ordered + */ + protected boolean strikeThrough = STRIKE_THROUGH_EDEFAULT; + + /** + * The default value of the '{@link #getColors() Colors}' attribute. + * + * @see #getColors() + * @generated + * @ordered + */ + protected static final String COLORS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getColors() Colors}' attribute. + * + * @see #getColors() + * @generated + * @ordered + */ + protected String colors = COLORS_EDEFAULT; + + /** + * The default value of the '{@link #getStrokeWidth() Stroke Width}' attribute. + * + * + * @see #getStrokeWidth() + * @generated + * @ordered + */ + protected static final String STROKE_WIDTH_EDEFAULT = null; + + /** + * The cached value of the '{@link #getStrokeWidth() Stroke Width}' attribute. + * + * @see #getStrokeWidth() + * @generated + * @ordered + */ + protected String strokeWidth = STROKE_WIDTH_EDEFAULT; + + /** + * The default value of the '{@link #getStrokeColor() Stroke Color}' attribute. + * + * + * @see #getStrokeColor() + * @generated + * @ordered + */ + protected static final String STROKE_COLOR_EDEFAULT = null; + + /** + * The cached value of the '{@link #getStrokeColor() Stroke Color}' attribute. + * + * @see #getStrokeColor() + * @generated + * @ordered + */ + protected String strokeColor = STROKE_COLOR_EDEFAULT; + + /** + * + * + * @generated + */ + protected PieChartDescriptionStyleImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ViewPackage.Literals.PIE_CHART_DESCRIPTION_STYLE; + } + + /** + * + * + * @generated + */ + @Override + public int getFontSize() { + return this.fontSize; + } + + /** + * + * + * @generated + */ + @Override + public void setFontSize(int newFontSize) { + int oldFontSize = this.fontSize; + this.fontSize = newFontSize; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE, oldFontSize, this.fontSize)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isItalic() { + return this.italic; + } + + /** + * + * + * @generated + */ + @Override + public void setItalic(boolean newItalic) { + boolean oldItalic = this.italic; + this.italic = newItalic; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC, oldItalic, this.italic)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isBold() { + return this.bold; + } + + /** + * + * + * @generated + */ + @Override + public void setBold(boolean newBold) { + boolean oldBold = this.bold; + this.bold = newBold; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD, oldBold, this.bold)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isUnderline() { + return this.underline; + } + + /** + * + * + * @generated + */ + @Override + public void setUnderline(boolean newUnderline) { + boolean oldUnderline = this.underline; + this.underline = newUnderline; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE, oldUnderline, this.underline)); + } + + /** + * + * + * @generated + */ + @Override + public boolean isStrikeThrough() { + return this.strikeThrough; + } + + /** + * + * + * @generated + */ + @Override + public void setStrikeThrough(boolean newStrikeThrough) { + boolean oldStrikeThrough = this.strikeThrough; + this.strikeThrough = newStrikeThrough; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH, oldStrikeThrough, this.strikeThrough)); + } + + /** + * + * + * @generated + */ + @Override + public String getColors() { + return this.colors; + } + + /** + * + * + * @generated + */ + @Override + public void setColors(String newColors) { + String oldColors = this.colors; + this.colors = newColors; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS, oldColors, this.colors)); + } + + /** + * + * + * @generated + */ + @Override + public String getStrokeWidth() { + return this.strokeWidth; + } + + /** + * + * + * @generated + */ + @Override + public void setStrokeWidth(String newStrokeWidth) { + String oldStrokeWidth = this.strokeWidth; + this.strokeWidth = newStrokeWidth; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH, oldStrokeWidth, this.strokeWidth)); + } + + /** + * + * + * @generated + */ + @Override + public String getStrokeColor() { + return this.strokeColor; + } + + /** + * + * + * @generated + */ + @Override + public void setStrokeColor(String newStrokeColor) { + String oldStrokeColor = this.strokeColor; + this.strokeColor = newStrokeColor; + if (this.eNotificationRequired()) + this.eNotify(new ENotificationImpl(this, Notification.SET, ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR, oldStrokeColor, this.strokeColor)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.getFontSize(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return this.isItalic(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + return this.isBold(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.isUnderline(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.isStrikeThrough(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + return this.getColors(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return this.getStrokeWidth(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return this.getStrokeColor(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize((Integer) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic((Boolean) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold((Boolean) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline((Boolean) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough((Boolean) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + this.setColors((String) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + this.setStrokeWidth((String) newValue); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.setStrokeColor((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + this.setFontSize(FONT_SIZE_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + this.setItalic(ITALIC_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + this.setBold(BOLD_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + this.setUnderline(UNDERLINE_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + this.setStrikeThrough(STRIKE_THROUGH_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + this.setColors(COLORS_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + this.setStrokeWidth(STROKE_WIDTH_EDEFAULT); + return; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + this.setStrokeColor(STROKE_COLOR_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return this.fontSize != FONT_SIZE_EDEFAULT; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return this.italic != ITALIC_EDEFAULT; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + return this.bold != BOLD_EDEFAULT; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return this.underline != UNDERLINE_EDEFAULT; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return this.strikeThrough != STRIKE_THROUGH_EDEFAULT; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__COLORS: + return COLORS_EDEFAULT == null ? this.colors != null : !COLORS_EDEFAULT.equals(this.colors); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH: + return STROKE_WIDTH_EDEFAULT == null ? this.strokeWidth != null : !STROKE_WIDTH_EDEFAULT.equals(this.strokeWidth); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR: + return STROKE_COLOR_EDEFAULT == null ? this.strokeColor != null : !STROKE_COLOR_EDEFAULT.equals(this.strokeColor); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (derivedFeatureID) { + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE: + return ViewPackage.LABEL_STYLE__FONT_SIZE; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC: + return ViewPackage.LABEL_STYLE__ITALIC; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD: + return ViewPackage.LABEL_STYLE__BOLD; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE: + return ViewPackage.LABEL_STYLE__UNDERLINE; + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH: + return ViewPackage.LABEL_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == LabelStyle.class) { + switch (baseFeatureID) { + case ViewPackage.LABEL_STYLE__FONT_SIZE: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__FONT_SIZE; + case ViewPackage.LABEL_STYLE__ITALIC: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__ITALIC; + case ViewPackage.LABEL_STYLE__BOLD: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__BOLD; + case ViewPackage.LABEL_STYLE__UNDERLINE: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__UNDERLINE; + case ViewPackage.LABEL_STYLE__STRIKE_THROUGH: + return ViewPackage.PIE_CHART_DESCRIPTION_STYLE__STRIKE_THROUGH; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (this.eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (fontSize: "); //$NON-NLS-1$ + result.append(this.fontSize); + result.append(", italic: "); //$NON-NLS-1$ + result.append(this.italic); + result.append(", bold: "); //$NON-NLS-1$ + result.append(this.bold); + result.append(", underline: "); //$NON-NLS-1$ + result.append(this.underline); + result.append(", strikeThrough: "); //$NON-NLS-1$ + result.append(this.strikeThrough); + result.append(", colors: "); //$NON-NLS-1$ + result.append(this.colors); + result.append(", strokeWidth: "); //$NON-NLS-1$ + result.append(this.strokeWidth); + result.append(", strokeColor: "); //$NON-NLS-1$ + result.append(this.strokeColor); + result.append(')'); + return result.toString(); + } + +} // PieChartDescriptionStyleImpl diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java index d82b47a7f6..4cbc7d7181 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewFactoryImpl.java @@ -20,16 +20,19 @@ import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.sirius.components.view.ArrowStyle; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; import org.eclipse.sirius.components.view.ButtonDescription; import org.eclipse.sirius.components.view.ButtonDescriptionStyle; import org.eclipse.sirius.components.view.ChangeContext; import org.eclipse.sirius.components.view.CheckboxDescription; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalTextareaDescriptionStyle; @@ -55,6 +58,7 @@ import org.eclipse.sirius.components.view.NodeStyle; import org.eclipse.sirius.components.view.NodeTool; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.SelectDescription; @@ -200,6 +204,14 @@ public EObject create(EClass eClass) { return this.createButtonDescriptionStyle(); case ViewPackage.CONDITIONAL_BUTTON_DESCRIPTION_STYLE: return this.createConditionalButtonDescriptionStyle(); + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE: + return this.createBarChartDescriptionStyle(); + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE: + return this.createConditionalBarChartDescriptionStyle(); + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE: + return this.createPieChartDescriptionStyle(); + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE: + return this.createConditionalPieChartDescriptionStyle(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -698,6 +710,50 @@ public ConditionalButtonDescriptionStyle createConditionalButtonDescriptionStyle return conditionalButtonDescriptionStyle; } + /** + * + * + * @generated + */ + @Override + public BarChartDescriptionStyle createBarChartDescriptionStyle() { + BarChartDescriptionStyleImpl barChartDescriptionStyle = new BarChartDescriptionStyleImpl(); + return barChartDescriptionStyle; + } + + /** + * + * + * @generated + */ + @Override + public ConditionalBarChartDescriptionStyle createConditionalBarChartDescriptionStyle() { + ConditionalBarChartDescriptionStyleImpl conditionalBarChartDescriptionStyle = new ConditionalBarChartDescriptionStyleImpl(); + return conditionalBarChartDescriptionStyle; + } + + /** + * + * + * @generated + */ + @Override + public PieChartDescriptionStyle createPieChartDescriptionStyle() { + PieChartDescriptionStyleImpl pieChartDescriptionStyle = new PieChartDescriptionStyleImpl(); + return pieChartDescriptionStyle; + } + + /** + * + * + * @generated + */ + @Override + public ConditionalPieChartDescriptionStyle createConditionalPieChartDescriptionStyle() { + ConditionalPieChartDescriptionStyleImpl conditionalPieChartDescriptionStyle = new ConditionalPieChartDescriptionStyleImpl(); + return conditionalPieChartDescriptionStyle; + } + /** * * diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java index a286e4d65c..efde2cfde0 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/impl/ViewPackageImpl.java @@ -20,6 +20,7 @@ import org.eclipse.emf.ecore.impl.EPackageImpl; import org.eclipse.sirius.components.view.ArrowStyle; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; import org.eclipse.sirius.components.view.BorderStyle; import org.eclipse.sirius.components.view.ButtonDescription; import org.eclipse.sirius.components.view.ButtonDescriptionStyle; @@ -27,11 +28,13 @@ import org.eclipse.sirius.components.view.CheckboxDescription; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; import org.eclipse.sirius.components.view.Conditional; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalTextareaDescriptionStyle; @@ -60,6 +63,7 @@ import org.eclipse.sirius.components.view.NodeTool; import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; @@ -443,6 +447,34 @@ public class ViewPackageImpl extends EPackageImpl implements ViewPackage { */ private EClass conditionalButtonDescriptionStyleEClass = null; + /** + * + * + * @generated + */ + private EClass barChartDescriptionStyleEClass = null; + + /** + * + * + * @generated + */ + private EClass conditionalBarChartDescriptionStyleEClass = null; + + /** + * + * + * @generated + */ + private EClass pieChartDescriptionStyleEClass = null; + + /** + * + * + * @generated + */ + private EClass conditionalPieChartDescriptionStyleEClass = null; + /** * * @@ -2180,6 +2212,86 @@ public EClass getConditionalButtonDescriptionStyle() { return this.conditionalButtonDescriptionStyleEClass; } + /** + * + * + * @generated + */ + @Override + public EClass getBarChartDescriptionStyle() { + return this.barChartDescriptionStyleEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getBarChartDescriptionStyle_BarsColor() { + return (EAttribute) this.barChartDescriptionStyleEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getConditionalBarChartDescriptionStyle() { + return this.conditionalBarChartDescriptionStyleEClass; + } + + /** + * + * + * @generated + */ + @Override + public EClass getPieChartDescriptionStyle() { + return this.pieChartDescriptionStyleEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPieChartDescriptionStyle_Colors() { + return (EAttribute) this.pieChartDescriptionStyleEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPieChartDescriptionStyle_StrokeWidth() { + return (EAttribute) this.pieChartDescriptionStyleEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPieChartDescriptionStyle_StrokeColor() { + return (EAttribute) this.pieChartDescriptionStyleEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getConditionalPieChartDescriptionStyle() { + return this.conditionalPieChartDescriptionStyleEClass; + } + /** * * @@ -2220,6 +2332,26 @@ public EAttribute getBarChartDescription_YAxisLabelExpression() { return (EAttribute) this.barChartDescriptionEClass.getEStructuralFeatures().get(2); } + /** + * + * + * @generated + */ + @Override + public EReference getBarChartDescription_Style() { + return (EReference) this.barChartDescriptionEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EReference getBarChartDescription_ConditionalStyles() { + return (EReference) this.barChartDescriptionEClass.getEStructuralFeatures().get(4); + } + /** * * @@ -2250,6 +2382,26 @@ public EAttribute getPieChartDescription_KeysExpression() { return (EAttribute) this.pieChartDescriptionEClass.getEStructuralFeatures().get(1); } + /** + * + * + * @generated + */ + @Override + public EReference getPieChartDescription_Style() { + return (EReference) this.pieChartDescriptionEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getPieChartDescription_ConditionalStyles() { + return (EReference) this.pieChartDescriptionEClass.getEStructuralFeatures().get(3); + } + /** * * @@ -2584,10 +2736,14 @@ public void createPackageContents() { this.createEAttribute(this.barChartDescriptionEClass, BAR_CHART_DESCRIPTION__VALUES_EXPRESSION); this.createEAttribute(this.barChartDescriptionEClass, BAR_CHART_DESCRIPTION__KEYS_EXPRESSION); this.createEAttribute(this.barChartDescriptionEClass, BAR_CHART_DESCRIPTION__YAXIS_LABEL_EXPRESSION); + this.createEReference(this.barChartDescriptionEClass, BAR_CHART_DESCRIPTION__STYLE); + this.createEReference(this.barChartDescriptionEClass, BAR_CHART_DESCRIPTION__CONDITIONAL_STYLES); this.pieChartDescriptionEClass = this.createEClass(PIE_CHART_DESCRIPTION); this.createEAttribute(this.pieChartDescriptionEClass, PIE_CHART_DESCRIPTION__VALUES_EXPRESSION); this.createEAttribute(this.pieChartDescriptionEClass, PIE_CHART_DESCRIPTION__KEYS_EXPRESSION); + this.createEReference(this.pieChartDescriptionEClass, PIE_CHART_DESCRIPTION__STYLE); + this.createEReference(this.pieChartDescriptionEClass, PIE_CHART_DESCRIPTION__CONDITIONAL_STYLES); this.flexboxContainerDescriptionEClass = this.createEClass(FLEXBOX_CONTAINER_DESCRIPTION); this.createEReference(this.flexboxContainerDescriptionEClass, FLEXBOX_CONTAINER_DESCRIPTION__CHILDREN); @@ -2642,6 +2798,18 @@ public void createPackageContents() { this.conditionalButtonDescriptionStyleEClass = this.createEClass(CONDITIONAL_BUTTON_DESCRIPTION_STYLE); + this.barChartDescriptionStyleEClass = this.createEClass(BAR_CHART_DESCRIPTION_STYLE); + this.createEAttribute(this.barChartDescriptionStyleEClass, BAR_CHART_DESCRIPTION_STYLE__BARS_COLOR); + + this.conditionalBarChartDescriptionStyleEClass = this.createEClass(CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE); + + this.pieChartDescriptionStyleEClass = this.createEClass(PIE_CHART_DESCRIPTION_STYLE); + this.createEAttribute(this.pieChartDescriptionStyleEClass, PIE_CHART_DESCRIPTION_STYLE__COLORS); + this.createEAttribute(this.pieChartDescriptionStyleEClass, PIE_CHART_DESCRIPTION_STYLE__STROKE_WIDTH); + this.createEAttribute(this.pieChartDescriptionStyleEClass, PIE_CHART_DESCRIPTION_STYLE__STROKE_COLOR); + + this.conditionalPieChartDescriptionStyleEClass = this.createEClass(CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE); + // Create enums this.arrowStyleEEnum = this.createEEnum(ARROW_STYLE); this.lineStyleEEnum = this.createEEnum(LINE_STYLE); @@ -2739,6 +2907,14 @@ public void initializePackageContents() { this.buttonDescriptionStyleEClass.getESuperTypes().add(this.getLabelStyle()); this.conditionalButtonDescriptionStyleEClass.getESuperTypes().add(this.getConditional()); this.conditionalButtonDescriptionStyleEClass.getESuperTypes().add(this.getButtonDescriptionStyle()); + this.barChartDescriptionStyleEClass.getESuperTypes().add(this.getWidgetDescriptionStyle()); + this.barChartDescriptionStyleEClass.getESuperTypes().add(this.getLabelStyle()); + this.conditionalBarChartDescriptionStyleEClass.getESuperTypes().add(this.getConditional()); + this.conditionalBarChartDescriptionStyleEClass.getESuperTypes().add(this.getBarChartDescriptionStyle()); + this.pieChartDescriptionStyleEClass.getESuperTypes().add(this.getWidgetDescriptionStyle()); + this.pieChartDescriptionStyleEClass.getESuperTypes().add(this.getLabelStyle()); + this.conditionalPieChartDescriptionStyleEClass.getESuperTypes().add(this.getConditional()); + this.conditionalPieChartDescriptionStyleEClass.getESuperTypes().add(this.getPieChartDescriptionStyle()); // Initialize classes, features, and operations; add parameters this.initEClass(this.viewEClass, View.class, "View", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -3018,12 +3194,20 @@ public void initializePackageContents() { IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEAttribute(this.getBarChartDescription_YAxisLabelExpression(), this.ecorePackage.getEString(), "yAxisLabelExpression", null, 0, 1, BarChartDescription.class, !IS_TRANSIENT, //$NON-NLS-1$ !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getBarChartDescription_Style(), this.getBarChartDescriptionStyle(), null, "style", null, 0, 1, BarChartDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, //$NON-NLS-1$ + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getBarChartDescription_ConditionalStyles(), this.getConditionalBarChartDescriptionStyle(), null, "conditionalStyles", null, 0, -1, BarChartDescription.class, //$NON-NLS-1$ + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.pieChartDescriptionEClass, PieChartDescription.class, "PieChartDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ this.initEAttribute(this.getPieChartDescription_ValuesExpression(), this.ecorePackage.getEString(), "valuesExpression", null, 0, 1, PieChartDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEAttribute(this.getPieChartDescription_KeysExpression(), this.ecorePackage.getEString(), "keysExpression", null, 0, 1, PieChartDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getPieChartDescription_Style(), this.getPieChartDescriptionStyle(), null, "style", null, 0, 1, PieChartDescription.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, //$NON-NLS-1$ + IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEReference(this.getPieChartDescription_ConditionalStyles(), this.getConditionalPieChartDescriptionStyle(), null, "conditionalStyles", null, 0, -1, PieChartDescription.class, //$NON-NLS-1$ + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); this.initEClass(this.flexboxContainerDescriptionEClass, FlexboxContainerDescription.class, "FlexboxContainerDescription", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ this.initEReference(this.getFlexboxContainerDescription_Children(), this.getWidgetDescription(), null, "children", null, 0, -1, FlexboxContainerDescription.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ @@ -3104,6 +3288,24 @@ public void initializePackageContents() { this.initEClass(this.conditionalButtonDescriptionStyleEClass, ConditionalButtonDescriptionStyle.class, "ConditionalButtonDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, //$NON-NLS-1$ IS_GENERATED_INSTANCE_CLASS); + this.initEClass(this.barChartDescriptionStyleEClass, BarChartDescriptionStyle.class, "BarChartDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + this.initEAttribute(this.getBarChartDescriptionStyle_BarsColor(), this.ecorePackage.getEString(), "barsColor", null, 0, 1, BarChartDescriptionStyle.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.conditionalBarChartDescriptionStyleEClass, ConditionalBarChartDescriptionStyle.class, "ConditionalBarChartDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, //$NON-NLS-1$ + IS_GENERATED_INSTANCE_CLASS); + + this.initEClass(this.pieChartDescriptionStyleEClass, PieChartDescriptionStyle.class, "PieChartDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ + this.initEAttribute(this.getPieChartDescriptionStyle_Colors(), this.ecorePackage.getEString(), "colors", null, 0, 1, PieChartDescriptionStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, //$NON-NLS-1$ + !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEAttribute(this.getPieChartDescriptionStyle_StrokeWidth(), this.ecorePackage.getEString(), "strokeWidth", null, 0, 1, PieChartDescriptionStyle.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + this.initEAttribute(this.getPieChartDescriptionStyle_StrokeColor(), this.ecorePackage.getEString(), "strokeColor", null, 0, 1, PieChartDescriptionStyle.class, !IS_TRANSIENT, !IS_VOLATILE, //$NON-NLS-1$ + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + this.initEClass(this.conditionalPieChartDescriptionStyleEClass, ConditionalPieChartDescriptionStyle.class, "ConditionalPieChartDescriptionStyle", !IS_ABSTRACT, !IS_INTERFACE, //$NON-NLS-1$ + IS_GENERATED_INSTANCE_CLASS); + // Initialize enums and add enum literals this.initEEnum(this.arrowStyleEEnum, ArrowStyle.class, "ArrowStyle"); //$NON-NLS-1$ this.addEEnumLiteral(this.arrowStyleEEnum, ArrowStyle.NONE); diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java index 583a5689bc..3711c49dd3 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewAdapterFactory.java @@ -17,6 +17,7 @@ import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; import org.eclipse.emf.ecore.EObject; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; import org.eclipse.sirius.components.view.BorderStyle; import org.eclipse.sirius.components.view.ButtonDescription; import org.eclipse.sirius.components.view.ButtonDescriptionStyle; @@ -24,11 +25,13 @@ import org.eclipse.sirius.components.view.CheckboxDescription; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; import org.eclipse.sirius.components.view.Conditional; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalTextareaDescriptionStyle; @@ -55,6 +58,7 @@ import org.eclipse.sirius.components.view.NodeTool; import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; @@ -399,6 +403,26 @@ public Adapter caseConditionalButtonDescriptionStyle(ConditionalButtonDescriptio return ViewAdapterFactory.this.createConditionalButtonDescriptionStyleAdapter(); } + @Override + public Adapter caseBarChartDescriptionStyle(BarChartDescriptionStyle object) { + return ViewAdapterFactory.this.createBarChartDescriptionStyleAdapter(); + } + + @Override + public Adapter caseConditionalBarChartDescriptionStyle(ConditionalBarChartDescriptionStyle object) { + return ViewAdapterFactory.this.createConditionalBarChartDescriptionStyleAdapter(); + } + + @Override + public Adapter casePieChartDescriptionStyle(PieChartDescriptionStyle object) { + return ViewAdapterFactory.this.createPieChartDescriptionStyleAdapter(); + } + + @Override + public Adapter caseConditionalPieChartDescriptionStyle(ConditionalPieChartDescriptionStyle object) { + return ViewAdapterFactory.this.createConditionalPieChartDescriptionStyleAdapter(); + } + @Override public Adapter defaultCase(EObject object) { return ViewAdapterFactory.this.createEObjectAdapter(); @@ -1114,6 +1138,64 @@ public Adapter createConditionalButtonDescriptionStyleAdapter() { return null; } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.BarChartDescriptionStyle + * Bar Chart Description Style}'. This default implementation returns null so that + * we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.BarChartDescriptionStyle + * @generated + */ + public Adapter createBarChartDescriptionStyleAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle Conditional Bar Chart + * Description Style}'. This default implementation returns null so that we can easily + * ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle + * @generated + */ + public Adapter createConditionalBarChartDescriptionStyleAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.PieChartDescriptionStyle + * Pie Chart Description Style}'. This default implementation returns null so that + * we can easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.PieChartDescriptionStyle + * @generated + */ + public Adapter createPieChartDescriptionStyleAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class + * '{@link org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle Conditional Pie Chart + * Description Style}'. This default implementation returns null so that we can easily + * ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle + * @generated + */ + public Adapter createConditionalPieChartDescriptionStyleAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.sirius.components.view.BarChartDescription * Bar Chart Description}'. This default implementation returns null so that we can diff --git a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java index 91a6596094..12f610da3e 100644 --- a/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java +++ b/packages/view/backend/sirius-components-view/src/main/java/org/eclipse/sirius/components/view/util/ViewSwitch.java @@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.util.Switch; import org.eclipse.sirius.components.view.BarChartDescription; +import org.eclipse.sirius.components.view.BarChartDescriptionStyle; import org.eclipse.sirius.components.view.BorderStyle; import org.eclipse.sirius.components.view.ButtonDescription; import org.eclipse.sirius.components.view.ButtonDescriptionStyle; @@ -23,11 +24,13 @@ import org.eclipse.sirius.components.view.CheckboxDescription; import org.eclipse.sirius.components.view.CheckboxDescriptionStyle; import org.eclipse.sirius.components.view.Conditional; +import org.eclipse.sirius.components.view.ConditionalBarChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalButtonDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalCheckboxDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalEdgeStyle; import org.eclipse.sirius.components.view.ConditionalMultiSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalNodeStyle; +import org.eclipse.sirius.components.view.ConditionalPieChartDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalRadioDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalSelectDescriptionStyle; import org.eclipse.sirius.components.view.ConditionalTextareaDescriptionStyle; @@ -54,6 +57,7 @@ import org.eclipse.sirius.components.view.NodeTool; import org.eclipse.sirius.components.view.Operation; import org.eclipse.sirius.components.view.PieChartDescription; +import org.eclipse.sirius.components.view.PieChartDescriptionStyle; import org.eclipse.sirius.components.view.RadioDescription; import org.eclipse.sirius.components.view.RadioDescriptionStyle; import org.eclipse.sirius.components.view.RepresentationDescription; @@ -668,6 +672,58 @@ protected T doSwitch(int classifierID, EObject theEObject) { result = this.defaultCase(theEObject); return result; } + case ViewPackage.BAR_CHART_DESCRIPTION_STYLE: { + BarChartDescriptionStyle barChartDescriptionStyle = (BarChartDescriptionStyle) theEObject; + T result = this.caseBarChartDescriptionStyle(barChartDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(barChartDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(barChartDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case ViewPackage.CONDITIONAL_BAR_CHART_DESCRIPTION_STYLE: { + ConditionalBarChartDescriptionStyle conditionalBarChartDescriptionStyle = (ConditionalBarChartDescriptionStyle) theEObject; + T result = this.caseConditionalBarChartDescriptionStyle(conditionalBarChartDescriptionStyle); + if (result == null) + result = this.caseConditional(conditionalBarChartDescriptionStyle); + if (result == null) + result = this.caseBarChartDescriptionStyle(conditionalBarChartDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(conditionalBarChartDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(conditionalBarChartDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case ViewPackage.PIE_CHART_DESCRIPTION_STYLE: { + PieChartDescriptionStyle pieChartDescriptionStyle = (PieChartDescriptionStyle) theEObject; + T result = this.casePieChartDescriptionStyle(pieChartDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(pieChartDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(pieChartDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } + case ViewPackage.CONDITIONAL_PIE_CHART_DESCRIPTION_STYLE: { + ConditionalPieChartDescriptionStyle conditionalPieChartDescriptionStyle = (ConditionalPieChartDescriptionStyle) theEObject; + T result = this.caseConditionalPieChartDescriptionStyle(conditionalPieChartDescriptionStyle); + if (result == null) + result = this.caseConditional(conditionalPieChartDescriptionStyle); + if (result == null) + result = this.casePieChartDescriptionStyle(conditionalPieChartDescriptionStyle); + if (result == null) + result = this.caseWidgetDescriptionStyle(conditionalPieChartDescriptionStyle); + if (result == null) + result = this.caseLabelStyle(conditionalPieChartDescriptionStyle); + if (result == null) + result = this.defaultCase(theEObject); + return result; + } default: return this.defaultCase(theEObject); } @@ -1425,6 +1481,68 @@ public T caseConditionalButtonDescriptionStyle(ConditionalButtonDescriptionStyle return null; } + /** + * Returns the result of interpreting the object as an instance of 'Bar Chart Description Style'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Bar Chart Description Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseBarChartDescriptionStyle(BarChartDescriptionStyle object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Conditional Bar Chart Description + * Style'. This implementation returns null; returning a non-null result will terminate + * the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Conditional Bar Chart Description + * Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseConditionalBarChartDescriptionStyle(ConditionalBarChartDescriptionStyle object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Pie Chart Description Style'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Pie Chart Description Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePieChartDescriptionStyle(PieChartDescriptionStyle object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Conditional Pie Chart Description + * Style'. This implementation returns null; returning a non-null result will terminate + * the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Conditional Pie Chart Description + * Style'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseConditionalPieChartDescriptionStyle(ConditionalPieChartDescriptionStyle object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Bar Chart Description'. This implementation returns null; returning a non-null result will terminate the switch.