From 505c4d3bf100d32455b54424092630acb729537c Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Mon, 25 Feb 2008 09:30:01 +0000 Subject: [PATCH] ENHANCEMENT: SplitPanel.setLocked(boolean locked) - allows locking the splitpanel handle (prevents user from dragging it). svn changeset:3907/svn branch:trunk --- .../terminal/gwt/client/ui/ISplitPanel.java | 24 ++++++++++++--- src/com/itmill/toolkit/ui/SplitPanel.java | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) 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 1fc864c1ff..e17271bf33 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java @@ -49,6 +49,10 @@ public class ISplitPanel extends ComplexPanel implements Paintable, private int origMouseY; + private boolean locked; + + private String splitterStyleName; + public ISplitPanel() { this(ORIENTATION_HORIZONTAL); } @@ -99,15 +103,16 @@ public class ISplitPanel extends ComplexPanel implements Paintable, DOM.setStyleAttribute(splitter, "height", "100%"); DOM.setStyleAttribute(firstContainer, "height", "100%"); DOM.setStyleAttribute(secondContainer, "height", "100%"); - DOM.setElementProperty(splitter, "className", CLASSNAME - + "-hsplitter"); } else { DOM.setStyleAttribute(splitter, "width", "100%"); DOM.setStyleAttribute(firstContainer, "width", "100%"); DOM.setStyleAttribute(secondContainer, "width", "100%"); - DOM.setElementProperty(splitter, "className", CLASSNAME - + "-vsplitter"); } + + splitterStyleName = CLASSNAME + + (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter" + : "-vsplitter"); + DOM.setElementProperty(splitter, "className", splitterStyleName); } public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { @@ -117,6 +122,14 @@ public class ISplitPanel extends ComplexPanel implements Paintable, setSplitPosition(uidl.getStringAttribute("position")); + locked = uidl.hasAttribute("locked"); + if (locked) { + DOM.setElementProperty(splitter, "className", splitterStyleName + + "-locked"); + } else { + DOM.setElementProperty(splitter, "className", splitterStyleName); + } + final Paintable newFirstChild = client.getPaintable(uidl .getChildUIDL(0)); final Paintable newSecondChild = client.getPaintable(uidl @@ -278,6 +291,9 @@ public class ISplitPanel extends ComplexPanel implements Paintable, } public void onMouseDown(Event event) { + if (locked) { + return; + } final Element trg = DOM.eventGetTarget(event); if (DOM.compare(trg, splitter) || DOM.compare(trg, DOM.getChild(splitter, 0))) { diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java index dd4c96c4b9..eda36ffb80 100644 --- a/src/com/itmill/toolkit/ui/SplitPanel.java +++ b/src/com/itmill/toolkit/ui/SplitPanel.java @@ -47,6 +47,8 @@ public class SplitPanel extends AbstractLayout { private int posUnit = UNITS_PERCENTAGE; + private boolean locked = false; + /** * Creates a new split panel. The orientation of the panels is * ORIENTATION_VERTICAL. @@ -196,6 +198,10 @@ public class SplitPanel extends AbstractLayout { final String position = pos + UNIT_SYMBOLS[posUnit]; target.addAttribute("position", position); + + if(isLocked()) { + target.addAttribute("locked", true); + } if (firstComponent != null) { firstComponent.paint(target); @@ -269,4 +275,27 @@ public class SplitPanel extends AbstractLayout { posUnit = unit; } + /** + * Lock the SplitPanels position, disabling the user from dragging the split + * handle. + * + * @param locked + * Set true if locked, false + * otherwise. + */ + public void setLocked(boolean locked) { + this.locked = locked; + requestRepaint(); + } + + /** + * Is the SplitPanel handle locked (user not allowed to change split + * position by dragging). + * + * @return true if locked, false otherwise. + */ + public boolean isLocked() { + return locked; + } + } -- 2.39.5