Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
InterCommIT
committed
Jun 24, 2011
1 parent
e6575c5
commit b9d1e63
Showing
91 changed files
with
6,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,127 @@ | |||
<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/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<groupId>nl.intercommit</groupId> | |||
<artifactId>weaves</artifactId> | |||
<name>InterCommIT Tapestry 5.2 Component Library</name> | |||
<version>1.0.0-SNAPSHOT</version> | |||
|
|||
<description>A Tapestry 5.2 module featuring components and multiple database support</description> | |||
|
|||
<organization> | |||
<name>InterCommIT b.v.</name> | |||
<url>http://www.intercommit.nl</url> | |||
</organization> | |||
|
|||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.tapestry</groupId> | |||
<artifactId>tapestry-core</artifactId> | |||
<version>5.2.4</version> | |||
<type>jar</type> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hibernate</groupId> | |||
<artifactId>hibernate-core</artifactId> | |||
<version>3.5.6-Final</version> | |||
<scope>provided</scope> | |||
<exclusions> | |||
<exclusion> | |||
<artifactId>slf4j-api</artifactId> | |||
<groupId>org.slf4j</groupId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hibernate</groupId> | |||
<artifactId>hibernate-annotations</artifactId> | |||
<version>3.5.6-Final</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
<version>3.8.2</version> | |||
<type>jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>servlet-api</artifactId> | |||
<version>2.5</version> | |||
<type>jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.tapestry</groupId> | |||
<artifactId>tapestry-test</artifactId> | |||
<version>5.2.4</version> | |||
<scope>test</scope> | |||
</dependency> | |||
|
|||
|
|||
<!-- | |||
http://tapestry.1045711.n5.nabble.com/ANNOUNCE-ChenilleKit-1-3-2-which-support-Tapestry-5-2-4-td3383473.html | |||
--> | |||
<dependency> | |||
<groupId>org.chenillekit</groupId> | |||
<artifactId>chenillekit-tapestry</artifactId> | |||
<version>1.3.2</version> | |||
<exclusions> | |||
<exclusion> | |||
<artifactId>tapestry-core</artifactId> | |||
<groupId>org.apache.tapestry</groupId> | |||
</exclusion> | |||
<exclusion> | |||
<artifactId>tapestry-upload</artifactId> | |||
<groupId>org.apache.tapestry</groupId> | |||
</exclusion> | |||
<exclusion> | |||
<artifactId>tapestry-func</artifactId> | |||
<groupId>org.apache.tapestry</groupId> | |||
</exclusion> | |||
<exclusion> | |||
<artifactId>tapestry-ioc</artifactId> | |||
<groupId>org.apache.tapestry</groupId> | |||
</exclusion> | |||
</exclusions> | |||
|
|||
</dependency> | |||
<dependency> | |||
<groupId>org.hsqldb</groupId> | |||
<artifactId>hsqldb</artifactId> | |||
<version>1.8.0.10</version> | |||
<type>jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
|
|||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
<version>2.3.2</version> | |||
<configuration> | |||
<source>1.6</source> | |||
<target>1.6</target> | |||
<optimize>true</optimize> | |||
</configuration> | |||
</plugin> | |||
|
|||
|
|||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-jar-plugin</artifactId> | |||
<configuration> | |||
<archive> | |||
<manifestEntries> | |||
<Tapestry-Module-Classes>nl.intercommit.tapestry.services.InterCommitModule</Tapestry-Module-Classes> | |||
</manifestEntries> | |||
</archive> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
49 changes: 49 additions & 0 deletions
49
src/main/java/nl/intercommit/weaves/base/BasicClientElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
/* Copyright 2011 InterCommIT b.v. | |||
* | |||
* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves | |||
* | |||
* Weaves is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Lesser General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* any later version. | |||
* | |||
* Weaves is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with Weaves. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
package nl.intercommit.weaves.base; | |||
|
|||
import org.apache.tapestry5.BindingConstants; | |||
import org.apache.tapestry5.ClientElement; | |||
import org.apache.tapestry5.annotations.Environmental; | |||
import org.apache.tapestry5.annotations.Parameter; | |||
import org.apache.tapestry5.services.javascript.JavaScriptSupport; | |||
|
|||
public abstract class BasicClientElement implements ClientElement { | |||
|
|||
private String assignedClientId; | |||
|
|||
@Parameter(value = "prop:componentResources.id", defaultPrefix = BindingConstants.LITERAL) | |||
private String clientId; | |||
|
|||
@Environmental | |||
private JavaScriptSupport javascriptSupport; | |||
|
|||
@SuppressWarnings("unused") | |||
private void setupRender() { | |||
assignedClientId = javascriptSupport.allocateClientId(clientId); | |||
} | |||
|
|||
@Override | |||
public String getClientId() { | |||
return assignedClientId; | |||
} | |||
|
|||
|
|||
|
|||
} |
140 changes: 140 additions & 0 deletions
140
src/main/java/nl/intercommit/weaves/components/DropDownMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,140 @@ | |||
/* Copyright 2011 InterCommIT b.v. | |||
* | |||
* This file is part of the "Weaves" project hosted on https://github.com/intercommit/Weaves | |||
* | |||
* Weaves is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Lesser General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* any later version. | |||
* | |||
* Weaves is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with Weaves. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
package nl.intercommit.weaves.components; | |||
|
|||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
|
|||
import nl.intercommit.weaves.menu.MenuItem; | |||
|
|||
import org.apache.tapestry5.annotations.Import; | |||
import org.apache.tapestry5.annotations.Parameter; | |||
import org.apache.tapestry5.annotations.Property; | |||
import org.apache.tapestry5.annotations.SetupRender; | |||
import org.apache.tapestry5.ioc.annotations.Inject; | |||
import org.apache.tapestry5.services.Request; | |||
import org.apache.tapestry5.services.javascript.JavaScriptSupport; | |||
|
|||
@Import(library="DropDownMenu.js",stylesheet="DropDownMenu.css") | |||
public class DropDownMenu { | |||
|
|||
public final static String MENU_ITEM_SELECTED = "selectmenuitem"; | |||
|
|||
// linkedhashmaps to preserve ordering! | |||
@Parameter(required=true,allowNull=false) | |||
private LinkedHashMap<MenuItem,LinkedHashMap<MenuItem, List<MenuItem>>> menu; | |||
|
|||
@Inject | |||
private JavaScriptSupport js; | |||
|
|||
@Inject | |||
private Request request; | |||
|
|||
@Property | |||
private MenuItem level1; | |||
|
|||
@Property | |||
private MenuItem level2; | |||
|
|||
@Property | |||
private MenuItem level3; | |||
|
|||
@SetupRender | |||
private void initJavaScript() { | |||
js.addScript("initMenu();", ""); | |||
} | |||
|
|||
public List<MenuItem> getMenuBar() { | |||
if (getHasLevel1()) { | |||
return Arrays.asList((MenuItem[])menu.keySet().toArray(new MenuItem[0])); | |||
} else { | |||
return new ArrayList<MenuItem>(); | |||
} | |||
} | |||
|
|||
public List<MenuItem> getMenuItems() { | |||
if (getHasLevel2()) { | |||
return Arrays.asList((MenuItem[])menu.get(level1).keySet().toArray(new MenuItem[0])); | |||
} else { | |||
return new ArrayList<MenuItem>(); | |||
} | |||
} | |||
|
|||
public List<MenuItem> getSubMenus() { | |||
if (getHasLevel3()) { | |||
return Arrays.asList((MenuItem[])menu.get(level1).get(level2).toArray(new MenuItem[0])); | |||
} else { | |||
return new ArrayList<MenuItem>(); | |||
} | |||
} | |||
|
|||
public boolean getHasLevel1() { | |||
return menu.keySet() != null; | |||
} | |||
|
|||
public boolean getHasLevel2() { | |||
if (getHasLevel1()) { | |||
return menu.get(level1).keySet() != null; | |||
} | |||
return false; | |||
} | |||
|
|||
public boolean getHasLevel3() { | |||
if (getHasLevel2()) { | |||
return menu.get(level1).get(level2) != null ; | |||
} | |||
return false; | |||
} | |||
|
|||
public String getSelectedClass() { | |||
String className= "none"; | |||
for (MenuItem topLevel: menu.keySet()) { | |||
if (matchesRequest(topLevel,topLevel)) { | |||
return "toplevelselected"; | |||
} | |||
for (MenuItem level2: menu.get(topLevel).keySet()) { | |||
if (matchesRequest(level2,topLevel)) { | |||
return "toplevelselected"; | |||
} | |||
if (menu.get(topLevel).get(level2) !=null ) { | |||
|
|||
for (Object level3: menu.get(topLevel).get(level2).toArray()) { | |||
if (matchesRequest((MenuItem)level3,topLevel)) { | |||
return "toplevelselected"; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
return className; | |||
} | |||
|
|||
private boolean matchesRequest(final MenuItem menu,final MenuItem currentLevel) { | |||
|
|||
String reqPath = request.getPath(); | |||
if (!request.getContextPath().equals("")) { | |||
reqPath = request.getContextPath() + reqPath; | |||
} | |||
return (menu.getUrl().getBasePath().startsWith(reqPath) && | |||
currentLevel == level1) ; | |||
} | |||
|
|||
} |
Oops, something went wrong.