@@ -7,7 +7,7 @@ package com.vaadin.terminal.gwt.client; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ui.VFilterSelectPaintable; | |||
import com.vaadin.terminal.gwt.client.ui.VListSelect; | |||
import com.vaadin.terminal.gwt.client.ui.VListSelectPaintable; | |||
import com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal; | |||
import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical; | |||
import com.vaadin.terminal.gwt.client.ui.VUnknownComponent; | |||
@@ -82,7 +82,7 @@ public class WidgetSet { | |||
if (uidl.hasAttribute("type")) { | |||
final String type = uidl.getStringAttribute("type").intern(); | |||
if ("legacy-multi" == type) { | |||
return VListSelect.class; | |||
return VListSelectPaintable.class; | |||
} | |||
} | |||
} else if (widgetClass == VSplitPanelHorizontal.class | |||
@@ -133,7 +133,7 @@ public class WidgetSet { | |||
* *actually* be VListSelect, when the annotation says VFilterSelect | |||
*/ | |||
if (fullyqualifiedName.equals("com.vaadin.ui.Select")) { | |||
loadImplementation(VListSelect.class); | |||
loadImplementation(VListSelectPaintable.class); | |||
} else if (fullyqualifiedName.equals("com.vaadin.ui.SplitPanel")) { | |||
loadImplementation(VSplitPanelVertical.class); | |||
} |
@@ -12,7 +12,6 @@ import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.ui.ListBox; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
import com.vaadin.terminal.gwt.client.VTooltip; | |||
@@ -81,11 +80,11 @@ public class VListSelect extends VOptionGroupBase { | |||
} else { | |||
lastSelectedIndex = si; | |||
if (isMultiselect()) { | |||
client.updateVariable(id, "selected", getSelectedItems(), | |||
isImmediate()); | |||
client.updateVariable(paintableId, "selected", | |||
getSelectedItems(), isImmediate()); | |||
} else { | |||
client.updateVariable(id, "selected", new String[] { "" | |||
+ getSelectedItem() }, isImmediate()); | |||
client.updateVariable(paintableId, "selected", | |||
new String[] { "" + getSelectedItem() }, isImmediate()); | |||
} | |||
} | |||
} | |||
@@ -110,11 +109,6 @@ public class VListSelect extends VOptionGroupBase { | |||
public void focus() { | |||
select.setFocus(true); | |||
} | |||
public Widget getWidgetForPaintable() { | |||
return this; | |||
} | |||
} | |||
/** | |||
@@ -123,7 +117,7 @@ public class VListSelect extends VOptionGroupBase { | |||
*/ | |||
class TooltipListBox extends ListBox { | |||
private ApplicationConnection client; | |||
private VPaintableWidget pntbl; | |||
private Widget widget; | |||
TooltipListBox(boolean isMultiselect) { | |||
super(isMultiselect); | |||
@@ -134,15 +128,15 @@ class TooltipListBox extends ListBox { | |||
this.client = client; | |||
} | |||
public void setSelect(VPaintableWidget s) { | |||
pntbl = s; | |||
public void setSelect(Widget widget) { | |||
this.widget = widget; | |||
} | |||
@Override | |||
public void onBrowserEvent(Event event) { | |||
super.onBrowserEvent(event); | |||
if (client != null) { | |||
client.handleTooltipEvent(event, pntbl); | |||
client.handleWidgetTooltipEvent(event, widget); | |||
} | |||
} | |||
@@ -0,0 +1,21 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.user.client.ui.Widget; | |||
public class VListSelectPaintable extends VOptionGroupBasePaintable { | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VListSelect.class); | |||
} | |||
@Override | |||
public VListSelect getWidgetForPaintable() { | |||
return (VListSelect) super.getWidgetForPaintable(); | |||
} | |||
} |
@@ -8,7 +8,6 @@ import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import com.google.gwt.event.dom.client.ChangeEvent; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
public class VNativeSelect extends VOptionGroupBase implements Field { | |||
@@ -74,10 +73,10 @@ public class VNativeSelect extends VOptionGroupBase implements Field { | |||
public void onChange(ChangeEvent event) { | |||
if (select.isMultipleSelect()) { | |||
client.updateVariable(id, "selected", getSelectedItems(), | |||
client.updateVariable(paintableId, "selected", getSelectedItems(), | |||
isImmediate()); | |||
} else { | |||
client.updateVariable(id, "selected", new String[] { "" | |||
client.updateVariable(paintableId, "selected", new String[] { "" | |||
+ getSelectedItem() }, isImmediate()); | |||
} | |||
if (firstValueIsTemporaryNullItem) { | |||
@@ -107,8 +106,4 @@ public class VNativeSelect extends VOptionGroupBase implements Field { | |||
public void focus() { | |||
select.setFocus(true); | |||
} | |||
public Widget getWidgetForPaintable() { | |||
return this; | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.user.client.ui.Widget; | |||
public class VNativeSelectPaintable extends VOptionGroupBasePaintable { | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VNativeSelect.class); | |||
} | |||
@Override | |||
public VNativeSelect getWidgetForPaintable() { | |||
return (VNativeSelect) super.getWidgetForPaintable(); | |||
} | |||
} |
@@ -4,7 +4,6 @@ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
@@ -38,14 +37,14 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
public static final String CLASSNAME = "v-select-optiongroup"; | |||
private final Panel panel; | |||
protected final Panel panel; | |||
private final Map<CheckBox, String> optionsToKeys; | |||
private boolean sendFocusEvents = false; | |||
private boolean sendBlurEvents = false; | |||
private List<HandlerRegistration> focusHandlers = null; | |||
private List<HandlerRegistration> blurHandlers = null; | |||
protected boolean sendFocusEvents = false; | |||
protected boolean sendBlurEvents = false; | |||
protected List<HandlerRegistration> focusHandlers = null; | |||
protected List<HandlerRegistration> blurHandlers = null; | |||
private final LoadHandler iconLoadHandler = new LoadHandler() { | |||
public void onLoad(LoadEvent event) { | |||
@@ -62,7 +61,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
*/ | |||
private boolean blurOccured = false; | |||
private boolean htmlContentAllowed = false; | |||
protected boolean htmlContentAllowed = false; | |||
public VOptionGroup() { | |||
super(CLASSNAME); | |||
@@ -70,43 +69,6 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
optionsToKeys = new HashMap<CheckBox, String>(); | |||
} | |||
@Override | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
htmlContentAllowed = uidl.hasAttribute(HTML_CONTENT_ALLOWED); | |||
super.updateFromUIDL(uidl, client); | |||
sendFocusEvents = client.hasEventListeners(this, EventId.FOCUS); | |||
sendBlurEvents = client.hasEventListeners(this, EventId.BLUR); | |||
if (focusHandlers != null) { | |||
for (HandlerRegistration reg : focusHandlers) { | |||
reg.removeHandler(); | |||
} | |||
focusHandlers.clear(); | |||
focusHandlers = null; | |||
for (HandlerRegistration reg : blurHandlers) { | |||
reg.removeHandler(); | |||
} | |||
blurHandlers.clear(); | |||
blurHandlers = null; | |||
} | |||
if (sendFocusEvents || sendBlurEvents) { | |||
focusHandlers = new ArrayList<HandlerRegistration>(); | |||
blurHandlers = new ArrayList<HandlerRegistration>(); | |||
// add focus and blur handlers to checkboxes / radio buttons | |||
for (Widget wid : panel) { | |||
if (wid instanceof CheckBox) { | |||
focusHandlers.add(((CheckBox) wid).addFocusHandler(this)); | |||
blurHandlers.add(((CheckBox) wid).addBlurHandler(this)); | |||
} | |||
} | |||
} | |||
} | |||
/* | |||
* Return true if no elements were changed, false otherwise. | |||
*/ | |||
@@ -133,7 +95,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
op = new VCheckBox(); | |||
op.setHTML(itemHtml); | |||
} else { | |||
op = new RadioButton(id, itemHtml, true); | |||
op = new RadioButton(paintableId, itemHtml, true); | |||
op.setStyleName("v-radiobutton"); | |||
} | |||
@@ -174,7 +136,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
} else { | |||
selectedKeys.remove(key); | |||
} | |||
client.updateVariable(id, "selected", getSelectedItems(), | |||
client.updateVariable(paintableId, "selected", getSelectedItems(), | |||
isImmediate()); | |||
} | |||
} | |||
@@ -200,7 +162,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
// panel was blurred => fire the event to the server side if | |||
// requested by server side | |||
if (sendFocusEvents) { | |||
client.updateVariable(id, EventId.FOCUS, "", true); | |||
client.updateVariable(paintableId, EventId.FOCUS, "", true); | |||
} | |||
} else { | |||
// blur occured before this focus event | |||
@@ -219,16 +181,12 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, | |||
// check whether blurOccured still is true and then send the | |||
// event out to the server | |||
if (blurOccured) { | |||
client.updateVariable(id, EventId.BLUR, "", true); | |||
client.updateVariable(paintableId, EventId.BLUR, "", | |||
true); | |||
blurOccured = false; | |||
} | |||
} | |||
}); | |||
} | |||
} | |||
public Widget getWidgetForPaintable() { | |||
return this; | |||
} | |||
} |
@@ -19,35 +19,34 @@ import com.google.gwt.user.client.ui.Panel; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.Focusable; | |||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
abstract class VOptionGroupBase extends Composite implements VPaintableWidget, | |||
Field, ClickHandler, ChangeHandler, KeyPressHandler, Focusable { | |||
abstract class VOptionGroupBase extends Composite implements Field, | |||
ClickHandler, ChangeHandler, KeyPressHandler, Focusable { | |||
public static final String CLASSNAME_OPTION = "v-select-option"; | |||
protected ApplicationConnection client; | |||
protected String id; | |||
protected String paintableId; | |||
protected Set<String> selectedKeys; | |||
private boolean immediate; | |||
protected boolean immediate; | |||
private boolean multiselect; | |||
protected boolean multiselect; | |||
private boolean disabled; | |||
protected boolean disabled; | |||
private boolean readonly; | |||
protected boolean readonly; | |||
private int cols = 0; | |||
protected int cols = 0; | |||
private int rows = 0; | |||
protected int rows = 0; | |||
private boolean nullSelectionAllowed = true; | |||
protected boolean nullSelectionAllowed = true; | |||
private boolean nullSelectionItemAvailable = false; | |||
protected boolean nullSelectionItemAvailable = false; | |||
/** | |||
* Widget holding the different options (e.g. ListBox or Panel for radio | |||
@@ -58,11 +57,11 @@ abstract class VOptionGroupBase extends Composite implements VPaintableWidget, | |||
/** | |||
* Panel containing the component | |||
*/ | |||
private final Panel container; | |||
protected final Panel container; | |||
private VTextField newItemField; | |||
protected VTextField newItemField; | |||
private VNativeButton newItemButton; | |||
protected VNativeButton newItemButton; | |||
public VOptionGroupBase(String classname) { | |||
container = new FlowPanel(); | |||
@@ -122,84 +121,23 @@ abstract class VOptionGroupBase extends Composite implements VPaintableWidget, | |||
return rows; | |||
} | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
this.client = client; | |||
id = uidl.getId(); | |||
if (client.updateComponent(this, uidl, true)) { | |||
return; | |||
} | |||
selectedKeys = uidl.getStringArrayVariableAsSet("selected"); | |||
readonly = uidl.getBooleanAttribute("readonly"); | |||
disabled = uidl.getBooleanAttribute("disabled"); | |||
multiselect = "multi".equals(uidl.getStringAttribute("selectmode")); | |||
immediate = uidl.getBooleanAttribute("immediate"); | |||
nullSelectionAllowed = uidl.getBooleanAttribute("nullselect"); | |||
nullSelectionItemAvailable = uidl.getBooleanAttribute("nullselectitem"); | |||
if (uidl.hasAttribute("cols")) { | |||
cols = uidl.getIntAttribute("cols"); | |||
} | |||
if (uidl.hasAttribute("rows")) { | |||
rows = uidl.getIntAttribute("rows"); | |||
} | |||
final UIDL ops = uidl.getChildUIDL(0); | |||
if (getColumns() > 0) { | |||
container.setWidth(getColumns() + "em"); | |||
if (container != optionsContainer) { | |||
optionsContainer.setWidth("100%"); | |||
} | |||
} | |||
buildOptions(ops); | |||
if (uidl.getBooleanAttribute("allownewitem")) { | |||
if (newItemField == null) { | |||
newItemButton = new VNativeButton(); | |||
newItemButton.setText("+"); | |||
newItemButton.addClickHandler(this); | |||
newItemField = new VTextField(); | |||
newItemField.addKeyPressHandler(this); | |||
} | |||
newItemField.setEnabled(!disabled && !readonly); | |||
newItemButton.setEnabled(!disabled && !readonly); | |||
if (newItemField == null || newItemField.getParent() != container) { | |||
container.add(newItemField); | |||
container.add(newItemButton); | |||
final int w = container.getOffsetWidth() | |||
- newItemButton.getOffsetWidth(); | |||
newItemField.setWidth(Math.max(w, 0) + "px"); | |||
} | |||
} else if (newItemField != null) { | |||
container.remove(newItemField); | |||
container.remove(newItemButton); | |||
} | |||
setTabIndex(uidl.hasAttribute("tabindex") ? uidl | |||
.getIntAttribute("tabindex") : 0); | |||
} | |||
abstract protected void setTabIndex(int tabIndex); | |||
public void onClick(ClickEvent event) { | |||
if (event.getSource() == newItemButton | |||
&& !newItemField.getText().equals("")) { | |||
client.updateVariable(id, "newitem", newItemField.getText(), true); | |||
client.updateVariable(paintableId, "newitem", | |||
newItemField.getText(), true); | |||
newItemField.setText(""); | |||
} | |||
} | |||
public void onChange(ChangeEvent event) { | |||
if (multiselect) { | |||
client.updateVariable(id, "selected", getSelectedItems(), immediate); | |||
client.updateVariable(paintableId, "selected", getSelectedItems(), | |||
immediate); | |||
} else { | |||
client.updateVariable(id, "selected", new String[] { "" | |||
client.updateVariable(paintableId, "selected", new String[] { "" | |||
+ getSelectedItem() }, immediate); | |||
} | |||
} |
@@ -0,0 +1,109 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
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.UIDL; | |||
public class VOptionGroupBasePaintable extends VAbstractPaintableWidget { | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
// Save details | |||
getWidgetForPaintable().client = client; | |||
getWidgetForPaintable().paintableId = uidl.getId(); | |||
if (client.updateComponent(this, uidl, true)) { | |||
return; | |||
} | |||
getWidgetForPaintable().selectedKeys = uidl | |||
.getStringArrayVariableAsSet("selected"); | |||
getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly"); | |||
getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled"); | |||
getWidgetForPaintable().multiselect = "multi".equals(uidl | |||
.getStringAttribute("selectmode")); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute("immediate"); | |||
getWidgetForPaintable().nullSelectionAllowed = uidl | |||
.getBooleanAttribute("nullselect"); | |||
getWidgetForPaintable().nullSelectionItemAvailable = uidl | |||
.getBooleanAttribute("nullselectitem"); | |||
if (uidl.hasAttribute("cols")) { | |||
getWidgetForPaintable().cols = uidl.getIntAttribute("cols"); | |||
} | |||
if (uidl.hasAttribute("rows")) { | |||
getWidgetForPaintable().rows = uidl.getIntAttribute("rows"); | |||
} | |||
final UIDL ops = uidl.getChildUIDL(0); | |||
if (getWidgetForPaintable().getColumns() > 0) { | |||
getWidgetForPaintable().container.setWidth(getWidgetForPaintable() | |||
.getColumns() + "em"); | |||
if (getWidgetForPaintable().container != getWidgetForPaintable().optionsContainer) { | |||
getWidgetForPaintable().optionsContainer.setWidth("100%"); | |||
} | |||
} | |||
getWidgetForPaintable().buildOptions(ops); | |||
if (uidl.getBooleanAttribute("allownewitem")) { | |||
if (getWidgetForPaintable().newItemField == null) { | |||
getWidgetForPaintable().newItemButton = new VNativeButton(); | |||
getWidgetForPaintable().newItemButton.setText("+"); | |||
getWidgetForPaintable().newItemButton | |||
.addClickHandler(getWidgetForPaintable()); | |||
getWidgetForPaintable().newItemField = new VTextField(); | |||
getWidgetForPaintable().newItemField | |||
.addKeyPressHandler(getWidgetForPaintable()); | |||
} | |||
getWidgetForPaintable().newItemField | |||
.setEnabled(!getWidgetForPaintable().disabled | |||
&& !getWidgetForPaintable().readonly); | |||
getWidgetForPaintable().newItemButton | |||
.setEnabled(!getWidgetForPaintable().disabled | |||
&& !getWidgetForPaintable().readonly); | |||
if (getWidgetForPaintable().newItemField == null | |||
|| getWidgetForPaintable().newItemField.getParent() != getWidgetForPaintable().container) { | |||
getWidgetForPaintable().container | |||
.add(getWidgetForPaintable().newItemField); | |||
getWidgetForPaintable().container | |||
.add(getWidgetForPaintable().newItemButton); | |||
final int w = getWidgetForPaintable().container | |||
.getOffsetWidth() | |||
- getWidgetForPaintable().newItemButton | |||
.getOffsetWidth(); | |||
getWidgetForPaintable().newItemField.setWidth(Math.max(w, 0) | |||
+ "px"); | |||
} | |||
} else if (getWidgetForPaintable().newItemField != null) { | |||
getWidgetForPaintable().container | |||
.remove(getWidgetForPaintable().newItemField); | |||
getWidgetForPaintable().container | |||
.remove(getWidgetForPaintable().newItemButton); | |||
} | |||
getWidgetForPaintable().setTabIndex( | |||
uidl.hasAttribute("tabindex") ? uidl | |||
.getIntAttribute("tabindex") : 0); | |||
} | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VOptionGroupBase.class); | |||
} | |||
@Override | |||
public VOptionGroupBase getWidgetForPaintable() { | |||
return (VOptionGroupBase) super.getWidgetForPaintable(); | |||
} | |||
} |
@@ -0,0 +1,71 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
import java.util.ArrayList; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.event.shared.HandlerRegistration; | |||
import com.google.gwt.user.client.ui.CheckBox; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.EventId; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
public class VOptionGroupPaintable extends VOptionGroupBasePaintable { | |||
@Override | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
getWidgetForPaintable().htmlContentAllowed = uidl | |||
.hasAttribute(VOptionGroup.HTML_CONTENT_ALLOWED); | |||
super.updateFromUIDL(uidl, client); | |||
getWidgetForPaintable().sendFocusEvents = client.hasEventListeners( | |||
this, EventId.FOCUS); | |||
getWidgetForPaintable().sendBlurEvents = client.hasEventListeners(this, | |||
EventId.BLUR); | |||
if (getWidgetForPaintable().focusHandlers != null) { | |||
for (HandlerRegistration reg : getWidgetForPaintable().focusHandlers) { | |||
reg.removeHandler(); | |||
} | |||
getWidgetForPaintable().focusHandlers.clear(); | |||
getWidgetForPaintable().focusHandlers = null; | |||
for (HandlerRegistration reg : getWidgetForPaintable().blurHandlers) { | |||
reg.removeHandler(); | |||
} | |||
getWidgetForPaintable().blurHandlers.clear(); | |||
getWidgetForPaintable().blurHandlers = null; | |||
} | |||
if (getWidgetForPaintable().sendFocusEvents | |||
|| getWidgetForPaintable().sendBlurEvents) { | |||
getWidgetForPaintable().focusHandlers = new ArrayList<HandlerRegistration>(); | |||
getWidgetForPaintable().blurHandlers = new ArrayList<HandlerRegistration>(); | |||
// add focus and blur handlers to checkboxes / radio buttons | |||
for (Widget wid : getWidgetForPaintable().panel) { | |||
if (wid instanceof CheckBox) { | |||
getWidgetForPaintable().focusHandlers.add(((CheckBox) wid) | |||
.addFocusHandler(getWidgetForPaintable())); | |||
getWidgetForPaintable().blurHandlers.add(((CheckBox) wid) | |||
.addBlurHandler(getWidgetForPaintable())); | |||
} | |||
} | |||
} | |||
} | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VOptionGroup.class); | |||
} | |||
@Override | |||
public VOptionGroup getWidgetForPaintable() { | |||
return (VOptionGroup) super.getWidgetForPaintable(); | |||
} | |||
} |
@@ -27,7 +27,6 @@ import com.google.gwt.user.client.ui.HTML; | |||
import com.google.gwt.user.client.ui.ListBox; | |||
import com.google.gwt.user.client.ui.Panel; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
import com.vaadin.terminal.gwt.client.Util; | |||
@@ -157,18 +156,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, | |||
return selectionsCaption; | |||
} | |||
@Override | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
// Captions are updated before super call to ensure the widths are set | |||
// correctly | |||
if (!uidl.getBooleanAttribute("cached")) { | |||
updateCaptions(uidl); | |||
} | |||
super.updateFromUIDL(uidl, client); | |||
} | |||
private void updateCaptions(UIDL uidl) { | |||
protected void updateCaptions(UIDL uidl) { | |||
String leftCaption = (uidl.hasAttribute(ATTRIBUTE_LEFT_CAPTION) ? uidl | |||
.getStringAttribute(ATTRIBUTE_LEFT_CAPTION) : null); | |||
String rightCaption = (uidl.hasAttribute(ATTRIBUTE_RIGHT_CAPTION) ? uidl | |||
@@ -297,7 +285,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, | |||
Set<String> movedItems = moveSelectedItems(options, selections); | |||
selectedKeys.addAll(movedItems); | |||
client.updateVariable(id, "selected", | |||
client.updateVariable(paintableId, "selected", | |||
selectedKeys.toArray(new String[selectedKeys.size()]), | |||
isImmediate()); | |||
} | |||
@@ -306,7 +294,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, | |||
Set<String> movedItems = moveSelectedItems(selections, options); | |||
selectedKeys.removeAll(movedItems); | |||
client.updateVariable(id, "selected", | |||
client.updateVariable(paintableId, "selected", | |||
selectedKeys.toArray(new String[selectedKeys.size()]), | |||
isImmediate()); | |||
} |
@@ -0,0 +1,34 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.terminal.gwt.client.ui; | |||
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.UIDL; | |||
public class VTwinColSelectPaintable extends VOptionGroupBasePaintable { | |||
@Override | |||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||
// Captions are updated before super call to ensure the widths are set | |||
// correctly | |||
if (!uidl.getBooleanAttribute("cached")) { | |||
getWidgetForPaintable().updateCaptions(uidl); | |||
} | |||
super.updateFromUIDL(uidl, client); | |||
} | |||
@Override | |||
protected Widget createWidget() { | |||
return GWT.create(VTwinColSelect.class); | |||
} | |||
@Override | |||
public VTwinColSelect getWidgetForPaintable() { | |||
return (VTwinColSelect) super.getWidgetForPaintable(); | |||
} | |||
} |
@@ -9,14 +9,14 @@ import java.util.Collection; | |||
import com.vaadin.data.Container; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.gwt.client.ui.VListSelect; | |||
import com.vaadin.terminal.gwt.client.ui.VListSelectPaintable; | |||
/** | |||
* This is a simple list select without, for instance, support for new items, | |||
* lazyloading, and other advanced features. | |||
*/ | |||
@SuppressWarnings("serial") | |||
@ClientWidget(VListSelect.class) | |||
@ClientWidget(VListSelectPaintable.class) | |||
public class ListSelect extends AbstractSelect { | |||
private int columns = 0; |
@@ -9,7 +9,7 @@ import java.util.Collection; | |||
import com.vaadin.data.Container; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.gwt.client.ui.VNativeSelect; | |||
import com.vaadin.terminal.gwt.client.ui.VNativeSelectPaintable; | |||
/** | |||
* This is a simple drop-down select without, for instance, support for | |||
@@ -18,7 +18,7 @@ import com.vaadin.terminal.gwt.client.ui.VNativeSelect; | |||
* better choice. | |||
*/ | |||
@SuppressWarnings("serial") | |||
@ClientWidget(VNativeSelect.class) | |||
@ClientWidget(VNativeSelectPaintable.class) | |||
public class NativeSelect extends AbstractSelect { | |||
// width in characters, mimics TextField |
@@ -18,12 +18,13 @@ import com.vaadin.event.FieldEvents.FocusListener; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.gwt.client.ui.VOptionGroup; | |||
import com.vaadin.terminal.gwt.client.ui.VOptionGroupPaintable; | |||
/** | |||
* Configures select to be used as an option group. | |||
*/ | |||
@SuppressWarnings("serial") | |||
@ClientWidget(VOptionGroup.class) | |||
@ClientWidget(VOptionGroupPaintable.class) | |||
public class OptionGroup extends AbstractSelect implements | |||
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { | |||
@@ -10,13 +10,14 @@ import com.vaadin.data.Container; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.PaintTarget; | |||
import com.vaadin.terminal.gwt.client.ui.VTwinColSelect; | |||
import com.vaadin.terminal.gwt.client.ui.VTwinColSelectPaintable; | |||
/** | |||
* Multiselect component with two lists: left side for available items and right | |||
* side for selected items. | |||
*/ | |||
@SuppressWarnings("serial") | |||
@ClientWidget(VTwinColSelect.class) | |||
@ClientWidget(VTwinColSelectPaintable.class) | |||
public class TwinColSelect extends AbstractSelect { | |||
private int columns = 0; |