summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <legioth@gmail.com>2018-01-08 12:58:08 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-01-08 12:58:08 +0200
commitaa3a703437e623134c16e81e8f2adef3ea411684 (patch)
tree7c0fe09ae51de190527bf1784151365a1a950000
parent580d60744473b2d01547b1daa4049603c7f05561 (diff)
downloadvaadin-framework-aa3a703437e623134c16e81e8f2adef3ea411684.tar.gz
vaadin-framework-aa3a703437e623134c16e81e8f2adef3ea411684.zip
Rename contentMode to descriptionContentMode in MenuItem (#10494)
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VMenuBar.java20
-rw-r--r--server/src/main/java/com/vaadin/ui/MenuBar.java28
-rw-r--r--server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java10
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarConstants.java2
4 files changed, 31 insertions, 29 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
index 144f6117d0..684527a380 100644
--- a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
@@ -57,8 +57,8 @@ import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.menubar.MenuBarConstants;
public class VMenuBar extends FocusableFlowPanel
- implements CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler,
- FocusHandler, SubPartAware, MouseOutHandler, MouseOverHandler {
+implements CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler,
+FocusHandler, SubPartAware, MouseOutHandler, MouseOverHandler {
// The hierarchy of VMenuBar is a bit weird as VMenuBar is the Paintable,
// used for the root menu but also used for the sub menus.
@@ -793,7 +793,7 @@ public class VMenuBar extends FocusableFlowPanel
*
*/
public static class CustomMenuItem extends Widget
- implements HasHTML, SubPartAware {
+ implements HasHTML, SubPartAware {
protected String html = null;
protected Command command = null;
@@ -805,7 +805,7 @@ public class VMenuBar extends FocusableFlowPanel
protected boolean checked = false;
protected boolean selected = false;
protected String description = null;
- protected ContentMode contentMode = null;
+ protected ContentMode descriptionContentMode = null;
private String styleName;
@@ -1116,23 +1116,23 @@ public class VMenuBar extends FocusableFlowPanel
}
if (uidl.hasAttribute(
- MenuBarConstants.ATTRIBUTE_ITEM_CONTENT_MODE)) {
+ MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION_CONTENT_MODE)) {
String contentModeString = uidl.getStringAttribute(
- MenuBarConstants.ATTRIBUTE_ITEM_CONTENT_MODE);
- contentMode = ContentMode.valueOf(contentModeString);
+ MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION_CONTENT_MODE);
+ descriptionContentMode = ContentMode.valueOf(contentModeString);
} else {
- contentMode = ContentMode.PREFORMATTED;
+ descriptionContentMode = ContentMode.PREFORMATTED;
}
updateStyleNames();
}
public TooltipInfo getTooltip() {
- if (description == null || contentMode == null) {
+ if (description == null || descriptionContentMode == null) {
return null;
}
- return new TooltipInfo(description, contentMode, null,
+ return new TooltipInfo(description, descriptionContentMode, null,
this);
}
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());
diff --git a/shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarConstants.java b/shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarConstants.java
index 4f5fcb72ff..831bab1e5d 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarConstants.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarConstants.java
@@ -24,7 +24,7 @@ public class MenuBarConstants implements Serializable {
@Deprecated
public static final String ATTRIBUTE_ITEM_DESCRIPTION = "description";
@Deprecated
- public static final String ATTRIBUTE_ITEM_CONTENT_MODE = "contentmode";
+ public static final String ATTRIBUTE_ITEM_DESCRIPTION_CONTENT_MODE = "descriptioncontentmode";
@Deprecated
public static final String ATTRIBUTE_ITEM_ICON = "icon";
@Deprecated