A way to run the Explorer version of the Model Editor under a Java project.

1. Import class library

    Please refer to the pom.xml below to introduce the relevant class library into your own Java project, where the sonatype repository is for the use of the SNAPSHOT version of the class library.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <name>sonatype Repository</name>

2. Run the model editor

    Write a Java program to run the Model Editor.

import org.xmeta.World;
import xworker.swt.SwtThingEditor;
import xworker.webserver.XWorkerWebServer;

import java.io.File;

public class ThingEditor {
    public static void main(String args[]){
            //Get an instance of the dynamic model engine
            World world = World.getInstance();
            //Initialize the working directory of the engine, some temporary files may be generated, the directory must be writable

            //Add a model manager, that is, the directory where the model is stored, which is needed to edit the model. Test is the name of the model manager and cannot be duplicated with other model managers.
            world.addFileThingManager("myproject", new File("./src/main/resources"), false, true);
            //The model can be placed in the Java source directory, and the model can be compiled and packaged with Java, but the model in the jar is generally read-only

            // run the web server and model editor
        }catch(Exception e){

    The first time it is executed or when the Jar that the project depends on is changed, the initialization operation will be performed. After the initialization is performed, the application will exit and need to be reopened. The function of initialization is to decompress the class libraries and resources that cannot be imported through Maven to the ./xworker/ directory. After execution, please import the relevant jars in the Java project according to the prompts.

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号