split event listeners and made xml elements for event en actions on back/frontend
This commit is contained in:
parent
3d0d609462
commit
a51eeeb254
|
@ -41,6 +41,6 @@ import java.lang.annotation.Target;
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface VascEventListener {
|
public @interface VascEventListener {
|
||||||
|
|
||||||
String[] backendEventListeners();
|
String[] backendEventListeners() default {};
|
||||||
String[] frontendEventListeners();
|
String[] frontendEventListeners() default {};
|
||||||
}
|
}
|
|
@ -34,6 +34,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.backends.MapVascEntryFieldValue;
|
||||||
|
import com.idcanet.vasc.backends.MapVascEntryRecordCreator;
|
||||||
import com.idcanet.vasc.core.AbstractVascBackend;
|
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||||
import com.idcanet.vasc.core.VascBackendState;
|
import com.idcanet.vasc.core.VascBackendState;
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
@ -151,49 +153,13 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend {
|
||||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||||
*/
|
*/
|
||||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||||
VascEntryFieldValue result = new VascEntryFieldValue() {
|
return new MapVascEntryFieldValue();
|
||||||
/**
|
|
||||||
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Object getValue(VascEntryField field, Object record) throws VascException {
|
|
||||||
Map<String,Object> map = (Map<String,Object>)record;
|
|
||||||
Object o = map.get(field.getBackendName());
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getDisplayValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public String getDisplayValue(VascEntryField field, Object record) throws VascException {
|
|
||||||
return ""+getValue(field,record); // not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
|
|
||||||
Map<String,Object> map = (Map<String,Object>)record;
|
|
||||||
map.put(field.getBackendName(), value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||||
*/
|
*/
|
||||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||||
return new VascEntryRecordCreator() {
|
return new MapVascEntryRecordCreator();
|
||||||
|
|
||||||
public Class<?> getObjectClass() {
|
|
||||||
return Map.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object newRecord(VascEntry entry) throws Exception {
|
|
||||||
return new HashMap<String,Object>(10);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,9 @@
|
||||||
|
|
||||||
package com.idcanet.vasc.core;
|
package com.idcanet.vasc.core;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
|
@ -56,10 +59,11 @@ abstract public class AbstractVascFrontend implements VascFrontend {
|
||||||
*/
|
*/
|
||||||
public void initEntry(VascEntry entry) throws Exception {
|
public void initEntry(VascEntry entry) throws Exception {
|
||||||
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
if (entry.getVascFrontendData().getVascFrontend()==null) {
|
||||||
|
Logger.getLogger(AbstractVascFrontend.class.getName()).fine("Bind frontend: "+this+" to: "+entry.getVascFrontendData()+" entry: "+entry.getId());
|
||||||
entry.getVascFrontendData().setVascFrontend(this);
|
entry.getVascFrontendData().setVascFrontend(this);
|
||||||
} else {
|
} else {
|
||||||
if (entry.getVascFrontendData().getVascFrontend()!=this) {
|
if (entry.getVascFrontendData().getVascFrontend()!=this) {
|
||||||
throw new IllegalArgumentException("VascEntry has already a differtent VascFrontend attected");
|
throw new IllegalArgumentException("VascEntry '"+entry.getId()+"' data: "+entry.getVascFrontendData()+" frontend: "+this+" has already a differtent VascFrontend attected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entry=entry;
|
this.entry=entry;
|
||||||
|
|
|
@ -393,13 +393,13 @@ public interface VascEntry extends Cloneable,Serializable {
|
||||||
* Added an VascEntryFrontendEventListener
|
* Added an VascEntryFrontendEventListener
|
||||||
* @param listener The class of the event listener.
|
* @param listener The class of the event listener.
|
||||||
*/
|
*/
|
||||||
public void addVascEntryFrontendEventListener(String listener);
|
public void addVascEntryFrontendEventListener(String listener,String frontendType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of VascEntryFrontendEventListener
|
* Returns the list of VascEntryFrontendEventListener
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getVascEntryFrontendEventListeners();
|
public List<String> getVascEntryFrontendEventListenersByType(String frontendType);
|
||||||
|
|
||||||
|
|
||||||
public void addListOption(VascEntryField listOption);
|
public void addListOption(VascEntryField listOption);
|
||||||
|
@ -409,6 +409,9 @@ public interface VascEntry extends Cloneable,Serializable {
|
||||||
public void addVascBackendFilter(VascBackendFilter filter);
|
public void addVascBackendFilter(VascBackendFilter filter);
|
||||||
public List<VascBackendFilter> getVascBackendFilters();
|
public List<VascBackendFilter> getVascBackendFilters();
|
||||||
|
|
||||||
|
public void addVascEntryFrontendAction(String actionClass,String frontendType);
|
||||||
|
public List<String> getVascEntryFrontendActionsByType(String frontendType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force impl to have public clone methode
|
* Force impl to have public clone methode
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -40,6 +40,8 @@ public interface VascFrontend {
|
||||||
|
|
||||||
public String getId();
|
public String getId();
|
||||||
|
|
||||||
|
public String getFrontendType();
|
||||||
|
|
||||||
public void initEntry(VascEntry entry) throws Exception;
|
public void initEntry(VascEntry entry) throws Exception;
|
||||||
|
|
||||||
public void renderView() throws Exception;
|
public void renderView() throws Exception;
|
||||||
|
|
|
@ -103,7 +103,7 @@ public interface VascFrontendData {
|
||||||
public VascEntryState getVascEntryState();
|
public VascEntryState getVascEntryState();
|
||||||
public void setVascEntryState(VascEntryState state);
|
public void setVascEntryState(VascEntryState state);
|
||||||
|
|
||||||
public void initFrontendListeners(VascEntry entry) throws InstantiationException, IllegalAccessException;
|
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException;
|
||||||
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
|
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener);
|
||||||
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
|
public List<VascEntryFrontendEventListener> getVascEntryFrontendEventListener(VascEntryFrontendEventListener.VascFrontendEventType type);
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@ public interface VascEntryBackendEventListener extends Serializable {
|
||||||
POST_MOVE_UP
|
POST_MOVE_UP
|
||||||
}
|
}
|
||||||
|
|
||||||
public VascBackendEventType[] getEventType();
|
public VascBackendEventType[] getEventTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is executed when the type of event is fired.
|
* Is executed when the type of event is fired.
|
||||||
|
|
|
@ -41,9 +41,7 @@ import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
import com.idcanet.vasc.core.actions.VascAction;
|
import com.idcanet.vasc.core.actions.VascAction;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
|
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VascEntry
|
* VascEntry
|
||||||
|
@ -87,10 +85,11 @@ public class DefaultVascEntry implements VascEntry {
|
||||||
private List<VascLinkEntry> vascLinkEntries = null;
|
private List<VascLinkEntry> vascLinkEntries = null;
|
||||||
private Map<String,Object> entryParameters = null;
|
private Map<String,Object> entryParameters = null;
|
||||||
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
|
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
|
||||||
private List<String> eventEntryFrontendEventListeners = null;
|
private Map<String,List<String>> eventEntryFrontendEventListeners = null;
|
||||||
private List<String> eventEntryBackendEventListeners = null;
|
private List<String> eventEntryBackendEventListeners = null;
|
||||||
private List<VascEntryField> listOptions = null;
|
private List<VascEntryField> listOptions = null;
|
||||||
private List<VascBackendFilter> backendFilters = null;
|
private List<VascBackendFilter> backendFilters = null;
|
||||||
|
private Map<String,List<String>> eventEntryFrontendActions = null;
|
||||||
|
|
||||||
private String backendId = null;
|
private String backendId = null;
|
||||||
private VascFrontendData vascFrontendData = null;
|
private VascFrontendData vascFrontendData = null;
|
||||||
|
@ -109,7 +108,8 @@ public class DefaultVascEntry implements VascEntry {
|
||||||
vascLinkEntries = new ArrayList<VascLinkEntry>(10);
|
vascLinkEntries = new ArrayList<VascLinkEntry>(10);
|
||||||
entryParameters = new HashMap<String,Object>(10);
|
entryParameters = new HashMap<String,Object>(10);
|
||||||
|
|
||||||
eventEntryFrontendEventListeners = new ArrayList<String>(10);
|
eventEntryFrontendActions = new HashMap<String,List<String>>(10);
|
||||||
|
eventEntryFrontendEventListeners = new HashMap<String,List<String>>(10);
|
||||||
eventEntryBackendEventListeners = new ArrayList<String>(10);
|
eventEntryBackendEventListeners = new ArrayList<String>(10);
|
||||||
listOptions = new ArrayList<VascEntryField>(5);
|
listOptions = new ArrayList<VascEntryField>(5);
|
||||||
backendFilters = new ArrayList<VascBackendFilter>(3);
|
backendFilters = new ArrayList<VascBackendFilter>(3);
|
||||||
|
@ -143,8 +143,9 @@ public class DefaultVascEntry implements VascEntry {
|
||||||
result.vascAdminDelete=vascAdminDelete;
|
result.vascAdminDelete=vascAdminDelete;
|
||||||
result.backendId=backendId;
|
result.backendId=backendId;
|
||||||
result.vascEntryFieldEventChannel=vascEntryFieldEventChannel;
|
result.vascEntryFieldEventChannel=vascEntryFieldEventChannel;
|
||||||
result.eventEntryFrontendEventListeners.addAll(eventEntryFrontendEventListeners);
|
result.eventEntryFrontendEventListeners.putAll(eventEntryFrontendEventListeners);
|
||||||
result.eventEntryBackendEventListeners.addAll(eventEntryBackendEventListeners);
|
result.eventEntryBackendEventListeners.addAll(eventEntryBackendEventListeners);
|
||||||
|
result.eventEntryFrontendActions.putAll(eventEntryFrontendActions);
|
||||||
// skipping 'vascFrontendData' because it should always be null when cloning happens.
|
// skipping 'vascFrontendData' because it should always be null when cloning happens.
|
||||||
|
|
||||||
for (VascEntryField f:vascFields) {
|
for (VascEntryField f:vascFields) {
|
||||||
|
@ -172,10 +173,10 @@ public class DefaultVascEntry implements VascEntry {
|
||||||
ff.setVascEntry(result);
|
ff.setVascEntry(result);
|
||||||
result.listOptions.add(ff);
|
result.listOptions.add(ff);
|
||||||
}
|
}
|
||||||
for (VascBackendFilter f:backendFilters) {
|
// for (VascBackendFilter f:backendFilters) {
|
||||||
VascBackendFilter ff = f.clone();
|
// VascBackendFilter ff = f.clone();
|
||||||
result.backendFilters.add(ff);
|
// result.backendFilters.add(ff);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// no cloning of the values here ?
|
// no cloning of the values here ?
|
||||||
|
@ -736,17 +737,83 @@ public class DefaultVascEntry implements VascEntry {
|
||||||
* Added an VascEntryFrontendEventListener
|
* Added an VascEntryFrontendEventListener
|
||||||
* @param listener The class of the event listener.
|
* @param listener The class of the event listener.
|
||||||
*/
|
*/
|
||||||
public void addVascEntryFrontendEventListener(String listener) {
|
public void addVascEntryFrontendEventListener(String listener,String frontendType) {
|
||||||
eventEntryFrontendEventListeners.add(listener);
|
if (frontendType==null) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
List<String> typeList = eventEntryFrontendEventListeners.get(frontendType);
|
||||||
|
if (typeList==null) {
|
||||||
|
typeList = new ArrayList<String>(10);
|
||||||
|
eventEntryFrontendEventListeners.put(frontendType,typeList);
|
||||||
|
}
|
||||||
|
typeList.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of VascEntryFrontendEventListener
|
* Returns the list of VascEntryFrontendEventListener
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getVascEntryFrontendEventListeners() {
|
public List<String> getVascEntryFrontendEventListenersByType(String frontendType) {
|
||||||
return eventEntryFrontendEventListeners;
|
if (frontendType==null) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
}
|
}
|
||||||
|
if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
List<String> typeList = eventEntryFrontendEventListeners.get(frontendType);
|
||||||
|
if (typeList==null) {
|
||||||
|
typeList = new ArrayList<String>(0);
|
||||||
|
}
|
||||||
|
if (frontendType.equals("__ALL__")==false) {
|
||||||
|
// also add all
|
||||||
|
List<String> typeListAll = eventEntryFrontendEventListeners.get("__ALL__");
|
||||||
|
if (typeListAll!=null) {
|
||||||
|
typeList.addAll(typeListAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVascEntryFrontendAction(String actionClass,String frontendType) {
|
||||||
|
if (frontendType==null) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
List<String> typeList = eventEntryFrontendActions.get(frontendType);
|
||||||
|
if (typeList==null) {
|
||||||
|
typeList = new ArrayList<String>(10);
|
||||||
|
eventEntryFrontendActions.put(frontendType,typeList);
|
||||||
|
}
|
||||||
|
typeList.add(actionClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> getVascEntryFrontendActionsByType(String frontendType) {
|
||||||
|
if (frontendType==null) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
if (frontendType.isEmpty() | "all".equalsIgnoreCase(frontendType)) {
|
||||||
|
frontendType = "__ALL__";
|
||||||
|
}
|
||||||
|
List<String> typeList = eventEntryFrontendActions.get(frontendType);
|
||||||
|
if (typeList==null) {
|
||||||
|
typeList = new ArrayList<String>(0);
|
||||||
|
}
|
||||||
|
if (frontendType.equals("__ALL__")==false) {
|
||||||
|
// also add all
|
||||||
|
List<String> typeListAll = eventEntryFrontendActions.get("__ALL__");
|
||||||
|
if (typeListAll!=null) {
|
||||||
|
typeList.addAll(typeListAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addListOption(VascEntryField listOption) {
|
public void addListOption(VascEntryField listOption) {
|
||||||
if (listOption==null) {
|
if (listOption==null) {
|
||||||
|
|
|
@ -116,9 +116,6 @@ public class DefaultVascFactory {
|
||||||
backend = new VascBackendProxyPaged(backend,entry);
|
backend = new VascBackendProxyPaged(backend,entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute backend event listeners
|
|
||||||
backend = new VascBackendProxyEventExecutor(backend,entry);
|
|
||||||
|
|
||||||
// return the configed backend.
|
// return the configed backend.
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ import com.idcanet.vasc.core.VascException;
|
||||||
import com.idcanet.vasc.core.VascFrontend;
|
import com.idcanet.vasc.core.VascFrontend;
|
||||||
import com.idcanet.vasc.core.VascFrontendData;
|
import com.idcanet.vasc.core.VascFrontendData;
|
||||||
import com.idcanet.vasc.core.VascFrontendHelper;
|
import com.idcanet.vasc.core.VascFrontendHelper;
|
||||||
|
import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||||
|
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||||
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
|
import com.idcanet.vasc.core.actions.VascAction;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFieldValidatorService;
|
import com.idcanet.vasc.core.entry.VascEntryFieldValidatorService;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
|
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryResourceImageResolver;
|
import com.idcanet.vasc.core.entry.VascEntryResourceImageResolver;
|
||||||
|
@ -247,12 +251,12 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initFrontendListeners(VascEntry entry) throws InstantiationException, IllegalAccessException {
|
public void initFrontendListeners(VascEntry entry,String frontendType) throws InstantiationException, IllegalAccessException {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
if (cl==null) {
|
if (cl==null) {
|
||||||
cl = entry.getClass().getClassLoader();
|
cl = entry.getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
for (String clazz:entry.getVascEntryFrontendEventListeners()) {
|
for (String clazz:entry.getVascEntryFrontendEventListenersByType(frontendType)) {
|
||||||
VascEntryFrontendEventListener listener;
|
VascEntryFrontendEventListener listener;
|
||||||
try {
|
try {
|
||||||
listener = (VascEntryFrontendEventListener)cl.loadClass(clazz).newInstance();
|
listener = (VascEntryFrontendEventListener)cl.loadClass(clazz).newInstance();
|
||||||
|
@ -261,6 +265,44 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
||||||
}
|
}
|
||||||
addVascEntryFrontendEventListener(listener);
|
addVascEntryFrontendEventListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (String clazz:entry.getVascEntryFrontendActionsByType(frontendType)) {
|
||||||
|
Object obj = null;
|
||||||
|
try {
|
||||||
|
obj = cl.loadClass(clazz).newInstance();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException("Could not load frontend action of: "+clazz);
|
||||||
|
}
|
||||||
|
if (obj instanceof VascAction) {
|
||||||
|
VascAction action = (VascAction)obj;
|
||||||
|
String aid = action.getId();
|
||||||
|
if (aid==null) {
|
||||||
|
throw new IllegalArgumentException("Action has no id: "+action+" in entryId: "+entry.getId());
|
||||||
|
}
|
||||||
|
if (action.getName()==null) {
|
||||||
|
action.setName("vasc.action."+aid+".name");
|
||||||
|
}
|
||||||
|
if (action.getDescription()==null) {
|
||||||
|
action.setDescription("vasc.action."+aid+".description");
|
||||||
|
}
|
||||||
|
if (action.getImage()==null) {
|
||||||
|
action.setImage("vasc.action."+aid+".image");
|
||||||
|
}
|
||||||
|
if (action.getHelpId()==null) {
|
||||||
|
action.setHelpId("vasc.action."+aid+".helpId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj instanceof RowVascAction) {
|
||||||
|
entry.addRowAction((RowVascAction)obj);
|
||||||
|
}
|
||||||
|
if (obj instanceof ColumnVascAction) {
|
||||||
|
entry.addColumnAction((ColumnVascAction)obj);
|
||||||
|
}
|
||||||
|
if (obj instanceof GlobalVascAction) {
|
||||||
|
entry.addGlobalAction((GlobalVascAction)obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener) {
|
public void addVascEntryFrontendEventListener(VascEntryFrontendEventListener listener) {
|
||||||
|
|
|
@ -68,12 +68,30 @@ public class VascBackendProxyEventExecutor extends AbstractVascBackendProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public VascBackendProxyEventExecutor(VascBackend backend,VascEntry entry,List<VascEntryBackendEventListener> listeners) {
|
||||||
|
super(backend);
|
||||||
|
this.entry=entry;
|
||||||
|
this.listeners=listeners;
|
||||||
|
}
|
||||||
|
|
||||||
private void fireVascEvent(VascBackendEventType type, Object data) {
|
private void fireVascEvent(VascBackendEventType type, Object data) {
|
||||||
for (int i=0;i<listeners.size();i++) {
|
for (int i=0;i<listeners.size();i++) {
|
||||||
VascEntryBackendEventListener l = listeners.get(i);
|
VascEntryBackendEventListener l = listeners.get(i);
|
||||||
|
VascBackendEventType[] types = l.getEventTypes();
|
||||||
|
if (types==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (types.length==0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int t=0;t<types.length;t++) {
|
||||||
|
VascBackendEventType typeListener = types[t];
|
||||||
|
if (typeListener==type) {
|
||||||
l.vascEvent(entry, data);
|
l.vascEvent(entry, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#delete(java.lang.Object)
|
* @see com.idcanet.vasc.core.AbstractVascBackendProxy#delete(java.lang.Object)
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
package com.idcanet.vasc.impl.entry;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascBackendState;
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
|
||||||
|
|
||||||
|
public class SetParameterBackendListener implements VascEntryBackendEventListener {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private String name = null;
|
||||||
|
private String value = null;
|
||||||
|
private String type = null;
|
||||||
|
|
||||||
|
private boolean isUserValue = false;
|
||||||
|
private Long userId = null;
|
||||||
|
private String userName = null;
|
||||||
|
|
||||||
|
public SetParameterBackendListener() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public SetParameterBackendListener(Long userId,String userName) {
|
||||||
|
this.userId=userId;
|
||||||
|
this.userName=userName;
|
||||||
|
isUserValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.entry.VascEntryBackendEventListener#getEventType()
|
||||||
|
*/
|
||||||
|
public VascBackendEventType[] getEventTypes() {
|
||||||
|
return new VascBackendEventType[] {
|
||||||
|
VascBackendEventType.PRE_DELETE,
|
||||||
|
VascBackendEventType.PRE_EXECUTE,
|
||||||
|
VascBackendEventType.PRE_MERGE,
|
||||||
|
VascBackendEventType.PRE_MOVE_DOWN,
|
||||||
|
VascBackendEventType.PRE_MOVE_UP,
|
||||||
|
VascBackendEventType.PRE_PERSIST,
|
||||||
|
VascBackendEventType.PRE_TOTAL_EXECUTE_SIZE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.entry.VascEntryBackendEventListener#vascEvent(com.idcanet.vasc.core.VascEntry, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void vascEvent(VascEntry entry, Object data) {
|
||||||
|
if (data instanceof VascBackendState) {
|
||||||
|
VascBackendState state = (VascBackendState)data;
|
||||||
|
if (isUserValue) {
|
||||||
|
if (value==null) {
|
||||||
|
value="id";
|
||||||
|
}
|
||||||
|
if ("id".equals(value)) {
|
||||||
|
if ("int".equals(type)) {
|
||||||
|
state.setDataParameter(name, userId.intValue());
|
||||||
|
} else {
|
||||||
|
state.setDataParameter(name, userId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.setDataParameter(name, userName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.setDataParameter(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value the value to set
|
||||||
|
*/
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type the type to set
|
||||||
|
*/
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userId
|
||||||
|
*/
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userId the userId to set
|
||||||
|
*/
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userName
|
||||||
|
*/
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userName the userName to set
|
||||||
|
*/
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,7 +112,7 @@ public class AnnotationParserElement extends AbstractElement {
|
||||||
VascEventListener vc = parser.getVascEventListener(modelClass);
|
VascEventListener vc = parser.getVascEventListener(modelClass);
|
||||||
if (vc!=null) {
|
if (vc!=null) {
|
||||||
for (String listener:vc.frontendEventListeners()) {
|
for (String listener:vc.frontendEventListeners()) {
|
||||||
entry.addVascEntryFrontendEventListener(listener);
|
entry.addVascEntryFrontendEventListener(listener,null);
|
||||||
}
|
}
|
||||||
for (String listener:vc.backendEventListeners()) {
|
for (String listener:vc.backendEventListeners()) {
|
||||||
entry.addVascEntryBackendEventListener(listener);
|
entry.addVascEntryBackendEventListener(listener);
|
||||||
|
|
|
@ -58,21 +58,7 @@ public class SetParameterElement extends AbstractElement {
|
||||||
logger.fine("Setting parameter name: "+name+" value: "+value+" type: "+type);
|
logger.fine("Setting parameter name: "+name+" value: "+value+" type: "+type);
|
||||||
|
|
||||||
if ("setUserParameter".equals(getElementClass().getTag())) {
|
if ("setUserParameter".equals(getElementClass().getTag())) {
|
||||||
if (value==null) {
|
entry.setEntryParameter(name, "userPara:"+type+":"+value);
|
||||||
value="id";
|
|
||||||
}
|
|
||||||
if ("id".equals(value)) {
|
|
||||||
if ("int".equals(type)) {
|
|
||||||
Long userId = cont.getVascUserRoleController().getUserId();
|
|
||||||
entry.setEntryParameter(name, userId.intValue());
|
|
||||||
} else {
|
|
||||||
Long userId = cont.getVascUserRoleController().getUserId();
|
|
||||||
entry.setEntryParameter(name, userId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String userName = cont.getVascUserRoleController().getUserName();
|
|
||||||
entry.setEntryParameter(name, userName);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +78,6 @@ public class SetParameterElement extends AbstractElement {
|
||||||
|
|
||||||
throw new ElementException("Could not set dataParameter: "+name+" with type: "+type);
|
throw new ElementException("Could not set dataParameter: "+name+" with type: "+type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. 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 IDCA 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 IDCA 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.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl.x4o;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||||
|
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||||
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
|
|
||||||
|
import com.idcanet.x4o.core.X4OParser;
|
||||||
|
import com.idcanet.x4o.element.AbstractElement;
|
||||||
|
import com.idcanet.x4o.element.ElementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handed the eventListener xml tag.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Oct 18, 2010
|
||||||
|
*/
|
||||||
|
public class VascEntryActionElement extends AbstractElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doElementRun() throws ElementException {
|
||||||
|
String clazz = getAttributes().get("class");
|
||||||
|
String type = getAttributes().get("type");
|
||||||
|
String frontendType = getAttributes().get("frontendType");
|
||||||
|
if (clazz==null) {
|
||||||
|
throw new ElementException("No class attribute given.");
|
||||||
|
}
|
||||||
|
if (clazz.isEmpty()) {
|
||||||
|
throw new ElementException("class attribute is empty.");
|
||||||
|
}
|
||||||
|
if (getParent().getElementObject() instanceof VascEntry==false) {
|
||||||
|
throw new ElementException("Parent object is not vasc entry.");
|
||||||
|
}
|
||||||
|
VascEntry v = (VascEntry)getParent().getElementObject();
|
||||||
|
if ("backend".equalsIgnoreCase(type)) {
|
||||||
|
Object obj = null;
|
||||||
|
try {
|
||||||
|
Class<?> clazz2 = X4OParser.loadClass(clazz);
|
||||||
|
obj = clazz2.newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ElementException("Could not load class: "+clazz);
|
||||||
|
}
|
||||||
|
if (obj instanceof RowVascAction) {
|
||||||
|
v.addRowAction((RowVascAction)obj);
|
||||||
|
}
|
||||||
|
if (obj instanceof ColumnVascAction) {
|
||||||
|
v.addColumnAction((ColumnVascAction)obj);
|
||||||
|
}
|
||||||
|
if (obj instanceof GlobalVascAction) {
|
||||||
|
v.addGlobalAction((GlobalVascAction)obj);
|
||||||
|
}
|
||||||
|
} else if ("frontend".equalsIgnoreCase(type)) {
|
||||||
|
v.addVascEntryFrontendAction(clazz, frontendType);
|
||||||
|
} else {
|
||||||
|
throw new ElementException("Unsupported type attribute: "+type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||||
|
* following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||||
|
* the following disclaimer.
|
||||||
|
* 2. 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 IDCA 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 IDCA 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.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||||
|
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.idcanet.vasc.impl.x4o;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
|
|
||||||
|
import com.idcanet.x4o.element.AbstractElement;
|
||||||
|
import com.idcanet.x4o.element.ElementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handed the eventListener xml tag.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Oct 18, 2010
|
||||||
|
*/
|
||||||
|
public class VascEventListenerElement extends AbstractElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.x4o.element.AbstractElement#doElementRun()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doElementRun() throws ElementException {
|
||||||
|
String clazz = getAttributes().get("class");
|
||||||
|
String type = getAttributes().get("type");
|
||||||
|
String frontendType = getAttributes().get("frontendType");
|
||||||
|
if (clazz==null) {
|
||||||
|
throw new ElementException("No class attribute given.");
|
||||||
|
}
|
||||||
|
if (clazz.isEmpty()) {
|
||||||
|
throw new ElementException("class attribute is empty.");
|
||||||
|
}
|
||||||
|
if (getParent().getElementObject() instanceof VascEntry==false) {
|
||||||
|
throw new ElementException("Parent object is not vasc entry.");
|
||||||
|
}
|
||||||
|
VascEntry v = (VascEntry)getParent().getElementObject();
|
||||||
|
if ("backend".equalsIgnoreCase(type)) {
|
||||||
|
v.addVascEntryBackendEventListener(clazz);
|
||||||
|
} else if ("frontend".equalsIgnoreCase(type)) {
|
||||||
|
v.addVascEntryFrontendEventListener(clazz, frontendType);
|
||||||
|
} else {
|
||||||
|
throw new ElementException("Unsupported type attribute: "+type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,8 @@
|
||||||
<eld:elementClassAttributeConverter attributeName="vascEntryFieldType" bean.class="com.idcanet.vasc.impl.x4o.VascEntryFieldTypeAttributeConverter"/>
|
<eld:elementClassAttributeConverter attributeName="vascEntryFieldType" bean.class="com.idcanet.vasc.impl.x4o.VascEntryFieldTypeAttributeConverter"/>
|
||||||
</eld:elementClass>
|
</eld:elementClass>
|
||||||
<eld:elementClass tag="vascEntryFieldType" elementClassName="com.idcanet.vasc.impl.x4o.VascEntryFieldTypeElement"/>
|
<eld:elementClass tag="vascEntryFieldType" elementClassName="com.idcanet.vasc.impl.x4o.VascEntryFieldTypeElement"/>
|
||||||
|
<eld:elementClass tag="eventListener" elementClassName="com.idcanet.vasc.impl.x4o.VascEventListenerElement"/>
|
||||||
|
<eld:elementClass tag="entryAction" elementClassName="com.idcanet.vasc.impl.x4o.VascEntryActionElement"/>
|
||||||
|
|
||||||
<eld:elementClass tag="vascSelectItemModel" objectClassName="com.idcanet.vasc.impl.DefaultVascSelectItemModel"/>
|
<eld:elementClass tag="vascSelectItemModel" objectClassName="com.idcanet.vasc.impl.DefaultVascSelectItemModel"/>
|
||||||
<eld:elementClass tag="vascSelectItemEntryParameter" elementClassName="com.idcanet.vasc.impl.x4o.VascLinkEntryParameterElement"/>
|
<eld:elementClass tag="vascSelectItemEntryParameter" elementClassName="com.idcanet.vasc.impl.x4o.VascLinkEntryParameterElement"/>
|
||||||
|
|
|
@ -49,11 +49,13 @@ import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import com.idcanet.vasc.backends.jpa.EntityManagerProvider;
|
import com.idcanet.vasc.backends.jpa.EntityManagerProvider;
|
||||||
import com.idcanet.vasc.core.VascBackend;
|
import com.idcanet.vasc.core.VascBackend;
|
||||||
|
import com.idcanet.vasc.core.VascBackendControllerLocal;
|
||||||
import com.idcanet.vasc.core.VascController;
|
import com.idcanet.vasc.core.VascController;
|
||||||
import com.idcanet.vasc.core.VascEntry;
|
import com.idcanet.vasc.core.VascEntry;
|
||||||
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||||
import com.idcanet.vasc.impl.DefaultVascEntryController;
|
import com.idcanet.vasc.impl.DefaultVascEntryController;
|
||||||
import com.idcanet.vasc.impl.DefaultVascFactory;
|
import com.idcanet.vasc.impl.DefaultVascFactory;
|
||||||
|
import com.idcanet.vasc.impl.VascBackendProxyEventExecutor;
|
||||||
import com.idcanet.vasc.impl.actions.AddRowAction;
|
import com.idcanet.vasc.impl.actions.AddRowAction;
|
||||||
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
|
||||||
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
import com.idcanet.vasc.impl.actions.DeleteRowAction;
|
||||||
|
@ -92,17 +94,15 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
||||||
public void loadAll() {
|
public void loadAll() {
|
||||||
logger.fine("VascServiceManager created now loading resources...");
|
logger.fine("VascServiceManager created now loading resources...");
|
||||||
try {
|
try {
|
||||||
long s = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Map<String,String> keys = loadKeys();
|
Map<String,String> keys = loadKeys();
|
||||||
for (String key:keys.keySet()) {
|
for (String key:keys.keySet()) {
|
||||||
String value = keys.get(key);
|
String value = keys.get(key);
|
||||||
if ("persistenceUnit".equals(key)) {
|
if ("persistenceUnit".equals(key)) {
|
||||||
logger.info("getting EntityManager: "+value);
|
logger.fine("getting EntityManager: "+value);
|
||||||
entityManager = (EntityManager)new InitialContext().lookup(value);
|
entityManager = (EntityManager)new InitialContext().lookup(value);
|
||||||
}
|
}
|
||||||
if ("xpqlController".equals(key)) {
|
if ("xpqlController".equals(key)) {
|
||||||
logger.info("getting XpqlQueryManagerLocal: "+value);
|
logger.fine("getting XpqlQueryManagerLocal: "+value);
|
||||||
xpqlController = (XpqlQueryManager)new InitialContext().lookup(value);
|
xpqlController = (XpqlQueryManager)new InitialContext().lookup(value);
|
||||||
}
|
}
|
||||||
if ("i18nBundle".equals(key)) {
|
if ("i18nBundle".equals(key)) {
|
||||||
|
@ -119,9 +119,10 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
||||||
if (resourceBundle==null) {
|
if (resourceBundle==null) {
|
||||||
new NullPointerException("Have no resourceBundle");
|
new NullPointerException("Have no resourceBundle");
|
||||||
}
|
}
|
||||||
|
long s = System.currentTimeMillis();
|
||||||
|
|
||||||
// get local jvm plugging controller
|
// get local jvm plugging controller
|
||||||
VascController c = DefaultVascFactory.getDefaultVascController(22l, "test", "login");
|
VascController c = DefaultVascFactory.getDefaultVascController(0l, "nobody", "NO_ROLE");
|
||||||
|
|
||||||
for (String key:keys.keySet()) {
|
for (String key:keys.keySet()) {
|
||||||
String value = keys.get(key);
|
String value = keys.get(key);
|
||||||
|
@ -391,9 +392,14 @@ public class VascServiceManagerImpl implements VascServiceManager.IRemote,VascSe
|
||||||
// this is temp untill x4o templaing
|
// this is temp untill x4o templaing
|
||||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||||
f.finalizeVascEntry(entry, c);
|
f.finalizeVascEntry(entry, c);
|
||||||
|
|
||||||
|
// execute backend event listeners
|
||||||
|
VascBackend vb = c.getVascBackendController().getVascBackendById(entry.getBackendId());
|
||||||
|
vb = new VascBackendProxyEventExecutor(vb,entry);
|
||||||
|
((VascBackendControllerLocal)c.getVascBackendController()).addVascBackend(vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("VASC COMPLEET LETS RETURN.");
|
logger.finer("Done final config vascController: "+c);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,13 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#getFrontendType()
|
||||||
|
*/
|
||||||
|
public String getFrontendType() {
|
||||||
|
return "swing";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add swing implmented ui components
|
* Add swing implmented ui components
|
||||||
*/
|
*/
|
||||||
|
@ -686,15 +693,12 @@ class SpringUtilities {
|
||||||
* @param yPad
|
* @param yPad
|
||||||
* y padding between cells
|
* y padding between cells
|
||||||
*/
|
*/
|
||||||
public static void makeGrid(Container parent, int rows, int cols,
|
public static void makeGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||||
int initialX, int initialY, int xPad, int yPad) {
|
|
||||||
SpringLayout layout;
|
SpringLayout layout;
|
||||||
try {
|
try {
|
||||||
layout = (SpringLayout) parent.getLayout();
|
layout = (SpringLayout) parent.getLayout();
|
||||||
} catch (ClassCastException exc) {
|
} catch (ClassCastException exc) {
|
||||||
System.err
|
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||||
.println("The first argument to makeGrid must use SpringLayout.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spring xPadSpring = Spring.constant(xPad);
|
Spring xPadSpring = Spring.constant(xPad);
|
||||||
|
@ -788,15 +792,12 @@ class SpringUtilities {
|
||||||
* @param yPad
|
* @param yPad
|
||||||
* y padding between cells
|
* y padding between cells
|
||||||
*/
|
*/
|
||||||
public static void makeCompactGrid(Container parent, int rows, int cols,
|
public static void makeCompactGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
|
||||||
int initialX, int initialY, int xPad, int yPad) {
|
|
||||||
SpringLayout layout;
|
SpringLayout layout;
|
||||||
try {
|
try {
|
||||||
layout = (SpringLayout) parent.getLayout();
|
layout = (SpringLayout) parent.getLayout();
|
||||||
} catch (ClassCastException exc) {
|
} catch (ClassCastException exc) {
|
||||||
System.err
|
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
|
||||||
.println("The first argument to makeCompactGrid must use SpringLayout.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Align all cells in each column and make them the same width.
|
//Align all cells in each column and make them the same width.
|
||||||
|
|
|
@ -104,6 +104,13 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#getFrontendType()
|
||||||
|
*/
|
||||||
|
public String getFrontendType() {
|
||||||
|
return "swt";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add swt implmented ui components
|
* Add swt implmented ui components
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,13 +51,17 @@ import com.idcanet.vasc.core.VascEntryControllerLocal;
|
||||||
import com.idcanet.vasc.core.VascEntryField;
|
import com.idcanet.vasc.core.VascEntryField;
|
||||||
import com.idcanet.vasc.core.VascException;
|
import com.idcanet.vasc.core.VascException;
|
||||||
import com.idcanet.vasc.core.VascFrontendData;
|
import com.idcanet.vasc.core.VascFrontendData;
|
||||||
|
import com.idcanet.vasc.core.entry.VascEntryBackendEventListener;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
|
import com.idcanet.vasc.core.entry.VascEntryFrontendEventListener;
|
||||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||||
import com.idcanet.vasc.ejb3.VascServiceManager;
|
import com.idcanet.vasc.ejb3.VascServiceManager;
|
||||||
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascEntryState;
|
||||||
import com.idcanet.vasc.impl.DefaultVascFactory;
|
import com.idcanet.vasc.impl.DefaultVascFactory;
|
||||||
|
import com.idcanet.vasc.impl.VascBackendProxyEventExecutor;
|
||||||
import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
import com.idcanet.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||||
|
import com.idcanet.vasc.impl.entry.SetParameterBackendListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base faces session object for managing vasc entries.
|
* Base faces session object for managing vasc entries.
|
||||||
|
@ -175,6 +179,9 @@ abstract public class AbstractJSFVascFacesController {
|
||||||
VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId);
|
VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId);
|
||||||
entry.setVascFrontendData(getNewVascFrontendData());
|
entry.setVascFrontendData(getNewVascFrontendData());
|
||||||
entry.getVascFrontendData().setVascController(getVascController());
|
entry.getVascFrontendData().setVascController(getVascController());
|
||||||
|
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setVascBackend(backend);
|
||||||
|
entry.getVascFrontendData().getVascEntryState().setVascEntry(entry);
|
||||||
|
|
||||||
// copy para
|
// copy para
|
||||||
if (para!=null) {
|
if (para!=null) {
|
||||||
|
@ -187,8 +194,7 @@ abstract public class AbstractJSFVascFacesController {
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||||
return entry.getVascFrontendData().getVascEntryState().getEntryDataList();
|
return entry.getVascFrontendData().getVascEntryState().getEntryDataList();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Could not execute list: "+e.getMessage(),e);
|
||||||
return new ArrayList<Object>(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,6 +392,31 @@ abstract public class AbstractJSFVascFacesController {
|
||||||
VascEntry ve = vascManager.getVascEntry(id);
|
VascEntry ve = vascManager.getVascEntry(id);
|
||||||
String backendId = ve.getBackendId();
|
String backendId = ve.getBackendId();
|
||||||
VascBackend vb = new RemoteVascBackend(backendId,vascManager);
|
VascBackend vb = new RemoteVascBackend(backendId,vascManager);
|
||||||
|
|
||||||
|
for (String key:ve.getEntryParameterKeys()) {
|
||||||
|
Object value = ve.getEntryParameter(key);
|
||||||
|
if (value instanceof String==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String paraValue = (String)value;
|
||||||
|
if (paraValue.startsWith("userPara")==false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] ps = paraValue.split(":");
|
||||||
|
String type = ps[1];
|
||||||
|
String paraTypeValue = ps[2];
|
||||||
|
|
||||||
|
SetParameterBackendListener listener = new SetParameterBackendListener(vui.userId,vui.username);
|
||||||
|
listener.setName(key);
|
||||||
|
listener.setType(type);
|
||||||
|
// listener.setValue(paraTypeValue);
|
||||||
|
|
||||||
|
List<VascEntryBackendEventListener> listeners=new ArrayList<VascEntryBackendEventListener>(10);
|
||||||
|
listeners.add(listener);
|
||||||
|
vb = new VascBackendProxyEventExecutor(vb,ve,listeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
localBackendController.addVascBackend(vb);
|
localBackendController.addVascBackend(vb);
|
||||||
|
|
||||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
||||||
try {
|
try {
|
||||||
result = ve.getDisplayValue(v, row);
|
result = ve.getDisplayValue(v, row);
|
||||||
} catch (VascException e) {
|
} catch (VascException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Could not get parent name DisplayValue: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
||||||
try {
|
try {
|
||||||
result = ve.getDisplayValue(v, row);
|
result = ve.getDisplayValue(v, row);
|
||||||
} catch (VascException e) {
|
} catch (VascException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Could not get selected name DisplayValue: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -528,8 +528,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
||||||
}
|
}
|
||||||
state.getMultiActionSelection().clear(); // after down deselect all options
|
state.getMultiActionSelection().clear(); // after down deselect all options
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
throw new RuntimeException("Could not do multirowaction",e);
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
vascEntry=null;
|
vascEntry=null;
|
||||||
}
|
}
|
||||||
|
@ -606,15 +605,7 @@ public class JSFVascEntrySupportBean implements Serializable {
|
||||||
|
|
||||||
// select record to edit
|
// select record to edit
|
||||||
Object rowObject = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
|
Object rowObject = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
|
||||||
//String idField = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry().getPrimaryKeyFieldId();
|
|
||||||
// VascEntryField field = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry().getVascEntryFieldById(idField);
|
|
||||||
// try {
|
|
||||||
// Object id = field.getVascEntryFieldValue().getValue(field, rowObject);
|
|
||||||
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent(),rowObject);
|
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent(),rowObject);
|
||||||
// } catch (VascException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
// e1.printStackTrace();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,14 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
|
||||||
|
|
||||||
// Frontend Stuff
|
// Frontend Stuff
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#getFrontendType()
|
||||||
|
*/
|
||||||
|
public String getFrontendType() {
|
||||||
|
return "jsf";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void addUiComponents() {
|
protected void addUiComponents() {
|
||||||
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
||||||
try {
|
try {
|
||||||
renderer.initEntry(entry);
|
renderer.initEntry(entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
throw new RuntimeException("Could not initEntry: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
supportBean = new JSFVascEntrySupportBean(entry);
|
supportBean = new JSFVascEntrySupportBean(entry);
|
||||||
// copy search string for preadded search string from application layer
|
// copy search string for preadded search string from application layer
|
||||||
|
@ -243,7 +243,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
||||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
|
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
|
||||||
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("Could not renderEdit: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,10 +324,11 @@ public class JSFVascUIComponent extends UIComponentBase {
|
||||||
throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController);
|
throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frontendData.setVascFrontend(null); // reset data obj. todo rm this.
|
||||||
frontendData.setVascController(vascController);
|
frontendData.setVascController(vascController);
|
||||||
entry.setVascFrontendData(frontendData);
|
entry.setVascFrontendData(frontendData);
|
||||||
try {
|
try {
|
||||||
frontendData.initFrontendListeners(entry);
|
frontendData.initFrontendListeners(entry,"jsf");
|
||||||
} catch (InstantiationException e1) {
|
} catch (InstantiationException e1) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -385,7 +386,7 @@ public class JSFVascUIComponent extends UIComponentBase {
|
||||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
|
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException("error: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,11 @@ public class JSFVascUIComponentRenderer extends Renderer {
|
||||||
|
|
||||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid);
|
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid);
|
||||||
VascEntry entry = comp.getVascEntry();
|
VascEntry entry = comp.getVascEntry();
|
||||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
if (entry==null) {
|
||||||
|
throw new NullPointerException("No parent vasc component found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||||
if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) {
|
if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) {
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class OldVascUIComponent extends UIComponentBase {
|
||||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), vascFrontendData.getExpressionString(), VascFrontendData.class);
|
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), vascFrontendData.getExpressionString(), VascFrontendData.class);
|
||||||
VascFrontendData frontendData = (VascFrontendData)ve2.getValue(FacesContext.getCurrentInstance().getELContext());
|
VascFrontendData frontendData = (VascFrontendData)ve2.getValue(FacesContext.getCurrentInstance().getELContext());
|
||||||
try {
|
try {
|
||||||
frontendData.initFrontendListeners(entry);
|
frontendData.initFrontendListeners(entry,"jsf");
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1597,6 +1597,13 @@ class JSFFrontendRenderer extends AbstractVascFrontend implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascFrontend#getFrontendType()
|
||||||
|
*/
|
||||||
|
public String getFrontendType() {
|
||||||
|
return "jsf";
|
||||||
|
}
|
||||||
|
|
||||||
// Frontend Stuff
|
// Frontend Stuff
|
||||||
|
|
||||||
protected void addUiComponents() {
|
protected void addUiComponents() {
|
||||||
|
|
Loading…
Reference in a new issue