From ae106c9b5e64a8ea88965ca850eef78c3e6d109b Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Wed, 3 Mar 2010 11:05:31 +0000 Subject: [PATCH] Fixes #3736 "Split up style and type definitions" and #3467 "Button styles missing?" * Now all built-in themes have an accompanying class file that describes all provided style names. * Deprecated Button.STYLE_LINK in favor of BaseTheme.BUTTON_LINK * Deprecated Panel.STYLE_LIGHT in favor of Reindeer.PANEL_LIGHT and Runo.PANEL_LIGHT svn changeset:11601/svn branch:6.3 --- src/com/vaadin/ui/Button.java | 8 +- src/com/vaadin/ui/Panel.java | 12 ++ src/com/vaadin/ui/themes/BaseTheme.java | 44 +++++++ src/com/vaadin/ui/themes/Reindeer.java | 163 ++++++++++++++++++++++++ src/com/vaadin/ui/themes/Runo.java | 30 +++++ 5 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 src/com/vaadin/ui/themes/BaseTheme.java create mode 100644 src/com/vaadin/ui/themes/Reindeer.java create mode 100644 src/com/vaadin/ui/themes/Runo.java diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 3ed50b2d42..65a34a18bb 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -13,6 +13,7 @@ import com.vaadin.data.Property; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.VButton; +import com.vaadin.ui.themes.BaseTheme; /** * A generic button component. @@ -239,7 +240,12 @@ public class Button extends AbstractField { private static final Method BUTTON_CLICK_METHOD; - /* Button style with no decorations. Looks like a link, acts like a button */ + /** + * Button style with no decorations. Looks like a link, acts like a button + * + * @deprecated use {@link BaseTheme#BUTTON_LINK} instead. + */ + @Deprecated public static final String STYLE_LINK = "link"; static { diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index df08c4e62b..f4ce352687 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -19,6 +19,8 @@ import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Scrollable; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VPanel; +import com.vaadin.ui.themes.Reindeer; +import com.vaadin.ui.themes.Runo; /** * Panel - a simple single component container. @@ -36,6 +38,16 @@ public class Panel extends AbstractComponentContainer implements Scrollable, private static final String CLICK_EVENT = VPanel.CLICK_EVENT_IDENTIFIER; + /** + * Removes extra decorations from the Panel. + * + * @deprecated this style is no longer part of the core framework and this + * component, even though most built-in themes implement this + * style. Use the constant specified in the theme class file + * that you're using, if it provides one, e.g. + * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT} . + */ + @Deprecated public static final String STYLE_LIGHT = "light"; /** diff --git a/src/com/vaadin/ui/themes/BaseTheme.java b/src/com/vaadin/ui/themes/BaseTheme.java new file mode 100644 index 0000000000..48083f5240 --- /dev/null +++ b/src/com/vaadin/ui/themes/BaseTheme.java @@ -0,0 +1,44 @@ +package com.vaadin.ui.themes; + +/** + *

+ * The Base theme is the foundation for all Vaadin themes. Although it is not + * necessary to use it as the starting point for all other themes, it is heavily + * encouraged, since it abstracts and hides away many necessary style properties + * that the Vaadin terminal expects and needs. + *

+ *

+ * When creating your own theme, either extend this class and specify the styles + * implemented in your theme here, or extend some other theme that has a class + * file specified (e.g. Reindeer or Runo). + *

+ *

+ * All theme class files should follow the convention of specifying the theme + * name as a string constant THEME_NAME. + * + * @since 6.3.0 + * + */ +public class BaseTheme { + + public static final String THEME_NAME = "Base"; + + /** + * Creates a button that looks like a regular hypertext link but still acts + * like a normal button. + */ + public static final String BUTTON_LINK = "link"; + + /** + * Removes extra decorations from the panel. + * + * @deprecated Base theme does not implement this style, but it is defined + * here since it has been a part of the framework before + * multiple themes were available. Use the constant provided by + * the theme you're using instead, e.g. + * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}. + */ + @Deprecated + public static final String PANEL_LIGHT = "light"; + +} \ No newline at end of file diff --git a/src/com/vaadin/ui/themes/Reindeer.java b/src/com/vaadin/ui/themes/Reindeer.java new file mode 100644 index 0000000000..acbf003151 --- /dev/null +++ b/src/com/vaadin/ui/themes/Reindeer.java @@ -0,0 +1,163 @@ +package com.vaadin.ui.themes; + +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.VerticalLayout; + +public class Reindeer extends BaseTheme { + + public static final String THEME_NAME = "Reindeer"; + + /*************************************************************************** + * + * Label styles + * + **************************************************************************/ + + /** + * Large font for main application headings + */ + public static final String LABEL_H1 = "h1"; + + /** + * Large font for different sections in the application + */ + public static final String LABEL_H2 = "h2"; + + /** + * Small and a little lighter font + */ + public static final String LABEL_SMALL = "light"; + + /*************************************************************************** + * + * Button styles + * + **************************************************************************/ + + /** + * Default action style for buttons (the button that gets activated when + * user presses 'enter' in a form). Use sparingly, only one default button + * per screen should be visible. + */ + public static final String BUTTON_DEFAULT = "primary"; + + /** + * Small sized button, use for context specific actions for example + */ + public static final String BUTTON_SMALL = "small"; + + /*************************************************************************** + * + * TextField styles + * + **************************************************************************/ + + /** + * Small sized text field with small font + */ + public static final String TEXTFIELD_SMALL = "small"; + + /*************************************************************************** + * + * Panel styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the panel + */ + public static final String PANEL_LIGHT = "light"; + + /*************************************************************************** + * + * SplitPanel styles + * + **************************************************************************/ + + /** + * Reduces the split handle to a minimal size (1 pixel) + */ + public static final String SPLITPANEL_SMALL = "small"; + + /*************************************************************************** + * + * TabSheet styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the tab sheet, and shows the + * tabs as a small bar. + */ + public static final String TABSHEET_BAR = "bar"; + + /** + * Removes borders and background color from the tab sheet. The tabs are + * presented with minimal lines indicating the selected tab. + */ + public static final String TABSHEET_MINIMAL = "minimal"; + + /*************************************************************************** + * + * Table styles + * + **************************************************************************/ + + /** + * Removes borders from the table + */ + public static final String TABLE_BORDERLESS = "borderless"; + + /** + * Makes the table headers dark and more prominent. + */ + public static final String TABLE_STRONG = "strong"; + + /*************************************************************************** + * + * Layout styles + * + **************************************************************************/ + + /** + * Changes the background of a layout to a shade of blue. Applies to + * {@link VerticalLayout}, {@link HorizontalLayout}, {@link GridLayout}, + * {@link FormLayout} and {@link CssLayout}. + */ + public static final String LAYOUT_BLUE = "blue"; + + /** + *

+ * Changes the background of a layout to almost black, and at the same time + * transforms contained components to their black style correspondents when + * available. At least texts, buttons, text fields, selects, date fields, + * tables and a few other component styles should change. + *

+ *

+ * Applies to {@link VerticalLayout}, {@link HorizontalLayout}, + * {@link GridLayout}, {@link FormLayout} and {@link CssLayout}. + *

+ * + */ + public static final String LAYOUT_BLACK = "black"; + + /*************************************************************************** + * + * Window styles + * + **************************************************************************/ + + /** + * Makes the whole window white and increases the font size of the title. + */ + public static final String WINDOW_LIGHT = "light"; + + /** + * Makes the whole window black, and changes contained components in the + * same way as {@link #LAYOUT_BLACK} does. + */ + public static final String WINDOW_BLACK = "black"; +} diff --git a/src/com/vaadin/ui/themes/Runo.java b/src/com/vaadin/ui/themes/Runo.java new file mode 100644 index 0000000000..4df6046756 --- /dev/null +++ b/src/com/vaadin/ui/themes/Runo.java @@ -0,0 +1,30 @@ +package com.vaadin.ui.themes; + + +public class Runo extends BaseTheme { + + public static final String THEME_NAME = "Runo"; + + /*************************************************************************** + * + * Button styles + * + **************************************************************************/ + + /** + * Small sized button, use for context specific actions for example + */ + public static final String BUTTON_SMALL = "small"; + + /*************************************************************************** + * + * Panel styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the panel + */ + public static final String PANEL_LIGHT = "light"; + +} -- 2.39.5