Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

Commit

Permalink
Rename FxmlNode as FxmlComponent for consistency
Browse files Browse the repository at this point in the history
And replicate that in doc, fixing the few issues that were lingering
  • Loading branch information
Tristan971 committed Aug 27, 2019
1 parent 870756e commit afed950
Show file tree
Hide file tree
Showing 39 changed files with 184 additions and 188 deletions.
2 changes: 1 addition & 1 deletion easyfxml-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Running _JavaFX_ mostly requires the X Virtual FrameBuffer (`xvfb`), but it is f

This images sets up basically all of what you might want.

It is invoked by [maven_clean_install.sh](maven) (which is on the path inside the image).
It is invoked using the entrypoint [easyfxml-maven](easyfxml-maven) (which is on the path inside the image).

That script wraps maven invocations with `xvfb-run` to ensure set-up and teardown of the
virtual desktop environment when building and most importantly testing.
Expand Down
2 changes: 1 addition & 1 deletion easyfxml-junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ are tested and for the most part using these features.

So, assuming a very minimal greeter window, let's test it:

![Hello World Sample Screenshot](../doc/images/sample-hello-world.png)
![Hello World Sample Screenshot](../easyfxml-samples/easyfxml-sample-hello-world/doc/sample-hello-world.png)

```java
@SpringBootTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public abstract class FxNodeTest extends ApplicationTest {
public abstract class FxmlComponentTest extends ApplicationTest {

protected final FxNodeAsyncQuery withNodes(Node... nodes) {
return FxNodeAsyncQuery.withNodes(nodes);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.springframework.stereotype.Component;

import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.form.user.view.userform.UserFormComponent;

@Component
Expand All @@ -37,7 +37,7 @@ protected String title() {
}

@Override
protected FxmlNode mainComponent() {
protected FxmlComponent mainComponent() {
return userFormComponent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

@Component
public class UserFormComponent implements FxmlNode {
public class UserFormComponent implements FxmlComponent {

@Override
public FxmlFile getFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void initialize() {
setOnClick(submitButton, this::submit);

Stream.of(firstnameComponent, lastnameComponent, birthdayComponent, emailComponent)
.map(field -> easyFxml.loadNode(field, VBox.class, FormFieldController.class))
.map(field -> easyFxml.load(field, VBox.class, FormFieldController.class))
.forEach(load -> load
.afterControllerLoaded(this::subscribeToField)
.afterNodeLoaded(fieldsBox.getChildren()::add)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

@Component
public class BirthdayComponent implements FxmlNode {
public class BirthdayComponent implements FxmlComponent {

public static final String BIRTHDATE_FIELD_NAME = "Birthdate";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

@Component
public class EmailComponent implements FxmlNode {
public class EmailComponent implements FxmlComponent {

public static final String EMAIL_FIELD_NAME = "Email address";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

@Component
public class FirstnameComponent implements FxmlNode {
public class FirstnameComponent implements FxmlComponent {

public static final String FIRST_NAME_FIELD_NAME = "First name";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

@Component
public class LastnameComponent implements FxmlNode {
public class LastnameComponent implements FxmlComponent {

public static final String LAST_NAME_FIELD_NAME = "Last name";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;
import moe.tristan.easyfxml.samples.form.user.model.ImmutableUserForm;
import moe.tristan.easyfxml.samples.form.user.model.UserCreationService;
import moe.tristan.easyfxml.samples.form.user.model.UserForm;

@SpringBootTest
@RunWith(SpringRunner.class)
public class UserFormComponentTest extends FxNodeTest {
public class UserFormComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -58,7 +58,7 @@ public class UserFormComponentTest extends FxNodeTest {

@Before
public void setUp() {
userFormPane = easyFxml.loadNode(userFormComponent).getNodeOrExceptionPane();
userFormPane = easyFxml.load(userFormComponent).getNodeOrExceptionPane();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;
import moe.tristan.easyfxml.model.fxml.FxmlLoadResult;

@SpringBootTest
@RunWith(SpringRunner.class)
public class BirthdayComponentTest extends FxNodeTest {
public class BirthdayComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -52,7 +52,7 @@ public class BirthdayComponentTest extends FxNodeTest {

@Before
public void setUp() {
final FxmlLoadResult<Pane, BirthdayController> load = easyFxml.loadNode(BirthdayComponent, Pane.class, BirthdayController.class);
final FxmlLoadResult<Pane, BirthdayController> load = easyFxml.load(BirthdayComponent, Pane.class, BirthdayController.class);
birthdayPane = load.getNodeOrExceptionPane();
birthdayController = load.getController().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;
import moe.tristan.easyfxml.model.fxml.FxmlLoadResult;

@SpringBootTest
@RunWith(SpringRunner.class)
public class EmailComponentTest extends FxNodeTest {
public class EmailComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -48,7 +48,7 @@ public class EmailComponentTest extends FxNodeTest {

@Before
public void setUp() {
final FxmlLoadResult<Pane, EmailController> load = easyFxml.loadNode(emailComponent, Pane.class, EmailController.class);
final FxmlLoadResult<Pane, EmailController> load = easyFxml.load(emailComponent, Pane.class, EmailController.class);
emailPane = load.getNodeOrExceptionPane();
emailController = load.getController().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;
import moe.tristan.easyfxml.model.fxml.FxmlLoadResult;

@SpringBootTest
@RunWith(SpringRunner.class)
public class FirstnameComponentTest extends FxNodeTest {
public class FirstnameComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -49,7 +49,7 @@ public class FirstnameComponentTest extends FxNodeTest {

@Before
public void setUp() {
final FxmlLoadResult<Pane, FirstnameController> load = easyFxml.loadNode(firstnameComponent, Pane.class, FirstnameController.class);
final FxmlLoadResult<Pane, FirstnameController> load = easyFxml.load(firstnameComponent, Pane.class, FirstnameController.class);
firstnamePane = load.getNodeOrExceptionPane();
firstnameController = load.getController().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;
import moe.tristan.easyfxml.model.fxml.FxmlLoadResult;

@SpringBootTest
@RunWith(SpringRunner.class)
public class LastnameComponentTest extends FxNodeTest {
public class LastnameComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -48,7 +48,7 @@ public class LastnameComponentTest extends FxNodeTest {

@Before
public void setUp() {
final FxmlLoadResult<Pane, LastnameController> load = easyFxml.loadNode(lastnameComponent, Pane.class, LastnameController.class);
final FxmlLoadResult<Pane, LastnameController> load = easyFxml.load(lastnameComponent, Pane.class, LastnameController.class);
lastnamePane = load.getNodeOrExceptionPane();
lastnameController = load.getController().get();
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javafx.stage.Stage;

import moe.tristan.easyfxml.FxUiManager;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;
import moe.tristan.easyfxml.samples.helloworld.view.hello.HelloComponent;

public class HelloWorldUiManager extends FxUiManager {
Expand All @@ -42,7 +42,7 @@ protected String title() {
* @return the component to load as the root view in your main {@link Stage}.
*/
@Override
protected FxmlNode mainComponent() {
protected FxmlComponent mainComponent() {
return helloComponent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import moe.tristan.easyfxml.api.FxmlController;
import moe.tristan.easyfxml.api.FxmlFile;
import moe.tristan.easyfxml.api.FxmlNode;
import moe.tristan.easyfxml.api.FxmlComponent;

public class HelloComponent implements FxmlNode {
public class HelloComponent implements FxmlComponent {

@Override
public FxmlFile getFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import javafx.scene.layout.Pane;

import moe.tristan.easyfxml.EasyFxml;
import moe.tristan.easyfxml.junit.FxNodeTest;
import moe.tristan.easyfxml.junit.FxmlComponentTest;

@SpringBootTest
@RunWith(SpringRunner.class)
public class HelloComponentTest extends FxNodeTest {
public class HelloComponentTest extends FxmlComponentTest {

@Autowired
private EasyFxml easyFxml;
Expand All @@ -46,7 +46,7 @@ public class HelloComponentTest extends FxNodeTest {

@Before
public void setUp() {
this.helloPane = easyFxml.loadNode(helloComponent).getNodeOrExceptionPane();
this.helloPane = easyFxml.load(helloComponent).getNodeOrExceptionPane();
}

@Test
Expand Down
22 changes: 10 additions & 12 deletions easyfxml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ should not be an issue.
The idea of EasyFXML is to adopt the industry-standard MVC model for UI components and apply it to _JavaFX_.
This allows easier separation of concerns and lifecycle management of these components inside applications.

There are thus three core elements that go into a UI component (an **[`FxmlNode`](src/main/java/moe/tristan/easyfxml/api/FxmlNode.java)** hereafter):
There are thus three core elements that go into a UI component (an **[`FxmlComponent`](src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java)** hereafter):
- For the **M**odel, it is simple as your standard classes are just provided and usable via Java itself, and services and other more complex things
can be injected via _Spring_'s autowiring system.
- The **V**iew, a standard `.fxml` file in the form of an **[`FxmlFile`](src/main/java/moe/tristan/easyfxml/api/FxmlFile.java)**
Expand All @@ -44,31 +44,29 @@ So, let's see how building a very minimal greeter window, like follows, would wo
![Hello World Sample Screenshot](../easyfxml-samples/easyfxml-sample-hello-world/doc/sample-hello-world.png)

For this you will need:
- The component's `FxmlNode`
- The component's `FxmlComponent`
- An entrypoint for the UI
- A main class

##### Component ([`FxmlNode`](../easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlNode.java))
##### Component ([`FxmlComponent`](src/main/java/moe/tristan/easyfxml/api/FxmlComponent.java))
```java
@Component
public class HelloComponent implements FxmlNode {
public class HelloComponent implements FxmlComponent {

@Override
public FxmlFile getFile() {
return () -> "my/package/view/hello/HelloView.fxml";
// component lies in `my.package.view.hello` package
} // and its FXML view file is `HelloView.fxml`
return () -> "HelloView.fxml";
}

@Override
public Class<? extends FxmlController> getControllerClass() {
return HelloController.class;
// Its controller class is `HelloController`
}

}
```

##### Controller ([`FxmlController`](../easyfxml/src/main/java/moe/tristan/easyfxml/api/FxmlController.java))
##### Controller ([`FxmlController`](src/main/java/moe/tristan/easyfxml/api/FxmlController.java))
```java
@Component
public class HelloController implements FxmlController {
Expand Down Expand Up @@ -98,7 +96,7 @@ public class HelloController implements FxmlController {
Note that if you can have multiple instances of a given component (a notification panel, or a individual cell in a list/table for example),
you need to make sure that the controller class is not a singleton with @Scope(scopeName = ConfigurableBeanFactory.PROTOTYPE)

##### Entrypoint of the UI ([`FxUiManager`](../easyfxml/src/main/java/moe/tristan/easyfxml/FxUiManager.java))
##### Entrypoint of the UI ([`FxUiManager`](src/main/java/moe/tristan/easyfxml/FxUiManager.java))
###### (called by EasyFXML once JavaFX and Spring are both ready to use)
```java
@Component
Expand All @@ -117,14 +115,14 @@ public class HelloWorldUiManager extends FxUiManager {
}

@Override
protected FxmlNode mainComponent() { // defines what component must be loaded first into the main stage
protected FxmlComponent mainComponent() { // defines what component must be loaded first into the main stage
return helloComponent;
}

}
```

##### Main class ([`FxApplication`](../easyfxml/src/main/java/moe/tristan/easyfxml/FxApplication.java))
##### Main class ([`FxApplication`](src/main/java/moe/tristan/easyfxml/FxApplication.java))
```java
@SpringBootApplication // EasyFXML wires itself in the context via Spring Boot's autoconfiguration
public class HelloWorld extends FxApplication { // FxApplication is essential here to set-up JavaFX
Expand Down
Loading

0 comments on commit afed950

Please sign in to comment.