Skip to content

Commit

Permalink
[4390] Add support for diagnostics on View-based widgets
Browse files Browse the repository at this point in the history
Bug: #4390
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Jan 16, 2025
1 parent 689cf68 commit d12f1cf
Show file tree
Hide file tree
Showing 34 changed files with 798 additions and 38 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ Some log messages have been updated in order to provide more information and mak
The configuration property `sirius.web.graphql.tracing` has also been added to active the tracing mode of the GraphQL API.
It can be activated using `sirius.web.graphql.tracing=true` since it is not enabled by default to not have any impact on the performance of the application.
Some additional log has also been contributed on the frontend in order to view more easily the order and time of the GraphQL requests and responses.

- https://github.com/eclipse-sirius/sirius-web/issues/4390[#4390] [form] Add support for diagnostics on View-based widgets
Add view-based widgets now support an optional _Diagnostics Expression_.
The expression can return a string (with a prefix of the form `INFO:`, `WARNING:` or `ERROR:` to indicate the severity), an EMF `org.eclipse.emf.common.util.Diagnostic`, or a list of either of these.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 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
Expand All @@ -14,6 +14,8 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Objects;

import org.assertj.core.api.AbstractAssert;
import org.eclipse.sirius.components.forms.Textfield;

Expand Down Expand Up @@ -46,6 +48,14 @@ public TextfieldAssert hasHelp(String help) {
return this;
}

public TextfieldAssert hasDiagnostic(String kind, String message) {
assertThat(this.actual.getDiagnostics())
.anyMatch(diagnostic -> Objects.equals(diagnostic.getKind(), kind) && Objects.equals(diagnostic.getMessage(), message));

return this;

}

public TextfieldAssert isReadOnly() {
assertThat(this.actual.isReadOnly())
.withFailMessage("Expecting the textfield to be read only but was not read only instead")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 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
Expand All @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.sirius.web.application.controllers.forms;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.eclipse.sirius.components.forms.tests.assertions.FormAssertions.assertThat;

Expand Down Expand Up @@ -109,6 +110,7 @@ public void givenTextfieldWidgetWhenItIsDisplayedThenItIsProperlyInitialized() {
.hasLabel("Name")
.hasValue("buck")
.hasHelp("The name of the object")
.hasDiagnostic("Warning", "name should start with upper case")
.isNotReadOnly()
.isBold()
.isNotItalic();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2025 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
Expand Down Expand Up @@ -116,6 +116,7 @@ private FormDescription createFormDescription() {
.valueExpression("aql:self.name")
.style(defaultTextStyle)
.conditionalStyles(isReadOnlyConditionalTextStyle)
.diagnosticsExpression("aql:if self.name->size() > 0 and self.name.at(1) = self.name.at(1).toUpper() then null else 'WARNING: name should start with upper case' endif")
.body(editTextfield)
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public BarChartDescriptionBuilder helpExpression(java.lang.String value) {
this.getBarChartDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public BarChartDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getBarChartDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValuesExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public ButtonDescriptionBuilder helpExpression(java.lang.String value) {
this.getButtonDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public ButtonDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getButtonDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ButtonLabelExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public CheckboxDescriptionBuilder helpExpression(java.lang.String value) {
this.getCheckboxDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public CheckboxDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getCheckboxDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public DateTimeDescriptionBuilder helpExpression(java.lang.String value) {
this.getDateTimeDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public DateTimeDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getDateTimeDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for StringValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public FlexboxContainerDescriptionBuilder helpExpression(java.lang.String value)
this.getFlexboxContainerDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public FlexboxContainerDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getFlexboxContainerDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for Children.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public ImageDescriptionBuilder helpExpression(java.lang.String value) {
this.getImageDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public ImageDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getImageDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for UrlExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public LabelDescriptionBuilder helpExpression(java.lang.String value) {
this.getLabelDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public LabelDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getLabelDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public LinkDescriptionBuilder helpExpression(java.lang.String value) {
this.getLinkDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public LinkDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getLinkDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public ListDescriptionBuilder helpExpression(java.lang.String value) {
this.getListDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public ListDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getListDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public MultiSelectDescriptionBuilder helpExpression(java.lang.String value) {
this.getMultiSelectDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public MultiSelectDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getMultiSelectDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public PieChartDescriptionBuilder helpExpression(java.lang.String value) {
this.getPieChartDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public PieChartDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getPieChartDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValuesExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public RadioDescriptionBuilder helpExpression(java.lang.String value) {
this.getRadioDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public RadioDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getRadioDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -69,6 +69,16 @@ public RichTextDescriptionBuilder helpExpression(java.lang.String value) {
this.getRichTextDescription().setHelpExpression(value);
return this;
}
/**
* Setter for DiagnosticsExpression.
*
* @generated
*/
public RichTextDescriptionBuilder diagnosticsExpression(java.lang.String value) {
this.getRichTextDescription().setDiagnosticsExpression(value);
return this;
}

/**
* Setter for ValueExpression.
*
Expand Down
Loading

0 comments on commit d12f1cf

Please sign in to comment.