click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadr...@apache.org
Subject svn commit: r955583 - in /click/trunk/click/examples: src/org/apache/click/examples/control/ src/org/apache/click/examples/page/control/ webapp/WEB-INF/ webapp/assets/css/ webapp/control/
Date Thu, 17 Jun 2010 13:13:05 GMT
Author: aadrian
Date: Thu Jun 17 13:13:05 2010
New Revision: 955583

URL: http://svn.apache.org/viewvc?rev=955583&view=rev
Log:
Added FieldSeparator Control and Example: CLK-544

Added:
    click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java 
 (with props)
    click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java
  (with props)
    click/trunk/click/examples/webapp/assets/css/separator.css   (with props)
    click/trunk/click/examples/webapp/control/field-separator-demo.htm   (with props)
Modified:
    click/trunk/click/examples/webapp/WEB-INF/menu.xml

Added: click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java?rev=955583&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java Thu
Jun 17 13:13:05 2010
@@ -0,0 +1,55 @@
+package org.apache.click.examples.control;
+
+import org.apache.click.Context;
+import org.apache.click.control.FieldSet;
+import org.apache.click.element.CssImport;
+import org.apache.click.element.Element;
+import org.apache.click.util.ClickUtils;
+
+import java.util.List;
+
+/**
+ * FieldSeparator is a component derived from a FieldSet that acts as a visual separator
+ * having a label/legend too. This component is practical in forms where a FieldSet would
+ * not align correctly the fields due to variable label width between the groups.<p/>
+ *
+ * @see FieldSeparatorDemo
+ *
+ */
+public class FieldSeparator extends FieldSet {
+    public FieldSeparator(String name) {
+        super(name);
+        addStyleClass("fieldSeparator");        
+    }
+
+    public FieldSeparator(String name, String legend) {
+        super(name, legend);
+        addStyleClass("fieldSeparator");
+    }
+
+    public FieldSeparator() {
+        super();
+        addStyleClass("fieldSeparator");
+    }
+    
+    /**
+     * Returns the FieldSeparator HTML HEAD elements for the
+     * <tt>click/control.css</tt> resource.
+     *
+     * @see org.apache.click.Control#getHeadElements()
+     *
+     * @return the list of HEAD elements to be included in the page
+     */
+    public List<Element> getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            Context context = getContext();
+            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);
+
+            headElements.add(new CssImport("/assets/css/separator.css", versionIndicator));
+        }
+        return headElements;
+    }
+
+}

Propchange: click/trunk/click/examples/src/org/apache/click/examples/control/FieldSeparator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java?rev=955583&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java
(added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java
Thu Jun 17 13:13:05 2010
@@ -0,0 +1,93 @@
+package org.apache.click.examples.page.control;
+
+import org.apache.click.control.*;
+import org.apache.click.examples.control.FieldSeparator;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.page.HomePage;
+import org.apache.click.extras.control.EmailField;
+import org.apache.click.extras.control.PageSubmit;
+import org.apache.click.util.Bindable;
+import org.apache.click.util.ContainerUtils;
+
+/**
+ * Provides a form FieldSet usage as Separator example.
+ */
+public class FieldSeparatorDemo extends BorderPage {
+    private static final long serialVersionUID = 1L;
+
+    @Bindable protected Form classicForm = new Form();
+    @Bindable protected Form newForm = new Form();
+
+    public FieldSeparatorDemo() {
+        // field set based form
+        makeFieldSetForm();
+
+        // separator based form
+        makeSeparatorForm();
+    }
+
+    private void makeFieldSetForm() {
+        classicForm.setLabelAlign(Form.ALIGN_RIGHT);
+        classicForm.setButtonAlign(Form.ALIGN_RIGHT);
+        FieldSet contactFieldSet = new FieldSet("contactDetails");
+        classicForm.add(contactFieldSet);
+        TextField name = new TextField("name");
+        contactFieldSet.add(name);
+        EmailField email = new EmailField("email");
+        contactFieldSet.add(email);
+
+        FieldSet feedbackFieldSet = new FieldSet("feedbackDetails");
+        classicForm.add(feedbackFieldSet);
+        TextArea comment = new TextArea("Comment");
+        feedbackFieldSet.add(comment);
+
+        Checkbox inform = new Checkbox("inform", "Yes, I agree!");
+        feedbackFieldSet.add(inform);
+        classicForm.add(new Submit("ok", "  OK  ",  this, "onOkClick1"));
+        classicForm.add(new PageSubmit("cancel", HomePage.class));
+    }
+
+    private void makeSeparatorForm() {
+        newForm.setLabelAlign(Form.ALIGN_RIGHT);
+        newForm.setButtonAlign(Form.ALIGN_RIGHT);
+        FieldSeparator contactFieldSet = new FieldSeparator("contactDetails");
+        newForm.add(contactFieldSet);
+        TextField name = new TextField("name");
+        newForm.add(name);
+        EmailField email = new EmailField("email");
+        newForm.add(email);
+
+        FieldSeparator feedbackFieldSet = new FieldSeparator("feedbackDetails");
+        newForm.add(feedbackFieldSet);
+        TextArea comment = new TextArea("Comment");
+        newForm.add(comment);
+
+        Checkbox inform = new Checkbox("inform","Yes, I agree!");
+        newForm.add(inform);
+
+        FieldSeparator sepo = new FieldSeparator("separator","");
+        newForm.add(sepo);
+
+        newForm.add(new Submit("ok", "  OK  ",  this, "onOkClick2"));
+        newForm.add(new PageSubmit("cancel", HomePage.class));
+    }
+
+    public boolean onOkClick1(){
+        if(classicForm.isValid()){
+            for (Field field : ContainerUtils.getInputFields(classicForm)) {
+                System.out.println(field.getName() + "=" + field.getValue());
+            }            
+        }
+        return true;
+    }
+
+    public boolean onOkClick2(){
+        if(newForm.isValid()){
+            for (Field field : ContainerUtils.getInputFields(newForm)) {
+                System.out.println(field.getName() + "=" + field.getValue());
+            }
+        }
+        return true;
+    }
+
+}

Propchange: click/trunk/click/examples/src/org/apache/click/examples/page/control/FieldSeparatorDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=955583&r1=955582&r2=955583&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ click/trunk/click/examples/webapp/WEB-INF/menu.xml Thu Jun 17 13:13:05 2010
@@ -74,6 +74,7 @@
     <menu label="Action Controls" path="control/action-demo.htm"/>
     <menu label="CheckList" path="control/check-list-demo.htm"/>
     <menu label="FieldSet" path="control/field-set-demo.htm"/>
+    <menu label="FieldSeparator" path="control/field-separator-demo.htm"/>
     <menu label="FileField" path="control/file-upload.htm"/>
     <menu label="ImageSubmit" path="control/image-demo.htm"/>
     <menu label="Link Controls" path="control/link-demo.htm"/>

Added: click/trunk/click/examples/webapp/assets/css/separator.css
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/assets/css/separator.css?rev=955583&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/assets/css/separator.css (added)
+++ click/trunk/click/examples/webapp/assets/css/separator.css Thu Jun 17 13:13:05 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * FieldSeparator Control specific style.
+ */
+.fieldSeparator {
+    border-bottom:0;
+    border-left:0;
+    border-right:0;
+    margin-top:1em;
+}
\ No newline at end of file

Propchange: click/trunk/click/examples/webapp/assets/css/separator.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: click/trunk/click/examples/webapp/control/field-separator-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/control/field-separator-demo.htm?rev=955583&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/control/field-separator-demo.htm (added)
+++ click/trunk/click/examples/webapp/control/field-separator-demo.htm Thu Jun 17 13:13:05
2010
@@ -0,0 +1,31 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.*#
+-->
+<style type="text/css">
+    td.box {       
+        padding-left: 2em;
+        padding-right: 2em;
+    }
+</style>
+<p>FieldSet vs FieldSeparator usage:</p>
+<table>
+    <tr>
+        <td class="box" style="border-right: solid 3px #d3d3d3;">$classicForm</td>
+        <td class="box">$newForm</td>
+    </tr>
+</table>
\ No newline at end of file

Propchange: click/trunk/click/examples/webapp/control/field-separator-demo.htm
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message