Clean demo directory layout
This commit is contained in:
parent
b3923bd2fb
commit
7c044adb1f
61 changed files with 2334 additions and 252 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -31,19 +31,11 @@
|
|||
<artifactId>vasc-demo-tech-editor</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.demo</groupId>
|
||||
<artifactId>vasc-demo-tech-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc.demo</groupId>
|
||||
<artifactId>vasc-demo-tech-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
package net.forwardfire.vasc.demo.tech.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.JMainPanel;
|
||||
|
||||
public class DeployManager {
|
||||
|
||||
private Logger logger = null;
|
||||
private File deployDir = null;
|
||||
private int scanPeriod = 3;
|
||||
private AutoDeployManager autoDeployManager = null;
|
||||
private Map<File,String> fileCheckSums = null;
|
||||
|
||||
public DeployManager() {
|
||||
logger = Logger.getLogger(DeployManager.class.getName());
|
||||
fileCheckSums = new HashMap<File,String>(20);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (deployDir==null) {
|
||||
throw new NullPointerException("Can't deploy with null deployDir.");
|
||||
}
|
||||
if (deployDir.exists()==false) {
|
||||
throw new IllegalStateException("Can't deploy with non-existing deployDir.");
|
||||
}
|
||||
if (deployDir.isDirectory()==false) {
|
||||
throw new IllegalStateException("Can't deploy with non-directory deployDir.");
|
||||
}
|
||||
Thread scanThread = new Thread(new AutoDeployManager());
|
||||
scanThread.setName("hotdeploy-scanner");
|
||||
scanThread.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (autoDeployManager==null) {
|
||||
return;
|
||||
}
|
||||
autoDeployManager.stop();
|
||||
}
|
||||
|
||||
|
||||
public String createMd5Sum(File file) throws IOException, NoSuchAlgorithmException {
|
||||
FileInputStream in = new FileInputStream(file.getAbsolutePath());
|
||||
try {
|
||||
byte[] b = new byte[1024 * 64];
|
||||
int num = 0;
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
while ((num = in.read(b)) != -1) {
|
||||
md.update(b, 0, num);
|
||||
}
|
||||
byte[] hashBytes = md.digest();
|
||||
BigInteger hashResult = new BigInteger(hashBytes);
|
||||
String hashString = hashResult.toString(16);
|
||||
return hashString;
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void hotDeployVasc() throws NoSuchAlgorithmException, IOException {
|
||||
boolean deployed = false;
|
||||
for (File file:deployDir.listFiles()) {
|
||||
if (file.canRead()==false) {
|
||||
continue;
|
||||
}
|
||||
if (file.getName().endsWith("xml")==false) {
|
||||
continue;
|
||||
}
|
||||
String md5File = createMd5Sum(file);
|
||||
String md5Deploy = fileCheckSums.get(file);
|
||||
if (md5Deploy!=null && md5Deploy.equals(md5File)) {
|
||||
continue;
|
||||
}
|
||||
fileCheckSums.put(file, md5File);
|
||||
deployed = true;
|
||||
TechUI.getInstance().getVascManager().openFile(file);
|
||||
}
|
||||
if (deployed) {
|
||||
((JMainPanel)TechUI.getInstance().getMainView().getComponent()).rebuildTree();
|
||||
}
|
||||
}
|
||||
|
||||
protected class AutoDeployManager implements Runnable {
|
||||
private volatile boolean run = true;
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(5000); // let gui+tomcat start
|
||||
logger.info("AutoDeployManager started");
|
||||
while(run) {
|
||||
try {
|
||||
hotDeployVasc();
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while depoying: "+e.getMessage(),e);
|
||||
}
|
||||
|
||||
if (scanPeriod == 0) {
|
||||
scanPeriod = 1;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000*scanPeriod);
|
||||
} catch (InterruptedException ie) {
|
||||
logger.info("Interrupted sleep");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE,"Error in run: "+e.getMessage(),e);
|
||||
} finally {
|
||||
logger.info("AutoDeployManager stoped");
|
||||
}
|
||||
}
|
||||
public void stop() {
|
||||
run = false;
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deployDir
|
||||
*/
|
||||
public File getDeployDir() {
|
||||
return deployDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deployDir the deployDir to set
|
||||
*/
|
||||
public void setDeployDir(File deployDir) {
|
||||
this.deployDir = deployDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanPeriod
|
||||
*/
|
||||
public int getScanPeriod() {
|
||||
return scanPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scanPeriod the scanPeriod to set
|
||||
*/
|
||||
public void setScanPeriod(int scanPeriod) {
|
||||
this.scanPeriod = scanPeriod;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,10 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
|
@ -49,8 +52,10 @@ import net.forwardfire.vasc.demo.tech.ui.components.JMainPanelMenuBar;
|
|||
public class TechUI extends SingleFrameApplication {
|
||||
|
||||
private Logger logger = null;
|
||||
private boolean showGui = false;
|
||||
private DemoVascManager vascManager = null;
|
||||
private TomcatManager tomcatManager = null;
|
||||
private DeployManager deployManager = null;
|
||||
|
||||
static public void main(String[] args) {
|
||||
Application.launch(TechUI.class, args);
|
||||
|
|
@ -99,6 +104,7 @@ public class TechUI extends SingleFrameApplication {
|
|||
public void willExit(EventObject event) {
|
||||
logger.info("Shutdown requested.");
|
||||
long startTime = System.currentTimeMillis();
|
||||
deployManager.stop();
|
||||
try {
|
||||
tomcatManager.stop();
|
||||
} catch (Exception e) {
|
||||
|
|
@ -110,32 +116,83 @@ public class TechUI extends SingleFrameApplication {
|
|||
}
|
||||
}
|
||||
|
||||
private void autoLoadVasc() {
|
||||
File autoLoadDir = new File("auto");
|
||||
if (autoLoadDir.exists()==false) {
|
||||
return;
|
||||
}
|
||||
for (File file:autoLoadDir.listFiles()) {
|
||||
if (file.canRead()==false) {
|
||||
continue;
|
||||
}
|
||||
if (file.getName().endsWith("xml")==false) {
|
||||
continue;
|
||||
}
|
||||
vascManager.openFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void initialize(String[] args) {
|
||||
protected void initialize(String[] argu) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// First parse user program arguments.
|
||||
String serverHost = null;
|
||||
String serverPort = null;
|
||||
List<String> arguList = new ArrayList<String>(argu.length);
|
||||
for (String a:argu) {
|
||||
arguList.add(a);
|
||||
}
|
||||
Iterator<String> arguIterator = arguList.iterator();
|
||||
while (arguIterator.hasNext()) {
|
||||
String arg = arguIterator.next();
|
||||
if ("-v".equals(arg)) {
|
||||
System.out.println();
|
||||
System.out.println("Optional:");
|
||||
System.out.println(" -host <ip> Sets the http hostname.");
|
||||
System.out.println(" -port <port> Sets the http port.");
|
||||
System.out.println(" -gui Sets gui mode.");
|
||||
System.out.println(" -h Print help. (this)");
|
||||
System.out.println();
|
||||
System.exit(1);
|
||||
}
|
||||
if ("-gui".equals(arg)) {
|
||||
showGui = true;
|
||||
}
|
||||
if ("-port".equals(arg)) {
|
||||
if (arguIterator.hasNext()==false) {
|
||||
System.out.println("No argument for -port given.");
|
||||
return;
|
||||
}
|
||||
serverPort = arguIterator.next();
|
||||
System.exit(1);
|
||||
}
|
||||
if ("-host".equals(arg)) {
|
||||
if (arguIterator.hasNext()==false) {
|
||||
System.out.println("No argument for -host given.");
|
||||
return;
|
||||
}
|
||||
serverHost = arguIterator.next();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
setupLogging();
|
||||
logger.info("Starting Vasc-Demo-Tech-UI.");
|
||||
|
||||
File deployDir = new File("deploy");
|
||||
File workDir = new File("workdir");
|
||||
if (isMavenRun()) {
|
||||
if (deployDir.exists()==false) {
|
||||
deployDir.mkdir();
|
||||
}
|
||||
if (workDir.exists()==false) {
|
||||
workDir.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vascManager = new DemoVascManager();
|
||||
vascManager.start();
|
||||
autoLoadVasc();
|
||||
|
||||
deployManager = new DeployManager();
|
||||
deployManager.setDeployDir(deployDir);
|
||||
deployManager.start();
|
||||
|
||||
tomcatManager = new TomcatManager();
|
||||
tomcatManager.setWorkDir(workDir);
|
||||
tomcatManager.setVascController(vascManager.getVascController());
|
||||
if (serverHost!=null) {
|
||||
tomcatManager.setHostname(serverHost);
|
||||
}
|
||||
if (serverPort!=null) {
|
||||
tomcatManager.setPort(new Integer(serverPort));
|
||||
}
|
||||
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
|
|
@ -158,11 +215,24 @@ public class TechUI extends SingleFrameApplication {
|
|||
long startTime = System.currentTimeMillis();
|
||||
addExitListener(new ShutdownManager());
|
||||
|
||||
FrameView mainView = getMainView();
|
||||
mainView.setComponent(new JMainPanel());
|
||||
mainView.setMenuBar(new JMainPanelMenuBar());
|
||||
mainView.getFrame().setMinimumSize(new Dimension(1024-64,768-128));
|
||||
show(mainView);
|
||||
if (showGui) {
|
||||
FrameView mainView = getMainView();
|
||||
mainView.setComponent(new JMainPanel());
|
||||
mainView.setMenuBar(new JMainPanelMenuBar());
|
||||
mainView.getFrame().setMinimumSize(new Dimension(1024-64,768-128));
|
||||
show(mainView);
|
||||
} else {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
while(true)
|
||||
try {
|
||||
Thread.sleep(3333);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
long stopTime = System.currentTimeMillis();
|
||||
logger.info("TechUI startup in "+(stopTime-startTime)+" ms total startup in "+(stopTime-startTime)+" ms.");
|
||||
|
|
@ -188,4 +258,8 @@ public class TechUI extends SingleFrameApplication {
|
|||
public VascController getVascController() {
|
||||
return vascManager.getVascController();
|
||||
}
|
||||
|
||||
public boolean isMavenRun() {
|
||||
return System.getProperty("java.class.path").contains("classes");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,24 @@ public class TomcatManager {
|
|||
private Logger logger = null;
|
||||
private Tomcat tomcat = null;
|
||||
private VascController vascController = null;
|
||||
private String hostname = null;
|
||||
private Integer port = null;
|
||||
private File workDir = null;
|
||||
|
||||
public TomcatManager() {
|
||||
logger = Logger.getLogger(TomcatManager.class.getName());
|
||||
hostname = "localhost";
|
||||
port = 8899;
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
Tomcat tomcat = new Tomcat();
|
||||
|
||||
String webPort = System.getenv("PORT");
|
||||
if(webPort == null || webPort.isEmpty()) {
|
||||
webPort = "8899";
|
||||
if (workDir==null) {
|
||||
throw new NullPointerException("Can't start tomcat with null workDir.");
|
||||
}
|
||||
tomcat.setPort(Integer.valueOf(webPort));
|
||||
Tomcat tomcat = new Tomcat();
|
||||
tomcat.setBaseDir(workDir.getAbsolutePath());
|
||||
tomcat.setPort(getPort());
|
||||
tomcat.setHostname(getHostname());
|
||||
|
||||
if (System.getProperty("java.class.path").contains("classes")) {
|
||||
String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
|
||||
|
|
@ -40,7 +45,7 @@ public class TomcatManager {
|
|||
|
||||
File techWarFile = null;
|
||||
for (File file:new File("lib").listFiles()) {
|
||||
if (file.getName().endsWith("war")) {
|
||||
if (file.getName().contains("vasc-demo-tech-web")) {
|
||||
techWarFile = file;
|
||||
break;
|
||||
}
|
||||
|
|
@ -48,7 +53,7 @@ public class TomcatManager {
|
|||
if (techWarFile==null) {
|
||||
throw new NullPointerException("Could not locate war file in lib directory.");
|
||||
}
|
||||
File destDir = new File("tomcat.wars"+File.separator+techWarFile.getName());
|
||||
File destDir = new File(workDir,"tomcat.wars"+File.separator+techWarFile.getName());
|
||||
if (destDir.exists()==false) {
|
||||
destDir.mkdirs();
|
||||
JarFile jar = new JarFile(techWarFile);
|
||||
|
|
@ -72,10 +77,7 @@ public class TomcatManager {
|
|||
String deployPath = destDir.getAbsolutePath();
|
||||
logger.info("Deploy war path: "+deployPath);
|
||||
tomcat.addWebapp("/demo",deployPath);
|
||||
}
|
||||
|
||||
instance = this;
|
||||
|
||||
}
|
||||
tomcat.start();
|
||||
}
|
||||
|
||||
|
|
@ -84,12 +86,6 @@ public class TomcatManager {
|
|||
return;
|
||||
}
|
||||
tomcat.stop();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
static private TomcatManager instance = null;
|
||||
static public TomcatManager getInstance() {
|
||||
return instance; // hackje to rm mvn 1-1 dep with ui
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,4 +101,46 @@ public class TomcatManager {
|
|||
public void setVascController(VascController vascController) {
|
||||
this.vascController = vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname the hostname to set
|
||||
*/
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the workDir
|
||||
*/
|
||||
public File getWorkDir() {
|
||||
return workDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param workDir the workDir to set
|
||||
*/
|
||||
public void setWorkDir(File workDir) {
|
||||
this.workDir = workDir;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,199 +0,0 @@
|
|||
package net.forwardfire.vasc.demo.tech.ui;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.schema.Column;
|
||||
import org.eobjects.metamodel.schema.Relationship;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextProvider;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.DefaultVascLinkEntry;
|
||||
import net.forwardfire.vasc.impl.ui.VascSelectItemModelEntry;
|
||||
|
||||
public class VascAutoSchemaMetaModel {
|
||||
|
||||
private Logger logger = null;
|
||||
private VascController vascController = null;
|
||||
|
||||
public VascAutoSchemaMetaModel(VascController vascController) {
|
||||
logger = Logger.getLogger(VascAutoSchemaMetaModel.class.getName());
|
||||
this.vascController=vascController;
|
||||
}
|
||||
|
||||
private VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
public void createMetaEntry(MetaModelDataContextProvider ds,String id,String tableName) {
|
||||
logger.info("Creating entry id: "+id+" of table: "+tableName);
|
||||
DataContext metaDs = ds.getDataContext();
|
||||
Table metaTable = null;
|
||||
if (tableName==null) {
|
||||
metaTable = metaDs.getDefaultSchema().getTable(0);
|
||||
} else {
|
||||
metaTable = metaDs.getDefaultSchema().getTableByName(tableName);
|
||||
}
|
||||
Column[] keys = metaTable.getPrimaryKeys();
|
||||
Column[] cols = metaTable.getColumns();
|
||||
if (cols.length==0) {
|
||||
return; // vasc needs at least one column
|
||||
}
|
||||
|
||||
MetaModelVascBackend backend = new MetaModelVascBackend();
|
||||
backend.setId(id+"_backend");
|
||||
backend.setDataContextProvider(ds);
|
||||
backend.setTable(metaTable.getName());
|
||||
if (keys.length>0) {
|
||||
backend.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backend.setTableId(cols[0].getName());
|
||||
//TODO backend.setRequestReadOnly(true);
|
||||
}
|
||||
|
||||
VascEntry ve = new DefaultVascEntry();
|
||||
ve.setId(id);
|
||||
ve.setBackendId(id+"_backend");
|
||||
ve.setPrimaryKeyFieldId(backend.getTableId());
|
||||
createFields(ve,cols);
|
||||
|
||||
for (Relationship rs:metaTable.getRelationships()) {
|
||||
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
|
||||
if (tableName.equals(rs.getForeignTable().getName())==false) {
|
||||
logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
createLinkEntry(ds,rs,ve,metaTable,id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
|
||||
} else {
|
||||
logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(ds,rs,ve,metaTable,id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backend);
|
||||
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(ve);
|
||||
|
||||
// mm TODO rm this fill which adds the global actions ... and show updated tree in editor
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) getVascController().getVascEntryController(), getVascController());
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createLinkEntry(MetaModelDataContextProvider ds,Relationship rs2,VascEntry ve,Table metaTable,String id) {
|
||||
MetaModelVascBackend backendLink = new MetaModelVascBackend();
|
||||
backendLink.setId(id+"_backend");
|
||||
backendLink.setDataContextProvider(ds);
|
||||
backendLink.setTable(rs2.getForeignTable().getName());
|
||||
|
||||
Column[] keys = rs2.getForeignTable().getPrimaryKeys();
|
||||
Column[] cols = rs2.getForeignTable().getColumns();
|
||||
if (cols.length==0) {
|
||||
return;
|
||||
}
|
||||
if (keys.length>0) {
|
||||
backendLink.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backendLink.setTableId(cols[0].getName());
|
||||
}
|
||||
|
||||
VascEntry veLink = new DefaultVascEntry();
|
||||
veLink.setId(id);
|
||||
veLink.setBackendId(id+"_backend");
|
||||
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
|
||||
createFields(veLink,cols);
|
||||
|
||||
for (Relationship rs:rs2.getForeignTable().getRelationships()) {
|
||||
logger.finer("Found relation FT: "+rs.getForeignTable().getName()+" PT: "+rs.getPrimaryTable().getName());
|
||||
if (rs2.getForeignTable().getName().equals(rs.getForeignTable().getName())==false) {
|
||||
//logger.info("Creating Link entry for: "+rs.getForeignColumns()[0].getName()+" of table: "+rs.getForeignTable().getName());
|
||||
//createLinkEntry(ds,rs,ve,rs2.getForeignTable(),id+"_"+rs.getForeignTable().getName()+"_"+rs.getForeignColumns()[0].getName()+"_link");
|
||||
} else {
|
||||
logger.info("Creating List entry for: "+rs.getPrimaryColumns()[0].getName()+" of table: "+rs.getPrimaryTable().getName());
|
||||
createListEntry(ds,rs,veLink,rs2.getForeignTable(),id+"_"+rs.getPrimaryTable().getName()+"_"+rs.getPrimaryColumns()[0].getName()+"_list");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink);
|
||||
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink);
|
||||
|
||||
VascLinkEntry vle = new DefaultVascLinkEntry();
|
||||
vle.setId(id+"Link");
|
||||
vle.setVascLinkEntryType(VascLinkEntryType.DEFAULT_TYPE);
|
||||
vle.setVascEntryId(id);
|
||||
vle.addEntryParameterFieldId(rs2.getForeignColumns()[0].getName(), rs2.getPrimaryColumns()[0].getName());
|
||||
|
||||
ve.addVascLinkEntry(vle);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createListEntry(MetaModelDataContextProvider ds,Relationship rs,VascEntry ve,Table metaTable,String id) {
|
||||
MetaModelVascBackend backendLink = new MetaModelVascBackend();
|
||||
backendLink.setId(id+"_backend");
|
||||
backendLink.setDataContextProvider(ds);
|
||||
backendLink.setTable(rs.getPrimaryTable().getName());
|
||||
|
||||
Column[] keys = rs.getPrimaryTable().getPrimaryKeys();
|
||||
Column[] cols = rs.getPrimaryTable().getColumns();
|
||||
if (cols.length==0) {
|
||||
return;
|
||||
}
|
||||
if (keys.length>0) {
|
||||
backendLink.setTableId(keys[0].getName());
|
||||
} else {
|
||||
backendLink.setTableId(cols[0].getName());
|
||||
}
|
||||
VascEntry veLink = new DefaultVascEntry();
|
||||
veLink.setId(id);
|
||||
veLink.setBackendId(id+"_backend");
|
||||
veLink.setPrimaryKeyFieldId(backendLink.getTableId());
|
||||
createFields(veLink,cols);
|
||||
try {
|
||||
VascEntryField vef = ve.getVascEntryFieldById(rs.getForeignColumns()[0].getName());
|
||||
if (vef==null) {
|
||||
logger.warning("Could not find: "+rs.getForeignColumns()[0].getName()+" in ve: "+ve.getId());
|
||||
return;
|
||||
}
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("ListField"));
|
||||
|
||||
VascSelectItemModelEntry itemModel = new VascSelectItemModelEntry();
|
||||
itemModel.setEntryId(veLink.getId());
|
||||
itemModel.setDisplayFieldId(veLink.getDisplayNameFieldId());
|
||||
vef.getVascEntryFieldType().setDataObject(itemModel);
|
||||
|
||||
((VascBackendControllerLocal)getVascController().getVascBackendController()).addVascBackend(backendLink);
|
||||
((VascEntryControllerLocal)getVascController().getVascEntryController()).addVascEntry(veLink);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createFields(VascEntry ve,Column[] cols) {
|
||||
for (Column c:cols) {
|
||||
VascEntryField vef = new DefaultVascEntryField(c.getName());
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
|
||||
if (c.getName().toLowerCase().contains("desc") || c.getName().toLowerCase().contains("text")) {
|
||||
vef.setVascEntryFieldType(getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextAreaField"));
|
||||
}
|
||||
ve.addVascEntryField(vef);
|
||||
if (ve.getDisplayNameFieldId()==null && c.getName().equals(ve.getPrimaryKeyFieldId())==false && c.getType().getJavaEquivalentClass()==String.class) {
|
||||
ve.setDisplayNameFieldId(c.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,8 +17,8 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
import net.forwardfire.vasc.demo.tech.ui.TechUI;
|
||||
import net.forwardfire.vasc.demo.tech.ui.VascAutoSchemaMetaModel;
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.JMainPanel;
|
||||
|
||||
public class JDialogMetaCsv extends JDialog implements ActionListener {
|
||||
|
|
@ -64,8 +64,11 @@ public class JDialogMetaCsv extends JDialog implements ActionListener {
|
|||
File file = fc.getSelectedFile();
|
||||
MetaModelDataContextCsv ds = new MetaModelDataContextCsv();
|
||||
ds.setFile(file.getAbsolutePath());
|
||||
VascAutoSchemaMetaModel schema = new VascAutoSchemaMetaModel(TechUI.getInstance().getVascManager().getVascController());
|
||||
schema.createMetaEntry(ds,file.getName(),null);
|
||||
|
||||
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
|
||||
schema.setDataContextProvider(ds);
|
||||
schema.setEntryPrefix(file.getName());
|
||||
schema.autoCreateEntries(TechUI.getInstance().getVascManager().getVascController());
|
||||
((JMainPanel)TechUI.getInstance().getMainView().getComponent()).rebuildTree();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,11 @@ import javax.swing.JTextField;
|
|||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
import net.forwardfire.vasc.demo.tech.ui.TechUI;
|
||||
import net.forwardfire.vasc.demo.tech.ui.VascAutoSchemaMetaModel;
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.JMainPanel;
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.SpringLayoutGrid;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
|
||||
public class JDialogMetaJdbc extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
|
|
@ -89,12 +87,11 @@ public class JDialogMetaJdbc extends JDialog implements ActionListener {
|
|||
ds.setConnectUrl(url);
|
||||
ds.setUsername(usernameField.getText());
|
||||
ds.setPassword(passwordField.getText());
|
||||
DataContext metaDs = ds.getDataContext();
|
||||
String dbName = url.substring(url.lastIndexOf('/')+1,url.length());
|
||||
VascAutoSchemaMetaModel schema = new VascAutoSchemaMetaModel(TechUI.getInstance().getVascManager().getVascController());
|
||||
for (String table:metaDs.getDefaultSchema().getTableNames()) {
|
||||
schema.createMetaEntry(ds,dbName+"_"+table,table);
|
||||
}
|
||||
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
|
||||
schema.setDataContextProvider(ds);
|
||||
schema.setEntryPrefix(dbName);
|
||||
schema.autoCreateEntries(TechUI.getInstance().getVascManager().getVascController());
|
||||
((JMainPanel)TechUI.getInstance().getMainView().getComponent()).rebuildTree();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ import javax.swing.JTextField;
|
|||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
|
||||
import net.forwardfire.vasc.demo.tech.ui.TechUI;
|
||||
import net.forwardfire.vasc.demo.tech.ui.VascAutoSchemaMetaModel;
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.JMainPanel;
|
||||
import net.forwardfire.vasc.demo.tech.ui.components.SpringLayoutGrid;
|
||||
|
||||
|
|
@ -79,11 +79,11 @@ public class JDialogMetaMongodb extends JDialog implements ActionListener {
|
|||
ds.setHostname(hostNameField.getText());
|
||||
ds.setPort(new Integer(hostPortField.getText()));
|
||||
ds.setDatabase(databaseField.getText());
|
||||
DataContext metaDs = ds.getDataContext();
|
||||
VascAutoSchemaMetaModel schema = new VascAutoSchemaMetaModel(TechUI.getInstance().getVascManager().getVascController());
|
||||
for (String table:metaDs.getDefaultSchema().getTableNames()) {
|
||||
schema.createMetaEntry(ds,ds.getDatabase()+"_"+table,table);
|
||||
}
|
||||
|
||||
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
|
||||
schema.setDataContextProvider(ds);
|
||||
schema.setEntryPrefix(ds.getDatabase());
|
||||
schema.autoCreateEntries(TechUI.getInstance().getVascManager().getVascController());
|
||||
((JMainPanel)TechUI.getInstance().getMainView().getComponent()).rebuildTree();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ import net.forwardfire.vasc.demo.tech.ui.TechUI;
|
|||
import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle_en;
|
||||
import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys;
|
||||
|
||||
public class JMainPanel extends JPanel {
|
||||
|
|
@ -291,15 +290,14 @@ public class JMainPanel extends JPanel {
|
|||
}
|
||||
File resourceFile = new File("auto/data/vasc-bundle.properties");
|
||||
if (resourceFile.exists()) {
|
||||
readPropertiesFile(p,resourceFile);
|
||||
readPropertiesFile(p,resourceFile);
|
||||
}
|
||||
for (String key:keys.keySet()) {
|
||||
p.put(key, keys.get(key));
|
||||
}
|
||||
writePropertiesFile(p,resourceFile);
|
||||
|
||||
new RootApplicationBundle_en().reload();
|
||||
RootApplicationBundle_en.clearCache();
|
||||
ResourceBundle.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import javax.swing.JMenuBar;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.demo.tech.ui.TechUI;
|
||||
import net.forwardfire.vasc.demo.tech.ui.actions.JDialogMetaCsv;
|
||||
import net.forwardfire.vasc.demo.tech.ui.actions.JDialogMetaJdbc;
|
||||
|
|
@ -17,14 +19,15 @@ import net.forwardfire.vasc.demo.tech.ui.actions.JDialogMetaMongodb;
|
|||
|
||||
public class JMainPanelMenuBar extends JMenuBar {
|
||||
|
||||
private static final long serialVersionUID = -2828428804621352725L;
|
||||
JMenu fileMenu = new JMenu("File");
|
||||
JMenu connMenu = new JMenu("Connection");
|
||||
JMenu vascMenu = new JMenu("Vasc");
|
||||
JMenu tabMenu = new JMenu("Tabs");
|
||||
|
||||
public JMainPanelMenuBar() {
|
||||
createMenuItems();
|
||||
add(fileMenu);
|
||||
add(connMenu);
|
||||
add(vascMenu);
|
||||
add(tabMenu);
|
||||
}
|
||||
|
||||
|
|
@ -61,17 +64,18 @@ public class JMainPanelMenuBar extends JMenuBar {
|
|||
fileMenu.add(exitItem);
|
||||
|
||||
JMenuItem connectVascItem = new JMenuItem("Add Vasc");
|
||||
connectVascItem.setEnabled(false);
|
||||
connectVascItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
connMenu.add(connectVascItem);
|
||||
vascMenu.add(connectVascItem);
|
||||
|
||||
JMenuItem connectLdapItem = new JMenuItem("Add Ldap");
|
||||
connectLdapItem.setEnabled(false);
|
||||
connMenu.add(connectLdapItem);
|
||||
connMenu.addSeparator();
|
||||
vascMenu.add(connectLdapItem);
|
||||
vascMenu.addSeparator();
|
||||
JMenuItem connectMetaCsvItem = new JMenuItem("Add meta csv");
|
||||
connectMetaCsvItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
@ -79,9 +83,10 @@ public class JMainPanelMenuBar extends JMenuBar {
|
|||
d.setVisible(true);
|
||||
}
|
||||
});
|
||||
connMenu.add(connectMetaCsvItem);
|
||||
vascMenu.add(connectMetaCsvItem);
|
||||
JMenuItem connectMetaXmlItem = new JMenuItem("Add meta xml");
|
||||
connMenu.add(connectMetaXmlItem);
|
||||
connectMetaXmlItem.setEnabled(false);
|
||||
vascMenu.add(connectMetaXmlItem);
|
||||
JMenuItem connectMetaMongoItem = new JMenuItem("Add meta mongo");
|
||||
connectMetaMongoItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
@ -89,7 +94,7 @@ public class JMainPanelMenuBar extends JMenuBar {
|
|||
d.setVisible(true);
|
||||
}
|
||||
});
|
||||
connMenu.add(connectMetaMongoItem);
|
||||
vascMenu.add(connectMetaMongoItem);
|
||||
JMenuItem connectMetaJdbcItem = new JMenuItem("Add meta jdbc");
|
||||
connectMetaJdbcItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
@ -97,27 +102,39 @@ public class JMainPanelMenuBar extends JMenuBar {
|
|||
d.setVisible(true);
|
||||
}
|
||||
});
|
||||
connMenu.add(connectMetaJdbcItem);
|
||||
vascMenu.add(connectMetaJdbcItem);
|
||||
|
||||
/*
|
||||
for (final String id:ve.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = ve.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, ve.getVascFrontendData().getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
vascMenu.addSeparator();
|
||||
JMenuItem removeEntryItem = new JMenuItem("Remove entry");
|
||||
removeEntryItem.setEnabled(false);
|
||||
removeEntryItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
});
|
||||
vascMenu.add(removeEntryItem);
|
||||
|
||||
JMenuItem removeAllItem = new JMenuItem("Remove all");
|
||||
removeAllItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
VascBackendControllerLocal backends = (VascBackendControllerLocal)TechUI.getInstance().getVascManager().getVascController().getVascBackendController();
|
||||
VascEntryControllerLocal entries = (VascEntryControllerLocal)TechUI.getInstance().getVascManager().getVascController().getVascEntryController();
|
||||
for (String entryId:entries.getVascEntryIds()) {
|
||||
if (entryId.startsWith("Vasc")) {
|
||||
continue;
|
||||
}
|
||||
entries.removeVascEntry(entryId);
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
*/
|
||||
|
||||
for (String backendId:backends.getVascBackendIds()) {
|
||||
if (backendId.startsWith("Vasc")) {
|
||||
continue;
|
||||
}
|
||||
backends.removeVascBackendById(backendId);
|
||||
}
|
||||
((JMainPanel)TechUI.getInstance().getMainView().getComponent()).rebuildTree();
|
||||
}
|
||||
});
|
||||
vascMenu.add(removeAllItem);
|
||||
|
||||
JMenuItem item = new JMenuItem("Close tab");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue