Skip to content

Commit

Permalink
Merge pull request #654 from Jugen/patch-1
Browse files Browse the repository at this point in the history
Add support for FXML (again)
  • Loading branch information
JordanMartinez committed Nov 24, 2017
2 parents 8619544 + 812e43e commit 08ff468
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
@@ -0,0 +1,28 @@
package org.fxmisc.richtext.api;

import java.io.IOException;
import javafx.stage.Stage;
import javafx.fxml.FXMLLoader;
import javafx.fxml.LoadException;
import org.fxmisc.richtext.RichTextFXTestBase;
import org.junit.Test;

public class FxmlTester extends RichTextFXTestBase {

@Override
public void start(Stage stage) throws Exception {
// Nothing needed here
}

@Test
public void test_fxml_construction_of_area() throws IOException, LoadException
{
// FxmlTest.fxml is located in resources folder:
// src/integrationTest/resources/org/fxmisc/richtext/api/
Object obj = FXMLLoader.load( getClass().getResource( "FxmlTest.fxml" ) );
// FXMLLoader will throw a LoadException if any properties failed to be set,
// so if obj is not null then all properties are guaranteed to have been set.
org.junit.Assert.assertNotNull( obj );
}

}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.VBox?>
<?import org.fxmisc.richtext.StyleClassedTextArea?>
<?import javafx.scene.control.ContextMenu?>
<?import javafx.scene.control.MenuItem?>

<VBox xmlns:fx="http://javafx.com/fxml/1">
<StyleClassedTextArea editable="true" wrapText="true" autoScrollOnDragDesired="true"
contextMenuXOffset="12.0" contextMenuYOffset="34.0" >
<contextMenu>
<ContextMenu>
<items><MenuItem text="Test Item" /></items>
</ContextMenu>
</contextMenu>
</StyleClassedTextArea>
</VBox>

Expand Up @@ -338,11 +338,17 @@ protected void invalidated() {
}
};
@Override public final BooleanProperty editableProperty() { return editable; }
// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setEditable(boolean value) { editable.set(value); }
@Override public boolean isEditable() { return editable.get(); }

// wrapText property
private final BooleanProperty wrapText = new SimpleBooleanProperty(this, "wrapText");
@Override public final BooleanProperty wrapTextProperty() { return wrapText; }

// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setWrapText(boolean value) { wrapText.set(value); }
@Override public boolean isWrapText() { return wrapText.get(); }

// undo manager
private UndoManager undoManager;
@Override public UndoManager getUndoManager() { return undoManager; }
Expand All @@ -359,14 +365,23 @@ protected void invalidated() {

private ObjectProperty<ContextMenu> contextMenu = new SimpleObjectProperty<>(null);
@Override public final ObjectProperty<ContextMenu> contextMenuObjectProperty() { return contextMenu; }
// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setContextMenu(ContextMenu menu) { contextMenu.set(menu); }
@Override public ContextMenu getContextMenu() { return contextMenu.get(); }

protected final boolean isContextMenuPresent() { return contextMenu.get() != null; }

private DoubleProperty contextMenuXOffset = new SimpleDoubleProperty(2);
@Override public final DoubleProperty contextMenuXOffsetProperty() { return contextMenuXOffset; }
// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setContextMenuXOffset(double offset) { contextMenuXOffset.set(offset); }
@Override public double getContextMenuXOffset() { return contextMenuXOffset.get(); }

private DoubleProperty contextMenuYOffset = new SimpleDoubleProperty(2);
@Override public final DoubleProperty contextMenuYOffsetProperty() { return contextMenuYOffset; }
// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setContextMenuYOffset(double offset) { contextMenuYOffset.set(offset); }
@Override public double getContextMenuYOffset() { return contextMenuYOffset.get(); }

private final BooleanProperty useInitialStyleForInsertion = new SimpleBooleanProperty();
@Override public BooleanProperty useInitialStyleForInsertionProperty() { return useInitialStyleForInsertion; }
Expand Down Expand Up @@ -430,6 +445,9 @@ protected void invalidated() {
// not a hook, but still plays a part in the default mouse behavior
private final BooleanProperty autoScrollOnDragDesired = new SimpleBooleanProperty(true);
@Override public final BooleanProperty autoScrollOnDragDesiredProperty() { return autoScrollOnDragDesired; }
// Don't remove as FXMLLoader doesn't recognise default methods !
@Override public void setAutoScrollOnDragDesired(boolean val) { autoScrollOnDragDesired.set(val); }
@Override public boolean isAutoScrollOnDragDesired() { return autoScrollOnDragDesired.get(); }

/* ********************************************************************** *
* *
Expand Down

0 comments on commit 08ff468

Please sign in to comment.