use of org.eclipse.sirius.components.forms.description.AbstractControlDescription in project sirius-components by eclipse-sirius.
the class NodeStylePropertiesConfigurer method getNodeStyleProperties.
private FormDescription getNodeStyleProperties() {
// $NON-NLS-1$
UUID formDescriptionId = UUID.nameUUIDFromBytes("nodestyle".getBytes());
// @formatter:off
List<AbstractControlDescription> controls = List.of(// $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.sizeExpression", // $NON-NLS-1$ //$NON-NLS-2$
"Size Expression", style -> ((NodeStyle) style).getSizeComputationExpression(), (style, newSizeExpression) -> ((NodeStyle) style).setSizeComputationExpression(newSizeExpression), ViewPackage.Literals.NODE_STYLE__SIZE_COMPUTATION_EXPRESSION), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.labelColor", // $NON-NLS-1$ //$NON-NLS-2$
"Label Color", style -> ((NodeStyle) style).getLabelColor(), (style, newLabelColor) -> ((NodeStyle) style).setLabelColor(newLabelColor), ViewPackage.Literals.NODE_STYLE__LABEL_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.color", // $NON-NLS-1$ //$NON-NLS-2$
"Color", style -> ((NodeStyle) style).getColor(), (style, newColor) -> ((NodeStyle) style).setColor(newColor), ViewPackage.Literals.STYLE__COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.borderColor", // $NON-NLS-1$ //$NON-NLS-2$
"Border Color", style -> ((NodeStyle) style).getBorderColor(), (style, newColor) -> ((NodeStyle) style).setBorderColor(newColor), ViewPackage.Literals.BORDER_STYLE__BORDER_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.borderRadius", // $NON-NLS-1$ //$NON-NLS-2$
"Border Radius", style -> String.valueOf(((NodeStyle) style).getBorderRadius()), (style, newBorderRadius) -> {
try {
((NodeStyle) style).setBorderRadius(Integer.parseInt(newBorderRadius));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.BORDER_STYLE__BORDER_RADIUS), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.borderSize", // $NON-NLS-1$ //$NON-NLS-2$
"Border Size", style -> String.valueOf(((NodeStyle) style).getBorderSize()), (style, newBorderSize) -> {
try {
((NodeStyle) style).setBorderSize(Integer.parseInt(newBorderSize));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.BORDER_STYLE__BORDER_SIZE), // $NON-NLS-1$
this.createBorderLineStyleSelectionField("nodestyle.borderstyle", ViewPackage.Literals.BORDER_STYLE__BORDER_LINE_STYLE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.listMode", // $NON-NLS-1$ //$NON-NLS-2$
"List Mode", style -> ((NodeStyle) style).isListMode(), (style, newListMode) -> ((NodeStyle) style).setListMode(newListMode), ViewPackage.Literals.NODE_STYLE__LIST_MODE), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.fontSize", // $NON-NLS-1$ //$NON-NLS-2$
"Font Size", style -> String.valueOf(((LabelStyle) style).getFontSize()), (style, newColor) -> {
try {
((LabelStyle) style).setFontSize(Integer.parseInt(newColor));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.LABEL_STYLE__FONT_SIZE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.italic", // $NON-NLS-1$ //$NON-NLS-2$
"Italic", style -> ((LabelStyle) style).isItalic(), (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic), ViewPackage.Literals.LABEL_STYLE__ITALIC), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.bold", // $NON-NLS-1$ //$NON-NLS-2$
"Bold", style -> ((LabelStyle) style).isBold(), (style, newBold) -> ((LabelStyle) style).setBold(newBold), ViewPackage.Literals.LABEL_STYLE__BOLD), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.underline", // $NON-NLS-1$ //$NON-NLS-2$
"Underline", style -> ((LabelStyle) style).isUnderline(), (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline), ViewPackage.Literals.LABEL_STYLE__UNDERLINE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"nodestyle.strikeThrough", // $NON-NLS-1$ //$NON-NLS-2$
"Strike Through", style -> ((LabelStyle) style).isStrikeThrough(), (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough), ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH), this.createShapeSelectionField(ViewPackage.Literals.NODE_STYLE__SHAPE));
GroupDescription groupDescription = this.createSimpleGroupDescription(controls);
Predicate<VariableManager> canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class).filter(self -> self instanceof List<?>).map(self -> (List<?>) self).flatMap(self -> self.stream().findFirst()).filter(self -> self instanceof NodeStyle && !(self instanceof ConditionalNodeStyle)).isPresent();
return FormDescription.newFormDescription(formDescriptionId).label(// $NON-NLS-1$
"Node Style").labelProvider(variableManager -> variableManager.get(VariableManager.SELF, NodeStyle.class).map(NodeStyle::getColor).orElse(UNNAMED)).canCreatePredicate(variableManager -> true).idProvider(new GetOrCreateRandomIdProvider()).targetObjectIdProvider(this.getTargetObjectIdProvider()).pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))).groupDescriptions(List.of(groupDescription)).build();
// @formatter:on
}
use of org.eclipse.sirius.components.forms.description.AbstractControlDescription in project sirius-components by eclipse-sirius.
the class NodeStylePropertiesConfigurer method getConditionalNodeStyleProperties.
private FormDescription getConditionalNodeStyleProperties() {
// $NON-NLS-1$
UUID formDescriptionId = UUID.nameUUIDFromBytes("conditionalnodestyle".getBytes());
// @formatter:off
List<AbstractControlDescription> controls = List.of(// $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.sizeExpression", // $NON-NLS-1$ //$NON-NLS-2$
"Size Expression", style -> ((NodeStyle) style).getSizeComputationExpression(), (style, newSizeExpression) -> ((NodeStyle) style).setSizeComputationExpression(newSizeExpression), ViewPackage.Literals.NODE_STYLE__SIZE_COMPUTATION_EXPRESSION), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.condition", // $NON-NLS-1$ //$NON-NLS-2$
"Condition", style -> ((ConditionalNodeStyle) style).getCondition(), (style, newCondition) -> ((ConditionalNodeStyle) style).setCondition(newCondition), ViewPackage.Literals.CONDITIONAL__CONDITION), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.labelColor", // $NON-NLS-1$ //$NON-NLS-2$
"Label Color", style -> ((NodeStyle) style).getLabelColor(), (style, newLabelColor) -> ((NodeStyle) style).setLabelColor(newLabelColor), ViewPackage.Literals.NODE_STYLE__LABEL_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.color", // $NON-NLS-1$ //$NON-NLS-2$
"Color", style -> ((NodeStyle) style).getColor(), (style, newColor) -> ((NodeStyle) style).setColor(newColor), ViewPackage.Literals.STYLE__COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.borderColor", // $NON-NLS-1$ //$NON-NLS-2$
"Border Color", style -> ((NodeStyle) style).getBorderColor(), (style, newColor) -> ((NodeStyle) style).setBorderColor(newColor), ViewPackage.Literals.BORDER_STYLE__BORDER_COLOR), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.borderRadius", // $NON-NLS-1$ //$NON-NLS-2$
"Border Radius", style -> String.valueOf(((NodeStyle) style).getBorderRadius()), (style, newBorderRadius) -> {
try {
((NodeStyle) style).setBorderRadius(Integer.parseInt(newBorderRadius));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.BORDER_STYLE__BORDER_RADIUS), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.borderSize", // $NON-NLS-1$ //$NON-NLS-2$
"Border Size", style -> String.valueOf(((NodeStyle) style).getBorderSize()), (style, newBorderSize) -> {
try {
((NodeStyle) style).setBorderSize(Integer.parseInt(newBorderSize));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.BORDER_STYLE__BORDER_SIZE), // $NON-NLS-1$
this.createBorderLineStyleSelectionField("conditionalnodestyle.borderstyle", ViewPackage.Literals.BORDER_STYLE__BORDER_LINE_STYLE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.listMode", // $NON-NLS-1$ //$NON-NLS-2$
"List Mode", style -> ((NodeStyle) style).isListMode(), (style, newListMode) -> ((NodeStyle) style).setListMode(newListMode), ViewPackage.Literals.NODE_STYLE__LIST_MODE), // $NON-NLS-1$ //$NON-NLS-2$
this.createTextField(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.fontSize", // $NON-NLS-1$ //$NON-NLS-2$
"Font Size", style -> String.valueOf(((LabelStyle) style).getFontSize()), (style, newColor) -> {
try {
((LabelStyle) style).setFontSize(Integer.parseInt(newColor));
} catch (NumberFormatException nfe) {
// Ignore.
}
}, ViewPackage.Literals.LABEL_STYLE__FONT_SIZE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.italic", // $NON-NLS-1$ //$NON-NLS-2$
"Italic", style -> ((LabelStyle) style).isItalic(), (style, newItalic) -> ((LabelStyle) style).setItalic(newItalic), ViewPackage.Literals.LABEL_STYLE__ITALIC), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.bold", // $NON-NLS-1$ //$NON-NLS-2$
"Bold", style -> ((LabelStyle) style).isBold(), (style, newBold) -> ((LabelStyle) style).setBold(newBold), ViewPackage.Literals.LABEL_STYLE__BOLD), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.underline", // $NON-NLS-1$ //$NON-NLS-2$
"Underline", style -> ((LabelStyle) style).isUnderline(), (style, newUnderline) -> ((LabelStyle) style).setUnderline(newUnderline), ViewPackage.Literals.LABEL_STYLE__UNDERLINE), // $NON-NLS-1$ //$NON-NLS-2$
this.createCheckbox(// $NON-NLS-1$ //$NON-NLS-2$
"conditionalnodestyle.strikeThrough", // $NON-NLS-1$ //$NON-NLS-2$
"Strike Through", style -> ((LabelStyle) style).isStrikeThrough(), (style, newStrikeThrough) -> ((LabelStyle) style).setStrikeThrough(newStrikeThrough), ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH), this.createShapeSelectionField(ViewPackage.Literals.NODE_STYLE__SHAPE));
GroupDescription groupDescription = this.createSimpleGroupDescription(controls);
Predicate<VariableManager> canCreatePagePredicate = variableManager -> variableManager.get(VariableManager.SELF, Object.class).filter(self -> self instanceof List<?>).map(self -> (List<?>) self).flatMap(self -> self.stream().findFirst()).filter(self -> self instanceof ConditionalNodeStyle).isPresent();
return FormDescription.newFormDescription(formDescriptionId).label(// $NON-NLS-1$
"Conditional Node Style").labelProvider(variableManager -> variableManager.get(VariableManager.SELF, ConditionalNodeStyle.class).map(ConditionalNodeStyle::getCondition).orElse(UNNAMED)).canCreatePredicate(variableManager -> true).idProvider(new GetOrCreateRandomIdProvider()).targetObjectIdProvider(this.getTargetObjectIdProvider()).pageDescriptions(List.of(this.createSimplePageDescription(groupDescription, canCreatePagePredicate))).groupDescriptions(List.of(groupDescription)).build();
// @formatter:on
}
use of org.eclipse.sirius.components.forms.description.AbstractControlDescription in project sirius-components by eclipse-sirius.
the class PropertiesDefaultDescriptionProvider method getGroupDescription.
private GroupDescription getGroupDescription() {
List<AbstractControlDescription> controlDescriptions = new ArrayList<>();
Function<VariableManager, List<?>> iterableProvider = variableManager -> {
List<Object> objects = new ArrayList<>();
Object self = variableManager.getVariables().get(VariableManager.SELF);
if (self instanceof EObject) {
EObject eObject = (EObject) self;
// @formatter:off
List<IItemPropertyDescriptor> propertyDescriptors = Optional.ofNullable(this.composedAdapterFactory.adapt(eObject, IItemPropertySource.class)).filter(IItemPropertySource.class::isInstance).map(IItemPropertySource.class::cast).map(iItemPropertySource -> iItemPropertySource.getPropertyDescriptors(eObject)).orElse(new ArrayList<>());
propertyDescriptors.stream().map(propertyDescriptor -> propertyDescriptor.getFeature(eObject)).filter(EStructuralFeature.class::isInstance).map(EStructuralFeature.class::cast).forEach(objects::add);
// @formatter:on
}
return objects;
};
List<IfDescription> ifDescriptions = new ArrayList<>();
ifDescriptions.add(new EStringIfDescriptionProvider(this.composedAdapterFactory, this.propertiesValidationProvider).getIfDescription());
ifDescriptions.add(new EBooleanIfDescriptionProvider(this.composedAdapterFactory, this.propertiesValidationProvider).getIfDescription());
ifDescriptions.add(new EEnumIfDescriptionProvider(this.composedAdapterFactory, this.propertiesValidationProvider).getIfDescription());
ifDescriptions.add(new MonoValuedNonContainmentReferenceIfDescriptionProvider(this.composedAdapterFactory, this.objectService, this.propertiesValidationProvider).getIfDescription());
ifDescriptions.add(new MultiValuedNonContainmentReferenceIfDescriptionProvider(this.composedAdapterFactory, this.objectService, this.propertiesValidationProvider).getIfDescription());
// @formatter:off
var numericDataTypes = List.of(EcorePackage.Literals.EINT, EcorePackage.Literals.EINTEGER_OBJECT, EcorePackage.Literals.EDOUBLE, EcorePackage.Literals.EDOUBLE_OBJECT, EcorePackage.Literals.EFLOAT, EcorePackage.Literals.EFLOAT_OBJECT, EcorePackage.Literals.ELONG, EcorePackage.Literals.ELONG_OBJECT, EcorePackage.Literals.ESHORT, EcorePackage.Literals.ESHORT_OBJECT);
// @formatter:on
for (var dataType : numericDataTypes) {
ifDescriptions.add(new NumberIfDescriptionProvider(dataType, this.composedAdapterFactory, this.propertiesValidationProvider, this.emfMessageService).getIfDescription());
}
// @formatter:off
ForDescription forDescription = // $NON-NLS-1$
ForDescription.newForDescription("forId").iterator(ESTRUCTURAL_FEATURE).iterableProvider(iterableProvider).ifDescriptions(ifDescriptions).build();
// @formatter:on
controlDescriptions.add(forDescription);
// @formatter:off
return // $NON-NLS-1$
GroupDescription.newGroupDescription("groupId").idProvider(// $NON-NLS-1$
variableManager -> "Core Properties").labelProvider(// $NON-NLS-1$
variableManager -> "Core Properties").semanticElementsProvider(variableManager -> Collections.singletonList(variableManager.getVariables().get(VariableManager.SELF))).controlDescriptions(controlDescriptions).build();
// @formatter:on
}
use of org.eclipse.sirius.components.forms.description.AbstractControlDescription in project sirius-components by eclipse-sirius.
the class GroupDescriptionConverter method convert.
public GroupDescription convert(org.eclipse.sirius.properties.GroupDescription siriusGroupDescription, Map<org.eclipse.sirius.properties.GroupDescription, GroupDescription> siriusGroup2SiriusWebGroup) {
ControlDescriptionConverter controlDescriptionConverter = new ControlDescriptionConverter(this.interpreter, this.objectService, this.identifierProvider, this.modelOperationHandlerSwitchProvider);
Function<VariableManager, String> idProvider = variableManager -> String.valueOf(siriusGroup2SiriusWebGroup.size());
// $NON-NLS-1$
StringValueProvider labelProvider = new StringValueProvider(this.interpreter, Optional.ofNullable(siriusGroupDescription.getLabelExpression()).orElse(""));
// @formatter:off
List<AbstractControlDescription> controlDescriptions = siriusGroupDescription.getControls().stream().flatMap(controlDescription -> controlDescriptionConverter.convert(controlDescription).stream()).collect(Collectors.toUnmodifiableList());
GroupDescription groupDescription = GroupDescription.newGroupDescription(this.identifierProvider.getIdentifier(siriusGroupDescription)).idProvider(idProvider).labelProvider(labelProvider).semanticElementsProvider(variableManager -> Collections.singletonList(variableManager.getVariables().get(VariableManager.SELF))).controlDescriptions(controlDescriptions).build();
// @formatter:on
siriusGroup2SiriusWebGroup.put(siriusGroupDescription, groupDescription);
return groupDescription;
}
use of org.eclipse.sirius.components.forms.description.AbstractControlDescription in project sirius-web by eclipse-sirius.
the class RepresentationsDescriptionProvider method getGroupDescription.
private GroupDescription getGroupDescription() {
List<AbstractControlDescription> controlDescriptions = new ArrayList<>();
// @formatter:off
ListDescription listDescription = // $NON-NLS-1$
ListDescription.newListDescription("RepresentationsList").idProvider(new WidgetIdProvider()).labelProvider(// $NON-NLS-1$
(variableManager) -> "Representations").itemsProvider(this.getItemsProvider()).itemIdProvider(this.getItemIdProvider()).itemLabelProvider(this.getItemLabelProvider()).itemImageURLProvider(this.getItemImageURLProvider()).itemDeletableProvider(this.getItemDeletableProvider()).itemDeleteHandlerProvider(this.getItemDeleteHandlerProvider()).itemKindProvider(this.getItemKindProvider()).diagnosticsProvider((variableManager) -> List.of()).kindProvider(// $NON-NLS-1$
(object) -> "").messageProvider(// $NON-NLS-1$
(object) -> "").build();
// @formatter:on
controlDescriptions.add(listDescription);
// @formatter:off
return // $NON-NLS-1$
GroupDescription.newGroupDescription("representationsGroupId").idProvider(// $NON-NLS-1$
variableManager -> "Representations Group").labelProvider(// $NON-NLS-1$
variableManager -> "Representations Group").semanticElementsProvider(variableManager -> Collections.singletonList(variableManager.getVariables().get(VariableManager.SELF))).controlDescriptions(controlDescriptions).build();
// @formatter:on
}
Aggregations