accordinglytags/7.0.0.alpha2
private HashMap<String, String> unknownComponents; | private HashMap<String, String> unknownComponents; | ||||
private Class<? extends VPaintableWidget>[] classes = new Class[1024]; | |||||
private Class<? extends ComponentConnector>[] classes = new Class[1024]; | |||||
private String windowId; | private String windowId; | ||||
return useDebugIdInDom; | return useDebugIdInDom; | ||||
} | } | ||||
public Class<? extends VPaintableWidget> getWidgetClassByEncodedTag( | |||||
public Class<? extends ComponentConnector> getWidgetClassByEncodedTag( | |||||
String tag) { | String tag) { | ||||
try { | try { | ||||
int parseInt = Integer.parseInt(tag); | int parseInt = Integer.parseInt(tag); | ||||
public void run() { | public void run() { | ||||
pending = false; | pending = false; | ||||
if (!isBusy()) { | if (!isBusy()) { | ||||
Class<? extends VPaintableWidget> nextType = getNextType(); | |||||
Class<? extends ComponentConnector> nextType = getNextType(); | |||||
if (nextType == null) { | if (nextType == null) { | ||||
// ensured that all widgets are loaded | // ensured that all widgets are loaded | ||||
deferredWidgetLoader = null; | deferredWidgetLoader = null; | ||||
} | } | ||||
} | } | ||||
private Class<? extends VPaintableWidget> getNextType() { | |||||
Class<? extends VPaintableWidget>[] deferredLoadedWidgets = widgetSet | |||||
private Class<? extends ComponentConnector> getNextType() { | |||||
Class<? extends ComponentConnector>[] deferredLoadedWidgets = widgetSet | |||||
.getDeferredLoadedWidgets(); | .getDeferredLoadedWidgets(); | ||||
if (deferredLoadedWidgets.length <= nextWidgetIndex) { | if (deferredLoadedWidgets.length <= nextWidgetIndex) { | ||||
return null; | return null; |
* | * | ||||
* Client-side widgets receive updates from the corresponding server-side | * Client-side widgets receive updates from the corresponding server-side | ||||
* components as calls to | * components as calls to | ||||
* {@link VPaintableWidget#updateFromUIDL(UIDL, ApplicationConnection)} (not to | |||||
* {@link ComponentConnector#updateFromUIDL(UIDL, ApplicationConnection)} (not to | |||||
* be confused with the server side interface | * be confused with the server side interface | ||||
* {@link com.vaadin.terminal.Paintable} ). Any client-side changes (typically | * {@link com.vaadin.terminal.Paintable} ). Any client-side changes (typically | ||||
* resulting from user actions) are sent back to the server as variable changes | * resulting from user actions) are sent back to the server as variable changes | ||||
private boolean validatingLayouts = false; | private boolean validatingLayouts = false; | ||||
private Set<VPaintableWidget> zeroWidthComponents = null; | |||||
private Set<ComponentConnector> zeroWidthComponents = null; | |||||
private Set<VPaintableWidget> zeroHeightComponents = null; | |||||
private Set<ComponentConnector> zeroHeightComponents = null; | |||||
private final LayoutManager layoutManager = new LayoutManager(this); | private final LayoutManager layoutManager = new LayoutManager(this); | ||||
* | * | ||||
* @param paintable | * @param paintable | ||||
*/ | */ | ||||
void highlightComponent(VPaintableWidget paintable) { | |||||
void highlightComponent(ComponentConnector paintable) { | |||||
String params = getRepaintAllParameters() + "&highlightComponent=" | String params = getRepaintAllParameters() + "&highlightComponent=" | ||||
+ paintableMap.getPid(paintable); | |||||
+ connectorMap.getConnectorId(paintable); | |||||
makeUidlRequest("", params, false); | makeUidlRequest("", params, false); | ||||
} | } | ||||
private void cleanVariableBurst(ArrayList<MethodInvocation> variableBurst) { | private void cleanVariableBurst(ArrayList<MethodInvocation> variableBurst) { | ||||
for (int i = 1; i < variableBurst.size(); i++) { | for (int i = 1; i < variableBurst.size(); i++) { | ||||
String id = variableBurst.get(i).getPaintableId(); | String id = variableBurst.get(i).getPaintableId(); | ||||
if (!getPaintableMap().hasPaintable(id) | |||||
&& !getPaintableMap().isDragAndDropPaintable(id)) { | |||||
if (!getConnectorMap().hasConnector(id) | |||||
&& !getConnectorMap().isDragAndDropPaintable(id)) { | |||||
// variable owner does not exist anymore | // variable owner does not exist anymore | ||||
variableBurst.remove(i); | variableBurst.remove(i); | ||||
VConsole.log("Removed variable from removed component: " + id); | VConsole.log("Removed variable from removed component: " + id); | ||||
if (meta.containsKey("repaintAll")) { | if (meta.containsKey("repaintAll")) { | ||||
repaintAll = true; | repaintAll = true; | ||||
view.getWidget().clear(); | view.getWidget().clear(); | ||||
getPaintableMap().clear(); | |||||
getConnectorMap().clear(); | |||||
if (meta.containsKey("invalidLayouts")) { | if (meta.containsKey("invalidLayouts")) { | ||||
validatingLayouts = true; | validatingLayouts = true; | ||||
zeroWidthComponents = new HashSet<VPaintableWidget>(); | |||||
zeroHeightComponents = new HashSet<VPaintableWidget>(); | |||||
zeroWidthComponents = new HashSet<ComponentConnector>(); | |||||
zeroHeightComponents = new HashSet<ComponentConnector>(); | |||||
} | } | ||||
} | } | ||||
if (meta.containsKey("timedRedirect")) { | if (meta.containsKey("timedRedirect")) { | ||||
// Process changes | // Process changes | ||||
JsArray<ValueMap> changes = json.getJSValueMapArray("changes"); | JsArray<ValueMap> changes = json.getJSValueMapArray("changes"); | ||||
ArrayList<VPaintableWidget> updatedVPaintableWidgets = new ArrayList<VPaintableWidget>(); | |||||
ArrayList<ComponentConnector> updatedVPaintableWidgets = new ArrayList<ComponentConnector>(); | |||||
componentCaptionSizeChanges.clear(); | componentCaptionSizeChanges.clear(); | ||||
Duration updateDuration = new Duration(); | Duration updateDuration = new Duration(); | ||||
try { | try { | ||||
final UIDL change = changes.get(i).cast(); | final UIDL change = changes.get(i).cast(); | ||||
final UIDL uidl = change.getChildUIDL(0); | final UIDL uidl = change.getChildUIDL(0); | ||||
VPaintable paintable = paintableMap.getPaintable(uidl | |||||
Connector paintable = connectorMap.getConnector(uidl | |||||
.getId()); | .getId()); | ||||
if (null == paintable | if (null == paintable | ||||
&& !uidl.getTag().equals( | && !uidl.getTag().equals( | ||||
for (int i = 0; i < keyArray.length(); i++) { | for (int i = 0; i < keyArray.length(); i++) { | ||||
try { | try { | ||||
String paintableId = keyArray.get(i); | String paintableId = keyArray.get(i); | ||||
VPaintable paintable = paintableMap | |||||
.getPaintable(paintableId); | |||||
Connector paintable = connectorMap | |||||
.getConnector(paintableId); | |||||
if (null != paintable) { | if (null != paintable) { | ||||
JSONArray stateDataAndType = new JSONArray( | JSONArray stateDataAndType = new JSONArray( | ||||
states.getJavaScriptObject(paintableId)); | states.getJavaScriptObject(paintableId)); | ||||
Object state = JsonDecoder.convertValue( | Object state = JsonDecoder.convertValue( | ||||
stateDataAndType, paintableMap); | |||||
stateDataAndType, connectorMap); | |||||
paintable.setState((SharedState) state); | paintable.setState((SharedState) state); | ||||
} | } | ||||
final UIDL change = changes.get(i).cast(); | final UIDL change = changes.get(i).cast(); | ||||
final UIDL uidl = change.getChildUIDL(0); | final UIDL uidl = change.getChildUIDL(0); | ||||
// TODO optimize | // TODO optimize | ||||
final VPaintableWidget paintable = (VPaintableWidget) paintableMap | |||||
.getPaintable(uidl.getId()); | |||||
final ComponentConnector paintable = (ComponentConnector) connectorMap | |||||
.getConnector(uidl.getId()); | |||||
if (paintable != null) { | if (paintable != null) { | ||||
paintable.updateFromUIDL(uidl, | paintable.updateFromUIDL(uidl, | ||||
ApplicationConnection.this); | ApplicationConnection.this); | ||||
+ uidl.getId() + ") rendered."); | + uidl.getId() + ") rendered."); | ||||
} else { | } else { | ||||
String pid = uidl.getId(); | String pid = uidl.getId(); | ||||
if (!paintableMap.hasPaintable(pid)) { | |||||
paintableMap.registerPaintable(pid, view); | |||||
if (!connectorMap.hasConnector(pid)) { | |||||
connectorMap.registerConnector(pid, view); | |||||
} | } | ||||
// VView does not call updateComponent so we | // VView does not call updateComponent so we | ||||
// register any event listeners here | // register any event listeners here | ||||
paintableMap.registerEventListenersFromUIDL( | |||||
connectorMap.registerEventListenersFromUIDL( | |||||
pid, uidl); | pid, uidl); | ||||
// Finally allow VView to update itself | // Finally allow VView to update itself | ||||
* idToPaintableDetail is already cleanded at the start of | * idToPaintableDetail is already cleanded at the start of | ||||
* the changeset handling, bypass cleanup. | * the changeset handling, bypass cleanup. | ||||
*/ | */ | ||||
paintableMap.purgeUnregistryBag(false); | |||||
connectorMap.purgeUnregistryBag(false); | |||||
} else { | } else { | ||||
paintableMap.purgeUnregistryBag(true); | |||||
connectorMap.purgeUnregistryBag(true); | |||||
} | } | ||||
// TODO build profiling for widget impl loading time | // TODO build profiling for widget impl loading time | ||||
VConsole.log(" Processing time was " | VConsole.log(" Processing time was " | ||||
+ String.valueOf(prosessingTime) + "ms for " | + String.valueOf(prosessingTime) + "ms for " | ||||
+ jsonText.length() + " characters of JSON"); | + jsonText.length() + " characters of JSON"); | ||||
VConsole.log("Referenced paintables: " + paintableMap.size()); | |||||
VConsole.log("Referenced paintables: " + connectorMap.size()); | |||||
endRequest(); | endRequest(); | ||||
for (int i = 0; i < invocation.getParameters().length; ++i) { | for (int i = 0; i < invocation.getParameters().length; ++i) { | ||||
// TODO non-static encoder? type registration? | // TODO non-static encoder? type registration? | ||||
paramJson.set(i, JsonEncoder.encode( | paramJson.set(i, JsonEncoder.encode( | ||||
invocation.getParameters()[i], getPaintableMap())); | |||||
invocation.getParameters()[i], getConnectorMap())); | |||||
} | } | ||||
invocationJson.set(3, paramJson); | invocationJson.set(3, paramJson); | ||||
reqJson.set(reqJson.size(), invocationJson); | reqJson.set(reqJson.size(), invocationJson); | ||||
* true if the update is to be sent as soon as possible | * true if the update is to be sent as soon as possible | ||||
*/ | */ | ||||
public void updateVariable(String paintableId, String variableName, | public void updateVariable(String paintableId, String variableName, | ||||
VPaintable newValue, boolean immediate) { | |||||
Connector newValue, boolean immediate) { | |||||
addVariableToQueue(paintableId, variableName, newValue, immediate); | addVariableToQueue(paintableId, variableName, newValue, immediate); | ||||
} | } | ||||
while (childWidgets.hasNext()) { | while (childWidgets.hasNext()) { | ||||
final Widget child = childWidgets.next(); | final Widget child = childWidgets.next(); | ||||
if (getPaintableMap().isPaintable(child)) { | |||||
if (getConnectorMap().isConnector(child)) { | |||||
if (handleComponentRelativeSize(child)) { | if (handleComponentRelativeSize(child)) { | ||||
/* | /* | ||||
* @param child | * @param child | ||||
* @return true if the child has a relative size | * @return true if the child has a relative size | ||||
*/ | */ | ||||
private boolean handleComponentRelativeSize(VPaintableWidget paintable) { | |||||
private boolean handleComponentRelativeSize(ComponentConnector paintable) { | |||||
return false; | return false; | ||||
} | } | ||||
* @return true if the child has a relative size | * @return true if the child has a relative size | ||||
*/ | */ | ||||
public boolean handleComponentRelativeSize(Widget widget) { | public boolean handleComponentRelativeSize(Widget widget) { | ||||
return handleComponentRelativeSize(paintableMap.getPaintable(widget)); | |||||
return handleComponentRelativeSize(connectorMap.getConnector(widget)); | |||||
} | } | ||||
* UIDL to create Paintable from. | * UIDL to create Paintable from. | ||||
* @return Either existing or new Paintable corresponding to UIDL. | * @return Either existing or new Paintable corresponding to UIDL. | ||||
*/ | */ | ||||
public VPaintableWidget getPaintable(UIDL uidl) { | |||||
public ComponentConnector getPaintable(UIDL uidl) { | |||||
final String pid = uidl.getId(); | final String pid = uidl.getId(); | ||||
// the actual content UIDL may be deferred, but it always contains | // the actual content UIDL may be deferred, but it always contains | ||||
// enough information to create a paintable instance | // enough information to create a paintable instance | ||||
if (!paintableMap.hasPaintable(pid)) { | |||||
if (!connectorMap.hasConnector(pid)) { | |||||
// Create and register a new paintable if no old was found | // Create and register a new paintable if no old was found | ||||
VPaintableWidget p = widgetSet.createWidget(uidl.getTag(), | |||||
ComponentConnector p = widgetSet.createWidget(uidl.getTag(), | |||||
configuration); | configuration); | ||||
p.setConnection(this); | p.setConnection(this); | ||||
p.setId(pid); | p.setId(pid); | ||||
p.init(); | p.init(); | ||||
paintableMap.registerPaintable(pid, p); | |||||
connectorMap.registerConnector(pid, p); | |||||
} | } | ||||
return (VPaintableWidget) paintableMap.getPaintable(pid); | |||||
return (ComponentConnector) connectorMap.getConnector(pid); | |||||
} | } | ||||
/** | /** | ||||
* Updating TooltipInfo is done in updateComponent method. | * Updating TooltipInfo is done in updateComponent method. | ||||
* | * | ||||
*/ | */ | ||||
public TooltipInfo getTooltipTitleInfo(VPaintableWidget titleOwner, | |||||
public TooltipInfo getTooltipTitleInfo(ComponentConnector titleOwner, | |||||
Object key) { | Object key) { | ||||
if (null == titleOwner) { | if (null == titleOwner) { | ||||
return null; | return null; | ||||
} | } | ||||
return paintableMap.getTooltipInfo(titleOwner, key); | |||||
return connectorMap.getTooltipInfo(titleOwner, key); | |||||
} | } | ||||
private final VTooltip tooltip = new VTooltip(this); | private final VTooltip tooltip = new VTooltip(this); | ||||
* @param event | * @param event | ||||
* @param owner | * @param owner | ||||
*/ | */ | ||||
public void handleTooltipEvent(Event event, VPaintableWidget owner) { | |||||
public void handleTooltipEvent(Event event, ComponentConnector owner) { | |||||
tooltip.handleTooltipEvent(event, owner, null); | tooltip.handleTooltipEvent(event, owner, null); | ||||
} | } | ||||
* the key for tooltip if this is "additional" tooltip, null for | * the key for tooltip if this is "additional" tooltip, null for | ||||
* components "main tooltip" | * components "main tooltip" | ||||
*/ | */ | ||||
public void handleTooltipEvent(Event event, VPaintableWidget owner, | |||||
public void handleTooltipEvent(Event event, ComponentConnector owner, | |||||
Object key) { | Object key) { | ||||
tooltip.handleTooltipEvent(event, owner, key); | tooltip.handleTooltipEvent(event, owner, key); | ||||
} | } | ||||
}; | }; | ||||
private VPaintableMap paintableMap = GWT.create(VPaintableMap.class); | |||||
private ConnectorMap connectorMap = GWT.create(ConnectorMap.class); | |||||
/** | /** | ||||
* Components can call this function to run all layout functions. This is | * Components can call this function to run all layout functions. This is | ||||
* this method. | * this method. | ||||
* <p> | * <p> | ||||
* Component must also pipe events to | * Component must also pipe events to | ||||
* {@link #handleTooltipEvent(Event, VPaintableWidget, Object)} method. | |||||
* {@link #handleTooltipEvent(Event, ComponentConnector, Object)} method. | |||||
* <p> | * <p> | ||||
* This method can also be used to deregister tooltips by using null as | * This method can also be used to deregister tooltips by using null as | ||||
* tooltip | * tooltip | ||||
* @param key | * @param key | ||||
* key assosiated with given tooltip. Can be any object. For | * key assosiated with given tooltip. Can be any object. For | ||||
* example a related dom element. Same key must be given for | * example a related dom element. Same key must be given for | ||||
* {@link #handleTooltipEvent(Event, VPaintableWidget, Object)} | |||||
* {@link #handleTooltipEvent(Event, ComponentConnector, Object)} | |||||
* method. | * method. | ||||
* | * | ||||
* @param tooltip | * @param tooltip | ||||
* the TooltipInfo object containing details shown in tooltip, | * the TooltipInfo object containing details shown in tooltip, | ||||
* null if deregistering tooltip | * null if deregistering tooltip | ||||
*/ | */ | ||||
public void registerTooltip(VPaintableWidget paintable, Object key, | |||||
public void registerTooltip(ComponentConnector paintable, Object key, | |||||
TooltipInfo tooltip) { | TooltipInfo tooltip) { | ||||
paintableMap.registerTooltip(paintable, key, tooltip); | |||||
connectorMap.registerTooltip(paintable, key, tooltip); | |||||
} | } | ||||
/** | /** | ||||
* @return true if at least one listener has been registered on server side | * @return true if at least one listener has been registered on server side | ||||
* for the event identified by eventIdentifier. | * for the event identified by eventIdentifier. | ||||
*/ | */ | ||||
public boolean hasEventListeners(VPaintableWidget paintable, | |||||
public boolean hasEventListeners(ComponentConnector paintable, | |||||
String eventIdentifier) { | String eventIdentifier) { | ||||
return paintableMap.hasEventListeners(paintable, eventIdentifier); | |||||
return connectorMap.hasEventListeners(paintable, eventIdentifier); | |||||
} | } | ||||
/** | /** | ||||
return uri; | return uri; | ||||
} | } | ||||
VPaintableMap getPaintableMap() { | |||||
return paintableMap; | |||||
ConnectorMap getConnectorMap() { | |||||
return connectorMap; | |||||
} | } | ||||
@Deprecated | @Deprecated | ||||
public void unregisterPaintable(VPaintable p) { | |||||
paintableMap.unregisterPaintable(p); | |||||
public void unregisterPaintable(Connector p) { | |||||
connectorMap.unregisterConnector(p); | |||||
} | } | ||||
public VTooltip getVTooltip() { | public VTooltip getVTooltip() { | ||||
@Deprecated | @Deprecated | ||||
public void handleTooltipEvent(Event event, Widget owner, Object key) { | public void handleTooltipEvent(Event event, Widget owner, Object key) { | ||||
handleTooltipEvent(event, getPaintableMap().getPaintable(owner), key); | |||||
handleTooltipEvent(event, getConnectorMap().getConnector(owner), key); | |||||
} | } | ||||
@Deprecated | @Deprecated | ||||
public void handleTooltipEvent(Event event, Widget owner) { | public void handleTooltipEvent(Event event, Widget owner) { | ||||
handleTooltipEvent(event, getPaintableMap().getPaintable(owner)); | |||||
handleTooltipEvent(event, getConnectorMap().getConnector(owner)); | |||||
} | } | ||||
@Deprecated | @Deprecated | ||||
public void registerTooltip(Widget owner, Object key, TooltipInfo info) { | public void registerTooltip(Widget owner, Object key, TooltipInfo info) { | ||||
registerTooltip(getPaintableMap().getPaintable(owner), key, info); | |||||
registerTooltip(getConnectorMap().getConnector(owner), key, info); | |||||
} | } | ||||
@Deprecated | @Deprecated | ||||
public boolean hasEventListeners(Widget widget, String eventIdentifier) { | public boolean hasEventListeners(Widget widget, String eventIdentifier) { | ||||
return hasEventListeners(getPaintableMap().getPaintable(widget), | |||||
return hasEventListeners(getConnectorMap().getConnector(widget), | |||||
eventIdentifier); | eventIdentifier); | ||||
} | } | ||||
* Updates can be sent back to the server using the | * Updates can be sent back to the server using the | ||||
* {@link ApplicationConnection#updateVariable()} methods. | * {@link ApplicationConnection#updateVariable()} methods. | ||||
*/ | */ | ||||
public interface VPaintableWidget extends VPaintable { | |||||
public interface ComponentConnector extends Connector { | |||||
/* | /* | ||||
* (non-Javadoc) | * (non-Javadoc) | ||||
public Widget getWidget(); | public Widget getWidget(); | ||||
/** | /** | ||||
* Returns the parent {@link VPaintableWidgetContainer} | |||||
* Returns the parent {@link ComponentContainerConnector} | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public VPaintableWidgetContainer getParent(); | |||||
public ComponentContainerConnector getParent(); | |||||
public LayoutManager getLayoutManager(); | public LayoutManager getLayoutManager(); | ||||
* An interface used by client-side paintables whose widget is a component | * An interface used by client-side paintables whose widget is a component | ||||
* container (implements {@link HasWidgets}). | * container (implements {@link HasWidgets}). | ||||
*/ | */ | ||||
public interface VPaintableWidgetContainer extends VPaintableWidget { | |||||
public interface ComponentContainerConnector extends ComponentConnector { | |||||
/** | /** | ||||
* Update child components caption, description and error message. | * Update child components caption, description and error message. | ||||
* @param uidl | * @param uidl | ||||
* UIDL of the child component. | * UIDL of the child component. | ||||
*/ | */ | ||||
void updateCaption(VPaintableWidget paintable, UIDL uidl); | |||||
void updateCaption(ComponentConnector paintable, UIDL uidl); | |||||
/** | /** | ||||
* Returns the children for this paintable. | * Returns the children for this paintable. | ||||
* <p> | * <p> | ||||
* The children for this paintable are defined as all | * The children for this paintable are defined as all | ||||
* {@link VPaintableWidget}s whose parent is this | |||||
* {@link VPaintableWidgetContainer}. | |||||
* {@link ComponentConnector}s whose parent is this | |||||
* {@link ComponentContainerConnector}. | |||||
* </p> | * </p> | ||||
* | * | ||||
* @return A collection of children for this paintable. An empty collection | * @return A collection of children for this paintable. An empty collection | ||||
* if there are no children. | * if there are no children. | ||||
*/ | */ | ||||
public Collection<VPaintableWidget> getChildren(); | |||||
public Collection<ComponentConnector> getChildren(); | |||||
} | } |
Element e = targetElement; | Element e = targetElement; | ||||
while (true) { | while (true) { | ||||
pid = VPaintableMap.get(client).getPid(e); | |||||
pid = ConnectorMap.get(client).getConnectorId(e); | |||||
if (pid != null) { | if (pid != null) { | ||||
break; | break; | ||||
} | } | ||||
// If we found a Paintable then we use that as reference. We should | // If we found a Paintable then we use that as reference. We should | ||||
// find the Paintable for all but very special cases (like | // find the Paintable for all but very special cases (like | ||||
// overlays). | // overlays). | ||||
w = ((VPaintableWidget) VPaintableMap.get(client).getPaintable(pid)) | |||||
w = ((ComponentConnector) ConnectorMap.get(client).getConnector(pid)) | |||||
.getWidget(); | .getWidget(); | ||||
/* | /* | ||||
return null; | return null; | ||||
} | } | ||||
String pid = VPaintableMap.get(client).getPid(w.getElement()); | |||||
String pid = ConnectorMap.get(client).getConnectorId(w.getElement()); | |||||
if (isStaticPid(pid)) { | if (isStaticPid(pid)) { | ||||
return pid; | return pid; | ||||
} | } | ||||
w = client.getView().getWidget(); | w = client.getView().getWidget(); | ||||
} else if (w == null) { | } else if (w == null) { | ||||
// Must be static pid (PID_S*) | // Must be static pid (PID_S*) | ||||
w = ((VPaintableWidget) VPaintableMap.get(client).getPaintable( | |||||
w = ((ComponentConnector) ConnectorMap.get(client).getConnector( | |||||
part)).getWidget(); | part)).getWidget(); | ||||
} else if (part.startsWith("domChild[")) { | } else if (part.startsWith("domChild[")) { | ||||
// The target widget has been found and the rest identifies the | // The target widget has been found and the rest identifies the |
* @version @VERSION@ | * @version @VERSION@ | ||||
* @since 7.0.0 | * @since 7.0.0 | ||||
*/ | */ | ||||
public interface VPaintable { | |||||
public interface Connector { | |||||
/** | /** | ||||
* TODO | * TODO | ||||
* | * | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client); | public void updateFromUIDL(UIDL uidl, ApplicationConnection client); | ||||
/** | /** | ||||
* Gets the current shared state of the paintable. | |||||
* Gets the current shared state of the connector. | |||||
* | * | ||||
* @return state | * @return state | ||||
*/ | */ | ||||
public SharedState getState(); | public SharedState getState(); | ||||
/** | /** | ||||
* Sets a new state for the paintable. | |||||
* Sets a new state for the connector. | |||||
* | * | ||||
* @param state | * @param state | ||||
* The new state | * The new state | ||||
public void setState(SharedState state); | public void setState(SharedState state); | ||||
/** | /** | ||||
* Returns the id for this VPaintable. This must always be what has been set | |||||
* Returns the id for this connector. This must always be what has been set | |||||
* using {@link #setId(String)}. | * using {@link #setId(String)}. | ||||
* | * | ||||
* @return The id for the VPaintable. | |||||
* @return The id for the connector. | |||||
*/ | */ | ||||
public String getId(); | public String getId(); | ||||
/** | /** | ||||
* Sets the id for the VPaintable. This method is called once by the | |||||
* framework when the VPaintable is initialized and should never be called | |||||
* Sets the id for the connector. This method is called once by the | |||||
* framework when the connector is initialized and should never be called | |||||
* otherwise. | * otherwise. | ||||
* <p> | * <p> | ||||
* The VPaintable id is used to map the server and the client paintables | |||||
* together. It is unique in this root and assigned by the framework. | |||||
* The connector id is used to map the server and the client side together. | |||||
* It is unique in this Root and assigned by the framework. | |||||
* </p> | * </p> | ||||
* | * | ||||
* @param id | * @param id | ||||
* The id of the paintable. | |||||
* The id of the connector. | |||||
*/ | */ | ||||
public void setId(String id); | public void setId(String id); | ||||
/** | /** | ||||
* Gets ApplicationConnection instance that created this VPaintable. | |||||
* Gets ApplicationConnection instance that created this connector. | |||||
* | * | ||||
* @return The ApplicationConnection as set by | * @return The ApplicationConnection as set by | ||||
* {@link #setConnection(ApplicationConnection)} | * {@link #setConnection(ApplicationConnection)} | ||||
/** | /** | ||||
* Sets the reference to ApplicationConnection. This method is called by the | * Sets the reference to ApplicationConnection. This method is called by the | ||||
* framework when the VPaintable is created and should never be called | |||||
* framework when the connector is created and should never be called | |||||
* otherwise. | * otherwise. | ||||
* | * | ||||
* @param connection | * @param connection | ||||
* The ApplicationConnection that created this VPaintable | |||||
* The ApplicationConnection that created this connector | |||||
*/ | */ | ||||
public void setConnection(ApplicationConnection connection); | public void setConnection(ApplicationConnection connection); | ||||
/* | |||||
@VaadinApache2LicenseForJavaFiles@ | |||||
*/ | |||||
package com.vaadin.terminal.gwt.client; | |||||
import java.util.ArrayList; | |||||
import java.util.Collection; | |||||
import java.util.Collections; | |||||
import java.util.HashMap; | |||||
import java.util.HashSet; | |||||
import java.util.Iterator; | |||||
import java.util.Map; | |||||
import java.util.Set; | |||||
import com.google.gwt.core.client.GWT; | |||||
import com.google.gwt.dom.client.Element; | |||||
import com.google.gwt.user.client.ui.HasWidgets; | |||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.vaadin.terminal.Paintable; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
public class ConnectorMap { | |||||
private Map<String, Connector> idToConnector = new HashMap<String, Connector>(); | |||||
public static ConnectorMap get(ApplicationConnection applicationConnection) { | |||||
return applicationConnection.getConnectorMap(); | |||||
} | |||||
@Deprecated | |||||
private final ComponentDetailMap idToComponentDetail = ComponentDetailMap | |||||
.create(); | |||||
private Set<String> unregistryBag = new HashSet<String>(); | |||||
/** | |||||
* Returns a {@link Connector} by its id | |||||
* | |||||
* @param id | |||||
* The connector id | |||||
* @return A connector or null if a connector with the given id has not been | |||||
* registered | |||||
*/ | |||||
public Connector getConnector(String connectorId) { | |||||
return idToConnector.get(connectorId); | |||||
} | |||||
/** | |||||
* Returns a {@link ComponentConnector} element by its root element | |||||
* | |||||
* @param element | |||||
* Root element of the {@link ComponentConnector} | |||||
* @return A connector or null if a connector with the given id has not been | |||||
* registered | |||||
*/ | |||||
public ComponentConnector getConnector(Element element) { | |||||
return (ComponentConnector) getConnector(getConnectorId(element)); | |||||
} | |||||
/** | |||||
* FIXME: What does this even do and why? | |||||
* | |||||
* @param pid | |||||
* @return | |||||
*/ | |||||
public boolean isDragAndDropPaintable(String pid) { | |||||
return (pid.startsWith("DD")); | |||||
} | |||||
/** | |||||
* Checks if a connector with the given id has been registered. | |||||
* | |||||
* @param connectorId | |||||
* The id to check for | |||||
* @return true if a connector has been registered with the given id, false | |||||
* otherwise | |||||
*/ | |||||
public boolean hasConnector(String connectorId) { | |||||
return idToConnector.containsKey(connectorId); | |||||
} | |||||
/** | |||||
* Removes all registered connectors | |||||
*/ | |||||
public void clear() { | |||||
idToConnector.clear(); | |||||
idToComponentDetail.clear(); | |||||
} | |||||
public ComponentConnector getConnector(Widget widget) { | |||||
return getConnector(widget.getElement()); | |||||
} | |||||
public void registerConnector(String id, Connector connector) { | |||||
ComponentDetail componentDetail = GWT.create(ComponentDetail.class); | |||||
idToComponentDetail.put(id, componentDetail); | |||||
idToConnector.put(id, connector); | |||||
if (connector instanceof ComponentConnector) { | |||||
ComponentConnector pw = (ComponentConnector) connector; | |||||
setConnectorId(pw.getWidget().getElement(), id); | |||||
} | |||||
} | |||||
private native void setConnectorId(Element el, String id) | |||||
/*-{ | |||||
el.tkPid = id; | |||||
}-*/; | |||||
/** | |||||
* Gets the id for a specific connector. | |||||
* <p> | |||||
* The id is used in the UIDL to identify a specific widget instance, | |||||
* effectively linking the widget with it's server side Component. | |||||
* </p> | |||||
* | |||||
* @param connector | |||||
* the connector whose id is needed | |||||
* @return the id for the given connector or null if the connector could not | |||||
* be found | |||||
* @deprecated use {@link Connector#getId()} instead | |||||
*/ | |||||
@Deprecated | |||||
public String getConnectorId(Connector connector) { | |||||
if (connector == null) { | |||||
return null; | |||||
} | |||||
return connector.getId(); | |||||
} | |||||
@Deprecated | |||||
public String getConnectorId(Widget widget) { | |||||
return getConnectorId(widget.getElement()); | |||||
} | |||||
/** | |||||
* Gets the connector id using a DOM element - the element should be the | |||||
* root element for a connector, otherwise no id will be found. Use | |||||
* {@link #getConnectorId(Connector)} instead whenever possible. | |||||
* | |||||
* @see #getConnectorId(Paintable) | |||||
* @param el | |||||
* element of the connector whose id is desired | |||||
* @return the id of the element's connector, if it's a connector | |||||
*/ | |||||
native String getConnectorId(Element el) | |||||
/*-{ | |||||
return el.tkPid; | |||||
}-*/; | |||||
/** | |||||
* Gets the main element for the connector with the given id. The reverse of | |||||
* {@link #getConnectorId(Element)}. | |||||
* | |||||
* @param connectorId | |||||
* the id of the widget whose element is desired | |||||
* @return the element for the connector corresponding to the id | |||||
*/ | |||||
public Element getElement(String connectorId) { | |||||
Connector p = getConnector(connectorId); | |||||
if (p instanceof ComponentConnector) { | |||||
return ((ComponentConnector) p).getWidget().getElement(); | |||||
} | |||||
return null; | |||||
} | |||||
/** | |||||
* Unregisters the given connector; always use after removing a connector. | |||||
* This method does not remove the connector from the DOM, but marks the | |||||
* connector so that ApplicationConnection may clean up its references to | |||||
* it. Removing the widget from DOM is component containers responsibility. | |||||
* | |||||
* @param connector | |||||
* the connector to remove | |||||
*/ | |||||
public void unregisterConnector(Connector connector) { | |||||
// add to unregistry que | |||||
if (connector == null) { | |||||
VConsole.error("WARN: Trying to unregister null connector"); | |||||
return; | |||||
} | |||||
String id = connector.getId(); | |||||
Widget widget = null; | |||||
if (connector instanceof ComponentConnector) { | |||||
widget = ((ComponentConnector) connector).getWidget(); | |||||
} | |||||
if (id == null) { | |||||
/* | |||||
* Uncomment the following to debug unregistring components. No | |||||
* paintables with null id should end here. At least one exception | |||||
* is our VScrollTableRow, that is hacked to fake it self as a | |||||
* Paintable to build support for sizing easier. | |||||
*/ | |||||
// if (!(p instanceof VScrollTableRow)) { | |||||
// VConsole.log("Trying to unregister Paintable not created by Application Connection."); | |||||
// } | |||||
} else { | |||||
unregistryBag.add(id); | |||||
} | |||||
if (widget != null && widget instanceof HasWidgets) { | |||||
unregisterChildConnectors((HasWidgets) widget); | |||||
} | |||||
} | |||||
public ComponentConnector[] getRegisteredComponentConnectors() { | |||||
ArrayList<ComponentConnector> result = new ArrayList<ComponentConnector>(); | |||||
for (Connector connector : getConnectors()) { | |||||
if (connector instanceof ComponentConnector) { | |||||
ComponentConnector componentConnector = (ComponentConnector) connector; | |||||
if (!unregistryBag.contains(getConnectorId(connector))) { | |||||
result.add(componentConnector); | |||||
} | |||||
} | |||||
} | |||||
return result.toArray(new ComponentConnector[result.size()]); | |||||
} | |||||
void purgeUnregistryBag(boolean unregisterConnectors) { | |||||
if (unregisterConnectors) { | |||||
for (String connectorId : unregistryBag) { | |||||
// TODO purge shared state for pid | |||||
Connector connector = getConnector(connectorId); | |||||
if (connector == null) { | |||||
/* | |||||
* this should never happen, but it does :-( See e.g. | |||||
* com.vaadin.tests.components.accordion.RemoveTabs (with | |||||
* test script) | |||||
*/ | |||||
VConsole.error("Tried to unregister component (id=" | |||||
+ connectorId | |||||
+ ") that is never registered (or already unregistered)"); | |||||
continue; | |||||
} | |||||
Widget widget = null; | |||||
if (connector instanceof ComponentConnector) { | |||||
widget = ((ComponentConnector) connector).getWidget(); | |||||
} | |||||
// check if can be cleaned | |||||
if (widget == null || !widget.isAttached()) { | |||||
// clean reference to paintable | |||||
idToComponentDetail.remove(connectorId); | |||||
idToConnector.remove(connectorId); | |||||
} | |||||
/* | |||||
* else NOP : same component has been reattached to another | |||||
* parent or replaced by another component implementation. | |||||
*/ | |||||
} | |||||
} | |||||
unregistryBag.clear(); | |||||
} | |||||
/** | |||||
* Unregisters the child connectors for the given container recursively. | |||||
* | |||||
* Use when after removing a connector that contains other connectors. Does | |||||
* not unregister the given container itself. Does not actually remove the | |||||
* widgets from the DOM. | |||||
* | |||||
* @see #unregisterConnector(Connector) | |||||
* @param container | |||||
* The container that contains the connectors that should be | |||||
* unregistered | |||||
*/ | |||||
public void unregisterChildConnectors(HasWidgets container) { | |||||
// FIXME: This should be based on the paintable hierarchy | |||||
final Iterator<Widget> it = container.iterator(); | |||||
while (it.hasNext()) { | |||||
final Widget w = it.next(); | |||||
ComponentConnector p = getConnector(w); | |||||
if (p != null) { | |||||
// This will unregister the paintable and all its children | |||||
unregisterConnector(p); | |||||
} else if (w instanceof HasWidgets) { | |||||
// For normal widget containers, unregister the children | |||||
unregisterChildConnectors((HasWidgets) w); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param pid | |||||
* @param uidl | |||||
*/ | |||||
@Deprecated | |||||
public void registerEventListenersFromUIDL(String pid, UIDL uidl) { | |||||
ComponentDetail cd = idToComponentDetail.get(pid); | |||||
if (cd == null) { | |||||
throw new IllegalArgumentException("Pid must not be null"); | |||||
} | |||||
cd.registerEventListenersFromUIDL(uidl); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public Size getOffsetSize(ComponentConnector paintable) { | |||||
return getComponentDetail(paintable).getOffsetSize(); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param componentConnector | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public void setOffsetSize(ComponentConnector componentConnector, | |||||
Size newSize) { | |||||
getComponentDetail(componentConnector).setOffsetSize(newSize); | |||||
} | |||||
private ComponentDetail getComponentDetail( | |||||
ComponentConnector componentConnector) { | |||||
return idToComponentDetail.get(getConnectorId(componentConnector)); | |||||
} | |||||
public int size() { | |||||
return idToConnector.size(); | |||||
} | |||||
/** | |||||
* FIXME: Should be moved to VAbstractPaintableWidget | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public TooltipInfo getTooltipInfo(ComponentConnector paintable, Object key) { | |||||
return getComponentDetail(paintable).getTooltipInfo(key); | |||||
} | |||||
@Deprecated | |||||
public TooltipInfo getWidgetTooltipInfo(Widget widget, Object key) { | |||||
return getTooltipInfo(getConnector(widget), key); | |||||
} | |||||
public Collection<? extends Connector> getConnectors() { | |||||
return Collections.unmodifiableCollection(idToConnector.values()); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param componentConnector | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public void registerTooltip(ComponentConnector componentConnector, | |||||
Object key, TooltipInfo tooltip) { | |||||
getComponentDetail(componentConnector).putAdditionalTooltip(key, | |||||
tooltip); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param componentConnector | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public boolean hasEventListeners(ComponentConnector componentConnector, | |||||
String eventIdentifier) { | |||||
return getComponentDetail(componentConnector).hasEventListeners( | |||||
eventIdentifier); | |||||
} | |||||
/** | |||||
* Tests if the widget is the root widget of a {@link ComponentConnector}. | |||||
* | |||||
* @param widget | |||||
* The widget to test | |||||
* @return true if the widget is the root widget of a | |||||
* {@link ComponentConnector}, false otherwise | |||||
*/ | |||||
public boolean isConnector(Widget w) { | |||||
return getConnectorId(w) != null; | |||||
} | |||||
} |
public abstract void printLayoutProblems(ValueMap meta, | public abstract void printLayoutProblems(ValueMap meta, | ||||
ApplicationConnection applicationConnection, | ApplicationConnection applicationConnection, | ||||
Set<VPaintableWidget> zeroHeightComponents, | |||||
Set<VPaintableWidget> zeroWidthComponents); | |||||
Set<ComponentConnector> zeroHeightComponents, | |||||
Set<ComponentConnector> zeroWidthComponents); | |||||
public abstract void setQuietMode(boolean quietDebugMode); | public abstract void setQuietMode(boolean quietDebugMode); | ||||
*/ | */ | ||||
public class EventHelper { | public class EventHelper { | ||||
public static HandlerRegistration updateFocusHandler(VPaintableWidget paintable, | |||||
public static HandlerRegistration updateFocusHandler(ComponentConnector paintable, | |||||
ApplicationConnection client, | ApplicationConnection client, | ||||
HandlerRegistration handlerRegistration) { | HandlerRegistration handlerRegistration) { | ||||
if (client.hasEventListeners(paintable, FOCUS)) { | if (client.hasEventListeners(paintable, FOCUS)) { | ||||
return null; | return null; | ||||
} | } | ||||
public static HandlerRegistration updateBlurHandler(VPaintableWidget paintable, | |||||
public static HandlerRegistration updateBlurHandler(ComponentConnector paintable, | |||||
ApplicationConnection client, | ApplicationConnection client, | ||||
HandlerRegistration handlerRegistration) { | HandlerRegistration handlerRegistration) { | ||||
if (client.hasEventListeners(paintable, BLUR)) { | if (client.hasEventListeners(paintable, BLUR)) { |
if (measuredSize == null) { | if (measuredSize == null) { | ||||
measuredSize = new MeasuredSize(); | measuredSize = new MeasuredSize(); | ||||
if (VPaintableMap.get(connection).getPaintable(element) == null) { | |||||
if (ConnectorMap.get(connection).getConnector(element) == null) { | |||||
nonPaintableElements.add(element); | nonPaintableElements.add(element); | ||||
} | } | ||||
setMeasuredSize(element, measuredSize); | setMeasuredSize(element, measuredSize); | ||||
} | } | ||||
private boolean needsMeasure(Element e) { | private boolean needsMeasure(Element e) { | ||||
if (connection.getPaintableMap().getPid(e) != null) { | |||||
if (connection.getConnectorMap().getConnectorId(e) != null) { | |||||
return true; | return true; | ||||
} else if (getMeasuredSize(e, nullSize).hasDependents()) { | } else if (getMeasuredSize(e, nullSize).hasDependents()) { | ||||
return true; | return true; | ||||
return element.vMeasuredSize || defaultSize; | return element.vMeasuredSize || defaultSize; | ||||
}-*/; | }-*/; | ||||
private static final MeasuredSize getMeasuredSize(VPaintableWidget paintable) { | |||||
private static final MeasuredSize getMeasuredSize(ComponentConnector paintable) { | |||||
Element element = paintable.getWidget().getElement(); | Element element = paintable.getWidget().getElement(); | ||||
MeasuredSize measuredSize = getMeasuredSize(element, null); | MeasuredSize measuredSize = getMeasuredSize(element, null); | ||||
if (measuredSize == null) { | if (measuredSize == null) { | ||||
} | } | ||||
public void doLayout() { | public void doLayout() { | ||||
VPaintableMap paintableMap = connection.getPaintableMap(); | |||||
VPaintableWidget[] paintableWidgets = paintableMap | |||||
.getRegisteredPaintableWidgets(); | |||||
ConnectorMap paintableMap = connection.getConnectorMap(); | |||||
ComponentConnector[] paintableWidgets = paintableMap | |||||
.getRegisteredComponentConnectors(); | |||||
int passes = 0; | int passes = 0; | ||||
Duration totalDuration = new Duration(); | Duration totalDuration = new Duration(); | ||||
FastStringSet needsHeightUpdate = FastStringSet.create(); | FastStringSet needsHeightUpdate = FastStringSet.create(); | ||||
FastStringSet needsWidthUpdate = FastStringSet.create(); | FastStringSet needsWidthUpdate = FastStringSet.create(); | ||||
for (VPaintableWidget paintable : paintableWidgets) { | |||||
for (ComponentConnector paintable : paintableWidgets) { | |||||
MeasuredSize measuredSize = getMeasuredSize(paintable); | MeasuredSize measuredSize = getMeasuredSize(paintable); | ||||
boolean managed = isManagedLayout(paintable); | boolean managed = isManagedLayout(paintable); | ||||
VPaintableWidgetContainer parent = paintable.getParent(); | |||||
ComponentContainerConnector parent = paintable.getParent(); | |||||
boolean managedParent = parent != null | boolean managedParent = parent != null | ||||
&& isManagedLayout(parent); | && isManagedLayout(parent); | ||||
for (int i = 0; i < needsWidthUpdateArray.length(); i++) { | for (int i = 0; i < needsWidthUpdateArray.length(); i++) { | ||||
String pid = needsWidthUpdateArray.get(i); | String pid = needsWidthUpdateArray.get(i); | ||||
VPaintable paintable = paintableMap.getPaintable(pid); | |||||
Connector paintable = paintableMap.getConnector(pid); | |||||
if (paintable instanceof DirectionalManagedLayout) { | if (paintable instanceof DirectionalManagedLayout) { | ||||
DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; | DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; | ||||
cl.layoutHorizontally(); | cl.layoutHorizontally(); | ||||
for (int i = 0; i < needsHeightUpdateArray.length(); i++) { | for (int i = 0; i < needsHeightUpdateArray.length(); i++) { | ||||
String pid = needsHeightUpdateArray.get(i); | String pid = needsHeightUpdateArray.get(i); | ||||
VPaintableWidget paintable = (VPaintableWidget) paintableMap | |||||
.getPaintable(pid); | |||||
ComponentConnector paintable = (ComponentConnector) paintableMap | |||||
.getConnector(pid); | |||||
if (paintable instanceof DirectionalManagedLayout) { | if (paintable instanceof DirectionalManagedLayout) { | ||||
DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; | DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; | ||||
cl.layoutVertically(); | cl.layoutVertically(); | ||||
} | } | ||||
} | } | ||||
for (VPaintableWidget vPaintableWidget : paintableWidgets) { | |||||
for (ComponentConnector vPaintableWidget : paintableWidgets) { | |||||
if (vPaintableWidget instanceof PostLayoutListener) { | if (vPaintableWidget instanceof PostLayoutListener) { | ||||
((PostLayoutListener) vPaintableWidget).postLayout(); | ((PostLayoutListener) vPaintableWidget).postLayout(); | ||||
} | } | ||||
+ "ms"); | + "ms"); | ||||
} | } | ||||
private void measureElements(VPaintableWidget[] paintableWidgets) { | |||||
private void measureElements(ComponentConnector[] paintableWidgets) { | |||||
for (VPaintableWidget paintableWidget : paintableWidgets) { | |||||
for (ComponentConnector paintableWidget : paintableWidgets) { | |||||
Element element = paintableWidget.getWidget() | Element element = paintableWidget.getWidget() | ||||
.getElement(); | .getElement(); | ||||
MeasuredSize measuredSize = getMeasuredSize(paintableWidget); | MeasuredSize measuredSize = getMeasuredSize(paintableWidget); | ||||
JsArrayString dependents = measuredSize.getDependents(); | JsArrayString dependents = measuredSize.getDependents(); | ||||
for (int i = 0; i < dependents.length(); i++) { | for (int i = 0; i < dependents.length(); i++) { | ||||
String pid = dependents.get(i); | String pid = dependents.get(i); | ||||
VPaintableWidget dependent = (VPaintableWidget) connection | |||||
.getPaintableMap().getPaintable(pid); | |||||
ComponentConnector dependent = (ComponentConnector) connection | |||||
.getConnectorMap().getConnector(pid); | |||||
if (dependent != null) { | if (dependent != null) { | ||||
MeasuredSize dependentSize = getMeasuredSize(dependent); | MeasuredSize dependentSize = getMeasuredSize(dependent); | ||||
if (measuredSize.isHeightNeedsUpdate()) { | if (measuredSize.isHeightNeedsUpdate()) { | ||||
} | } | ||||
} | } | ||||
private static boolean isManagedLayout(VPaintableWidget paintable) { | |||||
private static boolean isManagedLayout(ComponentConnector paintable) { | |||||
return paintable instanceof ManagedLayout; | return paintable instanceof ManagedLayout; | ||||
} | } | ||||
public void foceLayout() { | public void foceLayout() { | ||||
VPaintableMap paintableMap = connection.getPaintableMap(); | |||||
VPaintableWidget[] paintableWidgets = paintableMap | |||||
.getRegisteredPaintableWidgets(); | |||||
for (VPaintableWidget vPaintableWidget : paintableWidgets) { | |||||
ConnectorMap paintableMap = connection.getConnectorMap(); | |||||
ComponentConnector[] paintableWidgets = paintableMap | |||||
.getRegisteredComponentConnectors(); | |||||
for (ComponentConnector vPaintableWidget : paintableWidgets) { | |||||
MeasuredSize measuredSize = getMeasuredSize(vPaintableWidget); | MeasuredSize measuredSize = getMeasuredSize(vPaintableWidget); | ||||
measuredSize.setHeightNeedsUpdate(); | measuredSize.setHeightNeedsUpdate(); | ||||
measuredSize.setWidthNeedsUpdate(); | measuredSize.setWidthNeedsUpdate(); |
public void printLayoutProblems(ValueMap meta, | public void printLayoutProblems(ValueMap meta, | ||||
ApplicationConnection applicationConnection, | ApplicationConnection applicationConnection, | ||||
Set<VPaintableWidget> zeroHeightComponents, | |||||
Set<VPaintableWidget> zeroWidthComponents) { | |||||
Set<ComponentConnector> zeroHeightComponents, | |||||
Set<ComponentConnector> zeroWidthComponents) { | |||||
} | } | ||||
public void log(Throwable e) { | public void log(Throwable e) { |
/** | /** | ||||
* When a component is updated, it's client side widget's | * When a component is updated, it's client side widget's | ||||
* {@link VPaintableWidget#updateFromUIDL(UIDL, ApplicationConnection) | |||||
* {@link ComponentConnector#updateFromUIDL(UIDL, ApplicationConnection) | |||||
* updateFromUIDL()} will be called with the updated ("changes") UIDL received | * updateFromUIDL()} will be called with the updated ("changes") UIDL received | ||||
* from the server. | * from the server. | ||||
* <p> | * <p> | ||||
* AbstractComponent.paintContent()}. Note that if the UIDL corresponds to a | * AbstractComponent.paintContent()}. Note that if the UIDL corresponds to a | ||||
* Paintable, a component identifier will be returned instead - this is used | * Paintable, a component identifier will be returned instead - this is used | ||||
* internally and is not needed within | * internally and is not needed within | ||||
* {@link VPaintableWidget#updateFromUIDL(UIDL, ApplicationConnection) | |||||
* {@link ComponentConnector#updateFromUIDL(UIDL, ApplicationConnection) | |||||
* updateFromUIDL()}. | * updateFromUIDL()}. | ||||
* | * | ||||
* @return the name for this section | * @return the name for this section | ||||
* the name of the attribute | * the name of the attribute | ||||
* @return the Paintable referenced by the attribute, if it exists | * @return the Paintable referenced by the attribute, if it exists | ||||
*/ | */ | ||||
public VPaintable getPaintableAttribute(String name, | |||||
public Connector getPaintableAttribute(String name, | |||||
ApplicationConnection connection) { | ApplicationConnection connection) { | ||||
return VPaintableMap.get(connection).getPaintable( | |||||
return ConnectorMap.get(connection).getConnector( | |||||
getStringAttribute(name)); | getStringAttribute(name)); | ||||
} | } | ||||
* the name of the variable | * the name of the variable | ||||
* @return the Paintable referenced by the variable, if it exists | * @return the Paintable referenced by the variable, if it exists | ||||
*/ | */ | ||||
public VPaintable getPaintableVariable(String name, | |||||
public Connector getPaintableVariable(String name, | |||||
ApplicationConnection connection) { | ApplicationConnection connection) { | ||||
return VPaintableMap.get(connection).getPaintable( | |||||
return ConnectorMap.get(connection).getConnector( | |||||
getStringVariable(name)); | getStringVariable(name)); | ||||
} | } | ||||
List<ApplicationConnection> runningApplications = ApplicationConfiguration | List<ApplicationConnection> runningApplications = ApplicationConfiguration | ||||
.getRunningApplications(); | .getRunningApplications(); | ||||
for (ApplicationConnection applicationConnection : runningApplications) { | for (ApplicationConnection applicationConnection : runningApplications) { | ||||
VPaintableMap paintableMap = applicationConnection | |||||
.getPaintableMap(); | |||||
VPaintableWidget paintable = paintableMap.getPaintable(widget); | |||||
ConnectorMap paintableMap = applicationConnection | |||||
.getConnectorMap(); | |||||
ComponentConnector paintable = paintableMap.getConnector(widget); | |||||
if (paintable == null) { | if (paintable == null) { | ||||
continue; | continue; | ||||
} | } | ||||
String pid = paintableMap.getPid(paintable); | |||||
String pid = paintableMap.getConnectorId(paintable); | |||||
if (pid != null) { | if (pid != null) { | ||||
VPaintable otherPaintable = paintableMap.getPaintable(pid); | |||||
Connector otherPaintable = paintableMap.getConnector(pid); | |||||
if (otherPaintable == paintable) { | if (otherPaintable == paintable) { | ||||
return applicationConnection; | return applicationConnection; | ||||
} | } | ||||
* @return The VPaintableWidget which the element is a part of. Null if the | * @return The VPaintableWidget which the element is a part of. Null if the | ||||
* element does not belong to a child. | * element does not belong to a child. | ||||
*/ | */ | ||||
public static VPaintableWidget getPaintableForElement( | |||||
public static ComponentConnector getPaintableForElement( | |||||
ApplicationConnection client, Widget parent, Element element) { | ApplicationConnection client, Widget parent, Element element) { | ||||
Element rootElement = parent.getElement(); | Element rootElement = parent.getElement(); | ||||
while (element != null && element != rootElement) { | while (element != null && element != rootElement) { | ||||
VPaintableWidget paintable = VPaintableMap.get(client) | |||||
.getPaintable(element); | |||||
ComponentConnector paintable = ConnectorMap.get(client) | |||||
.getConnector(element); | |||||
if (paintable == null) { | if (paintable == null) { | ||||
String ownerPid = VCaption.getCaptionOwnerPid(element); | String ownerPid = VCaption.getCaptionOwnerPid(element); | ||||
if (ownerPid != null) { | if (ownerPid != null) { | ||||
paintable = (VPaintableWidget) VPaintableMap.get(client) | |||||
.getPaintable(ownerPid); | |||||
paintable = (ComponentConnector) ConnectorMap.get(client) | |||||
.getConnector(ownerPid); | |||||
} | } | ||||
} | } | ||||
* @param element | * @param element | ||||
* the element to start from | * the element to start from | ||||
*/ | */ | ||||
public static VPaintableWidget findPaintable(ApplicationConnection client, | |||||
public static ComponentConnector findPaintable(ApplicationConnection client, | |||||
Element element) { | Element element) { | ||||
Widget widget = Util.findWidget(element, null); | Widget widget = Util.findWidget(element, null); | ||||
VPaintableMap vPaintableMap = VPaintableMap.get(client); | |||||
while (widget != null && !vPaintableMap.isPaintable(widget)) { | |||||
ConnectorMap vPaintableMap = ConnectorMap.get(client); | |||||
while (widget != null && !vPaintableMap.isConnector(widget)) { | |||||
widget = widget.getParent(); | widget = widget.getParent(); | ||||
} | } | ||||
return vPaintableMap.getPaintable(widget); | |||||
return vPaintableMap.getConnector(widget); | |||||
} | } | ||||
private static void printPaintablesInvocations( | private static void printPaintablesInvocations( | ||||
ArrayList<MethodInvocation> invocations, String id, | ArrayList<MethodInvocation> invocations, String id, | ||||
ApplicationConnection c) { | ApplicationConnection c) { | ||||
VPaintableWidget paintable = (VPaintableWidget) VPaintableMap.get(c) | |||||
.getPaintable(id); | |||||
ComponentConnector paintable = (ComponentConnector) ConnectorMap.get(c) | |||||
.getConnector(id); | |||||
if (paintable != null) { | if (paintable != null) { | ||||
VConsole.log("\t" + id + " (" + paintable.getClass() + ") :"); | VConsole.log("\t" + id + " (" + paintable.getClass() + ") :"); | ||||
for (MethodInvocation invocation : invocations) { | for (MethodInvocation invocation : invocations) { | ||||
Object value = parameters[1]; | Object value = parameters[1]; | ||||
// TODO paintables inside lists/maps get rendered as | // TODO paintables inside lists/maps get rendered as | ||||
// components in the debug console | // components in the debug console | ||||
String formattedValue = value instanceof VPaintable ? c | |||||
.getPaintableMap().getPid((VPaintable) value) | |||||
String formattedValue = value instanceof Connector ? c | |||||
.getConnectorMap().getConnectorId((Connector) value) | |||||
: String.valueOf(value); | : String.valueOf(value); | ||||
formattedParams = parameters[0] + " : " + formattedValue; | formattedParams = parameters[0] + " : " + formattedValue; | ||||
} | } |
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.ui.HTML; | import com.google.gwt.user.client.ui.HTML; | ||||
import com.vaadin.terminal.gwt.client.ui.Icon; | import com.vaadin.terminal.gwt.client.ui.Icon; | ||||
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.VTabsheetBasePaintable; | import com.vaadin.terminal.gwt.client.ui.VTabsheetBasePaintable; | ||||
public class VCaption extends HTML { | public class VCaption extends HTML { | ||||
public static final String CLASSNAME = "v-caption"; | public static final String CLASSNAME = "v-caption"; | ||||
private final VPaintableWidget owner; | |||||
private final ComponentConnector owner; | |||||
private Element errorIndicatorElement; | private Element errorIndicatorElement; | ||||
} | } | ||||
/** | /** | ||||
* Creates a caption that is not linked to a {@link VPaintableWidget}. | |||||
* Creates a caption that is not linked to a {@link ComponentConnector}. | |||||
* | * | ||||
* When using this constructor, {@link #getOwner()} returns null. | * When using this constructor, {@link #getOwner()} returns null. | ||||
* | * | ||||
} | } | ||||
/** | /** | ||||
* Creates a caption for a {@link VPaintableWidget}. | |||||
* Creates a caption for a {@link ComponentConnector}. | |||||
* | * | ||||
* @param component | * @param component | ||||
* owner of caption, not null | * owner of caption, not null | ||||
* @param client | * @param client | ||||
* ApplicationConnection | * ApplicationConnection | ||||
*/ | */ | ||||
public VCaption(VPaintableWidget component, ApplicationConnection client) { | |||||
public VCaption(ComponentConnector component, ApplicationConnection client) { | |||||
super(); | super(); | ||||
this.client = client; | this.client = client; | ||||
owner = component; | owner = component; | ||||
if (client != null && owner != null) { | if (client != null && owner != null) { | ||||
setOwnerPid(getElement(), VPaintableMap.get(client).getPid(owner)); | |||||
setOwnerPid(getElement(), ConnectorMap.get(client).getConnectorId(owner)); | |||||
} | } | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
setStyleName(style); | setStyleName(style); | ||||
boolean hasIcon = uidl | boolean hasIcon = uidl | ||||
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON); | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON); | |||||
boolean showRequired = uidl | boolean showRequired = uidl | ||||
.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED); | |||||
.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED); | |||||
boolean showError = uidl | boolean showError = uidl | ||||
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR) | |||||
&& !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS); | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR) | |||||
&& !uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_HIDEERRORS); | |||||
if (hasIcon) { | if (hasIcon) { | ||||
if (icon == null) { | if (icon == null) { | ||||
placedAfterComponent = false; | placedAfterComponent = false; | ||||
icon.setUri(uidl | icon.setUri(uidl | ||||
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)); | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
} else if (icon != null) { | } else if (icon != null) { | ||||
// Remove existing | // Remove existing | ||||
} | } | ||||
} | } | ||||
boolean hasIcon = uidl | boolean hasIcon = uidl | ||||
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON); | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON); | |||||
boolean showError = uidl | boolean showError = uidl | ||||
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR) | |||||
&& !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS); | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR) | |||||
&& !uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_HIDEERRORS); | |||||
if (hasIcon) { | if (hasIcon) { | ||||
if (icon == null) { | if (icon == null) { | ||||
placedAfterComponent = false; | placedAfterComponent = false; | ||||
icon.setUri(uidl | icon.setUri(uidl | ||||
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)); | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
} else if (icon != null) { | } else if (icon != null) { | ||||
// Remove existing | // Remove existing | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) { | |||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR)) { | |||||
return true; | return true; | ||||
} | } | ||||
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)) { | |||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)) { | |||||
return true; | return true; | ||||
} | } | ||||
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) { | |||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED)) { | |||||
return true; | return true; | ||||
} | } | ||||
* | * | ||||
* @return owner Widget | * @return owner Widget | ||||
*/ | */ | ||||
public VPaintableWidget getOwner() { | |||||
public ComponentConnector getOwner() { | |||||
return owner; | return owner; | ||||
} | } | ||||
public static final String CLASSNAME = "v-captionwrapper"; | public static final String CLASSNAME = "v-captionwrapper"; | ||||
VCaption caption; | VCaption caption; | ||||
VPaintableWidget paintable; | |||||
ComponentConnector paintable; | |||||
/** | /** | ||||
* Creates a new caption wrapper panel. | * Creates a new caption wrapper panel. | ||||
* @param client | * @param client | ||||
* ApplicationConnection | * ApplicationConnection | ||||
*/ | */ | ||||
public VCaptionWrapper(VPaintableWidget toBeWrapped, | |||||
public VCaptionWrapper(ComponentConnector toBeWrapped, | |||||
ApplicationConnection client) { | ApplicationConnection client) { | ||||
caption = new VCaption(toBeWrapped, client); | caption = new VCaption(toBeWrapped, client); | ||||
add(caption); | add(caption); | ||||
setVisible(!uidl.getBooleanAttribute("invisible")); | setVisible(!uidl.getBooleanAttribute("invisible")); | ||||
} | } | ||||
public VPaintableWidget getPaintable() { | |||||
public ComponentConnector getPaintable() { | |||||
return paintable; | return paintable; | ||||
} | } | ||||
} | } |
public static void printLayoutProblems(ValueMap meta, | public static void printLayoutProblems(ValueMap meta, | ||||
ApplicationConnection applicationConnection, | ApplicationConnection applicationConnection, | ||||
Set<VPaintableWidget> zeroHeightComponents, | |||||
Set<VPaintableWidget> zeroWidthComponents) { | |||||
Set<ComponentConnector> zeroHeightComponents, | |||||
Set<ComponentConnector> zeroWidthComponents) { | |||||
impl.printLayoutProblems(meta, applicationConnection, | impl.printLayoutProblems(meta, applicationConnection, | ||||
zeroHeightComponents, zeroWidthComponents); | zeroHeightComponents, zeroWidthComponents); | ||||
} | } |
for (ApplicationConnection a : ApplicationConfiguration | for (ApplicationConnection a : ApplicationConfiguration | ||||
.getRunningApplications()) { | .getRunningApplications()) { | ||||
VPaintableWidget paintable = Util.getPaintableForElement(a, | |||||
ComponentConnector paintable = Util.getPaintableForElement(a, | |||||
a.getView().getWidget(), eventTarget); | a.getView().getWidget(), eventTarget); | ||||
if (paintable == null) { | if (paintable == null) { | ||||
paintable = Util.getPaintableForElement(a, | paintable = Util.getPaintableForElement(a, | ||||
RootPanel.get(), eventTarget); | RootPanel.get(), eventTarget); | ||||
} | } | ||||
if (paintable != null) { | if (paintable != null) { | ||||
String pid = VPaintableMap.get(a).getPid(paintable); | |||||
String pid = ConnectorMap.get(a).getConnectorId(paintable); | |||||
VUIDLBrowser.highlight(paintable); | VUIDLBrowser.highlight(paintable); | ||||
label.setText("Currently focused :" | label.setText("Currently focused :" | ||||
+ paintable.getClass() + " ID:" + pid); | + paintable.getClass() + " ID:" + pid); | ||||
.getClientY()); | .getClientY()); | ||||
for (ApplicationConnection a : ApplicationConfiguration | for (ApplicationConnection a : ApplicationConfiguration | ||||
.getRunningApplications()) { | .getRunningApplications()) { | ||||
VPaintableWidget paintable = Util.getPaintableForElement(a, | |||||
ComponentConnector paintable = Util.getPaintableForElement(a, | |||||
a.getView().getWidget(), eventTarget); | a.getView().getWidget(), eventTarget); | ||||
if (paintable == null) { | if (paintable == null) { | ||||
paintable = Util.getPaintableForElement(a, | paintable = Util.getPaintableForElement(a, | ||||
}-*/; | }-*/; | ||||
public void printLayoutProblems(ValueMap meta, ApplicationConnection ac, | public void printLayoutProblems(ValueMap meta, ApplicationConnection ac, | ||||
Set<VPaintableWidget> zeroHeightComponents, | |||||
Set<VPaintableWidget> zeroWidthComponents) { | |||||
Set<ComponentConnector> zeroHeightComponents, | |||||
Set<ComponentConnector> zeroWidthComponents) { | |||||
JsArray<ValueMap> valueMapArray = meta | JsArray<ValueMap> valueMapArray = meta | ||||
.getJSValueMapArray("invalidLayouts"); | .getJSValueMapArray("invalidLayouts"); | ||||
int size = valueMapArray.length(); | int size = valueMapArray.length(); | ||||
} | } | ||||
private void printClientSideDetectedIssues( | private void printClientSideDetectedIssues( | ||||
Set<VPaintableWidget> zeroHeightComponents, ApplicationConnection ac) { | |||||
for (final VPaintableWidget paintable : zeroHeightComponents) { | |||||
Set<ComponentConnector> zeroHeightComponents, ApplicationConnection ac) { | |||||
for (final ComponentConnector paintable : zeroHeightComponents) { | |||||
final Widget layout = paintable.getParent().getWidget(); | final Widget layout = paintable.getParent().getWidget(); | ||||
VerticalPanel errorDetails = new VerticalPanel(); | VerticalPanel errorDetails = new VerticalPanel(); | ||||
private void printLayoutError(ValueMap valueMap, SimpleTree root, | private void printLayoutError(ValueMap valueMap, SimpleTree root, | ||||
final ApplicationConnection ac) { | final ApplicationConnection ac) { | ||||
final String pid = valueMap.getString("id"); | final String pid = valueMap.getString("id"); | ||||
final VPaintableWidget paintable = (VPaintableWidget) VPaintableMap | |||||
.get(ac).getPaintable(pid); | |||||
final ComponentConnector paintable = (ComponentConnector) ConnectorMap | |||||
.get(ac).getConnector(pid); | |||||
SimpleTree errorNode = new SimpleTree(); | SimpleTree errorNode = new SimpleTree(); | ||||
VerticalPanel errorDetails = new VerticalPanel(); | VerticalPanel errorDetails = new VerticalPanel(); |
/* | |||||
@VaadinApache2LicenseForJavaFiles@ | |||||
*/ | |||||
package com.vaadin.terminal.gwt.client; | |||||
import java.util.ArrayList; | |||||
import java.util.Collection; | |||||
import java.util.Collections; | |||||
import java.util.HashMap; | |||||
import java.util.HashSet; | |||||
import java.util.Iterator; | |||||
import java.util.Map; | |||||
import java.util.Set; | |||||
import com.google.gwt.core.client.GWT; | |||||
import com.google.gwt.dom.client.Element; | |||||
import com.google.gwt.user.client.ui.HasWidgets; | |||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.vaadin.terminal.Paintable; | |||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | |||||
public class VPaintableMap { | |||||
private Map<String, VPaintable> idToPaintable = new HashMap<String, VPaintable>(); | |||||
public static VPaintableMap get(ApplicationConnection applicationConnection) { | |||||
return applicationConnection.getPaintableMap(); | |||||
} | |||||
@Deprecated | |||||
private final ComponentDetailMap idToComponentDetail = ComponentDetailMap | |||||
.create(); | |||||
private Set<String> unregistryBag = new HashSet<String>(); | |||||
/** | |||||
* Returns a Paintable by its paintable id | |||||
* | |||||
* @param id | |||||
* The Paintable id | |||||
*/ | |||||
public VPaintable getPaintable(String pid) { | |||||
return idToPaintable.get(pid); | |||||
} | |||||
/** | |||||
* Returns a Paintable element by its root element | |||||
* | |||||
* @param element | |||||
* Root element of the paintable | |||||
*/ | |||||
public VPaintableWidget getPaintable(Element element) { | |||||
return (VPaintableWidget) getPaintable(getPid(element)); | |||||
} | |||||
/** | |||||
* FIXME: What does this even do and why? | |||||
* | |||||
* @param pid | |||||
* @return | |||||
*/ | |||||
public boolean isDragAndDropPaintable(String pid) { | |||||
return (pid.startsWith("DD")); | |||||
} | |||||
/** | |||||
* Checks if a paintable with the given paintable id has been registered. | |||||
* | |||||
* @param pid | |||||
* The paintable id to check for | |||||
* @return true if a paintable has been registered with the given paintable | |||||
* id, false otherwise | |||||
*/ | |||||
public boolean hasPaintable(String pid) { | |||||
return idToPaintable.containsKey(pid); | |||||
} | |||||
/** | |||||
* Removes all registered paintable ids | |||||
*/ | |||||
public void clear() { | |||||
idToPaintable.clear(); | |||||
idToComponentDetail.clear(); | |||||
} | |||||
@Deprecated | |||||
public Widget getWidget(VPaintableWidget paintable) { | |||||
return paintable.getWidget(); | |||||
} | |||||
@Deprecated | |||||
public VPaintableWidget getPaintable(Widget widget) { | |||||
return getPaintable(widget.getElement()); | |||||
} | |||||
public void registerPaintable(String pid, VPaintable paintable) { | |||||
ComponentDetail componentDetail = GWT.create(ComponentDetail.class); | |||||
idToComponentDetail.put(pid, componentDetail); | |||||
idToPaintable.put(pid, paintable); | |||||
if (paintable instanceof VPaintableWidget) { | |||||
VPaintableWidget pw = (VPaintableWidget) paintable; | |||||
setPid(pw.getWidget().getElement(), pid); | |||||
} | |||||
} | |||||
private native void setPid(Element el, String pid) | |||||
/*-{ | |||||
el.tkPid = pid; | |||||
}-*/; | |||||
/** | |||||
* Gets the paintableId for a specific paintable. | |||||
* <p> | |||||
* The paintableId is used in the UIDL to identify a specific widget | |||||
* instance, effectively linking the widget with it's server side Component. | |||||
* </p> | |||||
* | |||||
* @param paintable | |||||
* the paintable who's id is needed | |||||
* @return the id for the given paintable or null if the paintable could not | |||||
* be found | |||||
* @deprecated use {@link VPaintable#getId()} instead | |||||
*/ | |||||
@Deprecated | |||||
public String getPid(VPaintable paintable) { | |||||
if (paintable == null) { | |||||
return null; | |||||
} | |||||
return paintable.getId(); | |||||
} | |||||
@Deprecated | |||||
public String getPid(Widget widget) { | |||||
return getPid(widget.getElement()); | |||||
} | |||||
/** | |||||
* Gets the paintableId using a DOM element - the element should be the main | |||||
* element for a paintable otherwise no id will be found. Use | |||||
* {@link #getPid(Paintable)} instead whenever possible. | |||||
* | |||||
* @see #getPid(Paintable) | |||||
* @param el | |||||
* element of the paintable whose pid is desired | |||||
* @return the pid of the element's paintable, if it's a paintable | |||||
*/ | |||||
native String getPid(Element el) | |||||
/*-{ | |||||
return el.tkPid; | |||||
}-*/; | |||||
/** | |||||
* Gets the main element for the paintable with the given id. The revers of | |||||
* {@link #getPid(Element)}. | |||||
* | |||||
* @param pid | |||||
* the pid of the widget whose element is desired | |||||
* @return the element for the paintable corresponding to the pid | |||||
*/ | |||||
public Element getElement(String pid) { | |||||
VPaintable p = getPaintable(pid); | |||||
if (p instanceof VPaintableWidget) { | |||||
return ((VPaintableWidget) p).getWidget().getElement(); | |||||
} | |||||
return null; | |||||
} | |||||
/** | |||||
* Unregisters the given paintable; always use after removing a paintable. | |||||
* This method does not remove the paintable from the DOM, but marks the | |||||
* paintable so that ApplicationConnection may clean up its references to | |||||
* it. Removing the widget from DOM is component containers responsibility. | |||||
* | |||||
* @param p | |||||
* the paintable to remove | |||||
*/ | |||||
public void unregisterPaintable(VPaintable p) { | |||||
// add to unregistry que | |||||
if (p == null) { | |||||
VConsole.error("WARN: Trying to unregister null paintable"); | |||||
return; | |||||
} | |||||
String id = getPid(p); | |||||
Widget widget = null; | |||||
if (p instanceof VPaintableWidget) { | |||||
widget = ((VPaintableWidget) p).getWidget(); | |||||
} | |||||
if (id == null) { | |||||
/* | |||||
* Uncomment the following to debug unregistring components. No | |||||
* paintables with null id should end here. At least one exception | |||||
* is our VScrollTableRow, that is hacked to fake it self as a | |||||
* Paintable to build support for sizing easier. | |||||
*/ | |||||
// if (!(p instanceof VScrollTableRow)) { | |||||
// VConsole.log("Trying to unregister Paintable not created by Application Connection."); | |||||
// } | |||||
} else { | |||||
unregistryBag.add(id); | |||||
} | |||||
if (widget != null && widget instanceof HasWidgets) { | |||||
unregisterChildPaintables((HasWidgets) widget); | |||||
} | |||||
} | |||||
public VPaintableWidget[] getRegisteredPaintableWidgets() { | |||||
ArrayList<VPaintableWidget> result = new ArrayList<VPaintableWidget>(); | |||||
for (VPaintable paintable : getPaintables()) { | |||||
if (paintable instanceof VPaintableWidget) { | |||||
VPaintableWidget paintableWidget = (VPaintableWidget) paintable; | |||||
if (!unregistryBag.contains(getPid(paintable))) { | |||||
result.add(paintableWidget); | |||||
} | |||||
} | |||||
} | |||||
return result.toArray(new VPaintableWidget[result.size()]); | |||||
} | |||||
void purgeUnregistryBag(boolean unregisterPaintables) { | |||||
if (unregisterPaintables) { | |||||
for (String pid : unregistryBag) { | |||||
// TODO purge shared state for pid | |||||
VPaintable paintable = getPaintable(pid); | |||||
if (paintable == null) { | |||||
/* | |||||
* this should never happen, but it does :-( See e.g. | |||||
* com.vaadin.tests.components.accordion.RemoveTabs (with | |||||
* test script) | |||||
*/ | |||||
VConsole.error("Tried to unregister component (id=" | |||||
+ pid | |||||
+ ") that is never registered (or already unregistered)"); | |||||
continue; | |||||
} | |||||
Widget widget = null; | |||||
if (paintable instanceof VPaintableWidget) { | |||||
widget = ((VPaintableWidget) paintable) | |||||
.getWidget(); | |||||
} | |||||
// check if can be cleaned | |||||
if (widget == null || !widget.isAttached()) { | |||||
// clean reference to paintable | |||||
idToComponentDetail.remove(pid); | |||||
idToPaintable.remove(pid); | |||||
} | |||||
/* | |||||
* else NOP : same component has been reattached to another | |||||
* parent or replaced by another component implementation. | |||||
*/ | |||||
} | |||||
} | |||||
unregistryBag.clear(); | |||||
} | |||||
/** | |||||
* Unregisters a paintable and all it's child paintables recursively. Use | |||||
* when after removing a paintable that contains other paintables. Does not | |||||
* unregister the given container itself. Does not actually remove the | |||||
* paintable from the DOM. | |||||
* | |||||
* @see #unregisterPaintable(Paintable) | |||||
* @param container | |||||
*/ | |||||
public void unregisterChildPaintables(HasWidgets container) { | |||||
// FIXME: This should be based on the paintable hierarchy | |||||
final Iterator<Widget> it = container.iterator(); | |||||
while (it.hasNext()) { | |||||
final Widget w = it.next(); | |||||
VPaintableWidget p = getPaintable(w); | |||||
if (p != null) { | |||||
// This will unregister the paintable and all its children | |||||
unregisterPaintable(p); | |||||
} else if (w instanceof HasWidgets) { | |||||
// For normal widget containers, unregister the children | |||||
unregisterChildPaintables((HasWidgets) w); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param pid | |||||
* @param uidl | |||||
*/ | |||||
@Deprecated | |||||
public void registerEventListenersFromUIDL(String pid, UIDL uidl) { | |||||
ComponentDetail cd = idToComponentDetail.get(pid); | |||||
if (cd == null) { | |||||
throw new IllegalArgumentException("Pid must not be null"); | |||||
} | |||||
cd.registerEventListenersFromUIDL(uidl); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public Size getOffsetSize(VPaintableWidget paintable) { | |||||
return getComponentDetail(paintable).getOffsetSize(); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public void setOffsetSize(VPaintableWidget paintable, Size newSize) { | |||||
getComponentDetail(paintable).setOffsetSize(newSize); | |||||
} | |||||
private ComponentDetail getComponentDetail(VPaintableWidget paintable) { | |||||
return idToComponentDetail.get(getPid(paintable)); | |||||
} | |||||
public int size() { | |||||
return idToPaintable.size(); | |||||
} | |||||
/** | |||||
* FIXME: Should be moved to VAbstractPaintableWidget | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public TooltipInfo getTooltipInfo(VPaintableWidget paintable, Object key) { | |||||
return getComponentDetail(paintable).getTooltipInfo(key); | |||||
} | |||||
@Deprecated | |||||
public TooltipInfo getWidgetTooltipInfo(Widget widget, Object key) { | |||||
return getTooltipInfo(getPaintable(widget), key); | |||||
} | |||||
public Collection<? extends VPaintable> getPaintables() { | |||||
return Collections.unmodifiableCollection(idToPaintable.values()); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public void registerTooltip(VPaintableWidget paintable, Object key, | |||||
TooltipInfo tooltip) { | |||||
getComponentDetail(paintable).putAdditionalTooltip(key, tooltip); | |||||
} | |||||
/** | |||||
* FIXME: Should not be here | |||||
* | |||||
* @param paintable | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
public boolean hasEventListeners(VPaintableWidget paintable, | |||||
String eventIdentifier) { | |||||
return getComponentDetail(paintable).hasEventListeners(eventIdentifier); | |||||
} | |||||
/** | |||||
* Tests if the widget is the root widget of a VPaintableWidget. | |||||
* | |||||
* @param widget | |||||
* The widget to test | |||||
* @return true if the widget is the root widget of a VPaintableWidget, | |||||
* false otherwise | |||||
*/ | |||||
public boolean isPaintable(Widget w) { | |||||
return getPid(w) != null; | |||||
} | |||||
} |
private static final int QUICK_OPEN_DELAY = 100; | private static final int QUICK_OPEN_DELAY = 100; | ||||
VErrorMessage em = new VErrorMessage(); | VErrorMessage em = new VErrorMessage(); | ||||
Element description = DOM.createDiv(); | Element description = DOM.createDiv(); | ||||
private VPaintableWidget tooltipOwner; | |||||
private ComponentConnector tooltipOwner; | |||||
private boolean closing = false; | private boolean closing = false; | ||||
private boolean opening = false; | private boolean opening = false; | ||||
} | } | ||||
} | } | ||||
public void showTooltip(VPaintableWidget owner, Event event, Object key) { | |||||
public void showTooltip(ComponentConnector owner, Event event, Object key) { | |||||
if (closing && tooltipOwner == owner && tooltipKey == key) { | if (closing && tooltipOwner == owner && tooltipKey == key) { | ||||
// return to same tooltip, cancel closing | // return to same tooltip, cancel closing | ||||
closeTimer.cancel(); | closeTimer.cancel(); | ||||
} | } | ||||
public void handleTooltipEvent(Event event, VPaintableWidget owner, Object key) { | |||||
public void handleTooltipEvent(Event event, ComponentConnector owner, Object key) { | |||||
final int type = DOM.eventGetType(event); | final int type = DOM.eventGetType(event); | ||||
if ((VTooltip.TOOLTIP_EVENTS & type) == type) { | if ((VTooltip.TOOLTIP_EVENTS & type) == type) { | ||||
if (type == Event.ONMOUSEOVER) { | if (type == Event.ONMOUSEOVER) { |
private String getNodeName(UIDL uidl, ApplicationConfiguration conf, | private String getNodeName(UIDL uidl, ApplicationConfiguration conf, | ||||
String name) { | String name) { | ||||
Class<? extends VPaintableWidget> widgetClassByDecodedTag = conf | |||||
Class<? extends ComponentConnector> widgetClassByDecodedTag = conf | |||||
.getWidgetClassByEncodedTag(name); | .getWidgetClassByEncodedTag(name); | ||||
if (widgetClassByDecodedTag == VUnknownComponentPaintable.class) { | if (widgetClassByDecodedTag == VUnknownComponentPaintable.class) { | ||||
return conf.getUnknownServerClassNameByEncodedTagName(name) | return conf.getUnknownServerClassNameByEncodedTagName(name) | ||||
// same | // same | ||||
// host page | // host page | ||||
for (ApplicationConnection applicationConnection : runningApplications) { | for (ApplicationConnection applicationConnection : runningApplications) { | ||||
VPaintableWidget paintable = (VPaintableWidget) VPaintableMap | |||||
.get(applicationConnection).getPaintable(uidl.getId()); | |||||
ComponentConnector paintable = (ComponentConnector) ConnectorMap | |||||
.get(applicationConnection).getConnector(uidl.getId()); | |||||
highlight(paintable); | highlight(paintable); | ||||
if (event != null && event.getNativeEvent().getShiftKey()) { | if (event != null && event.getNativeEvent().getShiftKey()) { | ||||
applicationConnection.highlightComponent(paintable); | applicationConnection.highlightComponent(paintable); | ||||
} | } | ||||
} | } | ||||
static void highlight(VPaintableWidget paintable) { | |||||
static void highlight(ComponentConnector paintable) { | |||||
if (paintable != null) { | if (paintable != null) { | ||||
Widget w = paintable.getWidget(); | Widget w = paintable.getWidget(); | ||||
Style style = highlight.getStyle(); | Style style = highlight.getStyle(); |
* A helper class used by WidgetMap implementation. Used by the generated code. | * A helper class used by WidgetMap implementation. Used by the generated code. | ||||
*/ | */ | ||||
interface WidgetInstantiator { | interface WidgetInstantiator { | ||||
public VPaintableWidget get(); | |||||
public ComponentConnector get(); | |||||
} | } |
protected static HashMap<Class, WidgetInstantiator> instmap = new HashMap<Class, WidgetInstantiator>(); | protected static HashMap<Class, WidgetInstantiator> instmap = new HashMap<Class, WidgetInstantiator>(); | ||||
// FIXME: Should use Paintable and not VPaintableWidget | // FIXME: Should use Paintable and not VPaintableWidget | ||||
public VPaintableWidget instantiate( | |||||
Class<? extends VPaintableWidget> classType) { | |||||
public ComponentConnector instantiate( | |||||
Class<? extends ComponentConnector> classType) { | |||||
return instmap.get(classType).get(); | return instmap.get(classType).get(); | ||||
} | } | ||||
// FIXME: Should use Paintable and not VPaintableWidget | // FIXME: Should use Paintable and not VPaintableWidget | ||||
public abstract Class<? extends VPaintableWidget> getImplementationByServerSideClassName( | |||||
public abstract Class<? extends ComponentConnector> getImplementationByServerSideClassName( | |||||
String fullyqualifiedName); | String fullyqualifiedName); | ||||
// FIXME: Should use Paintable and not VPaintableWidget | // FIXME: Should use Paintable and not VPaintableWidget | ||||
public abstract Class<? extends VPaintableWidget>[] getDeferredLoadedWidgets(); | |||||
public abstract Class<? extends ComponentConnector>[] getDeferredLoadedWidgets(); | |||||
// FIXME: Should use Paintable and not VPaintableWidget | // FIXME: Should use Paintable and not VPaintableWidget | ||||
public abstract void ensureInstantiator( | public abstract void ensureInstantiator( | ||||
Class<? extends VPaintableWidget> classType); | |||||
Class<? extends ComponentConnector> classType); | |||||
} | } |
/** | /** | ||||
* Create an uninitialized component that best matches given UIDL. The | * Create an uninitialized component that best matches given UIDL. The | ||||
* component must be a {@link Widget} that implements | * component must be a {@link Widget} that implements | ||||
* {@link VPaintableWidget}. | |||||
* {@link ComponentConnector}. | |||||
* | * | ||||
* @param tag | * @param tag | ||||
* component type tag for the component to create | * component type tag for the component to create | ||||
* @return New uninitialized and unregistered component that can paint given | * @return New uninitialized and unregistered component that can paint given | ||||
* UIDL. | * UIDL. | ||||
*/ | */ | ||||
public VPaintableWidget createWidget(String tag, | |||||
public ComponentConnector createWidget(String tag, | |||||
ApplicationConfiguration conf) { | ApplicationConfiguration conf) { | ||||
/* | /* | ||||
* Yes, this (including the generated code in WidgetMap) may look very | * Yes, this (including the generated code in WidgetMap) may look very | ||||
* has no "native" counterpart on client side. | * has no "native" counterpart on client side. | ||||
*/ | */ | ||||
Class<? extends VPaintableWidget> classType = resolveWidgetType(tag, | |||||
Class<? extends ComponentConnector> classType = resolveWidgetType(tag, | |||||
conf); | conf); | ||||
if (classType == null || classType == VUnknownComponentPaintable.class) { | if (classType == null || classType == VUnknownComponentPaintable.class) { | ||||
} | } | ||||
protected Class<? extends VPaintableWidget> resolveWidgetType(String tag, | |||||
protected Class<? extends ComponentConnector> resolveWidgetType(String tag, | |||||
ApplicationConfiguration conf) { | ApplicationConfiguration conf) { | ||||
Class<? extends VPaintableWidget> widgetClass = conf | |||||
Class<? extends ComponentConnector> widgetClass = conf | |||||
.getWidgetClassByEncodedTag(tag); | .getWidgetClassByEncodedTag(tag); | ||||
return widgetClass; | return widgetClass; | ||||
* @param applicationConfiguration | * @param applicationConfiguration | ||||
* @return | * @return | ||||
*/ | */ | ||||
public Class<? extends VPaintableWidget> getImplementationByClassName( | |||||
public Class<? extends ComponentConnector> getImplementationByClassName( | |||||
String fullyqualifiedName) { | String fullyqualifiedName) { | ||||
if (fullyqualifiedName == null) { | if (fullyqualifiedName == null) { | ||||
return VUnknownComponentPaintable.class; | return VUnknownComponentPaintable.class; | ||||
} | } | ||||
Class<? extends VPaintableWidget> implementationByServerSideClassName = widgetMap | |||||
Class<? extends ComponentConnector> implementationByServerSideClassName = widgetMap | |||||
.getImplementationByServerSideClassName(fullyqualifiedName); | .getImplementationByServerSideClassName(fullyqualifiedName); | ||||
return implementationByServerSideClassName; | return implementationByServerSideClassName; | ||||
} | } | ||||
public Class<? extends VPaintableWidget>[] getDeferredLoadedWidgets() { | |||||
public Class<? extends ComponentConnector>[] getDeferredLoadedWidgets() { | |||||
return widgetMap.getDeferredLoadedWidgets(); | return widgetMap.getDeferredLoadedWidgets(); | ||||
} | } | ||||
public void loadImplementation(Class<? extends VPaintableWidget> nextType) { | |||||
public void loadImplementation(Class<? extends ComponentConnector> nextType) { | |||||
widgetMap.ensureInstantiator(nextType); | widgetMap.ensureInstantiator(nextType); | ||||
} | } | ||||
* @since 7.0 | * @since 7.0 | ||||
*/ | */ | ||||
public interface InitializableClientToServerRpc extends ClientToServerRpc { | public interface InitializableClientToServerRpc extends ClientToServerRpc { | ||||
public void initRpc(String paintableId, ApplicationConnection client); | |||||
public void initRpc(String connectorId, ApplicationConnection client); | |||||
} | } | ||||
} | } |
import com.google.gwt.json.client.JSONArray; | import com.google.gwt.json.client.JSONArray; | ||||
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.google.gwt.json.client.JSONString; | import com.google.gwt.json.client.JSONString; | ||||
import com.vaadin.terminal.gwt.client.VPaintable; | |||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.Connector; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
/** | /** | ||||
* Client side decoder for converting shared state and other values from JSON | * Client side decoder for converting shared state and other values from JSON | ||||
* @param jsonArray | * @param jsonArray | ||||
* JSON array with two elements | * JSON array with two elements | ||||
* @param idMapper | * @param idMapper | ||||
* mapper between paintable ID and {@link VPaintable} objects | |||||
* mapper between connector ID and {@link Connector} objects | |||||
* @return converted value (does not contain JSON types) | * @return converted value (does not contain JSON types) | ||||
*/ | */ | ||||
public static Object convertValue(JSONArray jsonArray, | public static Object convertValue(JSONArray jsonArray, | ||||
VPaintableMap idMapper) { | |||||
ConnectorMap idMapper) { | |||||
String type = ((JSONString) jsonArray.get(0)).stringValue(); | String type = ((JSONString) jsonArray.get(0)).stringValue(); | ||||
return convertValue(type, jsonArray.get(1), idMapper); | return convertValue(type, jsonArray.get(1), idMapper); | ||||
} | } | ||||
private static Object convertValue(String variableType, Object value, | private static Object convertValue(String variableType, Object value, | ||||
VPaintableMap idMapper) { | |||||
ConnectorMap idMapper) { | |||||
Object val = null; | Object val = null; | ||||
// TODO type checks etc. | // TODO type checks etc. | ||||
if (JsonEncoder.VTYPE_UNDEFINED.equals(variableType)) { | if (JsonEncoder.VTYPE_UNDEFINED.equals(variableType)) { | ||||
val = Boolean.valueOf(String.valueOf(value)); | val = Boolean.valueOf(String.valueOf(value)); | ||||
} else if (JsonEncoder.VTYPE_PAINTABLE.equals(variableType)) { | } else if (JsonEncoder.VTYPE_PAINTABLE.equals(variableType)) { | ||||
// TODO handle properly | // TODO handle properly | ||||
val = idMapper.getPaintable(String.valueOf(value)); | |||||
val = idMapper.getConnector(String.valueOf(value)); | |||||
} else { | } else { | ||||
// object, class name as type | // object, class name as type | ||||
VaadinSerializer serializer = serializerMap | VaadinSerializer serializer = serializerMap | ||||
} | } | ||||
private static Map<String, Object> convertMap(JSONObject jsonMap, | private static Map<String, Object> convertMap(JSONObject jsonMap, | ||||
VPaintableMap idMapper) { | |||||
ConnectorMap idMapper) { | |||||
HashMap<String, Object> map = new HashMap<String, Object>(); | HashMap<String, Object> map = new HashMap<String, Object>(); | ||||
Iterator<String> it = jsonMap.keySet().iterator(); | Iterator<String> it = jsonMap.keySet().iterator(); | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
} | } | ||||
private static Object[] convertArray(JSONArray jsonArray, | private static Object[] convertArray(JSONArray jsonArray, | ||||
VPaintableMap idMapper) { | |||||
ConnectorMap idMapper) { | |||||
List<Object> tokens = new ArrayList<Object>(); | List<Object> tokens = new ArrayList<Object>(); | ||||
for (int i = 0; i < jsonArray.size(); ++i) { | for (int i = 0; i < jsonArray.size(); ++i) { | ||||
// each entry always has two elements: type and value | // each entry always has two elements: type and value |
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.google.gwt.json.client.JSONString; | import com.google.gwt.json.client.JSONString; | ||||
import com.google.gwt.json.client.JSONValue; | import com.google.gwt.json.client.JSONValue; | ||||
import com.vaadin.terminal.gwt.client.VPaintable; | |||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.Connector; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
/** | /** | ||||
* Encoder for converting RPC parameters and other values to JSON for transfer | * Encoder for converting RPC parameters and other values to JSON for transfer | ||||
* | * | ||||
* @param value | * @param value | ||||
* value to convert | * value to convert | ||||
* @param paintableMap | |||||
* mapper from paintables to paintable IDs | |||||
* @param connectorMap | |||||
* mapper from connectors to connector IDs | |||||
* @return JSON representation of the value | * @return JSON representation of the value | ||||
*/ | */ | ||||
public static JSONValue encode(Object value, VPaintableMap paintableMap) { | |||||
public static JSONValue encode(Object value, ConnectorMap connectorMap) { | |||||
if (null == value) { | if (null == value) { | ||||
// TODO as undefined type? | // TODO as undefined type? | ||||
return combineTypeAndValue(VTYPE_UNDEFINED, JSONNull.getInstance()); | return combineTypeAndValue(VTYPE_UNDEFINED, JSONNull.getInstance()); | ||||
JSONArray jsonArray = new JSONArray(); | JSONArray jsonArray = new JSONArray(); | ||||
for (int i = 0; i < array.length; ++i) { | for (int i = 0; i < array.length; ++i) { | ||||
// TODO handle object graph loops? | // TODO handle object graph loops? | ||||
jsonArray.set(i, encode(array[i], paintableMap)); | |||||
jsonArray.set(i, encode(array[i], connectorMap)); | |||||
} | } | ||||
return combineTypeAndValue(VTYPE_ARRAY, jsonArray); | return combineTypeAndValue(VTYPE_ARRAY, jsonArray); | ||||
} else if (value instanceof Map) { | } else if (value instanceof Map) { | ||||
for (String mapKey : map.keySet()) { | for (String mapKey : map.keySet()) { | ||||
// TODO handle object graph loops? | // TODO handle object graph loops? | ||||
Object mapValue = map.get(mapKey); | Object mapValue = map.get(mapKey); | ||||
jsonMap.put(mapKey, encode(mapValue, paintableMap)); | |||||
jsonMap.put(mapKey, encode(mapValue, connectorMap)); | |||||
} | } | ||||
return combineTypeAndValue(VTYPE_MAP, jsonMap); | return combineTypeAndValue(VTYPE_MAP, jsonMap); | ||||
} else if (value instanceof VPaintable) { | |||||
VPaintable paintable = (VPaintable) value; | |||||
} else if (value instanceof Connector) { | |||||
Connector paintable = (Connector) value; | |||||
return combineTypeAndValue(VTYPE_PAINTABLE, new JSONString( | return combineTypeAndValue(VTYPE_PAINTABLE, new JSONString( | ||||
paintableMap.getPid(paintable))); | |||||
connectorMap.getConnectorId(paintable))); | |||||
} else { | } else { | ||||
return combineTypeAndValue(getTransportType(value), new JSONString( | return combineTypeAndValue(getTransportType(value), new JSONString( | ||||
String.valueOf(value))); | String.valueOf(value))); | ||||
private static String getTransportType(Object value) { | private static String getTransportType(Object value) { | ||||
if (value instanceof String) { | if (value instanceof String) { | ||||
return VTYPE_STRING; | return VTYPE_STRING; | ||||
} else if (value instanceof VPaintable) { | |||||
} else if (value instanceof Connector) { | |||||
return VTYPE_PAINTABLE; | return VTYPE_PAINTABLE; | ||||
} else if (value instanceof Boolean) { | } else if (value instanceof Boolean) { | ||||
return VTYPE_BOOLEAN; | return VTYPE_BOOLEAN; |
import java.io.Serializable; | import java.io.Serializable; | ||||
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||||
/** | /** | ||||
* Interface to be implemented by all shared state classes used to communicate | * Interface to be implemented by all shared state classes used to communicate | ||||
* supported data types. | * supported data types. | ||||
* | * | ||||
* On the client side, for most widgets, | * On the client side, for most widgets, | ||||
* {@link VAbstractPaintableWidget#createState()} and | |||||
* {@link VAbstractPaintableWidget#getState()} methods should be overridden to | |||||
* {@link AbstractComponentConnector#createState()} and | |||||
* {@link AbstractComponentConnector#getState()} methods should be overridden to | |||||
* create and use a shared state instance of the correct type. | * create and use a shared state instance of the correct type. | ||||
* | * | ||||
* Subclasses of a paintable using shared state should also provide a subclass | * Subclasses of a paintable using shared state should also provide a subclass |
package com.vaadin.terminal.gwt.client.communication; | package com.vaadin.terminal.gwt.client.communication; | ||||
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
/** | /** | ||||
* Serializer that can deserialize custom objects received from the server. | * Serializer that can deserialize custom objects received from the server. | ||||
* @return deserialized object | * @return deserialized object | ||||
*/ | */ | ||||
// TODO Object -> something | // TODO Object -> something | ||||
Object deserialize(JSONObject jsonValue, VPaintableMap idMapper); | |||||
Object deserialize(JSONObject jsonValue, ConnectorMap idMapper); | |||||
} | } |
import com.vaadin.terminal.gwt.client.TooltipInfo; | import com.vaadin.terminal.gwt.client.TooltipInfo; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ComponentContainerConnector; | |||||
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc; | import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc; | ||||
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc.InitializableClientToServerRpc; | import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc.InitializableClientToServerRpc; | ||||
import com.vaadin.terminal.gwt.client.communication.SharedState; | import com.vaadin.terminal.gwt.client.communication.SharedState; | ||||
public abstract class VAbstractPaintableWidget implements VPaintableWidget { | |||||
public abstract class AbstractComponentConnector implements ComponentConnector { | |||||
// Generic UIDL parameter names, to be moved to shared state. | // Generic UIDL parameter names, to be moved to shared state. | ||||
// Attributes are here mainly if they apply to all paintable widgets or | // Attributes are here mainly if they apply to all paintable widgets or | ||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
*/ | */ | ||||
public VAbstractPaintableWidget() { | |||||
public AbstractComponentConnector() { | |||||
} | } | ||||
/** | /** | ||||
return GWT.create(ComponentState.class); | return GWT.create(ComponentState.class); | ||||
} | } | ||||
public VPaintableWidgetContainer getParent() { | |||||
public ComponentContainerConnector getParent() { | |||||
// FIXME: Hierarchy should be set by framework instead of looked up here | // FIXME: Hierarchy should be set by framework instead of looked up here | ||||
VPaintableMap paintableMap = VPaintableMap.get(getConnection()); | |||||
ConnectorMap paintableMap = ConnectorMap.get(getConnection()); | |||||
Widget w = getWidget(); | Widget w = getWidget(); | ||||
while (true) { | while (true) { | ||||
if (w == null) { | if (w == null) { | ||||
return null; | return null; | ||||
} | } | ||||
if (paintableMap.isPaintable(w)) { | |||||
return (VPaintableWidgetContainer) paintableMap.getPaintable(w); | |||||
if (paintableMap.isConnector(w)) { | |||||
return (ComponentContainerConnector) paintableMap.getConnector(w); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
VPaintableMap paintableMap = VPaintableMap.get(getConnection()); | |||||
ConnectorMap paintableMap = ConnectorMap.get(getConnection()); | |||||
// register the listened events by the server-side to the event-handler | // register the listened events by the server-side to the event-handler | ||||
// of the component | // of the component | ||||
paintableMap.registerEventListenersFromUIDL(getId(), uidl); | paintableMap.registerEventListenersFromUIDL(getId(), uidl); | ||||
// Parent should be updated if either dimension changed between relative | // Parent should be updated if either dimension changed between relative | ||||
// and non-relative | // and non-relative | ||||
if (w.endsWith("%") != declaredWidth.endsWith("%")) { | if (w.endsWith("%") != declaredWidth.endsWith("%")) { | ||||
VPaintableWidgetContainer parent = getParent(); | |||||
ComponentContainerConnector parent = getParent(); | |||||
if (parent instanceof ManagedLayout) { | if (parent instanceof ManagedLayout) { | ||||
getLayoutManager().setWidthNeedsUpdate((ManagedLayout) parent); | getLayoutManager().setWidthNeedsUpdate((ManagedLayout) parent); | ||||
} | } | ||||
} | } | ||||
if (h.endsWith("%") != declaredHeight.endsWith("%")) { | if (h.endsWith("%") != declaredHeight.endsWith("%")) { | ||||
VPaintableWidgetContainer parent = getParent(); | |||||
ComponentContainerConnector parent = getParent(); | |||||
if (parent instanceof ManagedLayout) { | if (parent instanceof ManagedLayout) { | ||||
getLayoutManager().setHeightNeedsUpdate((ManagedLayout) parent); | getLayoutManager().setHeightNeedsUpdate((ManagedLayout) parent); | ||||
} | } |
import com.google.gwt.user.client.ui.HasOneWidget; | import com.google.gwt.user.client.ui.HasOneWidget; | ||||
import com.google.gwt.user.client.ui.HasWidgets; | import com.google.gwt.user.client.ui.HasWidgets; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ComponentContainerConnector; | |||||
public abstract class VAbstractPaintableWidgetContainer extends | |||||
VAbstractPaintableWidget implements VPaintableWidgetContainer { | |||||
public abstract class AbstractComponentContainerConnector extends | |||||
AbstractComponentConnector implements ComponentContainerConnector { | |||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
*/ | */ | ||||
public VAbstractPaintableWidgetContainer() { | |||||
public AbstractComponentContainerConnector() { | |||||
} | } | ||||
public Collection<VPaintableWidget> getChildren() { | |||||
Collection<VPaintableWidget> children = new ArrayList<VPaintableWidget>(); | |||||
public Collection<ComponentConnector> getChildren() { | |||||
Collection<ComponentConnector> children = new ArrayList<ComponentConnector>(); | |||||
addDescendantPaintables(getWidget(), children, | addDescendantPaintables(getWidget(), children, | ||||
VPaintableMap.get(getConnection())); | |||||
ConnectorMap.get(getConnection())); | |||||
return children; | return children; | ||||
} | } | ||||
private static void addDescendantPaintables(Widget widget, | private static void addDescendantPaintables(Widget widget, | ||||
Collection<VPaintableWidget> paintables, VPaintableMap paintableMap) { | |||||
Collection<ComponentConnector> paintables, ConnectorMap paintableMap) { | |||||
// FIXME: Store hierarchy instead of doing lookup every time | // FIXME: Store hierarchy instead of doing lookup every time | ||||
if (widget instanceof HasWidgets) { | if (widget instanceof HasWidgets) { | ||||
} | } | ||||
private static void addIfPaintable(Widget widget, | private static void addIfPaintable(Widget widget, | ||||
Collection<VPaintableWidget> paintables, VPaintableMap paintableMap) { | |||||
VPaintableWidget paintable = paintableMap.getPaintable(widget); | |||||
Collection<ComponentConnector> paintables, ConnectorMap paintableMap) { | |||||
ComponentConnector paintable = paintableMap.getConnector(widget); | |||||
if (paintable != null) { | if (paintable != null) { | ||||
// If widget is a paintable, add it to the collection | // If widget is a paintable, add it to the collection | ||||
paintables.add(paintable); | paintables.add(paintable); |
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public abstract class ClickEventHandler implements DoubleClickHandler, | public abstract class ClickEventHandler implements DoubleClickHandler, | ||||
ContextMenuHandler, MouseUpHandler { | ContextMenuHandler, MouseUpHandler { | ||||
private HandlerRegistration contextMenuHandlerRegistration; | private HandlerRegistration contextMenuHandlerRegistration; | ||||
protected String clickEventIdentifier; | protected String clickEventIdentifier; | ||||
protected VPaintableWidget paintable; | |||||
protected ComponentConnector paintable; | |||||
private ApplicationConnection client; | private ApplicationConnection client; | ||||
public ClickEventHandler(VPaintableWidget paintable, | |||||
public ClickEventHandler(ComponentConnector paintable, | |||||
String clickEventIdentifier) { | String clickEventIdentifier) { | ||||
this.paintable = paintable; | this.paintable = paintable; | ||||
this.clickEventIdentifier = clickEventIdentifier; | this.clickEventIdentifier = clickEventIdentifier; | ||||
protected void fireClick(NativeEvent event) { | protected void fireClick(NativeEvent event) { | ||||
ApplicationConnection client = getApplicationConnection(); | ApplicationConnection client = getApplicationConnection(); | ||||
String pid = VPaintableMap.get(getApplicationConnection()).getPid( | |||||
String pid = ConnectorMap.get(getApplicationConnection()).getConnectorId( | |||||
paintable); | paintable); | ||||
MouseEventDetails mouseDetails = new MouseEventDetails(event, | MouseEventDetails mouseDetails = new MouseEventDetails(event, |
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public abstract class LayoutClickEventHandler extends ClickEventHandler { | public abstract class LayoutClickEventHandler extends ClickEventHandler { | ||||
public LayoutClickEventHandler(VPaintableWidget paintable, | |||||
public LayoutClickEventHandler(ComponentConnector paintable, | |||||
String clickEventIdentifier) { | String clickEventIdentifier) { | ||||
super(paintable, clickEventIdentifier); | super(paintable, clickEventIdentifier); | ||||
} | } | ||||
protected abstract VPaintableWidget getChildComponent(Element element); | |||||
protected abstract ComponentConnector getChildComponent(Element element); | |||||
@Override | @Override | ||||
protected void fireClick(NativeEvent event) { | protected void fireClick(NativeEvent event) { | ||||
ApplicationConnection client = getApplicationConnection(); | ApplicationConnection client = getApplicationConnection(); | ||||
String pid = VPaintableMap.get(getApplicationConnection()).getPid( | |||||
String pid = ConnectorMap.get(getApplicationConnection()).getConnectorId( | |||||
paintable); | paintable); | ||||
MouseEventDetails mouseDetails = new MouseEventDetails(event, | MouseEventDetails mouseDetails = new MouseEventDetails(event, | ||||
getRelativeToElement()); | getRelativeToElement()); | ||||
VPaintableWidget childComponent = getChildComponent((Element) event | |||||
ComponentConnector childComponent = getChildComponent((Element) event | |||||
.getEventTarget().cast()); | .getEventTarget().cast()); | ||||
Map<String, Object> parameters = new HashMap<String, Object>(); | Map<String, Object> parameters = new HashMap<String, Object>(); |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui; | package com.vaadin.terminal.gwt.client.ui; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public interface ManagedLayout extends VPaintableWidget { | |||||
public interface ManagedLayout extends ComponentConnector { | |||||
} | } |
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | ||||
/** | /** | ||||
} | } | ||||
/** | /** | ||||
* A focusable {@link VPaintableWidget} implementing this interface will be | |||||
* A focusable {@link ComponentConnector} implementing this interface will be | |||||
* notified before shortcut actions are handled if it will be the target of | * notified before shortcut actions are handled if it will be the target of | ||||
* the action (most commonly means it is the focused component during the | * the action (most commonly means it is the focused component during the | ||||
* keyboard combination is triggered by the user). | * keyboard combination is triggered by the user). | ||||
*/ | */ | ||||
public interface BeforeShortcutActionListener extends VPaintableWidget { | |||||
public interface BeforeShortcutActionListener extends ComponentConnector { | |||||
/** | /** | ||||
* This method is called by ShortcutActionHandler before firing the | * This method is called by ShortcutActionHandler before firing the | ||||
* shortcut if the Paintable is currently focused (aka the target of the | * shortcut if the Paintable is currently focused (aka the target of the | ||||
} | } | ||||
} | } | ||||
public void handleKeyboardEvent(final Event event, VPaintableWidget target) { | |||||
public void handleKeyboardEvent(final Event event, ComponentConnector target) { | |||||
final int modifiers = KeyboardListenerCollection | final int modifiers = KeyboardListenerCollection | ||||
.getKeyboardModifiers(event); | .getKeyboardModifiers(event); | ||||
final char keyCode = (char) DOM.eventGetKeyCode(event); | final char keyCode = (char) DOM.eventGetKeyCode(event); | ||||
} | } | ||||
private void fireAction(final Event event, final ShortcutAction a, | private void fireAction(final Event event, final ShortcutAction a, | ||||
VPaintableWidget target) { | |||||
ComponentConnector target) { | |||||
final Element et = DOM.eventGetTarget(event); | final Element et = DOM.eventGetTarget(event); | ||||
if (target == null) { | if (target == null) { | ||||
target = Util.findPaintable(client, et); | target = Util.findPaintable(client, et); | ||||
} | } | ||||
final VPaintableWidget finalTarget = target; | |||||
final ComponentConnector finalTarget = target; | |||||
event.preventDefault(); | event.preventDefault(); | ||||
package com.vaadin.terminal.gwt.client.ui; | package com.vaadin.terminal.gwt.client.ui; | ||||
import com.google.gwt.user.client.ui.HasWidgets; | import com.google.gwt.user.client.ui.HasWidgets; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public interface Table extends VPaintableWidget, HasWidgets { | |||||
public interface Table extends ComponentConnector, HasWidgets { | |||||
final int SELECT_MODE_NONE = 0; | final int SELECT_MODE_NONE = 0; | ||||
final int SELECT_MODE_SINGLE = 1; | final int SELECT_MODE_SINGLE = 1; | ||||
final int SELECT_MODE_MULTI = 2; | final int SELECT_MODE_MULTI = 2; |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VAbsoluteLayout extends ComplexPanel { | public class VAbsoluteLayout extends ComplexPanel { | ||||
String bottom; | String bottom; | ||||
private String zIndex; | private String zIndex; | ||||
private VPaintableWidget paintable; | |||||
private ComponentConnector paintable; | |||||
private VCaption caption; | private VCaption caption; | ||||
public AbsoluteWrapper(VPaintableWidget paintable) { | |||||
public AbsoluteWrapper(ComponentConnector paintable) { | |||||
this.paintable = paintable; | this.paintable = paintable; | ||||
setStyleName(CLASSNAME + "-wrapper"); | setStyleName(CLASSNAME + "-wrapper"); | ||||
} | } | ||||
@Override | @Override | ||||
public void setWidget(Widget w) { | public void setWidget(Widget w) { | ||||
// this fixes #5457 (Widget implementation can change on-the-fly) | // this fixes #5457 (Widget implementation can change on-the-fly) | ||||
paintable = VPaintableMap.get(client).getPaintable(w); | |||||
paintable = ConnectorMap.get(client).getConnector(w); | |||||
super.setWidget(w); | super.setWidget(w); | ||||
} | } | ||||
* @return The Paintable which the element is a part of. Null if the element | * @return The Paintable which the element is a part of. Null if the element | ||||
* belongs to the layout and not to a child. | * belongs to the layout and not to a child. | ||||
*/ | */ | ||||
VPaintableWidget getComponent(Element element) { | |||||
ComponentConnector getComponent(Element element) { | |||||
return Util.getPaintableForElement(client, this, element); | return Util.getPaintableForElement(client, this, element); | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout; | import com.vaadin.terminal.gwt.client.DirectionalManagedLayout; | ||||
import com.vaadin.terminal.gwt.client.EventId; | import com.vaadin.terminal.gwt.client.EventId; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout.AbsoluteWrapper; | import com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout.AbsoluteWrapper; | ||||
public class VAbsoluteLayoutPaintable extends VAbstractPaintableWidgetContainer | |||||
public class VAbsoluteLayoutPaintable extends AbstractComponentContainerConnector | |||||
implements DirectionalManagedLayout { | implements DirectionalManagedLayout { | ||||
private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | ||||
this, EventId.LAYOUT_CLICK) { | this, EventId.LAYOUT_CLICK) { | ||||
@Override | @Override | ||||
protected VPaintableWidget getChildComponent(Element element) { | |||||
protected ComponentConnector getChildComponent(Element element) { | |||||
return getWidget().getComponent(element); | return getWidget().getComponent(element); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
AbsoluteWrapper parent2 = (AbsoluteWrapper) (component | AbsoluteWrapper parent2 = (AbsoluteWrapper) (component | ||||
.getWidget()).getParent(); | .getWidget()).getParent(); | ||||
parent2.updateCaption(uidl); | parent2.updateCaption(uidl); | ||||
public void layoutVertically() { | public void layoutVertically() { | ||||
VAbsoluteLayout layout = getWidget(); | VAbsoluteLayout layout = getWidget(); | ||||
for (VPaintableWidget paintable : getChildren()) { | |||||
for (ComponentConnector paintable : getChildren()) { | |||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
AbsoluteWrapper wrapper = (AbsoluteWrapper) widget.getParent(); | AbsoluteWrapper wrapper = (AbsoluteWrapper) widget.getParent(); | ||||
Style wrapperStyle = wrapper.getElement().getStyle(); | Style wrapperStyle = wrapper.getElement().getStyle(); | ||||
public void layoutHorizontally() { | public void layoutHorizontally() { | ||||
VAbsoluteLayout layout = getWidget(); | VAbsoluteLayout layout = getWidget(); | ||||
for (VPaintableWidget paintable : getChildren()) { | |||||
for (ComponentConnector paintable : getChildren()) { | |||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
AbsoluteWrapper wrapper = (AbsoluteWrapper) widget.getParent(); | AbsoluteWrapper wrapper = (AbsoluteWrapper) widget.getParent(); | ||||
Style wrapperStyle = wrapper.getElement().getStyle(); | Style wrapperStyle = wrapper.getElement().getStyle(); |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public abstract class VAbstractSplitPanelPaintable extends | public abstract class VAbstractSplitPanelPaintable extends | ||||
VAbstractPaintableWidgetContainer implements SimpleManagedLayout { | |||||
AbstractComponentContainerConnector implements SimpleManagedLayout { | |||||
public static final String SPLITTER_CLICK_EVENT_IDENTIFIER = "sp_click"; | public static final String SPLITTER_CLICK_EVENT_IDENTIFIER = "sp_click"; | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// TODO Implement caption handling | // TODO Implement caption handling | ||||
} | } | ||||
getWidget().position = uidl.getStringAttribute("position"); | getWidget().position = uidl.getStringAttribute("position"); | ||||
final VPaintableWidget newFirstChildPaintable = client | |||||
final ComponentConnector newFirstChildPaintable = client | |||||
.getPaintable(uidl.getChildUIDL(0)); | .getPaintable(uidl.getChildUIDL(0)); | ||||
final VPaintableWidget newSecondChildPaintable = client | |||||
final ComponentConnector newSecondChildPaintable = client | |||||
.getPaintable(uidl.getChildUIDL(1)); | .getPaintable(uidl.getChildUIDL(1)); | ||||
Widget newFirstChild = newFirstChildPaintable.getWidget(); | Widget newFirstChild = newFirstChildPaintable.getWidget(); | ||||
Widget newSecondChild = newSecondChildPaintable.getWidget(); | Widget newSecondChild = newSecondChildPaintable.getWidget(); | ||||
if (getWidget().firstChild != newFirstChild) { | if (getWidget().firstChild != newFirstChild) { | ||||
if (getWidget().firstChild != null) { | if (getWidget().firstChild != null) { | ||||
client.unregisterPaintable(VPaintableMap.get(client) | |||||
.getPaintable(getWidget().firstChild)); | |||||
client.unregisterPaintable(ConnectorMap.get(client) | |||||
.getConnector(getWidget().firstChild)); | |||||
} | } | ||||
getWidget().setFirstWidget(newFirstChild); | getWidget().setFirstWidget(newFirstChild); | ||||
} | } | ||||
if (getWidget().secondChild != newSecondChild) { | if (getWidget().secondChild != newSecondChild) { | ||||
if (getWidget().secondChild != null) { | if (getWidget().secondChild != null) { | ||||
client.unregisterPaintable(VPaintableMap.get(client) | |||||
.getPaintable(getWidget().secondChild)); | |||||
client.unregisterPaintable(ConnectorMap.get(client) | |||||
.getConnector(getWidget().secondChild)); | |||||
} | } | ||||
getWidget().setSecondWidget(newSecondChild); | getWidget().setSecondWidget(newSecondChild); | ||||
} | } |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VAccordion extends VTabsheetBase { | public class VAccordion extends VTabsheetBase { | ||||
private StackItem moveStackItemIfNeeded(StackItem item, int newIndex, | private StackItem moveStackItemIfNeeded(StackItem item, int newIndex, | ||||
UIDL tabUidl) { | UIDL tabUidl) { | ||||
UIDL tabContentUIDL = null; | UIDL tabContentUIDL = null; | ||||
VPaintableWidget tabContent = null; | |||||
ComponentConnector tabContent = null; | |||||
if (tabUidl.getChildCount() > 0) { | if (tabUidl.getChildCount() > 0) { | ||||
tabContentUIDL = tabUidl.getChildUIDL(0); | tabContentUIDL = tabUidl.getChildUIDL(0); | ||||
tabContent = client.getPaintable(tabContentUIDL); | tabContent = client.getPaintable(tabContentUIDL); | ||||
public void replaceWidget(Widget newWidget) { | public void replaceWidget(Widget newWidget) { | ||||
if (getWidgetCount() > 1) { | if (getWidgetCount() > 1) { | ||||
Widget oldWidget = getWidget(1); | Widget oldWidget = getWidget(1); | ||||
VPaintableWidget oldPaintable = VPaintableMap.get(client) | |||||
.getPaintable(oldWidget); | |||||
VPaintableMap.get(client).unregisterPaintable(oldPaintable); | |||||
ComponentConnector oldPaintable = ConnectorMap.get(client) | |||||
.getConnector(oldWidget); | |||||
ConnectorMap.get(client).unregisterConnector(oldPaintable); | |||||
widgets.remove(oldWidget); | widgets.remove(oldWidget); | ||||
remove(1); | remove(1); | ||||
} | } | ||||
} | } | ||||
public void setContent(UIDL contentUidl) { | public void setContent(UIDL contentUidl) { | ||||
final VPaintableWidget newPntbl = client.getPaintable(contentUidl); | |||||
final ComponentConnector newPntbl = client.getPaintable(contentUidl); | |||||
Widget newWidget = newPntbl.getWidget(); | Widget newWidget = newPntbl.getWidget(); | ||||
if (getChildWidget() == null) { | if (getChildWidget() == null) { | ||||
add(newWidget, content); | add(newWidget, content); | ||||
return DOM.getFirstChild(content).getOffsetWidth(); | return DOM.getFirstChild(content).getOffsetWidth(); | ||||
} | } | ||||
public boolean contains(VPaintableWidget p) { | |||||
public boolean contains(ComponentConnector p) { | |||||
return (getChildWidget() == p.getWidget()); | return (getChildWidget() == p.getWidget()); | ||||
} | } | ||||
} | } | ||||
boolean isDynamicWidth() { | boolean isDynamicWidth() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedWidth(); | return paintable.isUndefinedWidth(); | ||||
} | } | ||||
boolean isDynamicHeight() { | boolean isDynamicHeight() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedHeight(); | return paintable.isUndefinedHeight(); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
protected VPaintableWidget getTab(int index) { | |||||
protected ComponentConnector getTab(int index) { | |||||
if (index < getWidgetCount()) { | if (index < getWidgetCount()) { | ||||
Widget w = getStackItem(index); | Widget w = getStackItem(index); | ||||
return VPaintableMap.get(client).getPaintable(w); | |||||
return ConnectorMap.get(client).getConnector(w); | |||||
} | } | ||||
return null; | return null; |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.VAccordion.StackItem; | import com.vaadin.terminal.gwt.client.ui.VAccordion.StackItem; | ||||
public class VAccordionPaintable extends VTabsheetBasePaintable implements | public class VAccordionPaintable extends VTabsheetBasePaintable implements | ||||
return GWT.create(VAccordion.class); | return GWT.create(VAccordion.class); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
/* Accordion does not render its children's captions */ | /* Accordion does not render its children's captions */ | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc; | import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc; | ||||
public class VButtonPaintable extends VAbstractPaintableWidget { | |||||
public class VButtonPaintable extends AbstractComponentConnector { | |||||
/** | /** | ||||
* RPC interface for calls from client to server. | * RPC interface for calls from client to server. |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
public class VCheckBoxPaintable extends VAbstractPaintableWidget { | |||||
public class VCheckBoxPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
protected boolean delegateCaptionHandling() { | protected boolean delegateCaptionHandling() { |
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ValueMap; | import com.vaadin.terminal.gwt.client.ValueMap; | ||||
public class VCssLayout extends SimplePanel { | public class VCssLayout extends SimplePanel { | ||||
for (final Iterator<Object> i = uidl.getChildIterator(); i | for (final Iterator<Object> i = uidl.getChildIterator(); i | ||||
.hasNext();) { | .hasNext();) { | ||||
final UIDL r = (UIDL) i.next(); | final UIDL r = (UIDL) i.next(); | ||||
final VPaintableWidget child = client.getPaintable(r); | |||||
final ComponentConnector child = client.getPaintable(r); | |||||
final Widget widget = child.getWidget(); | final Widget widget = child.getWidget(); | ||||
if (widget.getParent() == this) { | if (widget.getParent() == this) { | ||||
oldWidgets.remove(widget); | oldWidgets.remove(widget); | ||||
// them | // them | ||||
for (Widget w : oldWidgets) { | for (Widget w : oldWidgets) { | ||||
remove(w); | remove(w); | ||||
VPaintableMap paintableMap = VPaintableMap.get(client); | |||||
if (paintableMap.isPaintable(w)) { | |||||
final VPaintableWidget p = VPaintableMap.get(client) | |||||
.getPaintable(w); | |||||
ConnectorMap paintableMap = ConnectorMap.get(client); | |||||
if (paintableMap.isConnector(w)) { | |||||
final ComponentConnector p = ConnectorMap.get(client) | |||||
.getConnector(w); | |||||
client.unregisterPaintable(p); | client.unregisterPaintable(p); | ||||
} | } | ||||
VCaption vCaption = widgetToCaption.remove(w); | VCaption vCaption = widgetToCaption.remove(w); | ||||
insert(child, index); | insert(child, index); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector paintable, UIDL uidl) { | |||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
VCaption caption = widgetToCaption.get(widget); | VCaption caption = widgetToCaption.get(widget); | ||||
if (VCaption.isNeeded(uidl, paintable.getState())) { | if (VCaption.isNeeded(uidl, paintable.getState())) { | ||||
} | } | ||||
} | } | ||||
VPaintableWidget getComponent(Element element) { | |||||
ComponentConnector getComponent(Element element) { | |||||
return Util | return Util | ||||
.getPaintableForElement(client, VCssLayout.this, element); | .getPaintableForElement(client, VCssLayout.this, element); | ||||
} | } |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.EventId; | import com.vaadin.terminal.gwt.client.EventId; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VCssLayoutPaintable extends VAbstractPaintableWidgetContainer { | |||||
public class VCssLayoutPaintable extends AbstractComponentContainerConnector { | |||||
private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | ||||
this, EventId.LAYOUT_CLICK) { | this, EventId.LAYOUT_CLICK) { | ||||
@Override | @Override | ||||
protected VPaintableWidget getChildComponent(Element element) { | |||||
protected ComponentConnector getChildComponent(Element element) { | |||||
return getWidget().panel.getComponent(element); | return getWidget().panel.getComponent(element); | ||||
} | } | ||||
return GWT.create(VCssLayout.class); | return GWT.create(VCssLayout.class); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
getWidget().panel.updateCaption(component, uidl); | getWidget().panel.updateCaption(component, uidl); | ||||
} | } | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VCustomComponentPaintable extends | public class VCustomComponentPaintable extends | ||||
VAbstractPaintableWidgetContainer { | |||||
AbstractComponentContainerConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, final ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, final ApplicationConnection client) { | ||||
} | } | ||||
final UIDL child = uidl.getChildUIDL(0); | final UIDL child = uidl.getChildUIDL(0); | ||||
if (child != null) { | if (child != null) { | ||||
final VPaintableWidget paintable = client.getPaintable(child); | |||||
final ComponentConnector paintable = client.getPaintable(child); | |||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
if (widget != getWidget().getWidget()) { | if (widget != getWidget().getWidget()) { | ||||
if (getWidget().getWidget() != null) { | if (getWidget().getWidget() != null) { | ||||
client.unregisterPaintable(VPaintableMap.get(client) | |||||
.getPaintable(getWidget().getWidget())); | |||||
client.unregisterPaintable(ConnectorMap.get(client) | |||||
.getConnector(getWidget().getWidget())); | |||||
getWidget().clear(); | getWidget().clear(); | ||||
} | } | ||||
getWidget().setWidget(widget); | getWidget().setWidget(widget); | ||||
return (VCustomComponent) super.getWidget(); | return (VCustomComponent) super.getWidget(); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP, custom component dont render composition roots caption | // NOP, custom component dont render composition roots caption | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VCaptionWrapper; | import com.vaadin.terminal.gwt.client.VCaptionWrapper; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
/** | /** | ||||
* Custom Layout implements complex layout defined with HTML template. | * Custom Layout implements complex layout defined with HTML template. | ||||
final HashMap<String, Widget> locationToWidget = new HashMap<String, Widget>(); | final HashMap<String, Widget> locationToWidget = new HashMap<String, Widget>(); | ||||
/** Widget to captionwrapper map */ | /** Widget to captionwrapper map */ | ||||
private final HashMap<VPaintableWidget, VCaptionWrapper> paintableToCaptionWrapper = new HashMap<VPaintableWidget, VCaptionWrapper>(); | |||||
private final HashMap<ComponentConnector, VCaptionWrapper> paintableToCaptionWrapper = new HashMap<ComponentConnector, VCaptionWrapper>(); | |||||
/** Name of the currently rendered style */ | /** Name of the currently rendered style */ | ||||
String currentTemplateName; | String currentTemplateName; | ||||
} | } | ||||
/** Update caption for given widget */ | /** Update caption for given widget */ | ||||
public void updateCaption(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector paintable, UIDL uidl) { | |||||
VCaptionWrapper wrapper = paintableToCaptionWrapper.get(paintable); | VCaptionWrapper wrapper = paintableToCaptionWrapper.get(paintable); | ||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
if (VCaption.isNeeded(uidl, paintable.getState())) { | if (VCaption.isNeeded(uidl, paintable.getState())) { | ||||
/** Removes given widget from the layout */ | /** Removes given widget from the layout */ | ||||
@Override | @Override | ||||
public boolean remove(Widget w) { | public boolean remove(Widget w) { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable(w); | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector(w); | |||||
client.unregisterPaintable(paintable); | client.unregisterPaintable(paintable); | ||||
final String location = getLocation(w); | final String location = getLocation(w); | ||||
if (location != null) { | if (location != null) { |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VCustomLayoutPaintable extends VAbstractPaintableWidgetContainer | |||||
public class VCustomLayoutPaintable extends AbstractComponentContainerConnector | |||||
implements SimpleManagedLayout { | implements SimpleManagedLayout { | ||||
/** Update the layout from UIDL */ | /** Update the layout from UIDL */ | ||||
if (uidlForChild.getTag().equals("location")) { | if (uidlForChild.getTag().equals("location")) { | ||||
final String location = uidlForChild.getStringAttribute("name"); | final String location = uidlForChild.getStringAttribute("name"); | ||||
UIDL childUIDL = uidlForChild.getChildUIDL(0); | UIDL childUIDL = uidlForChild.getChildUIDL(0); | ||||
final VPaintableWidget childPaintable = client | |||||
final ComponentConnector childPaintable = client | |||||
.getPaintable(childUIDL); | .getPaintable(childUIDL); | ||||
Widget childWidget = childPaintable.getWidget(); | Widget childWidget = childPaintable.getWidget(); | ||||
try { | try { | ||||
return GWT.create(VCustomLayout.class); | return GWT.create(VCustomLayout.class); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector paintable, UIDL uidl) { | |||||
getWidget().updateCaption(paintable, uidl); | getWidget().updateCaption(paintable, uidl); | ||||
} | } |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
public class VDateFieldPaintable extends VAbstractPaintableWidget { | |||||
public class VDateFieldPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | import com.vaadin.terminal.gwt.client.RenderInformation.Size; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintable; | |||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.Connector; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
import com.vaadin.terminal.gwt.client.ValueMap; | import com.vaadin.terminal.gwt.client.ValueMap; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | ||||
private boolean startDrag(NativeEvent event) { | private boolean startDrag(NativeEvent event) { | ||||
if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) { | if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) { | ||||
VTransferable transferable = new VTransferable(); | VTransferable transferable = new VTransferable(); | ||||
transferable.setDragSource(VPaintableMap.get(client).getPaintable( | |||||
transferable.setDragSource(ConnectorMap.get(client).getConnector( | |||||
VDragAndDropWrapper.this)); | VDragAndDropWrapper.this)); | ||||
VPaintableWidget paintable = Util.findPaintable(client, | |||||
ComponentConnector paintable = Util.findPaintable(client, | |||||
(Element) event.getEventTarget().cast()); | (Element) event.getEventTarget().cast()); | ||||
Widget widget = paintable.getWidget(); | Widget widget = paintable.getWidget(); | ||||
transferable.setData("component", paintable); | transferable.setData("component", paintable); | ||||
} | } | ||||
if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) { | if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) { | ||||
VTransferable transferable = new VTransferable(); | VTransferable transferable = new VTransferable(); | ||||
transferable.setDragSource(VPaintableMap.get(client) | |||||
.getPaintable(this)); | |||||
transferable.setDragSource(ConnectorMap.get(client) | |||||
.getConnector(this)); | |||||
vaadinDragEvent = VDragAndDropManager.get().startDrag( | vaadinDragEvent = VDragAndDropManager.get().startDrag( | ||||
transferable, event, false); | transferable, event, false); | ||||
} | } | ||||
private String getPid() { | private String getPid() { | ||||
return VPaintableMap.get(client).getPid((VPaintable) this); | |||||
return ConnectorMap.get(client).getConnectorId((Connector) this); | |||||
} | } | ||||
public VDropHandler getDropHandler() { | public VDropHandler getDropHandler() { | ||||
} | } | ||||
@Override | @Override | ||||
public VPaintableWidget getPaintable() { | |||||
return VPaintableMap.get(client).getPaintable( | |||||
public ComponentConnector getPaintable() { | |||||
return ConnectorMap.get(client).getConnector( | |||||
VDragAndDropWrapper.this); | VDragAndDropWrapper.this); | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VEmbedded extends HTML { | public class VEmbedded extends HTML { | ||||
public static String CLASSNAME = "v-embedded"; | public static String CLASSNAME = "v-embedded"; | ||||
html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); | html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); | ||||
} | } | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
String height = paintable.getDeclaredHeight(); | String height = paintable.getDeclaredHeight(); | ||||
String width = paintable.getDeclaredWidth(); | String width = paintable.getDeclaredWidth(); |
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
public class VEmbeddedPaintable extends VAbstractPaintableWidget { | |||||
public class VEmbeddedPaintable extends AbstractComponentConnector { | |||||
public static final String CLICK_EVENT_IDENTIFIER = "click"; | public static final String CLICK_EVENT_IDENTIFIER = "click"; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
/** | /** | ||||
* Should be called when the width changes or when the icon changes. | * Should be called when the width changes or when the icon changes. | ||||
*/ | */ | ||||
protected void updateRootWidth() { | protected void updateRootWidth() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
if (paintable.isUndefinedWidth()) { | if (paintable.isUndefinedWidth()) { | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.ui.VFilterSelect.FilterSelectSuggestion; | import com.vaadin.terminal.gwt.client.ui.VFilterSelect.FilterSelectSuggestion; | ||||
public class VFilterSelectPaintable extends VAbstractPaintableWidget implements | |||||
public class VFilterSelectPaintable extends AbstractComponentConnector implements | |||||
SimpleManagedLayout { | SimpleManagedLayout { | ||||
/* | /* |
import com.vaadin.terminal.gwt.client.Focusable; | import com.vaadin.terminal.gwt.client.Focusable; | ||||
import com.vaadin.terminal.gwt.client.StyleConstants; | import com.vaadin.terminal.gwt.client.StyleConstants; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
/** | /** | ||||
for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext(); i++) { | for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext(); i++) { | ||||
prepareCell(i, 1); | prepareCell(i, 1); | ||||
final UIDL childUidl = (UIDL) it.next(); | final UIDL childUidl = (UIDL) it.next(); | ||||
final VPaintableWidget childPaintable = client | |||||
final ComponentConnector childPaintable = client | |||||
.getPaintable(childUidl); | .getPaintable(childUidl); | ||||
Widget childWidget = childPaintable.getWidget(); | Widget childWidget = childPaintable.getWidget(); | ||||
Caption caption = widgetToCaption.get(childWidget); | Caption caption = widgetToCaption.get(childWidget); | ||||
if (oldWidget == null) { | if (oldWidget == null) { | ||||
setWidget(i, COLUMN_WIDGET, childWidget); | setWidget(i, COLUMN_WIDGET, childWidget); | ||||
} else if (oldWidget != childWidget) { | } else if (oldWidget != childWidget) { | ||||
final VPaintableWidget oldPaintable = VPaintableMap.get( | |||||
client).getPaintable(oldWidget); | |||||
final ComponentConnector oldPaintable = ConnectorMap.get( | |||||
client).getConnector(oldWidget); | |||||
client.unregisterPaintable(oldPaintable); | client.unregisterPaintable(oldPaintable); | ||||
setWidget(i, COLUMN_WIDGET, childWidget); | setWidget(i, COLUMN_WIDGET, childWidget); | ||||
} | } | ||||
while (getRowCount() > i) { | while (getRowCount() > i) { | ||||
Widget w = getWidget(i, COLUMN_WIDGET); | Widget w = getWidget(i, COLUMN_WIDGET); | ||||
final VPaintableWidget p = VPaintableMap.get(client) | |||||
.getPaintable(w); | |||||
final ComponentConnector p = ConnectorMap.get(client) | |||||
.getConnector(w); | |||||
client.unregisterPaintable(p); | client.unregisterPaintable(p); | ||||
widgetToCaption.remove(w); | widgetToCaption.remove(w); | ||||
removeRow(i); | removeRow(i); | ||||
} | } | ||||
} | } | ||||
public void updateCaption(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector paintable, UIDL uidl) { | |||||
final Caption c = widgetToCaption.get(paintable | final Caption c = widgetToCaption.get(paintable | ||||
.getWidget()); | .getWidget()); | ||||
if (c != null) { | if (c != null) { | ||||
public static final String CLASSNAME = "v-caption"; | public static final String CLASSNAME = "v-caption"; | ||||
private final VPaintableWidget owner; | |||||
private final ComponentConnector owner; | |||||
private Element requiredFieldIndicator; | private Element requiredFieldIndicator; | ||||
* return null | * return null | ||||
* @param client | * @param client | ||||
*/ | */ | ||||
public Caption(VPaintableWidget component, ApplicationConnection client) { | |||||
public Caption(ComponentConnector component, ApplicationConnection client) { | |||||
super(); | super(); | ||||
this.client = client; | this.client = client; | ||||
owner = component; | owner = component; | ||||
boolean isEmpty = true; | boolean isEmpty = true; | ||||
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)) { | |||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)) { | |||||
if (icon == null) { | if (icon == null) { | ||||
icon = new Icon(client); | icon = new Icon(client); | ||||
DOM.insertChild(getElement(), icon.getElement(), 0); | DOM.insertChild(getElement(), icon.getElement(), 0); | ||||
} | } | ||||
icon.setUri(uidl | icon.setUri(uidl | ||||
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)); | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
isEmpty = false; | isEmpty = false; | ||||
} else { | } else { | ||||
if (icon != null) { | if (icon != null) { | ||||
removeStyleDependentName("hasdescription"); | removeStyleDependentName("hasdescription"); | ||||
} | } | ||||
if (uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) { | |||||
if (uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED)) { | |||||
if (requiredFieldIndicator == null) { | if (requiredFieldIndicator == null) { | ||||
requiredFieldIndicator = DOM.createSpan(); | requiredFieldIndicator = DOM.createSpan(); | ||||
DOM.setInnerText(requiredFieldIndicator, "*"); | DOM.setInnerText(requiredFieldIndicator, "*"); | ||||
* | * | ||||
* @return owner Widget | * @return owner Widget | ||||
*/ | */ | ||||
public VPaintableWidget getOwner() { | |||||
public ComponentConnector getOwner() { | |||||
return owner; | return owner; | ||||
} | } | ||||
private static final String CLASSNAME = VFormLayout.CLASSNAME | private static final String CLASSNAME = VFormLayout.CLASSNAME | ||||
+ "-error-indicator"; | + "-error-indicator"; | ||||
Element errorIndicatorElement; | Element errorIndicatorElement; | ||||
private VPaintableWidget owner; | |||||
private ComponentConnector owner; | |||||
public ErrorFlag() { | public ErrorFlag() { | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
sinkEvents(VTooltip.TOOLTIP_EVENTS); | sinkEvents(VTooltip.TOOLTIP_EVENTS); | ||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, VPaintableWidget component) { | |||||
public void updateFromUIDL(UIDL uidl, ComponentConnector component) { | |||||
owner = component; | owner = component; | ||||
if (uidl.hasAttribute("error") | if (uidl.hasAttribute("error") | ||||
&& !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS)) { | |||||
&& !uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_HIDEERRORS)) { | |||||
if (errorIndicatorElement == null) { | if (errorIndicatorElement == null) { | ||||
errorIndicatorElement = DOM.createDiv(); | errorIndicatorElement = DOM.createDiv(); | ||||
DOM.setInnerHTML(errorIndicatorElement, " "); | DOM.setInnerHTML(errorIndicatorElement, " "); |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VFormLayoutPaintable extends VAbstractPaintableWidgetContainer { | |||||
public class VFormLayoutPaintable extends AbstractComponentContainerConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidget().client = client; | getWidget().client = client; | ||||
getWidget().table.updateFromUIDL(uidl, client); | getWidget().table.updateFromUIDL(uidl, client); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
getWidget().table.updateCaption(component, uidl); | getWidget().table.updateCaption(component, uidl); | ||||
} | } | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VFormPaintable extends VAbstractPaintableWidgetContainer implements | |||||
public class VFormPaintable extends AbstractComponentContainerConnector implements | |||||
SimpleManagedLayout { | SimpleManagedLayout { | ||||
@Override | @Override | ||||
if (uidl.getChildCount() > 1 | if (uidl.getChildCount() > 1 | ||||
&& !uidl.getChildUIDL(1).getTag().equals("actions")) { | && !uidl.getChildUIDL(1).getTag().equals("actions")) { | ||||
// render footer | // render footer | ||||
VPaintableWidget newFooter = client.getPaintable(uidl | |||||
ComponentConnector newFooter = client.getPaintable(uidl | |||||
.getChildUIDL(1)); | .getChildUIDL(1)); | ||||
Widget newFooterWidget = newFooter.getWidget(); | Widget newFooterWidget = newFooter.getWidget(); | ||||
if (getWidget().footer == null) { | if (getWidget().footer == null) { | ||||
getWidget().footer = newFooterWidget; | getWidget().footer = newFooterWidget; | ||||
} else if (newFooter != getWidget().footer) { | } else if (newFooter != getWidget().footer) { | ||||
getWidget().remove(getWidget().footer); | getWidget().remove(getWidget().footer); | ||||
client.unregisterPaintable(VPaintableMap.get(getConnection()) | |||||
.getPaintable(getWidget().footer)); | |||||
client.unregisterPaintable(ConnectorMap.get(getConnection()) | |||||
.getConnector(getWidget().footer)); | |||||
getWidget().add(newFooter.getWidget(), | getWidget().add(newFooter.getWidget(), | ||||
getWidget().footerContainer); | getWidget().footerContainer); | ||||
} | } | ||||
} else { | } else { | ||||
if (getWidget().footer != null) { | if (getWidget().footer != null) { | ||||
getWidget().remove(getWidget().footer); | getWidget().remove(getWidget().footer); | ||||
client.unregisterPaintable(VPaintableMap.get(getConnection()) | |||||
.getPaintable(getWidget().footer)); | |||||
client.unregisterPaintable(ConnectorMap.get(getConnection()) | |||||
.getConnector(getWidget().footer)); | |||||
} | } | ||||
} | } | ||||
final UIDL layoutUidl = uidl.getChildUIDL(0); | final UIDL layoutUidl = uidl.getChildUIDL(0); | ||||
VPaintableWidget newLayout = client.getPaintable(layoutUidl); | |||||
ComponentConnector newLayout = client.getPaintable(layoutUidl); | |||||
Widget newLayoutWidget = newLayout.getWidget(); | Widget newLayoutWidget = newLayout.getWidget(); | ||||
if (getWidget().lo == null) { | if (getWidget().lo == null) { | ||||
// Layout not rendered before | // Layout not rendered before | ||||
getWidget().fieldContainer); | getWidget().fieldContainer); | ||||
} else if (getWidget().lo != newLayoutWidget) { | } else if (getWidget().lo != newLayoutWidget) { | ||||
// Layout has changed | // Layout has changed | ||||
client.unregisterPaintable(VPaintableMap.get(getConnection()) | |||||
.getPaintable(getWidget().lo)); | |||||
client.unregisterPaintable(ConnectorMap.get(getConnection()) | |||||
.getConnector(getWidget().lo)); | |||||
getWidget().remove(getWidget().lo); | getWidget().remove(getWidget().lo); | ||||
getWidget().lo = newLayoutWidget; | getWidget().lo = newLayoutWidget; | ||||
getWidget().add(newLayoutWidget, | getWidget().add(newLayoutWidget, | ||||
} | } | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP form don't render caption for neither field layout nor footer | // NOP form don't render caption for neither field layout nor footer | ||||
// layout | // layout | ||||
} | } |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | ||||
import com.vaadin.terminal.gwt.client.ui.layout.VPaintableLayoutSlot; | import com.vaadin.terminal.gwt.client.ui.layout.VPaintableLayoutSlot; | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
} | } | ||||
private VPaintableWidget getPaintable() { | |||||
return VPaintableMap.get(client).getPaintable(this); | |||||
private ComponentConnector getPaintable() { | |||||
return ConnectorMap.get(client).getConnector(this); | |||||
} | } | ||||
/** | /** | ||||
// about childUidl | // about childUidl | ||||
hasContent = childUidl != null; | hasContent = childUidl != null; | ||||
if (hasContent) { | if (hasContent) { | ||||
VPaintableWidget paintable = client.getPaintable(childUidl); | |||||
ComponentConnector paintable = client.getPaintable(childUidl); | |||||
if (slot == null || slot.getPaintable() != paintable) { | if (slot == null || slot.getPaintable() != paintable) { | ||||
slot = new VPaintableLayoutSlot(CLASSNAME, paintable); | slot = new VPaintableLayoutSlot(CLASSNAME, paintable); | ||||
* @return The Paintable which the element is a part of. Null if the element | * @return The Paintable which the element is a part of. Null if the element | ||||
* belongs to the layout and not to a child. | * belongs to the layout and not to a child. | ||||
*/ | */ | ||||
VPaintableWidget getComponent(Element element) { | |||||
ComponentConnector getComponent(Element element) { | |||||
return Util.getPaintableForElement(client, this, element); | return Util.getPaintableForElement(client, this, element); | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.EventId; | import com.vaadin.terminal.gwt.client.EventId; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.VGridLayout.Cell; | import com.vaadin.terminal.gwt.client.ui.VGridLayout.Cell; | ||||
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | ||||
public class VGridLayoutPaintable extends VAbstractPaintableWidgetContainer | |||||
public class VGridLayoutPaintable extends AbstractComponentContainerConnector | |||||
implements DirectionalManagedLayout { | implements DirectionalManagedLayout { | ||||
private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( | ||||
this, EventId.LAYOUT_CLICK) { | this, EventId.LAYOUT_CLICK) { | ||||
@Override | @Override | ||||
protected VPaintableWidget getChildComponent(Element element) { | |||||
protected ComponentConnector getChildComponent(Element element) { | |||||
return getWidget().getComponent(element); | return getWidget().getComponent(element); | ||||
} | } | ||||
if (w.getParent() == layout) { | if (w.getParent() == layout) { | ||||
w.removeFromParent(); | w.removeFromParent(); | ||||
VPaintableMap paintableMap = VPaintableMap.get(client); | |||||
paintableMap.unregisterPaintable(paintableMap.getPaintable(w)); | |||||
ConnectorMap paintableMap = ConnectorMap.get(client); | |||||
paintableMap.unregisterConnector(paintableMap.getConnector(w)); | |||||
} | } | ||||
cell.slot.getWrapperElement().removeFromParent(); | cell.slot.getWrapperElement().removeFromParent(); | ||||
} | } | ||||
getLayoutManager().setNeedsUpdate(this); | getLayoutManager().setNeedsUpdate(this); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector paintable, UIDL uidl) { | |||||
VGridLayout layout = getWidget(); | VGridLayout layout = getWidget(); | ||||
if (VCaption.isNeeded(uidl, paintable.getState())) { | if (VCaption.isNeeded(uidl, paintable.getState())) { | ||||
Cell cell = layout.widgetToCell.get(paintable | Cell cell = layout.widgetToCell.get(paintable |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VLinkPaintable extends VAbstractPaintableWidget { | |||||
public class VLinkPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
protected boolean delegateCaptionHandling() { | protected boolean delegateCaptionHandling() { |
import com.vaadin.terminal.gwt.client.LayoutManager; | import com.vaadin.terminal.gwt.client.LayoutManager; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ValueMap; | import com.vaadin.terminal.gwt.client.ValueMap; | ||||
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; | ||||
import com.vaadin.terminal.gwt.client.ui.layout.VPaintableLayoutSlot; | import com.vaadin.terminal.gwt.client.ui.layout.VPaintableLayoutSlot; | ||||
public abstract class VMeasuringOrderedLayoutPaintable extends | public abstract class VMeasuringOrderedLayoutPaintable extends | ||||
VAbstractPaintableWidgetContainer implements DirectionalManagedLayout { | |||||
AbstractComponentContainerConnector implements DirectionalManagedLayout { | |||||
@Override | @Override | ||||
public void init() { | public void init() { | ||||
getWidget().spacingMeasureElement); | getWidget().spacingMeasureElement); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
VMeasuringOrderedLayout layout = getWidget(); | VMeasuringOrderedLayout layout = getWidget(); | ||||
if (VCaption.isNeeded(uidl, component.getState())) { | if (VCaption.isNeeded(uidl, component.getState())) { | ||||
VLayoutSlot layoutSlot = layout.getSlotForChild(component | VLayoutSlot layoutSlot = layout.getSlotForChild(component | ||||
return; | return; | ||||
} | } | ||||
HashSet<VPaintableWidget> previousChildren = new HashSet<VPaintableWidget>( | |||||
HashSet<ComponentConnector> previousChildren = new HashSet<ComponentConnector>( | |||||
getChildren()); | getChildren()); | ||||
VMeasuringOrderedLayout layout = getWidget(); | VMeasuringOrderedLayout layout = getWidget(); | ||||
// TODO Support reordering elements! | // TODO Support reordering elements! | ||||
for (final Iterator<Object> it = uidl.getChildIterator(); it.hasNext();) { | for (final Iterator<Object> it = uidl.getChildIterator(); it.hasNext();) { | ||||
final UIDL childUIDL = (UIDL) it.next(); | final UIDL childUIDL = (UIDL) it.next(); | ||||
final VPaintableWidget child = client.getPaintable(childUIDL); | |||||
final ComponentConnector child = client.getPaintable(childUIDL); | |||||
Widget widget = child.getWidget(); | Widget widget = child.getWidget(); | ||||
VLayoutSlot slot = layout.getSlotForChild(widget); | VLayoutSlot slot = layout.getSlotForChild(widget); | ||||
previousChildren.remove(child); | previousChildren.remove(child); | ||||
} | } | ||||
for (VPaintableWidget child : previousChildren) { | |||||
for (ComponentConnector child : previousChildren) { | |||||
Widget widget = child.getWidget(); | Widget widget = child.getWidget(); | ||||
// Don't remove and unregister if it has been moved to a different | // Don't remove and unregister if it has been moved to a different | ||||
if (widget.getParent() == getWidget()) { | if (widget.getParent() == getWidget()) { | ||||
layout.removeSlot(layout.getSlotForChild(widget)); | layout.removeSlot(layout.getSlotForChild(widget)); | ||||
VPaintableMap vPaintableMap = VPaintableMap.get(client); | |||||
vPaintableMap.unregisterPaintable(child); | |||||
ConnectorMap vPaintableMap = ConnectorMap.get(client); | |||||
vPaintableMap.unregisterConnector(child); | |||||
} | } | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
public abstract class VMediaBasePaintable extends VAbstractPaintableWidget { | |||||
public abstract class VMediaBasePaintable extends AbstractComponentConnector { | |||||
public static final String TAG_SOURCE = "src"; | public static final String TAG_SOURCE = "src"; | ||||
public static final String ATTRIBUTE_CHECKED = "checked"; | public static final String ATTRIBUTE_CHECKED = "checked"; | ||||
public static final String ATTRIBUTE_ITEM_DESCRIPTION = "description"; | public static final String ATTRIBUTE_ITEM_DESCRIPTION = "description"; | ||||
public static final String ATTRIBUTE_ITEM_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ITEM_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ITEM_DISABLED = "disabled"; | public static final String ATTRIBUTE_ITEM_DISABLED = "disabled"; | ||||
public static final String ATTRIBUTE_ITEM_STYLE = "style"; | public static final String ATTRIBUTE_ITEM_STYLE = "style"; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.ui.VMenuBar.CustomMenuItem; | import com.vaadin.terminal.gwt.client.ui.VMenuBar.CustomMenuItem; | ||||
public class VMenuBarPaintable extends VAbstractPaintableWidget implements | |||||
public class VMenuBarPaintable extends AbstractComponentConnector implements | |||||
SimpleManagedLayout { | SimpleManagedLayout { | ||||
/** | /** | ||||
* This method must be implemented to update the client-side component from | * This method must be implemented to update the client-side component from |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.ui.VButtonPaintable.ButtonClientToServerRpc; | import com.vaadin.terminal.gwt.client.ui.VButtonPaintable.ButtonClientToServerRpc; | ||||
public class VNativeButtonPaintable extends VAbstractPaintableWidget { | |||||
public class VNativeButtonPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void init() { | public void init() { |
public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; | public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; | public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; | public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_NOTIFICATION_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; | public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; | public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public abstract class VOptionGroupBasePaintable extends | public abstract class VOptionGroupBasePaintable extends | ||||
VAbstractPaintableWidget { | |||||
AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.Focusable; | import com.vaadin.terminal.gwt.client.Focusable; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | ||||
public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, | public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, | ||||
private Element errorIndicatorElement; | private Element errorIndicatorElement; | ||||
VPaintableWidget layout; | |||||
ComponentConnector layout; | |||||
ShortcutActionHandler shortcutHandler; | ShortcutActionHandler shortcutHandler; | ||||
void setIconUri(UIDL uidl, ApplicationConnection client) { | void setIconUri(UIDL uidl, ApplicationConnection client) { | ||||
final String iconUri = uidl | final String iconUri = uidl | ||||
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON) ? uidl | |||||
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON) | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON) ? uidl | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON) | |||||
: null; | : null; | ||||
if (iconUri == null) { | if (iconUri == null) { | ||||
if (icon != null) { | if (icon != null) { |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.LayoutManager; | import com.vaadin.terminal.gwt.client.LayoutManager; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VPanelPaintable extends VAbstractPaintableWidgetContainer | |||||
public class VPanelPaintable extends AbstractComponentContainerConnector | |||||
implements SimpleManagedLayout, PostLayoutListener { | implements SimpleManagedLayout, PostLayoutListener { | ||||
public static final String CLICK_EVENT_IDENTIFIER = "click"; | public static final String CLICK_EVENT_IDENTIFIER = "click"; | ||||
// Render content | // Render content | ||||
final UIDL layoutUidl = uidl.getChildUIDL(0); | final UIDL layoutUidl = uidl.getChildUIDL(0); | ||||
final VPaintableWidget newLayout = client.getPaintable(layoutUidl); | |||||
final ComponentConnector newLayout = client.getPaintable(layoutUidl); | |||||
if (newLayout != getWidget().layout) { | if (newLayout != getWidget().layout) { | ||||
if (getWidget().layout != null) { | if (getWidget().layout != null) { | ||||
client.unregisterPaintable(getWidget().layout); | client.unregisterPaintable(getWidget().layout); | ||||
} | } | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP: layouts caption, errors etc not rendered in Panel | // NOP: layouts caption, errors etc not rendered in Panel | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaptionWrapper; | import com.vaadin.terminal.gwt.client.VCaptionWrapper; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; | ||||
*/ | */ | ||||
protected class CustomPopup extends VOverlay { | protected class CustomPopup extends VOverlay { | ||||
private VPaintableWidget popupComponentPaintable = null; | |||||
private ComponentConnector popupComponentPaintable = null; | |||||
Widget popupComponentWidget = null; | Widget popupComponentWidget = null; | ||||
VCaptionWrapper captionWrapper = null; | VCaptionWrapper captionWrapper = null; | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
VPaintableWidget newPopupComponent = client.getPaintable(uidl | |||||
ComponentConnector newPopupComponent = client.getPaintable(uidl | |||||
.getChildUIDL(0)); | .getChildUIDL(0)); | ||||
if (newPopupComponent != popupComponentPaintable) { | if (newPopupComponent != popupComponentPaintable) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VCaptionWrapper; | import com.vaadin.terminal.gwt.client.VCaptionWrapper; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer { | |||||
public class VPopupViewPaintable extends AbstractComponentContainerConnector { | |||||
@Override | @Override | ||||
protected boolean delegateCaptionHandling() { | protected boolean delegateCaptionHandling() { | ||||
/** | /** | ||||
* | * | ||||
* | * | ||||
* @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL, | |||||
* @see com.vaadin.terminal.gwt.client.ComponentConnector#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL, | |||||
* com.vaadin.terminal.gwt.client.ApplicationConnection) | * com.vaadin.terminal.gwt.client.ApplicationConnection) | ||||
*/ | */ | ||||
@Override | @Override | ||||
} | } | ||||
}// updateFromUIDL | }// updateFromUIDL | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
if (VCaption.isNeeded(uidl, component.getState())) { | if (VCaption.isNeeded(uidl, component.getState())) { | ||||
if (getWidget().popup.captionWrapper != null) { | if (getWidget().popup.captionWrapper != null) { | ||||
getWidget().popup.captionWrapper | getWidget().popup.captionWrapper |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VProgressIndicatorPaintable extends VAbstractPaintableWidget { | |||||
public class VProgressIndicatorPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow; | import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | ||||
void purgeUnregistryBag() { | void purgeUnregistryBag() { | ||||
for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator | for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator | ||||
.hasNext();) { | .hasNext();) { | ||||
VPaintableMap.get(client) | |||||
.unregisterChildPaintables(iterator.next()); | |||||
ConnectorMap.get(client) | |||||
.unregisterChildConnectors(iterator.next()); | |||||
} | } | ||||
lazyUnregistryBag.clear(); | lazyUnregistryBag.clear(); | ||||
} | } | ||||
addCell(uidl, cell.toString(), aligns[col++], style, | addCell(uidl, cell.toString(), aligns[col++], style, | ||||
isRenderHtmlInCells(), sorted, description); | isRenderHtmlInCells(), sorted, description); | ||||
} else { | } else { | ||||
final VPaintableWidget cellContent = client | |||||
final ComponentConnector cellContent = client | |||||
.getPaintable((UIDL) cell); | .getPaintable((UIDL) cell); | ||||
addCell(uidl, cellContent.getWidget(), | addCell(uidl, cellContent.getWidget(), | ||||
return index; | return index; | ||||
} | } | ||||
protected void paintComponent(VPaintableWidget p, UIDL uidl) { | |||||
protected void paintComponent(ComponentConnector p, UIDL uidl) { | |||||
if (isAttached()) { | if (isAttached()) { | ||||
p.updateFromUIDL(uidl, client); | p.updateFromUIDL(uidl, client); | ||||
} else { | } else { | ||||
super.onAttach(); | super.onAttach(); | ||||
if (pendingComponentPaints != null) { | if (pendingComponentPaints != null) { | ||||
for (UIDL uidl : pendingComponentPaints) { | for (UIDL uidl : pendingComponentPaints) { | ||||
VPaintableWidget paintable = (VPaintableWidget) VPaintableMap | |||||
.get(client).getPaintable(uidl.getId()); | |||||
ComponentConnector paintable = (ComponentConnector) ConnectorMap | |||||
.get(client).getConnector(uidl.getId()); | |||||
paintable.updateFromUIDL(uidl, client); | paintable.updateFromUIDL(uidl, client); | ||||
} | } | ||||
pendingComponentPaints.clear(); | pendingComponentPaints.clear(); | ||||
if (!containsWidget) { | if (!containsWidget) { | ||||
// Only text nodes has tooltips | // Only text nodes has tooltips | ||||
if (VPaintableMap.get(client).getWidgetTooltipInfo( | |||||
if (ConnectorMap.get(client).getWidgetTooltipInfo( | |||||
VScrollTable.this, target) != null) { | VScrollTable.this, target) != null) { | ||||
// Cell has description, use it | // Cell has description, use it | ||||
client.handleTooltipEvent(event, | client.handleTooltipEvent(event, | ||||
Element targetTdOrTr) { | Element targetTdOrTr) { | ||||
mDown = true; | mDown = true; | ||||
VTransferable transferable = new VTransferable(); | VTransferable transferable = new VTransferable(); | ||||
transferable.setDragSource(VPaintableMap.get(client) | |||||
.getPaintable(VScrollTable.this)); | |||||
transferable.setDragSource(ConnectorMap.get(client) | |||||
.getConnector(VScrollTable.this)); | |||||
transferable.setData("itemId", "" + rowKey); | transferable.setData("itemId", "" + rowKey); | ||||
NodeList<TableCellElement> cells = rowElement.getCells(); | NodeList<TableCellElement> cells = rowElement.getCells(); | ||||
for (int i = 0; i < cells.getLength(); i++) { | for (int i = 0; i < cells.getLength(); i++) { | ||||
} | } | ||||
@Override | @Override | ||||
public VPaintableWidget getPaintable() { | |||||
return VPaintableMap.get(client).getPaintable(VScrollTable.this); | |||||
public ComponentConnector getPaintable() { | |||||
return ConnectorMap.get(client).getConnector(VScrollTable.this); | |||||
} | } | ||||
public ApplicationConnection getApplicationConnection() { | public ApplicationConnection getApplicationConnection() { | ||||
} | } | ||||
private boolean isDynamicWidth() { | private boolean isDynamicWidth() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedWidth(); | return paintable.isUndefinedWidth(); | ||||
} | } | ||||
private boolean isDynamicHeight() { | private boolean isDynamicHeight() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedHeight(); | return paintable.isUndefinedHeight(); | ||||
} | } |
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout; | import com.vaadin.terminal.gwt.client.DirectionalManagedLayout; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer | |||||
public class VScrollTablePaintable extends AbstractComponentContainerConnector | |||||
implements DirectionalManagedLayout { | implements DirectionalManagedLayout { | ||||
/* | /* | ||||
return (VScrollTable) super.getWidget(); | return (VScrollTable) super.getWidget(); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP, not rendered | // NOP, not rendered | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VSliderPaintable extends VAbstractPaintableWidget { | |||||
public class VSliderPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.label.VLabel; | import com.vaadin.terminal.gwt.client.ui.label.VLabel; | ||||
public class VTabsheet extends VTabsheetBase { | public class VTabsheet extends VTabsheetBase { | ||||
@Override | @Override | ||||
public boolean updateCaption(UIDL uidl) { | public boolean updateCaption(UIDL uidl) { | ||||
if (uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION) | if (uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION) | ||||
|| uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) { | |||||
|| uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR)) { | |||||
TooltipInfo tooltipInfo = new TooltipInfo(); | TooltipInfo tooltipInfo = new TooltipInfo(); | ||||
tooltipInfo | tooltipInfo | ||||
.setTitle(uidl | .setTitle(uidl | ||||
.getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION)); | .getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION)); | ||||
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) { | |||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR)) { | |||||
tooltipInfo.setErrorUidl(uidl.getErrors()); | tooltipInfo.setErrorUidl(uidl.getErrors()); | ||||
} | } | ||||
client.registerTooltip(getTabsheet(), getElement(), | client.registerTooltip(getTabsheet(), getElement(), | ||||
} | } | ||||
boolean isDynamicWidth() { | boolean isDynamicWidth() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedWidth(); | return paintable.isUndefinedWidth(); | ||||
} | } | ||||
boolean isDynamicHeight() { | boolean isDynamicHeight() { | ||||
VPaintableWidget paintable = VPaintableMap.get(client).getPaintable( | |||||
ComponentConnector paintable = ConnectorMap.get(client).getConnector( | |||||
this); | this); | ||||
return paintable.isUndefinedHeight(); | return paintable.isUndefinedHeight(); | ||||
} | } | ||||
tab.recalculateCaptionWidth(); | tab.recalculateCaptionWidth(); | ||||
UIDL tabContentUIDL = null; | UIDL tabContentUIDL = null; | ||||
VPaintableWidget tabContentPaintable = null; | |||||
ComponentConnector tabContentPaintable = null; | |||||
Widget tabContentWidget = null; | Widget tabContentWidget = null; | ||||
if (tabUidl.getChildCount() > 0) { | if (tabUidl.getChildCount() > 0) { | ||||
tabContentUIDL = tabUidl.getChildUIDL(0); | tabContentUIDL = tabUidl.getChildUIDL(0); | ||||
} | } | ||||
private void renderContent(final UIDL contentUIDL) { | private void renderContent(final UIDL contentUIDL) { | ||||
final VPaintableWidget content = client.getPaintable(contentUIDL); | |||||
final ComponentConnector content = client.getPaintable(contentUIDL); | |||||
if (tp.getWidgetCount() > activeTabIndex) { | if (tp.getWidgetCount() > activeTabIndex) { | ||||
Widget old = tp.getWidget(activeTabIndex); | Widget old = tp.getWidget(activeTabIndex); | ||||
if (old != content) { | if (old != content) { | ||||
tp.remove(activeTabIndex); | tp.remove(activeTabIndex); | ||||
VPaintableMap paintableMap = VPaintableMap.get(client); | |||||
if (paintableMap.isPaintable(old)) { | |||||
paintableMap.unregisterPaintable(paintableMap | |||||
.getPaintable(old)); | |||||
ConnectorMap paintableMap = ConnectorMap.get(client); | |||||
if (paintableMap.isConnector(old)) { | |||||
paintableMap.unregisterConnector(paintableMap | |||||
.getConnector(old)); | |||||
} | } | ||||
tp.insert(content.getWidget(), activeTabIndex); | tp.insert(content.getWidget(), activeTabIndex); | ||||
} | } | ||||
*/ | */ | ||||
private void updateTabScroller() { | private void updateTabScroller() { | ||||
if (!isDynamicWidth()) { | if (!isDynamicWidth()) { | ||||
VPaintableWidget paintable = VPaintableMap.get(client) | |||||
.getPaintable(this); | |||||
ComponentConnector paintable = ConnectorMap.get(client) | |||||
.getConnector(this); | |||||
DOM.setStyleAttribute(tabs, "width", paintable.getDeclaredWidth()); | DOM.setStyleAttribute(tabs, "width", paintable.getDeclaredWidth()); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
protected VPaintableWidget getTab(int index) { | |||||
protected ComponentConnector getTab(int index) { | |||||
if (tp.getWidgetCount() > index) { | if (tp.getWidgetCount() > index) { | ||||
Widget widget = tp.getWidget(index); | Widget widget = tp.getWidget(index); | ||||
return VPaintableMap.get(client).getPaintable(widget); | |||||
return ConnectorMap.get(client).getConnector(widget); | |||||
} | } | ||||
return null; | return null; | ||||
} | } |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
abstract class VTabsheetBase extends ComplexPanel { | abstract class VTabsheetBase extends ComplexPanel { | ||||
* Implement in extending classes. This method should return the Paintable | * Implement in extending classes. This method should return the Paintable | ||||
* corresponding to the given index. | * corresponding to the given index. | ||||
*/ | */ | ||||
protected abstract VPaintableWidget getTab(int index); | |||||
protected abstract ComponentConnector getTab(int index); | |||||
/** | /** | ||||
* Implement in extending classes. This method should remove the rendered | * Implement in extending classes. This method should remove the rendered |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public abstract class VTabsheetBasePaintable extends | public abstract class VTabsheetBasePaintable extends | ||||
VAbstractPaintableWidgetContainer { | |||||
AbstractComponentContainerConnector { | |||||
public static final String ATTRIBUTE_TAB_DISABLED = "disabled"; | public static final String ATTRIBUTE_TAB_DISABLED = "disabled"; | ||||
public static final String ATTRIBUTE_TAB_DESCRIPTION = "description"; | public static final String ATTRIBUTE_TAB_DESCRIPTION = "description"; | ||||
} | } | ||||
for (int i = 0; i < getWidget().getTabCount(); i++) { | for (int i = 0; i < getWidget().getTabCount(); i++) { | ||||
VPaintableWidget p = getWidget().getTab(i); | |||||
ComponentConnector p = getWidget().getTab(i); | |||||
// During the initial rendering the paintable might be null (this is | // During the initial rendering the paintable might be null (this is | ||||
// weird...) | // weird...) | ||||
if (p != null) { | if (p != null) { | ||||
for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator | for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator | ||||
.hasNext();) { | .hasNext();) { | ||||
Widget oldWidget = iterator.next(); | Widget oldWidget = iterator.next(); | ||||
VPaintableWidget oldPaintable = VPaintableMap.get(client) | |||||
.getPaintable(oldWidget); | |||||
ComponentConnector oldPaintable = ConnectorMap.get(client) | |||||
.getConnector(oldWidget); | |||||
if (oldWidget.isAttached()) { | if (oldWidget.isAttached()) { | ||||
oldWidget.removeFromParent(); | oldWidget.removeFromParent(); | ||||
} | } | ||||
VPaintableMap.get(client).unregisterPaintable(oldPaintable); | |||||
ConnectorMap.get(client).unregisterConnector(oldPaintable); | |||||
} | } | ||||
} | } |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VTabsheetPaintable extends VTabsheetBasePaintable implements | public class VTabsheetPaintable extends VTabsheetBasePaintable implements | ||||
SimpleManagedLayout { | SimpleManagedLayout { | ||||
return (VTabsheet) super.getWidget(); | return (VTabsheet) super.getWidget(); | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
/* Tabsheet does not render its children's captions */ | /* Tabsheet does not render its children's captions */ | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; | ||||
public class VTextFieldPaintable extends VAbstractPaintableWidget implements | |||||
public class VTextFieldPaintable extends AbstractComponentConnector implements | |||||
BeforeShortcutActionListener { | BeforeShortcutActionListener { | ||||
@Override | @Override |
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.VTooltip; | import com.vaadin.terminal.gwt.client.VTooltip; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | import com.vaadin.terminal.gwt.client.ui.dd.DDUtil; | ||||
import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler; | import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler; | ||||
} | } | ||||
@Override | @Override | ||||
public VPaintableWidget getPaintable() { | |||||
return VPaintableMap.get(client).getPaintable(VTree.this); | |||||
public ComponentConnector getPaintable() { | |||||
return ConnectorMap.get(client).getConnector(VTree.this); | |||||
} | } | ||||
public ApplicationConnection getApplicationConnection() { | public ApplicationConnection getApplicationConnection() { | ||||
if (mouseDownEvent != null) { | if (mouseDownEvent != null) { | ||||
// start actual drag on slight move when mouse is down | // start actual drag on slight move when mouse is down | ||||
VTransferable t = new VTransferable(); | VTransferable t = new VTransferable(); | ||||
t.setDragSource(VPaintableMap.get(client).getPaintable( | |||||
t.setDragSource(ConnectorMap.get(client).getConnector( | |||||
VTree.this)); | VTree.this)); | ||||
t.setData("itemId", key); | t.setData("itemId", key); | ||||
VDragEvent drag = VDragAndDropManager.get().startDrag( | VDragEvent drag = VDragAndDropManager.get().startDrag( |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.ui.VTree.TreeNode; | import com.vaadin.terminal.gwt.client.ui.VTree.TreeNode; | ||||
public class VTreePaintable extends VAbstractPaintableWidget { | |||||
public class VTreePaintable extends AbstractComponentConnector { | |||||
public static final String ATTRIBUTE_NODE_STYLE = "style"; | public static final String ATTRIBUTE_NODE_STYLE = "style"; | ||||
public static final String ATTRIBUTE_NODE_CAPTION = "caption"; | public static final String ATTRIBUTE_NODE_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_NODE_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_NODE_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ACTION_CAPTION = "caption"; | public static final String ATTRIBUTE_ACTION_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_ACTION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ACTION_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VUIDLBrowser; | import com.vaadin.terminal.gwt.client.VUIDLBrowser; | ||||
public class VUnknownComponentPaintable extends VAbstractPaintableWidget { | |||||
public class VUnknownComponentPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
protected boolean delegateCaptionHandling() { | protected boolean delegateCaptionHandling() { |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VUploadPaintable extends VAbstractPaintableWidget { | |||||
public class VUploadPaintable extends AbstractComponentConnector { | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | ||||
/** | /** | ||||
String theme; | String theme; | ||||
VPaintableWidget layout; | |||||
ComponentConnector layout; | |||||
final LinkedHashSet<VWindow> subWindows = new LinkedHashSet<VWindow>(); | final LinkedHashSet<VWindow> subWindows = new LinkedHashSet<VWindow>(); | ||||
if (uidl.hasAttribute("scrollTo")) { | if (uidl.hasAttribute("scrollTo")) { | ||||
Scheduler.get().scheduleDeferred(new Command() { | Scheduler.get().scheduleDeferred(new Command() { | ||||
public void execute() { | public void execute() { | ||||
final VPaintableWidget paintable = (VPaintableWidget) uidl | |||||
final ComponentConnector paintable = (ComponentConnector) uidl | |||||
.getPaintableAttribute("scrollTo", connection); | .getPaintableAttribute("scrollTo", connection); | ||||
paintable.getWidget().getElement() | paintable.getWidget().getElement() | ||||
.scrollIntoView(); | .scrollIntoView(); |
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VConsole; | import com.vaadin.terminal.gwt.client.VConsole; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
public class VViewPaintable extends VAbstractPaintableWidgetContainer { | |||||
public class VViewPaintable extends AbstractComponentContainerConnector { | |||||
private static final String CLICK_EVENT_IDENTIFIER = VPanelPaintable.CLICK_EVENT_IDENTIFIER; | private static final String CLICK_EVENT_IDENTIFIER = VPanelPaintable.CLICK_EVENT_IDENTIFIER; | ||||
// Draw this application level window | // Draw this application level window | ||||
UIDL childUidl = uidl.getChildUIDL(childIndex); | UIDL childUidl = uidl.getChildUIDL(childIndex); | ||||
final VPaintableWidget lo = client.getPaintable(childUidl); | |||||
final ComponentConnector lo = client.getPaintable(childUidl); | |||||
if (getWidget().layout != null) { | if (getWidget().layout != null) { | ||||
if (getWidget().layout != lo) { | if (getWidget().layout != lo) { | ||||
for (final Iterator<VWindow> rem = removedSubWindows.iterator(); rem | for (final Iterator<VWindow> rem = removedSubWindows.iterator(); rem | ||||
.hasNext();) { | .hasNext();) { | ||||
final VWindow w = rem.next(); | final VWindow w = rem.next(); | ||||
client.unregisterPaintable(VPaintableMap.get(getConnection()) | |||||
.getPaintable(w)); | |||||
client.unregisterPaintable(ConnectorMap.get(getConnection()) | |||||
.getConnector(w)); | |||||
getWidget().subWindows.remove(w); | getWidget().subWindows.remove(w); | ||||
w.hide(); | w.hide(); | ||||
} | } | ||||
// set focused component when render phase is finished | // set focused component when render phase is finished | ||||
Scheduler.get().scheduleDeferred(new Command() { | Scheduler.get().scheduleDeferred(new Command() { | ||||
public void execute() { | public void execute() { | ||||
VPaintableWidget paintable = (VPaintableWidget) uidl | |||||
ComponentConnector paintable = (ComponentConnector) uidl | |||||
.getPaintableAttribute("focused", getConnection()); | .getPaintableAttribute("focused", getConnection()); | ||||
final Widget toBeFocused = paintable | final Widget toBeFocused = paintable | ||||
} | } | ||||
}; | }; | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP The main view never draws caption for its layout | // NOP The main view never draws caption for its layout | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.EventId; | import com.vaadin.terminal.gwt.client.EventId; | ||||
import com.vaadin.terminal.gwt.client.Focusable; | import com.vaadin.terminal.gwt.client.Focusable; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | ||||
/** | /** | ||||
public static final int Z_INDEX = 10000; | public static final int Z_INDEX = 10000; | ||||
VPaintableWidget layout; | |||||
ComponentConnector layout; | |||||
Element contents; | Element contents; | ||||
while (w != null) { | while (w != null) { | ||||
if (w instanceof Console) { | if (w instanceof Console) { | ||||
return true; // allow debug-window clicks | return true; // allow debug-window clicks | ||||
} else if (w instanceof VPaintableWidget) { | |||||
} else if (w instanceof ComponentConnector) { | |||||
return false; | return false; | ||||
} | } | ||||
w = w.getParent(); | w = w.getParent(); |
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; | ||||
public class VWindowPaintable extends VAbstractPaintableWidgetContainer | |||||
public class VWindowPaintable extends AbstractComponentContainerConnector | |||||
implements BeforeShortcutActionListener, SimpleManagedLayout, | implements BeforeShortcutActionListener, SimpleManagedLayout, | ||||
PostLayoutListener { | PostLayoutListener { | ||||
getWidget() | getWidget() | ||||
.setCaption( | .setCaption( | ||||
getState().getCaption(), | getState().getCaption(), | ||||
uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)); | |||||
uidl.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
} | } | ||||
getWidget().visibilityChangesDisabled = true; | getWidget().visibilityChangesDisabled = true; | ||||
childUidl = uidl.getChildUIDL(childIndex++); | childUidl = uidl.getChildUIDL(childIndex++); | ||||
} | } | ||||
final VPaintableWidget lo = client.getPaintable(childUidl); | |||||
final ComponentConnector lo = client.getPaintable(childUidl); | |||||
if (getWidget().layout != null) { | if (getWidget().layout != null) { | ||||
if (getWidget().layout != lo) { | if (getWidget().layout != lo) { | ||||
// remove old | // remove old | ||||
} | } | ||||
} | } | ||||
public void updateCaption(VPaintableWidget component, UIDL uidl) { | |||||
public void updateCaption(ComponentConnector component, UIDL uidl) { | |||||
// NOP, window has own caption, layout captio not rendered | // NOP, window has own caption, layout captio not rendered | ||||
} | } | ||||
import com.vaadin.event.Transferable; | import com.vaadin.event.Transferable; | ||||
import com.vaadin.event.dd.DropTarget; | import com.vaadin.event.dd.DropTarget; | ||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; | import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public abstract class VAbstractDropHandler implements VDropHandler { | public abstract class VAbstractDropHandler implements VDropHandler { | ||||
* side counterpart of the Paintable is expected to implement | * side counterpart of the Paintable is expected to implement | ||||
* {@link DropTarget} interface. | * {@link DropTarget} interface. | ||||
*/ | */ | ||||
public abstract VPaintableWidget getPaintable(); | |||||
public abstract ComponentConnector getPaintable(); | |||||
} | } |
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ValueMap; | import com.vaadin.terminal.gwt.client.ValueMap; | ||||
/** | /** | ||||
} | } | ||||
private void addActiveDragSourceStyleName() { | private void addActiveDragSourceStyleName() { | ||||
VPaintableWidget dragSource = currentDrag.getTransferable() | |||||
ComponentConnector dragSource = currentDrag.getTransferable() | |||||
.getDragSource(); | .getDragSource(); | ||||
dragSource.getWidget().addStyleName( | dragSource.getWidget().addStyleName( | ||||
ACTIVE_DRAG_SOURCE_STYLENAME); | ACTIVE_DRAG_SOURCE_STYLENAME); | ||||
* handled. E.g. hidden on start, removed in drophandler -> | * handled. E.g. hidden on start, removed in drophandler -> | ||||
* would flicker in case removed eagerly. | * would flicker in case removed eagerly. | ||||
*/ | */ | ||||
final VPaintableWidget dragSource = currentDrag | |||||
final ComponentConnector dragSource = currentDrag | |||||
.getTransferable().getDragSource(); | .getTransferable().getDragSource(); | ||||
final ApplicationConnection client = currentDropHandler | final ApplicationConnection client = currentDropHandler | ||||
.getApplicationConnection(); | .getApplicationConnection(); | ||||
} | } | ||||
private void removeActiveDragSourceStyleName(VPaintableWidget dragSource) { | |||||
private void removeActiveDragSourceStyleName(ComponentConnector dragSource) { | |||||
dragSource.getWidget().removeStyleName( | dragSource.getWidget().removeStyleName( | ||||
ACTIVE_DRAG_SOURCE_STYLENAME); | ACTIVE_DRAG_SOURCE_STYLENAME); | ||||
} | } | ||||
if (currentDropHandler == null) { | if (currentDropHandler == null) { | ||||
return; | return; | ||||
} | } | ||||
VPaintableWidget paintable = currentDropHandler.getPaintable(); | |||||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||||
ApplicationConnection client = currentDropHandler | ApplicationConnection client = currentDropHandler | ||||
.getApplicationConnection(); | .getApplicationConnection(); | ||||
/* | /* |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
/** | /** | ||||
* TODO Javadoc! | * TODO Javadoc! | ||||
@Override | @Override | ||||
protected boolean accept(VDragEvent drag, UIDL configuration) { | protected boolean accept(VDragEvent drag, UIDL configuration) { | ||||
try { | try { | ||||
VPaintableWidget component = drag.getTransferable().getDragSource(); | |||||
ComponentConnector component = drag.getTransferable().getDragSource(); | |||||
int c = configuration.getIntAttribute("c"); | int c = configuration.getIntAttribute("c"); | ||||
for (int i = 0; i < c; i++) { | for (int i = 0; i < c; i++) { | ||||
String requiredPid = configuration | String requiredPid = configuration | ||||
.getStringAttribute("component" + i); | .getStringAttribute("component" + i); | ||||
VDropHandler currentDropHandler = VDragAndDropManager.get() | VDropHandler currentDropHandler = VDragAndDropManager.get() | ||||
.getCurrentDropHandler(); | .getCurrentDropHandler(); | ||||
VPaintableWidget paintable = (VPaintableWidget) VPaintableMap | |||||
ComponentConnector paintable = (ComponentConnector) ConnectorMap | |||||
.get(currentDropHandler.getApplicationConnection()) | .get(currentDropHandler.getApplicationConnection()) | ||||
.getPaintable(requiredPid); | |||||
.getConnector(requiredPid); | |||||
if (paintable == component) { | if (paintable == component) { | ||||
return true; | return true; | ||||
} | } |
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
/** | /** | ||||
* Vaadin Widgets that want to receive something via drag and drop implement | * Vaadin Widgets that want to receive something via drag and drop implement | ||||
/** | /** | ||||
* Returns the Paintable into which this DragHandler is associated | * Returns the Paintable into which this DragHandler is associated | ||||
*/ | */ | ||||
public VPaintableWidget getPaintable(); | |||||
public ComponentConnector getPaintable(); | |||||
/** | /** | ||||
* Returns the application connection to which this {@link VDropHandler} | * Returns the application connection to which this {@link VDropHandler} |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
/** | /** | ||||
* Used to detect Widget from widget tree that has {@link #getDropHandler()} | * Used to detect Widget from widget tree that has {@link #getDropHandler()} | ||||
* | * | ||||
* Decide whether to get rid of this class. If so, {@link VAbstractDropHandler} | * Decide whether to get rid of this class. If so, {@link VAbstractDropHandler} | ||||
* must extend {@link VPaintableWidget}. | |||||
* must extend {@link ComponentConnector}. | |||||
* | * | ||||
*/ | */ | ||||
public interface VHasDropHandler { | public interface VHasDropHandler { |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
final public class VIsOverId extends VAcceptCriterion { | final public class VIsOverId extends VAcceptCriterion { | ||||
String pid = configuration.getStringAttribute("s"); | String pid = configuration.getStringAttribute("s"); | ||||
VDropHandler currentDropHandler = VDragAndDropManager.get() | VDropHandler currentDropHandler = VDragAndDropManager.get() | ||||
.getCurrentDropHandler(); | .getCurrentDropHandler(); | ||||
VPaintableWidget paintable = currentDropHandler.getPaintable(); | |||||
VPaintableMap paintableMap = VPaintableMap.get(currentDropHandler | |||||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||||
ConnectorMap paintableMap = ConnectorMap.get(currentDropHandler | |||||
.getApplicationConnection()); | .getApplicationConnection()); | ||||
String pid2 = paintableMap.getPid(paintable); | |||||
String pid2 = paintableMap.getConnectorId(paintable); | |||||
if (pid2.equals(pid)) { | if (pid2.equals(pid)) { | ||||
Object searchedId = drag.getDropDetails().get("itemIdOver"); | Object searchedId = drag.getDropDetails().get("itemIdOver"); | ||||
String[] stringArrayAttribute = configuration | String[] stringArrayAttribute = configuration |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
final public class VItemIdIs extends VAcceptCriterion { | final public class VItemIdIs extends VAcceptCriterion { | ||||
protected boolean accept(VDragEvent drag, UIDL configuration) { | protected boolean accept(VDragEvent drag, UIDL configuration) { | ||||
try { | try { | ||||
String pid = configuration.getStringAttribute("s"); | String pid = configuration.getStringAttribute("s"); | ||||
VPaintableWidget dragSource = drag.getTransferable() | |||||
ComponentConnector dragSource = drag.getTransferable() | |||||
.getDragSource(); | .getDragSource(); | ||||
VDropHandler currentDropHandler = VDragAndDropManager.get() | VDropHandler currentDropHandler = VDragAndDropManager.get() | ||||
.getCurrentDropHandler(); | .getCurrentDropHandler(); | ||||
String pid2 = VPaintableMap.get( | |||||
currentDropHandler.getApplicationConnection()).getPid( | |||||
String pid2 = ConnectorMap.get( | |||||
currentDropHandler.getApplicationConnection()).getConnectorId( | |||||
dragSource); | dragSource); | ||||
if (pid2.equals(pid)) { | if (pid2.equals(pid)) { | ||||
Object searchedId = drag.getTransferable().getData("itemId"); | Object searchedId = drag.getTransferable().getData("itemId"); |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui.dd; | package com.vaadin.terminal.gwt.client.ui.dd; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
final public class VSourceIsTarget extends VAcceptCriterion { | final public class VSourceIsTarget extends VAcceptCriterion { | ||||
@Override | @Override | ||||
protected boolean accept(VDragEvent drag, UIDL configuration) { | protected boolean accept(VDragEvent drag, UIDL configuration) { | ||||
VPaintableWidget dragSource = drag.getTransferable().getDragSource(); | |||||
VPaintableWidget paintable = VDragAndDropManager.get().getCurrentDropHandler() | |||||
ComponentConnector dragSource = drag.getTransferable().getDragSource(); | |||||
ComponentConnector paintable = VDragAndDropManager.get().getCurrentDropHandler() | |||||
.getPaintable(); | .getPaintable(); | ||||
return paintable == dragSource; | return paintable == dragSource; |
import java.util.Map; | import java.util.Map; | ||||
import com.vaadin.event.dd.DragSource; | import com.vaadin.event.dd.DragSource; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
/** | /** | ||||
* Client side counterpart for Transferable in com.vaadin.event.Transferable | * Client side counterpart for Transferable in com.vaadin.event.Transferable | ||||
*/ | */ | ||||
public class VTransferable { | public class VTransferable { | ||||
private VPaintableWidget component; | |||||
private ComponentConnector component; | |||||
private final Map<String, Object> variables = new HashMap<String, Object>(); | private final Map<String, Object> variables = new HashMap<String, Object>(); | ||||
* | * | ||||
* @return the component | * @return the component | ||||
*/ | */ | ||||
public VPaintableWidget getDragSource() { | |||||
public ComponentConnector getDragSource() { | |||||
return component; | return component; | ||||
} | } | ||||
* @param component | * @param component | ||||
* the component to set | * the component to set | ||||
*/ | */ | ||||
public void setDragSource(VPaintableWidget component) { | |||||
public void setDragSource(ComponentConnector component) { | |||||
this.component = component; | this.component = component; | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||||
public class VLabelPaintable extends VAbstractPaintableWidget { | |||||
public class VLabelPaintable extends AbstractComponentConnector { | |||||
public VLabelPaintable() { | public VLabelPaintable() { | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.LayoutManager; | import com.vaadin.terminal.gwt.client.LayoutManager; | ||||
import com.vaadin.terminal.gwt.client.VCaption; | import com.vaadin.terminal.gwt.client.VCaption; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | |||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.ManagedLayout; | import com.vaadin.terminal.gwt.client.ui.ManagedLayout; | ||||
public class VPaintableLayoutSlot extends VLayoutSlot { | public class VPaintableLayoutSlot extends VLayoutSlot { | ||||
final VPaintableWidget paintable; | |||||
final ComponentConnector paintable; | |||||
private LayoutManager layoutManager; | private LayoutManager layoutManager; | ||||
public VPaintableLayoutSlot(String baseClassName, VPaintableWidget paintable) { | |||||
public VPaintableLayoutSlot(String baseClassName, ComponentConnector paintable) { | |||||
super(baseClassName, paintable.getWidget()); | super(baseClassName, paintable.getWidget()); | ||||
this.paintable = paintable; | this.paintable = paintable; | ||||
layoutManager = paintable.getLayoutManager(); | layoutManager = paintable.getLayoutManager(); | ||||
} | } | ||||
public VPaintableWidget getPaintable() { | |||||
public ComponentConnector getPaintable() { | |||||
return paintable; | return paintable; | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.ui.Field; | import com.vaadin.terminal.gwt.client.ui.Field; | ||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; | ||||
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | ||||
shortcutHandler | shortcutHandler | ||||
.handleKeyboardEvent(com.google.gwt.user.client.Event | .handleKeyboardEvent(com.google.gwt.user.client.Event | ||||
.as(event.getNativeEvent()), | .as(event.getNativeEvent()), | ||||
VPaintableMap.get(client).getPaintable(this)); | |||||
ConnectorMap.get(client).getConnector(this)); | |||||
} | } | ||||
} | } | ||||