2
Fork 0

wip made remote ejb working over http

This commit is contained in:
Willem Cazander 2012-11-21 20:45:08 +01:00
parent d4e537a2bf
commit 2a0d992642
393 changed files with 8916 additions and 3872 deletions

View file

@ -3,7 +3,7 @@
<parent>
<artifactId>vasc-demo</artifactId>
<groupId>net.forwardfire.vasc.demo</groupId>
<version>0.3.5-SNAPSHOT</version>
<version>0.4.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-demo-tech</artifactId>
@ -11,9 +11,8 @@
<name>vasc-demo-tech</name>
<description>vasc-demo-tech</description>
<modules>
<module>vasc-demo-tech-build</module>
<module>vasc-demo-tech-editor</module>
<module>vasc-demo-tech-web</module>
<module>vasc-demo-tech-core</module>
<module>vasc-demo-tech-client-swing</module>
<module>vasc-demo-tech-ejb3</module>
</modules>
</project>

View file

@ -1,48 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>vasc-demo-tech</artifactId>
<groupId>net.forwardfire.vasc.demo</groupId>
<version>0.3.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-demo-tech-build</artifactId>
<packaging>pom</packaging>
<name>vasc-demo-tech-build</name>
<description>vasc-demo-tech-build</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>ui-dist-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-web</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2011, Willem Cazander
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.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>vasc-demo-tech-${project.version}</baseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.parent.parent.parent.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>authors.txt</include>
<include>licence.txt</include>
<!-- <include>versions.txt</include> -->
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/scripts/</directory>
<outputDirectory>/</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/files/</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>readme.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/directory/</directory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>conf/logback-server-console.xml</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Default context for all applications. -->
<Context>
<!-- Link global resources in local java:comp/env namespace -->
<ResourceLink name="config/START_GUI" global="config/START_GUI" type="java.lang.Boolean"/>
<ResourceLink name="config/START_EDITOR" global="config/START_EDITOR" type="java.lang.Boolean"/>
<ResourceLink name="config/DEPLOY_DEBUG" global="config/DEPLOY_DEBUG" type="java.lang.Boolean"/>
<ResourceLink name="config/DEPLOY_PATH" global="config/DEPLOY_PATH" type="java.lang.String"/>
<ResourceLink name="jdbc/DemoManagerDataDS" global="jdbc/DemoManagerDataDS" type="javax.sql.DataSource"/>
<ResourceLink name="vasc/DemoVascController" global="vasc/DemoVascController" type="net.forwardfire.vasc.core.VascController" />
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Disable session persistence across restarts -->
<Manager pathname="" />
</Context>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/http-access.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/http-access-%d{yyyy-MM-dd}.log.zip</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>combined</pattern>
</encoder>
</appender>
<appender-ref ref="FILE" />
</configuration>

View file

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="90 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<jmxConfigurator/>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/vasc-demo-tech.log</file>
<encoder>
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
<!-- Limit some startup messages. -->
<logger level="WARN" name="org.apache.catalina.startup.Catalina"/>
<logger level="WARN" name="org.apache.catalina.startup.ContextConfig"/>
<logger level="ERROR" name="org.apache.catalina.startup.ClassLoaderFactory"/>
<logger level="WARN" name="org.apache.catalina.core.AprLifecycleListener"/>
<logger level="WARN" name="org.ajax4jsf.cache.LRUMapCacheFactory"/>
<logger level="WARN" name="javax.enterprise.resource.webcontainer.jsf.application"/>
<logger level="WARN" name="net.jawr.web.resource.bundle.factory.BundlesHandlerFactory"/>
</configuration>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="90 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<jmxConfigurator/>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/vasc-demo-tech.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/vasc-demo-tech-%d{yyyy-MM-dd}.log.zip</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
</root>
<!-- Limit some startup messages. -->
<logger level="WARN" name="org.apache.catalina.startup.Catalina"/>
<logger level="WARN" name="org.apache.catalina.startup.ContextConfig"/>
<logger level="ERROR" name="org.apache.catalina.startup.ClassLoaderFactory"/>
<logger level="WARN" name="org.apache.catalina.core.AprLifecycleListener"/>
<logger level="WARN" name="org.ajax4jsf.cache.LRUMapCacheFactory"/>
<logger level="WARN" name="javax.enterprise.resource.webcontainer.jsf.application"/>
<logger level="WARN" name="net.jawr.web.resource.bundle.factory.BundlesHandlerFactory"/>
</configuration>

View file

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8805" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<!-- Config Vasc Tech Demo -->
<Environment name="config/START_GUI" value="true" type="java.lang.Boolean"/>
<Environment name="config/START_EDITOR" value="true" type="java.lang.Boolean"/>
<Environment name="config/DEPLOY_DEBUG" value="true" type="java.lang.Boolean"/>
<Environment name="config/DEPLOY_PATH" value="/demo" type="java.lang.String"/>
<!-- Config Vasc Tech DataSource -->
<Resource name="jdbc/DemoManagerDataDS" auth="Container" type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="1" minIdle="1"
driverClassName="org.h2.Driver"
url="jdbc:h2:tcp://localhost:9092/vasc-demo"
/>
<!-- Config The Vasc Demo Controller -->
<Resource name="vasc/DemoVascController" auth="Container" type="net.forwardfire.vasc.core.VascController" singleton="true" scope="Shareable"
factory="net.forwardfire.vasc.impl.jndi.JndiVascControllerFactory"
vascControllerProvider="net.forwardfire.vasc.demo.tech.core.VascTechDemoControllerConfig"
removeLocal="false"
/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8899" protocol="HTTP/1.1" connectionTimeout="5000" redirectPort="9988" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/DemoManagerDataDS"
userTable="vasc_user"
userRoleTable="vasc_user_role"
userNameCol="username"
userCredCol="password"
roleNameCol="role"
digestEncoding="UTF-8"
/>
<!--
<Realm className="net.forwardfire.vasc.demo.tech.core.service.tomcat.MongoRealm"
hostname="localhost" port="27017" database="testdb" authUser="" authPass=""
userCollection="site_user"
userField="username"
userPassField="password"
roleCollection="site_user_role"
roleField="role"
roleUserField="site_user_id"
roleUserIdRef="true"
digestEncoding="UTF-8"
/>
<Realm className="org.apache.catalina.realm.JNDIRealm"
connectionURL="ldap://localhost:389"
userBase="ou=people,dc=mycompany,dc=com"
userSearch="(mail={0})"
userRoleName="memberOf"
roleBase="ou=groups,dc=mycompany,dc=com"
roleName="cn"
roleSearch="(uniqueMember={0})"
/>
-->
</Realm>
<Host name="localhost" unpackWARs="true" autoDeploy="true"
appBase="workdir/webapps" workDir="workdir/work"
>
<Valve className="ch.qos.logback.access.tomcat.LogbackValve"
quiet="true" filename="conf/logback-access.xml"
/>
<Valve className="org.apache.catalina.valves.CrawlerSessionManagerValve"
crawlerUserAgents=".*[bB]ot.*|.*ahoo.*|.*oogle.*"
sessionInactiveInterval="60"
/>
<Valve className="net.forwardfire.vasc.demo.tech.core.service.tomcat.AuthSessionTimeoutValve"
logInfo="true" minTimeout="30" maxTimeout="3600" authTimeout="1200"
/>
</Host>
</Engine>
</Service>
</Server>

View file

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<v:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
xmlns:mm="http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld"
>
<mm:csvDataContext
el.id="metaPeopleDS"
file="meta-people.csv"
/>
<mm:metaModelBackend
id="metaPeopleBackend"
dataContextProvider="${metaPeopleDS}"
table="meta_people"
tableId="id"
/>
<v:entry id="metaPeople" backendId="metaPeopleBackend">
<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:field id="function" vascEntryFieldType="ListField">
<v:vascSelectItemModelString data="manager,devver,sales"/>
</v:field>
</v:entry>
<mm:csvDataContext
el.id="metaProjectDS"
file="meta-project.csv"
/>
<mm:metaModelBackend
id="metaProjectBackend"
dataContextProvider="${metaProjectDS}"
table="meta_project"
tableId="id"
/>
<v:entry id="metaProject" backendId="metaProjectBackend">
<v:field id="id" list="false"/>
<v:field id="name"/>
<v:field id="description" vascEntryFieldType="TextAreaField"/>
</v:entry>
</v:root>

View file

@ -1,10 +0,0 @@
id,name,gender,age,function
1,"mike",male,18,manager
2,"michael",male,19,manager-co
3,"peter",male,18,devop
4,"bob",male,17,devver
5,"barbara, barb",female,18,devver
6,"charlotte",female,18,devver
7,"hillary",female,20,tester
8,"vera",female,17,tester
9,"carrie",female,17,sales
1 id name gender age function
2 1 mike male 18 manager
3 2 michael male 19 manager-co
4 3 peter male 18 devop
5 4 bob male 17 devver
6 5 barbara, barb female 18 devver
7 6 charlotte female 18 devver
8 7 hillary female 20 tester
9 8 vera female 17 tester
10 9 carrie female 17 sales

View file

@ -1,4 +0,0 @@
id,name,description
1,"fix-website","Move all pages to plain text so it is printable when there is no power."
2,"refactor-HJY","Make function HJY abstract and use generic logic to improve total cpu lag on system"
3,"custum-graph","Big custumer foobar want really this killer graph woobly line point stuff."
1 id name description
2 1 fix-website Move all pages to plain text so it is printable when there is no power.
3 2 refactor-HJY Make function HJY abstract and use generic logic to improve total cpu lag on system
4 3 custum-graph Big custumer foobar want really this killer graph woobly line point stuff.

View file

@ -1,13 +0,0 @@
dn: cn=Mirjan Broek,os=Amsterdam,ou=user,o=forwardfire,c=net
objectClass: inetOrgPerson
cn: Mirjan Broek
description: Prime Contractors
mail: mirjan.broek@demo.vasc.forwardfire.net
postalAddress: 233 Mobbs Circuit$Vermont VIC
postalCode: 3133
sn: Broek
telephoneNumber: 622 7619
title: Secretary

View file

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<v:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
xmlns:l="http://vasc.forwardfire.net/eld/vasc-backend-ldap.eld"
>
<l:ldapConnectionProvider
el.id="ldapSudoers"
ldapHost="localhost"
bindUser="uid=admin-sudo,ou=services,dc=example,dc=nl"
bindPass="test"
/>
<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=example,dc=nl"
bindPass="test"
/>
<l:ldapBackend
id="ldapBackendUsers"
ldapConnectionProvider="${ldapUsers}"
baseDN="ou=users,dc=example,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="test"
/>
<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>
</v:root>

View file

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<v:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
xmlns:mm="http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld"
xmlns:j="http://vasc.forwardfire.net/eld/vasc-backend-jdbc.eld"
>
<j:jdbcConnectionProvider
el.id="dbRssFeeds"
driverClassName="org.postgresql.Driver"
dbUrl="jdbc:postgresql://localhost/vasc_testpg"
dbUser="test"
dbPassword="test"
/>
<j:jdbcBackend
id="rssChannelDB"
jdbcConnectionProvider="${dbRssFeeds}"
idColumnName="id"
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="rssChannel" backendId="rssChannelDB">
<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>
</v:root>

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<v:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
xmlns:mm="http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld"
xmlns:td="http://demo.vasc.forwardfire.net/eld/vasc-tech-demo.eld"
>
<!-- Load jndi factories into tomcat. -->
<td:tomcatResource name="mmdc/server/conf/server.xml" auth="Container" type="org.eobjects.metamodel.DataContext"
factory="net.forwardfire.vasc.backend.metamodel.jndi.JndiDataContextObjectFactory"
backendType="xmlDomFile" backendFile="conf/server.xml"
/>
<td:tomcatResource name="mmdc/server/conf/logback-server.xml" auth="Container" type="org.eobjects.metamodel.DataContext"
factory="net.forwardfire.vasc.backend.metamodel.jndi.JndiDataContextObjectFactory"
backendType="xmlDomFile" backendFile="conf/logback-server.xml"
/>
<td:tomcatResource name="mmdc/server/conf/logback-access.xml" auth="Container" type="org.eobjects.metamodel.DataContext"
factory="net.forwardfire.vasc.backend.metamodel.jndi.JndiDataContextObjectFactory"
backendType="xmlDomFile" backendFile="conf/logback-access.xml"
/>
<td:tomcatResource name="mmdc/server/conf/context.xml" auth="Container" type="org.eobjects.metamodel.DataContext"
factory="net.forwardfire.vasc.backend.metamodel.jndi.JndiDataContextObjectFactory"
backendType="xmlDomFile" backendFile="conf/context.xml"
/>
<td:tomcatResource name="mmdc/server/conf/web.xml" auth="Container" type="org.eobjects.metamodel.DataContext"
factory="net.forwardfire.vasc.backend.metamodel.jndi.JndiDataContextObjectFactory"
backendType="xmlDomFile" backendFile="conf/web.xml"
/>
<!-- Get our references to the backends. -->
<mm:jndiDataContext el.id="mmdc1" jndiName="java:mmdc/server/conf/server.xml"/>
<mm:jndiDataContext el.id="mmdc2" jndiName="java:mmdc/server/conf/logback-server.xml"/>
<mm:jndiDataContext el.id="mmdc3" jndiName="java:mmdc/server/conf/logback-access.xml"/>
<mm:jndiDataContext el.id="mmdc4" jndiName="java:mmdc/server/conf/context.xml"/>
<mm:jndiDataContext el.id="mmdc5" jndiName="java:mmdc/server/conf/web.xml"/>
<!-- Auto config schema from MetaModel backends. -->
<mm:schemaAutoEntry dataContextProvider="${mmdc1}" entryPrefix="AdminConfServer" />
<mm:schemaAutoEntry dataContextProvider="${mmdc2}" entryPrefix="AdminConfLogServer" />
<mm:schemaAutoEntry dataContextProvider="${mmdc3}" entryPrefix="AdminConfLogAccess" />
<mm:schemaAutoEntry dataContextProvider="${mmdc4}" entryPrefix="AdminConfConfig" />
<mm:schemaAutoEntry dataContextProvider="${mmdc5}" entryPrefix="AdminConfWeb" />
</v:root>

View file

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<v:root xmlns:v="http://vasc.forwardfire.net/eld/vasc-lang.eld"
xmlns:mm="http://vasc.forwardfire.net/eld/vasc-backend-metamodel.eld"
xmlns:td="http://demo.vasc.forwardfire.net/eld/vasc-tech-demo.eld"
>
<mm:jndiDataSourceDataContext el.id="DemoManagerDataDC" jndiName="java:jdbc/DemoManagerDataDS" />
<mm:metaModelBackend id="AdminVascUserBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_USER" tableId="ID" />
<v:entry id="AdminVascUser" backendId="AdminVascUserBackend" displayNameFieldId="username">
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="username" backendName="USERNAME"/>
<v:field id="password" backendName="PASSWORD"/>
<v:field id="description" backendName="DESCRIPTION" vascEntryFieldType="TextAreaField"/>
</v:entry>
<mm:metaModelBackend id="AdminVascUserRoleBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_USER_ROLE" tableId="ID" />
<v:entry id="AdminVascUserRole" backendId="AdminVascUserRoleBackend" >
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="username" backendName="USERNAME" vascEntryFieldType="ListField">
<v:vascSelectItemModel entryId="AdminVascUser" keyFieldId="username"/>
</v:field>
<v:field id="role" backendNAME="ROLE"/>
</v:entry>
<mm:metaModelBackend id="AdminVascUserChangeFieldBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_USER_CHANGE_FIELD" tableId="ID" />
<v:entry id="AdminVascUserChangeField" backendId="AdminVascUserChangeFieldBackend" adminEditReadOnly="true">
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="field" backendName="FIELD"/>
<v:field id="name" backendName="NAME"/>
<v:field id="active" backendNAME="ACTIVE" vascEntryFieldType="BooleanField"/>
</v:entry>
<mm:metaModelBackend id="AdminVascUserChangeLogBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_USER_CHANGE_LOG" tableId="ID" />
<v:entry id="AdminVascUserChangeLog" backendId="AdminVascUserChangeLogBackend" adminEditReadOnly="true">
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="user_id" backendName="USER_ID" vascEntryFieldType="ListField">
<v:vascSelectItemModel entryId="AdminVascUser" keyFieldId="id"/>
</v:field>
<v:field id="change_field_id" backendName="CHANGE_FIELD_ID" vascEntryFieldType="ListField">
<v:vascSelectItemModel entryId="AdminVascUser" keyFieldId="id"/>
</v:field>
<v:field id="value_old" backendNAME="VALUE_OLD"/>
<v:field id="value_new" backendNAME="VALUE_NEW"/>
</v:entry>
<mm:metaModelBackend id="AdminVascMenuBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_MENU" tableId="ID" />
<v:entry id="AdminVascMenu" backendId="AdminVascMenuBackend">
<v:listOption id="menu_type" backendName="MENU_TYPE" vascEntryFieldType="ListField" optional="true">
<v:vascSelectItemModelString nullLabel="All" data="BAR_LEFT,BAR_RIGHT,BAR_BOTTOM,PAGE_INDEX,PAGE_USER_LEFT,PAGE_USER_RIGHT,PAGE_ADMIN"/>
</v:listOption>
<v:listOption id="active" backendName="ACTIVE" vascEntryFieldType="ListField" optional="true" defaultValue="FALSE">
<v:vascSelectItemModelString nullLabel="All" data="TRUE,FALSE"/>
</v:listOption>
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="href" backendNAME="HREF"/>
<v:field id="title" backendNAME="TITLE"/>
<v:field id="target" backendNAME="TARGET"/>
<v:field id="active" backendNAME="ACTIVE" vascEntryFieldType="BooleanField"/>
<v:field id="roles" backendNAME="ROLES"/>
<v:field id="menu_order" backendNAME="MENU_ORDER" vascEntryFieldType="IntegerField"/>
<v:field id="menu_type" backendNAME="MENU_TYPE" vascEntryFieldType="ListField">
<v:vascSelectItemModelString data="BAR_LEFT,BAR_RIGHT,BAR_BOTTOM,MENU0,MENU1,MENU2,PAGE_INDEX,PAGE_USER_LEFT,PAGE_USER_RIGHT,PAGE_ADMIN"/>
</v:field>
</v:entry>
<mm:metaModelBackend id="AdminVascPageBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_PAGE" tableId="ID" />
<v:entry id="AdminVascPage" backendId="AdminVascPageBackend">
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="slug" backendNAME="SLUG"/>
<v:field id="title" backendNAME="TITLE"/>
<v:field id="i18n_key" backendNAME="I18N_KEY" vascEntryFieldType="BooleanField"/>
<!-- <v:field id="active" backendNAME="ACTIVE" vascEntryFieldType="BooleanField"/> -->
<v:field id="sitemap" backendNAME="SITEMAP" vascEntryFieldType="BooleanField"/>
</v:entry>
<mm:metaModelBackend id="AdminVascPagePartBackend" dataContextProvider="${DemoManagerDataDC}" table="VASC_PAGE_PART" tableId="ID" />
<v:entry id="AdminVascPagePart" backendId="AdminVascPagePartBackend">
<v:field id="id" backendName="ID" list="false" editReadOnly="true" create="false"/>
<v:field id="page_id" backendNAME="PAGE_ID" vascEntryFieldType="ListField">
<v:vascSelectItemModel entryId="AdminVascPage" keyFieldId="id"/>
</v:field>
<v:field id="title" backendNAME="TITLE"/>
<v:field id="text" backendNAME="TEXT"/>
<v:field id="i18n_key" backendNAME="I18N_KEY" vascEntryFieldType="BooleanField"/>
<v:field id="active" backendNAME="ACTIVE" vascEntryFieldType="BooleanField"/>
<v:field id="sitemap" backendNAME="SITEMAP" vascEntryFieldType="BooleanField"/>
<v:field id="part_order" backendNAME="PART_ORDER" vascEntryFieldType="IntegerField"/>
<v:field id="part_type" backendNAME="PART_TYPE" vascEntryFieldType="ListField">
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.demo.tech.web.menu.model.VascMenuType"/>
</v:field>
</v:entry>
</v:root>

View file

@ -1,7 +0,0 @@
== Deploy directory ==
-- All *.xml files are deployed on startup.
-- Directory get scanned every 3 secs.
-- Files get redeployed when md5sum changes.
-- No undeploy and no removal of vasc entries only ADD/replace.

View file

@ -1 +0,0 @@
1234-56-78 90:12:34,123 INFO [install] Thank you for trying this vasc demo tech.

View file

@ -1 +0,0 @@
All *.xml in this dir are automaticly started.

View file

@ -1,20 +0,0 @@
Readme for Vasc Tech Demo application.
To start:
execute: run.sh or run.bat
Custom i18n keys web:
Application.web.meta.robots = index, follow
Application.web.meta.description = Vasc Tech Demo Web Frontends
Application.web.meta.keywords = demo,forwardfire,x4o,vasc,java
Application.web.header.logo.alt = Vasc Tech Demo Logo
Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Richfaces.
Application.web.footer.left = Copyright &copy; 2012
Application.web.footer.right = Version 0.4.x<i>(beta)</i>

View file

@ -1,38 +0,0 @@
::
:: Copyright (c) 2011, Willem Cazander
:: 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.
::
@echo off
setlocal enableextensions
:: Run in app dir
cd /d %~dp0
:: Config variables
set JAVA_OPTS=-Xms64m -Xmx256m
set MAIN_CLASS=net.forwardfire.vasc.demo.tech.core.VascTechDemo
set CP=lib\*
:: Launch application
java %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS%
endlocal
:: EOF

View file

@ -1,38 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2011, Willem Cazander
# 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.
#
# Run in app dir
cd `dirname $0`;
# Config variables
JAVA="java";
JAVA_OPTS="-Xms64m -Xmx256m";
MAIN_CLASS="net.forwardfire.vasc.demo.tech.core.VascTechDemo";
CP=`echo lib/*.jar | sed 's/ /:/g'`;
# Launch application
$JAVA $JAVA_OPTS -cp $CP $MAIN_CLASS;
# EOF

View file

@ -1,25 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vasc-demo-tech-core</name>
<name>vasc-demo-tech-client-swing</name>
<comment></comment>
<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>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -27,10 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>vasc-demo-tech</artifactId>
<groupId>net.forwardfire.vasc.demo</groupId>
<version>0.4.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-demo-tech-client-swing</artifactId>
<dependencies>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core</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-frontend-swing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core-ejb3-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-ejb3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-client</artifactId>
<version>4.5.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jdesktop.bsaf</groupId>
<artifactId>bsaf</artifactId>
<version>${bsaf.version}</version>
<exclusions>
<exclusion>
<artifactId>jnlp</artifactId>
<groupId>javax.jnlp</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,556 @@
/*
* 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.client.swing;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
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 net.forwardfire.vasc.annotations.VascModelReference;
import net.forwardfire.vasc.backend.VascBackend;
import net.forwardfire.vasc.backend.VascBackendController;
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.proxy.VascBackendProxyEventExecutor;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascControllerLocal;
import net.forwardfire.vasc.core.VascControllerProvider;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryFieldLocal;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.ejb3.VascServiceManager;
import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration;
import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed;
import net.forwardfire.vasc.impl.DefaultVascController;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.entry.SetParameterBackendListener;
/**
* JMainPanel is the main panel/window of this demo.
*
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class JMainPanel extends JPanel {
private static final long serialVersionUID = 5834715323973411147L;
//private VascControllerService vascManager = null;
private VascController vc = null;
private VascMenuController vmc = null;
private VascServiceManager vsm = null;
private SwingPanelIntegration spi = null;
private JTabbedPane tabPane = null;
private JTree vascTree = null;
private JSplitPane bottomSplitPane = null;
private JSplitPane treeSplitPane = null;
public JMainPanel(VascServiceManager vsm,VascMenuController vmc) {
//this.vascManager=VascTechDemoStartup.getInstance().getVascControllerService();
this.vsm = vsm;
this.vmc = vmc;
setLayout(new BorderLayout());
add(createBottomSplit(), BorderLayout.CENTER);
vc = createVascController(vsm);
//vascManager.addVascServiceListener(this);
rebuildTree();
}
class RemoteVascBackend implements VascBackend {
private String backendId = null;
private VascServiceManager vascManager = null;
public RemoteVascBackend(String backendId,VascServiceManager vascManager) {
this.backendId=backendId;
this.vascManager=vascManager;
}
public void startBackend() {
}
public void stopBackend() {
}
public void delete(Object object) throws VascException {
Object[] args = new Object[1];
args[0]=object;
vascManager.invokeBackendMethod(backendId, "delete", args);
}
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
Object[] args = new Object[2];
args[0]=state;
args[1]=primaryId;
Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args);
return (Long)result;
}
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
Object[] args = new Object[2];
args[0]=state;
args[1]=primaryId;
Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args);
return (Long)result;
}
@SuppressWarnings("unchecked")
public List<Object> execute(VascBackendState state) throws VascException {
Object[] args = new Object[1];
args[0]=state;
Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
return (List<Object>)result;
}
public long fetchTotalExecuteSize(VascBackendState state) {
Object[] args = new Object[1];
args[0]=state;
Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args);
return (Long)result;
}
public String getId() {
return backendId;
}
public boolean isPageable() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args);
return (Boolean)result;
}
public boolean isRecordMoveable() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args);
return (Boolean)result;
}
public boolean isSearchable() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args);
return (Boolean)result;
}
public boolean isSortable() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args);
return (Boolean)result;
}
public Object merge(Object object) throws VascException {
Object[] args = new Object[1];
args[0]=object;
Object result = vascManager.invokeBackendMethod(backendId, "merge", args);
return result;
}
public void persist(Object object) throws VascException {
Object[] args = new Object[1];
args[0]=object;
vascManager.invokeBackendMethod(backendId, "delete", args);
}
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
try {
field = ((VascEntryFieldLocal)field).clone(); // RM...
ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed
ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray);
objOutstream.writeObject(field);
objOutstream.close();
int objectSize = dataArray.size();
System.out.println("Writing obj to field: "+objectSize);
} catch (Exception e) {
throw new RuntimeException(e);
}
Object[] args = new Object[1];
args[0]=field;
Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args);
return (VascEntryFieldValue)result;
}
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
VascEntryLocal clone = null;
try {
clone = ((VascEntryLocal)vascEntry).clone();
clone.setVascFrontendController(null);
clone.setVascEntryFieldEventChannel(null);
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed
ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray);
objOutstream.writeObject(clone);
objOutstream.close();
//int objectSize = dataArray.size();
//System.out.println("Writing obj to entry: "+objectSize);
} catch (IOException e) {
throw new RuntimeException(e);
}
Object[] args = new Object[1];
args[0]=clone;
Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args);
return (VascEntryRecordCreator)result;
}
public void setId(String id) {
// we cant change id
}
public Map<String, Object> executePageSummary() {
return null;
}
public Map<String, Object> executeTotalSummary() {
return null;
}
public boolean isPageSummary() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args);
return (Boolean)result;
}
public boolean isTotalSummary() {
Object[] args = new Object[0];
Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args);
return (Boolean)result;
}
public boolean isReadOnly() {
return false;
}
}
/**
* @return the vascController
*/
public VascController createVascController(VascServiceManager vsm) {
try {
// VascUserInfo vui = getVascUserInfo();
// get local jvm plugging controller
VascController c = DefaultVascFactory.getDefaultVascController();
/*
DefaultVascEntryController con = new DefaultVascEntryController() {
public VascEntry getVascEntryById(String id) {
VascEntry ve = super.getVascEntryById(id);
// add global listener to make sure we have all LAZY properties of a bean before we goto edit mode.
ve.addVascEntryEventListener(VascEventType.DATA_SELECT, new RefreshObjectForLazyPropertiesListener());
return ve;
}
};
((DefaultVascController)c).setVascEntryController(con);
*/
VascServiceManager vascManager = vsm;
List<String> entryIds = vascManager.getVascEntryIds();
VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController();
VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController();
for (String id:entryIds) {
VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id);
String backendId = ve.getBackendId();
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);
VascBackendProxyEventExecutor localUserProxy = new VascBackendProxyEventExecutor();
localUserProxy.addVascEntryBackendEventListener(listener);
vb = localUserProxy;
}
*/
localBackendController.addVascBackend(vb);
localEntryController.addVascEntry(ve);
c.getVascEntryConfigController().configVascEntry(c, ve);
}
return c;
} catch (Exception e) {
throw new RuntimeException("Could not create remote based vasc controller; "+e.getMessage(),e);
}
}
private JSplitPane createBottomSplit() {
JSplitPane sp0 = createTreeSplit();
JPanel sp1 = new JPanel();//JConsolePanel();
bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,sp0,sp1);
bottomSplitPane.setOneTouchExpandable(true);
bottomSplitPane.setResizeWeight(0.2);
bottomSplitPane.setDividerLocation(700);
sp0.setMinimumSize(new Dimension(400, 400));
sp1.setMinimumSize(new Dimension(400, 150));
return bottomSplitPane;
}
private JSplitPane createTreeSplit() {
JScrollPane sp0 = createTreePane();
JScrollPane sp1 = createContentPane();
treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp0,sp1);
treeSplitPane.setOneTouchExpandable(true);
treeSplitPane.setResizeWeight(0.7);
treeSplitPane.setDividerLocation(200);
sp0.setMinimumSize(new Dimension(200, 400));
sp1.setMinimumSize(new Dimension(400, 400));
return treeSplitPane;
}
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);
}
}
public void openVascEntry(String vascId) throws VascException {
VascEntryLocal ee = (VascEntryLocal)vsm.getVascEntry(vascId);
vc.getVascEntryConfigController().configVascFrontendController(vc, ee);
spi.createNewVascView(ee);
}
private JScrollPane createTreePane() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ROOT,"Menu"));
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 && vsm!=null) {
if (vascNode.type == VascTreeNodeType.ENTRY) {
openVascEntry(vascNode.id);
}
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
});
JPanel treePanel = new JPanel();
treePanel.setLayout(new GridLayout(1,0));
JScrollPane p = createJScrollPane(treePanel);
p.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
p.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
treePanel.add(vascTree);
rebuildTree();
return p;
}
private JScrollPane createContentPane() {
JPanel contentPane = new JPanel();
contentPane.setLayout(new GridLayout(1,0));
JScrollPane p = createJScrollPane(contentPane);
tabPane = new JTabbedPane();
spi = new SwingPanelTabbed(tabPane);
contentPane.add(tabPane);
return p;
}
private JScrollPane createJScrollPane(JPanel innerPanel) {
JScrollPane scrollPane = new JScrollPane(innerPanel);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.getVerticalScrollBar().setUnitIncrement(10);
scrollPane.getHorizontalScrollBar().setUnitIncrement(10);
//innerPanel.setParentScrollPane(scrollPane);
return scrollPane;
}
class VascTreeNode implements Serializable {
private static final long serialVersionUID = -1177727401194030822L;
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 {
ROOT,
GROUP,
ENTRY
}
public void rebuildTree() {
if (vsm==null) {
return;
}
DefaultMutableTreeNode root = (DefaultMutableTreeNode)vascTree.getModel().getRoot();
root.removeAllChildren();
List<VascMenuGroup> groups = vmc.getFilteredMenuGroup();
for (VascMenuGroup group:groups) {
DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.GROUP,group.getTitle()));
for (VascMenu vm:group.getMenus()) {
DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,vm.getVascEntryId()));
groupNode.add(entryNode);
}
root.add(groupNode);
}
SwingUtilities.updateComponentTreeUI(vascTree);
/*
// todo move
Map<String,String> keys = new HashMap<String,String>(300);
VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"));
for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) {
VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId);
keys.putAll(checker.generateMissingKeys(ve));
}
if (keys.isEmpty()==false) {
Properties p = new Properties();
File dataDir = new File("data");
if (dataDir.exists()==false) {
dataDir.mkdirs();
}
File resourceFile = new File("data/vasc-bundle.properties");
if (resourceFile.exists()) {
readPropertiesFile(p,resourceFile);
}
for (String key:keys.keySet()) {
if (key==null) {
continue;
}
if (keys.get(key)==null) {
continue;
}
p.put(key, keys.get(key));
}
writePropertiesFile(p,resourceFile);
ResourceBundle.clearCache();
}
*/
}
public JTabbedPane getTabPane() {
return tabPane;
}
public void changeEvent() {
rebuildTree();
}
}

View file

@ -20,11 +20,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.core.ui;
package net.forwardfire.vasc.demo.client.swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
@ -34,10 +35,11 @@ import javax.swing.JTabbedPane;
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaCsv;
import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaJdbc;
import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaMongodb;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
/**
* JMainPanelMenuBar Adds all menu bar items.
@ -45,21 +47,109 @@ import net.forwardfire.vasc.demo.tech.core.ui.actions.JDialogMetaMongodb;
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class JMainPanelMenuBar extends JMenuBar {
public class JMainPanelMenuBar extends JMenuBar implements ActionListener {
private static final long serialVersionUID = -2828428804621352725L;
JMenu fileMenu = new JMenu("File");
JMenu vascMenu = new JMenu("Vasc");
JMenu tabMenu = new JMenu("Tabs");
private VascMenuController vmc = null;
private JMainPanel mainPanel = null;
private List<JMenu> vascMenus = null;
private JMenu clientFileMenu = null;
private JMenu clientTabMenu = null;
public JMainPanelMenuBar() {
createMenuItems();
add(fileMenu);
add(vascMenu);
add(tabMenu);
public JMainPanelMenuBar(VascMenuController vmc,JMainPanel mainPanel) {
this.vmc=vmc;
this.mainPanel=mainPanel;
clientFileMenu = new JMenu("File");
add(clientFileMenu);
JMenuItem logoutItem = new JMenuItem("Logout");
logoutItem.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();
//VascTechDemoStartup.getInstance().getVascControllerService().openFile(file);
}
*/
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
clientFileMenu.add(logoutItem);
clientFileMenu.addSeparator();
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VascDemoSwingClient.getInstance().exit();
}
});
clientFileMenu.add(exitItem);
List<VascMenuGroup> groups = vmc.getFilteredMenuGroup();
for (VascMenuGroup group:groups) {
JMenu menu = new JMenu(group.getTitle());
for (VascMenu vm:group.getMenus()) {
JMenuItem item = new JMenuItem(vm.getTitle());
item.putClientProperty("vascEntryId", vm.getVascEntryId());
item.addActionListener(this);
menu.add(item);
}
add(menu);
}
clientTabMenu = new JMenu("Tabs");
add(clientTabMenu);
JMenuItem item = new JMenuItem("Close tab");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTabbedPane tabPane = getTabPane();
if (tabPane.getSelectedIndex()>=0) {
tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend
}
}
});
clientTabMenu.add(item);
JMenuItem itemAll = new JMenuItem("Close All tabs");
itemAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTabbedPane tabPane = getTabPane();
for (int i=tabPane.getTabCount();i>0;i--) {
tabPane.removeTabAt(i-1); // todo release vasc frontend
}
}
});
clientTabMenu.add(itemAll);
}
public JTabbedPane getTabPane() {
return mainPanel.getTabPane();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JMenuItem) {
JMenuItem item = (JMenuItem)e.getSource();
String vascId = (String)item.getClientProperty("vascEntryId");
try {
mainPanel.openVascEntry(vascId);
} catch (VascException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
/*
private void createMenuItems() {
JMenuItem openXmlItem = new JMenuItem("Import Xml");
openXmlItem.addActionListener(new ActionListener() {
@ -70,7 +160,7 @@ public class JMainPanelMenuBar extends JMenuBar {
int returnVal = fc.showOpenDialog((JMenuItem)e.getSource());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
VascTechDemo.getInstance().getVascControllerService().openFile(file);
//VascTechDemoStartup.getInstance().getVascControllerService().openFile(file);
}
} catch (Exception e1) {
e1.printStackTrace();
@ -85,7 +175,7 @@ public class JMainPanelMenuBar extends JMenuBar {
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JApplication.getInstance().exit();
//JApplication.getInstance().exit();
}
});
fileMenu.add(exitItem);
@ -103,33 +193,7 @@ public class JMainPanelMenuBar extends JMenuBar {
connectLdapItem.setEnabled(false);
vascMenu.add(connectLdapItem);
vascMenu.addSeparator();
JMenuItem connectMetaCsvItem = new JMenuItem("Add meta csv");
connectMetaCsvItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialogMetaCsv d = new JDialogMetaCsv(JApplication.getInstance().getMainFrame());
d.setVisible(true);
}
});
vascMenu.add(connectMetaCsvItem);
JMenuItem connectMetaXmlItem = new JMenuItem("Add meta xml");
connectMetaXmlItem.setEnabled(false);
vascMenu.add(connectMetaXmlItem);
JMenuItem connectMetaMongoItem = new JMenuItem("Add meta mongo");
connectMetaMongoItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialogMetaMongodb d = new JDialogMetaMongodb(JApplication.getInstance().getMainFrame());
d.setVisible(true);
}
});
vascMenu.add(connectMetaMongoItem);
JMenuItem connectMetaJdbcItem = new JMenuItem("Add meta jdbc");
connectMetaJdbcItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialogMetaJdbc d = new JDialogMetaJdbc(JApplication.getInstance().getMainFrame());
d.setVisible(true);
}
});
vascMenu.add(connectMetaJdbcItem);
vascMenu.addSeparator();
JMenuItem removeEntryItem = new JMenuItem("Remove entry");
@ -140,49 +204,10 @@ public class JMainPanelMenuBar extends JMenuBar {
});
vascMenu.add(removeEntryItem);
JMenuItem removeAllItem = new JMenuItem("Remove all");
removeAllItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VascBackendControllerLocal backends = (VascBackendControllerLocal)VascTechDemo.getInstance().getVascControllerService().getVascController().getVascBackendController();
VascEntryControllerLocal entries = (VascEntryControllerLocal)VascTechDemo.getInstance().getVascControllerService().getVascController().getVascEntryController();
for (String entryId:entries.getVascEntryIds()) {
if (entryId.startsWith("Vasc")) {
continue;
}
entries.removeVascEntry(entryId);
}
for (String backendId:backends.getVascBackendIds()) {
if (backendId.startsWith("Vasc")) {
continue;
}
backends.removeVascBackendById(backendId);
}
VascTechDemo.getInstance().getVascControllerService().fireChangeEvent();
}
});
vascMenu.add(removeAllItem);
JMenuItem item = new JMenuItem("Close tab");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTabbedPane tabPane = VascTechDemo.getInstance().getSwingGuiService().getTabPane();
if (tabPane.getSelectedIndex()>=0) {
tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend
}
}
});
tabMenu.add(item);
JMenuItem itemAll = new JMenuItem("Close All tabs");
itemAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTabbedPane tabPane = VascTechDemo.getInstance().getSwingGuiService().getTabPane();
for (int i=tabPane.getTabCount();i>0;i--) {
tabPane.removeTabAt(i-1); // todo release vasc frontend
}
}
});
tabMenu.add(itemAll);
}
*/
}

View file

@ -0,0 +1,361 @@
package net.forwardfire.vasc.demo.client.swing;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import javax.naming.CommunicationException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingException;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.swing.JOptionPane;
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
import net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserController;
import net.forwardfire.vasc.ejb3.VascServiceManager;
import org.jdesktop.application.Application;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;
public class VascDemoSwingClient extends SingleFrameApplication {
private static VascDemoSwingClient instance = null;
static protected Context context = null;
static protected LoginContext loginContext = null;
private Logger logger = null;
static public void main(String[] args) {
/*
instance = new VascDemoSwingClient();
instance.initialize(args);
instance.startup();
*/
Application.launch(VascDemoSwingClient.class, new String[] {});
}
@Override
protected void startup() {
logger = Logger.getLogger(VascDemoSwingClient.class.getName());
createContext();
try {
setJaasConfig();
} catch (IOException e) {
e.printStackTrace();
}
doLogin();
JdniTreePrinter printer = new JdniTreePrinter(false);
StringBuffer buf = new StringBuffer();
printer.printJNDITree(context, "", buf);
System.out.println(buf);
VascServiceManager vc = null;
LoginUserController luc = null;
VascMenuController vmc = null;
try {
vc = (VascServiceManager)context.lookup("vascServiceManagerRemote");
System.out.println("ob: "+vc);
luc = (LoginUserController)context.lookup("loginUserControllerRemote");
System.out.println("fll: "+luc.doClientLogin());
vmc = (VascMenuController)context.lookup("vascMenuControllerRemote");
} catch (Exception e) {
e.printStackTrace();
}
JMainPanel mainPanel = new JMainPanel(vc,vmc);
SingleFrameApplication a = (VascDemoSwingClient)getInstance(); // BIG NOTE because of 'launch' for auto conf swing.
FrameView mainView = a.getMainView();
mainView.setComponent(mainPanel);
mainView.setMenuBar(new JMainPanelMenuBar(vmc,mainPanel));
mainView.getFrame().setSize(600, 800);
mainView.getFrame().setVisible(true);
}
/**
* Created an context to the showplanner server.
*/
private void createContext() {
Properties props = new Properties();
String connectUrl = "http://localhost:8899/demo/ejb"; //System.getProperty("javaws.connecturl");
logger.info("Connecting to: "+connectUrl);
props.put(Context.PROVIDER_URL, connectUrl );
props.put("openejb.authentication.realmName", "vasc-auth-server");
props.put(Context.SECURITY_PRINCIPAL,"admin");
props.put(Context.SECURITY_CREDENTIALS,"admin123");
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
try {
context = new InitialContext(props);
} catch (Exception e) {
e.printStackTrace();
//logger.log(Level.WARNING,e.getMessage(),e);
//ExceptionDialog err = new ExceptionDialog(e,true);
//err.showOpenDialog(null,i18n(VascDemoSwingClient.class,"dialogTitle"),i18n(VascDemoSwingClient.class,"dialogContext"));
}
}
/**
* Sets our jaas config path
*/
private void setJaasConfig() throws IOException {
// tomee
String path = System.getProperty("java.security.auth.login.config");
if (path == null) {
URL url = VascDemoSwingClient.class.getClassLoader().getResource("META-INF/client.login.conf");
File tempFile = File.createTempFile("cached-", ".jar");
tempFile.deleteOnExit();
copyFile(url.openConnection().getInputStream(),tempFile);
String urlString = "file:"+tempFile.getAbsolutePath();
//logger.info("Setting jaas config property to url: "+urlString);
System.setProperty("java.security.auth.login.config", urlString);
logger.info("Setting jaas config property to url: "+urlString);
/*
if (resource != null) {
path = URLDecoder.decode(resource.getFile());
System.setProperty("java.security.auth.login.config", path);
} else {
logger.warning("Could not find client.login.conf");
}*/
}
/* jboss
URL url = Thread.currentThread().getContextClassLoader().getResource("META-INF/jaas.config");
String urlString = url.toExternalForm();
// jdk1.6 update10 has different classloader, so just copy for the moment..... ..
if (urlString.startsWith("jar:")) {
File tempFile = File.createTempFile("cached-", ".jar");
tempFile.deleteOnExit();
copyFile(url.openConnection().getInputStream(),tempFile);
urlString = "file:"+tempFile.getAbsolutePath();
}
//logger.info("Setting jaas config property to url: "+urlString);
System.setProperty("java.security.auth.login.config", urlString);
*/
}
private void copyFile(InputStream in, File out) throws IOException {
ByteBuffer buffer = ByteBuffer.allocate(1024*4);
byte[] bufferArray = buffer.array();
FileChannel outputChannel = new FileOutputStream(out).getChannel();
while (true) {
buffer.clear();
int lim = in.read(bufferArray);
if (lim < 0) {
break; // could not read anymore
}
buffer.flip();
buffer.limit(lim);
while (buffer.hasRemaining()) {
outputChannel.write(buffer);
}
}
outputChannel.close();
}
/**
* Do an login on the server
*/
private void doLogin() {
VascDemoUserLoginDialog loginHandler = new VascDemoUserLoginDialog();
try {
loginContext = new LoginContext("vasc-auth-client", loginHandler);
loginContext.login();
} catch(Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, i18n(this,"dialogNoLoginContext"),i18n(this,"dialogTitle"), JOptionPane.WARNING_MESSAGE);
System.exit(1);
}
try {
// Subject subject = loginContext.getSubject();
if(doLoginTest()) {
return;
}
loginContext.login();
if(doLoginTest()) {
return;
}
loginContext.login();
if(doLoginTest()) {
return;
}
JOptionPane.showMessageDialog(null, i18n(this,"dialogUserLoginFailure"),i18n(this,"dialogTitle"), JOptionPane.WARNING_MESSAGE);
System.exit(1);
} catch (CommunicationException e) {
List<String> messages = new ArrayList<String>(3);
messages.add("Could not connect to Vasc Tech Client Swing server, please try again.");
messages.add("If the problem persists please contact your systems administrator.");
String connectionError = "Could not obtain connection to any of these urls: ";
Integer connectionErrorLen = connectionError.length();
String emsg = e.getMessage();
if (emsg!=null && emsg.startsWith(connectionError)) {
Integer urlEndIdx = emsg.substring(connectionErrorLen).indexOf(':');
if (urlEndIdx>=0) {
messages.add("Server unreachable at: "+emsg.substring(connectionErrorLen, connectionErrorLen+urlEndIdx));
}
}
JOptionPane.showMessageDialog(null, messages.toArray(), "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
System.exit(1);
} catch (Exception e) {
//logger.log(Level.WARNING,e.getMessage(),e);
JOptionPane.showMessageDialog(null, "Failure on login test.", "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
System.exit(1);
}
}
/**
* Check if we have 'login' role on server.
* @return
* @throws Exception
*/
private boolean doLoginTest() throws Exception {
try {
LoginUserController loginManager = (LoginUserController)context.lookup("loginUserControllerRemote");
loginManager.doClientLogin();
return true;
} catch (javax.naming.NameNotFoundException e) {
JOptionPane.showMessageDialog(null, "Server is not deployed.\nPlease wait a couple of minuts and try again.");
return false;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage());
e.printStackTrace();
return false;
}
}
/**
* Some simple hardcoded i18n function here
*
* @param key
* @param params
* @return
*/
static protected String i18n(Object obj,String key,Object...params) {
if(obj==null) { throw new NullPointerException("Can't get key of null obj"); }
if (key==null) { throw new NullPointerException("key may not be null"); }
if(obj instanceof Class) {
key=((Class<?>)obj).getName()+"."+key;
} else {
key=obj.getClass().getName()+"."+key;
}
return key;
/*
try {
String text = ResourceBundle.getBundle("resources.i18n.root").getString(key);
if (params != null) {
MessageFormat mf = new MessageFormat(text);
text = mf.format(params, new StringBuffer(), null).toString();
}
return text;
} catch(MissingResourceException e){
return "MISSING: '"+key+"'";
}
*/
}
class JdniTreePrinter {
boolean printXml = true;
public JdniTreePrinter(boolean printXml) {
this.printXml=printXml;
}
public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) {
if (printXml) {
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
buf.append("<NamingRoot name=\""+ct+"\">\n");
}
printTree(context,ct,buf);
if (printXml) {
buf.append("</NamingRoot>\n");
}
}
public void printTree(javax.naming.Context context,String ct,StringBuffer buf) {
try {
printNE(context,context.list(ct), ct,buf);
} catch (NamingException e) {
//ignore leaf node exception
}
}
private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration<?> ne, String parentctx,StringBuffer buf) throws NamingException {
if (ne==null) {
return;
}
while (ne.hasMoreElements()) {
NameClassPair next = (NameClassPair) ne.nextElement();
if (printXml) {
printIndent(buf);
buf.append("<NamingRoot name=\""+next.getName()+"\" className=\""+next.getClassName()+"\">\n");
increaseIndent();
printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
decreaseIndent();
printIndent(buf);
buf.append("</NamingRoot>\n");
} else {
printEntry(next,buf);
increaseIndent();
printTree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
decreaseIndent();
}
}
}
private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) {
printIndent(buf);
buf.append("-->");
buf.append(next);
buf.append("\n");
}
private int indentLevel = 0;
private void increaseIndent() {
indentLevel += 4;
}
private void decreaseIndent() {
indentLevel -= 4;
}
private void printIndent(StringBuffer buf) {
for (int i = 0; i < indentLevel; i++) {
buf.append(" ");
}
}
}
}

View file

@ -0,0 +1,408 @@
/*
* @(#)DialogCallbackHandler.java 1.9 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package net.forwardfire.vasc.demo.client.swing;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.ConfirmationCallback;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.TextOutputCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
* Zwaar gehacke jaas login dialog
* added features:
* - name remebering
* - focus on name field
* - alway on top
* - logo stuff
* - message field
*
* <p>
* Uses a Swing dialog window to query the user for answers to authentication
* questions. This can be used by a JAAS application to instantiate a
* CallbackHandler
*
* @see javax.security.auth.callback
*/
public class VascDemoUserLoginDialog implements CallbackHandler {
/* The parent window, or null if using the default parent */
private Component parentComponent;
private static final int JPasswordFieldLen = 8;
private int loginTry = 0;
private String userName = null;
/**
* Creates a callback dialog with the default parent window.
*/
public VascDemoUserLoginDialog() {
}
/**
* Creates a callback dialog and specify the parent window.
*
* @param parentComponent
* the parent window -- specify <code>null</code> for the
* default parent
*/
public VascDemoUserLoginDialog(Component parentComponent) {
this.parentComponent = parentComponent;
}
/**
* An interface for recording actions to carry out if the user clicks OK for
* the dialog.
*/
private static interface Action {
void perform();
}
/**
* Handles the specified set of callbacks.
*
* @param callbacks
* the callbacks to handle
* @throws UnsupportedCallbackException
* if the callback is not an instance of NameCallback or
* PasswordCallback
*/
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
this.loginTry++;
/* Collect messages to display in the dialog */
final JPanel loginDesign = new JPanel();
loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS));
//final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/resources/images/logos/logo.png"));
final JPanel logoPanel = new JPanel() {
private static final long serialVersionUID = 10l;
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
// for antialiasing geometric shapes
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
// for antialiasing text
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
// to go for quality over speed
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
// Paint the default look of the panel.
super.paintComponent(g2d);
int offsetX = 0; // for windows systems
boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1;
if (isWindows) {
offsetX += 25;
}
g2d.setColor(Color.BLACK);
g2d.fillRect(0,0,getWidth(),getHeight());
g2d.setColor(new Color(238,212,1));
//int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
//int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
//g2d.drawImage(logoImage, w, h, this);
}
};
logoPanel.setPreferredSize(new Dimension(200, 170));
logoPanel.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
loginDesign.add(logoPanel);
loginDesign.add(Box.createVerticalStrut(5));
JPanel namePanel = new JPanel();
JLabel nameLabel = new JLabel("Vasc Demo Client");
nameLabel.setFont(new Font("Lucida Sans", Font.BOLD, 24));
namePanel.add(nameLabel);
loginDesign.add(namePanel);
loginDesign.add(Box.createVerticalStrut(5));
final GridLayout messagesLayout = new GridLayout(2,2);
final JPanel messages = new JPanel();
messages.setLayout(messagesLayout);
/* Collection actions to perform if the user clicks OK */
final List<Action> okActions = new ArrayList<Action>(2);
ConfirmationInfo confirmation = new ConfirmationInfo();
// hackje for focus
final JTextField name = new JTextField();
confirmation.initialValue=name;
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof TextOutputCallback) {
TextOutputCallback tc = (TextOutputCallback) callbacks[i];
switch (tc.getMessageType()) {
case TextOutputCallback.INFORMATION:
confirmation.messageType = JOptionPane.INFORMATION_MESSAGE;
break;
case TextOutputCallback.WARNING:
confirmation.messageType = JOptionPane.WARNING_MESSAGE;
break;
case TextOutputCallback.ERROR:
confirmation.messageType = JOptionPane.ERROR_MESSAGE;
break;
default:
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized message type");
}
messages.add(new JLabel(tc.getMessage()));
} else if (callbacks[i] instanceof NameCallback) {
final NameCallback nc = (NameCallback) callbacks[i];
JLabel prompt = new JLabel(nc.getPrompt());
String defaultName = nc.getDefaultName();
// if (check some property)
defaultName = "";
if (defaultName != null) {
name.setText(defaultName);
}
// default to last user name
if (userName !=null ) {
name.setText(userName);
}
messages.add(prompt);
messages.add(name);
/* Store the name back into the callback if OK */
okActions.add(new Action() {
public void perform() {
nc.setName(name.getText());
}
});
} else if (callbacks[i] instanceof PasswordCallback) {
final PasswordCallback pc = (PasswordCallback) callbacks[i];
JLabel prompt = new JLabel(pc.getPrompt());
final JPasswordField password = new JPasswordField(JPasswordFieldLen);
if (!pc.isEchoOn()) {
password.setEchoChar('*');
}
messages.add(prompt);
messages.add(password);
okActions.add(new Action() {
public void perform() {
pc.setPassword(password.getPassword());
}
});
} else if (callbacks[i] instanceof ConfirmationCallback) {
ConfirmationCallback cc = (ConfirmationCallback) callbacks[i];
confirmation.setCallback(cc);
if (cc.getPrompt() != null) {
messages.add(new JLabel(cc.getPrompt()));
}
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
if (this.loginTry>1) {
JPanel messagesPanel = new JPanel();
messagesPanel.setBorder(BorderFactory.createEtchedBorder());
JLabel iup = new JLabel("Invalid Username and Password:");
iup.setForeground(Color.RED);
messagesPanel.add(iup);
loginDesign.add(messagesPanel);
loginDesign.add(Box.createVerticalStrut(5));
}
JPanel messagesPanel = new JPanel();
messagesPanel.setBorder(BorderFactory.createEtchedBorder());
messagesPanel.add(messages);
loginDesign.add(messagesPanel);
/* Display the dialog */
/// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)
JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,confirmation.optionType,null,
confirmation.options,confirmation.initialValue);
JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login");
// We alway request focus after the windows gets focus
dialog.addWindowFocusListener(new WindowFocusListener() {
/**
* @see java.awt.event.WindowFocusListener#windowGainedFocus(java.awt.event.WindowEvent)
*/
public void windowGainedFocus(WindowEvent arg0) {
//System.out.println("request focus window focus");
name.requestFocus();
}
/**
* @see java.awt.event.WindowFocusListener#windowLostFocus(java.awt.event.WindowEvent)
*/
public void windowLostFocus(WindowEvent arg0) {
}
});
// HACK, EVEN the listener above doesn't work 100% so just request focus request
// until we have focus, then cancel task, see println output
final Timer lTimer = new Timer();
lTimer.schedule(new TimerTask() {
public void run() {
if(name.hasFocus()==false) {
//System.out.println("request focus timer task");
name.requestFocus();
} else {
cancel();
}
}
}, 10, 5);
// wait 10ms
// execute every 5ms
dialog.setAlwaysOnTop(true);
dialog.setVisible(true);
Integer result = (Integer)jop.getValue();
dialog.dispose();
if (result==null) {
// is null when escaping by window closing
result = JOptionPane.CANCEL_OPTION;
}
// copy user name for next try
userName = name.getText();
/* Perform the OK actions */
if (result == JOptionPane.OK_OPTION || result == JOptionPane.YES_OPTION) {
Iterator<Action> iterator = okActions.iterator();
while (iterator.hasNext()) {
iterator.next().perform();
}
} else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.NO_OPTION) {
System.exit(1);
}
confirmation.handleResult(result);
}
/**
* Provides assistance with translating between JAAS and Swing confirmation
* dialogs.
*/
private static class ConfirmationInfo {
private int[] translations;
int optionType = JOptionPane.OK_CANCEL_OPTION;
Object[] options = null;
Object initialValue = null;
int messageType = JOptionPane.QUESTION_MESSAGE;
private ConfirmationCallback callback;
/* Set the confirmation callback handler */
void setCallback(ConfirmationCallback callback) throws UnsupportedCallbackException {
this.callback = callback;
int confirmationOptionType = callback.getOptionType();
switch (confirmationOptionType) {
case ConfirmationCallback.YES_NO_OPTION:
optionType = JOptionPane.YES_NO_OPTION;
translations = new int[] {
JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO
};
break;
case ConfirmationCallback.YES_NO_CANCEL_OPTION:
optionType = JOptionPane.YES_NO_CANCEL_OPTION;
translations = new int[] {
JOptionPane.YES_OPTION, ConfirmationCallback.YES, JOptionPane.NO_OPTION, ConfirmationCallback.NO, JOptionPane.CANCEL_OPTION,
ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
};
break;
case ConfirmationCallback.OK_CANCEL_OPTION:
optionType = JOptionPane.OK_CANCEL_OPTION;
translations = new int[] {
JOptionPane.OK_OPTION, ConfirmationCallback.OK, JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL, JOptionPane.CLOSED_OPTION,
ConfirmationCallback.CANCEL
};
break;
case ConfirmationCallback.UNSPECIFIED_OPTION:
options = callback.getOptions();
/*
* There's no way to know if the default option means to
* cancel the login, but there isn't a better way to guess
* this.
*/
translations = new int[] {
JOptionPane.CLOSED_OPTION, callback.getDefaultOption()
};
break;
default:
throw new UnsupportedCallbackException(callback, "Unrecognized option type: " + confirmationOptionType);
}
int confirmationMessageType = callback.getMessageType();
switch (confirmationMessageType) {
case ConfirmationCallback.WARNING:
messageType = JOptionPane.WARNING_MESSAGE;
break;
case ConfirmationCallback.ERROR:
messageType = JOptionPane.ERROR_MESSAGE;
break;
case ConfirmationCallback.INFORMATION:
messageType = JOptionPane.INFORMATION_MESSAGE;
break;
default:
throw new UnsupportedCallbackException(callback, "Unrecognized message type: " + confirmationMessageType);
}
}
/* Process the result returned by the Swing dialog */
void handleResult(int result) {
if (callback == null) {
return;
}
for (int i = 0; i < translations.length; i += 2) {
if (translations[i] == result) {
result = translations[i + 1];
break;
}
}
callback.setSelectedIndex(result);
}
}
}

View file

@ -0,0 +1,6 @@
vasc-auth-client {
org.apache.openejb.client.ClientLoginModule required
debug=true
openejb.server.uri="http://localhost:8899/demo/ejb";
};

View file

@ -1,223 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>vasc-demo-tech</artifactId>
<groupId>net.forwardfire.vasc.demo</groupId>
<version>0.3.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-demo-tech-core</artifactId>
<name>vasc-demo-tech-core</name>
<description>vasc-demo-tech-core</description>
<dependencies>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${x4o-core.version}</version>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-web</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-frontend-swing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-frontend-web-jsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-frontend-web-export</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-frontend-cxf-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-backend-ldap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<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>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.lib</groupId>
<artifactId>vasc-lib-i18n</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.lib</groupId>
<artifactId>vasc-lib-editor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.test</groupId>
<artifactId>vasc-test-i18n</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jdesktop.bsaf</groupId>
<artifactId>bsaf</artifactId>
<version>${bsaf.version}</version>
<exclusions>
<exclusion>
<artifactId>jnlp</artifactId>
<groupId>javax.jnlp</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>net.jawr</groupId>
<artifactId>jawr</artifactId>
<version>${jawr.version}</version>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.wikipedia</groupId>
<artifactId>de.tudarmstadt.ukp.wikipedia.api</artifactId>
<version>0.9.1</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Tomcat deps -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>7.0.27</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>7.0.27</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>7.0.27</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.27</version>
</dependency>
<!-- Web tech deps
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>${javax.faces.version}</version>
</dependency>
<!-- RichFaces libraries -->
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>${rewrite-servlet.version}</version>
</dependency>
<!-- Jdbc Drivers for demo -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${derby.version}</version>
</dependency>
<!-- Setup proper logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>${logback-access.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${jul-to-slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${log4j-over-slf4j.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -1,248 +0,0 @@
/*
* 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.tech.core;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.logging.Handler;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.slf4j.bridge.SLF4JBridgeHandler;
import net.forwardfire.vasc.demo.tech.core.service.DatabaseService;
import net.forwardfire.vasc.demo.tech.core.service.ServerConfigService;
import net.forwardfire.vasc.demo.tech.core.service.ServerConfigService.ServerConfigKey;
import net.forwardfire.vasc.demo.tech.core.service.tomcat.TomcatService;
import net.forwardfire.vasc.demo.tech.core.service.SwingGuiService;
import net.forwardfire.vasc.demo.tech.core.service.VascControllerService;
import net.forwardfire.vasc.demo.tech.core.service.VascDeployService;
/**
* VascTechDemo init and starts the VascTechDemo
*
* @author Willem Cazander
* @version 1.0 May 3, 2012
*/
public class VascTechDemo {
private Logger logger = null;
private ServerConfigService serverConfigService = null;
private DatabaseService databaseService = null;
private TomcatService tomcatService = null;
private VascControllerService vascControllerService = null;
private VascDeployService vascDeployService = null;
private SwingGuiService swingGuiService = null;
static private VascTechDemo instance = null;
/**
* Starts this VascTechDemo instance
* @param args
*/
static public void main(String[] args) {
instance = new VascTechDemo();
instance.initialize(args);
instance.startup();
}
/**
* Copy copfig/etc directory stucture to root of project in maven/eclipse run.
* @throws IOException
*/
private void setupAutoDir() throws IOException {
File deployDir = new File("deploy");
File workDir = new File("workdir");
File workDirTmp = new File("workdir/tmp");
if (deployDir.exists()==false) {
deployDir.mkdir();
}
if (workDir.exists()==false) {
workDir.mkdir();
}
if (workDirTmp.exists()==false) {
workDirTmp.mkdir();
}
System.setProperty("java.io.tmpdir", workDirTmp.getAbsolutePath());
File tmpFile = File.createTempFile("test", "new-tmp");
if (tmpFile.getAbsolutePath().contains(workDirTmp.getName())==false) {
// Cant change tmp location.
}
tmpFile.delete();
File confDir = new File("conf");
if (confDir.exists()) {
return;
}
if (isMavenRun()==false) {
throw new RuntimeException("Can't start without conf dir.");
}
FileUtils.copyDirectory(new File("../vasc-demo-tech-build/src/main/directory/"), new File("."));
}
/**
* Config logging and setup logger object.
*/
private void setupLogging() {
// Set Config file property
if (System.getProperty("logback.configurationFile")==null) {
File logConfig = null;
if (isMavenRun()) {
logConfig = new File("conf/logback-server-console.xml");
} else {
logConfig = new File("conf/logback-server.xml");
}
try {
System.setProperty("logback.configurationFile", logConfig.toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
Logger rootLogger = Logger.getAnonymousLogger();
while (rootLogger.getParent()!=null) {
rootLogger = rootLogger.getParent();
}
for (Handler h:rootLogger.getHandlers()) {
rootLogger.removeHandler(h);
}
rootLogger.addHandler(new SLF4JBridgeHandler()); // This does also the init for us.
// Logback offical init method.
//LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
//StatusPrinter.print(lc);
// Create an JUL logger for our application.
logger = Logger.getLogger(VascTechDemo.class.getName());
logger.info("Logging is ready for application log;");
}
/**
* Init all demo service beans.
* @param argu
*/
protected void initialize(String[] argu) {
long startTime = System.currentTimeMillis();
try {
Thread.currentThread().setName("startup");
setupAutoDir();
setupLogging();
logger.info("VascTechDemo initializing ...");
databaseService = new DatabaseService();
tomcatService = new TomcatService();
serverConfigService = new ServerConfigService();
vascControllerService = new VascControllerService();
vascDeployService = new VascDeployService();
vascDeployService.setDeployDir(new File("deploy"));
swingGuiService = new SwingGuiService();
long stopTime = System.currentTimeMillis();
logger.info("VascTechDemo initialized in "+(stopTime-startTime)+" ms.");
} catch (Exception e1) {
e1.printStackTrace();
System.exit(1);
}
}
/**
* Startup and deploy all service beans.
*/
protected void startup() {
try {
long startTime = System.currentTimeMillis();
databaseService.start();
tomcatService.start();
serverConfigService.start();
vascControllerService.start();
if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_GUI)) {
swingGuiService.start();
}
if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.START_EDITOR)) {
vascControllerService.startEditor();
}
vascDeployService.start();
tomcatService.deploy(serverConfigService.getServerConfigValue(ServerConfigKey.DEPLOY_PATH));
if (serverConfigService.isServerConfigValueTrue(ServerConfigKey.DEPLOY_DEBUG)) {
tomcatService.deployDebug();
}
long stopTime = System.currentTimeMillis();
logger.info("VascTechDemo startup in "+(stopTime-startTime)+" ms.");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public void shutdown() {
if (instance==null) {
return;
}
Thread t = new Thread(new Runnable() {
public void run() {
try {
long startTime = System.currentTimeMillis();
vascDeployService.stop();
vascControllerService.stop();
serverConfigService.stop();
tomcatService.stop();
databaseService.stop();
long stopTime = System.currentTimeMillis();
logger.info("VascTechDemo shutdown in "+(stopTime-startTime)+" ms.");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
} finally {
instance = null;
}
}
});
t.setName("shutdown");
t.start();
}
static public VascTechDemo getInstance() {
return instance;
}
public boolean isMavenRun() {
return System.getProperty("java.class.path").contains("classes");
}
public VascControllerService getVascControllerService() {
return vascControllerService;
}
public VascDeployService getVascDeployService() {
return vascDeployService;
}
public TomcatService getTomcatService() {
return tomcatService;
}
public SwingGuiService getSwingGuiService() {
return swingGuiService;
}
}

View file

@ -1,72 +0,0 @@
/*
* 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.tech.core;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascControllerProvider;
import net.forwardfire.vasc.core.VascEntryConfigControllerLocal;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.entry.export.VascEntryExporterJR4O;
import net.forwardfire.vasc.lib.jr4o.JR4ODesignManager.JRExportType;
/**
* DemoVascControllerProvider gets the static local jvm vasc controller for this tech demo.
*
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class VascTechDemoControllerConfig implements VascControllerProvider {
/**
* @see net.forwardfire.vasc.core.VascControllerProvider#getVascController()
*/
public VascController getVascController() {
try {
VascController vascController = DefaultVascFactory.getDefaultVascController();
VascEntryConfigControllerLocal vecc = (VascEntryConfigControllerLocal)vascController.getVascEntryConfigController();
// Config all report export engines for demo.
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfLandscape",JRExportType.PDF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrPdfPortrait",JRExportType.PDF,"generic-portrait","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrRtf",JRExportType.RTF,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXls",JRExportType.XLS,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrXml",JRExportType.XML,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
vecc.addVascEntryExporter(new VascEntryExporterJR4O("jrCsv",JRExportType.CSV,"generic-landscape","net/forwardfire/vasc/lib/jr4o/reports/dynamic-reports.xml"));
// Config root bundle to load all resources.
vecc.setResourceBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle");
// Increase some config defaults
vecc.getMasterVascBackendState().setPageSize(200);
vecc.getMasterVascBackendState().setPageSizeMax(2000);
return vascController;
} catch (VascException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -1,149 +0,0 @@
/*
* 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.tech.core.service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.h2.tools.Server;
/**
* DatabaseService starts and stops the embedded H2 demo database.
*
* @author Willem Cazander
* @version 1.0 May 13, 2012
*/
public class DatabaseService {
private Logger logger = null;
private Server server = null;
public DatabaseService() {
logger = Logger.getLogger(DatabaseService.class.getName());
}
public void start() {
List<String> argu = new ArrayList<String>(10);
argu.add("-tcp");
argu.add("-tcpPort"); argu.add("9092");
argu.add("-tcpPassword"); argu.add("stopSecret");
argu.add("-baseDir"); argu.add("data/db");
String[] args = new String[argu.size()];
args = argu.toArray(args);
StringBuffer buf = new StringBuffer();
for (String a:args) {
buf.append(a);
buf.append(" ");
}
logger.info("Start H2 Server with: "+buf);
try {
server = Server.createTcpServer(args).start();
} catch (SQLException e) {
e.printStackTrace();
}
if (server.isRunning(true)) {
initDB();
}
}
public void stop() {
if (server==null) {
return;
}
logger.info("Stopping H2 Server");
server.stop();
}
private void initDB() {
Connection conn = null;
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl==null) {
cl = this.getClass().getClassLoader();
}
cl.loadClass("org.h2.Driver");
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9092/vasc-demo");
ResultSet rs = conn.prepareStatement("show tables").executeQuery();
if (rs.next()) {
logger.info("Tables found so skipping auto init.");
rs.close();
return;
}
rs.close();
String allSql = readResourceAsString("net/forwardfire/vasc/demo/tech/core/service/resources/init-db.sql");
String[] allSqlData = allSql.split(";");
for(String sql:allSqlData) {
sql = sql.trim();
if (sql.isEmpty()) {
continue;
}
conn.prepareStatement(sql+";").executeUpdate();
}
logger.info("Done auto init total statements done: "+allSqlData.length);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (conn!=null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
private String readResourceAsString(String resource) throws IOException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl==null) {
cl = this.getClass().getClassLoader();
}
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(new InputStreamReader(cl.getResourceAsStream(resource)));
try {
char[] buf = new char[1024];
int numRead=0;
while((numRead=reader.read(buf)) != -1){
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
} finally {
if (reader!=null) {
reader.close();
}
}
return fileData.toString();
}
}

View file

@ -1,87 +0,0 @@
/*
* 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.tech.core.service;
import javax.naming.Context;
import javax.naming.NamingException;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
/**
* ServerConfigService reads demo server config parameters from jndi.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class ServerConfigService {
public ServerConfigService() {
}
public void start() {
}
public void stop() {
}
private Object readConfigKey(ServerConfigKey key) {
try {
Context context = VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext();
return context.lookup("config/"+key.name());
} catch (NamingException e) {
throw new IllegalStateException("Naming error:"+e.getMessage()+" from key: "+key.name(),e);
}
}
public String getServerConfigValue(ServerConfigKey key) {
if (key==null) {
throw new NullPointerException("Can't get value for null key.");
}
Object v = readConfigKey(key);
if (v==null) {
return key.getDefaultValue();
}
return v.toString();
}
public boolean isServerConfigValueTrue(ServerConfigKey key) {
String value = getServerConfigValue(key);
return "true".equalsIgnoreCase(value);
}
public enum ServerConfigKey {
START_GUI("true"),
START_EDITOR("true"),
DEPLOY_DEBUG("true"),
DEPLOY_PATH("/demo");
private String defaultValue = null;
private ServerConfigKey(String defaultValue) {
this.defaultValue=defaultValue;
}
public String getDefaultValue() {
return defaultValue;
}
}
}

View file

@ -1,130 +0,0 @@
/*
* 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.tech.core.service;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.x4o.VascParser;
/**
* VascControllerService manages the demo vasc controller which gets init by jndi factory.
*
* @author Willem Cazander
* @version 1.0 May 18, 2012
*/
public class VascControllerService {
private Logger logger = null;
private VascController vascController = null;
private List<VascServiceListener> vascServiceListeners = null;
public VascControllerService() {
logger = Logger.getLogger(VascControllerService.class.getName());
vascServiceListeners = new ArrayList<VascServiceListener>(10);
}
public void start() {
logger.finer("Starting vascmanager");
if (vascController!=null) {
throw new RuntimeException("VascManager is already started.");
}
try {
// Fetch from jndi
vascController = (VascController)VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext().lookup("vasc/DemoVascController");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void stop() {
if (vascController==null) {
return;
}
VascBackendControllerLocal backends = (VascBackendControllerLocal)vascController.getVascBackendController();
backends.clearAndStopBackends();
vascController = null;
logger.info("Stop manager, cleared all.");
}
public void startEditor() {
try {
VascParser parser = new VascParser(vascController);
parser.addGlobalELBean("vascController", vascController);
parser.parseResource("net/forwardfire/vasc/lib/editor/vasc-edit.xml");
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
} catch (Exception e) {
e.printStackTrace();
} finally {
fireChangeEvent();
}
}
public void openFile(File file) {
logger.info("Vasc open file: "+file.getAbsoluteFile());
try {
VascParser parser = new VascParser(vascController);
//File f = File.createTempFile("test-vasc", ".xml");
//parser.setDebugOutputStream(new FileOutputStream(f));
parser.parseFile(file);
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vascController.getVascEntryController(), vascController);
} catch (Exception e) {
e.printStackTrace();
} finally {
fireChangeEvent();
}
}
public VascController getVascController() {
return vascController;
}
public void fireChangeEvent() {
for (VascServiceListener listener:vascServiceListeners) {
listener.changeEvent();
}
}
public void addVascServiceListener(VascServiceListener listener) {
vascServiceListeners.add(listener);
}
public interface VascServiceListener {
public void changeEvent();
}
}

View file

@ -1,223 +0,0 @@
/*
* 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.tech.core.service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingException;
import org.apache.catalina.Server;
import org.apache.naming.ContextBindings;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
/**
* VascDeployService parses "deploy/*.xml" automaticly for hotdeployments.
*
* @author Willem Cazander
* @version 1.0 May 10, 2012
*/
public class VascDeployService {
private Logger logger = null;
private File deployDir = null;
private int scanPeriod = 3;
private AutoDeployManager autoDeployManager = null;
private Map<File,String> fileCheckSums = null;
public VascDeployService() {
logger = Logger.getLogger(VascDeployService.class.getName());
fileCheckSums = new HashMap<File,String>(20);
}
public void start() {
if (deployDir==null) {
throw new NullPointerException("Can't deploy with null deployDir.");
}
if (deployDir.exists()==false) {
throw new IllegalStateException("Can't deploy with non-existing deployDir.");
}
if (deployDir.isDirectory()==false) {
throw new IllegalStateException("Can't deploy with non-directory deployDir.");
}
// Start scan thread for auto (re)deployments
Thread scanThread = new Thread(new AutoDeployManager());
scanThread.setName("hotdeploy-scanner");
scanThread.start();
}
public void stop() {
if (autoDeployManager==null) {
return;
}
autoDeployManager.stop();
}
public String createMd5Sum(File file) throws IOException, NoSuchAlgorithmException {
FileInputStream in = new FileInputStream(file.getAbsolutePath());
try {
byte[] b = new byte[1024 * 64];
int num = 0;
MessageDigest md = MessageDigest.getInstance("MD5");
while ((num = in.read(b)) != -1) {
md.update(b, 0, num);
}
byte[] hashBytes = md.digest();
BigInteger hashResult = new BigInteger(hashBytes);
String hashString = hashResult.toString(16);
return hashString;
} finally {
if (in != null) {
in.close();
}
}
}
private void hotDeployVasc() throws NoSuchAlgorithmException, IOException {
int deployed = 0;
long startTime = System.currentTimeMillis();
for (File file:deployDir.listFiles()) {
if (file.canRead()==false) {
continue;
}
if (file.getName().endsWith("xml")==false) {
continue;
}
String md5File = createMd5Sum(file);
String md5Deploy = fileCheckSums.get(file);
if (md5Deploy!=null && md5Deploy.equals(md5File)) {
continue;
}
fileCheckSums.put(file, md5File);
deployed++;
VascTechDemo.getInstance().getVascControllerService().openFile(file);
}
if (deployed > 0) {
long stopTime = System.currentTimeMillis();
logger.info("Done deploying total files read: "+deployed+" in "+(stopTime-startTime)+" ms.");
/*
try {
StringBuffer buf = new StringBuffer();
InitialContext context = new InitialContext();
JdniTreePrinter jndi = new JdniTreePrinter();
jndi.printJNDITree(context, "java:", buf);
logger.info("JDNI Tree:\n"+buf.toString());
} catch (Exception e) {
e.printStackTrace();
} */
}
}
protected class AutoDeployManager implements Runnable {
private volatile boolean run = true;
public void run() {
try {
Thread.sleep(2000); // let gui+tomcat start
logger.info("AutoDeployManager started");
Server server = VascTechDemo.getInstance().getTomcatService().getServer();
Object token = "secretToken";
String bindName = "autoDeployThread";
try {
ContextBindings.bindContext(bindName, server.getGlobalNamingContext(),token);
ContextBindings.bindThread(bindName,token);
} catch (NamingException e) {
e.printStackTrace();
}
while(run) {
try {
hotDeployVasc();
} catch (Exception e) {
logger.log(Level.WARNING,"Error while depoying: "+e.getMessage(),e);
}
if (scanPeriod == 0) {
scanPeriod = 1;
}
try {
Thread.sleep(1000*scanPeriod);
} catch (InterruptedException ie) {
logger.info("Interrupted sleep");
break;
}
}
ContextBindings.unbindThread(bindName,token);
ContextBindings.unbindContext(bindName,token);
} catch (Exception e) {
logger.log(Level.SEVERE,"Error in run: "+e.getMessage(),e);
} finally {
logger.info("AutoDeployManager stoped");
}
}
public void stop() {
run = false;
this.notify();
}
}
/**
* @return the deployDir
*/
public File getDeployDir() {
return deployDir;
}
/**
* @param deployDir the deployDir to set
*/
public void setDeployDir(File deployDir) {
this.deployDir = deployDir;
}
/**
* @return the scanPeriod
*/
public int getScanPeriod() {
return scanPeriod;
}
/**
* @param scanPeriod the scanPeriod to set
*/
public void setScanPeriod(int scanPeriod) {
this.scanPeriod = scanPeriod;
}
}

View file

@ -1,126 +0,0 @@
/*
* 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.tech.core.service.tomcat;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;
/**
* AuthSessionTimeoutValve sets sessions timeout for Sessions which has user pricaiap.
*
* @author Willem Cazander
* @version 1.0 May 27, 2012
*/
public class AuthSessionTimeoutValve extends ValveBase {
private boolean logInfo = false;
private int minTimeout = 60;
private int maxTimeout = 60*60;
private int authTimeout = 60*20;
/**
* The descriptive information about this implementation.
*/
protected static final String info = AuthSessionTimeoutValve.class.getName()+"/1.0";
@Override
public void invoke(Request request, Response response) throws IOException,ServletException {
getNext().invoke(request, response);
HttpSession session = request.getSession(false);
if (session==null) {
return;
}
int curSessionTimeout = session.getMaxInactiveInterval();
int newSessionTimeout = curSessionTimeout;
if (curSessionTimeout < minTimeout) {
newSessionTimeout = minTimeout;
}
if (curSessionTimeout > maxTimeout) {
newSessionTimeout = maxTimeout;
}
if (request.getUserPrincipal()!=null) {
newSessionTimeout = authTimeout;
}
if (curSessionTimeout != newSessionTimeout) {
session.setMaxInactiveInterval(newSessionTimeout);
logChange(session.getId(),curSessionTimeout,newSessionTimeout);
}
}
private void logChange(String sessionId,int curSessionTimeout,int newSessionTimeout) {
String log = "Changed session: "+sessionId+" from timeout: "+curSessionTimeout+" to: "+newSessionTimeout;
if (logInfo) {
getContainer().getLogger().info(log);
} else {
getContainer().getLogger().debug(log);
}
}
/**
* @return the minTimeout
*/
public int getMinTimeout() {
return minTimeout;
}
/**
* @param minTimeout the minTimeout to set
*/
public void setMinTimeout(int minTimeout) {
this.minTimeout = minTimeout;
}
/**
* @return the maxTimeout
*/
public int getMaxTimeout() {
return maxTimeout;
}
/**
* @param maxTimeout the maxTimeout to set
*/
public void setMaxTimeout(int maxTimeout) {
this.maxTimeout = maxTimeout;
}
/**
* @return the authTimeout
*/
public int getAuthTimeout() {
return authTimeout;
}
/**
* @param authTimeout the authTimeout to set
*/
public void setAuthTimeout(int authTimeout) {
this.authTimeout = authTimeout;
}
}

View file

@ -1,52 +0,0 @@
package net.forwardfire.vasc.demo.tech.core.service.tomcat;
import javax.naming.NameClassPair;
import javax.naming.NamingException;
public class JdniTreePrinter {
public JdniTreePrinter() {
}
public void printJNDITree(javax.naming.Context context,String ct,StringBuffer buf) {
try {
printNE(context,context.list(ct), ct,buf);
} catch (NamingException e) {
//ignore leaf node exception
}
}
private void printNE(javax.naming.Context context,javax.naming.NamingEnumeration<?> ne, String parentctx,StringBuffer buf) throws NamingException {
while (ne.hasMoreElements()) {
NameClassPair next = (NameClassPair) ne.nextElement();
printEntry(next,buf);
increaseIndent();
printJNDITree(context,(parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName(),buf);
decreaseIndent();
}
}
private void printEntry(javax.naming.NameClassPair next,StringBuffer buf) {
printIndent(buf);
buf.append("-->");
buf.append(next);
buf.append("\n");
}
private int indentLevel = 0;
private void increaseIndent() {
indentLevel += 4;
}
private void decreaseIndent() {
indentLevel -= 4;
}
private void printIndent(StringBuffer buf) {
for (int i = 0; i < indentLevel; i++) {
buf.append(" ");
}
}
}

View file

@ -1,39 +0,0 @@
package net.forwardfire.vasc.demo.tech.core.service.tomcat;
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
public class JndiDebugServlet extends HttpServlet {
private static final long serialVersionUID = -7624183395089913214L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
try {
Context context = new InitialContext();
if (req.getRequestURI().endsWith("global")) {
context = VascTechDemo.getInstance().getTomcatService().getServer().getGlobalNamingContext();
}
StringBuffer buf = new StringBuffer();
JdniTreePrinter jndi = new JdniTreePrinter();
if (req.getRequestURI().endsWith("global")) {
jndi.printJNDITree(context,"",buf);
} else {
jndi.printJNDITree(context,"java:",buf);
}
PrintWriter out = response.getWriter();
out.append(buf.toString());
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -1,343 +0,0 @@
/*
* 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.tech.core.service.tomcat;
import java.net.UnknownHostException;
import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.realm.RealmBase;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
import com.mongodb.MongoOptions;
import com.mongodb.ServerAddress;
/**
* MongoRealm does auth to mongo collections.
*
* @author Willem Cazander
* @version 1.0 May 13, 2012
*/
public class MongoRealm extends RealmBase {
private Logger logger = Logger.getLogger(MongoRealm.class.getName());
private String hostname = "localhost";
private int port = 27017;
private String database = null;
private String authUser = null;
private String authPass = null;
private String userCollection = null;
private String userField = "username";
private String userPassField = "password";
private String roleCollection = null;
private String roleField = "role";
private String roleUserField = userField;
private boolean roleUserIdRef = false;
private Mongo mongo = null;
private DB db = null;
@Override
protected String getName() {
return this.getClass().getSimpleName();
}
@Override
protected String getPassword(String username) {
DBObject user = getUser(username);
if (user==null) {
return null;
}
String password = (String) user.get(getUserPassField());
return password;
}
protected DBObject getUser(String username) {
DBCollection coll = db.getCollection(getUserCollection());
DBObject query = new BasicDBObject();
query.put(getUserField(), username);
DBCursor cur = coll.find(query);
if (cur.hasNext()==false) {
return null;
}
DBObject user = cur.next();
return user;
}
@Override
protected Principal getPrincipal(String username) {
String password = getPassword(username);
if (password==null) {
return null;
}
DBCollection coll = db.getCollection(getRoleCollection());
DBObject query = new BasicDBObject();
if (isRoleUserIdRef()) {
DBObject user = getUser(username);
query.put(getRoleUserField(), user.get("_id"));
} else {
query.put(getRoleUserField(), username);
}
DBCursor cur = coll.find(query);
if (cur.hasNext()==false) {
return null;
}
List<String> roles = new ArrayList<String>(30);
while (cur.hasNext()) {
DBObject row = cur.next();
String role = (String)row.get(getRoleField());
roles.add(role);
}
return new GenericPrincipal(username, password, roles);
}
/**
* @see org.apache.catalina.realm.RealmBase#startInternal()
*/
@Override
protected void startInternal() throws LifecycleException {
super.startInternal();
if (database==null) {
throw new LifecycleException("database is null.");
}
if (userCollection==null) {
throw new LifecycleException("userCollection is null.");
}
if (roleCollection==null) {
throw new LifecycleException("roleCollection is null.");
}
createMongoConnection();
logger.fine("Started mongo realm to database: "+getDatabase());
}
/**
* @see org.apache.catalina.realm.RealmBase#stopInternal()
*/
@Override
protected void stopInternal() throws LifecycleException {
super.stopInternal();
if (mongo==null) {
return;
}
mongo.close();
logger.fine("Stopped mongo realm.");
}
private void createMongoConnection() throws LifecycleException {
ServerAddress server;
try {
server = new ServerAddress(hostname,port);
} catch (UnknownHostException e) {
throw new LifecycleException(e);
}
MongoOptions options = new MongoOptions();
mongo = new Mongo(server,options);
db = mongo.getDB(database);
if (authUser!=null && authUser.isEmpty()==false && authPass!=null && authPass.isEmpty()==false) {
boolean auth = db.authenticate(authUser, authPass.toCharArray());
authPass = null;
if (auth==false) {
throw new LifecycleException("Could not auth to db: "+database+" with username: "+authUser);
}
}
db.setReadOnly(true);
logger.finer("Connection to: "+db.getName());
}
/**
* @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 authUser
*/
public String getAuthUser() {
return authUser;
}
/**
* @param authUser the authUser to set
*/
public void setAuthUser(String authUser) {
this.authUser = authUser;
}
/**
* @return the authPass
*/
public String getAuthPass() {
return authPass;
}
/**
* @param authPass the authPass to set
*/
public void setAuthPass(String authPass) {
this.authPass = authPass;
}
/**
* @return the userCollection
*/
public String getUserCollection() {
return userCollection;
}
/**
* @param userCollection the userCollection to set
*/
public void setUserCollection(String userCollection) {
this.userCollection = userCollection;
}
/**
* @return the userField
*/
public String getUserField() {
return userField;
}
/**
* @param userField the userField to set
*/
public void setUserField(String userField) {
this.userField = userField;
}
/**
* @return the roleCollection
*/
public String getRoleCollection() {
return roleCollection;
}
/**
* @param roleCollection the roleCollection to set
*/
public void setRoleCollection(String roleCollection) {
this.roleCollection = roleCollection;
}
/**
* @return the roleField
*/
public String getRoleField() {
return roleField;
}
/**
* @param roleField the roleField to set
*/
public void setRoleField(String roleField) {
this.roleField = roleField;
}
/**
* @return the roleUserField
*/
public String getRoleUserField() {
return roleUserField;
}
/**
* @param roleUserField the roleUserField to set
*/
public void setRoleUserField(String roleUserField) {
this.roleUserField = roleUserField;
}
/**
* @return the userPassField
*/
public String getUserPassField() {
return userPassField;
}
/**
* @param userPassField the userPassField to set
*/
public void setUserPassField(String userPassField) {
this.userPassField = userPassField;
}
/**
* @return the roleUserIdRef
*/
public boolean isRoleUserIdRef() {
return roleUserIdRef;
}
/**
* @param roleUserIdRef the roleUserIdRef to set
*/
public void setRoleUserIdRef(boolean roleUserIdRef) {
this.roleUserIdRef = roleUserIdRef;
}
}

View file

@ -1,218 +0,0 @@
/*
* 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.tech.core.service.tomcat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import org.apache.catalina.Context;
import org.apache.catalina.Host;
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Bootstrap;
import org.apache.catalina.startup.ContextConfig;
import org.apache.naming.resources.VirtualDirContext;
/**
* TomcatService config and starts Tomcat in semi embedded mode.
*
* @author Willem Cazander
* @version 1.0 May 10, 2012
*/
public class TomcatService {
private Logger logger = null;
private Server server = null;
private ClassLoader commonLoader = null;
private Context applicationContext = null;
public TomcatService() {
logger = Logger.getLogger(TomcatService.class.getName());
}
public void start() throws Exception {
Bootstrap boot = new Bootstrap();
boot.setCatalinaHome(System.getProperty("user.dir"));
boot.init();
boot.start();
/// After startup get the server object from private method.
for (Method m:boot.getClass().getDeclaredMethods()) {
if (m.getName().equals("getServer")) {
m.setAccessible(true);
server = (Server)m.invoke(boot);
}
}
if (server==null) {
throw new RuntimeException("Could not get server by reflection from BootStrap.");
}
for (Field f:boot.getClass().getDeclaredFields()) {
if (f.getName().equals("commonLoader")) {
f.setAccessible(true);
commonLoader = (ClassLoader)f.get(boot);
}
}
}
public void deploy(String deployContext) throws Exception {
Service service = server.findService("Catalina");
Host host = (Host)service.getContainer().findChild("localhost");
String deployPath = null;
if (VascTechDemo.getInstance().isMavenRun()) {
String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/";
deployPath = new File(webappPathLocation).getAbsolutePath();
logger.info("Deploy demo app from workspace path: "+deployPath);
} else {
File techWarFile = null;
for (File file:new File("lib").listFiles()) {
if (file.getName().contains("vasc-demo-tech-web")) {
techWarFile = file;
break;
}
}
if (techWarFile==null) {
throw new NullPointerException("Could not locate war file in lib directory.");
}
File destDir = new File("workdir","tomcat.wars"+File.separator+techWarFile.getName());
if (destDir.exists()==false) {
destDir.mkdirs();
JarFile jar = new JarFile(techWarFile);
Enumeration<JarEntry> jars = jar.entries();
while (jars.hasMoreElements()) {
JarEntry file = jars.nextElement();
File f = new File(destDir+File.separator+file.getName());
if (file.isDirectory()) {
f.mkdir();
continue;
}
InputStream is = jar.getInputStream(file);
FileOutputStream fos = new FileOutputStream(f);
while (is.available() > 0) {
fos.write(is.read()); // slow copy
}
fos.close();
is.close();
}
}
deployPath = destDir.getAbsolutePath();
logger.info("Deploy war path: "+deployPath);
}
Context ctx = new StandardContext();
ctx.setName(deployContext);
ctx.setPath(deployContext);
ctx.setDocBase(deployPath);
//ctx.setParentClassLoader(commonLoader);
ctx.setConfigured(true);
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener(ctxCfg);
VirtualDirContext vDir = new VirtualDirContext();
vDir.setExtraResourcePaths("../vasc-demo-tech-web/target/classes");
ctx.setResources(vDir);
//VirtualWebappLoader loader = new VirtualWebappLoader();
//String cl = System.getProperty("java.class.path").replace(":", ";");
//logger.info("Virtal class path: "+cl);
//loader.setVirtualClasspath(cl);
//loader.setSearchVirtualFirst(true);
//ctx.setLoader(loader);
//ctx.getJarScanner().scan
host.addChild(ctx);
applicationContext = ctx;
}
public void deployDebug() throws Exception {
if (applicationContext==null) {
throw new NullPointerException("Can only deploy debug after deploy.");
}
long startTime = System.currentTimeMillis();
addServlet(applicationContext,"jdbcConsole","org.h2.server.web.WebServlet");
applicationContext.addServletMapping("/debug/jdbc/console/*", "jdbcConsole");
addServlet(applicationContext,"jndiView","net.forwardfire.vasc.demo.tech.core.service.tomcat.JndiDebugServlet");
applicationContext.addServletMapping("/debug/jndi/view", "jndiView");
applicationContext.addServletMapping("/debug/jndi/view/global", "jndiView");
addServlet(applicationContext,"logbackClassicStatus","ch.qos.logback.classic.ViewStatusMessagesServlet");
applicationContext.addServletMapping("/debug/logback/status/classic", "logbackClassicStatus");
addServlet(applicationContext,"logbackAccessStatus","ch.qos.logback.access.ViewStatusMessagesServlet");
applicationContext.addServletMapping("/debug/logback/status/access", "logbackAccessStatus");
long stopTime = System.currentTimeMillis();
logger.info("Deployed all debug resources in: "+(stopTime-startTime)+" ms.");
}
public Wrapper addServlet(Context ctx,String servletName,String servletClass) {
Wrapper sw = ctx.createWrapper();
sw.setServletClass(servletClass);
sw.setName(servletName);
ctx.addChild(sw);
return sw;
}
public void stop() throws Exception {
if (server==null) {
return;
}
server.stop();
}
public ClassLoader getClassLoaderCommon() {
return commonLoader;
}
public Server getServer() {
return server;
}
/**
* @return the applicationContext
*/
public Context getApplicationContext() {
return applicationContext;
}
}

View file

@ -1,35 +0,0 @@
package net.forwardfire.vasc.demo.tech.core.ui;
import java.awt.Dimension;
import java.util.EventObject;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;
public class JApplication extends SingleFrameApplication {
protected void startup() {
addExitListener(new ShutdownManager());
FrameView mainView = getMainView();
mainView.setComponent(new JMainPanel());
mainView.setMenuBar(new JMainPanelMenuBar());
mainView.getFrame().setMinimumSize(new Dimension(1024-64,768-128));
show(mainView);
}
static public JApplication getInstance() {
return getInstance(JApplication.class);
}
class ShutdownManager implements ExitListener {
public boolean canExit(EventObject e) {
return true;
}
public void willExit(EventObject event) {
VascTechDemo.getInstance().shutdown();
}
}
}

View file

@ -1,180 +0,0 @@
/*
* 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.tech.core.ui;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Enumeration;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SpringLayout;
import javax.swing.SwingUtilities;
/**
* JConsolePanel binds to JUL and display log messages in texteara.
*
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class JConsolePanel extends JPanel implements ActionListener {
private static final long serialVersionUID = 485766723433479054L;
private UILogHandler logHandler = null;
private JButton clearButton = null;
private JComboBox levelBox = null;
private JTextArea logTextArea = null;
private JCheckBox autoScrollBox = null;
private int logLinesMax = 255;
public JConsolePanel() {
setLayout(new FlowLayout(FlowLayout.LEFT));
JPanel wrap = new JPanel();
wrap.setLayout(new SpringLayout());
wrap.add(createHeader());
wrap.add(createEditor());
SpringLayoutGrid.makeCompactGrid(wrap,2,1);
add(wrap);
Logger rootLogger = Logger.getAnonymousLogger();
while (rootLogger.getParent()!=null) {
rootLogger = rootLogger.getParent();
}
logHandler = new UILogHandler();
logHandler.setFormatter(new SimpleFormatter());
rootLogger.addHandler(logHandler);
}
/**
* This needs release if playing the the this tab add/removal very multiple times.
*/
public void release() {
Logger rootLogger = Logger.getAnonymousLogger();
while (rootLogger.getParent()!=null) {
rootLogger = rootLogger.getParent();
}
rootLogger.removeHandler(logHandler);
}
private JPanel createHeader() {
JPanel result = new JPanel();
result.setBorder(BorderFactory.createLineBorder(Color.BLUE));
result.setLayout(new FlowLayout(FlowLayout.LEFT));
result.add(new JLabel("Log Level"));
levelBox = new JComboBox(new Level[] {Level.OFF,Level.SEVERE,Level.WARNING,Level.INFO,Level.FINE,Level.FINER,Level.FINEST,Level.ALL});
levelBox.setSelectedItem(Level.INFO);
levelBox.addActionListener(this);
result.add(levelBox);
clearButton = new JButton("Clear");
clearButton.addActionListener(this);
result.add(clearButton);
autoScrollBox = new JCheckBox("Autoscroll");
autoScrollBox.setSelected(true);
result.add(autoScrollBox);
return result;
}
private JPanel createEditor() {
JPanel result = new JPanel();
result.setBorder(BorderFactory.createLineBorder(Color.BLUE));
logTextArea = new JTextArea(5, 80);
logTextArea.setAutoscrolls(true);
logTextArea.setEditable(false);
JScrollPane logScrollPane = new JScrollPane(logTextArea);
logScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
logScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
logScrollPane.getViewport().setOpaque(false);
result.add(logScrollPane);
return result;
}
public void actionPerformed(ActionEvent e) {
if (clearButton.equals(e.getSource())) {
logTextArea.setText("");
} else if (levelBox.equals(e.getSource()) && levelBox.getSelectedIndex()!=-1) {
Level level = (Level)levelBox.getSelectedItem();
logHandler.setLevel(level);
Enumeration<String> loggers = LogManager.getLogManager().getLoggerNames();
while (loggers.hasMoreElements()) {
String name = loggers.nextElement();
Logger logger = LogManager.getLogManager().getLogger(name);
if (logger!=null && name.contains("pulsefire")) {
logger.setLevel(level); // only set pulsefire code loggers
}
}
}
}
class UILogHandler extends Handler {
@Override
public void close() throws SecurityException {
}
@Override
public void flush() {
}
@Override
public void publish(LogRecord record) {
final String recordStr = getFormatter().format(record);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
logTextArea.append(recordStr);
if (logTextArea.getLineCount() > logLinesMax) {
String t = logTextArea.getText();
int l = 0;
int rm = logLinesMax/2;
for (int i=0;i<rm;i++) {
int ll = t.indexOf('\n',l+1);
if (ll==-1) {
break;
}
l = ll;
}
String tt = t.substring(l,t.length());
logTextArea.setText(tt);
}
if (autoScrollBox.isSelected()) {
logTextArea.setCaretPosition(logTextArea.getText().length());
}
}
});
}
}
}

View file

@ -1,377 +0,0 @@
/*
* 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.tech.core.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
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 net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.demo.tech.core.service.VascControllerService;
import net.forwardfire.vasc.demo.tech.core.service.VascControllerService.VascServiceListener;
import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration;
import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.test.i18n.VascBundleCheckEntryKeys;
/**
* JMainPanel is the main panel/window of this demo.
*
* @author Willem Cazander
* @version 1.0 May 12, 2012
*/
public class JMainPanel extends JPanel implements VascServiceListener {
private static final long serialVersionUID = 5834715323973411147L;
private VascControllerService vascManager = null;
private SwingPanelIntegration spi = null;
private JTabbedPane tabPane = null;
private JTree vascTree = null;
private JSplitPane bottomSplitPane = null;
private JSplitPane treeSplitPane = null;
public JMainPanel() {
this.vascManager=VascTechDemo.getInstance().getVascControllerService();
setLayout(new BorderLayout());
add(createBottomSplit(), BorderLayout.CENTER);
vascManager.addVascServiceListener(this);
}
private JSplitPane createBottomSplit() {
JSplitPane sp0 = createTreeSplit();
JPanel sp1 = new JConsolePanel();
bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,sp0,sp1);
bottomSplitPane.setOneTouchExpandable(true);
bottomSplitPane.setResizeWeight(0.2);
bottomSplitPane.setDividerLocation(700);
sp0.setMinimumSize(new Dimension(400, 400));
sp1.setMinimumSize(new Dimension(400, 150));
return bottomSplitPane;
}
private JSplitPane createTreeSplit() {
JScrollPane sp0 = createTreePane();
JScrollPane sp1 = createContentPane();
treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp0,sp1);
treeSplitPane.setOneTouchExpandable(true);
treeSplitPane.setResizeWeight(0.7);
treeSplitPane.setDividerLocation(200);
sp0.setMinimumSize(new Dimension(200, 400));
sp1.setMinimumSize(new Dimension(400, 400));
return treeSplitPane;
}
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 JScrollPane 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) {
VascEntryLocal ee = (VascEntryLocal)vascManager.getVascController().getVascEntryController().getVascEntryById(vascNode.id);
vascManager.getVascController().getVascEntryConfigController().configVascFrontendController(vascManager.getVascController(), ee);
spi.createNewVascView(ee);
}
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
}
});
JPanel treePanel = new JPanel();
treePanel.setLayout(new GridLayout(1,0));
JScrollPane p = createJScrollPane(treePanel);
p.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
p.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
treePanel.add(vascTree);
rebuildTree();
return p;
}
private JScrollPane createContentPane() {
JPanel contentPane = new JPanel();
contentPane.setLayout(new GridLayout(1,0));
JScrollPane p = createJScrollPane(contentPane);
tabPane = new JTabbedPane();
spi = new SwingPanelTabbed(tabPane);
contentPane.add(tabPane);
return p;
}
private JScrollPane createJScrollPane(JPanel innerPanel) {
JScrollPane scrollPane = new JScrollPane(innerPanel);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.getVerticalScrollBar().setUnitIncrement(10);
scrollPane.getHorizontalScrollBar().setUnitIncrement(10);
//innerPanel.setParentScrollPane(scrollPane);
return scrollPane;
}
class VascTreeNode implements Serializable {
private static final long serialVersionUID = -1177727401194030822L;
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,
FIELD_TYPE,
BACKEND,
ENTRY
}
public void rebuildTree() {
DefaultMutableTreeNode root = (DefaultMutableTreeNode)vascTree.getModel().getRoot();
root.removeAllChildren();
DefaultMutableTreeNode fieldTypes = new DefaultMutableTreeNode("VascFieldTypes");
for (String id:vascManager.getVascController().getVascEntryFieldTypeController().getVascEntryFieldTypeIds()) {
DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.FIELD_TYPE,id));
fieldTypes.add(typeNode);
}
root.add(fieldTypes);
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);
}
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);
// todo move
Map<String,String> keys = new HashMap<String,String>(300);
VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"));
for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) {
VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId);
keys.putAll(checker.generateMissingKeys(ve));
}
if (keys.isEmpty()==false) {
Properties p = new Properties();
File dataDir = new File("data");
if (dataDir.exists()==false) {
dataDir.mkdirs();
}
File resourceFile = new File("data/vasc-bundle.properties");
if (resourceFile.exists()) {
readPropertiesFile(p,resourceFile);
}
for (String key:keys.keySet()) {
if (key==null) {
continue;
}
if (keys.get(key)==null) {
continue;
}
p.put(key, keys.get(key));
}
writePropertiesFile(p,resourceFile);
ResourceBundle.clearCache();
}
}
public JTabbedPane getTabPane() {
return tabPane;
}
protected void writePropertiesFile(Properties p,File file) {
try {
writePropertiesStream(p,new FileOutputStream(file));
} catch (Exception e) {
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
}
}
protected void readPropertiesFile(Properties p,File file) {
try {
readPropertiesStream(p,new FileInputStream(file));
} catch (Exception e) {
throw new RuntimeException("Could not load resource file error: "+e.getMessage(),e);
}
}
protected void writePropertiesStream(Properties p,OutputStream out) {
try {
p.store(out, "Saved by vasc auto i18n.");
} catch (Exception e) {
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
} finally {
if (out!=null) {
try {
out.close();
} catch (IOException e) {
}
}
}
}
protected void readPropertiesStream(Properties p,InputStream in) {
try {
p.load(in);
} catch (Exception e) {
throw new RuntimeException("Could not load properties error: "+e.getMessage(),e);
} finally {
if (in!=null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
public void changeEvent() {
rebuildTree();
}
}

View file

@ -1,214 +0,0 @@
/*
* Copyright (c) 2011, Willem Cazander
* 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.tech.core.ui;
import java.awt.Component;
import java.awt.Container;
import javax.swing.Spring;
import javax.swing.SpringLayout;
/**
* SpringLayoutGrid, someone should create an JCP to get these functions into
* SpringLayout object because this code is to much duplicated on many projects.
*
* A 1.4 file that provides utility methods for creating form- or grid-style
* layouts with SpringLayout. These utilities are used by several programs, such
* as SpringBox and SpringCompactGrid.
*/
public class SpringLayoutGrid {
/**
* Aligns the first <code>rows</code>*<code>cols</code> components of
* <code>parent</code> in a grid. Each component is as big as the maximum
* preferred width and height of the components. The parent is made just big
* enough to fit them all.
*
* @param rows
* number of rows
* @param cols
* number of columns
* @param initialX
* x location to start the grid at
* @param initialY
* y location to start the grid at
* @param xPad
* x padding between cells
* @param yPad
* y padding between cells
*/
public static void makeGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
}
Spring xPadSpring = Spring.constant(xPad);
Spring yPadSpring = Spring.constant(yPad);
Spring initialXSpring = Spring.constant(initialX);
Spring initialYSpring = Spring.constant(initialY);
int max = rows * cols;
//Calculate Springs that are the max of the width/height so that all
//cells have the same size.
Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0))
.getWidth();
Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0))
.getWidth();
for (int i = 1; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(parent
.getComponent(i));
maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
}
//Apply the new width/height Spring. This forces all the
//components to have the same size.
for (int i = 0; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(parent
.getComponent(i));
cons.setWidth(maxWidthSpring);
cons.setHeight(maxHeightSpring);
}
//Then adjust the x/y constraints of all the cells so that they
//are aligned in a grid.
SpringLayout.Constraints lastCons = null;
SpringLayout.Constraints lastRowCons = null;
for (int i = 0; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(parent
.getComponent(i));
if (i % cols == 0) { //start of new row
lastRowCons = lastCons;
cons.setX(initialXSpring);
} else { //x position depends on previous component
cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
xPadSpring));
}
if (i / cols == 0) { //first row
cons.setY(initialYSpring);
} else { //y position depends on previous row
cons.setY(Spring.sum(lastRowCons
.getConstraint(SpringLayout.SOUTH), yPadSpring));
}
lastCons = cons;
}
//Set the parent's size.
SpringLayout.Constraints pCons = layout.getConstraints(parent);
pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring
.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
pCons.setConstraint(SpringLayout.EAST, Spring.sum(
Spring.constant(xPad), lastCons
.getConstraint(SpringLayout.EAST)));
}
/* Used by makeCompactGrid. */
private static SpringLayout.Constraints getConstraintsForCell(int row,
int col, Container parent, int cols) {
SpringLayout layout = (SpringLayout) parent.getLayout();
Component c = parent.getComponent(row * cols + col);
return layout.getConstraints(c);
}
public static void makeCompactGrid(Container parent, int rows, int cols) {
makeCompactGrid(parent,rows,cols,6,6,6,6);
}
/**
* Aligns the first <code>rows</code>*<code>cols</code> components of
* <code>parent</code> in a grid. Each component in a column is as wide as
* the maximum preferred width of the components in that column; height is
* similarly determined for each row. The parent is made just big enough to
* fit them all.
*
* @param rows
* number of rows
* @param cols
* number of columns
* @param initialX
* x location to start the grid at
* @param initialY
* y location to start the grid at
* @param xPad
* x padding between cells
* @param yPad
* y padding between cells
*/
public static void makeCompactGrid(Container parent, int rows, int cols,int initialX, int initialY, int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
throw new IllegalArgumentException("parent container has not StringLayout layoutmanager.");
}
//Align all cells in each column and make them the same width.
Spring x = Spring.constant(initialX);
for (int c = 0; c < cols; c++) {
Spring width = Spring.constant(0);
for (int r = 0; r < rows; r++) {
width = Spring.max(width, getConstraintsForCell(r, c, parent,
cols).getWidth());
}
for (int r = 0; r < rows; r++) {
SpringLayout.Constraints constraints = getConstraintsForCell(r,
c, parent, cols);
constraints.setX(x);
constraints.setWidth(width);
}
x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
}
//Align all cells in each row and make them the same height.
Spring y = Spring.constant(initialY);
for (int r = 0; r < rows; r++) {
Spring height = Spring.constant(0);
for (int c = 0; c < cols; c++) {
height = Spring.max(height, getConstraintsForCell(r, c, parent,
cols).getHeight());
}
for (int c = 0; c < cols; c++) {
SpringLayout.Constraints constraints = getConstraintsForCell(r,
c, parent, cols);
constraints.setY(y);
constraints.setHeight(height);
}
y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
}
//Set the parent's size.
SpringLayout.Constraints pCons = layout.getConstraints(parent);
pCons.setConstraint(SpringLayout.SOUTH, y);
pCons.setConstraint(SpringLayout.EAST, x);
}
}

View file

@ -1,112 +0,0 @@
/*
* 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.tech.core.ui.actions;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextCsv;
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
/**
* JDialogMetaCsv Add and runs MetaModel Schema Auto Entry code.
*
* @author Willem Cazander
* @version 1.0 May 9, 2012
*/
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());
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
schema.setDataContextProvider(ds);
schema.setEntryPrefix(file.getName());
schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController());
VascTechDemo.getInstance().getVascControllerService().fireChangeEvent();
}
}
});
result.add(fileButton);
return result;
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}

View file

@ -1,136 +0,0 @@
/*
* 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.tech.core.ui.actions;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextJdbc;
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.demo.tech.core.ui.SpringLayoutGrid;
/**
* JDialogMetaJdbc Add and runs MetaModel Schema Auto Entry code.
*
* @author Willem Cazander
* @version 1.0 May 9, 2012
*/
public class JDialogMetaJdbc extends JDialog implements ActionListener {
private static final long serialVersionUID = -8638394652416472734L;
private JComboBox driverClassBox = null;
private JTextField connectUrlField = null;
private JTextField usernameField = null;
private JTextField passwordField = null;
public JDialogMetaJdbc(Frame aFrame) {
setTitle("Add jdbc");
setMinimumSize(new Dimension(300,200));
setPreferredSize(new Dimension(500,400));
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("Driver"));
driverClassBox = new JComboBox(new String[] {"org.postgresql.Driver","com.mysql.jdbc.Driver","org.apache.derby.jdbc.EmbeddedDriver","org.hsqldb.jdbcDriver","org.sqlite.JDBC"});
driverClassBox.setSelectedIndex(0);
result.add(driverClassBox);
result.add(new JLabel("Url"));
connectUrlField = new JTextField("jdbc:postgresql://localhost/dellstore2");
result.add(connectUrlField);
result.add(new JLabel("Username"));
usernameField = new JTextField("postgres");
result.add(usernameField);
result.add(new JLabel("Password"));
passwordField = new JTextField("postgresql");
result.add(passwordField);
JButton fileButton = new JButton("Connect");
fileButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String url = connectUrlField.getText();
MetaModelDataContextJdbc ds = new MetaModelDataContextJdbc();
ds.setDriverClass((String)driverClassBox.getSelectedItem());
ds.setConnectUrl(url);
ds.setUsername(usernameField.getText());
ds.setPassword(passwordField.getText());
String dbName = url.substring(url.lastIndexOf('/')+1,url.length());
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
schema.setDataContextProvider(ds);
schema.setEntryPrefix(dbName);
schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController());
VascTechDemo.getInstance().getVascControllerService().fireChangeEvent();
}
});
result.add(fileButton);
result.add(new JLabel(""));
SpringLayoutGrid.makeCompactGrid(result, 5, 2);
return result;
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}

View file

@ -1,126 +0,0 @@
/*
* 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.tech.core.ui.actions;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import net.forwardfire.vasc.backend.metamodel.MetaModelDataContextMongodb;
import net.forwardfire.vasc.backend.metamodel.MetaModelSchemaAutoEntry;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.demo.tech.core.ui.SpringLayoutGrid;
/**
* JDialogMetaMongodb Add and runs MetaModel Schema Auto Entry code.
*
* @author Willem Cazander
* @version 1.0 May 9, 2012
*/
public class JDialogMetaMongodb extends JDialog implements ActionListener {
private static final long serialVersionUID = -8638394652416472734L;
private JTextField hostNameField = null;
private JTextField hostPortField = null;
private JTextField databaseField = null;
public JDialogMetaMongodb(Frame aFrame) {
setTitle("Add mongodb");
setMinimumSize(new Dimension(300,200));
setPreferredSize(new Dimension(400,300));
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"));
hostNameField = new JTextField("localhost");
result.add(hostNameField);
result.add(new JLabel("Port"));
hostPortField = new JTextField("27017");
result.add(hostPortField);
result.add(new JLabel("Database"));
databaseField = new JTextField("lefiona");
result.add(databaseField);
JButton fileButton = new JButton("Connect");
fileButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MetaModelDataContextMongodb ds = new MetaModelDataContextMongodb();
ds.setHostname(hostNameField.getText());
ds.setPort(new Integer(hostPortField.getText()));
ds.setDatabase(databaseField.getText());
MetaModelSchemaAutoEntry schema = new MetaModelSchemaAutoEntry();
schema.setDataContextProvider(ds);
schema.setEntryPrefix(ds.getDatabase());
schema.autoCreateEntries(VascTechDemo.getInstance().getVascControllerService().getVascController());
VascTechDemo.getInstance().getVascControllerService().fireChangeEvent();
}
});
result.add(fileButton);
result.add(new JLabel(""));
SpringLayoutGrid.makeCompactGrid(result, 4, 2);
return result;
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}

View file

@ -1,103 +0,0 @@
/*
* 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.tech.core.x4o.vasc;
import java.util.Map;
import java.util.logging.Logger;
import net.forwardfire.vasc.demo.tech.core.VascTechDemo;
import net.forwardfire.vasc.demo.tech.core.service.tomcat.TomcatService;
import org.apache.catalina.Server;
import org.apache.catalina.deploy.ContextResource;
import org.apache.catalina.deploy.NamingResources;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
/**
* TomcatResourceElement Add a global DataSource to tomcat jndi context.
*
* @author Willem Cazander
* @version 1.0 May 13, 2012
*/
public class TomcatResourceElement extends AbstractElement {
private Logger logger = Logger.getLogger(TomcatResourceElement.class.getName());
/**
* @see org.x4o.xml.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
// Check needed attributes
Map<String,String> attr = getAttributes();
if (attr.containsKey("name")==false) {
throw new ElementException("No attribute name found.");
}
if (attr.containsKey("auth")==false) {
throw new ElementException("No attribute auth found.");
}
if (attr.containsKey("type")==false) {
throw new ElementException("No attribute type found.");
}
// Set resource object fields.
ContextResource resource = new ContextResource();
String name = attr.remove("name");
resource.setName(name);
String auth = attr.remove("auth");
resource.setAuth(auth);
String type = attr.remove("type");
resource.setType(type);
String scope = attr.remove("scope");
if (scope!=null) {
resource.setScope(scope);
}
String closeMethod = attr.remove("closeMethod");
if (closeMethod!=null) {
resource.setCloseMethod(closeMethod);
}
String singleton = attr.remove("singleton");
if (singleton!=null) {
resource.setSingleton("true".equalsIgnoreCase(singleton));
}
String description = attr.remove("description");
if (description!=null) {
resource.setDescription(description);
}
// copy other stuff
for (String key:attr.keySet()) {
String value = attr.get(key);
resource.setProperty(key, value);
}
// add to tomcat
TomcatService tm = VascTechDemo.getInstance().getTomcatService();
Server server = tm.getServer();
NamingResources jndiContext = server.getGlobalNamingResources();
jndiContext.addResource(resource);
logger.info("Added jndi global resource: "+resource.getName());
}
}

View file

@ -1,11 +0,0 @@
config.charset=UTF-8
config.bundles=bundle1,bundle2
# bundle list to merge and load
bundle1.uri=net.forwardfire.vasc.demo.tech.core.ui.resources.JApplication
bundle2.uri=data/vasc-bundle.properties
bundle2.type=FILE
bundle2.optional=true

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
<eld:elementClass tag="tomcatResource" elementClassName="net.forwardfire.vasc.demo.tech.core.x4o.vasc.TomcatResourceElement"/>
</eld:root>

View file

@ -1,136 +0,0 @@
--
-- Create vasc demo database.
--
CREATE TABLE vasc_user (
id IDENTITY not null primary key,
username varchar not null,
password varchar not null,
description varchar not null,
);
CREATE UNIQUE INDEX vasc_user_username_idx ON vasc_user(username);
CREATE TABLE vasc_user_role (
id IDENTITY not null primary key,
username varchar not null,
role varchar not null
);
CREATE INDEX vasc_user_role_username_idx ON vasc_user_role(username);
CREATE TABLE vasc_user_change_field (
id IDENTITY not null primary key,
field varchar not null,
name varchar not null,
active boolean not null
);
CREATE INDEX vasc_user_change_field_active_idx ON vasc_user_change_field(active);
CREATE TABLE vasc_user_change_log (
id IDENTITY not null primary key,
user_id integer not null,
change_field_id integer not null,
value_old varchar not null,
value_new varchar not null
);
CREATE INDEX vasc_user_change_log_user_id_idx ON vasc_user_change_log(user_id);
CREATE INDEX vasc_user_change_log_id_idx ON vasc_user_change_log(user_id);
CREATE TABLE vasc_page (
id IDENTITY not null primary key,
slug varchar not null,
title varchar not null,
i18n_key boolean not null,
active boolean not null,
sitemap boolean not null,
roles varchar not null
);
CREATE INDEX vasc_page_slug_idx ON vasc_page(slug);
CREATE INDEX vasc_page_sitemap_idx ON vasc_page(sitemap);
CREATE TABLE vasc_page_part (
id IDENTITY not null primary key,
page_id integer not null,
title varchar not null,
text varchar not null,
i18n_key boolean not null,
active boolean not null,
sitemap boolean not null,
part_order integer not null,
part_type varchar not null,
roles varchar not null
);
CREATE INDEX vasc_page_part_page_id_idx ON vasc_page_part(page_id);
CREATE INDEX vasc_page_part_active_idx ON vasc_page_part(active);
CREATE INDEX vasc_page_part_sitemap_idx ON vasc_page_part(sitemap);
CREATE TABLE vasc_menu (
id IDENTITY not null primary key,
href varchar not null,
title varchar not null,
target varchar not null,
active BOOLEAN NOT NULL,
roles varchar not null,
menu_order integer not null,
menu_type varchar not null
);
CREATE INDEX vasc_menu_active_idx ON vasc_menu(active);
CREATE INDEX vasc_menu_type_idx ON vasc_menu(menu_type);
--
-- Insert demo data.
--
INSERT INTO vasc_user VALUES(1, 'admin','admin123','Demo Admin user');
INSERT INTO vasc_user VALUES(2, 'demo', 'demo123', 'Demo user');
INSERT INTO vasc_user_role VALUES(1, 'admin', 'login');
INSERT INTO vasc_user_role VALUES(2, 'admin', 'admin');
INSERT INTO vasc_user_role VALUES(3, 'demo', 'login');
INSERT INTO vasc_user_change_field VALUES(1,'Username', 'username', TRUE);
INSERT INTO vasc_user_change_field VALUES(2,'Password', 'password', TRUE);
INSERT INTO vasc_user_change_field VALUES(3,'Description', 'description', TRUE);
INSERT INTO vasc_user_change_field VALUES(4,'Birthdate', 'date_age', TRUE);
-- ID SLUG TITLE I18N ACTIVE SITEMAP
INSERT INTO vasc_page VALUES(4, 'debug', 'Debug', FALSE, TRUE, FALSE);
INSERT INTO vasc_page VALUES(5, 'contact', '', TRUE, TRUE, TRUE);
INSERT INTO vasc_page VALUES(6, 'help', '', TRUE, TRUE, TRUE);
INSERT INTO vasc_page_part VALUES(1, 4, 'vasc', '', TRUE,TRUE,TRUE,1,'HTML');
INSERT INTO vasc_page_part VALUES(2, 4, 'jdbc', '', TRUE,TRUE,TRUE,2,'HTML');
INSERT INTO vasc_page_part VALUES(3, 4, 'jndi', '', TRUE,TRUE,TRUE,3,'HTML');
INSERT INTO vasc_page_part VALUES(4, 4, 'logback', '', TRUE,TRUE,TRUE,3,'HTML');
INSERT INTO vasc_page_part VALUES(5, 5, 'project', '', TRUE,TRUE,TRUE,1,'WIKI');
INSERT INTO vasc_page_part VALUES(6, 5, 'support', '', TRUE,TRUE,TRUE,2,'WIKI');
INSERT INTO vasc_page_part VALUES(7, 5, 'location', '', TRUE,TRUE,TRUE,3,'HTML');
INSERT INTO vasc_page_part VALUES(8, 6, 'server', '', TRUE,TRUE,TRUE,1,'WIKI');
INSERT INTO vasc_page_part VALUES(9, 6, 'vasc', '', TRUE,TRUE,TRUE,2,'WIKI');
INSERT INTO vasc_page_part VALUES(10,6, 'metamodel','', TRUE,TRUE,TRUE,3,'WIKI');
-- INSERT INTO vasc_page VALUES(1, 'home','home','Welcome to the vasc demo, please login as admin to view all stuff.');
INSERT INTO vasc_menu VALUES(1, '/html/index.jsf','Home','',true,'',1,'BAR_RIGHT');
INSERT INTO vasc_menu VALUES(2, '/html/admin/debug.jsf','Debug','',true,'admin',2,'BAR_RIGHT');
INSERT INTO vasc_menu VALUES(3, '/html/admin/index.jsf','Admin','',true,'admin',3,'BAR_RIGHT');
INSERT INTO vasc_menu VALUES(4, '/html/index.jsf','Home', '',true,'',1,'BAR_BOTTOM');
INSERT INTO vasc_menu VALUES(5, '/html/index.jsf','Contact', '',true,'',2,'BAR_BOTTOM');
INSERT INTO vasc_menu VALUES(6, '/html/index.jsf','Help', '',true,'',3,'BAR_BOTTOM');
INSERT INTO vasc_menu VALUES(7, '/html/index.jsf','Techno', '',true,'',3,'BAR_BOTTOM');
INSERT INTO vasc_menu VALUES(8, '/html/index.jsf','Licences', '',true,'',3,'BAR_BOTTOM');
INSERT INTO vasc_menu VALUES(10, '/vasc/AdminVascUser/list.jsf', 'Users', '',true,'admin',4,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(11, '/vasc/AdminVascUserRole/list.jsf', 'UserRoles', '',true,'admin',5,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(12, '/vasc/AdminVascUserChangeField/list.jsf', 'ChangeField', '',true,'admin',5,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(13, '/vasc/AdminVascUserChangeLog/list.jsf', 'ChangeFieldLog', '',true,'admin',5,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(14, '/vasc/AdminVascPage/list.jsf', 'Pages', '',true,'admin',5,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(15, '/vasc/AdminVascPagePart/list.jsf', 'PageParts', '',true,'admin',5,'PAGE_ADMIN');
INSERT INTO vasc_menu VALUES(16, '/vasc/AdminVascMenu/list.jsf', 'Menu', '',true,'admin',4,'PAGE_ADMIN');

View file

@ -1,148 +0,0 @@
#
# Copyright (c) 2011, Willem Cazander
# 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.
#
# Application's properties
Application.name = Vasc Demo Tech
Application.title = VascDemoTech
Application.vendor = Willem Cazander
Application.homepage = http://vasc.forwardfire.org/
Application.vendorId = vasc
Application.id = vascdemotech
Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
#Application.icon = images/icon.png
Application.web.meta.robots = index, follow
Application.web.meta.description = Vasc Tech Demo Web Frontends
Application.web.meta.keywords = demo,forwardfire,x4o,vasc,java
Application.web.header.logo.alt = Vasc Tech Demo Logo
Application.web.header.login = Login
Application.web.header.logout = Logout
Application.web.footer.center = Vasc Tech Demo Web Based on JSF and Faclets and Richfaces.
Application.web.footer.left = Copyright &copy; 2012
Application.web.footer.right = Version 0.4.x<i>(beta)</i>
generic.active.labelText = active
generic.active.toolTipText = active
generic.createdDate.labelText = createdDate
generic.createdDate.toolTipText = createdDate
generic.description.labelText = description
generic.description.toolTipText = description
generic.id.labelText = id
generic.id.toolTipText = id
generic.modifiedDate.labelText = modifiedDate
generic.modifiedDate.toolTipText = modifiedDate
generic.name.labelText = name
generic.name.toolTipText = name
generic.orderNumber.labelText = orderNumber
generic.orderNumber.toolTipText = orderNumber
# hibernate validators
validator.assertFalse=assertion failed
validator.assertTrue=assertion failed
validator.future=Date must lie in the future
validator.length=Field must contain between {min} and {max} characters.
validator.max=Value must be equal to or lower than {value}
validator.min=Value must be equal to or higher than {value}
validator.notNull=A value must be entered
validator.past=Date must lie in the future
validator.pattern=Value must conform to "{regex}"
validator.range=Value must lie between {min} and {max}
validator.size=There must be between {min} and {max} characters
validator.email=The value must be a valid e-mail address
# vasc validators
vasc.validator.VascDateFutureValidator=The date must lie in the future.
vasc.validator.VascDatePastValidator=The date must lie in the past.
vasc.validator.VascIntSizeValidator=Value must lie between {0} and {1}
vasc.validator.VascLongSizeValidator=Value must lie between {0} and {1}
vasc.validator.VascObjectNotNullValidator=A value must be entered
vasc.validator.VascObjectNullValidator=No value may be entered
vasc.validator.VascStringEmailValidator=The value must be a valid e-mail address
vasc.validator.VascStringLengthValidator=There must be at least {0} and at most {1} items
vasc.validator.VascStringRegexValidator=Value must conform to "{0}"
vasc.validator.VascStringZipCodeValidator=Value must be a valid post code.
# Vasc actions labels
vasc.action.addRowAction.description = add a new record
vasc.action.addRowAction.name = Add
vasc.action.deleteRowAction.description = delete
vasc.action.deleteRowAction.name = delete
vasc.action.downloadAction.description = Select this record.
vasc.action.downloadAction.name = Select
vasc.action.editRowAction.description = edit
vasc.action.editRowAction.name = Edit
vasc.action.csvExportAction.description = CSV
vasc.action.csvExportAction.name = CSV
vasc.action.xmlExportAction.description = XML
vasc.action.xmlExportAction.name = XML
vasc.action.xmltreeExportAction.description = XMLTree
vasc.action.xmltreeExportAction.name = XMLTree
vasc.action.jrPdfLandscapeExportAction.description = jrPdfLandscape
vasc.action.jrPdfLandscapeExportAction.name = PDF-Landscape
vasc.action.jrPdfPortraitExportAction.description = jrPdfPortrait
vasc.action.jrPdfPortraitExportAction.name = PDF-Portrait
vasc.action.jrRtfExportAction.description = RTF
vasc.action.jrRtfExportAction.name = RTF
vasc.action.jrXlsExportAction.description = XLS
vasc.action.jrXlsExportAction.name = XLS
vasc.action.jrXmlExportAction.description = JR-XML
vasc.action.jrXmlExportAction.name = JR-XML
vasc.action.jrCsvExportAction.description = JR-CSV
vasc.action.jrCsvExportAction.name = JR-CSV
# Temp jsf
generic.vasc.jsf.listOption.header = Searchoptions
generic.vasc.jsf.listOption.search = Searh\:
generic.vasc.jsf.listOption.sumbit = Search
generic.vasc.jsf.pager.previous = Previous
generic.vasc.jsf.pager.next = Next
generic.vasc.jsf.table.rows = Row Numbers\:
generic.vasc.jsf.table.pagerDirect = Go to\:
generic.vasc.jsf.table.downloadDirect = Download\:
generic.vasc.jsf.table.resultText = Results {0}-{1} from {2} rows
generic.vasc.jsf.table.download.img = Save table data.
generic.vasc.jsf.table.printer.img = Shows the table in printer friendly format.
generic.vasc.jsf.table.export.select = ...
generic.vasc.jsf.table.export.select.alt = Select Export
generic.vasc.jsf.table.page.select = ...
generic.vasc.jsf.table.page.select.alt = Select Page
generic.vasc.jsf.table.page.name = Page:
generic.vasc.jsf.table.page.description = Goto page:
generic.vasc.jsf.tableHeader.fields = Fields
generic.vasc.jsf.tableHeader.links = Links
generic.vasc.jsf.tableHeader.actions = Actions
generic.vasc.jsf.multiAction.selectAll = Select all:
generic.vasc.jsf.multiAction.name = ...
generic.vasc.jsf.multiAction.description = Select Action
generic.vasc.jsf.action.save = Save
generic.vasc.jsf.action.cancel = Cancel
generic.vasc.jsf.action.back = Back
generic.vasc.jsf.parentSelected = Selected:
vasc.dialog.edit.message = Edit
vasc.dialog.save.name = Save
vasc.dialog.cancel.name = Cancel

View file

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vasc-demo-tech-build</name>
<name>vasc-demo-tech-ejb3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -12,6 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech</artifactId>
<version>0.4.1-SNAPSHOT</version>
</parent>
<artifactId>vasc-demo-tech-ejb3</artifactId>
<name>vasc-demo-tech-ejb3</name>
<description>vasc-demo-tech-ejb3</description>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,17 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import java.util.List;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
public interface VascMenuController {
List<VascMenuWeb> getFilteredMenuWeb(VascMenuWebType type);
List<VascMenuGroup> getFilteredMenuGroup();
List<VascMenu> getFilteredMenu(String groupId);
}

View file

@ -0,0 +1,280 @@
/*
* Copyright 2009-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.tech.ejb3.menu;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroupComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
/**
* MenuController Shows the menu for the user.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuControllerRemote {
private VascMenuWebComparator vascMenuWebComparator = null;
private VascMenuGroupComparator vascMenuGroupComparator = null;
private VascMenuComparator vascMenuComparator = null;
@Resource
private SessionContext session;
public VascMenuControllerImpl() {
vascMenuWebComparator = new VascMenuWebComparator();
vascMenuGroupComparator = new VascMenuGroupComparator();
vascMenuComparator = new VascMenuComparator();
}
public List<VascMenuWeb> fetchVascMenuWeb() {
List<VascMenuWeb> result = new ArrayList<VascMenuWeb>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU_WEB");
ResultSet rs = s.getResultSet();
//int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
VascMenuWeb menu = new VascMenuWeb();
menu.setId(rs.getInt(1));
menu.setHref(rs.getString(2));
menu.setTitle(rs.getString(3));
menu.setTarget(rs.getString(4));
menu.setActive(rs.getBoolean(5));
menu.setRoles(rs.getString(6));
menu.setMenuOrder(rs.getInt(7));
menu.setMenuType(VascMenuWebType.valueOf(rs.getString(8)));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
public List<VascMenuGroup> fetchVascMenuGroup() {
List<VascMenuGroup> result = new ArrayList<VascMenuGroup>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU_GROUP");
ResultSet rs = s.getResultSet();
while (rs.next()) {
VascMenuGroup menu = new VascMenuGroup();
menu.setId(rs.getString(1));
menu.setTitle(rs.getString(2));
menu.setActive(rs.getBoolean(3));
menu.setRoles(rs.getString(4));
menu.setMenuOrder(rs.getInt(5));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
public List<VascMenu> fetchVascMenu() {
List<VascMenu> result = new ArrayList<VascMenu>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU");
ResultSet rs = s.getResultSet();
while (rs.next()) {
VascMenu menu = new VascMenu();
menu.setId(rs.getInt(1));
menu.setVascEntryId(rs.getString(2));
menu.setTitle(rs.getString(3));
menu.setActive(rs.getBoolean(4));
menu.setRoles(rs.getString(5));
menu.setMenuOrder(rs.getInt(6));
menu.setMenuGroup(rs.getString(7));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
private DataSource getDataSource(String name) throws SQLException {
try {
Context initialContext = new InitialContext();
DataSource datasource = (DataSource)initialContext.lookup(name);
if ( datasource == null ) {
throw new SQLException("Cannot lookup datasource: "+name);
}
return datasource;
} catch ( NamingException e ) {
throw new SQLException("Cannot get connection " + e,e);
}
}
private boolean filterVascMenuRoles(Boolean active,String roles) {
if (active!=null && active==false) {
return false;
}
if (roles!=null && roles.isEmpty()==false) {
String[] rolesArray = roles.split(",");
for (String role:rolesArray) {
if (role.isEmpty()) {
continue;
}
if (session.isCallerInRole(role)==false) {
return false;
}
}
}
return true;
}
public List<VascMenuGroup> getFilteredMenuGroup() {
List<VascMenuGroup> result = fetchVascMenuGroup();
for (VascMenuGroup group:result) {
group.setMenus(getFilteredMenu(group.getId()));
}
Collections.sort(result,vascMenuGroupComparator);
return result;
}
public List<VascMenu> getFilteredMenu(String groupId) {
if (groupId==null) {
throw new NullPointerException("Can't filter on null groupId.");
}
List<VascMenu> result = new ArrayList<VascMenu>(15);
for (VascMenu menu:fetchVascMenu()) {
if (groupId.equals(menu.getMenuGroup())) {
result.add(menu);
}
}
Collections.sort(result,vascMenuComparator);
return result;
}
public List<VascMenuWeb> getFilteredMenuWeb(VascMenuWebType type) {
if (type==null) {
throw new NullPointerException("Can't filter on null type.");
}
List<VascMenuWeb> result = new ArrayList<VascMenuWeb>(15);
for (VascMenuWeb menu:fetchVascMenuWeb()) {
if (type.equals(menu.getMenuType())) {
result.add(menu);
}
}
Collections.sort(result,vascMenuWebComparator);
return result;
}
private List<VascMenuWeb> getMenuFiltered(VascMenuWebType type) {
return getFilteredMenuWeb(type);
}
public List<VascMenuWeb> getMenuBarLeft() {
return getMenuFiltered(VascMenuWebType.BAR_LEFT);
}
public List<VascMenuWeb> getMenuBarRight() {
return getMenuFiltered(VascMenuWebType.BAR_RIGHT);
}
public List<VascMenuWeb> getMenuBarBottom() {
return getMenuFiltered(VascMenuWebType.BAR_BOTTOM);
}
public List<VascMenuWeb> getMenuPageIndex() {
return getMenuFiltered(VascMenuWebType.PAGE_INDEX);
}
public List<VascMenuWeb> getMenuPageUserLeft() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT);
}
public List<VascMenuWeb> getMenuPageUserRight() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT);
}
public List<VascMenuWeb> getMenuPageAdmin() {
return getMenuFiltered(VascMenuWebType.PAGE_ADMIN);
}
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import javax.ejb.Local;
@Local
public interface VascMenuControllerLocal extends VascMenuController {
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import javax.ejb.Remote;
@Remote
public interface VascMenuControllerRemote extends VascMenuController {
}

View file

@ -20,7 +20,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.web.menu.model;
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
/**
* VascMenu stores menu item information.
@ -28,16 +30,16 @@ package net.forwardfire.vasc.demo.tech.web.menu.model;
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenu {
public class VascMenu implements Serializable {
private static final long serialVersionUID = 5087600835051760512L;
private Integer id = null;
private String href = null;
private String vascEntryId = null;
private String title = null;
private String target = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private VascMenuType menuType = null;
private String menuGroup = null;
/**
* @return the id
@ -54,19 +56,19 @@ public class VascMenu {
}
/**
* @return the href
* @return the vascEntryId
*/
public String getHref() {
return href;
public String getVascEntryId() {
return vascEntryId;
}
/**
* @param href the href to set
* @param vascEntryId the vascEntryId to set
*/
public void setHref(String href) {
this.href = href;
public void setVascEntryId(String vascEntryId) {
this.vascEntryId = vascEntryId;
}
/**
* @return the title
*/
@ -81,20 +83,6 @@ public class VascMenu {
this.title = title;
}
/**
* @return the target
*/
public String getTarget() {
return target;
}
/**
* @param target the target to set
*/
public void setTarget(String target) {
this.target = target;
}
/**
* @return the active
*/
@ -136,18 +124,18 @@ public class VascMenu {
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menuType
* @return the menuGroup
*/
public VascMenuType getMenuType() {
return menuType;
public String getMenuGroup() {
return menuGroup;
}
/**
* @param menuType the menuType to set
* @param menuGroup the menuGroup to set
*/
public void setMenuType(VascMenuType menuType) {
this.menuType = menuType;
public void setMenuGroup(String menuGroup) {
this.menuGroup = menuGroup;
}
}

View file

@ -20,19 +20,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.web.menu;
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu;
/**
* VascMenuComparator orders the menu items.
* VascMenuComparator orders the menu group.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
* @version 1.0 nov 17, 2012
*/
public class VascMenuComparator implements Serializable,Comparator<VascMenu> {

View file

@ -0,0 +1,127 @@
/*
* Copyright 2009-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.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.List;
/**
* VascMenuGroup stores menu header item information.
*
* @author Willem Cazander
* @version 1.0 Nov 21, 2012
*/
public class VascMenuGroup implements Serializable {
private static final long serialVersionUID = -9154803561816570868L;
private String id = null;
private String title = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private List<VascMenu> menus = null;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roles
*/
public String getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(String roles) {
this.roles = roles;
}
/**
* @return the menuOrder
*/
public Integer getMenuOrder() {
return menuOrder;
}
/**
* @param menuOrder the menuOrder to set
*/
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menus
*/
public List<VascMenu> getMenus() {
return menus;
}
/**
* @param menus the menus to set
*/
public void setMenus(List<VascMenu> menus) {
this.menus = menus;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2009-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.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
/**
* VascMenuGroupComparator orders the menu group.
*
* @author Willem Cazander
* @version 1.0 nov 17, 2012
*/
public class VascMenuGroupComparator implements Serializable,Comparator<VascMenuGroup> {
private static final long serialVersionUID = 386631856823832371L;
public int compare(VascMenuGroup m1, VascMenuGroup m2) {
if (m1.getMenuOrder()==null) {
return 1;
}
if (m2.getMenuOrder()==null) {
return -1;
}
return m1.getMenuOrder().compareTo(m2.getMenuOrder());
}
}

View file

@ -0,0 +1,156 @@
/*
* Copyright 2009-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.tech.ejb3.menu.model;
import java.io.Serializable;
/**
* VascMenu stores menu item information.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenuWeb implements Serializable {
private static final long serialVersionUID = -4650021226959950898L;
private Integer id = null;
private String href = null;
private String title = null;
private String target = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private VascMenuWebType menuType = 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 href
*/
public String getHref() {
return href;
}
/**
* @param href the href to set
*/
public void setHref(String href) {
this.href = href;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the target
*/
public String getTarget() {
return target;
}
/**
* @param target the target to set
*/
public void setTarget(String target) {
this.target = target;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roles
*/
public String getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(String roles) {
this.roles = roles;
}
/**
* @return the menuOrder
*/
public Integer getMenuOrder() {
return menuOrder;
}
/**
* @param menuOrder the menuOrder to set
*/
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menuType
*/
public VascMenuWebType getMenuType() {
return menuType;
}
/**
* @param menuType the menuType to set
*/
public void setMenuType(VascMenuWebType menuType) {
this.menuType = menuType;
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
* Copyright 2009-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:
@ -20,39 +20,30 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.core.service;
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import javax.swing.JTabbedPane;
import java.io.Serializable;
import java.util.Comparator;
import net.forwardfire.vasc.demo.tech.core.ui.JApplication;
import net.forwardfire.vasc.demo.tech.core.ui.JMainPanel;
import org.jdesktop.application.Application;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;
/**
* SwingGuiService Shows the demo swing gui and vasc swing frontend.
* VascMenuComparator orders the menu items.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class SwingGuiService {
public void start() {
Application.launch(JApplication.class, new String[] {});
}
public class VascMenuWebComparator implements Serializable,Comparator<VascMenuWeb> {
public void stop() {
}
private static final long serialVersionUID = 386631856823832371L;
// move
public JTabbedPane getTabPane() {
SingleFrameApplication a = (SingleFrameApplication)JApplication.getInstance(); // BIG NOTE because of 'launch' for auto conf swing.
FrameView mainView = a.getMainView();
JMainPanel mainPanel = (JMainPanel)mainView.getComponent();
return mainPanel.getTabPane();
public int compare(VascMenuWeb m1, VascMenuWeb m2) {
if (m1.getMenuOrder()==null) {
return 1;
}
if (m2.getMenuOrder()==null) {
return -1;
}
return m1.getMenuOrder().compareTo(m2.getMenuOrder());
}
}
}

View file

@ -20,7 +20,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.web.menu.model;
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
/**
* VascMenuType defines all menu lists on page.
@ -28,16 +28,12 @@ package net.forwardfire.vasc.demo.tech.web.menu.model;
* @author Willem Cazander
* @version 1.0 May 26, 2012
*/
public enum VascMenuType {
public enum VascMenuWebType {
BAR_LEFT,
BAR_RIGHT,
BAR_BOTTOM,
MENU0,
MENU1,
MENU2,
PAGE_INDEX,
PAGE_USER_LEFT,
PAGE_USER_RIGHT,

View file

@ -0,0 +1,21 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import javax.ejb.Remote;
public interface LoginUserController {
public String doClientLogin();
/*
public void doClientLogout();
public User getUser() throws Exception;
public List<RightRole> getClientRoles() throws Exception;
*/
}

View file

@ -0,0 +1,57 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.annotation.Resource;
import javax.annotation.security.RolesAllowed;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
@Stateless(name="loginUserController")
public class LoginUserControllerImpl implements LoginUserControllerLocal,LoginUserControllerRemote {
@Resource
private SessionContext session;
/**
* Tests for the login role
*/
@RolesAllowed("login")
public String doClientLogin() {
String name = session.getCallerPrincipal().getName();
return name;
/*
User u = null;
try {
u = getUser();
} catch (Exception e) {
throw new IllegalStateException("Could not lookup showplanner user from username: "+session.getCallerPrincipal().getName());
}
UserSession us = new UserSession();
us.setLoginDate(new Date());
us.setLogoutDate(null); // set when doing doClientLogout();
try {
Query q2 = xtesManager.getQuery("users.xml", "getUserSessionStatusByStatusKey");
q2.setQueryParameter("status_key", "success");
q2.setProperty("limit", 1);
UserSessionStatus userSessionStatus = (UserSessionStatus)xtesManager.executeObject(q2);
us.setUserSessionStatus(userSessionStatus);
} catch (Exception e) {
throw new IllegalStateException("Could not lookup session status of success.");
}
// current_time_in_secs + str_to_int(username)*10E20
long timeSS = us.getLoginDate().getTime();
int userSS = hashUserName(u.getUsername());
int modSS = 10230;
long sessionId = timeSS+userSS*modSS;
us.setSessionId(sessionId);
//System.out.println("Created sessionId: timeSS: "+timeSS+" userSS: "+userSS+" modSS: "+modSS);
us.setUser(u);
entityManager.persist(us);
return u.getUsername();
*/
}
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.ejb.Local;
@Local
public interface LoginUserControllerLocal extends LoginUserController {
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.ejb.Remote;
@Remote
public interface LoginUserControllerRemote extends LoginUserController {
}

View file

@ -0,0 +1,17 @@
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<!--
<enterprise-beans>
<session>
<ejb-name>loginUserController</ejb-name>
<business-local>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserController$ILocal</business-local>
<business-remote>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserController$ILocal</business-remote>
<ejb-class>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserControllerImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
-->
</ejb-jar>

View file

@ -3,7 +3,7 @@
<parent>
<artifactId>vasc-demo-tech</artifactId>
<groupId>net.forwardfire.vasc.demo</groupId>
<version>0.3.5-SNAPSHOT</version>
<version>0.4.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>vasc-demo-tech-web</artifactId>
@ -33,18 +33,32 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech-ejb3</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-xpql-ejb3-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.forwardfire.vasc</groupId>
<artifactId>vasc-core-ejb3-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>${javax.faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>

View file

@ -18,7 +18,7 @@ public class ExportController {
public ExportController() {
try {
JndiVascControllerProvider p = new JndiVascControllerProvider();
p.setJndiName("java:comp/env/vasc/DemoVascController");
p.setJndiName("java:comp/env/vasc/server-tech");
vascController = p.getVascController();
} catch (Exception e) {
e.printStackTrace();

View file

@ -0,0 +1,125 @@
/*
* Copyright 2009-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.tech.web.beans;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuController;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
/**
* MenuController Shows the menu for the user.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class MenuController implements Serializable {
private static final long serialVersionUID = -6820749860984575869L;
private List<VascMenuWeb> userVascMenu = null;
private UserController userController = null;
private VascMenuController vascMenuController = null;
private void init() {
// RM ME
if (vascMenuController==null) {
try {
InitialContext ctx = new InitialContext();
vascMenuController = (VascMenuController)ctx.lookup("java:app/demo/vascMenuController");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private List<VascMenuWeb> getMenuFiltered(VascMenuWebType type) {
init();
return vascMenuController.getFilteredMenuWeb(type);
}
public List<VascMenuGroup> getVascMenuGroup() {
init();
List<VascMenuGroup> result = vascMenuController.getFilteredMenuGroup();
return result;
}
public List<VascMenuWeb> getMenuBarLeft() {
return getMenuFiltered(VascMenuWebType.BAR_LEFT);
}
public List<VascMenuWeb> getMenuBarRight() {
return getMenuFiltered(VascMenuWebType.BAR_RIGHT);
}
public List<VascMenuWeb> getMenuBarBottom() {
return getMenuFiltered(VascMenuWebType.BAR_BOTTOM);
}
public List<VascMenuWeb> getMenuPageIndex() {
return getMenuFiltered(VascMenuWebType.PAGE_INDEX);
}
public List<VascMenuWeb> getMenuPageUserLeft() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT);
}
public List<VascMenuWeb> getMenuPageUserRight() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT);
}
public List<VascMenuWeb> getMenuPageAdmin() {
return getMenuFiltered(VascMenuWebType.PAGE_ADMIN);
}
/**
* @return the userController
*/
public UserController getUserController() {
return userController;
}
/**
* @param userController the userController to set
*/
public void setUserController(UserController userController) {
this.userController = userController;
}
}

View file

@ -24,11 +24,15 @@ package net.forwardfire.vasc.demo.tech.web.beans;
import java.io.IOException;
import java.io.Serializable;
import java.util.Properties;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.http.HttpSession;
import net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserController;
import net.forwardfire.vasc.demo.tech.web.models.WebUser;
/**
@ -71,6 +75,27 @@ public class UserController implements Serializable {
user.setFullName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());
user.setLoginName(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(WEB_USER_SESSION_KEY, user);
/*
try {
Properties properties = new Properties();
properties.setProperty (Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");
InitialContext ic = new InitialContext(properties);
Object object = ic.lookup("java:app/demo/vascServiceManager");
System.out.println("ob: "+object);
} catch (Exception e) {
e.printStackTrace();
}
try {
InitialContext ic = new InitialContext();
LoginUserController object = (LoginUserController)ic.lookup("java:app/demo/loginUserController");
System.out.println("ob: "+object);
System.out.println("login: "+object.doClientLogin());
} catch (Exception e) {
e.printStackTrace();
}
*/
return user;
}

View file

@ -18,8 +18,8 @@ import javax.faces.event.SystemEventListener;
import org.richfaces.resource.ResourceKey;
import com.sun.faces.renderkit.html_basic.ScriptRenderer;
import com.sun.faces.renderkit.html_basic.StylesheetRenderer;
//import com.sun.faces.renderkit.html_basic.ScriptRenderer;
//import com.sun.faces.renderkit.html_basic.StylesheetRenderer;
/**

View file

@ -36,7 +36,7 @@ public class UrlRewriteConfigurationProvider extends HttpConfigurationProvider {
return ConfigurationBuilder.begin()
.addRule(Join.path("/yoyo").to("/html/index.jsf"))
//.addRule(Join.path("/yoyo").to("/html/index.jsf"))
.defineRule()
.when(Direction.isInbound().

View file

@ -1,212 +0,0 @@
/*
* Copyright 2009-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.tech.web.menu;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import net.forwardfire.vasc.demo.tech.web.beans.UserController;
import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.web.menu.model.VascMenuType;
/**
* MenuController Shows the menu for the user.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class MenuController implements Serializable {
private static final long serialVersionUID = -6820749860984575869L;
private List<VascMenu> userVascMenu = null;
private VascMenuComparator vascMenuComparator = null;
private UserController userController = null;
public List<VascMenu> fetchVascMenu() {
//if (userVascMenu!=null) {
// return userVascMenu;
//}
vascMenuComparator = new VascMenuComparator();
userVascMenu = new ArrayList<VascMenu>(50);
/*
MetaModelDataContextJndiDataSource dsFactory = new MetaModelDataContextJndiDataSource();
dsFactory.setJndiName("java:comp/env/jdbc/vascDemoDS");
DataContext ds = dsFactory.getDataContext();
Table table = ds.getDefaultSchema().getTableByName("vasc_menu");
DataSet data = ds.query().from(table).select(table.getColumns()).execute();
List<VascMenu> result = new ArrayList<VascMenu>(50);
Iterator<Row> i = data.iterator();
while (i.hasNext()) {
Row row = i.next();
}*/
Connection connection = null;
try {
DataSource ds = getDataSource("java:comp/env/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU");
ResultSet rs = s.getResultSet();
//int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
VascMenu menu = new VascMenu();
menu.setId(rs.getInt(1));
menu.setHref(rs.getString(2));
menu.setTitle(rs.getString(3));
menu.setTarget(rs.getString(4));
menu.setActive(rs.getBoolean(5));
menu.setRoles(rs.getString(6));
menu.setMenuOrder(rs.getInt(7));
menu.setMenuType(VascMenuType.valueOf(rs.getString(8)));
if (filterVascMenuRoles(menu)==false) {
continue;
}
userVascMenu.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return userVascMenu;
}
private DataSource getDataSource(String name) throws SQLException {
try {
Context initialContext = new InitialContext();
DataSource datasource = (DataSource)initialContext.lookup(name);
if ( datasource == null ) {
throw new SQLException("Cannot lookup datasource: "+name);
}
return datasource;
} catch ( NamingException e ) {
throw new SQLException("Cannot get connection " + e,e);
}
}
private boolean filterVascMenuRoles(VascMenu menu) {
if (menu.getActive()!=null && menu.getActive()==false) {
return false;
}
if (menu.getRoles()!=null && menu.getRoles().isEmpty()==false) {
String[] roles = menu.getRoles().split(",");
for (String role:roles) {
if (role.isEmpty()) {
continue;
}
if (userController.hasUserRole(role)==false) {
return false;
}
}
}
return true;
}
private List<VascMenu> getMenuFiltered(VascMenuType type) {
if (type==null) {
throw new NullPointerException("Can't filter on null type.");
}
List<VascMenu> result = new ArrayList<VascMenu>(15);
for (VascMenu menu:fetchVascMenu()) {
if (type.equals(menu.getMenuType())) {
result.add(menu);
}
}
Collections.sort(result,vascMenuComparator);
return result;
}
public List<VascMenu> getMenuBarLeft() {
return getMenuFiltered(VascMenuType.BAR_LEFT);
}
public List<VascMenu> getMenuBarRight() {
return getMenuFiltered(VascMenuType.BAR_RIGHT);
}
public List<VascMenu> getMenuBarBottom() {
return getMenuFiltered(VascMenuType.BAR_BOTTOM);
}
public List<VascMenu> getMenuPageIndex() {
return getMenuFiltered(VascMenuType.PAGE_INDEX);
}
public List<VascMenu> getMenuPageUserLeft() {
return getMenuFiltered(VascMenuType.PAGE_USER_LEFT);
}
public List<VascMenu> getMenuPageUserRight() {
return getMenuFiltered(VascMenuType.PAGE_USER_RIGHT);
}
public List<VascMenu> getMenuPageAdmin() {
return getMenuFiltered(VascMenuType.PAGE_ADMIN);
}
public List<VascMenu> getMenu0() {
return getMenuFiltered(VascMenuType.MENU0);
}
public List<VascMenu> getMenu1() {
return getMenuFiltered(VascMenuType.MENU1);
}
public List<VascMenu> getMenu2() {
return getMenuFiltered(VascMenuType.MENU2);
}
/**
* @return the userController
*/
public UserController getUserController() {
return userController;
}
/**
* @param userController the userController to set
*/
public void setUserController(UserController userController) {
this.userController = userController;
}
}

View file

@ -36,8 +36,8 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
import net.forwardfire.vasc.demo.tech.web.beans.UserController;
import net.forwardfire.vasc.demo.tech.web.menu.VascMenuComparator;
/**
* MenuController Shows the menu for the user.

View file

@ -2,7 +2,7 @@
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>
Vasc namespace for the vasc tech demo
Files to load
</comment>
<entry key="eld.http://demo.vasc.forwardfire.net/eld/vasc-tech-demo.eld">vasc-tech-demo.eld</entry>
<entry key="vascController">openejb:Resource/vasc/server-tech</entry>
</properties>

View file

@ -12,8 +12,8 @@ jawr.debug.overrideKey=jawr_debug
jawr.config.reload.refreshKey=jawr_refresh
# Development mode flags
jawr.debug.on=true
jawr.config.reload.interval=3
#jawr.debug.on=true
#jawr.config.reload.interval=3
#
@ -42,6 +42,7 @@ jawr.js.bundle.skin-switcher.mappings=skinSwitcher:switcher.js
jawr.js.bundle.vasc.mappings=/js/vasc-jsf.js
jawr.js.bundle.richfaces.mappings=\
jar:/META-INF/resources/javax.faces/jsf.js,\
jar:/META-INF/resources/jquery.js,\
jar:/META-INF/resources/jquery.focus.js,\
jar:/META-INF/resources/jquery.position.js,\
@ -52,7 +53,9 @@ jar:/META-INF/resources/richfaces-queue.js,\
jar:/META-INF/resources/richfaces-event.js,\
jar:/META-INF/resources/richfaces-selection.js,\
jar:/META-INF/resources/richfaces-jsf-event.js,\
jar:/META-INF/resources/richfaces-jsf-log.js
jar:/META-INF/resources/richfaces-jsf-log.js,\
jar:/META-INF/resources/org.richfaces/datatable.js
jawr.js.bundle.richfaces-atmosphere.mappings=\
jar:/META-INF/resources/net.java.dev.atmosphere/jquery-atmosphere.js

View file

@ -0,0 +1,31 @@
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>vascServiceManager</ejb-name>
<business-local>net.forwardfire.vasc.ejb3.VascServiceManagerLocal</business-local>
<business-remote>net.forwardfire.vasc.ejb3.VascServiceManagerRemote</business-remote>
<ejb-class>net.forwardfire.vasc.ejb3.VascServiceManagerImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<ejb-name>loginUserController</ejb-name>
<business-local>net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerLocal</business-local>
<business-remote>net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerRemote</business-remote>
<ejb-class>net.forwardfire.vasc.demo.tech.ejb3.user.LoginUserControllerImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<ejb-name>vascMenuController</ejb-name>
<business-local>net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerLocal</business-local>
<business-remote>net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerRemote</business-remote>
<ejb-class>net.forwardfire.vasc.demo.tech.ejb3.menu.VascMenuControllerImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

View file

@ -15,9 +15,9 @@
<default-locale>en</default-locale>
</locale-config>
<system-event-listener>
<system-event-listener-class>net.forwardfire.vasc.demo.tech.web.faces.NoneLoadStyleResourceEventListener</system-event-listener-class>
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
<system-event-listener-class>net.forwardfire.vasc.demo.tech.web.faces.NoneLoadStyleResourceEventListener</system-event-listener-class>
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
</application>
<managed-bean>
@ -37,7 +37,7 @@
<managed-bean>
<description>Controls the display of the dynamic menus.</description>
<managed-bean-name>menuController</managed-bean-name>
<managed-bean-class>net.forwardfire.vasc.demo.tech.web.menu.MenuController</managed-bean-class>
<managed-bean-class>net.forwardfire.vasc.demo.tech.web.beans.MenuController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>userController</property-name>
@ -52,14 +52,14 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<!-- This should be in jawr jar file faces so it gets automatic done. -->
<!-- This should be in jawr jar file faces so it gets automatic done. -->
<component>
<component-type>jawr.JavascriptBundle</component-type>
<component-type>jawr.JavascriptBundle</component-type>
<component-class>net.jawr.web.taglib.jsf.JavascriptBundleTag</component-class>
</component>
<component>
<component-type>jawr.CSSBundle</component-type>
<component-class>net.jawr.web.taglib.jsf.CSSBundleTag</component-class>
</component>
</faces-config>

View file

@ -62,22 +62,32 @@
</h:outputFormat>
</p>
<h:form>
<ul class="actionboxtab">
<li><a class="active"><h:outputText value="#{entrySupport.i18nMap['vasc.action.editRowAction.name']}"/></a></li>
<ui:repeat var="link" value="#{entrySupport.vascLinkEntriesEditTab}" rendered="#{!entrySupport.vascEntry.vascFrontendController.vascEntryState.editCreate}">
<li><h:commandLink actionListener="#{entrySupport.linkEditAction}" value="#{entrySupport.i18nMap[link.name]}" type="#{link.id}"/></li>
</ui:repeat>
</ul>
<p class="vascButtons">
<h:commandButton onclick="document.getElementById('ef:save').click();return false;" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.save']}"/>
<h:commandButton onclick="document.getElementById('ef:cancel').click();return false;" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.cancel']}" />
</p>
</h:form>
<h:form>
<div class="actiontab">
<ul class="actionboxtab">
<li><a class="active"><h:outputText value="#{entrySupport.i18nMap['vasc.action.editRowAction.name']}"/></a></li>
<ui:repeat var="link" value="#{entrySupport.vascLinkEntriesEditTab}" rendered="#{!entrySupport.vascEntry.vascFrontendController.vascEntryState.editCreate}">
<li><h:commandLink actionListener="#{entrySupport.linkEditAction}" value="#{entrySupport.i18nMap[link.name]}" type="#{link.id}"/></li>
</ui:repeat>
</ul>
<div class="actiontabline"/>
</div>
<!--
<h:panelGrid columns="1" styleClass="actionbox">
<h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
</h:panelGrid>
-->
</h:form>
<br/>
<h:form>
<h:panelGrid columns="3" id="injectEditFieldsId" styleClass="actionbox"/>
<p>
<h:commandButton actionListener="#{entrySupport.saveAction}" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.save']}"/>
<h:commandButton actionListener="#{entrySupport.cancelAction}" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.cancel']}" />
<h:form id="ef">
<h:panelGrid columns="3" id="injectEditFieldsId" styleClass="vascEditBox"/>
<p class="vascButtons">
<h:commandButton id="save" actionListener="#{entrySupport.saveAction}" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.save']}"/>
<h:commandButton id="cancel" actionListener="#{entrySupport.cancelAction}" value="#{entrySupport.i18nMap['generic.vasc.jsf.action.cancel']}" />
</p>
</h:form>
</h:panelGroup>
@ -92,9 +102,8 @@
</h:outputFormat>
</p>
<h:form>
<p><!-- rendered="{entrySupport.vascEntry.vascAdminCreate}" -->
<p class="vascButtons"><!-- rendered="{entrySupport.vascEntry.vascAdminCreate}" -->
<h:commandButton actionListener="#{entrySupport.addAction}"
value="#{entrySupport.i18nMap['vasc.action.addRowAction.name']}"
title="#{entrySupport.i18nMap['vasc.action.addRowAction.description']}"
/>
@ -107,22 +116,25 @@
</h:form>
<h:form>
<rich:dataTable id="itci" var="tableRecord" value="#{entrySupport.tableDataModel}" rowClasses="odd,even">
<f:facet name="header">
<f:facet name="header">
<rich:columnGroup>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left">
<ul class="actionboxtab">
<li>
<h:panelGroup rendered="#{!entrySupport.renderBackAction}">
<a class="active"><h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.listOption.header']}"/></a>
</h:panelGroup>
<h:commandLink actionListener="#{entrySupport.backEditAction}" value="#{entrySupport.i18nMap['vasc.action.editRowAction.name']}" rendered="#{entrySupport.renderBackEditAction}"/>
</li>
<ui:repeat var="link" value="#{entrySupport.vascLinkEntriesEditTabParentState}">
<li><h:commandLink actionListener="#{entrySupport.linkListAction}" value="#{entrySupport.i18nMap[link.name]}" type="#{link.id}" styleClass="#{link.vascEntryId==entrySupport.vascEntry.id?'active':''}"/></li>
</ui:repeat>
</ul>
<div class="actiontab">
<ul class="actionboxtab">
<li>
<h:panelGroup rendered="#{!entrySupport.renderBackAction}">
<a class="active"><h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.listOption.header']}"/></a>
</h:panelGroup>
<h:commandLink actionListener="#{entrySupport.backEditAction}" value="#{entrySupport.i18nMap['vasc.action.editRowAction.name']}" rendered="#{entrySupport.renderBackEditAction}"/>
</li>
<ui:repeat var="link" value="#{entrySupport.vascLinkEntriesEditTabParentState}">
<li><h:commandLink actionListener="#{entrySupport.linkListAction}" value="#{entrySupport.i18nMap[link.name]}" type="#{link.id}" styleClass="#{link.vascEntryId==entrySupport.vascEntry.id?'active':''}"/></li>
</ui:repeat>
</ul>
<div class="actiontabline"/>
</div>
<h:panelGrid columns="1" styleClass="actionbox">
<h:panelGrid columns="2" id="itoi"/>
<h:panelGrid id="itoi" columns="2" columnClasses="itoiOption,itoiOptionValue"/>
<h:panelGroup>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.listOption.search']}"/>
<h:inputText value="#{entrySupport.searchString}"/>
@ -176,74 +188,76 @@
</rich:column>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left" breakRowBefore="true">
<h:panelGroup styleClass="table_options_top">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.rows']}" />
<h:inputText required="false" value="#{entrySupport.vascEntry.vascFrontendController.vascEntryState.vascBackendState.pageSize}" size="4"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.pagerDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedDirectPage}" valueChangeListener="#{entrySupport.processDirectPageChange}">
<f:selectItems value="#{entrySupport.directPageItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_download.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.downloadDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedExporterAction}" valueChangeListener="#{entrySupport.processDirectDownloadChange}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.rows']}" />
<h:inputText required="false" value="#{entrySupport.vascEntry.vascFrontendController.vascEntryState.vascBackendState.pageSize}" size="4"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.pagerDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedDirectPage}" valueChangeListener="#{entrySupport.processDirectPageChange}">
<f:selectItems value="#{entrySupport.directPageItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_download.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.downloadDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedExporterAction}" valueChangeListener="#{entrySupport.processDirectDownloadChange}">
<f:selectItems value="#{entrySupport.globalExportItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_print.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.printer.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputFormat value="#{entrySupport.i18nMap['generic.vasc.jsf.table.resultText']}">
<h:outputFormat value="#{entrySupport.i18nMap['generic.vasc.jsf.table.resultText']}">
<f:param value="#{entrySupport.pageStartCount}" />
<f:param value="#{entrySupport.pageStopCount}" />
<f:param value="#{entrySupport.pageTotalRecordCount}" />
</h:outputFormat>
</h:panelGroup>
</rich:column>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left" breakRowBefore="true" rendered="#{entrySupport.hasMultiRowActions}">
</h:panelGroup>
</rich:column>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left" breakRowBefore="true" rendered="#{entrySupport.hasMultiRowActions}">
<div class="vascSelectAll">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.multiAction.selectAll']}"/>
<h:selectBooleanCheckbox id="selectAllBox" required="false" onchange="javascript:selectAllCheckboxes(this);return false;" value="#{entrySupport.selectAllValue}"/>
<h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:selectOneMenu id="multiAction" required="false" value="#{entrySupport.selectedMultiRowAction}" onchange="javascript:this.form.submit(); return false;" valueChangeListener="#{entrySupport.processMultiRowActionChange}">
<f:selectItems value="#{entrySupport.multiRowActionItems}" />
</h:selectOneMenu>
</div>
</rich:column>
<rich:column colspan="#{entrySupport.totalFieldColumnCount}" breakRowBefore="true">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.fields']}" styleClass="table_sub_header"/>
</rich:column>
<rich:column colspan="#{entrySupport.totalLinkColumnCount}" rendered="#{entrySupport.totalLinkColumnCount != 0}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.links']}" styleClass="table_sub_header"/>
</rich:column>
<rich:column colspan="#{entrySupport.totalActionColumnCount}" rendered="#{entrySupport.totalActionColumnCount != 0}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.actions']}" styleClass="table_sub_header"/>
</rich:column>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.fields']}" styleClass="table_sub_header"/>
</rich:column>
<rich:column colspan="#{entrySupport.totalLinkColumnCount}" rendered="#{entrySupport.totalLinkColumnCount != 0}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.links']}" styleClass="table_sub_header"/>
</rich:column>
<rich:column colspan="#{entrySupport.totalActionColumnCount}" rendered="#{entrySupport.totalActionColumnCount != 0}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.tableHeader.actions']}" styleClass="table_sub_header"/>
</rich:column>
</rich:columnGroup>
</f:facet>
<f:facet name="footer">
</f:facet>
<f:facet name="footer">
<rich:columnGroup>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left">
<h:panelGroup styleClass="table_options_bottom">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.rows']}" />
<h:inputText required="false" value="#{entrySupport.vascEntry.vascFrontendController.vascEntryState.vascBackendState.pageSize}" size="4"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.pagerDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedDirectPage}" valueChangeListener="#{entrySupport.processDirectPageChange}">
<f:selectItems value="#{entrySupport.directPageItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_download.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.downloadDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedExporterAction}" valueChangeListener="#{entrySupport.processDirectDownloadChange}">
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.rows']}" />
<h:inputText required="false" value="#{entrySupport.vascEntry.vascFrontendController.vascEntryState.vascBackendState.pageSize}" size="4"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.pagerDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedDirectPage}" valueChangeListener="#{entrySupport.processDirectPageChange}">
<f:selectItems value="#{entrySupport.directPageItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_download.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.download.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputText value="#{entrySupport.i18nMap['generic.vasc.jsf.table.downloadDirect']}" />
<h:selectOneMenu onchange="javascript:this.form.submit(); return false;" value="#{entrySupport.selectedExporterAction}" valueChangeListener="#{entrySupport.processDirectDownloadChange}">
<f:selectItems value="#{entrySupport.globalExportItems}" />
</h:selectOneMenu>
<img src="#{facesContext.externalContext.requestContextPath}/img/icon_print.png" alt="#{entrySupport.i18nMap['generic.vasc.jsf.table.printer.img']}" width="15" height="15" /><h:outputText value="&amp;nbsp;&amp;nbsp;" escape="false"/>
<h:outputFormat value="#{entrySupport.i18nMap['generic.vasc.jsf.table.resultText']}">
<h:outputFormat value="#{entrySupport.i18nMap['generic.vasc.jsf.table.resultText']}">
<f:param value="#{entrySupport.pageStartCount}" />
<f:param value="#{entrySupport.pageStopCount}" />
<f:param value="#{entrySupport.pageTotalRecordCount}" />
</h:outputFormat>
</h:panelGroup>
</rich:column>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left" breakRowBefore="true">
</h:panelGroup>
</rich:column>
<rich:column colspan="#{entrySupport.totalColumnCount}" styleClass="text_left" breakRowBefore="true">
<ul class="paging">
<li class="paging_atstart">
<h:commandLink rendered="#{entrySupport.hasPagePreviousAction}" value="#{entrySupport.i18nMap['generic.vasc.jsf.pager.previous']}"
@ -292,16 +306,18 @@
</rich:dataTable>
</h:form>
<h:form>
<p> <!-- rendered="{entrySupport.vascEntry.vascAdminCreate}" -->
<p class="vascButtons"> <!-- rendered="{entrySupport.vascEntry.vascAdminCreate}" -->
<h:commandButton actionListener="#{entrySupport.addAction}"
value="#{entrySupport.i18nMap['vasc.action.addRowAction.name']}"
title="#{entrySupport.i18nMap['vasc.action.addRowAction.description']}"/>
<h:commandButton actionListener="#{entrySupport.backAction}"
rendered="#{entrySupport.renderBackAction}"
value="#{entrySupport.i18nMap['generic.vasc.jsf.action.back']}"
/>
</p>
</h:form>
</h:panelGroup>
</f:facet>
</v:vascEntry>
</ui:define>
</ui:define>
</ui:composition>

View file

@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
>
<div id="body-deco-logo">
<div id="body-deco-logo-div">
@ -17,36 +16,4 @@
</span>
</div>
</div>
<div id="body-deco-menu">
<div id="body-deco-menu0-div">
<h4>
<span><h:outputText value="menu0"/></span>
</h4>
<ul>
<ui:repeat var="menuEntry" value="#{menuController.menu0}">
<li><a href="#{contextPathController.rootPath}#{menuEntry.href}" title="#{menuEntry.title}" target="#{menuEntry.target}">#{menuEntry.title}</a></li>
</ui:repeat>
</ul>
</div>
<div id="body-deco-menu1-div">
<h4>
<span><h:outputText value="menu1"/></span>
</h4>
<ul>
<ui:repeat var="menuEntry" value="#{menuController.menu1}">
<li><a href="#{contextPathController.rootPath}#{menuEntry.href}" title="#{menuEntry.title}" target="#{menuEntry.target}">#{menuEntry.title}</a></li>
</ui:repeat>
</ul>
</div>
<div id="body-deco-menu2-div">
<h4>
<span><h:outputText value="menu2"/></span>
</h4>
<ul>
<ui:repeat var="menuEntry" value="#{menuController.menu2}">
<li><a href="#{contextPathController.rootPath}#{menuEntry.href}" title="#{menuEntry.title}" target="#{menuEntry.target}">#{menuEntry.title}</a></li>
</ui:repeat>
</ul>
</div>
</div>
</ui:composition>

View file

@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
>
<div id="body-footer">
<div id="body-footer-text">

View file

@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
>
<div id="page-header">
<div id="page-header-left">

View file

@ -0,0 +1,21 @@
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
>
<div id="body-deco-menu">
<ui:repeat var="menuGroup" value="#{menuController.vascMenuGroup}">
<div id="body-deco-menu-group">
<h4>
<span><h:outputText value="#{menuGroup.title}"/></span>
</h4>
<ul>
<ui:repeat var="menu" value="#{menuGroup.menus}">
<li><a href="#{contextPathController.rootPath}/vasc/#{menu.vascEntryId}/list,jsf" title="#{menu.title}">#{menu.title}</a></li>
</ui:repeat>
</ul>
</div>
</ui:repeat>
</div>
</ui:composition>

View file

@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
>
<f:view>
<div id="body-view">
@ -11,16 +10,21 @@
<ui:include src="/WEB-INF/template/structure/main-body-header.xhtml"/>
</ui:insert>
<ui:insert name="main_body_content">
<div id="body-content">
<h1><ui:insert name="page_title"/></h1>
<h:messages globalOnly="true" />
<ui:insert name="page_content"/>
<ui:insert name="main_body_footer">
<ui:include src="/WEB-INF/template/structure/main-body-footer.xhtml"/>
<div id="body-container">
<ui:insert name="main_body_menu">
<ui:include src="/WEB-INF/template/structure/main-body-menu.xhtml"/>
</ui:insert>
<ui:insert name="main_body_decorator">
<ui:include src="/WEB-INF/template/structure/main-body-decorator.xhtml"/>
</ui:insert>
<div id="body-content">
<h1><ui:insert name="page_title"/></h1>
<h:messages globalOnly="true" />
<ui:insert name="page_content"/>
<ui:insert name="main_body_footer">
<ui:include src="/WEB-INF/template/structure/main-body-footer.xhtml"/>
</ui:insert>
</div>
</div>
</ui:insert>
</div>

View file

@ -3,7 +3,6 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:jawr="https://jawr.dev.java.net/jsf/facelets"
>
<ui:insert name="main_head_content_type">
@ -14,6 +13,9 @@
<meta name="description" content="#{i18n['Application.web.meta.description']}"/>
<meta name="keywords" content="#{i18n['Application.web.meta.keywords']}"/>
</ui:insert>
<ui:insert name="main_head_icon">
<link rel="icon" href="#{contextPathController.rootPath}/img/favicon.ico"/>
</ui:insert>
<title>
<ui:insert name="main_head_title">
<ui:insert name="page_title"/>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" metadata-complete="false"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<!-- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd -->
<display-name>Vasc Demo Tech Web Application</display-name>
<welcome-file-list>
<welcome-file>/html/index.jsf</welcome-file>
<welcome-file>/html/index.jsf</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>4</session-timeout>
@ -14,17 +14,17 @@
</session-config>
<security-role>
<role-name>user</role-name>
</security-role>
<security-role>
<role-name>admin-company</role-name>
</security-role>
<security-role>
<role-name>admin-system</role-name>
</security-role>
<role-name>user</role-name>
</security-role>
<security-role>
<role-name>inaccessible</role-name>
</security-role>
<role-name>admin-company</role-name>
</security-role>
<security-role>
<role-name>admin-system</role-name>
</security-role>
<security-role>
<role-name>inaccessible</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
@ -34,37 +34,36 @@
<auth-constraint/>
</security-constraint>
<security-constraint>
<display-name>User Required</display-name>
<web-resource-collection>
<web-resource-name>User pages</web-resource-name>
<url-pattern>/html/user/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>login</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Admin User Required</display-name>
<web-resource-collection>
<web-resource-name>Admin pages</web-resource-name>
<url-pattern>/html/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>VascDemoSecurity</realm-name>
<security-constraint>
<display-name>User Required</display-name>
<web-resource-collection>
<web-resource-name>User pages</web-resource-name>
<url-pattern>/html/user/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>login</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Admin User Required</display-name>
<web-resource-collection>
<web-resource-name>Admin pages</web-resource-name>
<url-pattern>/html/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>VascDemoSecurity</realm-name>
<form-login-config>
<form-login-page>/html/auth/login.jsf</form-login-page>
<form-error-page>/html/auth/error.jsf</form-error-page>
</form-login-config>
</login-config>
</login-config>
<error-page>
<error-code>400</error-code>
@ -111,15 +110,18 @@
</filter>
<filter-mapping>
<filter-name>userFilter</filter-name>
<servlet-name>facesServlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-name>userFilter</filter-name>
<servlet-name>facesServlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
-->
<!-- =============== CONFIG =================================== -->
<!-- JSF 2.0 -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
@ -129,6 +131,10 @@
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
@ -146,7 +152,7 @@
<param-value>false</param-value>
</context-param>
<!-- Jawr -->
<!-- Jawr -->
<servlet>
<servlet-name>JsServlet</servlet-name>
@ -185,12 +191,11 @@
<servlet-mapping>
<servlet-name>CssServlet</servlet-name>
<url-pattern>/_css/*</url-pattern>
</servlet-mapping>
</servlet-mapping>
<!-- Vasc -->
<filter>
<filter>
<display-name>VASC Filter</display-name>
<filter-name>vascFilter</filter-name>
<filter-class>net.forwardfire.vasc.frontend.web.jsf.VascRequestFacesFilter</filter-class>
@ -200,22 +205,42 @@
</init-param>
<init-param>
<param-name>vascControllerProvider</param-name>
<param-value>java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
<param-value>java:comp/env/vasc/server-tech@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>vascFilter</filter-name>
<url-pattern>/vasc/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<!-- <dispatcher>FORWARD</dispatcher> -->
</filter-mapping>
<filter-name>vascFilter</filter-name>
<url-pattern>/vasc/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<!-- <dispatcher>FORWARD</dispatcher> -->
</filter-mapping>
<filter>
<display-name>VASC Filter</display-name>
<filter-name>vascFilterServerAdmin</filter-name>
<filter-class>net.forwardfire.vasc.frontend.web.jsf.VascRequestFacesFilter</filter-class>
<init-param>
<param-name>templateFile</param-name>
<param-value>/WEB-INF/template/page-vasc.jsf</param-value>
</init-param>
<init-param>
<param-name>vascControllerProvider</param-name>
<param-value>java:comp/env/vasc/server-admin@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>vascFilterServerAdmin</filter-name>
<url-pattern>/server-admin/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<!-- <dispatcher>FORWARD</dispatcher> -->
</filter-mapping>
<servlet>
<servlet-name>vascExportServlet</servlet-name>
<servlet-class>net.forwardfire.vasc.frontend.web.export.VascExportServlet</servlet-class>
<init-param>
<param-name>vascControllerProvider</param-name>
<param-value>java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
<param-value>java:comp/env/vasc/server-tech@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
@ -233,7 +258,7 @@
<servlet-class>net.forwardfire.vasc.frontend.cxf.server.web.VascCXFServlet</servlet-class>
<init-param>
<param-name>vascControllerProvider</param-name>
<param-value>java:comp/env/vasc/DemoVascController@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
<param-value>java:comp/env/vasc/server-tech@net.forwardfire.vasc.impl.jndi.JndiVascControllerProvider</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
@ -242,17 +267,44 @@
<url-pattern>/cxf/*</url-pattern>
</servlet-mapping>
<!-- Debug
<!-- Add header tags -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>net.forwardfire.vasc.demo.tech.web.servlets.TestServlet</servlet-class>
<load-on-startup>6</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
-->
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresExcludedResponseStatusCodes</param-name>
<param-value>302, 304, 500, 503</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType image</param-name>
<param-value>access plus 10 weeks</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType text/css</param-name>
<param-value>access plus 10 weeks</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType application/javascript</param-name>
<param-value>access plus 10 weeks</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<!-- Remote ejb -->
<servlet>
<servlet-name>EjbServerServlet</servlet-name>
<servlet-class>org.apache.openejb.server.httpd.ServerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EjbServerServlet</servlet-name>
<url-pattern>/ejb/*</url-pattern>
</servlet-mapping>
</web-app>

View file

@ -4,17 +4,26 @@ body {
margin: 10px;
}
#body-container {
margin-top: 10px;
}
#body-content {
margin: 10px auto;
margin-left: 200px;
padding: 10px;
}
#body-clear {
clear: both;
}
#page-header {
height: 1.5em;
}
#page-header-left {
float:left;
margin-left: 200px;
}
#page-header-info {
@ -30,11 +39,8 @@ body {
padding-top: 10px;
}
#body-footer {
text-align: center;
text-align: center;
padding: 5px;
margin-left:20em;
margin-right:20em;
@ -48,7 +54,7 @@ body {
}
#body-deco-menu {
position: absolute;
right: 20px;
top: 150px;
float: left;
width: 190px;
}

View file

@ -31,4 +31,4 @@
.no-border {
border:none;
}
}

View file

@ -8,7 +8,9 @@ body {
}
#body-content {
border: 1px solid #ccc;
border: 1px solid #ccc;
border-bottom-left-radius:3px;
border-bottom-right-radius:3px;
background-image: url(/demo/img/skin/default/body-view-bg.png);
}
@ -49,7 +51,7 @@ h2 {
h3 {
font-family: Georgia, serif;
color: #2d1100;
color: #2d1100;
font-style: italic;
margin-top: 20px;
margin-bottom: 5px;
@ -62,7 +64,7 @@ h3 span {
padding-top:2px;
padding-left:5px;
padding-right: 40px;
padding-bottom: 4x;
padding-bottom: 4px;
}
@ -86,7 +88,7 @@ h3 span {
}
#body-deco-menu {
padding:10px;
}
#body-deco-logo-div,#body-deco-menu0-div,#body-deco-menu1-div,#body-deco-menu2-div {
@ -101,13 +103,14 @@ h3 span {
}
#body-deco-menu {
#body-deco-menu-group {
padding:5px;
margin-bottom: 10px;
border-radius:5px;
border: 1px solid #BBBBBB;
background-image: url(/demo/img/skin/default/body-view-bg.png);
}
.rf-p {
border-radius:5px;
border: 1px solid #BBBBBB;
@ -122,25 +125,19 @@ h3 span {
}
.rf-p-b {
padding-top:10px;
padding-left:5px;
padding-bottom:10px;
padding-right:5px;
}
input,textarea,select{
padding: 3px;
background: none repeat scroll 0 0 transparent;
border: 2px solid rgba(66, 60, 24, 0.6);
border-radius:3px;
margin-right: 5px;
margin-bottom: 2px;
background: none repeat scroll 0 0 transparent;
border: 2px solid rgba(66, 60, 24, 0.6);
border-radius:3px;
margin-right: 5px;
margin-bottom: 2px;
}
input:hover,textarea:hover,select:hover{
@ -159,7 +156,7 @@ input:hover,textarea:hover,select:hover{
background-color:rgba(218, 247, 82, 0.6);
}
.table_options_bottom, .table_options_top, .actionbox, ul.actionboxtab li a.active,.rf-p-hdr {
.table_options_bottom, .table_options_top, .actionbox,.vascEditBox, ul.actionboxtab li a.active,.rf-p-hdr,.actiontabline {
background-color:rgba(200, 224, 64, 0.6);
}

View file

@ -1,5 +1,17 @@
.vascEditBox {
background-color:#DDCCCC;
border-radius:3px;
border-top-left-radius:0;
border:none;
clear:both;
padding-left:5px;
padding-right:5px;
padding-top:15px;
padding-bottom:15px;
}
.actionbox{
background-color:#DDCCCC;
border-radius:3px;
@ -19,7 +31,8 @@ ul.actionboxtab li a {
border-top-right-radius:3px;
font-weight:700;
display:block;
margin-right:5px;color:#000;
color:#000;
margin-left:5px;
padding:3px 15px;
}
ul.actionboxtab li a.active{background-color:#DDCCCC;text-decoration:none;}
@ -27,6 +40,40 @@ ul.actionboxtab li a:hover{background-color:#DDCCCC;text-decoration:none;}
td.tableactions{border-bottom-color:#bbb;text-align:left;}
.itoiOption {
text-align: right;
padding: 1px;
}
.itoiOptionValue {
text-align: left;
padding: 1px;
padding-left: 5px;
}
.vascButtons {
padding: 5px;
padding-top: 10px;
}
.actiontab {
display:block;
float:left;
}
.actiontabline {
display:block;
float:left;
background-color:#DDCCCC;
width:100%;
height:5px;
border-top-left-radius:3px;
}
.vascSelectAll {
padding-left: 5px;
text-align: left;
}
ul.paging{
clear:both;
margin-bottom:5px;
@ -118,7 +165,7 @@ ul.paging .paging_break{
border: none;
padding-left: 0px;
padding-right: 0px;
font-weight: none;
font-weight: normal;
}
.rf-dt-thd {
@ -131,9 +178,11 @@ ul.paging .paging_break{
border-top-right-radius:3px;
background-color:#DDCCCC;
font-size:12px;
font-weight:700;
font-weight:bold;
padding:6px 15px;
display: block;
text-align:left;
margin-bottom:5px;
}
.table_options_bottom {
@ -141,10 +190,11 @@ ul.paging .paging_break{
border-bottom-right-radius:3px;
background-color:#DDCCCC;
font-size:12px;
font-weight:700;
font-weight:bold;
padding:6px 15px;
margin-top:5px;
display: block;
text-align:left;
margin-top:5px;
}
@ -164,5 +214,5 @@ ul.paging .paging_break{
padding-top:2px;
text-align:center;
}

View file

@ -3,3 +3,29 @@ body {
color: #00FF00;
}
input:hover,textarea:hover,select:hover{
border: 2px solid rgba(100, 224, 64, 0.6);
}
.even {
background-color:rgba(70, 180, 60, 0.6);
}
.odd {
background-color:rgba(10, 230, 120, 0.6);
}
#page-header-left a,#page-header-right a,#page-header-info-body,.rf-dt-shdr-c a,.table_sub_header {
background-color:rgba(18, 247, 82, 0.6);
}
.table_options_bottom, .table_options_top, .actionbox, ul.actionboxtab li a.active,.rf-p-hdr,.actiontabline {
background-color:rgba(00, 224, 64, 0.6);
}
ul.actionboxtab li a:hover,#page-header-left a:hover,#page-header-right a:hover,#page-header-info-body:hover {
background-color:rgba(65, 182, 33, 0.6);
}

Some files were not shown because too many files have changed in this diff Show more