Skip to content

Commit

Permalink
mobile: navigation portlet proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
vrockai committed Feb 13, 2013
1 parent 5533719 commit f818208
Show file tree
Hide file tree
Showing 16 changed files with 701 additions and 942 deletions.
12 changes: 0 additions & 12 deletions mobile-integration/portlets/navigation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@
<scope>provided</scope>
</dependency>

<!-- ExoKernel Integration to retrieve Service -->
<!-- <dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.commons</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.common</artifactId>
<scope>provided</scope>
</dependency> -->
</dependencies>

<repositories>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,73 @@
******************************************************************************/
package org.gatein.portlet.responsive.navigation;

import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.gatein.api.PortalRequest;
import org.gatein.api.navigation.Node;
import org.gatein.api.navigation.NodePath;
import org.gatein.api.navigation.Visibility;

/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
* @version $Revision$
*/
public class Node {
private URI uri;
private String name;
private List<Node> children;

public Node(String name, URI uri) {
this.name = name;
this.uri = uri;
public class NavigationNodeBean {

private Node node;

/* Flag marking currently accessed node */
boolean active = false;

public boolean isSystem(){
return node.getVisibility().getStatus().equals(Visibility.Status.SYSTEM);
}

public NavigationNodeBean(Node node) {
this.node = node;
}

public void setActive(boolean active){
this.active = active;
}

public boolean isActive(){
NodePath currentPath = PortalRequest.getInstance().getNodePath();
NodePath nodePath = node.getNodePath();
if (!active)
active = (nodePath != null) ? nodePath.equals(currentPath) : false;
return active;
}

public boolean isPage(){
return node.getPageId() != null;
}

/* Parent node contains one or more children nodes */
public boolean isParent(){
return !getChildren().isEmpty();
}

public String getName() {
return name;
return node.getDisplayName();
}

public String getURI() {
if (uri != null) {
return uri.toString();
} else {
return null;
}
return node.getURI();
}

public void setChildren(List<Node> children) {
if (children != null) {
this.children = children;
}
}
public List<NavigationNodeBean> getChildren() {
List<NavigationNodeBean> nodes = new ArrayList<NavigationNodeBean>();

public List<Node> getChildren() {
if (children == null) {
children = new ArrayList<Node>();
Iterator<Node> nodeIterator = node.iterator();

while(nodeIterator.hasNext()){
Node childNode = nodeIterator.next();
NavigationNodeBean childNodeBean = new NavigationNodeBean(childNode);
nodes.add(childNodeBean);
}
return children;

return nodes;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
/******************************************************************************
* JBoss, a division of Red Hat *
* Copyright 2011, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
* *
* This 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 2.1 of *
* the License, or (at your option) any later version. *
* *
* This software 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 this software; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
/**
* ****************************************************************************
* JBoss, a division of Red Hat * Copyright 2012, Red Hat Middleware, LLC, and individual * contributors as indicated by the
* @authors tag. See the * copyright.txt in the distribution for a full listing of * individual contributors. * * This 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 2.1 of * the License, or (at your option) any later version. * * This software 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 this software; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
*****************************************************************************
*/
package org.gatein.portlet.responsive.navigation;

import java.io.IOException;

import java.util.List;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletRequestDispatcher;
import org.gatein.api.PortalRequest;
import org.gatein.api.navigation.Navigation;
import org.gatein.api.navigation.Node;
import org.gatein.api.navigation.NodePath;
import org.gatein.api.navigation.Nodes;

/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
* @version $Revision$
*/
public class NavigationPortlet extends GenericPortlet {

NavigationBean navigationBean;
NavigationNodeBean navigationRootNodeBean;

public NavigationPortlet() {
this.navigationBean = new NavigationBean();

}

@Override
protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
request.setAttribute("navigation", navigationBean);

PortalRequest portalRequest = PortalRequest.getInstance();

Navigation navigation = portalRequest.getNavigation();
Node rootNode = navigation.getRootNode(Nodes.ALL);

navigationRootNodeBean = new NavigationNodeBean(rootNode);

/* Setting the 1st node to be active when accesing the root node "/" */
List<NavigationNodeBean> rootNodeChildrenList = navigationRootNodeBean.getChildren();

if (!rootNodeChildrenList.isEmpty() && portalRequest.getNodePath().equals(NodePath.root())){
rootNodeChildrenList.get(0).setActive(true);
}

request.setAttribute("navigationRootNode", navigationRootNodeBean);
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/navigation.jsp");
prd.include(request, response);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
label.SignIn=Sign in
label.Register=Register
label.SignOut=Sign Out
label.UserProfile=Profile
label.Dashboard=Dashboard
label.GroupPages=Group Pages
label.show=Show navigation
label.hide=Hide navigation
label.children=Show children nodes
Original file line number Diff line number Diff line change
@@ -1,27 +1,81 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<gatein-resources
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_resources_1_3 http://www.gatein.org/xml/ns/gatein_resources_1_3"
xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_3">

<portlet-skin>
<application-name>responsive-navigation-portlet</application-name>
<portlet-name>ResponsiveNavigationPortlet</portlet-name>
<css-path>/css/ResponsiveStylesheet.css</css-path>
</portlet-skin>

<portlet>
<name>ResponsiveNavigationPortlet</name>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_resources_1_3 http://www.gatein.org/xml/ns/gatein_resources_1_3"
xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_3">

<module>
<name>collapsiblecontainer_jquery</name>
<script>
<path>/js/collapsiblecontainer.jquery.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
</module>

<!-- DropDown menu is supported from the header portlet right now
<module>
<name>dropdownmenu_jquery</name>
<script>
<path>/js/dropdownmenu.jquery.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
</module>
-->

<module>
<script>
<name>navigation</name>
<path>/js/navigation.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
<name>org_gatein_navigation</name>
<script>
<path>/js/navigation.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
<!-- DropDown menu is supported from the header portlet right now
<depends>
<module>dropdownmenu_jquery</module>
</depends>
-->
<depends>
<module>collapsiblecontainer_jquery</module>
</depends>
</module>
</portlet>

<portlet-skin>
<application-name>responsive-navigation-portlet</application-name>
<portlet-name>ResponsiveNavigationPortlet</portlet-name>
<css-path>/css/ResponsiveStylesheet.css</css-path>
</portlet-skin>

<portlet>
<name>ResponsiveNavigationPortlet</name>

<module>
<depends>
<module>org_gatein_navigation</module>
</depends>

<depends>
<module>collapsiblecontainer_jquery</module>
</depends>

<!-- DropDown menu is supported from the header portlet right now
<depends>
<module>dropdownmenu_jquery</module>
</depends>
-->

<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
</module>
</portlet>

</gatein-resources>

0 comments on commit f818208

Please sign in to comment.