Made unittest data backend for frontends and improved swing frontend.
Worked on metamodel backend and some other fixes.
This commit is contained in:
parent
1c308a684a
commit
a25e98f5d5
7
pom.xml
7
pom.xml
|
@ -321,6 +321,13 @@
|
|||
<url>http://repository.ops4j.org/maven2/</url>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eobjects-metamodel</id>
|
||||
<name>eobjects.org</name>
|
||||
<layout>default</layout>
|
||||
<url>http://repo.eobjects.org</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<!-- DistributionManagement -->
|
||||
|
|
|
@ -56,7 +56,11 @@ public class LdapConnectionProviderImpl implements LdapConnectionProvider {
|
|||
}
|
||||
return lc;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
if (bindUser!=null && bindPass!=null) {
|
||||
throw new RuntimeException("Connect as: "+bindUser+" pass: "+bindPass+" message: "+e.getMessage(),e);
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eobjects.metamodel</groupId>
|
||||
<artifactId>MetaModel-core</artifactId>
|
||||
<version>2.1</version>
|
||||
<artifactId>MetaModel-full</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,91 @@
|
|||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.csv.CsvConfiguration;
|
||||
import org.eobjects.metamodel.csv.CsvDataContext;
|
||||
|
||||
public class MetaModelDataContextCsv implements MetaModelDataContextProvider {
|
||||
|
||||
private String file = null;
|
||||
private String resource = null;
|
||||
private String url = null;
|
||||
private CsvConfiguration csvConfiguration = null;
|
||||
|
||||
public DataContext getDataContext() {
|
||||
if (csvConfiguration==null) {
|
||||
csvConfiguration = new CsvConfiguration();
|
||||
}
|
||||
CsvDataContext dataContext;
|
||||
if (file != null) {
|
||||
dataContext = new CsvDataContext(new File(file),csvConfiguration);
|
||||
} else if (url != null) {
|
||||
try {
|
||||
dataContext = new CsvDataContext(new URL(url),csvConfiguration);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Could not parse url: "+e.getMessage(),e);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("No file or url defined.");
|
||||
}
|
||||
return dataContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the file
|
||||
*/
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param file the file to set
|
||||
*/
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resource
|
||||
*/
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource the resource to set
|
||||
*/
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url the url to set
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the csvConfiguration
|
||||
*/
|
||||
public CsvConfiguration getCsvConfiguration() {
|
||||
return csvConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param csvConfiguration the csvConfiguration to set
|
||||
*/
|
||||
public void setCsvConfiguration(CsvConfiguration csvConfiguration) {
|
||||
this.csvConfiguration = csvConfiguration;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.mongodb.MongoDbDataContext;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoOptions;
|
||||
import com.mongodb.ServerAddress;
|
||||
|
||||
public class MetaModelDataContextMongodb implements MetaModelDataContextProvider {
|
||||
|
||||
private String hostname = "localhost";
|
||||
private int port = 27017;
|
||||
private String database = null;
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
private boolean readonly = false;
|
||||
|
||||
protected static Mongo mongo = null;
|
||||
protected static DB db = null;
|
||||
|
||||
public DataContext getDataContext() {
|
||||
MongoDbDataContext dataContext = new MongoDbDataContext(getMongodbConnection());
|
||||
return dataContext;
|
||||
}
|
||||
|
||||
public DB getMongodbConnection() {
|
||||
if (db!=null) {
|
||||
return db;
|
||||
}
|
||||
synchronized (this) {
|
||||
ServerAddress server;
|
||||
try {
|
||||
server = new ServerAddress(hostname,port);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
MongoOptions options = new MongoOptions();
|
||||
mongo = new Mongo(server,options);
|
||||
db = mongo.getDB(database);
|
||||
if (username!=null && password!=null) {
|
||||
boolean auth = db.authenticate(username, password.toCharArray());
|
||||
if (auth==false) {
|
||||
throw new RuntimeException("Could not auth to db: "+database+" with username: "+username);
|
||||
}
|
||||
}
|
||||
if (readonly) {
|
||||
db.setReadOnly(true);
|
||||
}
|
||||
//logger.info("Connection to: "+db.getName());
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the database
|
||||
*/
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param database the database to set
|
||||
*/
|
||||
public void setDatabase(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the readonly
|
||||
*/
|
||||
public boolean isReadonly() {
|
||||
return readonly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param readonly the readonly to set
|
||||
*/
|
||||
public void setReadonly(boolean readonly) {
|
||||
this.readonly = readonly;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
|
||||
/**
|
||||
* Provides an metamodel datacontext object to the metamodel backend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 25, 2012
|
||||
*/
|
||||
public interface MetaModelDataContextProvider {
|
||||
|
||||
/**
|
||||
* Returns a DB connection.
|
||||
* @return An DB connection to mongodb
|
||||
*/
|
||||
public DataContext getDataContext();
|
||||
}
|
|
@ -23,17 +23,21 @@
|
|||
package net.forwardfire.vasc.backend.metamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.UpdateCallback;
|
||||
import org.eobjects.metamodel.UpdateScript;
|
||||
import org.eobjects.metamodel.UpdateableDataContext;
|
||||
import org.eobjects.metamodel.data.DataSet;
|
||||
import org.eobjects.metamodel.data.Row;
|
||||
import org.eobjects.metamodel.query.Query;
|
||||
import org.eobjects.metamodel.query.SelectItem;
|
||||
import org.eobjects.metamodel.schema.Schema;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
import org.eobjects.metamodel.update.RowUpdationBuilder;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
|
@ -53,13 +57,23 @@ import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
|||
*/
|
||||
public class MetaModelVascBackend extends AbstractVascBackend {
|
||||
|
||||
private DataContext dataContext = null;
|
||||
private MetaModelDataContextProvider dataContextProvider = null;
|
||||
private UpdateableDataContext dataContext = null;
|
||||
private String table = null;
|
||||
private String tableId = null;
|
||||
|
||||
private UpdateableDataContext getUpdateableDataContext() {
|
||||
if (dataContext!=null) {
|
||||
return dataContext;
|
||||
}
|
||||
dataContext = (UpdateableDataContext)dataContextProvider.getDataContext();
|
||||
return dataContext;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
UpdateableDataContext dataContext = getUpdateableDataContext();
|
||||
Schema schema = dataContext.getDefaultSchema();
|
||||
Table t = schema.getTableByName(table);
|
||||
//dataContext.query().from("").select("").where("").
|
||||
Query q = dataContext.query().from(t).select(t.getColumns()).toQuery();
|
||||
DataSet ds = dataContext.executeQuery(q);
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
|
@ -78,13 +92,52 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
UpdateableDataContext dataContext = getUpdateableDataContext();
|
||||
dataContext.executeUpdate(new UpdateScript() {
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
Table table = backendImpl.createTable(null, "some_entries").withColumn("foo").withColumn("bar")
|
||||
.withColumn("baz").withColumn("list").execute();
|
||||
|
||||
backendImpl.insertInto(table).value("foo", 1).value("bar", "hello").execute();
|
||||
backendImpl.insertInto(table).value("foo", 2).value("bar", "world").execute();
|
||||
backendImpl.insertInto(table).value("foo", 3).value("bar", "hi").execute();
|
||||
|
||||
Map<String, Object> nestedObj = new HashMap<String, Object>();
|
||||
nestedObj.put("foo", "bar");
|
||||
nestedObj.put("123", 456);
|
||||
|
||||
backendImpl.insertInto(table).value("foo", 4).value("bar", "there").value("baz", nestedObj)
|
||||
.value("list", Arrays.asList(1, 2, 3)).execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object merge(Object object) throws VascException {
|
||||
final Map<String,Object> map = (Map<String,Object>)object;
|
||||
UpdateableDataContext dataContext = getUpdateableDataContext();
|
||||
dataContext.executeUpdate(new UpdateScript() {
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
RowUpdationBuilder query = backendImpl.update(table).where(tableId).equals(""+map.get(tableId));
|
||||
for (String key:map.keySet()) {
|
||||
Object value = map.get(key);
|
||||
query.value(key, value);
|
||||
}
|
||||
query.execute();
|
||||
}
|
||||
});
|
||||
return object;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void delete(Object object) throws VascException {
|
||||
final Map<String,Object> map = (Map<String,Object>)object;
|
||||
UpdateableDataContext dataContext = getUpdateableDataContext();
|
||||
dataContext.executeUpdate(new UpdateScript() {
|
||||
public void run(UpdateCallback backendImpl) {
|
||||
backendImpl.deleteFrom(table).where(tableId).in(""+map.get(tableId)).execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
|
@ -94,4 +147,46 @@ public class MetaModelVascBackend extends AbstractVascBackend {
|
|||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new MapVascEntryRecordCreator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataContextProvider
|
||||
*/
|
||||
public MetaModelDataContextProvider getDataContextProvider() {
|
||||
return dataContextProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataContextProvider the dataContextProvider to set
|
||||
*/
|
||||
public void setDataContextProvider(MetaModelDataContextProvider dataContextProvider) {
|
||||
this.dataContextProvider = dataContextProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the table
|
||||
*/
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param table the table to set
|
||||
*/
|
||||
public void setTable(String table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tableId
|
||||
*/
|
||||
public String getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableId the tableId to set
|
||||
*/
|
||||
public void setTableId(String tableId) {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||
<eld:elementClass tag="metaModelBackend" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelVascBackend">
|
||||
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||
</eld:elementClass>
|
||||
<eld:elementClass tag="mongodbDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb"/>
|
||||
<eld:elementClass tag="csvDataContext" objectClassName="net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv"/>
|
||||
</eld:root>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment>
|
||||
Vasc namespace for the metamodel backend
|
||||
</comment>
|
||||
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld">vasc-backend-metamodel.eld</entry>
|
||||
</properties>
|
|
@ -53,6 +53,13 @@ abstract public class AbstractVascBackend implements VascBackend {
|
|||
this.id=id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isPageable()
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ public interface VascBackend {
|
|||
|
||||
public List<Object> execute(VascBackendState state) throws VascException;
|
||||
|
||||
public boolean isReadOnly();
|
||||
|
||||
public void persist(Object object) throws VascException;
|
||||
|
||||
public Object merge(Object object) throws VascException;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -31,4 +33,6 @@ package net.forwardfire.vasc.backend;
|
|||
public interface VascBackendController {
|
||||
|
||||
public VascBackend getVascBackendById(String id);
|
||||
|
||||
public List<String> getVascBackendIds();
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
|
||||
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
|
||||
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.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryFieldSet;
|
||||
import net.forwardfire.vasc.impl.DefaultVascLinkEntry;
|
||||
|
||||
public class VirtualVascBackend extends AbstractVascBackend {
|
||||
|
||||
private VascController vascController = null;
|
||||
private String vascType = "entry";
|
||||
private String entryId = null;
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
List<Object> result = new ArrayList<Object>(100);
|
||||
entryId = (String)state.getDataParameter("entry_id");
|
||||
if ("entry".equals(vascType)) {
|
||||
for (String id:vascController.getVascEntryController().getVascEntryIds()) {
|
||||
result.add(vascController.getVascEntryController().getVascEntryById(id));
|
||||
}
|
||||
} else if ("field".equals(vascType)) {
|
||||
if (entryId!=null) {
|
||||
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
|
||||
result.addAll(ve.getVascEntryFields());
|
||||
}
|
||||
} else if ("fieldset".equals(vascType)) {
|
||||
if (entryId!=null) {
|
||||
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
|
||||
result.addAll(ve.getVascEntryFieldSets());
|
||||
}
|
||||
} else if ("linkentries".equals(vascType)) {
|
||||
if (entryId!=null) {
|
||||
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
|
||||
result.addAll(ve.getVascLinkEntries());
|
||||
}
|
||||
} else if ("listoptions".equals(vascType)) {
|
||||
if (entryId!=null) {
|
||||
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
|
||||
result.addAll(ve.getListOptions());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
edit(object,false,true);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
return edit(object,true,true);
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
edit(object,true,false);
|
||||
}
|
||||
|
||||
public Object edit(Object object,boolean removeReal,boolean addEdit) throws VascException {
|
||||
|
||||
if (object instanceof VascEntry) {
|
||||
entryId = ((VascEntry)object).getId();
|
||||
}
|
||||
VascEntry veReal = ((VascEntryControllerLocal)vascController.getVascEntryController()).getMasterVascEntryById(entryId);
|
||||
|
||||
if ("entry".equals(vascType)) {
|
||||
|
||||
} else if ("field".equals(vascType)) {
|
||||
VascEntryField vef = (VascEntryField)object;
|
||||
if (removeReal) {
|
||||
VascEntryField vefReal = veReal.getVascEntryFieldById(vef.getId());
|
||||
veReal.removeVascEntryField(vefReal);
|
||||
}
|
||||
if (addEdit) {
|
||||
veReal.addVascEntryField(vef);
|
||||
}
|
||||
} else if ("fieldset".equals(vascType)) {
|
||||
VascEntryFieldSet vefs = (VascEntryFieldSet)object;
|
||||
if (removeReal) {
|
||||
VascEntryFieldSet vefsReal = veReal.getVascEntryFieldSetById(vefs.getId());
|
||||
veReal.removeVascEntryFieldSet(vefsReal);
|
||||
}
|
||||
if (addEdit) {
|
||||
veReal.addVascEntryFieldSet(vefs);
|
||||
}
|
||||
} else if ("linkentries".equals(vascType)) {
|
||||
VascLinkEntry vefs = (VascLinkEntry)object;
|
||||
if (removeReal) {
|
||||
VascLinkEntry vefsReal = veReal.getVascLinkEntryById(vefs.getId());
|
||||
veReal.removeVascLinkEntry(vefsReal);
|
||||
}
|
||||
if (addEdit) {
|
||||
veReal.addVascLinkEntry(vefs);
|
||||
}
|
||||
} else if ("listoptions".equals(vascType)) {
|
||||
VascEntryField vef = (VascEntryField)object;
|
||||
if (removeReal) {
|
||||
VascEntryField vefReal = veReal.getListOptionById(vef.getId());
|
||||
veReal.removeListOption(vefReal);
|
||||
}
|
||||
if (addEdit) {
|
||||
veReal.addListOption(vef);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new BeanVascEntryFieldValue();
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
if ("entry".equals(vascType)) {
|
||||
return new BeanVascEntryRecordCreator(DefaultVascEntry.class);
|
||||
} else if ("field".equals(vascType)) {
|
||||
return new BeanVascEntryRecordCreator(DefaultVascEntryField.class);
|
||||
} else if ("fieldset".equals(vascType)) {
|
||||
return new BeanVascEntryRecordCreator(DefaultVascEntryFieldSet.class);
|
||||
} else if ("linkentries".equals(vascType)) {
|
||||
return new BeanVascEntryRecordCreator(DefaultVascLinkEntry.class);
|
||||
} else if ("listoptions".equals(vascType)) {
|
||||
return new BeanVascEntryRecordCreator(DefaultVascEntryField.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascController the vascController to set
|
||||
*/
|
||||
public void setVascController(VascController vascController) {
|
||||
this.vascController = vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascType
|
||||
*/
|
||||
public String getVascType() {
|
||||
return vascType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascType the vascType to set
|
||||
*/
|
||||
public void setVascType(String vascType) {
|
||||
this.vascType = vascType;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -51,6 +51,13 @@ abstract public class AbstractVascBackendProxy implements VascBackend {
|
|||
this.backend=backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#isReadOnly()
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
return backend.isReadOnly();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.backend.VascBackend#fetchTotalExecuteSize(VascBackendState state)
|
||||
*/
|
||||
|
|
|
@ -22,12 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.proxy;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
|
@ -36,8 +32,6 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simple text search
|
||||
*
|
||||
|
@ -82,6 +76,9 @@ public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
|||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field);
|
||||
Object value = fieldValue.getValue(field, record);
|
||||
if (value==null) {
|
||||
continue; // can't search null values.
|
||||
}
|
||||
String r = value.toString().toLowerCase();
|
||||
if (r.contains(searchString)) {
|
||||
search.add(record);
|
||||
|
|
|
@ -33,9 +33,6 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add an sortware sort an a backend
|
||||
*
|
||||
|
@ -66,14 +63,15 @@ public class VascBackendProxySort extends AbstractVascBackendProxy {
|
|||
try {
|
||||
final VascEntryField field = entry.getVascEntryFieldById(state.getSortField());
|
||||
final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field.clone());
|
||||
Collections.sort(result, new Comparator() {
|
||||
Collections.sort(result, new Comparator<Object>() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public int compare(Object o1, Object o2) {
|
||||
try {
|
||||
Comparable c1 = null;
|
||||
Comparable c2 = null;
|
||||
if (field.getDisplayName()!=null) {
|
||||
c1 = (Comparable)fieldValue.getDisplayValue(field, o1);
|
||||
c2 = (Comparable)fieldValue.getDisplayValue(field, o2);
|
||||
c1 = fieldValue.getDisplayValue(field, o1);
|
||||
c2 = fieldValue.getDisplayValue(field, o2);
|
||||
} else {
|
||||
c1 = (Comparable)fieldValue.getValue(field, o1);
|
||||
c2 = (Comparable)fieldValue.getValue(field, o2);
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.validators.VascValidator;
|
||||
|
@ -45,6 +47,7 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
|
|||
protected Class<?> autoDetectClass = null;
|
||||
protected List<VascValidator> vascValidators = null;
|
||||
protected Map<String,String> properties = null;
|
||||
protected ObjectConverter objectConverter = null;
|
||||
|
||||
protected Object dataObject = null;
|
||||
protected String uiComponentId = null;
|
||||
|
@ -215,4 +218,18 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
|
|||
VascValueModel model = new VascValueModel();
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the objectConverter
|
||||
*/
|
||||
public ObjectConverter getObjectConverter() {
|
||||
return objectConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objectConverter the objectConverter to set
|
||||
*/
|
||||
public void setObjectConverter(ObjectConverter objectConverter) {
|
||||
this.objectConverter = objectConverter;
|
||||
}
|
||||
}
|
|
@ -403,7 +403,9 @@ public interface VascEntry extends Cloneable,Serializable {
|
|||
|
||||
|
||||
public void addListOption(VascEntryField listOption);
|
||||
public void removeListOption(VascEntryField listOption);
|
||||
public List<VascEntryField> getListOptions();
|
||||
public VascEntryField getListOptionById(String listOptionId);
|
||||
|
||||
|
||||
public void addVascBackendFilter(VascBackendFilter filter);
|
||||
|
|
|
@ -377,7 +377,7 @@ public interface VascEntryField extends Cloneable,Serializable {
|
|||
public void setGraphable(Boolean graphable);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* Force impl to have public clone method
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
|
|
|
@ -25,6 +25,8 @@ package net.forwardfire.vasc.core;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.validators.VascValidator;
|
||||
|
@ -67,6 +69,17 @@ public interface VascEntryFieldType extends Serializable {
|
|||
public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException;
|
||||
public VascValueModel provideEditorVascValueModel(int index,VascEntryField entryField) throws VascException;
|
||||
|
||||
|
||||
/**
|
||||
* @return the objectConverter
|
||||
*/
|
||||
public ObjectConverter getObjectConverter();
|
||||
|
||||
/**
|
||||
* @param objectConverter the objectConverter to set
|
||||
*/
|
||||
public void setObjectConverter(ObjectConverter objectConverter);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
|
|
|
@ -35,4 +35,6 @@ public interface VascEntryFieldTypeController {
|
|||
public VascEntryFieldType getVascEntryFieldTypeById(String id);
|
||||
|
||||
public List<String> getVascEntryFieldTypeIds();
|
||||
|
||||
public VascEntryFieldType getVascEntryFieldTypeByClass(Class<?> clazz);
|
||||
}
|
|
@ -26,6 +26,7 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.core.VascException;
|
||||
|
||||
/**
|
||||
* VascOptionValueModelListener to handle editors which sets entry parameter values.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 21, 2009
|
||||
|
|
|
@ -24,21 +24,21 @@ package net.forwardfire.vasc.impl;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldType;
|
||||
import net.forwardfire.vasc.core.VascEntryFinalizer;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||
import net.forwardfire.vasc.core.actions.VascAction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks for minimal needed stuff
|
||||
* and fills up the rest.
|
||||
|
@ -79,7 +79,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
// Check if backendId is valid
|
||||
VascBackend back = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
if (back==null) {
|
||||
throw new IllegalArgumentException("The VascEntry backendId is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
|
||||
throw new IllegalArgumentException("The VascEntry backend is not found in backends: '"+entry.getBackendId()+"' in entryId: "+id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,22 +234,17 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
vef.setEditReadOnly(false);
|
||||
}
|
||||
|
||||
/* moved to fillVascEntryFrontend
|
||||
if (vef.getVascEntryFieldValue()==null) {
|
||||
VascBackend back2 = vascController.getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
|
||||
}
|
||||
*/
|
||||
|
||||
if (vef.getVascEntryFieldType()==null) {
|
||||
Object defValue = vef.getDefaultValue();
|
||||
if (defValue != null) {
|
||||
for (String typeId: vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
|
||||
VascEntryFieldType type = vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById(typeId);
|
||||
Class<?> autoClass = type.getAutoDetectClass();
|
||||
if (autoClass!=null && autoClass.isAssignableFrom(defValue.getClass())) {
|
||||
vef.setVascEntryFieldType(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(defValue.getClass()));
|
||||
}
|
||||
if (vef.getVascEntryFieldType()==null) {
|
||||
vef.setVascEntryFieldType(vascController.getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField"));
|
||||
|
@ -257,6 +252,19 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
|
||||
|
||||
if (vef.getDefaultValue()!=null && vef.getDefaultValue() instanceof String) {
|
||||
if (vef.getVascEntryFieldType().getObjectConverter() != null) {
|
||||
Object value;
|
||||
try {
|
||||
value = vef.getVascEntryFieldType().getObjectConverter().convertTo(vef.getDefaultValue(), Locale.getDefault());
|
||||
} catch (ObjectConverterException e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
vef.setDefaultValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
//for (VascValidator vv:vef.getVascValidators()) {
|
||||
//}
|
||||
}
|
||||
|
@ -363,6 +371,18 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
//VascBackend back2 = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
//vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
|
||||
}
|
||||
|
||||
if (vef.getDefaultValue()!=null && vef.getDefaultValue() instanceof String) {
|
||||
if (vef.getVascEntryFieldType()!=null && vef.getVascEntryFieldType().getObjectConverter() != null) {
|
||||
Object value;
|
||||
try {
|
||||
value = vef.getVascEntryFieldType().getObjectConverter().convertTo(vef.getDefaultValue(), Locale.getDefault());
|
||||
} catch (ObjectConverterException e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
vef.setDefaultValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
|
||||
package net.forwardfire.vasc.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
|
@ -62,5 +65,14 @@ public class DefaultVascBackendController implements VascBackendControllerLocal
|
|||
}
|
||||
backends.put(backend.getId(), backend);
|
||||
}
|
||||
|
||||
public List<String> getVascBackendIds() {
|
||||
List<String> result = new ArrayList<String>(50);
|
||||
for (String id:backends.keySet()) {
|
||||
result.add(id);
|
||||
}
|
||||
Collections.sort(result); // lets do abc for consistance behauvior.
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -824,6 +824,19 @@ public class DefaultVascEntry implements VascEntry {
|
|||
return listOptions;
|
||||
}
|
||||
|
||||
public VascEntryField getListOptionById(String listOptionId) {
|
||||
for (VascEntryField vef:listOptions) {
|
||||
if (vef.getId().equals(listOptionId)) {
|
||||
return vef;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeListOption(VascEntryField listOption) {
|
||||
listOptions.remove(listOption);
|
||||
}
|
||||
|
||||
|
||||
public void addVascBackendFilter(VascBackendFilter filter) {
|
||||
backendFilters.add(filter);
|
||||
|
|
|
@ -37,7 +37,9 @@ import net.forwardfire.vasc.backend.proxy.VascBackendProxyTimerLogger;
|
|||
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.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
import net.forwardfire.vasc.impl.actions.CSVExportGlobalAction;
|
||||
|
@ -139,20 +141,26 @@ public class DefaultVascFactory {
|
|||
static public void fillVascControllerLocalEntries(VascEntryControllerLocal c,VascController con) throws VascException {
|
||||
for (String id:c.getVascEntryIds()) {
|
||||
VascEntry entry = c.getMasterVascEntryById(id);
|
||||
if (entry.isVascDisplayOnly()==false) {
|
||||
if (entry.isVascAdminCreate()) {
|
||||
entry.addRowAction(new AddRowAction());
|
||||
|
||||
// hackje for calling multiple times on same entries.
|
||||
if (entry.getGlobalActionById(XMLExportGlobalAction.ACTION_ID)==null) {
|
||||
|
||||
if (entry.isVascDisplayOnly()==false) {
|
||||
if (entry.isVascAdminCreate()) {
|
||||
entry.addRowAction(new AddRowAction());
|
||||
}
|
||||
if (entry.isVascAdminEdit()) {
|
||||
entry.addRowAction(new EditRowAction());
|
||||
}
|
||||
if (entry.isVascAdminDelete()) {
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
}
|
||||
}
|
||||
if (entry.isVascAdminEdit()) {
|
||||
entry.addRowAction(new EditRowAction());
|
||||
}
|
||||
if (entry.isVascAdminDelete()) {
|
||||
entry.addRowAction(new DeleteRowAction());
|
||||
}
|
||||
}
|
||||
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
entry.addGlobalAction(new XMLExportGlobalAction());
|
||||
entry.addGlobalAction(new CSVExportGlobalAction());
|
||||
entry.addGlobalAction(new RefreshDataGlobalAction());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
DefaultVascEntryResourceResolver t = new DefaultVascEntryResourceResolver(resourceBundle);
|
||||
|
@ -208,6 +216,14 @@ public class DefaultVascFactory {
|
|||
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
frontendData.getVascEntryState().setVascBackend(backend);
|
||||
frontendData.getVascEntryState().setVascEntry(entry);
|
||||
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
if (field.getVascEntryFieldValue()==null) {
|
||||
VascEntryFieldValue v = backend.provideVascEntryFieldValue(field);
|
||||
field.setVascEntryFieldValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
frontendData.setVascFrontendPager(new DefaultVascFrontendPager(entry));
|
||||
frontendData.setVascFrontendActions(new DefaultVascFrontendActions(entry));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Date;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
@ -170,21 +171,33 @@ public class DefaultVascFrontendActions implements VascFrontendActions {
|
|||
public void refreshData() {
|
||||
entry.getVascFrontendData().fireVascFrontendEvent(entry,VascEntryFrontendEventListener.VascFrontendEventType.PRE_READ, null);
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
|
||||
VascBackendState backendState = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
|
||||
try {
|
||||
// check and correct max page size
|
||||
if (entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()>entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax()) {
|
||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSizeMax());
|
||||
if (backendState.getPageSize() > backendState.getPageSizeMax()) {
|
||||
backendState.setPageSize(backendState.getPageSizeMax());
|
||||
}
|
||||
|
||||
// Sets parameters to backend state
|
||||
for (String key:entry.getEntryParameterKeys()) {
|
||||
Object value = entry.getEntryParameter(key);
|
||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(key, value);
|
||||
}
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(entry.getVascFrontendData().getVascEntryState().getVascBackendState()));
|
||||
backendState.setDataParameter(key, value);
|
||||
}
|
||||
|
||||
// also update total every time
|
||||
Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(entry.getVascFrontendData().getVascEntryState().getVascBackendState());
|
||||
// Execute to get data.
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(backendState));
|
||||
|
||||
// Update total every time first
|
||||
Long total = entry.getVascFrontendData().getVascEntryState().getVascBackend().fetchTotalExecuteSize(backendState);
|
||||
entry.getVascFrontendData().getVascEntryState().setTotalBackendRecords(total);
|
||||
|
||||
// check if we need to change the current page
|
||||
int pages = new Long(total/backendState.getPageSize()).intValue();
|
||||
if (backendState.getPageIndex() > pages) {
|
||||
backendState.setPageIndex(pages);
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataList(entry.getVascFrontendData().getVascEntryState().getVascBackend().execute(backendState));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
|
@ -42,8 +40,6 @@ import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFronte
|
|||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendHelper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
|
|
|
@ -148,7 +148,7 @@ public class DefaultVascFrontendPager implements VascFrontendPager {
|
|||
if (total==null) {
|
||||
return result; // no pages
|
||||
}
|
||||
int pages = new Long(total/state.getPageSize()).intValue();
|
||||
int pages = new Long(total/state.getPageSize()).intValue();
|
||||
for (int i=0;i<=pages;i++) {
|
||||
VascBackendPageNumber pn = new VascBackendPageNumber(i);
|
||||
if (state.getPageIndex()==i) {
|
||||
|
|
|
@ -40,6 +40,9 @@ public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType {
|
|||
public VascEntryFieldType clone() throws CloneNotSupportedException {
|
||||
DefaultVascEntryFieldType clone = new DefaultVascEntryFieldType();
|
||||
clone.id=id;
|
||||
if (objectConverter!=null) {
|
||||
clone.objectConverter=objectConverter.clone();
|
||||
}
|
||||
clone.autoDetectClass=autoDetectClass;
|
||||
clone.uiComponentId=uiComponentId;
|
||||
clone.inputMask=inputMask;
|
||||
|
|
|
@ -100,4 +100,16 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo
|
|||
Collections.sort(result); // lets do abc for consistance behauvior.
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public VascEntryFieldType getVascEntryFieldTypeByClass(Class<?> clazz) {
|
||||
for (String typeId: vascEntryFieldTypes.keySet()) {
|
||||
VascEntryFieldType type = getVascEntryFieldTypeById(typeId);
|
||||
Class<?> autoClass = type.getAutoDetectClass();
|
||||
if (autoClass!=null && autoClass.isAssignableFrom(clazz)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import net.forwardfire.vasc.core.VascEntryFieldType;
|
|||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.x4o.xml.conv.DefaultObjectConverterProvider;
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
import org.x4o.xml.core.X4OParser;
|
||||
import org.x4o.xml.element.Element;
|
||||
|
||||
|
@ -63,8 +65,13 @@ public class FieldTypeParser extends X4OParser {
|
|||
|
||||
public List<VascEntryFieldType> getTypes() {
|
||||
List<VascEntryFieldType> result = new ArrayList<VascEntryFieldType>(4);
|
||||
DefaultObjectConverterProvider convProvider = new DefaultObjectConverterProvider(true);
|
||||
for (Element e:getElementContext().getRootElement().getChilderen()) {
|
||||
VascEntryFieldType a = (VascEntryFieldType)e.getElementObject();
|
||||
if (a.getObjectConverter()==null && a.getAutoDetectClass()!=null) {
|
||||
ObjectConverter conv = convProvider.getObjectConverterForClass(a.getAutoDetectClass());
|
||||
a.setObjectConverter(conv); // move to x4o or finalizer
|
||||
}
|
||||
result.add(a);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -43,6 +43,7 @@ public class VascSelectItemModelStringEnum implements VascSelectItemModel {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Object data = null;
|
||||
private Class<?> enumClass = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
private Boolean returnKeyValue = null;
|
||||
|
@ -54,6 +55,12 @@ public class VascSelectItemModelStringEnum implements VascSelectItemModel {
|
|||
public List<VascSelectItem> getVascSelectItems(VascEntry currentEntry) throws VascException {
|
||||
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
|
||||
|
||||
if (enumClass!=null) {
|
||||
for (Object o:enumClass.getEnumConstants()) {
|
||||
String value = o.toString();
|
||||
result.add(new VascSelectItem(value,value,value));
|
||||
}
|
||||
}
|
||||
if (data==null) {
|
||||
return result;
|
||||
}
|
||||
|
@ -143,4 +150,18 @@ public class VascSelectItemModelStringEnum implements VascSelectItemModel {
|
|||
public void setUseParentFields(Boolean useParentFields) {
|
||||
this.useParentFields = useParentFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the enumClass
|
||||
*/
|
||||
public Class<?> getEnumClass() {
|
||||
return enumClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enumClass the enumClass to set
|
||||
*/
|
||||
public void setEnumClass(Class<?> enumClass) {
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntryFieldType"
|
||||
childClass="net.forwardfire.vasc.validators.VascValidator"
|
||||
method="addVascValidator"/>
|
||||
|
||||
|
||||
<eld:elementClass tag="dateFutureValidator" objectClassName="net.forwardfire.vasc.validators.VascDateFutureValidator"/>
|
||||
<eld:elementClass tag="datePastValidator" objectClassName="net.forwardfire.vasc.validators.VascDatePastValidator"/>
|
||||
<eld:elementClass tag="intSizeValidator" objectClassName="net.forwardfire.vasc.validators.VascIntSizeValidator"/>
|
||||
|
@ -28,4 +28,27 @@
|
|||
<eld:elementClass tag="stringRegexValidator" objectClassName="net.forwardfire.vasc.validators.VascStringRegexValidator"/>
|
||||
<eld:elementClass tag="stringZipCodeValidator" objectClassName="net.forwardfire.vasc.validators.VascStringZipCodeValidator"/>
|
||||
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntryFieldType"
|
||||
childClass="org.x4o.xml.conv.ObjectConverter"
|
||||
method="setObjectConverter"/>
|
||||
|
||||
<eld:elementRefectionBindingHandler parentClass="org.x4o.xml.conv.ObjectConverter"
|
||||
childClass="org.x4o.xml.conv.ObjectConverter"
|
||||
method="addObjectConverter"/>
|
||||
|
||||
<eld:elementClass tag="beanConverter" elementClassName="org.x4o.xml.impl.lang.BeanElement"
|
||||
description="Define an loadable in bean.class for an ObjectConverter."
|
||||
/>
|
||||
<eld:elementClass tag="booleanConverter" objectClassName="org.x4o.xml.conv.text.BooleanConverter" />
|
||||
<eld:elementClass tag="byteConverter" objectClassName="org.x4o.xml.conv.text.ByteConverter" />
|
||||
<eld:elementClass tag="characterConverter" objectClassName="org.x4o.xml.conv.text.CharacterConverter" />
|
||||
<eld:elementClass tag="doubleConverter" objectClassName="org.x4o.xml.conv.text.DoubleConverter" />
|
||||
<eld:elementClass tag="floatConverter" objectClassName="org.x4o.xml.conv.text.FloatConverter" />
|
||||
<eld:elementClass tag="IntegerConverter" objectClassName="org.x4o.xml.conv.text.IntegerConverter" />
|
||||
<eld:elementClass tag="LongConverter" objectClassName="org.x4o.xml.conv.text.LongConverter" />
|
||||
<eld:elementClass tag="UrlConverter" objectClassName="org.x4o.xml.conv.text.URLConverter" />
|
||||
<eld:elementClass tag="ClassConverter" objectClassName="org.x4o.xml.conv.text.ClassConverter" />
|
||||
<eld:elementClass tag="EnumConverter" objectClassName="org.x4o.xml.conv.text.EnumConverter" />
|
||||
|
||||
|
||||
</eld:root>
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.VascEntryFieldSet" method="addVascEntryFieldSet"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.VascLinkEntry" method="addVascLinkEntry"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.VascBackendFilter" method="addVascBackendFilter"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.backend.VascBackendFilter" method="addVascBackendFilter"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.actions.GlobalVascAction" method="addGlobalAction"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.actions.RowVascAction" method="addRowAction"/>
|
||||
<eld:elementRefectionBindingHandler parentClass="net.forwardfire.vasc.core.VascEntry" childClass="net.forwardfire.vasc.core.actions.ColumnVascAction" method="addColumnAction"/>
|
||||
|
@ -32,7 +32,11 @@
|
|||
<eld:elementClass tag="vascSelectItemEntryParameter" elementClassName="net.forwardfire.vasc.impl.x4o.VascLinkEntryParameterElement"/>
|
||||
|
||||
<eld:elementClass tag="vascSelectItemModelString" objectClassName="net.forwardfire.vasc.impl.ui.VascSelectItemModelStringEnum"/>
|
||||
<eld:elementClass tag="vascSelectItemModelEnum" objectClassName="net.forwardfire.vasc.impl.ui.VascSelectItemModelStringEnum"/>
|
||||
<eld:elementClass tag="vascSelectItemModelEnum" objectClassName="net.forwardfire.vasc.impl.ui.VascSelectItemModelStringEnum">
|
||||
<eld:elementClassAttribute attributeName="enumClass">
|
||||
<eld:attributeClassConverter/>
|
||||
</eld:elementClassAttribute>
|
||||
</eld:elementClass>
|
||||
|
||||
|
||||
<eld:elementClass tag="fieldSet" objectClassName="net.forwardfire.vasc.impl.DefaultVascEntryFieldSet" elementClassName="net.forwardfire.vasc.impl.x4o.VascEntryFieldSetElement">
|
||||
|
@ -71,4 +75,8 @@
|
|||
<eld:elementClass tag="stringZipCodeValidator" objectClassName="net.forwardfire.vasc.validators.VascStringZipCodeValidator"/>
|
||||
|
||||
|
||||
<eld:elementClass tag="virtualVascBackend" objectClassName="net.forwardfire.vasc.backend.VirtualVascBackend">
|
||||
<eld:elementConfigurator bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
|
||||
</eld:elementClass>
|
||||
|
||||
</eld:root>
|
|
@ -21,12 +21,12 @@
|
|||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>vasc-demo-swing</artifactId>
|
||||
<groupId>net.forwardfire.vasc.demo</groupId>
|
||||
<name>vasc-demo-swing</name>
|
||||
<description>vasc-demo-swing</description>
|
||||
<dependencies>
|
||||
|
@ -31,6 +30,11 @@
|
|||
<artifactId>vasc-backend-mongodb</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-backend-metamodel</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-backend-jdbc</artifactId>
|
||||
|
@ -41,5 +45,15 @@
|
|||
<artifactId>juel</artifactId>
|
||||
<version>${juel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.19</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,640 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import org.eobjects.metamodel.DataContext;
|
||||
import org.eobjects.metamodel.schema.Column;
|
||||
import org.eobjects.metamodel.schema.Table;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.backend.VascBackendFilter;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv;
|
||||
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb;
|
||||
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.VascEntryController;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryFieldSet;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelTabbed;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.validators.VascValidator;
|
||||
|
||||
public class JMainFrame extends JFrame {
|
||||
|
||||
VascManager vascManager = null;
|
||||
SwingPanelIntegration spi = null;
|
||||
JTabbedPane tabPane = null;
|
||||
JTree vascTree = null;
|
||||
JMenu fileMenu = new JMenu("File");
|
||||
JMenu connMenu = new JMenu("Connection");
|
||||
JMenu vascMenu = new JMenu("Entries");
|
||||
|
||||
public JMainFrame(VascManager vascManager ) {
|
||||
this.vascManager=vascManager;
|
||||
setTitle("Vasc Swing Demo");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(createTreePane(), BorderLayout.LINE_START);
|
||||
add(createContentPane(), BorderLayout.LINE_END);
|
||||
add(createLogPane(), BorderLayout.PAGE_END);
|
||||
|
||||
createMenuItems();
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
menubar.add(fileMenu);
|
||||
menubar.add(connMenu);
|
||||
menubar.add(vascMenu);
|
||||
|
||||
// view
|
||||
setJMenuBar(menubar);
|
||||
setMinimumSize(new Dimension(1111,888));
|
||||
pack();
|
||||
//setVisible(true);
|
||||
|
||||
//spi.createNewVascView(ve);
|
||||
}
|
||||
|
||||
class VascTreeModel extends DefaultTreeModel {
|
||||
public VascTreeModel(TreeNode root) {
|
||||
super(root);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -7436681803506994277L;
|
||||
|
||||
@Override
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
super.addTreeModelListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel createTreePane() {
|
||||
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.NONE,null));
|
||||
|
||||
vascTree = new JTree(new VascTreeModel(root));
|
||||
vascTree.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
if (e.getClickCount() == 2 && vascTree.getSelectionModel().isSelectionEmpty()==false) {
|
||||
try {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)vascTree.getSelectionModel().getSelectionPath().getLastPathComponent();
|
||||
if (node.getUserObject() instanceof String) {
|
||||
return;
|
||||
}
|
||||
VascTreeNode vascNode = (VascTreeNode)node.getUserObject();
|
||||
if (vascNode != null) {
|
||||
if (vascNode.type == VascTreeNodeType.ENTRY) {
|
||||
VascEntry ee = vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.id).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, vascManager.getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ee);
|
||||
} else if (vascNode.type == VascTreeNodeType.ENTRY_FIELD) {
|
||||
VascEntryField vef = vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.entryId).getVascEntryFieldById(vascNode.id);
|
||||
JDialogVascEntryField d = new JDialogVascEntryField(JMainFrame.this,vef);
|
||||
d.setVisible(true);
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JPanel treePanel = new JPanel();
|
||||
treePanel.setBorder(BorderFactory.createLineBorder(Color.PINK));
|
||||
treePanel.add(vascTree);
|
||||
return treePanel;
|
||||
}
|
||||
|
||||
private JPanel createContentPane() {
|
||||
JPanel contentPane = new JPanel();
|
||||
tabPane = new JTabbedPane();
|
||||
spi = new SwingPanelTabbed(tabPane);
|
||||
contentPane.add(tabPane);
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
private JPanel createLogPane() {
|
||||
JPanel logPanel = new JPanel();
|
||||
logPanel.add(new JLabel("log"));
|
||||
return logPanel;
|
||||
}
|
||||
|
||||
class VascTreeNode {
|
||||
public VascTreeNode() {}
|
||||
public VascTreeNode(VascTreeNodeType type,String id) { this.type=type;this.id=id; }
|
||||
public VascTreeNode(VascTreeNodeType type,String id,String entryId) { this.type=type;this.id=id;this.entryId=entryId; }
|
||||
VascTreeNodeType type;
|
||||
String id;
|
||||
String entryId;
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
enum VascTreeNodeType {
|
||||
NONE,
|
||||
BACKEND,
|
||||
ENTRY,
|
||||
ENTRY_FIELD,
|
||||
ENTRY_FIELD_SET
|
||||
}
|
||||
|
||||
private void rebuildTree() {
|
||||
|
||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode)vascTree.getModel().getRoot();
|
||||
root.removeAllChildren();
|
||||
|
||||
DefaultMutableTreeNode backends = new DefaultMutableTreeNode("VascBackends");
|
||||
for (String id:vascManager.getVascController().getVascBackendController().getVascBackendIds()) {
|
||||
DefaultMutableTreeNode backendNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.BACKEND,id));
|
||||
backends.add(backendNode);
|
||||
}
|
||||
root.add(backends);
|
||||
|
||||
DefaultMutableTreeNode entries = new DefaultMutableTreeNode("VascEntries");
|
||||
for (String id:vascManager.getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(id);
|
||||
DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,id));
|
||||
entries.add(entryNode);
|
||||
|
||||
DefaultMutableTreeNode fields = new DefaultMutableTreeNode("Fields");
|
||||
for (VascEntryField vef:ve.getVascEntryFields()) {
|
||||
DefaultMutableTreeNode vefNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD,vef.getId(),id));
|
||||
fields.add(vefNode);
|
||||
|
||||
/*
|
||||
DefaultMutableTreeNode validators = new DefaultMutableTreeNode("Validators");
|
||||
for (VascValidator vv:vef.getVascValidators()) {
|
||||
DefaultMutableTreeNode vNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD,vv.getClass().getSimpleName()));
|
||||
validators.add(vNode);
|
||||
}
|
||||
vefNode.add(validators);
|
||||
*/
|
||||
}
|
||||
entryNode.add(fields);
|
||||
|
||||
DefaultMutableTreeNode fieldSets = new DefaultMutableTreeNode("FieldSets");
|
||||
for (VascEntryFieldSet vefs:ve.getVascEntryFieldSets()) {
|
||||
DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vefs.getId(),id));
|
||||
fieldSets.add(vefsNode);
|
||||
}
|
||||
entryNode.add(fieldSets);
|
||||
|
||||
DefaultMutableTreeNode links = new DefaultMutableTreeNode("Links");
|
||||
for (VascLinkEntry vle:ve.getVascLinkEntries()) {
|
||||
DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vle.getId()));
|
||||
links.add(vefsNode);
|
||||
}
|
||||
entryNode.add(links);
|
||||
|
||||
DefaultMutableTreeNode filters = new DefaultMutableTreeNode("Backend Filters");
|
||||
for (VascBackendFilter vbf:ve.getVascBackendFilters()) {
|
||||
DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vbf.getClass().getSimpleName()));
|
||||
filters.add(vefsNode);
|
||||
}
|
||||
entryNode.add(links);
|
||||
|
||||
DefaultMutableTreeNode param = new DefaultMutableTreeNode("Backend Parameters");
|
||||
for (String key:ve.getEntryParameterKeys()) {
|
||||
DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,key));
|
||||
param.add(vefsNode);
|
||||
}
|
||||
entryNode.add(param);
|
||||
|
||||
|
||||
DefaultMutableTreeNode options = new DefaultMutableTreeNode("List Options");
|
||||
for (VascEntryField vef:ve.getListOptions()) {
|
||||
DefaultMutableTreeNode vefsNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY_FIELD_SET,vef.getId()));
|
||||
options.add(vefsNode);
|
||||
}
|
||||
entryNode.add(options);
|
||||
}
|
||||
root.add(entries);
|
||||
|
||||
SwingUtilities.updateComponentTreeUI(vascTree);
|
||||
}
|
||||
|
||||
private void createMenuItems() {
|
||||
JMenuItem openXmlItem = new JMenuItem("Open Xml");
|
||||
openXmlItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
//fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
int returnVal = fc.showOpenDialog((JMenuItem)e.getSource());
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
vascManager.openFile(file);
|
||||
rebuildTree();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
fileMenu.add(openXmlItem);
|
||||
JMenuItem closeXmlItem = new JMenuItem("Close");
|
||||
fileMenu.add(closeXmlItem);
|
||||
fileMenu.addSeparator();
|
||||
JMenuItem exitItem = new JMenuItem("Exit");
|
||||
fileMenu.add(exitItem);
|
||||
|
||||
JMenuItem connectVascItem = new JMenuItem("Add Vasc");
|
||||
connectVascItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
connMenu.add(connectVascItem);
|
||||
|
||||
JMenuItem connectMongoItem = new JMenuItem("Connect Mongo");
|
||||
connectMongoItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
connMenu.add(connectMongoItem);
|
||||
|
||||
JMenuItem connectPgItem = new JMenuItem("Add Postgres");
|
||||
connMenu.add(connectPgItem);
|
||||
JMenuItem connectMysqlItem = new JMenuItem("Add Mysql");
|
||||
connMenu.add(connectMysqlItem);
|
||||
JMenuItem connectLdapItem = new JMenuItem("Add Ldap");
|
||||
connMenu.add(connectLdapItem);
|
||||
connMenu.addSeparator();
|
||||
JMenuItem connectMetaCsvItem = new JMenuItem("Add meta csv");
|
||||
connectMetaCsvItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JDialogMetaCsv d = new JDialogMetaCsv(JMainFrame.this);
|
||||
d.setVisible(true);
|
||||
}
|
||||
});
|
||||
connMenu.add(connectMetaCsvItem);
|
||||
JMenuItem connectMetaXmlItem = new JMenuItem("Add meta xml");
|
||||
connMenu.add(connectMetaXmlItem);
|
||||
JMenuItem connectMetaMongoItem = new JMenuItem("Add meta mongo");
|
||||
connectMetaMongoItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JDialogMetaMongodb d = new JDialogMetaMongodb(JMainFrame.this);
|
||||
d.setVisible(true);
|
||||
}
|
||||
});
|
||||
connMenu.add(connectMetaMongoItem);
|
||||
JMenuItem connectMetaJdbcItem = new JMenuItem("Add meta jdbc");
|
||||
connMenu.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.add(item);
|
||||
}
|
||||
*/
|
||||
|
||||
JMenuItem item = new JMenuItem("Close tab.");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (tabPane.getSelectedIndex()>=0) {
|
||||
tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
|
||||
public class JDialogMetaCsv extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
|
||||
public JDialogMetaCsv(Frame aFrame) {
|
||||
setTitle("Add csv file");
|
||||
setMinimumSize(new Dimension(640,480));
|
||||
setPreferredSize(new Dimension(999,666));
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
clearAndHide();
|
||||
}
|
||||
});
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
//mainPanel.add(createPanelTop(),BorderLayout.NORTH);
|
||||
mainPanel.add(createPanelCenter(),BorderLayout.CENTER);
|
||||
//mainPanel.add(createPanelBottom(),BorderLayout.SOUTH);
|
||||
getContentPane().add(mainPanel);
|
||||
pack();
|
||||
setLocationRelativeTo(aFrame);
|
||||
}
|
||||
|
||||
public void clearAndHide() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
//result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("File"));
|
||||
JButton fileButton = new JButton("Open");
|
||||
fileButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
int returnVal = fc.showOpenDialog((JButton)e.getSource());
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
MetaModelDataContextCsv ds = new MetaModelDataContextCsv();
|
||||
ds.setFile(file.getAbsolutePath());
|
||||
createMetaEntry(ds,file.getName(),null);
|
||||
}
|
||||
}
|
||||
});
|
||||
result.add(fileButton);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class JDialogMetaMongodb extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JTextField hostname = null;
|
||||
private JTextField database = null;
|
||||
|
||||
public JDialogMetaMongodb(Frame aFrame) {
|
||||
setTitle("Add mongodb");
|
||||
setMinimumSize(new Dimension(800,600));
|
||||
setPreferredSize(new Dimension(999,666));
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
clearAndHide();
|
||||
}
|
||||
});
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
//mainPanel.add(createPanelTop(),BorderLayout.NORTH);
|
||||
mainPanel.add(createPanelCenter(),BorderLayout.CENTER);
|
||||
//mainPanel.add(createPanelBottom(),BorderLayout.SOUTH);
|
||||
getContentPane().add(mainPanel);
|
||||
pack();
|
||||
setLocationRelativeTo(aFrame);
|
||||
}
|
||||
|
||||
public void clearAndHide() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
//result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("Hostname"));
|
||||
hostname = new JTextField("localhost");
|
||||
result.add(hostname);
|
||||
|
||||
result.add(new JLabel("Database"));
|
||||
database = new JTextField("lefiona");
|
||||
result.add(database);
|
||||
|
||||
JButton fileButton = new JButton("Connect");
|
||||
fileButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb();
|
||||
ds.setHostname(hostname.getText());
|
||||
ds.setDatabase(database.getText());
|
||||
DataContext metaDs = ds.getDataContext();
|
||||
for (String table:metaDs.getDefaultSchema().getTableNames()) {
|
||||
createMetaEntry(ds,table,table);
|
||||
}
|
||||
}
|
||||
});
|
||||
result.add(fileButton);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class JDialogVascEntryField extends JDialog implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8638394652416472734L;
|
||||
private JButton okButton = null;
|
||||
private JButton cancelButton = null;
|
||||
private JTextField idField = null;
|
||||
private JTextField backendNameField = null;
|
||||
private JComboBox fieldTypeBox = null;
|
||||
private VascEntryField field = null;
|
||||
|
||||
public JDialogVascEntryField(Frame aFrame,VascEntryField field) {
|
||||
this.field = field;
|
||||
setTitle("Vasc Entry Field");
|
||||
setMinimumSize(new Dimension(800,600));
|
||||
setPreferredSize(new Dimension(999,666));
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent we) {
|
||||
clearAndHide();
|
||||
}
|
||||
});
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
//mainPanel.add(createPanelTop(),BorderLayout.NORTH);
|
||||
mainPanel.add(createPanelCenter(),BorderLayout.CENTER);
|
||||
mainPanel.add(createPanelBottom(),BorderLayout.SOUTH);
|
||||
getContentPane().add(mainPanel);
|
||||
pack();
|
||||
setLocationRelativeTo(aFrame);
|
||||
}
|
||||
|
||||
public void clearAndHide() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public JPanel createPanelCenter() {
|
||||
JPanel result = new JPanel();
|
||||
//result.setLayout(new SpringLayout());
|
||||
|
||||
result.add(new JLabel("id"));
|
||||
idField = new JTextField(field.getId());
|
||||
result.add(idField);
|
||||
|
||||
result.add(new JLabel("backendName"));
|
||||
backendNameField = new JTextField(field.getBackendName());
|
||||
result.add(backendNameField);
|
||||
|
||||
result.add(new JLabel("type"));
|
||||
fieldTypeBox = new JComboBox(vascManager.getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeIds().toArray());
|
||||
fieldTypeBox.setSelectedItem(field.getVascEntryFieldType().getId());
|
||||
result.add(fieldTypeBox);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private JPanel createPanelBottom() {
|
||||
JPanel result = new JPanel();
|
||||
okButton = new JButton("ok");
|
||||
okButton.addActionListener(this);
|
||||
cancelButton = new JButton("cancel");
|
||||
cancelButton.addActionListener(this);
|
||||
result.add(okButton);
|
||||
result.add(cancelButton);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource()==cancelButton) {
|
||||
clearAndHide();
|
||||
return;
|
||||
}
|
||||
if (e.getSource()==okButton) {
|
||||
|
||||
VascEntryField vef = ((VascEntryControllerLocal)vascManager.getVascController().getVascEntryController()).getMasterVascEntryById(field.getVascEntry().getId()).getVascEntryFieldById(field.getId());
|
||||
vef.setVascEntryFieldType(vascManager.getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeById((String)fieldTypeBox.getSelectedItem()));
|
||||
|
||||
clearAndHide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createMetaEntry(MetaModelDataContextProvider ds,String id,String 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");
|
||||
for (Column c:cols) {
|
||||
VascEntryField vef = new DefaultVascEntryField(c.getName());
|
||||
vef.setVascEntryFieldType(vascManager.getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeByClass(c.getType().getJavaEquivalentClass()));
|
||||
ve.addVascEntryField(vef);
|
||||
}
|
||||
|
||||
try {
|
||||
((VascBackendControllerLocal)vascManager.getVascController().getVascBackendController()).addVascBackend(backend);
|
||||
((VascEntryControllerLocal)vascManager.getVascController().getVascEntryController()).addVascEntry(ve, vascManager.getVascController());
|
||||
|
||||
// mm TODO rm this fill which adds the global actions ... and show updated tree in editor
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascManager.getVascController().getVascEntryController(), vascManager.getVascController());
|
||||
rebuildTree();
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,115 +22,38 @@
|
|||
|
||||
package net.forwardfire.vasc.demo.swing;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
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.frontends.swing.SwingVascFrontend;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.x4o.VascParser;
|
||||
|
||||
public class SwingStartup {
|
||||
|
||||
private JMainFrame mainFrame = null;
|
||||
private VascManager vascManager = null;
|
||||
|
||||
|
||||
public static void main(String[] argu){
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
try {
|
||||
VascEntry entry = getVascTable();
|
||||
|
||||
SwingStartup s = new SwingStartup();
|
||||
JFrame frame = s.viewEntry(entry);
|
||||
|
||||
while (frame.isVisible()) {
|
||||
Thread.sleep(100000);
|
||||
}
|
||||
SwingStartup s = new SwingStartup();
|
||||
s.init();
|
||||
s.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
// get GUI
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
|
||||
fill(ee,entry.getVascFrontendData().getVascController());
|
||||
viewEntry(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// define redering
|
||||
JPanel panel = new JPanel();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel);
|
||||
frame.add(panel);
|
||||
public void init() throws Exception {
|
||||
vascManager = new VascManager();
|
||||
vascManager.start();
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
return frame;
|
||||
mainFrame = new JMainFrame(vascManager);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static public void fill(VascEntry entry,VascController vascController) {
|
||||
DefaultVascFactory.fillVascEntryFrontend(entry, vascController, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(0);
|
||||
}
|
||||
|
||||
static public VascEntry getVascTable() throws Exception {
|
||||
|
||||
VascController c = DefaultVascFactory.getDefaultVascController(2288L,"forwarddire.net","user","admin");
|
||||
|
||||
VascParser parser = new VascParser(c);
|
||||
File f = File.createTempFile("test-vasc", ".xml");
|
||||
parser.setDebugOutputStream(new FileOutputStream(f));
|
||||
parser.parseResource("net/forwardfire/vasc/demo/swing/example/tables.xml");
|
||||
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) c.getVascEntryController(), c);
|
||||
|
||||
VascEntry entry = parser.getVascController().getVascEntryController().getVascEntryById("users");
|
||||
fill(entry,c);
|
||||
return entry;
|
||||
|
||||
public void open() throws Exception {
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
static void printEntry(VascEntry e) throws Exception {
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package net.forwardfire.vasc.demo.swing;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.x4o.VascParser;
|
||||
|
||||
public class VascManager {
|
||||
|
||||
VascController vascController = null;
|
||||
|
||||
public VascManager() {
|
||||
|
||||
}
|
||||
|
||||
public void start() {
|
||||
try {
|
||||
vascController = DefaultVascFactory.getDefaultVascController(2288L,"forwardfire.net","user","admin");
|
||||
initEditor();
|
||||
} catch (VascException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
private void initEditor() {
|
||||
try {
|
||||
VascParser parser = new VascParser(vascController);
|
||||
parser.addGlobalELBean("vascController", vascController);
|
||||
parser.parseResource("net/forwardfire/vasc/demo/swing/example/vasc-edit.xml");
|
||||
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void openFile(File file) {
|
||||
try {
|
||||
VascParser parser = new VascParser(vascController);
|
||||
File f = File.createTempFile("test-vasc", ".xml");
|
||||
parser.setDebugOutputStream(new FileOutputStream(f));
|
||||
parser.parseFile(file.getAbsolutePath());
|
||||
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public VascController getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<x4o:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
|
||||
xmlns:mm="http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld"
|
||||
xmlns:m="http://vasc.forwardfire.net/eld/vasc-backend-mongodb.eld"
|
||||
xmlns:l="http://vasc.forwardfire.net/eld/vasc-backend-ldap.eld"
|
||||
xmlns:j="http://vasc.forwardfire.net/eld/vasc-backend-jdbc.eld"
|
||||
|
@ -7,6 +8,54 @@
|
|||
>
|
||||
|
||||
|
||||
<mm:csvDataContext
|
||||
el.id="metaDS_csv"
|
||||
file="/tmp/csv_people.csv"
|
||||
/>
|
||||
<mm:metaModelBackend
|
||||
id="meta_people_backend"
|
||||
dataContextProvider="${metaDS_csv}"
|
||||
table="csv_people"
|
||||
tableId="id"
|
||||
/>
|
||||
<v:entry id="meta_people" backendId="meta_people_backend">
|
||||
<v:field id="id" list="false"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="age"/>
|
||||
<v:field id="gender" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelString data="male,female,unknown"/>
|
||||
</v:field>
|
||||
</v:entry>
|
||||
|
||||
|
||||
|
||||
<mm:mongodbDataContext
|
||||
el.id="metaDS_mongodb"
|
||||
hostname="localhost"
|
||||
database="lefiona"
|
||||
/>
|
||||
<mm:metaModelBackend
|
||||
id="meta_profiles_backend"
|
||||
dataContextProvider="${metaDS_mongodb}"
|
||||
table="dg2_profiles"
|
||||
tableId="_id"
|
||||
/>
|
||||
<v:entry id="meta_profiles" backendId="meta_profiles_backend">
|
||||
<v:field id="_id" readOnly="true" list="false"/>
|
||||
<v:field id="url"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="active" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="body_text" list="false" vascEntryFieldType="TextAreaField"/>
|
||||
<v:field id="profile_type" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelString data="MALE,FEMALE,BOTH"/>
|
||||
</v:field>
|
||||
<v:field id="send_jokers" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="run_date" vascEntryFieldType="DateField"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
|
||||
|
||||
<m:mongodbConnectionProvider
|
||||
el.id="lefiona_connection"
|
||||
hostname="localhost"
|
||||
|
@ -51,23 +100,23 @@
|
|||
|
||||
|
||||
<j:jdbcConnectionProvider
|
||||
el.id="dbDatafeeds"
|
||||
el.id="dbRssFeeds"
|
||||
driverClassName="org.postgresql.Driver"
|
||||
dbUrl="jdbc:postgresql://localhost/datafeeds_dev"
|
||||
dbUrl="jdbc:postgresql://localhost/vasc_testpg"
|
||||
dbUser="test"
|
||||
dbPassword="eephoh2O"
|
||||
dbPassword="test"
|
||||
/>
|
||||
<j:jdbcBackend
|
||||
id="dbStreams"
|
||||
jdbcConnectionProvider="${dbDatafeeds}"
|
||||
id="rssChannelDB"
|
||||
jdbcConnectionProvider="${dbRssFeeds}"
|
||||
idColumnName="id"
|
||||
sqlList="SELECT * FROM stream LIMIT 100"
|
||||
sqlDelete="DELETE FROM stream WHERE id = ?0"
|
||||
sqlPersist="INSERT INTO stream (name,url,importing,etc) VALUES (?0,?1,?2,?3,?4)"
|
||||
sqlMerge="UPDATE stream (name,url) VALUE (?0,?1)"
|
||||
sqlList="SELECT * FROM channel LIMIT 100"
|
||||
sqlDelete="DELETE FROM channel WHERE id = ?0"
|
||||
sqlPersist="INSERT INTO channel (name,url,importing,etc) VALUES (?0,?1,?2,?3,?4)"
|
||||
sqlMerge="UPDATE channel (name,url) VALUE (?0,?1)"
|
||||
/>
|
||||
|
||||
<v:entry id="streams" backendId="dbStreams">
|
||||
<v:entry id="rssChannel" backendId="rssChannelDB">
|
||||
<v:field id="id" readOnly="true"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="url"/>
|
||||
|
@ -79,13 +128,13 @@
|
|||
<v:field id="column_mapping" list="false"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
<l:ldapConnectionProvider
|
||||
el.id="ldapSudoers"
|
||||
ldapHost="localhost"
|
||||
bindUser="uid=admin-sudo,ou=services,dc=example,dc=nl"
|
||||
bindPass="adminSudo"
|
||||
bindPass="test"
|
||||
/>
|
||||
<l:ldapBackend
|
||||
id="ldapBackendSudoers"
|
||||
|
@ -100,6 +149,8 @@
|
|||
<v:field id="sudoCommand" vascEntryFieldType="MultiTextField"/>
|
||||
<v:field id="sudoHost" vascEntryFieldType="MultiTextField"/>
|
||||
<v:field id="sudoUser" vascEntryFieldType="MultiTextField"/>
|
||||
|
||||
-->
|
||||
|
||||
<!--
|
||||
<v:ldapNextIdFunction name="nextUidNumber" ldapFilter="(&(objectClass=posixGroup))" ldapAttribute="gidnumber"/>
|
||||
|
@ -112,19 +163,22 @@
|
|||
<v:link fieldName="gidNumber" viewController="ldapGroups" parameterName="group_key,${baseDn}"/>
|
||||
|
||||
<v:detail fieldName="gidNumber" detailController="${ldapGroups}"/>
|
||||
-->
|
||||
-->
|
||||
|
||||
|
||||
<!--
|
||||
</v:entry>
|
||||
|
||||
<l:ldapConnectionProvider
|
||||
el.id="ldapUsers"
|
||||
ldapHost="10.11.12.96"
|
||||
bindUser="uid=libnss,ou=services,dc=dutchworks,dc=nl"
|
||||
bindPass="superN"
|
||||
bindUser="uid=libnss,ou=services,dc=example,dc=nl"
|
||||
bindPass="test"
|
||||
/>
|
||||
<l:ldapBackend
|
||||
id="ldapBackendUsers"
|
||||
ldapConnectionProvider="${ldapUsers}"
|
||||
baseDN="ou=users,dc=dutchworks,dc=nl"
|
||||
baseDN="ou=users,dc=example,dc=nl"
|
||||
keyAttribute="uid"
|
||||
ldapFilter="(&(objectClass=posixAccount))"
|
||||
/>
|
||||
|
@ -155,7 +209,7 @@
|
|||
el.id="ldapMachines"
|
||||
ldapHost="localhost"
|
||||
bindUser="uid=samba,ou=services,dc=example,dc=nl"
|
||||
bindPass="superS"
|
||||
bindPass="test"
|
||||
/>
|
||||
<l:ldapBackend
|
||||
id="ldapBackendMachines"
|
||||
|
@ -170,7 +224,7 @@
|
|||
<v:field id="sambaSID" />
|
||||
<v:field id="uidNumber" />
|
||||
</v:entry>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<!--
|
||||
|
@ -221,7 +275,7 @@ Master
|
|||
|
||||
<v:ldapConnection el.id="sudoers" x4o.templates="ldapServerTemplate">
|
||||
<x4o:property name="user" value="uid=admin-sudo,ou=services,dc=example,dc=nl"/>
|
||||
<x4o:property name="pass" value="adminSudo"/>
|
||||
<x4o:property name="pass" value="test"/>
|
||||
<x4o:property name="baseDn" value="ou=sudoers,dc=example,dc=nl"/>
|
||||
</v:ldapConnection>
|
||||
|
||||
|
@ -234,7 +288,7 @@ Master
|
|||
</x4o:template>
|
||||
|
||||
<x4o:template el.id="sambaUserSchema">
|
||||
<v:field name="sambaSID" fieldEditor="textField" edit="false" list="false" view="false" create="false" defaultValue="S-1-5-21-1200182392-965607725-1867741125-514"/>
|
||||
<v:field name="sambaSID" fieldEditor="textField" edit="false" list="false" view="false" create="false" defaultValue="S-1-5-21-123523482392-923323723-12323323235-514"/>
|
||||
<v:field name="sambaGroupType" v.defaultValue="2"/>
|
||||
</x4o:template>
|
||||
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<x4o:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
|
||||
xmlns:x4o="http://eld.x4o.org/eld/x4o-lang.eld"
|
||||
>
|
||||
<v:virtualVascBackend id="vascEntryBackend" vascController="${vascController}" vascType="entry"/>
|
||||
<v:entry id="vascEntry" backendId="vascEntryBackend">
|
||||
<v:field id="id"/>
|
||||
<v:field id="backendId"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="helpId" list="false"/>
|
||||
<v:field id="image" list="false"/>
|
||||
|
||||
<v:field id="listDescription" list="false"/>
|
||||
<v:field id="listImage" list="false"/>
|
||||
<v:field id="editDescription" list="false"/>
|
||||
<v:field id="editImage" list="false"/>
|
||||
<v:field id="deleteDescription" list="false"/>
|
||||
<v:field id="deleteImage" list="false"/>
|
||||
<v:field id="createDescription" list="false"/>
|
||||
<v:field id="createImage" list="false"/>
|
||||
|
||||
<v:field id="primaryKeyFieldId" list="false"/>
|
||||
<v:field id="displayNameFieldId" list="false"/>
|
||||
|
||||
<v:field id="vascDisplayOnly" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="vascAdminList" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="vascAdminEdit" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="vascAdminCreate" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="vascAdminDelete" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<v:link id="VascEntryField" vascEntryId="VascEntryFieldLink">
|
||||
<v:linkEntryCreateFieldValue valueFieldId="vascEntry"/>
|
||||
<v:linkEntryParameter name="entry_id" valueFieldId="id"/>
|
||||
</v:link>
|
||||
<v:link id="VascEntryFieldSet" vascEntryId="VascEntryFieldSetLink">
|
||||
<v:linkEntryParameter name="entry_id" valueFieldId="id"/>
|
||||
</v:link>
|
||||
<v:link id="VascLinkEntry" vascEntryId="VascLinkEntryLink">
|
||||
<v:linkEntryCreateFieldValue valueFieldId="vascEntry"/>
|
||||
<v:linkEntryParameter name="entry_id" valueFieldId="id"/>
|
||||
</v:link>
|
||||
<v:link id="VascListOption" vascEntryId="VascListOptionLink">
|
||||
<v:linkEntryCreateFieldValue valueFieldId="vascEntry"/>
|
||||
<v:linkEntryParameter name="entry_id" valueFieldId="id"/>
|
||||
</v:link>
|
||||
</v:entry>
|
||||
|
||||
<v:virtualVascBackend id="VascEntryFieldLinkBackend" vascController="${vascController}" vascType="field" />
|
||||
<v:entry id="VascEntryFieldLink" backendId="VascEntryFieldLinkBackend">
|
||||
<v:field id="id"/>
|
||||
<v:field id="backendName" list="false"/>
|
||||
<v:field id="displayName" list="false"/>
|
||||
|
||||
<v:field id="vascEntryFieldType" list="false" editReadOnly="true"/>
|
||||
<v:field id="vascEntryFieldValue" list="false" editReadOnly="true"/>
|
||||
|
||||
<v:field id="name"/>
|
||||
<v:field id="description" list="false"/>
|
||||
<v:field id="helpId" list="false"/>
|
||||
<v:field id="image" list="false"/>
|
||||
<v:field id="orderIndex" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="defaultValue"/>
|
||||
|
||||
<v:field id="sizeList" list="false" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="sizeEdit" list="false" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="styleList" list="false"/>
|
||||
<v:field id="styleEdit" list="false"/>
|
||||
|
||||
<v:field id="choices" list="false"/>
|
||||
<v:field id="choicesAsRadio" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<v:field id="view" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="create" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="edit" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="editReadOnly" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="editBlank" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="list" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<v:field id="rolesCreate" list="false"/>
|
||||
<v:field id="rolesEdit" list="false"/>
|
||||
<v:field id="rolesEditReadOnly" list="false"/>
|
||||
<v:field id="rolesList" list="false"/>
|
||||
|
||||
<v:field id="sortable" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="sumable" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="graphable" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<!-- private List<VascValidator> vascValidators = null; -->
|
||||
</v:entry>
|
||||
|
||||
|
||||
<v:virtualVascBackend id="VascEntryFieldSetLinkBackend" vascController="${vascController}" vascType="fieldset" />
|
||||
<v:entry id="VascEntryFieldSetLink" backendId="VascEntryFieldSetLinkBackend">
|
||||
<v:field id="id"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="description" list="false"/>
|
||||
|
||||
<v:field id="helpId" list="false"/>
|
||||
<v:field id="image" list="false"/>
|
||||
|
||||
<v:field id="styleList" list="false"/>
|
||||
<v:field id="styleEdit" list="false"/>
|
||||
<v:field id="collapsed" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<!-- private List<String> vascEntryFieldIds = null; -->
|
||||
</v:entry>
|
||||
|
||||
<v:virtualVascBackend id="VascLinkEntryLinkBackend" vascController="${vascController}" vascType="linkentries" />
|
||||
<v:entry id="VascLinkEntryLink" backendId="VascLinkEntryLinkBackend">
|
||||
<v:field id="id"/>
|
||||
<v:field id="vascEntryId"/>
|
||||
<v:field id="vascLinkEntryType" list="false" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.core.VascLinkEntryType"/>
|
||||
</v:field>
|
||||
|
||||
<v:field id="doActionId" list="false"/>
|
||||
<v:field id="name" list="false"/>
|
||||
|
||||
<!--
|
||||
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
|
||||
private Map<String,String> entryCreateFieldValues = new HashMap<String,String>(3);
|
||||
-->
|
||||
</v:entry>
|
||||
|
||||
|
||||
<v:virtualVascBackend id="VascListOptionLinkBackend" vascController="${vascController}" vascType="listoptions" />
|
||||
<v:entry id="VascListOptionLink" backendId="VascListOptionLinkBackend">
|
||||
<v:field id="id"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="description" list="false"/>
|
||||
|
||||
<v:field id="helpId" list="false"/>
|
||||
<v:field id="image" list="false"/>
|
||||
|
||||
<v:field id="styleList" list="false"/>
|
||||
<v:field id="styleEdit" list="false"/>
|
||||
<v:field id="collapsed" list="false" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
|
||||
|
||||
<!-- private List<String> vascEntryFieldIds = null; -->
|
||||
</v:entry>
|
||||
|
||||
<!--
|
||||
<m:mongodbConnectionProvider
|
||||
el.id="lefiona_connection"
|
||||
hostname="localhost"
|
||||
database="lefiona"
|
||||
/>
|
||||
<m:mongodbBackend
|
||||
id="dg2_smiles_backend"
|
||||
connectionProvider="${lefiona_connection}"
|
||||
collection="dg2_smiles"
|
||||
/>
|
||||
<v:entry id="dg2_smiles" backendId="dg2_smiles_backend">
|
||||
<v:field id="_id" readOnly="true" list="false"/>
|
||||
<v:field id="text" vascEntryFieldType="TextAreaField"/>
|
||||
<v:field id="profile_type" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelString data="MALE,FEMALE,BOTH"/>
|
||||
</v:field>
|
||||
<v:field id="cron_type" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelString data="BASE,DAILY,WEEKLY,MONTLY"/>
|
||||
</v:field>
|
||||
<v:field id="group"/>
|
||||
<v:field id="active" vascEntryFieldType="BooleanField"/>
|
||||
</v:entry>
|
||||
|
||||
|
||||
<m:mongodbBackend
|
||||
id="dg2_profiles_backend"
|
||||
connectionProvider="${lefiona_connection}"
|
||||
collection="dg2_profiles"
|
||||
/>
|
||||
<v:entry id="dg2_profiles" backendId="dg2_profiles_backend">
|
||||
<v:field id="_id" readOnly="true" list="false"/>
|
||||
<v:field id="url"/>
|
||||
<v:field id="name"/>
|
||||
<v:field id="active" vascEntryFieldType="BooleanField"/>
|
||||
<v:field id="body_text" list="false" vascEntryFieldType="TextAreaField"/>
|
||||
<v:field id="profile_type" vascEntryFieldType="ListField">
|
||||
<v:vascSelectItemModelString data="MALE,FEMALE,BOTH"/>
|
||||
</v:field>
|
||||
<v:field id="send_jokers" vascEntryFieldType="IntegerField"/>
|
||||
<v:field id="run_date" vascEntryFieldType="DateField"/>
|
||||
</v:entry>
|
||||
-->
|
||||
|
||||
</x4o:root>
|
|
@ -49,12 +49,7 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis
|
|||
|
||||
public SwingPagerPanel(VascEntry vascEntry) {
|
||||
this.vascEntry=vascEntry;
|
||||
//result = this;
|
||||
result = new JPanel();
|
||||
// result.setBackground(Color.green);
|
||||
//result.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
|
||||
|
||||
add(result);
|
||||
vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* SwingPanelFrame to render into frames.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public class SwingPanelFrame implements SwingPanelIntegration {
|
||||
|
||||
Map<JPanel,JFrame> panels = new HashMap<JPanel,JFrame>(5);
|
||||
boolean addVascMenu = true;
|
||||
|
||||
public SwingPanelFrame() {
|
||||
this(true);
|
||||
}
|
||||
public SwingPanelFrame(boolean addVascMenu) {
|
||||
this.addVascMenu=addVascMenu;
|
||||
}
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception {
|
||||
// define redering
|
||||
JPanel panel = initVascView();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel,this);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
|
||||
private static final long serialVersionUID = -6801954395965101748L;
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
if (data instanceof Exception) {
|
||||
Exception e = (Exception)data;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
return new VascFrontendEventType[] {VascFrontendEventType.EXCEPTION};
|
||||
}
|
||||
});
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
openVascView(panel, entry);
|
||||
}
|
||||
|
||||
public JPanel initVascView() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
public void openVascView(JPanel pane,final VascEntry entry) {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Edit - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
if (addVascMenu) {
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id).clone();
|
||||
//TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, entry.getVascFrontendData().getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
createNewVascView(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
}
|
||||
|
||||
frame.add(pane);
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
panels.put(pane,frame);
|
||||
}
|
||||
|
||||
public void closeVascView(JPanel pane,VascEntry entry) {
|
||||
JFrame frame = panels.get(pane);
|
||||
if (frame!=null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
||||
/**
|
||||
* SwingPanelIntegration provides the JPanels to vasc to integrate into application panel handing.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public interface SwingPanelIntegration {
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception;
|
||||
public JPanel initVascView();
|
||||
public void openVascView(JPanel pane,VascEntry entry);
|
||||
public void closeVascView(JPanel pane,VascEntry entry);
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
/**
|
||||
* SwingPanelTabbed to render into tabs.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public class SwingPanelTabbed implements SwingPanelIntegration {
|
||||
|
||||
JTabbedPane tabbedPane = null;
|
||||
|
||||
public SwingPanelTabbed(JTabbedPane tabbedPane) {
|
||||
this.tabbedPane=tabbedPane;
|
||||
}
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception {
|
||||
// define redering
|
||||
JPanel panel = initVascView();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel,this);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
|
||||
private static final long serialVersionUID = -6801954395965101748L;
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
if (data instanceof Exception) {
|
||||
Exception e = (Exception)data;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
return new VascFrontendEventType[] {VascFrontendEventType.EXCEPTION};
|
||||
}
|
||||
});
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
openVascView(panel, entry);
|
||||
}
|
||||
|
||||
public JPanel initVascView() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
public void openVascView(JPanel pane,final VascEntry entry) {
|
||||
tabbedPane.addTab(entry.getName(), pane);
|
||||
tabbedPane.setSelectedIndex(tabbedPane.getTabCount()-1);
|
||||
}
|
||||
|
||||
public void closeVascView(JPanel pane,VascEntry entry) {
|
||||
for (int i=0;i<tabbedPane.getTabCount();i++) {
|
||||
Object tab = tabbedPane.getComponentAt(i);
|
||||
if (pane==tab) {
|
||||
tabbedPane.removeTabAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,17 +28,18 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.ui.VascColumnValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* SwingVascEditDialog renders vasc entry edit dialog
|
||||
|
@ -46,7 +47,7 @@ import net.forwardfire.vasc.core.ui.VascValueModel;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascEditDialog extends JDialog {
|
||||
public class SwingVascEditDialog extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 10L;
|
||||
private String headerText = null;
|
||||
|
@ -55,70 +56,102 @@ public class SwingVascEditDialog extends JDialog {
|
|||
private Object bean = null;
|
||||
private VascEntry entry = null;
|
||||
private SwingVascFrontend swingFrontend = null;
|
||||
private SwingPanelIntegration panels = null;
|
||||
private JPanel editView = null;
|
||||
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JComponent parent,VascEntry entry,Object bean,String beanValue) throws Exception {
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JPanel editView,VascEntry entry,Object bean,String beanValue,SwingPanelIntegration panels) throws Exception {
|
||||
super();
|
||||
this.headerText = "vasc.dialog.edit.message";
|
||||
this.headerTextValue = beanValue;
|
||||
this.bean = bean;
|
||||
this.entry = entry;
|
||||
this.swingFrontend=swingFrontend;
|
||||
this.panels=panels;
|
||||
this.editView=editView;
|
||||
|
||||
setTitle(swingFrontend.i18n("vasc.dialog.edit.title"));
|
||||
setModal(true);
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new BorderLayout());
|
||||
setLayout(new BorderLayout());
|
||||
add(createHeader(), BorderLayout.NORTH);
|
||||
add(createBody(), BorderLayout.CENTER);
|
||||
add(createFooter(), BorderLayout.SOUTH);
|
||||
|
||||
editView.add(this);
|
||||
}
|
||||
|
||||
protected JPanel createHeader() {
|
||||
JPanel header = new JPanel();
|
||||
createHeader(header);
|
||||
pane.add(header,BorderLayout.NORTH);
|
||||
|
||||
JPanel body = new JPanel();
|
||||
createBody(body);
|
||||
pane.add(body,BorderLayout.CENTER);
|
||||
|
||||
JPanel footer = new JPanel();
|
||||
createFooter(footer);
|
||||
pane.add(footer,BorderLayout.SOUTH);
|
||||
|
||||
add(pane);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
//Ensure the text field always gets the first focus.
|
||||
//addComponentListener(new ComponentAdapter() {
|
||||
// public void componentShown(ComponentEvent ce) {
|
||||
// textField.requestFocusInWindow();
|
||||
// }
|
||||
/// });
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(parent);
|
||||
setResizable(false);
|
||||
}
|
||||
|
||||
|
||||
public Object openDialog() {
|
||||
setVisible(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createHeader(JPanel header) {
|
||||
JLabel l = new JLabel();
|
||||
l.setText(swingFrontend.i18n(headerText,headerTextValue));
|
||||
l.setFont(new Font(null,Font.BOLD, 14));
|
||||
//l.setToolTipText(i18n(headerText));
|
||||
header.add(l);
|
||||
|
||||
for (final VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
JButton but = new JButton(vle.getName());
|
||||
but.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascController vc = entry.getVascFrontendData().getVascController();
|
||||
VascEntry ee = vc.getVascEntryController().getVascEntryById(vle.getVascEntryId()).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
// Set parameters
|
||||
try {
|
||||
Object selected = bean;
|
||||
for (String parameterName:vle.getEntryParameterFieldIdKeys()) {
|
||||
String fieldId = vle.getEntryParameterFieldId(parameterName);
|
||||
VascEntryField v = ee.getVascEntryFieldById(fieldId);
|
||||
if (v==null) {
|
||||
System.out.println("Could nog get VascEntryField for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
if (v.getVascEntryFieldValue()==null) {
|
||||
System.out.println("Could not get VascEntryFieldValue for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
|
||||
// set data parameter on new vasc entry
|
||||
ee.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
|
||||
System.out.println("Setting link parameter: "+parameterName+" with: "+selectedValue);
|
||||
}
|
||||
|
||||
for (String fieldId:vle.getEntryCreateFieldValueKeys()) {
|
||||
String selectedfieldId = vle.getEntryParameterFieldId(fieldId);
|
||||
Object selectedValue = selected;
|
||||
if (selectedfieldId!=null) {
|
||||
VascEntryField v = ee.getVascEntryFieldById(selectedfieldId);
|
||||
selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
}
|
||||
|
||||
// create listener for new objects
|
||||
//entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
|
||||
}
|
||||
} catch (Exception eee) {
|
||||
throw new RuntimeException("error: "+eee.getMessage(),eee);
|
||||
}
|
||||
|
||||
|
||||
|
||||
panels.createNewVascView(ee);
|
||||
} catch (Exception eee) {
|
||||
eee.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
header.add(but);
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
public void createBody(JPanel body) throws Exception {
|
||||
protected JPanel createBody() throws Exception {
|
||||
JPanel body = new JPanel();
|
||||
body.setLayout(new SpringLayout());
|
||||
int column = 0;
|
||||
int column = 0;
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (c.isEditReadOnly()==true) {
|
||||
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
@ -142,10 +175,10 @@ public class SwingVascEditDialog extends JDialog {
|
|||
}
|
||||
//JComponent, rows, cols, initX, initY ,xPad, yPad
|
||||
SpringUtilities.makeCompactGrid(body, column,2, 6,6, 6,6);
|
||||
|
||||
return body;
|
||||
}
|
||||
public void createFooter(JPanel footer) {
|
||||
|
||||
public JPanel createFooter() {
|
||||
JPanel footer = new JPanel();
|
||||
JButton saveButton = new JButton();
|
||||
saveButton.setIcon(swingFrontend.getImageIcon("vasc.dialog.save.image"));
|
||||
saveButton.setText(swingFrontend.i18n("vasc.dialog.save.name"));
|
||||
|
@ -155,8 +188,15 @@ public class SwingVascEditDialog extends JDialog {
|
|||
//if(entry.getVascFrontendData().getVascFrontendHelper().validateObject(entry, bean)) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
result = bean;
|
||||
setVisible(false);
|
||||
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
|
||||
panels.closeVascView(editView, SwingVascEditDialog.this.entry);
|
||||
//setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(saveButton);
|
||||
|
@ -168,9 +208,11 @@ public class SwingVascEditDialog extends JDialog {
|
|||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
result = null;
|
||||
setVisible(false);
|
||||
panels.closeVascView(editView, SwingVascEditDialog.this.entry);
|
||||
//setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(cancelButton);
|
||||
return footer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import java.awt.event.MouseAdapter;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
|
@ -63,6 +65,7 @@ import net.forwardfire.vasc.core.VascException;
|
|||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.core.ui.VascOptionValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
@ -87,10 +90,14 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
private Logger logger = null;
|
||||
private JComponent parent = null;
|
||||
private boolean initOnce = true;
|
||||
private Map<RowVascAction,JButton> rowActions = null;
|
||||
private SwingPanelIntegration panels = null;
|
||||
|
||||
public SwingVascFrontend(JComponent parent) {
|
||||
public SwingVascFrontend(JComponent parent,SwingPanelIntegration panels) {
|
||||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||
this.parent=parent;
|
||||
this.panels=panels;
|
||||
rowActions = new HashMap<RowVascAction,JButton>(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,14 +166,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
}
|
||||
SwingVascEditDialog dialog = new SwingVascEditDialog(this,parent,entry,rowBean,beanValue);
|
||||
Object result = dialog.openDialog();
|
||||
logger.finest("OPEN closed : "+result);
|
||||
if(result==null) {
|
||||
return;
|
||||
}
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
JPanel editPanel = panels.initVascView();
|
||||
SwingVascEditDialog dialog = new SwingVascEditDialog(this,editPanel,entry,rowBean,beanValue,panels);
|
||||
|
||||
panels.openVascView(editPanel,entry);
|
||||
}
|
||||
|
||||
public void renderDelete() throws Exception {
|
||||
|
@ -309,8 +312,8 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
model.addListener(new VascOptionValueModelListener(c));
|
||||
model.setValue(c.getDefaultValue());
|
||||
//model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
Object g = editor.createComponent(entry,c,model,body);
|
||||
|
||||
column++;
|
||||
|
@ -320,6 +323,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
body.add(new JLabel()); // fill :(
|
||||
}
|
||||
}
|
||||
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
|
||||
|
||||
// add search
|
||||
column++;
|
||||
|
@ -327,10 +331,17 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
body.add(searchLabel);
|
||||
final JTextField searchField = new JTextField();
|
||||
body.add(searchField);
|
||||
searchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
String searchText = searchField.getText();
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchText);
|
||||
}
|
||||
});
|
||||
JButton searchButton = new JButton("Search");
|
||||
searchButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchField.getText());
|
||||
String searchText = searchField.getText();
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchText);
|
||||
}
|
||||
});
|
||||
body.add(searchButton);
|
||||
|
@ -396,7 +407,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
counter++;
|
||||
}
|
||||
table.getSelectionModel().addListSelectionListener(new EntrySectionListener(table));
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
|
@ -428,40 +439,16 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
public void mouseClicked(MouseEvent e) {
|
||||
TableColumnModel colModel = table.getColumnModel();
|
||||
int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
|
||||
//int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();
|
||||
/*
|
||||
if (modelIndex < 0)
|
||||
return;
|
||||
if (sortCol == modelIndex)
|
||||
isSortAsc = !isSortAsc;
|
||||
else
|
||||
sortCol = modelIndex;
|
||||
|
||||
for (int i = 0; i < columnsCount; i++) {
|
||||
TableColumn column = colModel.getColumn(i);
|
||||
column.setHeaderValue(getColumnName(column.getModelIndex()));
|
||||
}
|
||||
table.getTableHeader().repaint();
|
||||
*/
|
||||
|
||||
TableColumn tc = colModel.getColumn(columnModelIndex);
|
||||
VascEntryField field = (VascEntryField)tc.getHeaderValue();
|
||||
//VascEntry entry = comp.getVascEntry();
|
||||
//VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
|
||||
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
|
||||
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
|
||||
//Collections.sort(vector,new MyComparator(isSortAsc));
|
||||
//table.tableChanged(new TableModelEvent(MyTableModel.this));
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
table.repaint();
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +461,33 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
if (e.getValueIsAdjusting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (table.getSelectedRowCount()==0) {
|
||||
for (RowVascAction action:rowActions.keySet()) {
|
||||
JButton but = rowActions.get(action);
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
}
|
||||
} else if (table.getSelectedRowCount()==1) {
|
||||
for (JButton but:rowActions.values()) {
|
||||
but.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
for (RowVascAction action:rowActions.keySet()) {
|
||||
JButton but = rowActions.get(action);
|
||||
if (action.isMultiRowAction()) {
|
||||
but.setEnabled(true);
|
||||
} else {
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rowIndex = table.getSelectedRow();
|
||||
|
||||
if (rowIndex!=-1) {
|
||||
// temp; gets index by sorter
|
||||
//rowIndex = tableSorter.modelIndex(rowIndex);
|
||||
|
@ -529,6 +542,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
but.setToolTipText(i18n(action.getDescription()));
|
||||
but.setIcon(getImageIcon(action.getImage()));
|
||||
but.addActionListener(new RowActionListener(action));
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
rowActions.put(action, but);
|
||||
panel.add(but);
|
||||
}
|
||||
bottomPanel.add(panel,BorderLayout.SOUTH);
|
||||
|
|
|
@ -104,7 +104,7 @@ public class SwingVascTableModel extends AbstractTableModel implements VascEntry
|
|||
}
|
||||
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE,VascFrontendEventType.POST_READ};
|
||||
VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE,VascFrontendEventType.POST_READ,VascFrontendEventType.POST_DELETE};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@ public class SwingBoolean implements VascUIComponent {
|
|||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
checkBox = new JCheckBox();
|
||||
orgBackgroundColor = checkBox.getBackground();
|
||||
checkBox.setSelected(new Boolean(model.getValue().toString()));
|
||||
if (model.getValue()!=null) {
|
||||
checkBox.setSelected(new Boolean(model.getValue().toString()));
|
||||
}
|
||||
((JComponent)gui).add(checkBox);
|
||||
checkBox.addActionListener(new SelectActionListener(model,table));
|
||||
return checkBox;
|
||||
|
|
|
@ -22,53 +22,30 @@
|
|||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingVascFrontend;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelFrame;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelEntry;
|
||||
|
||||
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests a simple x4o xml language.
|
||||
* SwingTestTabbed shows interfaces in frames.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class SwingTest extends TestCase {
|
||||
|
||||
private TestModelEntry entry = null;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
//InputStream loggingProperties = this.getClass().getResourceAsStream("META-INF/logging.properties");
|
||||
//LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
//loggingProperties.close();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void testNull() throws Exception {
|
||||
assertEquals(true, true);
|
||||
//main(new String[] {});
|
||||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
public static void main(String[] argu){
|
||||
SwingTest s = new SwingTest();
|
||||
try {
|
||||
s.open();
|
||||
|
@ -78,69 +55,13 @@ public class SwingTest extends TestCase {
|
|||
}
|
||||
|
||||
public void open() throws Exception {
|
||||
SwingPanelIntegration spi = new SwingPanelFrame();
|
||||
TestModelData testData = new TestModelData();
|
||||
VascController vc = testData.getTestVascController();
|
||||
testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController());
|
||||
|
||||
entry = new TestModelEntry();
|
||||
VascController vc = entry.getTestVascController();
|
||||
|
||||
VascEntry ve = entry.createVascEntry(vc);
|
||||
|
||||
((VascEntryControllerLocal)vc.getVascEntryController()).addVascEntry(ve,vc);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vc.getVascEntryController(), vc);
|
||||
|
||||
VascEntry ve = testData.getTestEntry(vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
JFrame frame = viewEntry(ve);
|
||||
|
||||
while (frame.isVisible()) {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
// get GUI
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
|
||||
//TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
viewEntry(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// define redering
|
||||
JPanel panel = new JPanel();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel);
|
||||
frame.add(panel);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
return frame;
|
||||
spi.createNewVascView(ve);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelTabbed;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* SwingTestTabbed shows interfaces in tabs.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 06, 2012
|
||||
*/
|
||||
public class SwingTestTabbed extends TestCase {
|
||||
|
||||
public void testNull() throws Exception {
|
||||
assertEquals(true, true);
|
||||
//main(new String[] {});
|
||||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
SwingTestTabbed s = new SwingTestTabbed();
|
||||
try {
|
||||
s.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void open() throws Exception {
|
||||
TestModelData testData = new TestModelData();
|
||||
final VascController vc = testData.getTestVascController();
|
||||
testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController());
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Tabbed Test");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
final JTabbedPane pane = new JTabbedPane();
|
||||
final SwingPanelIntegration spi = new SwingPanelTabbed(pane);
|
||||
frame.add(pane);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Entries");
|
||||
for (final String id:vc.getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = vc.getVascEntryController().getVascEntryById(id).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
JMenuItem item = new JMenuItem("Close tab.");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (pane.getSelectedIndex()>=0) {
|
||||
pane.removeTabAt(pane.getSelectedIndex()); // todo release vasc frontend
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// view
|
||||
frame.setMinimumSize(new Dimension(800,600));
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
VascEntry ve = testData.getTestEntry(vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ve);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
public class Test implements ActionListener {
|
||||
|
||||
JFrame frame;
|
||||
JTabbedPane tabPane;
|
||||
JButton addTab;
|
||||
ImageIcon close;
|
||||
Dimension size;
|
||||
int tabCounter = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Test jtab = new Test();
|
||||
}
|
||||
|
||||
public Test() {
|
||||
frame = new JFrame();
|
||||
tabPane = new JTabbedPane();
|
||||
addTab = new JButton("Add Tab");
|
||||
addTab.addActionListener(this);
|
||||
close = new ImageIcon("/home/willemc/door_out.png");
|
||||
size = new Dimension(close.getIconWidth()+1,close.getIconHeight()+1);
|
||||
frame.add(tabPane,BorderLayout.CENTER);
|
||||
frame.add(addTab, BorderLayout.NORTH);
|
||||
frame.setSize(300, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JLabel label = null;
|
||||
final JPanel panel = new JPanel();
|
||||
JPanel tab = new JPanel();
|
||||
tab.setOpaque(false);
|
||||
try{
|
||||
String str = JOptionPane.showInputDialog(null, "Enter Tab Name : ", "JavaJazzUp", 1);
|
||||
|
||||
if (str.length() == 0){
|
||||
JOptionPane.showMessageDialog(null,"Please Enter the Tab Name : ", "JavaJazzUp",1);
|
||||
} else if (str != null){
|
||||
label = new JLabel(str);
|
||||
panel.add(new JLabel("test"+str));
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null,"You pressed cancel button.", "JavaJazzUp",1);
|
||||
}
|
||||
JButton tabClose = new JButton(close);
|
||||
tabClose.setPreferredSize(size);
|
||||
tabClose.addActionListener(new ActionListener() {
|
||||
public void
|
||||
actionPerformed(ActionEvent e) {
|
||||
int tNum = tabPane.indexOfComponent(panel);
|
||||
tabPane.removeTabAt(tNum);
|
||||
}
|
||||
});
|
||||
tab.add(label, BorderLayout.WEST);
|
||||
tab.add(tabClose, BorderLayout.EAST);
|
||||
tabPane.addTab(null, panel);
|
||||
tabPane.setTabComponentAt(tabPane.getTabCount()-1, tab);
|
||||
} catch(Exception ex){}
|
||||
}
|
||||
}
|
|
@ -329,7 +329,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
net.forwardfire.vasc.core.ui.VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option);
|
||||
model = new VascValueModel(option.getVascEntryFieldType().provideEditorVascValueModel(i,option));
|
||||
model.addListener(new VascOptionValueModelListener(option));
|
||||
model.setValue(null);
|
||||
model.setValue(option.getDefaultValue());
|
||||
model.addListener(new VascValueModelListener() {
|
||||
public void valueUpdate(VascValueModel model) throws VascException {
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();// mm
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.forwardfire.vasc.core.VascEntry;
|
|||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swt.SwtVascFrontend;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelEntry;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelData;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -45,7 +45,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public class SWTTest extends TestCase {
|
||||
|
||||
private TestModelEntry entry = null;
|
||||
private TestModelData testData = null;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
@ -70,13 +70,12 @@ public class SWTTest extends TestCase {
|
|||
// define redering and render
|
||||
SwtVascFrontend render = new SwtVascFrontend(shell);
|
||||
|
||||
entry = new TestModelEntry();
|
||||
VascController vc = entry.getTestVascController();
|
||||
VascEntry ve = entry.createVascEntry(vc);
|
||||
((VascEntryControllerLocal)vc.getVascEntryController()).addVascEntry(ve,vc);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vc.getVascEntryController(), vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
testData = new TestModelData();
|
||||
VascController vc = testData.getTestVascController();
|
||||
testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController());
|
||||
|
||||
VascEntry ve = testData.getTestEntry(vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
ve.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
render.initEntry(ve);
|
||||
render.renderView();
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
@ -11,6 +32,12 @@ import net.forwardfire.vasc.core.VascEntryField;
|
|||
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* AbstractJSFVascFacesControllerBase for making jsf frontend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 21, 2011
|
||||
*/
|
||||
public abstract class AbstractJSFVascFacesControllerBase {
|
||||
|
||||
abstract VascFrontendData getNewVascFrontendData();
|
||||
|
|
|
@ -325,6 +325,10 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
|
|||
Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,15 +29,14 @@ import javax.el.ValueExpression;
|
|||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
* JSFVascEntryEventListener fills data in support bean.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 11, 2009
|
||||
*/
|
||||
public class JSFVascEntryEventListener implements VascEntryFrontendEventListener {
|
||||
|
||||
|
@ -59,6 +58,7 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
|
|||
|
||||
|
||||
public void vascEvent(VascEntry entry,Object dataNotUsed) {
|
||||
/* moved to fillVascEntryFrontend
|
||||
try {
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
if (field.getVascEntryFieldValue()==null) {
|
||||
|
@ -73,6 +73,7 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
|
|||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
*/
|
||||
List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
|
||||
List<Object> result = new ArrayList<Object>(data.size());
|
||||
int index = 0;
|
||||
|
|
|
@ -64,7 +64,7 @@ import net.forwardfire.vasc.impl.actions.EditRowAction;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* JSFVascEntrySupportBean add EL support for renderer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 10, 2009
|
||||
|
@ -1012,7 +1012,7 @@ class JSFVascSupportI18nMapController implements Map<String,String> {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void putAll(Map m) {
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.lang.reflect.Method;
|
|||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
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.impl.DefaultVascEntry;
|
||||
import net.forwardfire.vasc.impl.DefaultVascEntryField;
|
||||
|
@ -37,24 +38,32 @@ import net.forwardfire.vasc.impl.DefaultVascFactory;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 2, 2007
|
||||
*/
|
||||
public class TestModelEntry {
|
||||
public class TestModelData {
|
||||
|
||||
public VascController getTestVascController() throws Exception {
|
||||
VascController c = DefaultVascFactory.getDefaultVascController(1234L,"Nice UserName","user","role_admin");
|
||||
|
||||
// for test
|
||||
TestModelVascDataSource backend = new TestModelVascDataSource();
|
||||
backend.generatorData(10876);
|
||||
backend.setId("testBackend");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backend);
|
||||
TestModelVascDataSource backends = new TestModelVascDataSource();
|
||||
backends.generatorData(10876);
|
||||
|
||||
backends.orderModel.setId("orderModelBackend");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderModel);
|
||||
|
||||
backends.orderLineModel.setId("orderLineModelBackend");
|
||||
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(backends.orderLineModel);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public VascEntry createVascEntry(VascController vc) throws Exception {
|
||||
public VascEntry getTestEntry(VascController vc) {
|
||||
return vc.getVascEntryController().getVascEntryById("orderModel");
|
||||
}
|
||||
|
||||
public void createVascEntries(VascController vc,VascEntryControllerLocal vecl) throws Exception {
|
||||
VascEntry ve = new DefaultVascEntry();
|
||||
ve.setId("testEntry");
|
||||
ve.setBackendId("testBackend");
|
||||
ve.setId("orderModel");
|
||||
ve.setBackendId("orderModelBackend");
|
||||
|
||||
VascEntryField field = new DefaultVascEntryField();
|
||||
field.setId("name");
|
||||
|
@ -89,9 +98,34 @@ public class TestModelEntry {
|
|||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("BooleanField"));
|
||||
field.setBackendName("active");
|
||||
field.setDefaultValue("true"); // obj does also work ! we are first need to fix string defaults.
|
||||
|
||||
ve.addListOption(field);
|
||||
|
||||
return ve;
|
||||
vecl.addVascEntry(ve,vc);
|
||||
|
||||
|
||||
ve = new DefaultVascEntry();
|
||||
ve.setId("orderLineModel");
|
||||
ve.setBackendId("orderLineModelBackend");
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("name");
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("price");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("FloatField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
field = new DefaultVascEntryField();
|
||||
field.setId("date");
|
||||
field.setVascEntryFieldType(vc.getVascEntryFieldTypeController().getVascEntryFieldTypeById("DateField"));
|
||||
ve.addVascEntryField(field);
|
||||
|
||||
vecl.addVascEntry(ve,vc);
|
||||
|
||||
|
||||
DefaultVascFactory.fillVascControllerLocalEntries(vecl, vc);
|
||||
}
|
||||
|
||||
static void printEntry(VascEntry e) throws Exception {
|
|
@ -42,16 +42,31 @@ import net.forwardfire.vasc.validators.VascStringLength;
|
|||
* @version 1.0 Mar 28, 2007
|
||||
*/
|
||||
@VascEntry(headerName="En een tooltip op het model")
|
||||
public class TestModel {
|
||||
public class TestModelOrder {
|
||||
|
||||
private Integer id = null;
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private Float price = null;
|
||||
private Boolean active = null;
|
||||
private Date date = null;
|
||||
private TestModel testModel = null;
|
||||
private TestModelOrder testModel = null;
|
||||
private String hexColor = null;
|
||||
//private Node nonEditorField = null;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
|
@ -60,7 +75,7 @@ public class TestModel {
|
|||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param date the date to set
|
||||
*/
|
||||
|
@ -125,11 +140,11 @@ public class TestModel {
|
|||
@VascObjectNotNull
|
||||
@VascModelReference
|
||||
@VascI18n(image="/resources/images/gabelfresser.gif")
|
||||
public TestModel getTestModel() {
|
||||
public TestModelOrder getTestModel() {
|
||||
return testModel;
|
||||
}
|
||||
|
||||
public void setTestModel(TestModel testModel) {
|
||||
public void setTestModel(TestModelOrder testModel) {
|
||||
this.testModel = testModel;
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.test.frontend.data;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import net.forwardfire.vasc.annotations.VascDefaultValue;
|
||||
import net.forwardfire.vasc.annotations.VascEntry;
|
||||
import net.forwardfire.vasc.annotations.VascI18n;
|
||||
import net.forwardfire.vasc.annotations.VascModelReference;
|
||||
import net.forwardfire.vasc.annotations.VascStyle;
|
||||
import net.forwardfire.vasc.validators.VascDateFuture;
|
||||
import net.forwardfire.vasc.validators.VascObjectNotNull;
|
||||
import net.forwardfire.vasc.validators.VascStringLength;
|
||||
|
||||
/**
|
||||
* TestModelOrderLine
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 7, 2012
|
||||
*/
|
||||
@VascEntry(headerName="OrderLine")
|
||||
public class TestModelOrderLine {
|
||||
|
||||
private TestModelOrder order = null;
|
||||
private String name = null;
|
||||
private Float price = null;
|
||||
private Date date = null;
|
||||
|
||||
/**
|
||||
* @return the order
|
||||
*/
|
||||
public TestModelOrder getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param order the order to set
|
||||
*/
|
||||
public void setOrder(TestModelOrder order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
*/
|
||||
@VascDateFuture
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date the date to set
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price
|
||||
*/
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param price the price to set
|
||||
*/
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,9 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
||||
import org.x4o.xml.impl.DefaultElementObjectPropertyValue;
|
||||
|
||||
import net.forwardfire.vasc.backend.AbstractVascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
@ -45,20 +48,24 @@ import net.forwardfire.vasc.impl.entry.BeanVascEntryRecordCreator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class TestModelVascDataSource extends AbstractVascBackend implements VascSelectItemModel {
|
||||
public class TestModelVascDataSource {
|
||||
|
||||
private List<TestModel> testModels = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
//private List<TestModelOrder> testModels = null;
|
||||
public ListObjectVascDataSource orderModel = null;
|
||||
public ListObjectVascDataSource orderLineModel = null;
|
||||
|
||||
public TestModelVascDataSource() {
|
||||
testModels = new ArrayList<TestModel>(200);
|
||||
this(new ArrayList<TestModelOrder>(200),new ArrayList<TestModelOrderLine>(200));
|
||||
}
|
||||
public TestModelVascDataSource(List<TestModelOrder> testModels,List<TestModelOrderLine> testModelLine) {
|
||||
orderModel = new ListObjectVascDataSource(TestModelOrder.class,(List)testModels);
|
||||
orderLineModel = new ListObjectVascDataSource(TestModelOrderLine.class,(List)testModelLine);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void generatorData(int size) {
|
||||
for (int i=0;i<size;i++) {
|
||||
TestModel t = new TestModel();
|
||||
for (int i=0;i<size/3;i++) {
|
||||
TestModelOrder t = new TestModelOrder();
|
||||
t.setDate(new Date());
|
||||
t.setDescription("Some long text in this....");
|
||||
t.setName("BeanName_"+i);
|
||||
|
@ -68,96 +75,138 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc
|
|||
} else {
|
||||
t.setActive(true);
|
||||
}
|
||||
if (testModels.isEmpty()==false) {
|
||||
t.setTestModel((TestModel)testModels.get(0));
|
||||
if (orderModel.getObjectList().isEmpty()==false) {
|
||||
t.setTestModel((TestModelOrder)orderModel.getObjectList().get(0));
|
||||
}
|
||||
orderModel.getObjectList().add(t);
|
||||
|
||||
for (int ii=0;ii<size/1000;ii++) {
|
||||
TestModelOrderLine line = new TestModelOrderLine();
|
||||
line.setDate(new Date());
|
||||
line.setName("OrderLine"+ii);
|
||||
line.setPrice(new Float(123+ii));
|
||||
line.setOrder(t);
|
||||
orderLineModel.getObjectList().add(line);
|
||||
}
|
||||
testModels.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TestModelVascDataSource(List<TestModel> testModels) {
|
||||
this.testModels=testModels;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
if (state.getDataParameterKeys().contains("active")) {
|
||||
List<Object> result = new ArrayList<Object>(testModels.size()/2);
|
||||
for (TestModel tm:testModels) {
|
||||
if (tm.getActive()!=null && tm.getActive().equals(state.getDataParameter("active"))) {
|
||||
result.add(tm);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
List<Object> result = new ArrayList<Object>(testModels.size());
|
||||
for (TestModel tm:testModels) {
|
||||
result.add(tm);
|
||||
}
|
||||
return result;
|
||||
|
||||
class ListObjectVascDataSource extends AbstractVascBackend {
|
||||
private Class<?> modelClass = null;
|
||||
private List<Object> modelList = null;
|
||||
private String nullLabel = null;
|
||||
private String nullKeyValue = null;
|
||||
|
||||
public ListObjectVascDataSource(Class<?> modelClass,List<Object> modelList) {
|
||||
this.modelClass=modelClass;
|
||||
this.modelList=modelList;
|
||||
}
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
testModels.add((TestModel)object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
if(testModels.contains(object)==false) {
|
||||
testModels.add((TestModel)object);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
testModels.remove(object);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new BeanVascEntryRecordCreator(TestModel.class);
|
||||
}
|
||||
|
||||
// --- VascSelectItemModel interface
|
||||
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
|
||||
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
||||
for (Object o:testModels) {
|
||||
TestModel t = (TestModel)o;
|
||||
VascSelectItem i = new VascSelectItem(t.getName(),t);
|
||||
res.add(i);
|
||||
public List<Object> getObjectList() {
|
||||
return modelList;
|
||||
}
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
if (state.getDataParameterKeys().isEmpty()==false) {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size()/2);
|
||||
DefaultElementObjectPropertyValue helper = new DefaultElementObjectPropertyValue();
|
||||
for (Object row:modelList) {
|
||||
boolean addRow = true;
|
||||
for (String key:state.getDataParameterKeys()) {
|
||||
Object keyValue = state.getDataParameter(key);
|
||||
Object propValue = null;
|
||||
try {
|
||||
propValue = helper.getProperty(row, key);
|
||||
} catch (ElementObjectPropertyValueException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (keyValue==null && propValue==null) {
|
||||
continue;
|
||||
}
|
||||
if (keyValue.equals(propValue)) {
|
||||
continue;
|
||||
}
|
||||
addRow = false;
|
||||
}
|
||||
if (addRow) {
|
||||
result.add(row);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
List<Object> result = new ArrayList<Object>(modelList.size());
|
||||
for (Object row:modelList) {
|
||||
result.add(row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
modelList.add(object);
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
if(modelList.contains(object)==false) {
|
||||
modelList.add(object);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
modelList.remove(object);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return new BeanPropertyVascEntryFieldValue(field.getBackendName());
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new BeanVascEntryRecordCreator(modelClass);
|
||||
}
|
||||
|
||||
// --- VascSelectItemModel interface
|
||||
/*
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) {
|
||||
List<VascSelectItem> res = new ArrayList<VascSelectItem>(4);
|
||||
for (Object o:testModels) {
|
||||
TestModelOrder t = (TestModelOrder)o;
|
||||
VascSelectItem i = new VascSelectItem(t.getName(),t);
|
||||
res.add(i);
|
||||
}
|
||||
return res;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @return the nullLabel
|
||||
*/
|
||||
public String getNullLabel() {
|
||||
return nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullLabel the nullLabel to set
|
||||
*/
|
||||
public void setNullLabel(String nullLabel) {
|
||||
this.nullLabel = nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullKeyValue
|
||||
*/
|
||||
public String getNullKeyValue() {
|
||||
return nullKeyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullKeyValue the nullKeyValue to set
|
||||
*/
|
||||
public void setNullKeyValue(String nullKeyValue) {
|
||||
this.nullKeyValue = nullKeyValue;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullLabel
|
||||
*/
|
||||
public String getNullLabel() {
|
||||
return nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullLabel the nullLabel to set
|
||||
*/
|
||||
public void setNullLabel(String nullLabel) {
|
||||
this.nullLabel = nullLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nullKeyValue
|
||||
*/
|
||||
public String getNullKeyValue() {
|
||||
return nullKeyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nullKeyValue the nullKeyValue to set
|
||||
*/
|
||||
public void setNullKeyValue(String nullKeyValue) {
|
||||
this.nullKeyValue = nullKeyValue;
|
||||
}
|
||||
}
|
|
@ -26,30 +26,41 @@ import java.util.Locale;
|
|||
|
||||
import net.forwardfire.vasc.xpql.query.QueryParameterValue.QueryParameterType;
|
||||
|
||||
import org.x4o.xml.converters.ObjectConverter;
|
||||
import org.x4o.xml.converters.ObjectConverterException;
|
||||
import org.x4o.xml.conv.AbstractStringObjectConverter;
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
|
||||
|
||||
/**
|
||||
* ParameterTypeObjectConverter
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 21, 2007
|
||||
*/
|
||||
public class ParameterTypeObjectConverter implements ObjectConverter {
|
||||
public class ParameterTypeObjectConverter extends AbstractStringObjectConverter {
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
private static final long serialVersionUID = 40849496158706355L;
|
||||
|
||||
public Class<?> getObjectClassTo() {
|
||||
return QueryParameterType.class;
|
||||
}
|
||||
|
||||
public String convertToString(Object obj, Locale locale) {
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((QueryParameterType)obj).name();
|
||||
}
|
||||
|
||||
public Object convertToObject(String str, Locale locale) throws ObjectConverterException {
|
||||
|
||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
try {
|
||||
return QueryParameterType.valueOf(""+str);
|
||||
} catch (Exception ex) {
|
||||
throw new ObjectConverterException(this,"Could not convert to QueryParameterType value="+str,ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
ParameterTypeObjectConverter result = new ParameterTypeObjectConverter();
|
||||
result.converters=cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -26,29 +26,42 @@ import java.util.Locale;
|
|||
|
||||
import net.forwardfire.vasc.xpql.query.Query.QueryType;
|
||||
|
||||
import org.x4o.xml.converters.ObjectConverter;
|
||||
import org.x4o.xml.converters.ObjectConverterException;
|
||||
import org.x4o.xml.conv.AbstractStringObjectConverter;
|
||||
import org.x4o.xml.conv.ObjectConverter;
|
||||
import org.x4o.xml.conv.ObjectConverterException;
|
||||
|
||||
/**
|
||||
* QueryTypeObjectConverter converts query type enum.
|
||||
*
|
||||
* todo: rm this for the enum conv.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 21, 2007
|
||||
*/
|
||||
public class QueryTypeObjectConverter implements ObjectConverter {
|
||||
public class QueryTypeObjectConverter extends AbstractStringObjectConverter {
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
private static final long serialVersionUID = 2383122486722789617L;
|
||||
|
||||
public Class<?> getObjectClassTo() {
|
||||
return QueryType.class;
|
||||
}
|
||||
|
||||
public String convertToString(Object obj, Locale locale) {
|
||||
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
|
||||
return ((QueryType)obj).name();
|
||||
}
|
||||
|
||||
public Object convertToObject(String str, Locale locale) throws ObjectConverterException {
|
||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||
try {
|
||||
return QueryType.valueOf(""+str);
|
||||
} catch (Exception ex) {
|
||||
throw new ObjectConverterException(this,"Could not convert to QueryType value="+str,ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectConverter clone() throws CloneNotSupportedException {
|
||||
QueryTypeObjectConverter result = new QueryTypeObjectConverter();
|
||||
result.converters=cloneConverters();
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue