2
0
Fork 0

Small refactor for comming converters

This commit is contained in:
Willem Cazander 2012-01-22 08:16:15 +01:00
parent 75b3d5e0a0
commit 1c308a684a
178 changed files with 5865 additions and 1531 deletions

View file

@ -3,7 +3,11 @@
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -20,10 +25,18 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View file

@ -1,6 +1,9 @@
#Mon Mar 21 21:23:08 CET 2011
#Sat Jan 14 05:41:29 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,168 @@
/*
* 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.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 {
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);
}
} 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);
// render
render.initEntry(entry);
render.renderView();
// get data
entry.getVascFrontendData().getVascFrontendActions().refreshData();
// view
frame.pack();
frame.setVisible(true);
return frame;
}
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;
}
static void printEntry(VascEntry e) throws Exception {
System.out.println("");
System.out.println("=== Printing entry ===");
System.out.println("");
for (Method m:e.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(e));
}
System.out.println("");
System.out.println("=== Fields ===");
for (VascEntryField vef:e.getVascEntryFields()) {
System.out.println("=== Field: "+vef.getId());
for (Method m:vef.getClass().getMethods()) {
if (m.getName().startsWith("get")==false) { //a bit dirty
continue;
}
if (m.getParameterTypes().length>0) {
continue;
}
System.out.println("prop: "+m.getName()+" -> "+m.invoke(vef));
}
}
}
}

View file

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<x4o:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.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"
xmlns:x4o="http://eld.x4o.org/eld/x4o-lang.eld"
>
<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>
<j:jdbcConnectionProvider
el.id="dbDatafeeds"
driverClassName="org.postgresql.Driver"
dbUrl="jdbc:postgresql://localhost/datafeeds_dev"
dbUser="test"
dbPassword="eephoh2O"
/>
<j:jdbcBackend
id="dbStreams"
jdbcConnectionProvider="${dbDatafeeds}"
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)"
/>
<v:entry id="streams" backendId="dbStreams">
<v:field id="id" readOnly="true"/>
<v:field id="name"/>
<v:field id="url"/>
<v:field id="importing" vascEntryFieldType="BooleanField"/>
<v:field id="last_parsed" vascEntryFieldType="DateField" />
<v:field id="last_checked" vascEntryFieldType="DateField"/>
<v:field id="parser_locale" list="false"/>
<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"
/>
<l:ldapBackend
id="ldapBackendSudoers"
ldapConnectionProvider="${ldapSudoers}"
baseDN="ou=sudoers,dc=example,dc=nl"
keyAttribute="cn"
ldapFilter="(&amp;(objectClass=sudoRole))"
/>
<v:entry id="sudoers" backendId="ldapBackendSudoers">
<v:field id="user" backendName="cn" readOnly="true"/>
<v:field id="description" rolesEdit="admin" rolesList="all"/>
<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"/>
<v:listeners hook="post_create">
<etc:loginToFtpServer/>
</v:listeners>
<v:link fieldName="user" viewController="ldapUsers" parameterName="user_cn"/>
<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"
/>
<l:ldapBackend
id="ldapBackendUsers"
ldapConnectionProvider="${ldapUsers}"
baseDN="ou=users,dc=dutchworks,dc=nl"
keyAttribute="uid"
ldapFilter="(&amp;(objectClass=posixAccount))"
/>
<v:entry id="users" backendId="ldapBackendUsers">
<v:field id="uid" />
<v:field id="uidNumber" vascEntryFieldType="IntegerField"/>
<v:field id="gidNumber" vascEntryFieldType="IntegerField"/>
<v:field id="loginShell" list="false"/>
<v:field id="homeDirectory" list="false"/>
<v:field id="cn" list="false"/>
<v:field id="givenName" />
<v:field id="sn" />
<v:field id="mailbox" list="false"/>
<v:field id="mail" vascEntryFieldType="EmailField"/>
<v:field id="mailActive" vascEntryFieldType="BooleanField"/>
<v:field id="alias" vascEntryFieldType="MultiTextField" list="false"/>
<v:field id="autoResponseActive" vascEntryFieldType="BooleanField" />
<v:field id="autoresponseMessage" vascEntryFieldType="TextAreaField" list="false"/>
<v:field id="sambaAcctFlags" list="false"/>
<v:field id="sambaPrimaryGroupSID" list="false"/>
<v:field id="sambaSID" list="false"/>
</v:entry>
<l:ldapConnectionProvider
el.id="ldapMachines"
ldapHost="localhost"
bindUser="uid=samba,ou=services,dc=example,dc=nl"
bindPass="superS"
/>
<l:ldapBackend
id="ldapBackendMachines"
ldapConnectionProvider="${ldapMachines}"
baseDN="ou=machines,dc=example,dc=nl"
keyAttribute="uid"
ldapFilter="(&amp;(objectClass=sambaSamAccount))"
/>
<v:entry id="machines" backendId="ldapBackendMachines">
<v:field id="uid" />
<v:field id="sambaAcctFlags"/>
<v:field id="sambaSID" />
<v:field id="uidNumber" />
</v:entry>
<!--
- View
- States
- Tables
- Columns
Master
- Details
-->
<!--
<x4o:bean el.id="dataSource" bean.class="com.id.."/>
<x4o:bean el.id="tableController" bean.class="com.id.."/>
<v:vascView name="test1">
<v:vascTableController>
</v:vascTableController>
<v:vascBackendController>
<v:vascJDBCQueryController>
<x4o:property name="list">select id,name,blog_status_id,description,slug from blog_post</x4o:property>
<x4o:property name="update">update (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=?</x4o:property>
<x4o:property name="create">instert into (id,name,blog_status_id,description,slug) values(?,?,?,?,?) from blog_post where id=?</x4o:property>
<x4o:property name="delete">delete from blog_post where id=?</x4o:property>
</v:vascJDBCQueryController>
</v:vascBackendController>
<v:vascField name="">
<v:vascFieldOptions/>
<v:vascFieldChoises/>
</v:vascField>
<v:vascField name="">
<v:vascUserRoles list="admin"/>
</v:vascField>
</v:vascView>
<x4o:template el.id="ldapServerTemplate">
<v:ldapConnection name="main">
<x4o:property name="connectionUrl" value="ldaps://localhost"/>
</v:ldapConnection>
</x4o:template>
<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="baseDn" value="ou=sudoers,dc=example,dc=nl"/>
</v:ldapConnection>
<x4o:template el.id="sudoTemplate">
<v:field name="user" backendName="cn" readOnly="true"/>
<v:field name="description" backendName="description"/>
<v:field name="sudoCommand" fieldEditor="listField"/>
<v:field name="sudoHost" fieldEditor="listField"/>
<v:field name="sudoUser" fieldEditor="listField"/>
</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="sambaGroupType" v.defaultValue="2"/>
</x4o:template>
<v:viewController name="ldapUsers" primaryKey="user">
<x4o:templateTag template="${posixUserSchema}"/>
<x4o:templateTag template="${sambaUserSchema}">
<v:field name="sambaGroupType" v.defaultValue="3"/>
</x4o:templateTag>
<v:field name="sambaGroupType" v.defaultValue="4"/>
</v:viewController>
<vasc:fieldType name="EmailField2">
<vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="timeout" default="200"/>
</vasc:fieldType>
<vasc:fieldType name="listField">
<vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="timeout" default="200"/>
</vasc:fieldType>
-->
</x4o:root>