1 14 package org.wings.plaf.css.msie; 15 16 17 import java.io.IOException ; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.wings.SMenu; 22 import org.wings.SMenuItem; 23 import org.wings.SPopupMenu; 24 import org.wings.io.Device; 25 26 public class PopupMenuCG extends org.wings.plaf.css.PopupMenuCG { 27 private final transient static Log log = LogFactory.getLog(PopupMenuCG.class); 28 29 32 protected void writeListAttributes(final Device device, SPopupMenu menu) throws IOException { 33 int maxLength = 0; 35 for (int i = 0; i < menu.getMenuComponentCount(); i++) { 36 if (!(menu.getMenuComponent(i) instanceof SMenuItem)) 37 continue; 38 String text = ((SMenuItem)menu.getMenuComponent(i)).getText(); 39 if (text != null && text.length() > maxLength) { 40 maxLength = text.length(); 41 if (menu.getMenuComponent(i) instanceof SMenu) { 42 maxLength = maxLength + 2; } 44 } 45 } 46 device.print(" style=\"width:"); 47 String stringLength = String.valueOf(maxLength * menu.getWidthScaleFactor()); 48 device.print(stringLength.substring(0,stringLength.lastIndexOf('.')+2)); 49 device.print("em;\""); 50 } 51 } 52 | Popular Tags |