summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java12
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java10
-rw-r--r--server/src/com/vaadin/ui/AbstractSplitPanel.java4
-rw-r--r--server/src/com/vaadin/ui/Button.java3
-rw-r--r--server/src/com/vaadin/ui/DragAndDropWrapper.java2
-rw-r--r--server/src/com/vaadin/ui/Grid.java3
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java10
-rw-r--r--server/src/com/vaadin/ui/Label.java2
-rw-r--r--server/src/com/vaadin/ui/MenuBar.java4
-rw-r--r--server/src/com/vaadin/ui/Slider.java2
-rw-r--r--server/src/com/vaadin/ui/Table.java4
-rw-r--r--server/src/com/vaadin/ui/Window.java4
-rw-r--r--server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java22
13 files changed, 42 insertions, 40 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 42b36b0f21..d3506e9097 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -1176,16 +1176,16 @@ public abstract class AbstractComponent extends AbstractClientConnector
// first try the full shorthands
if (widthFull && heightFull) {
- attributes.put("size-full", "");
+ attributes.put("size-full", true);
} else if (widthAuto && heightAuto) {
- attributes.put("size-auto", "");
+ attributes.put("size-auto", true);
} else {
// handle width
if (!hasEqualWidth(defaultInstance)) {
if (widthFull) {
- attributes.put("width-full", "");
+ attributes.put("width-full", true);
} else if (widthAuto) {
- attributes.put("width-auto", "");
+ attributes.put("width-auto", true);
} else {
String widthString = DesignAttributeHandler.getFormatter()
.format(getWidth()) + getWidthUnits().getSymbol();
@@ -1196,9 +1196,9 @@ public abstract class AbstractComponent extends AbstractClientConnector
if (!hasEqualHeight(defaultInstance)) {
// handle height
if (heightFull) {
- attributes.put("height-full", "");
+ attributes.put("height-full", true);
} else if (heightAuto) {
- attributes.put("height-auto", "");
+ attributes.put("height-auto", true);
} else {
String heightString = DesignAttributeHandler.getFormatter()
.format(getHeight()) + getHeightUnits().getSymbol();
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index afe4717212..e0dbcb004b 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -547,19 +547,19 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
// handle alignment
Alignment alignment = getComponentAlignment(child);
if (alignment.isMiddle()) {
- childElement.attr(":middle", "");
+ childElement.attr(":middle", true);
} else if (alignment.isBottom()) {
- childElement.attr(":bottom", "");
+ childElement.attr(":bottom", true);
}
if (alignment.isCenter()) {
- childElement.attr(":center", "");
+ childElement.attr(":center", true);
} else if (alignment.isRight()) {
- childElement.attr(":right", "");
+ childElement.attr(":right", true);
}
// handle expand ratio
float expandRatio = getExpandRatio(child);
if (expandRatio == 1.0f) {
- childElement.attr(":expand", "");
+ childElement.attr(":expand", true);
} else if (expandRatio > 0) {
childElement.attr(":expand", DesignAttributeHandler
.getFormatter().format(expandRatio));
diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java
index cae98fd71d..271c4df571 100644
--- a/server/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -735,7 +735,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
+ getMaxSplitPositionUnit());
}
if (getSplitterState().positionReversed) {
- design.attr("reversed", "");
+ design.attr("reversed", true);
}
// handle child components
if (!designContext.shouldWriteChildren(this, def)) {
@@ -750,7 +750,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
if (secondComponent != null) {
Element childElement = designContext.createElement(secondComponent);
if (firstComponent == null) {
- childElement.attr(":second", "");
+ childElement.attr(":second", true);
}
design.appendChild(childElement);
}
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index 5c12f20479..cb8ba66217 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
-import org.jsoup.parser.Parser;
import com.vaadin.event.Action;
import com.vaadin.event.ShortcutAction;
@@ -635,7 +634,7 @@ public class Button extends AbstractFocusable implements
}
// plain-text (default is html)
if (!isHtmlContentAllowed()) {
- design.attr(DESIGN_ATTR_PLAIN_TEXT, "");
+ design.attr(DESIGN_ATTR_PLAIN_TEXT, true);
// encode HTML entities
if (content != null) {
design.html(DesignFormatter.encodeForTextNode(content));
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java
index ba912f15dc..90b3b56ef6 100644
--- a/server/src/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java
@@ -491,7 +491,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
if (getDragStartMode() == DragStartMode.COMPONENT_OTHER) {
Element child = designContext
.createElement(getDragImageComponent());
- child.attr(":drag-image", "");
+ child.attr(":drag-image", true);
design.appendChild(child);
}
}
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index d44cb31cb0..c26e6d6705 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -2226,8 +2226,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
DesignContext designContext) {
switch (cellState.type) {
case TEXT:
- DesignAttributeHandler.writeAttribute("plain-text",
- cellElement.attributes(), "", null, String.class);
+ cellElement.attr("plain-text", true);
cellElement.appendText(getText());
break;
case HTML:
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 7eb870d1f8..8517962e91 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -1512,14 +1512,14 @@ public class GridLayout extends AbstractLayout implements
Alignment alignment = getComponentAlignment(child);
if (alignment.isMiddle()) {
- childElement.attr(":middle", "");
+ childElement.attr(":middle", true);
} else if (alignment.isBottom()) {
- childElement.attr(":bottom", "");
+ childElement.attr(":bottom", true);
}
if (alignment.isCenter()) {
- childElement.attr(":center", "");
+ childElement.attr(":center", true);
} else if (alignment.isRight()) {
- childElement.attr(":right", "");
+ childElement.attr(":right", true);
}
col.appendChild(childElement);
@@ -1659,4 +1659,4 @@ public class GridLayout extends AbstractLayout implements
result.add("columns");
return result;
}
-} \ No newline at end of file
+}
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index 79d9491ae9..2b96d51fa5 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -629,7 +629,7 @@ public class Label extends AbstractComponent implements Property<String>,
}
// plain-text (default is html)
if (getContentMode() == ContentMode.TEXT) {
- design.attr(DESIGN_ATTR_PLAIN_TEXT, "");
+ design.attr(DESIGN_ATTR_PLAIN_TEXT, true);
design.html(DesignFormatter.encodeForTextNode(getValue()));
}
}
diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java
index c11cf02aaf..9f05df7869 100644
--- a/server/src/com/vaadin/ui/MenuBar.java
+++ b/server/src/com/vaadin/ui/MenuBar.java
@@ -952,12 +952,12 @@ public class MenuBar extends AbstractComponent implements LegacyComponent,
// in many cases there seems to be an empty more menu item
if (getMoreMenuItem() != null && !getMoreMenuItem().getText().isEmpty()) {
Element moreMenu = createMenuElement(getMoreMenuItem());
- moreMenu.attr("more", "");
+ moreMenu.attr("more", true);
design.appendChild(moreMenu);
}
if (!htmlContentAllowed) {
- design.attr(DESIGN_ATTR_PLAIN_TEXT, "");
+ design.attr(DESIGN_ATTR_PLAIN_TEXT, true);
}
}
diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java
index 6b0880efd5..e85f634ac4 100644
--- a/server/src/com/vaadin/ui/Slider.java
+++ b/server/src/com/vaadin/ui/Slider.java
@@ -381,7 +381,7 @@ public class Slider extends AbstractField<Double> {
public void writeDesign(Element design, DesignContext context) {
super.writeDesign(design, context);
if (getOrientation() == SliderOrientation.VERTICAL) {
- design.attr("vertical", "");
+ design.attr("vertical", true);
}
Slider defaultSlider = context.getDefaultInstance(this);
DesignAttributeHandler.writeAttribute(this, "value",
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 7f2a8e96e2..cbc216661a 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -6312,9 +6312,9 @@ public class Table extends AbstractSelect implements Action.Container,
col.attr("property-id", id.toString());
if (getColumnAlignment(id) == Align.CENTER) {
- col.attr("center", "");
+ col.attr("center", true);
} else if (getColumnAlignment(id) == Align.RIGHT) {
- col.attr("right", "");
+ col.attr("right", true);
}
DesignAttributeHandler.writeAttribute("width", col.attributes(),
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index 653a7d471c..b5cd384f53 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -1453,7 +1453,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
Window def = context.getDefaultInstance(this);
if (getState().centered) {
- design.attr("center", "");
+ design.attr("center", true);
}
DesignAttributeHandler.writeAttribute("position", design.attributes(),
@@ -1481,7 +1481,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
for (Component c : getAssistiveDescription()) {
Element child = context.createElement(c).attr(
- ":assistive-description", "");
+ ":assistive-description", true);
design.appendChild(child);
}
}
diff --git a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
index e93a5c51cb..cee2ebe381 100644
--- a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
+++ b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
@@ -117,8 +117,10 @@ public class DesignAttributeHandler implements Serializable {
success = true;
}
} catch (Exception e) {
- getLogger().log(Level.WARNING,
- "Failed to set attribute " + attribute, e);
+ getLogger().log(
+ Level.WARNING,
+ "Failed to set value \"" + value + "\" to attribute "
+ + attribute, e);
}
if (!success) {
getLogger().info(
@@ -191,6 +193,7 @@ public class DesignAttributeHandler implements Serializable {
* @param defaultInstance
* the default instance for comparing default values
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public static void writeAttribute(Object component, String attribute,
Attributes attr, Object defaultInstance) {
Method getter = findGetterForAttribute(component.getClass(), attribute);
@@ -202,12 +205,8 @@ public class DesignAttributeHandler implements Serializable {
// compare the value with default value
Object value = getter.invoke(component);
Object defaultValue = getter.invoke(defaultInstance);
- // if the values are not equal, write the data
- if (!SharedUtil.equals(value, defaultValue)) {
- String attributeValue = toAttributeValue(
- getter.getReturnType(), value);
- attr.put(attribute, attributeValue);
- }
+ writeAttribute(attribute, attr, value, defaultValue,
+ (Class) getter.getReturnType());
} catch (Exception e) {
getLogger()
.log(Level.SEVERE,
@@ -240,7 +239,12 @@ public class DesignAttributeHandler implements Serializable {
}
if (!SharedUtil.equals(value, defaultValue)) {
String attributeValue = toAttributeValue(inputType, value);
- attributes.put(attribute, attributeValue);
+ if ("".equals(attributeValue)
+ && (inputType == boolean.class || inputType == Boolean.class)) {
+ attributes.put(attribute, true);
+ } else {
+ attributes.put(attribute, attributeValue);
+ }
}
}