From: Jouni Koivuviita Date: Wed, 18 Feb 2009 15:04:55 +0000 (+0000) Subject: Fixes #2605: Splitpanel CSS affects nested splitpanels. X-Git-Tag: 6.7.0.beta1~3116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=70be0e7731b85cd8ea31665cfcfd7bf267276fa3;p=vaadin-framework.git Fixes #2605: Splitpanel CSS affects nested splitpanels. Split panel element source order changed also, the splitter element is now top-most. svn changeset:6896/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java index 7a0cc981cb..6928475549 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java @@ -60,7 +60,7 @@ public class ISplitPanel extends ComplexPanel implements Container, private boolean locked = false; - private String splitterStyleName; + private String[] componentStyleNames; private Element draggingCurtain; @@ -113,9 +113,9 @@ public class ISplitPanel extends ComplexPanel implements Container, DOM.setStyleAttribute(wrapper, "width", "100%"); DOM.setStyleAttribute(wrapper, "height", "100%"); - DOM.appendChild(wrapper, splitter); DOM.appendChild(wrapper, secondContainer); DOM.appendChild(wrapper, firstContainer); + DOM.appendChild(wrapper, splitter); DOM.setStyleAttribute(splitter, "position", "absolute"); DOM.setStyleAttribute(secondContainer, "position", "absolute"); @@ -129,18 +129,20 @@ public class ISplitPanel extends ComplexPanel implements Container, this.orientation = orientation; if (orientation == ORIENTATION_HORIZONTAL) { DOM.setStyleAttribute(splitter, "height", "100%"); + DOM.setStyleAttribute(splitter, "top", "0"); DOM.setStyleAttribute(firstContainer, "height", "100%"); DOM.setStyleAttribute(secondContainer, "height", "100%"); } else { DOM.setStyleAttribute(splitter, "width", "100%"); + DOM.setStyleAttribute(splitter, "left", "0"); DOM.setStyleAttribute(firstContainer, "width", "100%"); DOM.setStyleAttribute(secondContainer, "width", "100%"); } - splitterStyleName = CLASSNAME - + (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter" - : "-vsplitter"); - DOM.setElementProperty(splitter, "className", splitterStyleName); + DOM.setElementProperty(firstContainer, "className", CLASSNAME + + "-first-container"); + DOM.setElementProperty(secondContainer, "className", CLASSNAME + + "-second-container"); } public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { @@ -155,8 +157,16 @@ public class ISplitPanel extends ComplexPanel implements Container, return; } + if (uidl.hasAttribute("style")) { + componentStyleNames = uidl.getStringAttribute("style").split(" "); + } else { + componentStyleNames = new String[0]; + } + setLocked(uidl.getBooleanAttribute("locked")); + setStylenames(); + setSplitPosition(uidl.getStringAttribute("position")); final Paintable newFirstChild = client.getPaintable(uidl @@ -180,7 +190,7 @@ public class ISplitPanel extends ComplexPanel implements Container, renderInformation.updateSize(getElement()); - if (Util.isIE7()) { + if (BrowserInfo.get().isIE7()) { // Part III of IE7 hack DeferredCommand.addCommand(new Command() { public void execute() { @@ -195,15 +205,8 @@ public class ISplitPanel extends ComplexPanel implements Container, private void setLocked(boolean newValue) { if (locked != newValue) { locked = newValue; - if (locked) { - DOM.setElementProperty(splitter, "className", splitterStyleName - + "-locked"); - } else { - DOM - .setElementProperty(splitter, "className", - splitterStyleName); - } splitterSize = -1; + setStylenames(); } } @@ -352,8 +355,7 @@ public class ISplitPanel extends ComplexPanel implements Container, return; } final Element trg = DOM.eventGetTarget(event); - if (DOM.compare(trg, splitter) - || DOM.compare(trg, DOM.getChild(splitter, 0))) { + if (trg == splitter || trg == DOM.getChild(splitter, 0)) { resizing = true; if (BrowserInfo.get().isGecko()) { showDraggingCurtain(); @@ -538,8 +540,7 @@ public class ISplitPanel extends ComplexPanel implements Container, } public void updateCaption(Paintable component, UIDL uidl) { - // TODO Auto-generated method stub - + // TODO Implement caption handling } /** @@ -553,4 +554,31 @@ public class ISplitPanel extends ComplexPanel implements Container, client.updateVariable(id, "position", pos, immediate); } + private void setStylenames() { + final String splitterSuffix = (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter" + : "-vsplitter"); + final String firstContainerSuffix = "-first-container"; + final String secondContainerSuffix = "-second-container"; + String lockedSuffix = ""; + + String splitterStyle = CLASSNAME + splitterSuffix; + String firstStyle = CLASSNAME + firstContainerSuffix; + String secondStyle = CLASSNAME + secondContainerSuffix; + + if (locked) { + splitterStyle = CLASSNAME + splitterSuffix + "-locked"; + lockedSuffix = "-locked"; + } + for (int i = 0; i < componentStyleNames.length; i++) { + splitterStyle += " " + CLASSNAME + splitterSuffix + "-" + + componentStyleNames[i] + lockedSuffix; + firstStyle += " " + CLASSNAME + firstContainerSuffix + "-" + + componentStyleNames[i]; + secondStyle += " " + CLASSNAME + secondContainerSuffix + "-" + + componentStyleNames[i]; + } + DOM.setElementProperty(splitter, "className", splitterStyle); + DOM.setElementProperty(firstContainer, "className", firstStyle); + DOM.setElementProperty(secondContainer, "className", secondStyle); + } }