1 29 30 package nextapp.echo2.webcontainer.syncpeer; 31 32 import java.io.IOException ; 33 34 import org.w3c.dom.Element ; 35 36 import nextapp.echo2.app.Color; 37 import nextapp.echo2.app.Component; 38 import nextapp.echo2.app.Extent; 39 import nextapp.echo2.app.FillImage; 40 import nextapp.echo2.app.FillImageBorder; 41 import nextapp.echo2.app.Font; 42 import nextapp.echo2.app.ImageReference; 43 import nextapp.echo2.app.Insets; 44 import nextapp.echo2.app.ResourceImageReference; 45 import nextapp.echo2.app.WindowPane; 46 import nextapp.echo2.app.update.PropertyUpdate; 47 import nextapp.echo2.app.update.ServerComponentUpdate; 48 import nextapp.echo2.webcontainer.ActionProcessor; 49 import nextapp.echo2.webcontainer.ComponentSynchronizePeer; 50 import nextapp.echo2.webcontainer.ContainerInstance; 51 import nextapp.echo2.webcontainer.PartialUpdateManager; 52 import nextapp.echo2.webcontainer.PartialUpdateParticipant; 53 import nextapp.echo2.webcontainer.PropertyUpdateProcessor; 54 import nextapp.echo2.webcontainer.RenderContext; 55 import nextapp.echo2.webcontainer.SynchronizePeerFactory; 56 import nextapp.echo2.webcontainer.image.ImageRenderSupport; 57 import nextapp.echo2.webcontainer.image.ImageTools; 58 import nextapp.echo2.webcontainer.propertyrender.ColorRender; 59 import nextapp.echo2.webcontainer.propertyrender.ExtentRender; 60 import nextapp.echo2.webcontainer.propertyrender.FillImageRender; 61 import nextapp.echo2.webcontainer.propertyrender.FontRender; 62 import nextapp.echo2.webcontainer.propertyrender.InsetsRender; 63 import nextapp.echo2.webrender.Connection; 64 import nextapp.echo2.webrender.ContentType; 65 import nextapp.echo2.webrender.ServerMessage; 66 import nextapp.echo2.webrender.Service; 67 import nextapp.echo2.webrender.WebRenderServlet; 68 import nextapp.echo2.webrender.output.CssStyle; 69 import nextapp.echo2.webrender.servermessage.DomUpdate; 70 import nextapp.echo2.webrender.service.JavaScriptService; 71 72 79 public class WindowPanePeer implements ActionProcessor, ImageRenderSupport, 80 PropertyUpdateProcessor, ComponentSynchronizePeer { 81 82 88 public static final String PROPERTY_IE_ALPHA_RENDER_BORDER 89 = "nextapp.echo2.webcontainer.syncpeer.WindowPanePeer.ieAlphaRenderBorder"; 90 91 private static final String IMAGE_ID_TITLE_BACKGROUND = "titleBackground"; 92 private static final String IMAGE_ID_CLOSE_ICON = "close"; 93 private static final String IMAGE_ID_ICON = "icon"; 94 private static final String IMAGE_ID_BACKGROUND = "background"; 95 private static final String IMAGE_ID_BORDER_TOP_LEFT = "borderTopLeft"; 96 private static final String IMAGE_ID_BORDER_TOP = "borderTop"; 97 private static final String IMAGE_ID_BORDER_TOP_RIGHT = "borderTopRight"; 98 private static final String IMAGE_ID_BORDER_LEFT = "borderLeft"; 99 private static final String IMAGE_ID_BORDER_RIGHT = "borderRight"; 100 private static final String IMAGE_ID_BORDER_BOTTOM_LEFT = "borderBottomLeft"; 101 private static final String IMAGE_ID_BORDER_BOTTOM = "borderBottom"; 102 private static final String IMAGE_ID_BORDER_BOTTOM_RIGHT = "borderBottomRight"; 103 104 private static final ImageReference DEFAULT_CLOSE_ICON = new ResourceImageReference( 105 "/nextapp/echo2/webcontainer/resource/image/DefaultCloseButton.gif"); 106 107 private static final String [] FILL_IMAGE_NAMES = {"tl", "t", "tr", "l", "r", "bl", "b", "br"}; 108 private static final String [] FILL_IMAGE_IDS = { 109 IMAGE_ID_BORDER_TOP_LEFT, IMAGE_ID_BORDER_TOP, IMAGE_ID_BORDER_TOP_RIGHT, IMAGE_ID_BORDER_LEFT, 110 IMAGE_ID_BORDER_RIGHT, IMAGE_ID_BORDER_BOTTOM_LEFT, IMAGE_ID_BORDER_BOTTOM, IMAGE_ID_BORDER_BOTTOM_RIGHT }; 111 112 private static final String BLANK_HTML_STRING = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " 113 + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" 114 + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title></title><body></body></html>"; 115 116 private static final Service BLANK_HTML_SERVICE = new Service() { 117 118 121 public String getId() { 122 return "Echo.WindowPane.IFrame"; 123 } 124 125 128 public int getVersion() { 129 return 0; 130 } 131 132 135 public void service(Connection conn) throws IOException { 136 conn.setContentType(ContentType.TEXT_HTML); 137 conn.getWriter().write(BLANK_HTML_STRING); 138 } 139 }; 140 141 144 public static final Service WINDOW_PANE_SERVICE = JavaScriptService.forResource("Echo.WindowPane", 145 "/nextapp/echo2/webcontainer/resource/js/WindowPane.js"); 146 147 static { 148 WebRenderServlet.getServiceRegistry().add(WINDOW_PANE_SERVICE); 149 WebRenderServlet.getServiceRegistry().add(BLANK_HTML_SERVICE); 150 } 151 152 private static void renderPixelProperty(WindowPane windowPane, String propertyName, Element element, String attributeName) { 153 String pixelValue; 154 Extent extent = (Extent) windowPane.getRenderProperty(propertyName); 155 if (extent != null) { 156 pixelValue = ExtentRender.renderCssAttributePixelValue(extent); 157 if (pixelValue != null) { 158 element.setAttribute(attributeName, pixelValue); 159 } 160 } 161 } 162 163 private PartialUpdateParticipant placeHolder = new PartialUpdateParticipant() { 164 165 public boolean canRenderProperty(RenderContext rc, ServerComponentUpdate update) { 166 return true; 167 } 168 169 public void renderProperty(RenderContext rc, ServerComponentUpdate update) { 170 } 172 }; 173 174 private PartialUpdateManager partialUpdateManager; 175 176 179 public WindowPanePeer() { 180 super(); 181 partialUpdateManager = new PartialUpdateManager(); 182 partialUpdateManager.add(WindowPane.PROPERTY_POSITION_X, placeHolder); 183 partialUpdateManager.add(WindowPane.PROPERTY_POSITION_Y, placeHolder); 184 partialUpdateManager.add(WindowPane.PROPERTY_WIDTH, placeHolder); 185 partialUpdateManager.add(WindowPane.PROPERTY_HEIGHT, placeHolder); 186 partialUpdateManager.add(WindowPane.PROPERTY_TITLE, placeHolder); 187 } 188 189 192 public String getContainerId(Component child) { 193 return ContainerInstance.getElementId(child.getParent()) + "_content"; 194 } 195 196 200 public ImageReference getImage(Component component, String imageId) { 201 if (IMAGE_ID_TITLE_BACKGROUND.equals(imageId)) { 202 FillImage backgroundImage = (FillImage) component.getRenderProperty(WindowPane.PROPERTY_TITLE_BACKGROUND_IMAGE); 203 return backgroundImage == null ? null : backgroundImage.getImage(); 204 } else if (IMAGE_ID_BACKGROUND.equals(imageId)) { 205 FillImage backgroundImage = (FillImage) component.getRenderProperty(WindowPane.PROPERTY_BACKGROUND_IMAGE); 206 return backgroundImage == null ? null : backgroundImage.getImage(); 207 } else if (IMAGE_ID_ICON.equals(imageId)) { 208 return (ImageReference) component.getRenderProperty(WindowPane.PROPERTY_ICON); 209 } else if (IMAGE_ID_CLOSE_ICON.equals(imageId)) { 210 return (ImageReference) component.getRenderProperty(WindowPane.PROPERTY_CLOSE_ICON, DEFAULT_CLOSE_ICON); 211 } else if (IMAGE_ID_BORDER_TOP_LEFT.equals(imageId)) { 212 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 213 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.TOP_LEFT); 214 return fillImage == null ? null : fillImage.getImage(); 215 } else if (IMAGE_ID_BORDER_TOP.equals(imageId)) { 216 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 217 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.TOP); 218 return fillImage == null ? null : fillImage.getImage(); 219 } else if (IMAGE_ID_BORDER_TOP_RIGHT.equals(imageId)) { 220 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 221 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.TOP_RIGHT); 222 return fillImage == null ? null : fillImage.getImage(); 223 } else if (IMAGE_ID_BORDER_LEFT.equals(imageId)) { 224 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 225 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.LEFT); 226 return fillImage == null ? null : fillImage.getImage(); 227 } else if (IMAGE_ID_BORDER_RIGHT.equals(imageId)) { 228 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 229 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.RIGHT); 230 return fillImage == null ? null : fillImage.getImage(); 231 } else if (IMAGE_ID_BORDER_BOTTOM_LEFT.equals(imageId)) { 232 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 233 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.BOTTOM_LEFT); 234 return fillImage == null ? null : fillImage.getImage(); 235 } else if (IMAGE_ID_BORDER_BOTTOM.equals(imageId)) { 236 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 237 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.BOTTOM); 238 return fillImage == null ? null : fillImage.getImage(); 239 } else if (IMAGE_ID_BORDER_BOTTOM_RIGHT.equals(imageId)) { 240 FillImageBorder fillImageBorder = ((FillImageBorder) component.getRenderProperty(WindowPane.PROPERTY_BORDER)); 241 FillImage fillImage = fillImageBorder == null ? null : fillImageBorder.getFillImage(FillImageBorder.BOTTOM_RIGHT); 242 return fillImage == null ? null : fillImage.getImage(); 243 } else { 244 return null; 245 } 246 } 247 248 252 public void processAction(ContainerInstance ci, Component component, Element actionElement) { 253 WindowPane windowPane = (WindowPane) component; 254 boolean closable = ((Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_CLOSABLE, Boolean.TRUE)).booleanValue(); 255 if (closable) { 256 ci.getUpdateManager().getClientUpdateManager().setComponentAction(component, WindowPane.INPUT_CLOSE, null); 257 } 258 } 259 260 265 public void processPropertyUpdate(ContainerInstance ci, Component component, Element propertyElement) { 266 String propertyName = propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_NAME); 267 WindowPane windowPane = (WindowPane) component; 268 boolean movable = ((Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_MOVABLE, Boolean.TRUE)).booleanValue(); 269 boolean resizable = ((Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_RESIZABLE, Boolean.TRUE)).booleanValue(); 270 if (WindowPane.PROPERTY_POSITION_X.equals(propertyName)) { 271 if (movable) { 272 ci.getUpdateManager().getClientUpdateManager().setComponentProperty(component, WindowPane.PROPERTY_POSITION_X, 273 ExtentRender.toExtent(propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_VALUE))); 274 } 275 } else if (WindowPane.PROPERTY_POSITION_Y.equals(propertyName)) { 276 if (movable) { 277 ci.getUpdateManager().getClientUpdateManager().setComponentProperty(component, WindowPane.PROPERTY_POSITION_Y, 278 ExtentRender.toExtent(propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_VALUE))); 279 } 280 } else if (WindowPane.PROPERTY_WIDTH.equals(propertyName)) { 281 if (resizable) { 282 ci.getUpdateManager().getClientUpdateManager().setComponentProperty(component, WindowPane.PROPERTY_WIDTH, 283 ExtentRender.toExtent(propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_VALUE))); 284 } 285 } else if (WindowPane.PROPERTY_HEIGHT.equals(propertyName)) { 286 if (resizable) { 287 ci.getUpdateManager().getClientUpdateManager().setComponentProperty(component, WindowPane.PROPERTY_HEIGHT, 288 ExtentRender.toExtent(propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_VALUE))); 289 } 290 } else if (WindowPane.Z_INDEX_CHANGED_PROPERTY.equals(propertyName)) { 291 ci.getUpdateManager().getClientUpdateManager().setComponentProperty(component, WindowPane.Z_INDEX_CHANGED_PROPERTY, 292 new Integer (propertyElement.getAttribute(PropertyUpdateProcessor.PROPERTY_VALUE))); 293 } 294 } 295 296 297 302 public void renderAdd(RenderContext rc, ServerComponentUpdate update, 303 String targetId, Component component) { 304 ServerMessage serverMessage = rc.getServerMessage(); 305 serverMessage.addLibrary(WINDOW_PANE_SERVICE.getId()); 306 WindowPane windowPane = (WindowPane) component; 307 renderInitDirective(rc, windowPane, targetId); 308 Component[] children = windowPane.getVisibleComponents(); 309 if (children.length != 0) { 310 ComponentSynchronizePeer syncPeer = SynchronizePeerFactory.getPeerForComponent(children[0].getClass()); 311 syncPeer.renderAdd(rc, update, getContainerId(children[0]), children[0]); 312 } 313 } 314 315 320 public void renderDispose(RenderContext rc, ServerComponentUpdate update, 321 Component component) { 322 ServerMessage serverMessage = rc.getServerMessage(); 323 serverMessage.addLibrary(WINDOW_PANE_SERVICE.getId()); 324 renderDisposeDirective(rc, (WindowPane) component); 325 } 326 327 335 private void renderDisposeDirective(RenderContext rc, WindowPane windowPane) { 336 String elementId = ContainerInstance.getElementId(windowPane); 337 ServerMessage serverMessage = rc.getServerMessage(); 338 Element initElement = serverMessage.appendPartDirective(ServerMessage.GROUP_ID_PREREMOVE, 339 "EchoWindowPane.MessageProcessor", "dispose"); 340 initElement.setAttribute("eid", elementId); 341 } 342 343 351 private void renderInitDirective(RenderContext rc, WindowPane windowPane, String targetId) { 352 String elementId = ContainerInstance.getElementId(windowPane); 353 ServerMessage serverMessage = rc.getServerMessage(); 354 Element partElement = serverMessage.addPart(ServerMessage.GROUP_ID_UPDATE, "EchoWindowPane.MessageProcessor"); 355 Element initElement = serverMessage.getDocument().createElement("init"); 356 initElement.setAttribute("container-eid", targetId); 357 initElement.setAttribute("eid", elementId); 358 359 if (!windowPane.isRenderEnabled()) { 360 initElement.setAttribute("enabled", "false"); 361 } 362 if (windowPane.getZIndex() != 0) { 363 initElement.setAttribute("z-index", Integer.toString(windowPane.getZIndex())); 364 } 365 366 Insets insets = (Insets) windowPane.getRenderProperty(WindowPane.PROPERTY_INSETS); 368 if (insets != null) { 369 initElement.setAttribute("insets", InsetsRender.renderCssAttributeValue(insets)); 370 } 371 Color background = (Color) windowPane.getRenderProperty(WindowPane.PROPERTY_BACKGROUND); 372 if (background != null) { 373 initElement.setAttribute("background", ColorRender.renderCssAttributeValue(background)); 374 } 375 FillImage backgroundImage = (FillImage) windowPane.getRenderProperty(WindowPane.PROPERTY_BACKGROUND_IMAGE); 376 if (backgroundImage != null) { 377 CssStyle backgroundImageCssStyle = new CssStyle(); 378 FillImageRender.renderToStyle(backgroundImageCssStyle, rc, this, windowPane, IMAGE_ID_BACKGROUND, 379 backgroundImage, 0); 380 initElement.setAttribute("background-image", backgroundImageCssStyle.renderInline()); 381 } 382 Color foreground = (Color) windowPane.getRenderProperty(WindowPane.PROPERTY_FOREGROUND); 383 if (foreground != null) { 384 initElement.setAttribute("foreground", ColorRender.renderCssAttributeValue(foreground)); 385 } 386 Font font = (Font) windowPane.getRenderProperty(WindowPane.PROPERTY_FONT); 387 if (font != null) { 388 CssStyle fontCssStyle = new CssStyle(); 389 FontRender.renderToStyle(fontCssStyle, font); 390 initElement.setAttribute("font", fontCssStyle.renderInline()); 391 } 392 393 renderPixelProperty(windowPane, WindowPane.PROPERTY_POSITION_X, initElement, "position-x"); 395 renderPixelProperty(windowPane, WindowPane.PROPERTY_POSITION_Y, initElement, "position-y"); 396 renderPixelProperty(windowPane, WindowPane.PROPERTY_WIDTH, initElement, "width"); 397 renderPixelProperty(windowPane, WindowPane.PROPERTY_HEIGHT, initElement, "height"); 398 renderPixelProperty(windowPane, WindowPane.PROPERTY_MINIMUM_WIDTH, initElement, "minimum-width"); 399 renderPixelProperty(windowPane, WindowPane.PROPERTY_MINIMUM_HEIGHT, initElement, "minimum-height"); 400 renderPixelProperty(windowPane, WindowPane.PROPERTY_MAXIMUM_WIDTH, initElement, "maximum-width"); 401 renderPixelProperty(windowPane, WindowPane.PROPERTY_MAXIMUM_HEIGHT, initElement, "maximum-height"); 402 403 int fillImageRenderFlags = ((Boolean ) windowPane.getRenderProperty(PROPERTY_IE_ALPHA_RENDER_BORDER, 404 Boolean.FALSE)).booleanValue() ? FillImageRender.FLAG_ENABLE_IE_PNG_ALPHA_FILTER : 0; 405 406 if (windowPane.getRenderProperty(WindowPane.PROPERTY_ICON) != null) { 408 initElement.setAttribute("icon", ImageTools.getUri(rc, this, windowPane, IMAGE_ID_ICON)); 409 Insets iconInsets = (Insets) windowPane.getRenderProperty(WindowPane.PROPERTY_ICON_INSETS); 410 if (iconInsets != null) { 411 initElement.setAttribute("icon-insets", InsetsRender.renderCssAttributeValue(iconInsets)); 412 } 413 } 414 String title = (String ) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE); 415 if (title != null) { 416 initElement.setAttribute("title", title); 417 Insets titleInsets = (Insets) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_INSETS); 418 Color titleForeground = (Color) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_FOREGROUND); 419 if (titleForeground != null) { 420 initElement.setAttribute("title-foreground", ColorRender.renderCssAttributeValue(titleForeground)); 421 } 422 if (titleInsets != null) { 423 initElement.setAttribute("title-insets", InsetsRender.renderCssAttributeValue(titleInsets)); 424 } 425 Font titleFont = (Font) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_FONT); 426 if (titleFont != null) { 427 CssStyle fontCssStyle = new CssStyle(); 428 FontRender.renderToStyle(fontCssStyle, titleFont); 429 initElement.setAttribute("title-font", fontCssStyle.renderInline()); 430 } 431 } 432 Insets titleBarInsets = (Insets) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_BAR_INSETS); 433 if (titleBarInsets != null) { 434 initElement.setAttribute("title-bar-insets", InsetsRender.renderCssAttributeValue(titleBarInsets)); 435 } 436 renderPixelProperty(windowPane, WindowPane.PROPERTY_TITLE_HEIGHT, initElement, "title-height"); 437 Color titleBackground = (Color) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_BACKGROUND); 438 if (titleBackground != null) { 439 initElement.setAttribute("title-background", ColorRender.renderCssAttributeValue(titleBackground)); 440 } 441 FillImage titleBackgroundImage = (FillImage) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE_BACKGROUND_IMAGE); 442 if (titleBackgroundImage != null) { 443 CssStyle titleBackgroundImageCssStyle = new CssStyle(); 444 FillImageRender.renderToStyle(titleBackgroundImageCssStyle, rc, this, windowPane, IMAGE_ID_TITLE_BACKGROUND, 445 titleBackgroundImage, fillImageRenderFlags); 446 initElement.setAttribute("title-background-image", titleBackgroundImageCssStyle.renderInline()); 447 } 448 449 Boolean resizableBoolean = (Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_RESIZABLE); 451 boolean resizable = resizableBoolean == null ? true : resizableBoolean.booleanValue(); 452 initElement.setAttribute("resizable", resizable ? "true" : "false"); 453 Boolean closableBoolean = (Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_CLOSABLE); 454 boolean closable = closableBoolean == null ? true : closableBoolean.booleanValue(); 455 initElement.setAttribute("closable", closable ? "true" : "false"); 456 if (closable) { 457 if (getImage(windowPane, IMAGE_ID_CLOSE_ICON) != null) { 458 initElement.setAttribute("close-icon", ImageTools.getUri(rc, this, windowPane, IMAGE_ID_CLOSE_ICON)); 459 Insets closeIconInsets = (Insets) windowPane.getRenderProperty(WindowPane.PROPERTY_CLOSE_ICON_INSETS); 460 if (closeIconInsets != null) { 461 initElement.setAttribute("close-icon-insets", InsetsRender.renderCssAttributeValue(closeIconInsets)); 462 } 463 } 464 } 465 Boolean movableBoolean = (Boolean ) windowPane.getRenderProperty(WindowPane.PROPERTY_MOVABLE); 466 boolean movable = movableBoolean == null ? true : movableBoolean.booleanValue(); 467 initElement.setAttribute("movable", movable ? "true" : "false"); 468 469 FillImageBorder border = (FillImageBorder) windowPane.getRenderProperty(WindowPane.PROPERTY_BORDER); 471 if (border != null && border.getBorderInsets() != null && border.getContentInsets() != null) { 472 Element borderElement = serverMessage.getDocument().createElement("border"); 473 if (border.getColor() != null) { 474 borderElement.setAttribute("color", ColorRender.renderCssAttributeValue(border.getColor())); 475 } 476 borderElement.setAttribute("border-insets", InsetsRender.renderCssAttributeValue(border.getBorderInsets())); 477 borderElement.setAttribute("content-insets", InsetsRender.renderCssAttributeValue(border.getContentInsets())); 478 for (int i = 0; i < 8; ++i) { 479 FillImage fillImage = border.getFillImage(i); 480 if (fillImage != null) { 481 Element imageElement = serverMessage.getDocument().createElement("image"); 482 imageElement.setAttribute("name", FILL_IMAGE_NAMES[i]); 483 CssStyle fillImageCssStyle = new CssStyle(); 484 FillImageRender.renderToStyle(fillImageCssStyle, rc, this, windowPane, FILL_IMAGE_IDS[i], fillImage, 485 fillImageRenderFlags); 486 imageElement.setAttribute("value", fillImageCssStyle.renderInline()); 487 borderElement.appendChild(imageElement); 488 } 489 } 490 initElement.appendChild(borderElement); 491 } 492 493 partElement.appendChild(initElement); 494 } 495 496 private void renderSetContent(RenderContext rc, ServerComponentUpdate update) { 497 } 499 500 504 public boolean renderUpdate(RenderContext rc, ServerComponentUpdate update, 505 String targetId) { 506 boolean fullReplace = false; 507 if (update.hasUpdatedLayoutDataChildren()) { 508 fullReplace = true; 509 } else if (update.hasUpdatedProperties()) { 510 if (partialUpdateManager.canProcess(rc, update)) { 511 renderUpdateDirective(rc, update); 512 } else { 513 fullReplace = true; 514 } 515 } 516 517 if (update.hasAddedChildren() || update.hasRemovedChildren() || update.hasUpdatedLayoutDataChildren()) { 518 fullReplace = true; 520 } 521 522 if (fullReplace) { 523 renderDisposeDirective(rc, (WindowPane) update.getParent()); 525 DomUpdate.renderElementRemove(rc.getServerMessage(), ContainerInstance.getElementId(update.getParent())); 526 renderAdd(rc, update, targetId, update.getParent()); 527 } else { 528 partialUpdateManager.process(rc, update); 529 if (update.hasAddedChildren() || update.hasRemovedChildren()) { 530 renderSetContent(rc, update); 531 } 532 } 533 534 return fullReplace; 535 } 536 537 private void renderUpdateDirective(RenderContext rc, ServerComponentUpdate update) { 538 WindowPane windowPane = (WindowPane) update.getParent(); 539 540 Element updateElement = rc.getServerMessage().appendPartDirective(ServerMessage.GROUP_ID_PREREMOVE, 541 "EchoWindowPane.MessageProcessor", "update"); 542 String elementId = ContainerInstance.getElementId(windowPane); 543 updateElement.setAttribute("eid", elementId); 544 545 PropertyUpdate positionX = update.getUpdatedProperty(WindowPane.PROPERTY_POSITION_X); 546 if (positionX != null) { 547 renderPixelProperty(windowPane, WindowPane.PROPERTY_POSITION_X, updateElement, "position-x"); 548 } 549 550 PropertyUpdate positionY = update.getUpdatedProperty(WindowPane.PROPERTY_POSITION_Y); 551 if (positionY != null) { 552 renderPixelProperty(windowPane, WindowPane.PROPERTY_POSITION_Y, updateElement, "position-y"); 553 } 554 555 PropertyUpdate width = update.getUpdatedProperty(WindowPane.PROPERTY_WIDTH); 556 if (width != null) { 557 renderPixelProperty(windowPane, WindowPane.PROPERTY_WIDTH, updateElement, "width"); 558 } 559 560 PropertyUpdate height = update.getUpdatedProperty(WindowPane.PROPERTY_HEIGHT); 561 if (height != null) { 562 renderPixelProperty(windowPane, WindowPane.PROPERTY_HEIGHT, updateElement, "height"); 563 } 564 565 if (update.getUpdatedProperty(WindowPane.PROPERTY_TITLE) != null) { 566 updateElement.setAttribute("title", (String ) windowPane.getRenderProperty(WindowPane.PROPERTY_TITLE, " ")); 567 } 568 } 569 } 570 | Popular Tags |