forked from eclipse-sirius/sirius-web
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2044] Custom icons to edges and nodes label in view dsl
Bug: eclipse-sirius#2044 Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
- Loading branch information
Showing
27 changed files
with
1,295 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...va/org/eclipse/sirius/components/view/emf/compatibility/IPropertiesConfigurerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.compatibility; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.sirius.components.representations.VariableManager; | ||
|
||
/** | ||
* Configuration for the properties view for some of the View DSL elements. | ||
* | ||
* @author mcharfadi | ||
*/ | ||
public interface IPropertiesConfigurerService { | ||
|
||
Function<VariableManager, List<?>> getDiagnosticsProvider(Object feature); | ||
|
||
Function<Object, String> getKindProvider(); | ||
|
||
Function<Object, String> getMessageProvider(); | ||
|
||
Function<VariableManager, String> getTargetObjectIdProvider(); | ||
} |
38 changes: 38 additions & 0 deletions
38
...rg/eclipse/sirius/components/view/emf/compatibility/IPropertiesWidgetCreationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.compatibility; | ||
|
||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
import org.eclipse.sirius.components.forms.description.AbstractControlDescription; | ||
import org.eclipse.sirius.components.forms.description.CheckboxDescription; | ||
import org.eclipse.sirius.components.forms.description.GroupDescription; | ||
import org.eclipse.sirius.components.forms.description.PageDescription; | ||
import org.eclipse.sirius.components.representations.VariableManager; | ||
|
||
/** | ||
* Customizes the properties view for some of the View DSL elements. | ||
* | ||
* @author mcharfadi | ||
*/ | ||
public interface IPropertiesWidgetCreationService { | ||
|
||
PageDescription createSimplePageDescription(GroupDescription groupDescription, Predicate<VariableManager> canCreatePredicate); | ||
|
||
GroupDescription createSimpleGroupDescription(List<AbstractControlDescription> controls); | ||
|
||
CheckboxDescription createCheckbox(String id, String title, Function<Object, Boolean> reader, BiConsumer<Object, Boolean> writer, Object feature); | ||
} |
104 changes: 104 additions & 0 deletions
104
...ava/org/eclipse/sirius/components/view/emf/compatibility/PropertiesConfigurerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 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.compatibility; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.emf.common.util.Diagnostic; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.util.EcoreUtil; | ||
import org.eclipse.sirius.components.collaborative.validation.api.IValidationService; | ||
import org.eclipse.sirius.components.representations.VariableManager; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Configuration for the properties view for some of the View DSL elements. | ||
* | ||
* @author mcharfadi | ||
*/ | ||
@Service | ||
public class PropertiesConfigurerService implements IPropertiesConfigurerService { | ||
|
||
private final IValidationService validationService; | ||
|
||
public PropertiesConfigurerService(IValidationService validationService) { | ||
this.validationService = Objects.requireNonNull(validationService); | ||
} | ||
|
||
@Override | ||
public Function<VariableManager, String> getTargetObjectIdProvider() { | ||
// @formatter:off | ||
return variableManager -> variableManager.get(VariableManager.SELF, Object.class) | ||
.filter(self -> self instanceof List<?>) | ||
.map(self -> (List<?>) self) | ||
.flatMap(self -> self.stream().findFirst()) | ||
.filter(EObject.class::isInstance) | ||
.map(EObject.class::cast) | ||
.map(obj -> EcoreUtil.getURI(obj).toString()) | ||
.orElse(null); | ||
// @formatter:on | ||
} | ||
|
||
@Override | ||
public Function<VariableManager, List<?>> getDiagnosticsProvider(Object feature) { | ||
return variableManager -> { | ||
var optionalSelf = variableManager.get(VariableManager.SELF, EObject.class); | ||
|
||
if (optionalSelf.isPresent()) { | ||
EObject self = optionalSelf.get(); | ||
List<Object> diagnostics = this.validationService.validate(self, feature); | ||
return diagnostics; | ||
} | ||
|
||
return List.of(); | ||
}; | ||
} | ||
|
||
@Override | ||
public Function<Object, String> getKindProvider() { | ||
return object -> { | ||
String kind = "Unknown"; | ||
if (object instanceof Diagnostic) { | ||
Diagnostic diagnostic = (Diagnostic) object; | ||
switch (diagnostic.getSeverity()) { | ||
case org.eclipse.emf.common.util.Diagnostic.ERROR: | ||
kind = "Error"; | ||
break; | ||
case org.eclipse.emf.common.util.Diagnostic.WARNING: | ||
kind = "Warning"; | ||
break; | ||
case org.eclipse.emf.common.util.Diagnostic.INFO: | ||
kind = "Info"; | ||
break; | ||
default: | ||
kind = "Unknown"; | ||
break; | ||
} | ||
} | ||
return kind; | ||
}; | ||
} | ||
|
||
@Override | ||
public Function<Object, String> getMessageProvider() { | ||
return object -> { | ||
if (object instanceof Diagnostic) { | ||
Diagnostic diagnostic = (Diagnostic) object; | ||
return diagnostic.getMessage(); | ||
} | ||
return ""; | ||
}; | ||
} | ||
} |
Oops, something went wrong.