diff options
author | Leif Åstrand <legioth@gmail.com> | 2018-01-08 12:58:08 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-01-08 12:58:08 +0200 |
commit | aa3a703437e623134c16e81e8f2adef3ea411684 (patch) | |
tree | 7c0fe09ae51de190527bf1784151365a1a950000 /server/src | |
parent | 580d60744473b2d01547b1daa4049603c7f05561 (diff) | |
download | vaadin-framework-aa3a703437e623134c16e81e8f2adef3ea411684.tar.gz vaadin-framework-aa3a703437e623134c16e81e8f2adef3ea411684.zip |
Rename contentMode to descriptionContentMode in MenuItem (#10494)
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/MenuBar.java | 28 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java | 10 |
2 files changed, 20 insertions, 18 deletions
diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java index 1525782c8a..9a0533cb59 100644 --- a/server/src/main/java/com/vaadin/ui/MenuBar.java +++ b/server/src/main/java/com/vaadin/ui/MenuBar.java @@ -47,7 +47,7 @@ import com.vaadin.ui.declarative.DesignContext; */ @SuppressWarnings("serial") public class MenuBar extends AbstractComponent - implements LegacyComponent, Focusable { +implements LegacyComponent, Focusable { // Items of the top-level menu private final List<MenuItem> menuItems; @@ -144,10 +144,11 @@ public class MenuBar extends AbstractComponent description); } - ContentMode contentMode = item.getContentMode(); + ContentMode contentMode = item.getDescriptionContentMode(); // If the contentMode is equal to ContentMode.PREFORMATTED, we don't add any attribute. if (contentMode != null && contentMode != ContentMode.PREFORMATTED) { - target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_CONTENT_MODE, + target.addAttribute( + MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION_CONTENT_MODE, contentMode.name()); } @@ -466,7 +467,7 @@ public class MenuBar extends AbstractComponent private boolean isSeparator = false; private String styleName; private String description; - private ContentMode contentMode = ContentMode.PREFORMATTED; + private ContentMode descriptionContentMode = ContentMode.PREFORMATTED; private boolean checkable = false; private boolean checked = false; @@ -595,7 +596,7 @@ public class MenuBar extends AbstractComponent */ public MenuBar.MenuItem addItemBefore(String caption, Resource icon, MenuBar.Command command, MenuBar.MenuItem itemToAddBefore) - throws IllegalStateException { + throws IllegalStateException { if (isCheckable()) { throw new IllegalStateException( "A checkable item cannot have children"); @@ -825,7 +826,7 @@ public class MenuBar extends AbstractComponent */ public void setDescription(String description, ContentMode mode) { this.description = description; - this.contentMode = mode; + this.descriptionContentMode = mode; markAsDirty(); } @@ -902,8 +903,8 @@ public class MenuBar extends AbstractComponent * @see ContentMode * @since 8.3 */ - public ContentMode getContentMode() { - return contentMode; + public ContentMode getDescriptionContentMode() { + return descriptionContentMode; } /** @@ -1035,9 +1036,9 @@ public class MenuBar extends AbstractComponent DesignAttributeHandler.writeAttribute("description", attr, item.getDescription(), def.getDescription(), String.class, context); - DesignAttributeHandler.writeAttribute("contentmode", attr, - item.getContentMode().name(), def.getContentMode().name(), String.class, - context); + DesignAttributeHandler.writeAttribute("descriptioncontentmode", attr, + item.getDescriptionContentMode().name(), + def.getDescriptionContentMode().name(), String.class, context); DesignAttributeHandler.writeAttribute("style-name", attr, item.getStyleName(), def.getStyleName(), String.class, context); @@ -1098,8 +1099,9 @@ public class MenuBar extends AbstractComponent } if (menuElement.hasAttr("description")) { String description = DesignAttributeHandler.readAttribute("description", attr, String.class); - if (menuElement.hasAttr("contentmode")) { - String contentModeString = DesignAttributeHandler.readAttribute("contentmode", attr, String.class); + if (menuElement.hasAttr("descriptioncontentmode")) { + String contentModeString = DesignAttributeHandler.readAttribute( + "descriptioncontentmode", attr, String.class); menu.setDescription(description, ContentMode.valueOf(contentModeString)); } else { menu.setDescription(description); diff --git a/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java index 68f1fad864..55b1b84c75 100644 --- a/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java @@ -25,10 +25,10 @@ import org.junit.Test; import com.vaadin.server.ExternalResource; import com.vaadin.server.ThemeResource; +import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.design.DeclarativeTestBase; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.MenuItem; -import com.vaadin.shared.ui.ContentMode; /** * Tests declarative support for menu bars. @@ -74,8 +74,8 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase<MenuBar> { String design = "<vaadin-menu-bar plain-text>" + "<menu description=\"This description is implicitly preformatted\">One</menu>" + "<menu description=\"This description\nis explicitly\n\npreformatted\">preformatted</menu>" - + "<menu contentmode=\"HTML\" description=\"<b>I</b> contain <br/> <e>html</e>\">HTML</menu>" - + "<menu contentmode=\"TEXT\" description=\"Just plain text\">plain text</menu>" + + "<menu descriptioncontentmode=\"HTML\" description=\"<b>I</b> contain <br/> <e>html</e>\">HTML</menu>" + + "<menu descriptioncontentmode=\"TEXT\" description=\"Just plain text\">plain text</menu>" + "</vaadin-menu-bar>"; MenuBar menuBar = new MenuBar(); menuBar.addItem("One", null).setDescription("This description is implicitly preformatted"); @@ -192,8 +192,8 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase<MenuBar> { actual.getDescription()); assertEquals(baseError + "Style Name", expected.getStyleName(), actual.getStyleName()); - assertEquals(baseError + "Content Mode", expected.getContentMode(), - actual.getContentMode()); + assertEquals(baseError + "Content Mode", expected.getDescriptionContentMode(), + actual.getDescriptionContentMode()); if (expected.getIcon() != null) { assertNotNull(baseError + "Icon was null", actual.getIcon()); |