import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
import com.vaadin.terminal.gwt.client.UIDL;
-public class TwinColSelectConnector extends OptionGroupBaseConnector {
+public class TwinColSelectConnector extends OptionGroupBaseConnector implements
+ DirectionalManagedLayout {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
public VTwinColSelect getWidget() {
return (VTwinColSelect) super.getWidget();
}
+
+ public void layoutVertically() {
+ if (isUndefinedHeight()) {
+ getWidget().clearInternalHeights();
+ } else {
+ getWidget().setInternalHeights();
+ }
+ }
+
+ public void layoutHorizontally() {
+ if (isUndefinedWidth()) {
+ getWidget().clearInternalWidths();
+ } else {
+ getWidget().setInternalWidths();
+ }
+ }
}
private final Panel panel;
- private boolean widthSet = false;
-
/**
* A ListBox which catches double clicks
*
}
}
- int cols = -1;
- if (getColumns() > 0) {
- cols = getColumns();
- } else if (!widthSet) {
- cols = DEFAULT_COLUMN_COUNT;
- }
-
- if (cols >= 0) {
- String colWidth = cols + "em";
- String containerWidth = (2 * cols + 4) + "em";
- // Caption wrapper width == optionsSelect + buttons +
- // selectionsSelect
- String captionWrapperWidth = (2 * cols + 4 - 0.5) + "em";
-
- options.setWidth(colWidth);
- if (optionsCaption != null) {
- optionsCaption.setWidth(colWidth);
- }
- selections.setWidth(colWidth);
- if (selectionsCaption != null) {
- selectionsCaption.setWidth(colWidth);
- }
- buttons.setWidth("3.5em");
- optionsContainer.setWidth(containerWidth);
- captionWrapper.setWidth(captionWrapperWidth);
- }
if (getRows() > 0) {
options.setVisibleItemCount(getRows());
selections.setVisibleItemCount(getRows());
}
}
- @Override
- public void setHeight(String height) {
- super.setHeight(height);
- if ("".equals(height)) {
- options.setHeight("");
- selections.setHeight("");
- } else {
- setInternalHeights();
- }
+ void clearInternalHeights() {
+ selections.setHeight("");
+ options.setHeight("");
}
- private void setInternalHeights() {
+ void setInternalHeights() {
int captionHeight = 0;
int totalHeight = getOffsetHeight();
}
- @Override
- public void setWidth(String width) {
- super.setWidth(width);
- if (!"".equals(width) && width != null) {
- setInternalWidths();
- widthSet = true;
+ void clearInternalWidths() {
+ int cols = -1;
+ if (getColumns() > 0) {
+ cols = getColumns();
} else {
- widthSet = false;
+ cols = DEFAULT_COLUMN_COUNT;
+ }
+
+ if (cols >= 0) {
+ String colWidth = cols + "em";
+ String containerWidth = (2 * cols + 4) + "em";
+ // Caption wrapper width == optionsSelect + buttons +
+ // selectionsSelect
+ String captionWrapperWidth = (2 * cols + 4 - 0.5) + "em";
+
+ options.setWidth(colWidth);
+ if (optionsCaption != null) {
+ optionsCaption.setWidth(colWidth);
+ }
+ selections.setWidth(colWidth);
+ if (selectionsCaption != null) {
+ selectionsCaption.setWidth(colWidth);
+ }
+ buttons.setWidth("3.5em");
+ optionsContainer.setWidth(containerWidth);
+ captionWrapper.setWidth(captionWrapperWidth);
}
}
- private void setInternalWidths() {
+ void setInternalWidths() {
DOM.setStyleAttribute(getElement(), "position", "relative");
int bordersAndPaddings = Util.measureHorizontalPaddingAndBorder(
buttons.getElement(), 0);