diff --git a/java/bundles/org.eclipse.set.nattable.utils/.classpath b/java/bundles/org.eclipse.set.nattable.utils/.classpath index 375961e4d6..7b6771245f 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/.classpath +++ b/java/bundles/org.eclipse.set.nattable.utils/.classpath @@ -1,5 +1,6 @@ + diff --git a/java/bundles/org.eclipse.set.nattable.utils/META-INF/MANIFEST.MF b/java/bundles/org.eclipse.set.nattable.utils/META-INF/MANIFEST.MF index f3c8fd677f..18da6b47fe 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/META-INF/MANIFEST.MF +++ b/java/bundles/org.eclipse.set.nattable.utils/META-INF/MANIFEST.MF @@ -7,8 +7,12 @@ Automatic-Module-Name: org.eclipse.set.nattable.utils Bundle-RequiredExecutionEnvironment: JavaSE-21 Bundle-Vendor: Eclipse Signalling Engineering Toolbox Bundle-ActivationPolicy: lazy +Bundle-ClassPath: hyph/, + . Export-Package: org.eclipse.set.nattable.utils -Import-Package: org.eclipse.nebula.widgets.nattable.config;version="1.5.0", +Import-Package: com.google.common.collect, + org.apache.fop.hyphenation, + org.eclipse.nebula.widgets.nattable.config;version="1.5.0", org.eclipse.nebula.widgets.nattable.export;version="1.5.0", org.eclipse.nebula.widgets.nattable.export.command;version="1.5.0", org.eclipse.nebula.widgets.nattable.export.csv;version="1.5.0", diff --git a/java/bundles/org.eclipse.set.nattable.utils/build.properties b/java/bundles/org.eclipse.set.nattable.utils/build.properties index 34d2e4d2da..39ffddba03 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/build.properties +++ b/java/bundles/org.eclipse.set.nattable.utils/build.properties @@ -1,4 +1,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - . + .,\ + hyph/ diff --git a/java/bundles/org.eclipse.set.nattable.utils/hyph/de.hyp b/java/bundles/org.eclipse.set.nattable.utils/hyph/de.hyp new file mode 100644 index 0000000000..5deefad0a0 Binary files /dev/null and b/java/bundles/org.eclipse.set.nattable.utils/hyph/de.hyp differ diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/Hyphenator.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/Hyphenator.java new file mode 100644 index 0000000000..ab483ce0c7 --- /dev/null +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/Hyphenator.java @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2026 DB InfraGO AG and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + */ +package org.eclipse.set.nattable.utils; + +import java.io.ObjectInputStream; + +import org.apache.fop.hyphenation.Hyphenation; +import org.apache.fop.hyphenation.HyphenationTree; + +/** + * + */ +public class Hyphenator { + HyphenationTree hyphenation; + + /** + * @param hyphenationTree + * the {@link HyphenationTree} + */ + public Hyphenator(final HyphenationTree hyphenationTree) { + hyphenation = hyphenationTree; + } + + /** + * @param word + * the word to hyphenate + * @return the split index + */ + public int[] points(final String word) { + final Hyphenation hyphenate = hyphenation.hyphenate(word, 2, 2); + return hyphenate == null ? new int[0] + : hyphenate.getHyphenationPoints(); + } + + /** + * @param word + * the word to hyphenate + * @return the split words + */ + public String[] splitedWord(final String word) { + final int[] points = points(word); + final String[] splitWords = new String[points.length + 1]; + int startIndex = 0; + for (int i = 0; i < points.length; i++) { + splitWords[i] = word.substring(startIndex, points[i]); + startIndex = points[i]; + } + splitWords[points.length] = word.substring(startIndex, word.length()); + return splitWords; + } + + /** + * @return the {@link Hyphenator} + */ + public static Hyphenator createInstance() { + try (var inputStream = Hyphenator.class.getClassLoader() + .getResourceAsStream("hyph/de.hyp")) { //$NON-NLS-1$ + final ObjectInputStream objectInputStream = new ObjectInputStream( + inputStream); + if (objectInputStream + .readObject() instanceof final HyphenationTree hyphenationTree) { + return new Hyphenator(hyphenationTree); + } + throw new IllegalArgumentException("Can't create Hyphenator"); //$NON-NLS-1$ + } catch (final Exception e) { + throw new IllegalArgumentException("Can't create Hyphenator"); //$NON-NLS-1$ + } + + } +} diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextCellPainter.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextCellPainter.java index d3a34f177d..05f29bb015 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextCellPainter.java +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextCellPainter.java @@ -43,7 +43,8 @@ public PlanProRichTextCellPainter(final boolean wrapText, final boolean calculateByTextLength, final boolean calculateByTextHeight) { super(wrapText, calculateByTextLength, calculateByTextHeight); - richTextPainter.setWordSplitRegex(WORD_SPLIT_REGEX); + this.richTextPainter = new PlanProRichTextPainter(wrapText); + this.richTextPainter.setWordSplitRegex(WORD_SPLIT_REGEX); } @Override diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextPainter.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextPainter.java new file mode 100644 index 0000000000..03cc448314 --- /dev/null +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProRichTextPainter.java @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2026 DB InfraGO AG and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + */ +package org.eclipse.set.nattable.utils; + +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.events.Characters; +import javax.xml.stream.events.XMLEvent; + +import org.eclipse.nebula.widgets.richtext.RichTextPainter; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; + +/** + * + */ +public class PlanProRichTextPainter extends RichTextPainter { + private static String HYPHENATION_SEPARATOR = "-"; //$NON-NLS-1$ + private static String RICHTEXT_LINE_BREAK = "

"; //$NON-NLS-1$ + XMLInputFactory factory = XMLInputFactory.newInstance(); + { + // as we don't have a well-formed XML document, we need to take care + // of + // entity references ourself + factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, + Boolean.FALSE); + } + Hyphenator hyphenator; + + /** + * @param wrap + */ + public PlanProRichTextPainter(final boolean wrap) { + super(wrap); + hyphenator = Hyphenator.createInstance(); + } + + @Override + protected void paintHTML(final String html, final GC gc, + final Rectangle bounds, final boolean render) { + try { + final String cleanedHTML = html + .replaceAll(RichTextPainter.CONTROL_CHARACTER_REGEX, ""); //$NON-NLS-1$ + final XMLEventReader reader = factory + .createXMLEventReader(new StringReader(cleanedHTML)); + String newHtmlText = html; + while (reader.hasNext()) { + final XMLEvent event = reader.nextEvent(); + if (event.getEventType() == XMLStreamConstants.CHARACTERS) { + final Characters asCharacters = event.asCharacters(); + final String textValue = asCharacters.getData(); + final String hyphenationText = hyphenationText(textValue, + gc, bounds.width); + newHtmlText = html.replace(textValue, hyphenationText); + } + } + super.paintHTML(newHtmlText, gc, bounds, render); + } catch (final Exception e) { + super.paintHTML(html, gc, bounds, render); + } + } + + /** + * @param text + * the text to hyphenation + * @param gc + * the {@link GC} + * @param availableLength + * the available length + * @return the hyphenated text + */ + public String hyphenationText(final String text, final GC gc, + final int availableLength) { + if (gc.textExtent(text).x <= availableLength) { + return text; + } + final StringBuilder result = new StringBuilder(); + final Matcher matcher = Pattern.compile("\\S+|\\s+").matcher(text); + while (matcher.find()) { + final String word = matcher.group(); + if (Character.isWhitespace(word.charAt(0))) { + // Keep original whitespace character + result.append(word); + } else { + result.append(hyphenationText(word, gc, availableLength, "_")); //$NON-NLS-1$ + } + } + return result.toString(); + } + + private String hyphenationText(final String text, final GC gc, + final int availableLength, final String seperator) { + final String[] words = text.split(seperator); + if (words.length == 1) { + if (gc.textExtent(text).x > availableLength) { + return splitWord(gc, text, availableLength).stream() + .collect(Collectors.joining( + HYPHENATION_SEPARATOR + RICHTEXT_LINE_BREAK)); + } + return text; + } + final StringBuilder result = new StringBuilder(); + final int separatorW = gc.textExtent(seperator).x; + int lineWidth = 0; + for (int i = 0; i < words.length; i++) { + final int w = gc.textExtent(words[i]).x; + if (lineWidth + separatorW + w > availableLength) { + // Add line break instead hyphenation, when word length relevant + if (separatorW + w <= availableLength) { + result.append(RICHTEXT_LINE_BREAK).append(words[i]); + lineWidth = w; + } else { + int rest = availableLength - lineWidth - separatorW; + if (rest <= 0) { + result.append(RICHTEXT_LINE_BREAK); + rest = availableLength; + lineWidth = 0; + } + final List hyphenatedWord = splitWord(gc, words[i], + rest); + result.append(hyphenatedWord.stream() + .collect(Collectors.joining(HYPHENATION_SEPARATOR + + RICHTEXT_LINE_BREAK))); + lineWidth = gc.textExtent(hyphenatedWord.getLast()).x; + } + } else { + result.append(words[i]); + lineWidth += w; + } + + if (i < words.length - 1) { + lineWidth += separatorW; + result.append(seperator); + } + } + return result.toString(); + + } + + private List splitWord(final GC gc, final String word, + final int rest) { + final String[] splitdWord = hyphenator.splitedWord(word); + final List hyphenatedWord = new ArrayList<>(); + StringBuilder builder = new StringBuilder(); + for (final String w : splitdWord) { + final String tmpW = builder.toString() + w; + if (builder.length() > 0 + && gc.textExtent(tmpW + HYPHENATION_SEPARATOR).x > rest) { + hyphenatedWord.add(builder.toString()); + builder = new StringBuilder(w); + } else { + builder.append(w); + } + } + + if (builder.length() > 0 || hyphenatedWord.isEmpty()) { + hyphenatedWord.add(builder.toString()); + } + + return hyphenatedWord; + + } +} \ No newline at end of file diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java index 4701f39170..4bbce3afeb 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 DB Netz AG and others. + * Copyright (c) 2017 DB Netz AG and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -39,18 +39,27 @@ public class PlanProTableCellPainter extends BackgroundPainter { public PlanProTableCellPainter(final ICellPainter interiorPainter, final Image yellowWarningImage, final Image redWarningImage, final Image blackWarningImage) { - super(new PaddingDecorator(new BasePainterDecorator( - new BasePainterDecorator(new BasePainterDecorator( - interiorPainter, BaseEdgeEnum.BEFORE, - new WarningPainter(redWarningImage, - CellContentExtensions.WARNING_MARK_RED)), - BaseEdgeEnum.BEFORE, - new WarningPainter(blackWarningImage, - CellContentExtensions.WARNING_MARK_BLACK)), - BaseEdgeEnum.BEFORE, - new WarningPainter(yellowWarningImage, - CellContentExtensions.WARNING_MARK_YELLOW)), - TOP_PADDING, RIGHT_PADDING, BOTTOM_PADDING, LEFT_PADDING, + super(new PaddingDecorator( // + new BasePainterDecorator( // + new BasePainterDecorator( // + new BasePainterDecorator( // + interiorPainter, // + BaseEdgeEnum.BEFORE, + new WarningPainter(redWarningImage, + CellContentExtensions.WARNING_MARK_RED) // + ), // + BaseEdgeEnum.BEFORE, // + new WarningPainter(blackWarningImage, + CellContentExtensions.WARNING_MARK_BLACK) // + ), // + BaseEdgeEnum.BEFORE, // + new WarningPainter(yellowWarningImage, + CellContentExtensions.WARNING_MARK_YELLOW) // + ), // + TOP_PADDING, // + RIGHT_PADDING, // + BOTTOM_PADDING, // + LEFT_PADDING, // false)); } } diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/.classpath b/java/java-test/org.eclipse.set.nattable.utils.test/.classpath new file mode 100644 index 0000000000..e221e25d34 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/.project b/java/java-test/org.eclipse.set.nattable.utils.test/.project new file mode 100644 index 0000000000..08ddc7eddd --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/.project @@ -0,0 +1,28 @@ + + + org.eclipse.set.nattable.utils.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.core.resources.prefs b/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.jdt.core.prefs b/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..23fa13b170 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/META-INF/MANIFEST.MF b/java/java-test/org.eclipse.set.nattable.utils.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..fe7923a6e8 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Nattable Utils Test +Bundle-SymbolicName: org.eclipse.set.nattable.utils.test +Bundle-Version: 2.7.0.qualifier +Fragment-Host: org.eclipse.set.nattable.utils +Automatic-Module-Name: org.eclipse.set.nattable.utils.test +Bundle-ClassPath: hyph/, + . +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Import-Package: net.bytebuddy;version="[1.17.0,2.0.0)", + net.bytebuddy.agent;version="[1.17.0,2.0.0)", + org.junit.jupiter.api, + org.junit.jupiter.api.function, + org.junit.jupiter.params, + org.junit.jupiter.params.provider +Require-Bundle: org.mockito.mockito-core diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/build.properties b/java/java-test/org.eclipse.set.nattable.utils.test/build.properties new file mode 100644 index 0000000000..39ffddba03 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + hyph/ diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/hyph/de.hyp b/java/java-test/org.eclipse.set.nattable.utils.test/hyph/de.hyp new file mode 100644 index 0000000000..5deefad0a0 Binary files /dev/null and b/java/java-test/org.eclipse.set.nattable.utils.test/hyph/de.hyp differ diff --git a/java/java-test/org.eclipse.set.nattable.utils.test/src/org/eclipse/set/nattable/utils/test/PlanProRichTextPainterTest.java b/java/java-test/org.eclipse.set.nattable.utils.test/src/org/eclipse/set/nattable/utils/test/PlanProRichTextPainterTest.java new file mode 100644 index 0000000000..d3f9ec1f70 --- /dev/null +++ b/java/java-test/org.eclipse.set.nattable.utils.test/src/org/eclipse/set/nattable/utils/test/PlanProRichTextPainterTest.java @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2026 DB InfraGO AG and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + */ +package org.eclipse.set.nattable.utils.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.stream.Stream; + +import org.apache.fop.hyphenation.HyphenationTree; +import org.eclipse.set.nattable.utils.Hyphenator; +import org.eclipse.set.nattable.utils.PlanProRichTextPainter; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentMatchers; +import org.mockito.MockedStatic; +import org.mockito.Mockito; + +/** + * + */ +@SuppressWarnings("boxing") +public class PlanProRichTextPainterTest { + + private static Stream getTestSpecialString() { + return Stream.of(Arguments.of("a b\tc\n", "a b\tc\n", 2), + Arguments.of("123456789", "123456789", 3)); + } + + private static Stream getTestStringWithOutSeparator() { + return Stream.of( + Arguments.of("Aussenelementansteuerung", + "Aussenelementansteuerung", 30), + Arguments.of("Aussenelementansteuerung", + "Aussenelement-

ansteuerung", 14), + Arguments.of("Aussenelementansteuerung", + "Aussen-

element-

ansteue-

rung", + 8), + Arguments.of("Aussenelementansteuerung", + "Aussenelementansteue-

rung", 22)); + } + + private static Stream getTestStringWithUnterlineSeparator() { + return Stream.of( + Arguments.of("Aus_sen_element_ansteue_rung", + "Aus_sen_element_

ansteue_rung", 17), + Arguments.of( + "Aussenelementansteuerung_Aussenelementansteuerung", + "Aussenelemen-

tansteuerung_

Aussenelement-

ansteuerung", + 14)); + } + + GC gc; + + String hyphenatedStr; + + Hyphenator hyphenator; + + PlanProRichTextPainter testee; + + private void thenExpectEqual(final String expect) { + assertEquals(expect, hyphenatedStr); + } + + private void whenHyphenateText(final String origin, + final int avaiableLength) { + hyphenatedStr = testee.hyphenationText(origin, gc, avaiableLength); + } + + void givenGC() { + gc = Mockito.mock(GC.class); + Mockito.when(gc.textExtent(ArgumentMatchers.anyString())) + .thenAnswer(invocate -> { + if (invocate.getArgument(0) instanceof final String word) { + return new Point(word.length(), 0); + } + throw new IllegalArgumentException(); + }); + } + + void givenHyphenator() + throws FileNotFoundException, IOException, ClassNotFoundException { + try (var fileInputStream = new FileInputStream( + new File("hyph/de.hyp"))) { + final ObjectInputStream objectInputStream = new ObjectInputStream( + fileInputStream); + if (objectInputStream + .readObject() instanceof final HyphenationTree hyphenationTree) { + hyphenator = new Hyphenator(hyphenationTree); + } + } + } + + void givenPlanProRichTextPainter() { + testee = new PlanProRichTextPainter(false); + } + + @ParameterizedTest + @MethodSource("getTestSpecialString") + void testHyphenationSpeicalText(final String origin, final String expect, + final int availableLength) + throws FileNotFoundException, ClassNotFoundException, IOException { + givenHyphenator(); + try (MockedStatic mockStatic = Mockito + .mockStatic(Hyphenator.class)) { + mockStatic.when(Hyphenator::createInstance).thenReturn(hyphenator); + givenPlanProRichTextPainter(); + givenGC(); + whenHyphenateText(origin, availableLength); + thenExpectEqual(expect); + } + } + + @Test + void testHyphenationTextDoesNotEmitEmptyFragmentWhenRestIsNegative() + throws FileNotFoundException, ClassNotFoundException, IOException { + givenHyphenator(); + try (MockedStatic mockStatic = Mockito + .mockStatic(Hyphenator.class)) { + mockStatic.when(Hyphenator::createInstance).thenReturn(hyphenator); + givenPlanProRichTextPainter(); + givenGC(); + whenHyphenateText("foo_Aussenelementansteuerung", 4); + assertFalse(hyphenatedStr.startsWith("-

")); + } + } + + @ParameterizedTest + @MethodSource("getTestStringWithOutSeparator") + void testHyphenationTextWithoutSeperator(final String origin, + final String expect, final int avaiableLength) + throws FileNotFoundException, ClassNotFoundException, IOException { + givenHyphenator(); + try (MockedStatic mockStatic = Mockito + .mockStatic(Hyphenator.class)) { + mockStatic.when(Hyphenator::createInstance).thenReturn(hyphenator); + givenPlanProRichTextPainter(); + givenGC(); + whenHyphenateText(origin, avaiableLength); + thenExpectEqual(expect); + } + } + + @ParameterizedTest + @MethodSource("getTestStringWithUnterlineSeparator") + void testHyphenationTextWithUnterline(final String origin, + final String expect, final int avaiableLength) + throws FileNotFoundException, ClassNotFoundException, IOException { + givenHyphenator(); + try (MockedStatic mockStatic = Mockito + .mockStatic(Hyphenator.class)) { + mockStatic.when(Hyphenator::createInstance).thenReturn(hyphenator); + givenPlanProRichTextPainter(); + givenGC(); + whenHyphenateText(origin, avaiableLength); + thenExpectEqual(expect); + } + } +} diff --git a/java/java-test/pom.xml b/java/java-test/pom.xml index cd84912775..9164074fbf 100644 --- a/java/java-test/pom.xml +++ b/java/java-test/pom.xml @@ -21,6 +21,15 @@ ${project.parent.version} + + default + + true + + + org.eclipse.set.nattable.utils.test + + swtbot