Search in sources :

Example 6 with WHorizontalRule

use of com.github.bordertech.wcomponents.WHorizontalRule in project wcomponents by BorderTech.

the class ColumnLayoutExample method addHgapVGapExample.

/**
 * Build an example using hgap and vgap.
 *
 * @param hgap the hgap width
 * @param vgap the vgap width
 */
private void addHgapVGapExample(final Size hgap, final Size vgap) {
    add(new WHeading(HeadingLevel.H2, "Column Layout: hgap=" + hgap.toString() + " vgap=" + vgap.toString()));
    WPanel panel = new WPanel();
    panel.setLayout(new ColumnLayout(new int[] { 25, 25, 25, 25 }, hgap, vgap));
    add(panel);
    for (int i = 0; i < 8; i++) {
        panel.add(new BoxComponent("25%"));
    }
    add(new WHorizontalRule());
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) WHeading(com.github.bordertech.wcomponents.WHeading) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Example 7 with WHorizontalRule

use of com.github.bordertech.wcomponents.WHorizontalRule in project wcomponents by BorderTech.

the class ColumnLayoutExample method addAutoWidthExample.

/**
 * This example shows a column which does not have widths set in Java. This is a "good thing": widths should be set in CSS.
 */
private void addAutoWidthExample() {
    add(new WHeading(HeadingLevel.H2, "Automatic (app defined) widths"));
    add(new ExplanatoryText("This example shows what happens if you use undefined (0) column width and do not then define them in CSS."));
    WPanel panel = new WPanel();
    panel.setLayout(new ColumnLayout(new int[] { 0, 0, 0 }, new Alignment[] { Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT }));
    add(panel);
    panel.add(new BoxComponent("Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."));
    panel.add(new BoxComponent("Praesent eu turpis convallis, fringilla elit nec, ullamcorper purus. Proin dictum ac nunc rhoncus fringilla. " + "Pellentesque habitant morbi tristique senectus et netus et malesuada fames."));
    panel.add(new BoxComponent("Vestibulum vehicula a turpis et efficitur. Integer maximus enim a orci posuere, id fermentum magna dignissim. " + "Sed condimentum, dui et condimentum faucibus, quam erat pharetra."));
    panel.add(new BoxComponent("Left"));
    panel.add(new BoxComponent("Center"));
    panel.add(new BoxComponent("Right"));
    add(new WHorizontalRule());
}
Also used : Alignment(com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Example 8 with WHorizontalRule

use of com.github.bordertech.wcomponents.WHorizontalRule in project wcomponents by BorderTech.

the class SafetyContainer method paintComponent.

/**
 * <p>
 * Override paintComponent to provide some protection against bad code when examples are being developed, resulting
 * in invalid XML.</p>
 *
 * <p>
 * Real applications should not emit HTML directly.</p>
 *
 * @param renderContext the RenderContext to send the output to.
 */
@Override
protected void paintComponent(final RenderContext renderContext) {
    final Throwable error = (Throwable) getAttribute(ERROR_KEY);
    if (error == null) {
        if (renderContext instanceof WebXmlRenderContext) {
            // For a WebXmlContext, we can output partial XML.
            WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
            final StringWriter buf = new StringWriter();
            WebXmlRenderContext bufferedContext = new WebXmlRenderContext(new PrintWriter(buf));
            try {
                for (int i = 0; i < shim.getChildCount(); i++) {
                    shim.getChildAt(i).paint(bufferedContext);
                }
                webRenderContext.getWriter().write(buf.toString());
            } catch (final Exception e) {
                new ErrorComponent("Error during rendering", e).paint(renderContext);
                new WHorizontalRule().paint(renderContext);
                PrintWriter writer = webRenderContext.getWriter();
                writer.println("\n<br/>Partial XML:<br/>\n<pre>\n");
                writer.println(WebUtilities.encode(buf.toString()));
                writer.println("\n</pre>");
            }
        } else {
            try {
                for (int i = 0; i < shim.getChildCount(); i++) {
                    shim.getChildAt(i).paint(renderContext);
                }
            } catch (final Exception e) {
                new ErrorComponent("Error during rendering", e).paint(renderContext);
                new WHorizontalRule().paint(renderContext);
            }
        }
    } else {
        new ErrorComponent("Error during action phase", error).paint(renderContext);
    }
}
Also used : WebXmlRenderContext(com.github.bordertech.wcomponents.servlet.WebXmlRenderContext) StringWriter(java.io.StringWriter) SystemException(com.github.bordertech.wcomponents.util.SystemException) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule) PrintWriter(java.io.PrintWriter)

Example 9 with WHorizontalRule

use of com.github.bordertech.wcomponents.WHorizontalRule in project wcomponents by BorderTech.

the class WSkipLinksExample method buildPanel.

/**
 * Creates a panel for the example.
 *
 * @param title the panel title.
 * @return a panel for use in the example.
 */
private WPanel buildPanel(final String title) {
    WPanel panel = new WPanel(WPanel.Type.CHROME);
    panel.setTitleText(title);
    WProgressBar progress = new WProgressBar(18);
    progress.setValue(15);
    panel.add(progress);
    panel.add(new WHorizontalRule());
    WTextField input = new WTextField();
    WLabel label = new WLabel("Text input", input);
    panel.add(label);
    panel.add(input);
    return panel;
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) WPanel(com.github.bordertech.wcomponents.WPanel) WTextField(com.github.bordertech.wcomponents.WTextField) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 10 with WHorizontalRule

use of com.github.bordertech.wcomponents.WHorizontalRule in project wcomponents by BorderTech.

the class ExampleSection method selectExample.

/**
 * Selects an example.
 *
 * @param example the example to select.
 * @param exampleName the name of the example being selected.
 */
public void selectExample(final WComponent example, final String exampleName) {
    WComponent currentExample = container.getChildAt(0).getParent();
    if (currentExample != null && currentExample.getClass().equals(example.getClass())) {
        // Same example selected, do nothing
        return;
    }
    resetExample();
    container.removeAll();
    this.getDecoratedLabel().setBody(new WText(exampleName));
    WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this);
    if (app != null) {
        app.setTitle(exampleName);
    }
    if (example instanceof ErrorComponent) {
        tabset.getTab(0).setText("Error");
        source.setSource(null);
    } else {
        String className = example.getClass().getName();
        WDefinitionList list = new WDefinitionList(WDefinitionList.Type.COLUMN);
        container.add(list);
        list.addTerm("Example path", new WText(className.replaceAll("\\.", " / ")));
        list.addTerm("Example JavaDoc", new JavaDocText(getSource(className)));
        container.add(new WHorizontalRule());
        tabset.getTab(0).setText(example.getClass().getSimpleName());
        source.setSource(getSource(className));
    }
    container.add(example);
    example.setLocked(true);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WText(com.github.bordertech.wcomponents.WText) WApplication(com.github.bordertech.wcomponents.WApplication) WDefinitionList(com.github.bordertech.wcomponents.WDefinitionList) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Aggregations

WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)12 WPanel (com.github.bordertech.wcomponents.WPanel)8 WHeading (com.github.bordertech.wcomponents.WHeading)6 WText (com.github.bordertech.wcomponents.WText)4 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)4 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)3 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)3 Test (org.junit.Test)2 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)1 WApplication (com.github.bordertech.wcomponents.WApplication)1 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)1 WDefinitionList (com.github.bordertech.wcomponents.WDefinitionList)1 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)1 WImage (com.github.bordertech.wcomponents.WImage)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WProgressBar (com.github.bordertech.wcomponents.WProgressBar)1 WTabSet (com.github.bordertech.wcomponents.WTabSet)1 WTextField (com.github.bordertech.wcomponents.WTextField)1