import java.util.Iterator;\r
import java.util.Vector;\r
\r
+import com.google.gwt.user.client.DOM;\r
import com.google.gwt.user.client.ui.FlowPanel;\r
import com.google.gwt.user.client.ui.HTML;\r
import com.google.gwt.user.client.ui.ListBox;\r
private static final String CLASSNAME = "i-select-twincol";\r
\r
private static final int VISIBLE_COUNT = 10;\r
- \r
+\r
private static final int DEFAULT_COLUMN_COUNT = 10;\r
\r
private final ListBox options;\r
\r
private final IButton remove;\r
\r
+ private FlowPanel buttons;\r
+\r
+ private Panel panel;\r
+\r
+ private boolean widthSet = false;\r
+\r
public ITwinColSelect() {\r
super(CLASSNAME);\r
options = new ListBox();\r
selections.setVisibleItemCount(VISIBLE_COUNT);\r
options.setStyleName(CLASSNAME + "-options");\r
selections.setStyleName(CLASSNAME + "-selections");\r
- final Panel buttons = new FlowPanel();\r
+ buttons = new FlowPanel();\r
buttons.setStyleName(CLASSNAME + "-buttons");\r
add = new IButton();\r
add.setText(">>");\r
remove = new IButton();\r
remove.setText("<<");\r
remove.addClickListener(this);\r
- final Panel p = ((Panel) optionsContainer);\r
- p.add(options);\r
+ panel = ((Panel) optionsContainer);\r
+ panel.add(options);\r
buttons.add(add);\r
final HTML br = new HTML("<span/>");\r
br.setStyleName(CLASSNAME + "-deco");\r
buttons.add(br);\r
buttons.add(remove);\r
- p.add(buttons);\r
- p.add(selections);\r
+ panel.add(buttons);\r
+ panel.add(selections);\r
}\r
\r
protected void buildOptions(UIDL uidl) {\r
optionUidl.getStringAttribute("key"));\r
}\r
}\r
- optionsContainer.setWidth(null);\r
if (getColumns() > 0) {\r
options.setWidth(getColumns() + "em");\r
selections.setWidth(getColumns() + "em");\r
- optionsContainer.setWidth((getColumns()*2 + 3) + "em");\r
- } else {\r
+ optionsContainer.setWidth((getColumns() * 2 + 3) + "em");\r
+ } else if (!widthSet) {\r
options.setWidth(DEFAULT_COLUMN_COUNT + "em");\r
selections.setWidth(DEFAULT_COLUMN_COUNT + "em");\r
- optionsContainer.setWidth((DEFAULT_COLUMN_COUNT*2 + 2) + "em");\r
+ optionsContainer.setWidth((DEFAULT_COLUMN_COUNT * 2 + 2) + "em");\r
}\r
if (getRows() > 0) {\r
options.setVisibleItemCount(getRows());\r
}\r
}\r
\r
+ public void setHeight(String height) {\r
+ super.setHeight(height);\r
+ setFullHeightInternals();\r
+ }\r
+\r
+ private void setFullHeightInternals() {\r
+ options.setHeight("100%");\r
+ selections.setHeight("100%");\r
+ }\r
+\r
+ public void setWidth(String width) {\r
+ super.setWidth(width);\r
+ if (!"".equals(width) && width != null) {\r
+ setRelativeInternalWidths();\r
+ }\r
+ }\r
+\r
+ private void setRelativeInternalWidths() {\r
+ DOM.setStyleAttribute(getElement(), "position", "relative");\r
+ buttons.setWidth("16%");\r
+ options.setWidth("42%");\r
+ selections.setWidth("42%");\r
+ widthSet = true;\r
+ }\r
}\r