-
Notifications
You must be signed in to change notification settings - Fork 104
IDE integration
We are planning to create an IDEA plugin for mvvmFX (see the current state at #339).
A recurring task when creating applications with mvvmFX is to create classes for the View, ViewModel and a FXML file for each view component. To simplify this process you can use these file templates in IntelliJ IDEA.
- Go to
Settings
->Editor
->File and Code Templates
. - Add a new file template by pressing the
+
button. - Name: "mvvmFX ViewModel", Extension: "java"
For ViewModels:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import de.saxsys.mvvmfx.ViewModel;
#parse("File Header.java")
public class ${NAME}ViewModel implements ViewModel {
}
For FxmlViews:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import de.saxsys.mvvmfx.FxmlView;
import de.saxsys.mvvmfx.InjectViewModel;
#parse("File Header.java")
public class ${NAME}View implements FxmlView<${NAME}ViewModel> {
@InjectViewModel
private ${NAME}ViewModel viewModel;
public void initialize() {
}
}
For JavaViews:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import de.saxsys.mvvmfx.JavaView;
import de.saxsys.mvvmfx.InjectViewModel;
import javafx.scene.layout.AnchorPane;
#parse("File Header.java")
public class ${NAME} extends AnchorPane implements JavaView<${NAME}ViewModel> {
@InjectViewModel
private ${NAME}ViewModel viewModel;
public void initialize() {
}
}
To use the file templates right click on the package and choose "New" -> "mvvmFX ViewModel" and "mvvmFX FxmlView" or "mvvmFX JavaView". The dialog will ask for a file name. Here you should only enter the domain specific name without the "-ViewModel" or "-View" suffix. Instead of "HelloWorldViewModel" just enter "HelloWorld" for both the ViewModel and the View. The file template will automatically add the correct suffix for you.
At the moment we have no special integration for these IDEs. However, we would be very happy to add introductions for file templates like the ones for IntelliJ here. If you are using Eclipse/Netbeans we highly appreciate your contributions. See #439, #175 and #342