portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r392140 - in /portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent: WebContentHistoryList.java WebContentHistoryPage.java
Date Fri, 07 Apr 2006 00:56:50 GMT
Author: taylor
Date: Thu Apr  6 17:56:49 2006
New Revision: 392140

URL: http://svn.apache.org/viewcvs?rev=392140&view=rev
Log:
previous page, next page, refresh added to WebPagePortlet and SSOWebPagePortlet
contribution from David Young

Added:
    portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryList.java
    portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryPage.java

Added: portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryList.java?rev=392140&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryList.java
(added)
+++ portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryList.java
Thu Apr  6 17:56:49 2006
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.portlet.webcontent;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * A history of content navigations in the WebContentPortlet
+ *
+ * @author <a href="mailto:dyoung@phase2systems.com">David L Young</a>
+ * @version $Id: $ 
+ */
+
+public class WebContentHistoryList extends Object
+    implements Serializable
+{
+    int maxLength;
+    List history;
+    int currentIndex;
+    
+    // Constructors
+
+    public WebContentHistoryList()
+    {
+        this( -1 );
+    }
+    public WebContentHistoryList( int maxLength )
+    {
+        super();
+        
+        this.maxLength = maxLength;
+        this.history = new ArrayList();
+        this.currentIndex = -1;
+    }
+    
+    // Methods
+    
+    public boolean isEmpty()
+    {
+        return this.history.isEmpty();
+    }
+    public boolean hasCurrentPage()
+    {
+        return this.currentIndex >= 0;
+    }
+    public boolean hasPreviousPage()
+    {
+        return !isEmpty() && this.currentIndex-1 >= 0;
+    }
+    public boolean hasNextPage()
+    {
+        return !isEmpty() && this.currentIndex+1 < this.history.size();
+    }
+    
+    public WebContentHistoryPage getCurrentPage()
+    {
+        if (!hasCurrentPage())
+            return null ;
+        return (WebContentHistoryPage)this.history.get(this.currentIndex);
+    }
+    public WebContentHistoryPage getPreviousPage()
+    {
+        if (!hasPreviousPage())
+            return null;
+        this.currentIndex = this.currentIndex-1;
+        return getCurrentPage();
+    }
+    public WebContentHistoryPage getNextPage()
+    {
+        if (!hasNextPage())
+            return null;
+        this.currentIndex = this.currentIndex+1;
+        return getCurrentPage();
+    }
+    
+    public void visitPage(WebContentHistoryPage page)
+    {
+        if (page==null)
+            throw new IllegalArgumentException("WebContentHistoryList.addPage() - non-null
page required.");
+        
+        int i = this.history.indexOf(page);
+        if (i >= 0 && i == this.currentIndex) 
+        {
+            // just visiting the current page
+            return;
+        }
+        
+        // otherwise - new page...
+        while (hasNextPage())
+        {
+            // ...visiting a page discards any pages we have visited by going "back"
+            this.history.remove(this.currentIndex+1);
+        }
+        if (i >= 0 && i < history.size())
+        {
+            // ...actually, new visit to an old page, only keep one reference to it
+            this.history.remove(i);
+        }
+        
+        // add in the new page, at the end
+        this.history.add(page);
+        this.currentIndex = this.history.size()-1;
+        
+        // System.out.println("WebContentHistoryList.visitPage() - current index is: "+this.currentIndex+"\nhistory
list..."+ArrayUtils.toString(this.history));
+    }
+}

Added: portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryPage.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryPage.java?rev=392140&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryPage.java
(added)
+++ portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/webcontent/WebContentHistoryPage.java
Thu Apr  6 17:56:49 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.portlet.webcontent;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.lang.ArrayUtils;
+
+
+/**
+ * Information required to re-visit a page in the WebContentPortlet
+ *
+ * @author <a href="mailto:dyoung@phase2systems.com">David L Young</a>
+ * @version $Id: $ 
+ */
+
+public class WebContentHistoryPage extends Object
+    implements Serializable
+{
+    private String url;
+    private Map params;
+    private boolean is_post;
+
+    // Constructors
+    
+    public WebContentHistoryPage(String url)
+    {
+        this(url, null, null);
+    }
+    public WebContentHistoryPage(String url, Map params, String method)
+    {
+        super();
+
+        // guarantee non-null, so that equals() is well-behaved
+        if (url==null)
+            throw new IllegalArgumentException("WebContentHistoryPage() - url required");
+        
+        this.url = url;
+        this.params = params != null ? params : new HashMap();
+        this.is_post = method != null && method.equalsIgnoreCase("post");
+    }
+    
+    // Base Class Protocol
+    
+    public boolean equals(Object o)
+    {
+        if (o == null || !(o instanceof WebContentHistoryPage))
+            return false ;
+
+        WebContentHistoryPage page = (WebContentHistoryPage)o;
+        
+        return page.url.equals(this.url) && page.params.equals(this.params) &&
page.isPost() == this.isPost() ;
+    }
+    public String toString()
+    {
+        StringBuffer buff = new StringBuffer();
+        buff.append( "[" ).append(isPost() ? "POST: " : "GET: ").append( getUrl() ).append(
", " ).append( getParams().size() ).append(" params: {");
+        Iterator iter = getParams().entrySet().iterator();
+        while ( iter.hasNext() )
+        {
+            Map.Entry entry = (Map.Entry)iter.next();
+            buff.append("(").append(entry.getKey()).append(" . ").append(ArrayUtils.toString((String[])entry.getKey())).append(")");
+        }
+        buff.append("}]");
+        return buff.toString();
+    }
+    
+    // Data Access
+    
+    public String getUrl()
+    {
+        return this.url;
+    }
+    public Map getParams()
+    {
+        return this.params;
+    }
+    public boolean isPost()
+    {
+        return this.is_post;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message