From: Marc Englund Date: Mon, 22 Oct 2007 12:52:55 +0000 (+0000) Subject: setStyle() -> setStyleName() refactor (partial #890). Compromise: setStyle() _removed... X-Git-Tag: 6.7.0.beta1~5793 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e0e48472e6c3960b384e8dfdb03565c46d8b30bc;p=vaadin-framework.git setStyle() -> setStyleName() refactor (partial #890). Compromise: setStyle() _removed_ from Component, _deprecated_ in AbstractComponent. svn changeset:2577/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java b/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java index 63cc57cffa..779dd35a88 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java @@ -207,7 +207,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, "Sample Formatted error", "Sample System Error" }); // Style - String currentStyle = ((Component) objectToConfigure).getStyle(); + String currentStyle = ((Component) objectToConfigure).getStyleName(); if (currentStyle == null) set.replaceWithSelect("style", new Object[] { null }, new Object[] { "Default" }).setNewItemsAllowed(true); diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 62a34ba453..68ceec5b0c 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -151,11 +151,38 @@ public abstract class AbstractComponent implements Component, MethodEventSource */ public abstract String getTag(); + /** + * Gets style for component. Multiple styles are joined with spaces. + * + * @return the component's styleValue of property style. + * @deprecated Use getStyleName() instead; renamed for consistency and to + * indicate that "style" should not be used to switch client + * side implementation, only to style the component. + */ + public String getStyle() { + return getStyleName(); + } + + /** + * Sets and replaces all previous style names of the component. This method + * will trigger a + * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}. + * + * @param style + * the new style of the component. + * @deprecated Use setStyleName() instead; renamed for consistency and to + * indicate that "style" should not be used to switch client + * side implementation, only to style the component. + */ + public void setStyle(String style) { + setStyleName(style); + } + /* * Gets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ - public String getStyle() { + public String getStyleName() { String s = ""; if (styles != null) { for (Iterator it = styles.iterator(); it.hasNext();) { @@ -171,7 +198,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * Sets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ - public void setStyle(String style) { + public void setStyleName(String style) { if (style == null || "".equals(style)) { styles = null; requestRepaint(); diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java index 7af0485e0e..eefa6ff11d 100644 --- a/src/com/itmill/toolkit/ui/Component.java +++ b/src/com/itmill/toolkit/ui/Component.java @@ -55,7 +55,7 @@ public interface Component extends Paintable, VariableOwner { * * @return the component's styleValue of property style. */ - public String getStyle(); + public String getStyleName(); /** * Sets and replaces all previous style names of the component. This method @@ -65,12 +65,12 @@ public interface Component extends Paintable, VariableOwner { * @param style * the new style of the component. */ - public void setStyle(String style); - + public void setStyleName(String style); + /** - * Adds style name to component. Handeling additional style names is - * terminal spesicif, but in web browser enviroment they will most likely - * become CSS classes as given on server side. + * Adds style name to component. Handling additional style names is terminal + * specific, but in web browser environment they will most likely become CSS + * classes as given on server side. * * This method will trigger a * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}. diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java index 2c5267e033..786fdae539 100644 --- a/src/com/itmill/toolkit/ui/CustomComponent.java +++ b/src/com/itmill/toolkit/ui/CustomComponent.java @@ -228,7 +228,7 @@ public class CustomComponent implements Component { * * @see com.itmill.toolkit.ui.Component#getStyle() */ - public String getStyle() { + public String getStyleName() { return null; } @@ -244,7 +244,7 @@ public class CustomComponent implements Component { } /** - * Custom component is allways enabled by default. + * Custom component is always enabled by default. * * @see com.itmill.toolkit.ui.Component#isEnabled() */ @@ -380,11 +380,11 @@ public class CustomComponent implements Component { } /** - * Sets the look-and-feel style of the component. + * Custom component does not implement custom styles by default. * * @see com.itmill.toolkit.ui.Component#setStyle(java.lang.String) */ - public void setStyle(String style) { + public void setStyleName(String style) { } /** @@ -433,13 +433,16 @@ public class CustomComponent implements Component { } /* Dependency -framework is deprecated */ - public void dependsOn(VariableOwner depended) {} - public void removeDirectDependency(VariableOwner depended) {} + public void dependsOn(VariableOwner depended) { + } + + public void removeDirectDependency(VariableOwner depended) { + } + public Set getDirectDependencies() { return null; } - /* Event functions are not implemented by default -------------------- */ /**