Using the Eclipse plug-in

1.Basic knowledge

1.1.XWorker project directory

    In Eclipse, you use XWorker plug-ins to edit the model. The model must have two ways to set up XWorker items under the XWorker project directory.

1.1.1..dml

    In a directory in Eclipse, a file named .dml can be created to make the directory a project directory of the XWorker, which can be created in the directory and subdirectory.

1.1.2.Project name

    In .dml, you can set projectName properties, such as projectName=Test, which means the project name is Test.

    The project name can be empty, and the directory name is used as the project name. Because the name of the project can not be repeated, it is recommended that the directory be used as the project name.

1.2.XWorker's project is global

    Because the dynamic model engine is designed as a global single state, even in different projects of Eclipse, the path of the thing still cannot be repeated, and the path of each thing must be unique, otherwise the editor will only edit the first thing that is in line with the path.

2.The way to create things

2.1.Use a new thing Guide

  Enter a new thing guide.

进入新建事物向导

    Create a thing.

创建一个事物

2.2.Create a *.dml file

    You can create a file with suffix DML directly in the directory, and then double-click to create the edit, but this model is not described at this time.

3.Edit things

    Double click to open the thing under the directory, if the text editor opens, select the open mode for ThingEditor, or the default editor of *.dml, *.xer, *.xer.txt, *.xer.xml in the Window->Preferences->General->Editors->File Associations to be set to ThingEditor.

     编辑事物

4.Run things

    Because there is only one instance of XWorker in Eclipse, it has nothing to do with the specific Eclipse project, so the running model in the editor does not use the Eclipse's project configuration, so if the model does not depend on the other configuration of the project, you can run it directly, otherwise you can run the model in the Java code.  

    Such as:

import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
 
public class RunEditor {
    public static void main(String args[]){
        try{
            //X-Meta引擎是单实例的
            World world = World.getInstance();          
             
            //初始化引擎,参数是模型库的目录,如果为null那么通过XMETA_HOME或XWORKER_HOME环境变量获取模型库的位置
            world.init(null);
             
            //获取简单事物编辑器,简单事物编辑器
            Thing thingEditor = world.getThing("xworker.swt.xwidgets.prototypes.SimpleThingEditor");
            ActionContext actionContext = new ActionContext();
             
            //执行简单事物编辑器
            thingEditor.doAction("run", actionContext);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

 

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