summaryrefslogtreecommitdiffstats
path: root/src/com/itmill
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-02-17 14:24:36 +0000
committerMarc Englund <marc.englund@itmill.com>2009-02-17 14:24:36 +0000
commit795cd1ae440b540b14f07d800de48de90cf68c3e (patch)
tree1ce2e0c58d6ef1ac88101690db2134debb1a3c99 /src/com/itmill
parentd999ccc9df0563c0b7d965f632d47c516b74606e (diff)
downloadvaadin-framework-795cd1ae440b540b14f07d800de48de90cf68c3e.tar.gz
vaadin-framework-795cd1ae440b540b14f07d800de48de90cf68c3e.zip
SplitPanel sample + icon updated.
svn changeset:6877/svn branch:trunk
Diffstat (limited to 'src/com/itmill')
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/layouts/75-SplitPanelBasic.pngbin3628 -> 10390 bytes
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasic.java10
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasicExample.java139
3 files changed, 40 insertions, 109 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/features/layouts/75-SplitPanelBasic.png b/src/com/itmill/toolkit/demo/sampler/features/layouts/75-SplitPanelBasic.png
index 39d75a319f..562d6af32b 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/layouts/75-SplitPanelBasic.png
+++ b/src/com/itmill/toolkit/demo/sampler/features/layouts/75-SplitPanelBasic.png
Binary files differ
diff --git a/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasic.java b/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasic.java
index bf2afda6bb..a6b4472fc0 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasic.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasic.java
@@ -9,15 +9,15 @@ public class SplitPanelBasic extends Feature {
@Override
public String getName() {
- return "SplitPanel";
+ return "Split panel";
}
@Override
public String getDescription() {
- return "SplitPanel is a component container that can contain two components."
- + " The split orientation can be either horizontal or vertical. Various"
- + " settings regarding eg. region sizes and resizeability can be set."
- + "<br>Click the button for a demo in a new window.";
+ return "The SplitPanel has two resizable component areas, either"
+ + " vertically or horizontally oriented. The split position"
+ + " can optionally be locked.<br/> By nesting split panels,"
+ + " one can make quite complicated, dynamic layouts.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasicExample.java b/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasicExample.java
index 0fe365b84f..442a9763c2 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasicExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/layouts/SplitPanelBasicExample.java
@@ -1,119 +1,50 @@
package com.itmill.toolkit.demo.sampler.features.layouts;
-import java.net.URL;
-
-import com.itmill.toolkit.demo.sampler.ExampleUtil;
-import com.itmill.toolkit.terminal.ExternalResource;
-import com.itmill.toolkit.ui.AbstractSelect;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.SplitPanel;
-import com.itmill.toolkit.ui.TabSheet;
-import com.itmill.toolkit.ui.Tree;
import com.itmill.toolkit.ui.VerticalLayout;
-import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
public class SplitPanelBasicExample extends VerticalLayout {
- private URL nativeWindowURL = null;
- private Button b1;
+ public static final String brownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. ";
public SplitPanelBasicExample() {
- setSpacing(true);
-
- b1 = new Button("Open a new window with a SplitPanel", this,
- "openButtonClick");
- addComponent(b1);
-
- }
-
- public void openButtonClick(ClickEvent event) {
- if (nativeWindowURL == null) {
- getApplication().addWindow(createWindow());
- }
- getApplication().getMainWindow().open(
- new ExternalResource(nativeWindowURL), "_blank");
- }
-
- /*
- * Create new window which contains the layout obtained from
- * createDemoLayout()
- */
- private Window createWindow() {
- // Create a new window for the SplitPanel
- final Window w = new Window("SplitPanel Demo");
- getApplication().addWindow(w);
- w.setLayout(createDemoLayout());
- nativeWindowURL = w.getURL();
- return w;
- }
-
- /*
- * Creates the actual Layout with two SplitPanels and some content
- */
- private SplitPanel createDemoLayout() {
- // Create a new SplitPanel
- SplitPanel demoSP = new SplitPanel();
- // Set orientation
- demoSP.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL);
- // Set split position (from left edge) in pixels
- demoSP.setSplitPosition(200, UNITS_PIXELS);
-
- // Create an example tree component, set to full size
- Tree t = new Tree("Hardware Inventory", ExampleUtil
- .getHardwareContainer());
- t.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME);
- t.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
- t.setSizeFull();
-
- // Add the Tree component to the SplitPanel
- demoSP.addComponent(t);
-
- // Create a second SplitPanel
- SplitPanel subSP = new SplitPanel();
- // Set orientation
- subSP.setOrientation(SplitPanel.ORIENTATION_VERTICAL);
- // Set split position in percentage
- subSP.setSplitPosition(80);
- // Set the split locked (= not resizeable)
- subSP.setLocked(true);
-
- // Create an example tabsheet component with some content
- final TabSheet ts = new TabSheet();
- final Label l1 = new Label(
- "This window shows an example of a SplitPanel component."
- + " A second SplitPanel is inserted into the first one"
- + " to allow a split into three regions.");
- final Label l2 = new Label(
- "Try resizing the window (horizontally) and you will"
- + " notice that the leftmost region does not resize because"
- + " the split position is set in pixels."
- + " If you resize the window vertically you will see"
- + " how the split position ratio works.");
- final Label l3 = new Label(
- "You may resize the left and right regions by dragging the"
- + " vertical split handle left or right. Resizing the"
- + " upper and lower regions has been disabled.");
- ts.addTab(l1);
- ts.setTabCaption(l1, "SplitPanel demo");
- ts.addTab(l2);
- ts.setTabCaption(l2, "Resizing");
- ts.addTab(l3);
- ts.setTabCaption(l3, "Resizing the regions");
- ts.setSizeFull();
-
- // Add the components to the sub-SplitPanel
- subSP.addComponent(ts);
- subSP.addComponent(new Label("Comment area"));
-
- // Add sub-SplitPanel to main SplitPanel
- demoSP.addComponent(subSP);
-
- // Enable margins in both SplitPanels
- demoSP.setMargin(true);
- subSP.setMargin(true);
+ // First a vertical SplitPanel
+ final SplitPanel vert = new SplitPanel();
+ vert.setHeight("450px");
+ vert.setWidth("100%");
+ // vert.setOrientation(SplitPanel.ORIENTATION_VERTICAL); // default
+ vert.setSplitPosition(150, SplitPanel.UNITS_PIXELS);
+ addComponent(vert);
+
+ // add a label to the upper area
+ vert.addComponent(new Label(brownFox));
+
+ // Add a horizontal SplitPanel to the lower area
+ final SplitPanel horiz = new SplitPanel();
+ horiz.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL);
+ horiz.setSplitPosition(50); // percent
+ vert.addComponent(horiz);
+
+ // left component:
+ horiz.addComponent(new Label(brownFox));
+
+ // right component:
+ horiz.addComponent(new Label(brownFox));
+
+ // Lock toggle button
+ Button toggleLocked = new Button("Splits locked",
+ new Button.ClickListener() {
+ // inline click.listener
+ public void buttonClick(ClickEvent event) {
+ vert.setLocked(event.getButton().booleanValue());
+ horiz.setLocked(event.getButton().booleanValue());
+ }
+ });
+ toggleLocked.setSwitchMode(true);
+ addComponent(toggleLocked);
- return demoSP;
}
} \ No newline at end of file