You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2002/07/19 18:47:14 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls VelocityPortletSetControl.java
taylor 2002/07/19 09:47:14
Modified: src/java/org/apache/jetspeed/portal/controls
VelocityPortletSetControl.java
Log:
- Patch from Scott Weaver to fix bug in sort order of Tabs in Customizer
Revision Changes Path
1.7 +60 -4 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java
Index: VelocityPortletSetControl.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- VelocityPortletSetControl.java 9 Mar 2002 06:29:17 -0000 1.6
+++ VelocityPortletSetControl.java 19 Jul 2002 16:47:14 -0000 1.7
@@ -68,7 +68,11 @@
// Velocity Stuff
import org.apache.velocity.context.Context;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
import java.util.List;
+import java.util.TreeSet;
import java.util.Vector;
import java.util.Enumeration;
@@ -107,9 +111,9 @@
* @param portlet the base portlet to explore for children
* @
*/
- private List getTabs( PortletSet portlets, RunData rundata, Context context )
+ private Collection getTabs( PortletSet portlets, RunData rundata, Context context )
{
- Vector tabs = new Vector();
+ TreeSet tabs = new TreeSet(new PortletTabComparator());
PanedPortletController controller = null;
// if portlet is a PortletSet, try to retrieve the Controller
@@ -136,6 +140,7 @@
PortletTab tab = new PortletTab();
tab.setTitle( (p.getTitle()!=null)?p.getTitle():p.getName() );
+ tab.setPosition(p.getPortletConfig().getPosition());
if ( controller != null )
{
@@ -144,7 +149,7 @@
}
tab.setActions(buildActionList(rundata, p));
- tabs.addElement(tab);
+ tabs.add(tab);
}
return tabs;
@@ -158,6 +163,7 @@
private boolean selected = false;
private String link = null;
private List actions = null;
+ private int position = -1;
public String getTitle()
{
@@ -198,5 +204,55 @@
{
this.actions = actions;
}
+
+ public int getPosition()
+ {
+ return position;
+ }
+
+ public void setPosition(int pos)
+ {
+ position = pos;
+ }
}
+
+ /**
+ * Used to correctly order tabs based on the position value
+ * that is found each PortletTab's parent Portlet's PortletConfig object.
+ */
+ public class PortletTabComparator implements Comparator
+ {
+
+ /**
+ * @see Comparator#compare(Object, Object)
+ */
+ public int compare(Object o1, Object o2)
+ {
+ try
+ {
+ PortletTab pt1 = (PortletTab) o1;
+ PortletTab pt2 = (PortletTab) o2;
+ int pos1 = pt1.getPosition();
+ int pos2 = pt2.getPosition();
+
+ if(pos1 < pos2)
+ {
+ return -1;
+ }
+ else if(pos1 > pos2)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch(ClassCastException e)
+ {
+ return 0;
+ }
+ }
+ }
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>