View Javadoc
1   /**
2    * This file Copyright (c) 2018 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.poc;
35  
36  import static com.vaadin.server.Sizeable.Unit.*;
37  
38  import info.magnolia.ui.incub.FieldCaptionActiveExtension;
39  
40  import java.util.stream.StreamSupport;
41  
42  import javax.servlet.annotation.WebServlet;
43  
44  import com.vaadin.annotations.Theme;
45  import com.vaadin.annotations.Title;
46  import com.vaadin.annotations.VaadinServletConfiguration;
47  import com.vaadin.annotations.Widgetset;
48  import com.vaadin.server.VaadinRequest;
49  import com.vaadin.server.VaadinServlet;
50  import com.vaadin.ui.Button;
51  import com.vaadin.ui.GridLayout;
52  import com.vaadin.ui.Label;
53  import com.vaadin.ui.UI;
54  import com.vaadin.ui.themes.ValoTheme;
55  
56  @Theme("poctheme")
57  @Title("Magnolia 6 Resurface - Typefaces Components")
58  @Widgetset("info.magnolia.poc.Widgetset")
59  public class TypefacesComponentUI extends UI {
60  
61      @Override
62      protected void init(VaadinRequest vaadinRequest) {
63  
64          GridLayout layout = new GridLayout(2, 10);
65          layout.setSpacing(true);
66          layout.setMargin(true);
67          layout.setWidth(926, PIXELS);
68          layout.addStyleName("exp-bg-color");
69  
70          Label title1 = new Label("Title 1");
71          title1.addStyleName("h1");
72  
73          Label title2 = new Label("Title 2");
74          title2.addStyleName("h2");
75  
76          Label title3 = new Label("Title 3");
77          title3.addStyleName("h3");
78  
79          Label description = new Label("Description");
80          description.addStyleNames("description");
81  
82          Label actionBarTitle = new Label("Action bar titles");
83          actionBarTitle.addStyleName("actionbar-title");
84  
85          Label actionBarTitleRegular = new Label("Action bar text regular");
86          actionBarTitleRegular.addStyleName("actionbar-text-regular");
87  
88          Label actionBarTitleSmall = new Label("Action bar text small");
89          actionBarTitleSmall.addStyleName("actionbar-text-small");
90  
91          Label textMedium = new Label("Text medium");
92          textMedium.addStyleName("text-medium");
93  
94          Label textRegular = new Label("Text regular");
95          textRegular.addStyleName("text-regular");
96  
97          Label textLight = new Label("Text light");
98          textLight.addStyleName("text-light");
99  
100         Label textTiny = new Label("Text tiny");
101         textTiny.addStyleName("text-tiny");
102 
103         Label fieldLabelDefault = new Label("Field label default");
104         fieldLabelDefault.addStyleName("field-label-default");
105 
106         Label fieldLabelSecondary = new Label("Field label secondary");
107         fieldLabelSecondary.addStyleName("field-label-secondary");
108 
109         Label fieldPlaceholder = new Label("Field placeholder");
110         fieldPlaceholder.addStyleName("field-placeholder");
111 
112         Label fieldLabelFocus = new Label("Field label focus");
113         fieldLabelFocus.addStyleName("field-label-focus");
114 
115         Label fieldInputText = new Label("Field input text");
116         fieldInputText.addStyleName("field-input-text");
117 
118         Label fieldLabelDisable = new Label("Field label disable");
119         fieldLabelDisable.addStyleName("field-label-disable");
120 
121         Label fieldInputTextDisable = new Label("Field input text disable");
122         fieldInputTextDisable.addStyleName("field-input-disable");
123 
124         Label fieldLabelValidation = new Label("Field label validation");
125         fieldLabelValidation.addStyleName("field-label-validation");
126 
127         Label fieldTextValidation = new Label("Field text validation");
128         fieldTextValidation.addStyleName("field-text-validation");
129 
130         Label fieldButtonText = new Label("Field button text");
131         fieldButtonText.addStyleName("field-button-text");
132 
133         Label messageTitleBlack = new Label("Message title black");
134         messageTitleBlack.addStyleName("message-title-black");
135 
136         Label messageTitleWhite = new Label("Message title white");
137         messageTitleWhite.addStyleName("message-title-white");
138 
139         Label messageTextBlack = new Label("Message text black");
140         messageTextBlack.addStyleName("message-text-black");
141 
142         Label messageTextWhite = new Label("Message text white");
143         messageTextWhite.addStyleName("message-text-white");
144 
145         Button regularButton = new Button("Regular button");
146 
147         Button primaryButton = new Button("Primary button");
148         primaryButton.addStyleName("primary");
149 
150         Button secondaryButton = new Button("Secondary button");
151         secondaryButton.addStyleName("secondary");
152 
153         Button linkButton = new Button("Link button");
154         linkButton.addStyleName(ValoTheme.BUTTON_LINK);
155 
156         layout.addComponents(title1,
157                 title2,
158                 title3,
159                 description,
160                 actionBarTitle,
161                 actionBarTitleRegular,
162                 actionBarTitleSmall,
163                 textMedium,
164                 textRegular,
165                 textLight,
166                 textTiny,
167                 fieldLabelDefault,
168                 fieldLabelSecondary,
169                 fieldPlaceholder,
170                 fieldLabelFocus,
171                 fieldInputText,
172                 fieldLabelDisable,
173                 fieldInputTextDisable,
174                 fieldLabelValidation,
175                 fieldTextValidation,
176                 fieldButtonText,
177                 messageTitleBlack,
178                 messageTitleWhite,
179                 messageTextBlack,
180                 messageTextWhite,
181                 regularButton,
182                 primaryButton,
183                 secondaryButton,
184                 linkButton);
185 
186 
187         StreamSupport.stream(layout.spliterator(), false)
188                 .filter(component -> !(component instanceof Button))
189                 .forEach(component -> component.setWidth(100, PERCENTAGE));
190 
191         setContent(layout);
192         FieldCaptionActiveExtension.focusCaptionOf(layout);
193     }
194 
195     @WebServlet(value = "/typefaces/*", asyncSupported = true)
196     @VaadinServletConfiguration(productionMode = false, ui = TypefacesComponentUI.class)
197     public static class Servlet extends VaadinServlet {
198     }
199 }