|
I noticed, with moderate re-ordering, that the tab order did not always reflect that of the psml file. I have 5 tabs, and they did not always come out in the order that they should have after re-ordering through the layout customizer. However, all my tabs were always ordered correctly within the layout customizer.
By adding the PortletTabs created within VelocityPortletSetControl to TreeSet rather than a Vector and using a custom comparator, PortletTabComparator, to order the TreeSet, my tabs are now ordered correctly 100% of the time.
This may be more of an issue with the way BasePortletSet is handling portlets, however this fix works pretty well and was easy to implement.
Scott |
Index: src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java,v
retrieving revision 1.6
diff -u -r1.6 VelocityPortletSetControl.java
--- src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java 9 Mar
2002 06:29:17 -0000 1.6
+++ src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java 18 Jul
+2002 21:12:18 -0000
@@ -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: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
