Added mm-doc screen

This commit is contained in:
Willem Cazander 2022-10-15 06:22:53 +02:00
parent c8905bfabf
commit d7e92845b5
8 changed files with 301 additions and 129 deletions

View file

@ -15,48 +15,6 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-eld-doc</artifactId>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-html</artifactId>
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-full</artifactId>
<exclusions>
<exclusion>
<artifactId>MetaModel-openoffice</artifactId><!-- Blocks hsqldb vs H2 -->
<groupId>org.eobjects.metamodel</groupId>
</exclusion>
<exclusion>
<artifactId>MetaModel-excel</artifactId><!-- Jars not needed -->
<groupId>org.eobjects.metamodel</groupId>
</exclusion>
<exclusion>
<artifactId>MetaModel-couchdb</artifactId><!-- Jars not needed -->
<groupId>org.eobjects.metamodel</groupId>
</exclusion>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
@ -73,7 +31,8 @@
<_metatypeannotations>*</_metatypeannotations>
<Import-Package>
${tos4.packages},
${vrgem4.packages}
${vrgem4.packages},
${mmdoc.packages}
</Import-Package>
<Bundle-Vendor>distributedrebirth.love</Bundle-Vendor>
</instructions>

View file

@ -6,6 +6,7 @@ import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import love.distributedrebirth.bassboonyd.info.BãßBȍőnAuthor注;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
@ -21,10 +22,13 @@ public class MMDocComponent {
@Reference
private VrGem4DeskAppService deskAppService;
@Reference
private SystemGdxBootArgs bootArgs;
private final DeskAppLauncher launcher;
public MMDocComponent() {
launcher = new DeskAppLauncher(DeskAppMenuSection.PROGRAMMING, "MMDoc", () -> new MMDocDeskApp());
launcher = new DeskAppLauncher(DeskAppMenuSection.PROGRAMMING, "MMDoc", () -> new MMDocDeskApp(bootArgs.getFileChooser()));
}
@Activate

View file

@ -1,58 +1,154 @@
package love.distributedrebirth.gdxapp4d.app.mmdoc;
import java.io.File;
import java.sql.SQLException;
import java.util.Map.Entry;
import java.util.function.Consumer;
import org.eobjects.metamodel.DataContext;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import imgui.ImGui;
import imgui.flag.ImGuiTableFlags;
import imgui.type.ImString;
import love.distributedrebirth.bassboonyd.info.BãßBȍőnAuthor注;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.AbstractDeskApp;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppContourSection;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer;
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
import net.spookygames.gdx.nativefilechooser.NativeFileChooserCallback;
import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public class MMDocDeskApp extends AbstractDeskApp implements DeskAppRenderer {
private final NativeFileChooser fileChooser;
private final NativeFileChooserConfiguration fileChooserConfig;
private final MMDocManager docManager = new MMDocManager();
private final ImString dbHost = new ImString();
private final ImString dbName = new ImString();
private final ImString dbUser = new ImString();
private final ImString dbPass = new ImString();
private final ImString docTarget = new ImString();
private String result = "";
public MMDocDeskApp(NativeFileChooser fileChooser) {
this.fileChooser = fileChooser;
fileChooserConfig = new NativeFileChooserConfiguration();
fileChooserConfig.directory = Gdx.files.absolute(System.getProperty("user.home"));
fileChooserConfig.title = "Choose file";
}
public void create() {
getContours().setTitle("MMDoc");
getContours().registrateContour(DeskAppContourSection.MAIN, this);
dbHost.set("localhost");
dbName.set("test");
dbUser.set("user");
dbPass.set("pass");
docTarget.set("target/mm-doc");
}
@Override
public void render() {
ImGui.text("Current amount:");
ImGui.sameLine();
ImGui.text("0000");
ImGui.inputText("docTarget", docTarget);
ImGui.separator();
ImGui.inputText("dbHost", dbHost);
ImGui.inputText("dbName", dbName);
ImGui.inputText("dbUser", dbUser);
ImGui.inputText("dbPass", dbPass);
ImGui.separator();
if (ImGui.button("Add")) {
if (ImGui.button("Add XML")) {
fileChooser.chooseFile(fileChooserConfig, NativeFileChooserCallbackAdapter.onFileChosen(v -> {
docManager.addDocModelXml(v.file());
result = "Added XML file";
}));
}
ImGui.sameLine();
if (ImGui.button("Add CSV")) {
fileChooser.chooseFile(fileChooserConfig, NativeFileChooserCallbackAdapter.onFileChosen(v -> {
docManager.addDocModelCsv(v.file());
result = "Added CSV file";
}));
}
ImGui.sameLine();
if (ImGui.button("Add PG")) {
try {
docManager.addDocModelJdbcPg(dbHost.get(), dbName.get(), dbUser.get(), dbPass.get());
result = "Added PG DB";
} catch (SQLException e) {
e.printStackTrace();
result = e.getMessage();
}
}
if (ImGui.button("Generate")) {
try {
docManager.generate(new File(docTarget.get()));
result = "done";
} catch (Exception e) {
e.printStackTrace();
result = e.getMessage();
}
}
ImGui.sameLine();
ImGui.text("Result: "+result);
ImGui.separator();
ImGui.text("DataSources:");
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV | ImGuiTableFlags.Resizable;
ImGui.beginTable("DataSources", 4, flags);
ImGui.tableSetupColumn("In/Out");
ImGui.tableSetupColumn("Amount");
ImGui.tableSetupColumn("Fraction");
ImGui.tableSetupColumn("Decimal");
ImGui.tableSetupColumn("Id");
ImGui.tableSetupColumn("Type");
ImGui.tableSetupColumn("TableCount");
ImGui.tableSetupColumn("Remove");
ImGui.tableHeadersRow();
String[] walletData = {"test", "test", "test"};
for (String data:walletData) {
String removeId = null;
for (Entry<String,DataContext> data:docManager.getDataStore().entrySet()) {
ImGui.tableNextRow();
ImGui.tableNextColumn();
ImGui.text(data);
ImGui.text(data.getKey());
ImGui.tableNextColumn();
ImGui.text(data);
ImGui.text(data.getValue().getClass().getSimpleName());
ImGui.tableNextColumn();
ImGui.text(data);
ImGui.text(Integer.toString(data.getValue().getDefaultSchema().getTableCount()));
ImGui.tableNextColumn();
ImGui.text(data);
if (ImGui.smallButton("Remove")) {
removeId = data.getKey();
}
}
ImGui.endTable();
if (removeId != null) {
docManager.getDataStore().removeDataContext(removeId);
}
}
static class NativeFileChooserCallbackAdapter implements NativeFileChooserCallback {
@Override
public void onFileChosen(FileHandle file) {
}
@Override
public void onCancellation() {
}
@Override
public void onError(Exception exception) {
}
static NativeFileChooserCallbackAdapter onFileChosen(Consumer<FileHandle> eater) {
return new NativeFileChooserCallbackAdapter() {
@Override
public void onFileChosen(FileHandle file) {
eater.accept(file);
}
};
}
}
}

View file

@ -4,86 +4,56 @@ import java.io.File;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.eobjects.metamodel.csv.CsvDataContext;
import org.eobjects.metamodel.doc.DocModelDataStore;
import org.eobjects.metamodel.doc.DocModelWriter;
import org.eobjects.metamodel.jdbc.JdbcDataContext;
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
import org.eobjects.metamodel.xml.XmlDomDataContext;
import com.mongodb.Mongo;
import com.mongodb.MongoOptions;
import com.mongodb.ServerAddress;
public class MMDocManager {
public enum MMDocManager {
private final DocModelDataStore dms = new DocModelDataStore();
INSTANCE;
private String DB_URL = "jdbc:mariadb://localhost/";
private String DB_USER = "test";
private String DB_PASS = "test";
private String PDB_URL = "jdbc:postgresql:";
private String PDB_USER = "postgres";
private String PDB_PASS = "postgresql";
private String MONGO_HOST = "localhost";
private String MS_URL = "jdbc:sqlserver://localhost";
private String MS_USER = "sa";
private String MS_PASS = "admin123";
private Mongo mongo = null;
private MMDocManager() {
public DocModelDataStore getDataStore() {
return dms;
}
public void testWriteDocModel() throws Exception {
public void generate(File targetPath) throws Exception {
Class.forName(org.postgresql.Driver.class.getName());
Class.forName(org.h2.Driver.class.getName());
//Class.forName(org.h2.Driver.class.getName());
//Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver.class.getName());
mongo = new Mongo(new ServerAddress(MONGO_HOST),new MongoOptions());
File targetPath = new File("target/mm-doc2");
DocModelDataStore dms = buildDocModelStore();
try {
DocModelWriter writer = new DocModelWriter(dms);
writer.writeModelDoc(targetPath);
} finally {
dms.clearAndCloseAllSafe();
//dms.clearAndCloseAllSafe();
}
//assertTrue(targetPath.exists());
}
private DocModelDataStore buildDocModelStore() throws SQLException {
DocModelDataStore dms = new DocModelDataStore();
//buildDocModelStoreJdbcPg(dms,"dellstore2");
buildDocModelStoreJdbcPg(dms,"fsim");
buildDocModelStoreJdbcPg(dms,"openbravo");
buildDocModelStoreJdbcPg(dms,"dellstore2");
buildDocModelStoreJdbcPg(dms,"pagila");
/*
buildDocModelStoreMongoDB(dms,"lia");
buildDocModelStoreMongoDB(dms,"lefiona");
dms.addDataContext("xml-pom-doc",new XmlDomDataContext(new File("pom.xml"),false));
dms.addDataContext("csv-people",new CsvDataContext(new File("src/test/resources/junit/csv-data/meta-people.csv")));
dms.addDataContext("csv-project",new CsvDataContext(new File("src/test/resources/junit/csv-data/meta-project.csv")));
*/
return dms;
public void addDocModelXml(File file) {
dms.addDataContext("xml-"+file.getName(),new XmlDomDataContext(file,false));
}
private void buildDocModelStoreJdbcMy(DocModelDataStore ds,String dbName) throws SQLException {
ds.addDataContext("my-"+dbName,new JdbcDataContext(DriverManager.getConnection(DB_URL+dbName,DB_USER,DB_PASS)));
public void addDocModelCsv(File file) {
dms.addDataContext("csv-"+file.getName(),new CsvDataContext(file));
}
private void buildDocModelStoreJdbcPg(DocModelDataStore ds,String dbName) throws SQLException {
ds.addDataContext("pg-"+dbName,new JdbcDataContext(DriverManager.getConnection(PDB_URL+dbName,PDB_USER,PDB_PASS)));
public void addDocModelJdbcMy(String host, String dbName, String user, String pass) throws SQLException {
dms.addDataContext("my-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:mariadb://"+host+"/"+dbName,user,pass)));
}
private void buildDocModelStoreMongoDB(DocModelDataStore ds,String dbName) {
ds.addDataContext("mongo-"+dbName,new MongoDbDataContext(mongo.getDB(dbName)));
public void addDocModelJdbcPg(String host, String dbName, String user, String pass) throws SQLException {
dms.addDataContext("pg-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:postgresql://"+host+"/"+dbName,user,pass)));
}
private void buildDocModelStoreJdbcMs(DocModelDataStore ds,String dbName) throws SQLException {
ds.addDataContext("ms-"+dbName,new JdbcDataContext(DriverManager.getConnection(MS_URL+";databaseName="+dbName,MS_USER,MS_PASS)));
public void addDocModelJdbcMs(String host, String dbName, String user, String pass) throws SQLException {
dms.addDataContext("ms-"+dbName,new JdbcDataContext(DriverManager.getConnection("jdbc:sqlserver://"+host+";databaseName="+dbName,user,pass)));
}
// @SuppressWarnings("deprecation")
// public void addDocModelMongoDB(String host, String dbName, String user, String pass) {
// Mongo mongo = new Mongo(new ServerAddress(host),new MongoOptions());
// dms.addDataContext("mongo-"+dbName,new MongoDbDataContext(mongo.getDB(dbName)));
// }
}

View file

@ -6,11 +6,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.eobjects.metamodel.DataContext;
import org.eobjects.metamodel.jdbc.JdbcDataContext;
import java.util.Map.Entry;
public class DocModelDataStore {
private Map<String,DataContext> dataContexts = null;

View file

@ -58,6 +58,36 @@
<artifactId>gdx-freetype-platform</artifactId>
<classifier>natives-desktop</classifier>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-eld-doc</artifactId>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-html</artifactId>
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-csv</artifactId>
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-xml</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
@ -71,7 +101,8 @@
<_donotcopy>(.git)</_donotcopy>
<Import-Package>org.osgi.framework,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker,*</Import-Package>
<Export-Package>
${tos4.packages}
${tos4.packages},
${mmdoc.packages}
</Export-Package>
<Bundle-Activator>love.distributedrebirth.gdxapp4d.tos4.GDXAppTos4Activator</Bundle-Activator>
<Bundle-Vendor>distributedrebirth.love</Bundle-Vendor>

View file

@ -134,7 +134,62 @@ public class GDXAppTos4BootFactory {
"love.distributedrebirth.warpme.ship,"+
"love.distributedrebirth.unicode4d,"+
"love.distributedrebirth.unicode4d.atlas,"+
"love.distributedrebirth.unicode4d.draw"
"love.distributedrebirth.unicode4d.draw,"+
"org.x4o.html,"+
"org.x4o.html.spec,"+
"org.x4o.xml.eld.doc,"+
"org.x4o.xml.eld.doc.api,"+
"org.x4o.xml.eld.doc.api.dom,"+
"org.x4o.xml.eld.doc.theme.base,"+
"org.x4o.xml.eld.doc.theme.jdk6,"+
"org.x4o.xml.eld.doc.theme.jdk7,"+
"org.eobjects.metamodel,"+
"org.eobjects.metamodel.convert,"+
"org.eobjects.metamodel.create,"+
"org.eobjects.metamodel.data,"+
"org.eobjects.metamodel.delete,"+
"org.eobjects.metamodel.drop,"+
"org.eobjects.metamodel.insert,"+
"org.eobjects.metamodel.intercept,"+
"org.eobjects.metamodel.query,"+
"org.eobjects.metamodel.query.builder,"+
"org.eobjects.metamodel.query.parser,"+
"org.eobjects.metamodel.schema,"+
"org.eobjects.metamodel.update,"+
"org.eobjects.metamodel.util,"+
"org.eobjects.metamodel.csv,"+
"org.eobjects.metamodel.xml,"+
"org.eobjects.metamodel.mongodb,"+
"org.eobjects.metamodel.jdbc,"+
"org.eobjects.metamodel.jdbc.dialects,"+
"au.com.bytecode.opencsv,"+
"au.com.bytecode.opencsv.bean,"+
"org.postgresql,"+
"org.postgresql.copy,"+
"org.postgresql.core,"+
"org.postgresql.core.types,"+
"org.postgresql.core.v2,"+
"org.postgresql.core.v3,"+
"org.postgresql.ds,"+
"org.postgresql.ds.common,"+
"org.postgresql.ds.jdbc23,"+
"org.postgresql.db.jdbc4,"+
"org.postgresql.fastpath,"+
"org.postgresql.geometric,"+
"org.postgresql.gss,"+
"org.postgresql.jdbc2,"+
"org.postgresql.jdbc2.optional,"+
"org.postgresql.jdbc3,"+
"org.postgresql.jdbc3g,"+
"org.postgresql.jdbc4,"+
"org.postgresql.largeobject,"+
"org.postgresql.ssl,"+
"org.postgresql.translation,"+
"org.postgresql.util,"+
"org.postgresql.xa,"+
"org.postgresql.xa.jdbc3,"+
"org.postgresql.xa.jdbc4"
); // ; version=1.0.0
if (cachedir != null) {

74
pom.xml
View file

@ -176,6 +176,62 @@
org.apache.commons.lang3.time,
org.apache.commons.lang3.tuple
</lang3.packages>
<mmdoc.packages>
org.x4o.html,
org.x4o.html.spec,
org.x4o.xml.eld.doc,
org.x4o.xml.eld.doc.api,
org.x4o.xml.eld.doc.api.dom,
org.x4o.xml.eld.doc.theme.base,
org.x4o.xml.eld.doc.theme.jdk6,
org.x4o.xml.eld.doc.theme.jdk7,
org.eobjects.metamodel,
org.eobjects.metamodel.convert,
org.eobjects.metamodel.create,
org.eobjects.metamodel.data,
org.eobjects.metamodel.delete,
org.eobjects.metamodel.drop,
org.eobjects.metamodel.insert,
org.eobjects.metamodel.intercept,
org.eobjects.metamodel.query,
org.eobjects.metamodel.query.builder,
org.eobjects.metamodel.query.parser,
org.eobjects.metamodel.schema,
org.eobjects.metamodel.update,
org.eobjects.metamodel.util,
org.eobjects.metamodel.csv,
org.eobjects.metamodel.xml,
org.eobjects.metamodel.mongodb,
org.eobjects.metamodel.jdbc,
org.eobjects.metamodel.jdbc.dialects,
au.com.bytecode.opencsv,
au.com.bytecode.opencsv.bean,
org.postgresql,
org.postgresql.copy,
org.postgresql.core,
org.postgresql.core.types,
org.postgresql.core.v2,
org.postgresql.core.v3,
org.postgresql.ds,
org.postgresql.ds.common,
org.postgresql.ds.jdbc23,
org.postgresql.db.jdbc4,
org.postgresql.fastpath,
org.postgresql.geometric,
org.postgresql.gss,
org.postgresql.jdbc2,
org.postgresql.jdbc2.optional,
org.postgresql.jdbc3,
org.postgresql.jdbc3g,
org.postgresql.jdbc4,
org.postgresql.largeobject,
org.postgresql.ssl,
org.postgresql.translation,
org.postgresql.util,
org.postgresql.xa,
org.postgresql.xa.jdbc3,
org.postgresql.xa.jdbc4
</mmdoc.packages>
</properties>
<dependencyManagement>
<dependencies>
@ -292,24 +348,24 @@
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-full</artifactId>
<artifactId>MetaModel-jdbc</artifactId>
<version>3.4.11</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.10.2</version>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-csv</artifactId>
<version>3.4.11</version>
</dependency>
<dependency>
<groupId>org.eobjects.metamodel</groupId>
<artifactId>MetaModel-xml</artifactId>
<version>3.4.11</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.170</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>