1 14 package org.wings.plaf.css.msie; 15 16 import org.apache.commons.logging.Log; 17 import org.apache.commons.logging.LogFactory; 18 import org.wings.*; 19 import org.wings.border.STitledBorder; 20 import org.wings.io.Device; 21 import org.wings.plaf.css.AbstractLayoutCG; 22 import org.wings.plaf.css.InputMapScriptListener; 23 import org.wings.plaf.css.Utils; 24 import org.wings.plaf.css.VersionedInputMap; 25 26 import javax.swing.*; 27 import java.io.IOException ; 28 29 32 public class PrefixAndSuffixDelegate implements org.wings.plaf.PrefixAndSuffixDelegate { 33 private final static transient Log log = LogFactory.getLog(PrefixAndSuffixDelegate.class); 34 35 public PrefixAndSuffixDelegate() { 36 } 37 38 public void writePrefix(Device device, SComponent component) throws IOException { 39 SDimension prefSize = component.getPreferredSize(); 40 final int align = component.getHorizontalAlignment(); 41 42 if (prefSize == null && (align == SConstants.CENTER || align == SConstants.RIGHT)) 44 prefSize = new SDimension("100%", null); 45 46 StringBuffer inlineStyles = Utils.generateCSSInlinePreferredSize(prefSize); 47 48 Utils.printDebugNewline(device, component); 49 Utils.printDebug(device, "<!-- ").print(component.getName()).print(" -->"); 50 device.print("<table id=\"").print(component.getName()).print("\""); 51 Utils.optAttribute(device, "class", "SLayout " + component.getStyle()); 52 Utils.optAttribute(device, "style", inlineStyles.toString()); 53 54 if (component instanceof LowLevelEventListener) { 55 LowLevelEventListener lowLevelEventListener = (LowLevelEventListener) component; 56 device.print(" eid=\"") 57 .print(lowLevelEventListener.getEncodedLowLevelEventId()).print("\""); 58 } 59 60 String toolTip = component.getToolTipText(); 61 if (toolTip != null) 62 device.print(" onmouseover=\"return makeTrue(domTT_activate(this, event, 'content', '") 63 .print(toolTip) 64 .print("', 'predefined', 'default'));\""); 65 66 InputMap inputMap = component.getInputMap(); 67 if (inputMap != null && !(inputMap instanceof VersionedInputMap)) { 68 log.debug("inputMap = " + inputMap); 69 inputMap = new VersionedInputMap(inputMap); 70 component.setInputMap(inputMap); 71 } 72 73 if (inputMap != null) { 74 VersionedInputMap versionedInputMap = (VersionedInputMap) inputMap; 75 Integer inputMapVersion = (Integer ) component.getClientProperty("inputMapVersion"); 76 if (inputMapVersion == null || versionedInputMap.getVersion() != inputMapVersion.intValue()) { 77 log.debug("inputMapVersion = " + inputMapVersion); 78 InputMapScriptListener.install(component); 79 component.putClientProperty("inputMapVersion", new Integer (versionedInputMap.getVersion())); 80 } 81 } 82 83 SPopupMenu menu = component.getComponentPopupMenu(); 84 if (menu != null) { 85 String componentId = menu.getName(); 87 String popupId = componentId + "_pop"; 88 device.print(" onContextMenu=\"javascript:return wpm_menuPopup(event, '"); 90 device.print(popupId); 91 device.print("');\" onMouseDown=\"javascript:return wpm_menuPopup(event, '"); 92 device.print(popupId); 93 device.print("');\""); 94 } 95 96 device.print("><tr>"); AbstractLayoutCG.openLayouterCell(device, false, 0, 0, 0, component); 98 device.print(">"); 99 100 if (component.getBorder() instanceof STitledBorder) { 102 STitledBorder titledBorder = (STitledBorder) component.getBorder(); 103 device.print("<div class=\"STitledBorderLegend\" style=\""); 104 titledBorder.getTitleAttributes().write(device); 105 device.print("\">"); 106 device.print(titledBorder.getTitle()); 107 device.print("</div>"); 108 } 109 110 component.fireRenderEvent(SComponent.START_RENDERING); 111 } 112 113 public void writeSuffix(Device device, SComponent component) throws IOException { 114 component.fireRenderEvent(SComponent.DONE_RENDERING); 115 AbstractLayoutCG.closeLayouterCell(device, false); 116 device.print("</tr></table>"); 117 Utils.printDebug(device, "<!-- /").print(component.getName()).print(" -->"); 118 } 119 120 } 121 | Popular Tags |