org.fxmisc.richtext.GenericStyledArea Java Examples
The following examples show how to use
org.fxmisc.richtext.GenericStyledArea.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RichTextFXGenericStyledTextaAreaElementTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void clear() { GenericStyledArea codeAreaNode = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); Platform.runLater(() -> { codeArea.marathon_select("Hello World"); }); new Wait("Waiting for the text area value to be set") { @Override public boolean until() { return "Hello World".equals(codeAreaNode.getText()); } }; codeArea.clear(); new Wait("Waiting for the text area value to be cleared") { @Override public boolean until() { return "".equals(codeAreaNode.getText()); } }; }
Example #2
Source File: RFXGenericStyledTextAreaTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void getText() { final GenericStyledArea textArea = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); LoggingRecorder lr = new LoggingRecorder(); List<Object> text = new ArrayList<>(); Platform.runLater(() -> { RFXComponent rca = new RFXGenericStyledArea(textArea, null, null, lr); textArea.appendText("Hello World"); rca.focusLost(null); text.add(rca.getAttribute("text")); }); new Wait("Waiting for text area text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("Hello World", text.get(0)); }
Example #3
Source File: RFXGenericStyledTextAreaTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void selectWithSpecialChars() throws InterruptedException { final GenericStyledArea codeArea = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); Platform.runLater(new Runnable() { @Override public void run() { codeArea.appendText("Hello\n World'\""); } }); LoggingRecorder lr = new LoggingRecorder(); RFXComponent rTextField = new RFXGenericStyledArea(codeArea, null, null, lr); Platform.runLater(new Runnable() { @Override public void run() { rTextField.focusLost(null); } }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording select = recordings.get(0); AssertJUnit.assertEquals("recordSelect", select.getCall()); AssertJUnit.assertEquals("Hello\n World'\"", select.getParameters()[0]); }
Example #4
Source File: RFXGenericStyledTextAreaTest.java From marathonv5 with Apache License 2.0 | 6 votes |
@Test public void selectWithUtf8Chars() throws InterruptedException { final GenericStyledArea codeArea = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); Platform.runLater(new Runnable() { @Override public void run() { codeArea.appendText("å∫ç∂´ƒ©˙ˆ∆"); } }); LoggingRecorder lr = new LoggingRecorder(); RFXComponent rTextField = new RFXGenericStyledArea(codeArea, null, null, lr); Platform.runLater(new Runnable() { @Override public void run() { rTextField.focusLost(null); } }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording select = recordings.get(0); AssertJUnit.assertEquals("recordSelect", select.getCall()); AssertJUnit.assertEquals("å∫ç∂´ƒ©˙ˆ∆", select.getParameters()[0]); }
Example #5
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 6 votes |
/** * Returns an UndoManager with an unlimited history that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change after {@code preventMergeDelay}. * <p><b>Note</b>: that <u>only styling changes</u> may occur <u>during suspension</u> of the undo manager. */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextSuspendableUndoManager( GenericStyledArea<PS, SEG, S> area, Duration preventMergeDelay, SuspendableYes suspendUndo) { RichTextChange.skipStyleComparison( true ); return new MultiChangeUndoManagerImpl<> ( new UnlimitedChangeQueue<>(), TextChange::invert, applyMultiRichTextChange(area), TextChange::mergeWith, TextChange::isIdentity, area.multiRichChanges().conditionOn(suspendUndo), preventMergeDelay ); }
Example #6
Source File: Utils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
public static int entityEnd(int entityIndex, String[] array, GenericStyledArea<?, ?, ?> area) { if (entityIndex == array.length - 1) { return area.getLength(); } else { return entityStart(entityIndex + 1, array) - 1; } }
Example #7
Source File: RichTextFXGenericStyledTextaAreaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void marathon_select() { GenericStyledArea codeAreaNode = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); Platform.runLater(() -> { codeArea.marathon_select("Hello World"); }); new Wait("Waiting for the text area value to be set") { @Override public boolean until() { return "Hello World".equals(codeAreaNode.getText()); } }; }
Example #8
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
private static void moveToChange( GenericStyledArea area, TextChange chg ) { int pos = chg.getPosition(); int len = chg.getNetLength(); if ( len > 0 ) pos += len; area.moveTo( Math.min( pos, area.getLength() ) ); }
Example #9
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Applies a list of {@link RichTextChange} to the given area when the {@link UndoManager}'s change stream emits * an event by {@code area.replaceAbsolutely(change.getPosition(), change.getRemovalEnd(), change.getInserted()}. */ public static <PS, SEG, S> Consumer<List<RichTextChange<PS, SEG, S>>> applyMultiRichTextChange( GenericStyledArea<PS, SEG, S> area) { return changeList -> { MultiChangeBuilder<PS, SEG, S> builder = area.createMultiChange(changeList.size()); for (RichTextChange<PS, SEG, S> c : changeList) { builder.replaceAbsolutely(c.getPosition(), c.getRemovalEnd(), c.getInserted()); } builder.commit(); moveToChange( area, changeList.get( changeList.size()-1 ) ); }; }
Example #10
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Applies a list of {@link PlainTextChange}s to the given area when the {@link UndoManager}'s change stream emits * an event by {@code area.replaceAbsolutely(change.getPosition(), change.getRemovalEnd(), change.getInserted()}. */ public static <PS, SEG, S> Consumer<List<PlainTextChange>> applyMultiPlainTextChange( GenericStyledArea<PS, SEG, S> area) { return changeList -> { MultiChangeBuilder<PS, SEG, S> builder = area.createMultiChange(changeList.size()); for (PlainTextChange c : changeList) { builder.replaceTextAbsolutely(c.getPosition(), c.getRemovalEnd(), c.getInserted()); } builder.commit(); moveToChange( area, changeList.get( changeList.size()-1 ) ); }; }
Example #11
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Applies a {@link RichTextChange} to the given area when the {@link UndoManager}'s change stream emits an event * by {@code area.replace(change.getPosition(), change.getRemovalEnd(), change.getInserted()}. */ public static <PS, SEG, S> Consumer<RichTextChange<PS, SEG, S>> applyRichTextChange( GenericStyledArea<PS, SEG, S> area) { return change -> { area.replace(change.getPosition(), change.getRemovalEnd(), change.getInserted()); moveToChange( area, change ); }; }
Example #12
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Applies a {@link PlainTextChange} to the given area when the {@link UndoManager}'s change stream emits an event * by {@code area.replaceText(change.getPosition(), change.getRemovalEnd(), change.getInserted()}. */ public static <PS, SEG, S> Consumer<PlainTextChange> applyPlainTextChange(GenericStyledArea<PS, SEG, S> area) { return change -> { area.replaceText(change.getPosition(), change.getRemovalEnd(), change.getInserted()); moveToChange( area, change ); }; }
Example #13
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns an UndoManager that can undo/redo {@link PlainTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@code preventMergeDelay} */ public static <PS, SEG, S> UndoManager<List<PlainTextChange>> plainTextUndoManager( GenericStyledArea<PS, SEG, S> area, UndoManagerFactory factory, Duration preventMergeDelay) { return factory.createMultiChangeUM(area.multiPlainChanges(), TextChange::invert, applyMultiPlainTextChange(area), TextChange::mergeWith, TextChange::isIdentity, preventMergeDelay); }
Example #14
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns an UndoManager that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@code preventMergeDelay} */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextUndoManager( GenericStyledArea<PS, SEG, S> area, UndoManagerFactory factory, Duration preventMergeDelay) { return factory.createMultiChangeUM(area.multiRichChanges(), TextChange::invert, applyMultiRichTextChange(area), TextChange::mergeWith, TextChange::isIdentity, preventMergeDelay); }
Example #15
Source File: RichTextFXGenericStyledTextaAreaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
@Test public void getText() { GenericStyledArea codeAreaNode = (GenericStyledArea) getPrimaryStage().getScene().getRoot().lookup(".code-area"); AssertJUnit.assertEquals("", codeArea.getText()); Platform.runLater(() -> { codeArea.marathon_select("Hello World"); }); new Wait("Waiting for the text area value to be set") { @Override public boolean until() { return "Hello World".equals(codeAreaNode.getText()); } }; AssertJUnit.assertEquals("Hello World", codeArea.getText()); }
Example #16
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 4 votes |
/** * Constructs an UndoManager with an unlimited history: * if {@link GenericStyledArea#isPreserveStyle() the area's preserveStyle flag is true}, the returned UndoManager * can undo/redo multiple {@link RichTextChange}s; otherwise, it can undo/redo multiple {@link PlainTextChange}s. */ public static <PS, SEG, S> UndoManager defaultUndoManager(GenericStyledArea<PS, SEG, S> area) { return area.isPreserveStyle() ? richTextUndoManager(area) : plainTextUndoManager(area); }
Example #17
Source File: BulletFactory.java From RichTextFX with BSD 2-Clause "Simplified" License | 4 votes |
public BulletFactory( GenericStyledArea<ParStyle,?,?> area ) { this.area = area; }
Example #18
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager with an unlimited history that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change after {@link #DEFAULT_PREVENT_MERGE_DELAY} * <p><b>Note</b>: that <u>only styling changes</u> may occur <u>during suspension</u> of the undo manager. */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextSuspendableUndoManager( GenericStyledArea<PS, SEG, S> area, SuspendableYes suspendUndo) { return richTextSuspendableUndoManager(area, DEFAULT_PREVENT_MERGE_DELAY, suspendUndo); }
Example #19
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager with an unlimited history that can undo/redo {@link PlainTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@link #DEFAULT_PREVENT_MERGE_DELAY} */ public static <PS, SEG, S> UndoManager<List<PlainTextChange>> plainTextUndoManager( GenericStyledArea<PS, SEG, S> area) { return plainTextUndoManager(area, DEFAULT_PREVENT_MERGE_DELAY); }
Example #20
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager that can undo/redo {@link PlainTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@code preventMergeDelay} */ public static <PS, SEG, S> UndoManager<List<PlainTextChange>> plainTextUndoManager( GenericStyledArea<PS, SEG, S> area, Duration preventMergeDelay) { return plainTextUndoManager(area, UndoManagerFactory.unlimitedHistoryFactory(), preventMergeDelay); }
Example #21
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager that can undo/redo {@link PlainTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@link #DEFAULT_PREVENT_MERGE_DELAY} */ public static <PS, SEG, S> UndoManager<List<PlainTextChange>> plainTextUndoManager( GenericStyledArea<PS, SEG, S> area, UndoManagerFactory factory) { return plainTextUndoManager(area, factory, DEFAULT_PREVENT_MERGE_DELAY); }
Example #22
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@link #DEFAULT_PREVENT_MERGE_DELAY} */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextUndoManager( GenericStyledArea<PS, SEG, S> area, UndoManagerFactory factory) { return richTextUndoManager(area, factory, DEFAULT_PREVENT_MERGE_DELAY); }
Example #23
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@code preventMergeDelay} */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextUndoManager( GenericStyledArea<PS, SEG, S> area, Duration preventMergeDelay) { return richTextUndoManager(area, UndoManagerFactory.unlimitedHistoryFactory(), preventMergeDelay); }
Example #24
Source File: UndoUtils.java From RichTextFX with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns an UndoManager with an unlimited history that can undo/redo {@link RichTextChange}s. New changes * emitted from the stream will not be merged with the previous change * after {@link #DEFAULT_PREVENT_MERGE_DELAY} */ public static <PS, SEG, S> UndoManager<List<RichTextChange<PS, SEG, S>>> richTextUndoManager( GenericStyledArea<PS, SEG, S> area) { return richTextUndoManager(area, UndoManagerFactory.unlimitedHistoryFactory()); }