Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1281] Add support for Link widget in Form representation
Bug: #1281 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
- Loading branch information
1 parent
47679f7
commit 12b8e96
Showing
41 changed files
with
3,679 additions
and
28 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
61 changes: 61 additions & 0 deletions
61
...ents-emf/src/main/java/org/eclipse/sirius/components/emf/view/form/LinkStyleProvider.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,61 @@ | ||
/******************************************************************************* | ||
* 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.emf.view.form; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.sirius.components.forms.LinkStyle; | ||
import org.eclipse.sirius.components.forms.LinkStyle.Builder; | ||
import org.eclipse.sirius.components.representations.VariableManager; | ||
import org.eclipse.sirius.components.view.LinkDescriptionStyle; | ||
|
||
/** | ||
* The style provider for the Link Description widget of the View DSL. | ||
* | ||
* @author fbarbin | ||
*/ | ||
public class LinkStyleProvider implements Function<VariableManager, LinkStyle> { | ||
|
||
private final LinkDescriptionStyle viewStyle; | ||
|
||
public LinkStyleProvider(LinkDescriptionStyle viewStyle) { | ||
this.viewStyle = Objects.requireNonNull(viewStyle); | ||
} | ||
|
||
@Override | ||
public LinkStyle apply(VariableManager variableManager) { | ||
Builder linkStyleBuilder = LinkStyle.newLinkStyle(); | ||
|
||
String color = this.viewStyle.getColor(); | ||
if (color != null && !color.isBlank()) { | ||
linkStyleBuilder.color(color); | ||
} | ||
int fontSize = this.viewStyle.getFontSize(); | ||
boolean italic = this.viewStyle.isItalic(); | ||
boolean bold = this.viewStyle.isBold(); | ||
boolean underline = this.viewStyle.isUnderline(); | ||
boolean strikeThrough = this.viewStyle.isStrikeThrough(); | ||
|
||
// @formatter:off | ||
return linkStyleBuilder | ||
.fontSize(fontSize) | ||
.italic(italic) | ||
.bold(bold) | ||
.underline(underline) | ||
.strikeThrough(strikeThrough) | ||
.build(); | ||
// @formatter:on | ||
} | ||
|
||
} |
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
Oops, something went wrong.