Browse Source

Split Paintable handling from ApplicationConnection to PaintableMap.

tags/7.0.0.alpha2
Artur Signell 12 years ago
parent
commit
622545764d

+ 104
- 278
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java View File



private final ArrayList<String> pendingVariables = new ArrayList<String>(); private final ArrayList<String> pendingVariables = new ArrayList<String>();


private final ComponentDetailMap idToPaintableDetail = ComponentDetailMap
.create();

private WidgetSet widgetSet; private WidgetSet widgetSet;


private VContextMenu contextMenu = null; private VContextMenu contextMenu = null;


private Set<Paintable> zeroHeightComponents = null; private Set<Paintable> zeroHeightComponents = null;


private Set<String> unregistryBag = new HashSet<String>();

public ApplicationConnection() { public ApplicationConnection() {
view = GWT.create(VView.class); view = GWT.create(VView.class);
} }
*/ */
void highlightComponent(Paintable paintable) { void highlightComponent(Paintable paintable) {
String params = getRepaintAllParameters() + "&highlightComponent=" String params = getRepaintAllParameters() + "&highlightComponent="
+ getPid(paintable);
+ paintableMap.getPid(paintable);
makeUidlRequest("", params, false); makeUidlRequest("", params, false);
} }


for (int i = 1; i < variableBurst.size(); i += 2) { for (int i = 1; i < variableBurst.size(); i += 2) {
String id = variableBurst.get(i); String id = variableBurst.get(i);
id = id.substring(0, id.indexOf(VAR_FIELD_SEPARATOR)); id = id.substring(0, id.indexOf(VAR_FIELD_SEPARATOR));
if (!idToPaintableDetail.containsKey(id) && !id.startsWith("DD")) {
if (!getPaintableMap().hasPaintable(id)
&& !getPaintableMap().isDragAndDropPaintable(id)) {
// variable owner does not exist anymore // variable owner does not exist anymore
variableBurst.remove(i - 1); variableBurst.remove(i - 1);
variableBurst.remove(i - 1); variableBurst.remove(i - 1);
if (meta.containsKey("repaintAll")) { if (meta.containsKey("repaintAll")) {
repaintAll = true; repaintAll = true;
view.clear(); view.clear();
idToPaintableDetail.clear();
getPaintableMap().clear();
if (meta.containsKey("invalidLayouts")) { if (meta.containsKey("invalidLayouts")) {
validatingLayouts = true; validatingLayouts = true;
zeroWidthComponents = new HashSet<Paintable>(); zeroWidthComponents = new HashSet<Paintable>();
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 Paintable paintable = getPaintable(uidl.getId());
final Paintable paintable = paintableMap
.getPaintable(uidl.getId());
if (paintable != null) { if (paintable != null) {
paintable.updateFromUIDL(uidl, paintable.updateFromUIDL(uidl,
ApplicationConnection.this); ApplicationConnection.this);
// paintable may have changed during render to
// another
// implementation, use the new one for updated
// widgets map
updatedWidgets.add(idToPaintableDetail.get(
uidl.getId()).getComponent());

updatedWidgets.add(paintable);
} else { } else {
if (!uidl.getTag().equals( if (!uidl.getTag().equals(
configuration.getEncodedWindowTag())) { configuration.getEncodedWindowTag())) {
+ uidl.getId() + ") rendered."); + uidl.getId() + ") rendered.");
} else { } else {
String pid = uidl.getId(); String pid = uidl.getId();
if (!idToPaintableDetail.containsKey(pid)) {
registerPaintable(pid, view);
if (!paintableMap.hasPaintable(pid)) {
paintableMap.registerPaintable(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
ComponentDetail cd = idToPaintableDetail
.get(pid);
cd.registerEventListenersFromUIDL(uidl);
paintableMap.registerEventListenersFromUIDL(
pid, uidl);


// Finally allow VView to update itself // Finally allow VView to update itself
view.updateFromUIDL(uidl, view.updateFromUIDL(uidl,
sizeUpdatedWidgets.addAll(componentCaptionSizeChanges); sizeUpdatedWidgets.addAll(componentCaptionSizeChanges);


for (Paintable paintable : updatedWidgets) { for (Paintable paintable : updatedWidgets) {
ComponentDetail detail = idToPaintableDetail
.get(getPid(paintable));
Widget widget = (Widget) paintable;
Size oldSize = detail.getOffsetSize();
Widget widget = paintableMap.getWidget(paintable);
Size oldSize = paintableMap.getOffsetSize(paintable);
Size newSize = new Size(widget.getOffsetWidth(), Size newSize = new Size(widget.getOffsetWidth(),
widget.getOffsetHeight()); widget.getOffsetHeight());


if (oldSize == null || !oldSize.equals(newSize)) { if (oldSize == null || !oldSize.equals(newSize)) {
sizeUpdatedWidgets.add(paintable); sizeUpdatedWidgets.add(paintable);
detail.setOffsetSize(newSize);
paintableMap.setOffsetSize(paintable, newSize);
} }


} }
* 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.
*/ */
unregistryBag.clear();
paintableMap.purgeUnregistryBag(false);
} else { } else {
purgeUnregistryBag();
paintableMap.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: "
+ idToPaintableDetail.size());
VConsole.log("Referenced paintables: " + paintableMap.size());


endRequest(); endRequest();


} }
}-*/; }-*/;


public void registerPaintable(String pid, Paintable paintable) {
ComponentDetail componentDetail = new ComponentDetail(this, pid,
paintable);
idToPaintableDetail.put(pid, componentDetail);
setPid(((Widget) paintable).getElement(), pid);
}

private native void setPid(Element el, String pid)
/*-{
el.tkPid = pid;
}-*/;

/**
* Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).
* <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
*/
public String getPid(Paintable paintable) {
return getPid(((Widget) paintable).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
*/
public 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 getElementByPid(String pid) {
return ((Widget) getPaintable(pid)).getElement();
}

/**
* 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(Paintable p) {

// add to unregistry que

if (p == null) {
VConsole.error("WARN: Trying to unregister null paintable");
return;
}
String id = getPid(p);
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.");
// }
if (p instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) p);
}
} else {
unregistryBag.add(id);
if (p instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) p);
}
}
}

private void purgeUnregistryBag() {
for (String id : unregistryBag) {
ComponentDetail componentDetail = idToPaintableDetail.get(id);
if (componentDetail == null) {
/*
* this should never happen, but it does :-( See e.g.
* com.vaadin.tests.components.accordion.RemoveTabs (with test
* script)
*/
VConsole.error("ApplicationConnetion tried to unregister component (id="
+ id
+ ") that is never registered (or already unregistered)");
continue;
}
// check if can be cleaned
Widget component = (Widget) componentDetail.getComponent();
if (!component.isAttached()) {
// clean reference from ac to paintable
idToPaintableDetail.remove(id);
}
/*
* 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) {
final Iterator<Widget> it = container.iterator();
while (it.hasNext()) {
final Widget w = it.next();
if (w instanceof Paintable) {
unregisterPaintable((Paintable) w);
} else if (w instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) w);
}
}
}

/**
* Returns Paintable element by its id
*
* @param id
* Paintable ID
*/
public Paintable getPaintable(String id) {
ComponentDetail componentDetail = idToPaintableDetail.get(id);
if (componentDetail == null) {
return null;
} else {
return componentDetail.getComponent();
}
}

private void addVariableToQueue(String paintableId, String variableName, private void addVariableToQueue(String paintableId, String variableName,
String encodedValue, boolean immediate, char type) { String encodedValue, boolean immediate, char type) {
final String id = paintableId + VAR_FIELD_SEPARATOR + variableName final String id = paintableId + VAR_FIELD_SEPARATOR + variableName
*/ */
public void updateVariable(String paintableId, String variableName, public void updateVariable(String paintableId, String variableName,
Paintable newValue, boolean immediate) { Paintable newValue, boolean immediate) {
String pid = (newValue != null) ? getPid(newValue) : null;
String pid = paintableMap.getPid(newValue);
addVariableToQueue(paintableId, variableName, pid, immediate, 'p'); addVariableToQueue(paintableId, variableName, pid, immediate, 'p');
} }


* the id of the paintable that owns the variable * the id of the paintable that owns the variable
* @param variableName * @param variableName
* the name of the variable * the name of the variable
* @param newValue
* @param map
* the new value to be sent * the new value to be sent
* @param immediate * @param immediate
* true if the update is to be sent as soon as possible * true if the update is to be sent as soon as possible
buf.append(escapeVariableValue(key)); buf.append(escapeVariableValue(key));
buf.append(VAR_ARRAYITEM_SEPARATOR); buf.append(VAR_ARRAYITEM_SEPARATOR);
if (transportType == 'p') { if (transportType == 'p') {
buf.append(getPid((Paintable) value));
buf.append(paintableMap.getPid((Paintable) value));
} else { } else {
buf.append(escapeVariableValue(String.valueOf(value))); buf.append(escapeVariableValue(String.valueOf(value)));
} }
// first char tells the type in array // first char tells the type in array
buf.append(transportType); buf.append(transportType);
if (transportType == 'p') { if (transportType == 'p') {
buf.append(getPid((Paintable) value));
buf.append(paintableMap.getPid((Paintable) value));
} else { } else {
buf.append(escapeVariableValue(String.valueOf(value))); buf.append(escapeVariableValue(String.valueOf(value)));
} }
*/ */
public boolean updateComponent(Widget component, UIDL uidl, public boolean updateComponent(Widget component, UIDL uidl,
boolean manageCaption) { boolean manageCaption) {
String pid = getPid(component.getElement());
Paintable paintable = paintableMap.getPaintable(component);

String pid = paintableMap.getPid(paintable);
if (pid == null) { if (pid == null) {
VConsole.error("Trying to update an unregistered component: " VConsole.error("Trying to update an unregistered component: "
+ Util.getSimpleName(component)); + Util.getSimpleName(component));
return true; return true;
} }


ComponentDetail componentDetail = idToPaintableDetail.get(pid);

if (componentDetail == null) {
VConsole.error("ComponentDetail not found for "
+ Util.getSimpleName(component) + " with PID " + pid
+ ". This should not happen.");
return true;
}

// If the server request that a cached instance should be used, do // If the server request that a cached instance should be used, do
// nothing // nothing
if (uidl.getBooleanAttribute("cached")) { if (uidl.getBooleanAttribute("cached")) {


// 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
componentDetail.registerEventListenersFromUIDL(uidl);
paintableMap.registerEventListenersFromUIDL(pid, uidl);


// Visibility // Visibility
boolean visible = !uidl.getBooleanAttribute("invisible"); boolean visible = !uidl.getBooleanAttribute("invisible");
if (!visible) { if (!visible) {
// component is invisible, delete old size to notify parent, if // component is invisible, delete old size to notify parent, if
// later make visible // later make visible
componentDetail.setOffsetSize(null);
paintableMap.setOffsetSize(paintable, null);
return true; return true;
} }


final Container parent = Util.getLayout(component); final Container parent = Util.getLayout(component);
if (parent != null) { if (parent != null) {
parent.replaceChildComponent(component, w); parent.replaceChildComponent(component, w);
unregisterPaintable((Paintable) component);
registerPaintable(uidl.getId(), (Paintable) w);
paintableMap.unregisterPaintable(paintable);
paintableMap.registerPaintable(uidl.getId(), (Paintable) w);
((Paintable) w).updateFromUIDL(uidl, this); ((Paintable) w).updateFromUIDL(uidl, this);
return true; return true;
} }
styleBuf.append(MODIFIED_CLASSNAME); styleBuf.append(MODIFIED_CLASSNAME);
} }


TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(paintable, null);
// Update tooltip // Update tooltip
if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) { if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
tooltipInfo tooltipInfo
* taken into account * taken into account
*/ */


updateComponentSize(componentDetail, uidl);
updateComponentSize(paintable, uidl);


return false; return false;
} }


private void updateComponentSize(ComponentDetail cd, UIDL uidl) {
private void updateComponentSize(Paintable paintable, UIDL uidl) {
String w = uidl.hasAttribute("width") ? uidl String w = uidl.hasAttribute("width") ? uidl
.getStringAttribute("width") : ""; .getStringAttribute("width") : "";


// One or both is relative // One or both is relative
FloatSize relativeSize = new FloatSize(relativeWidth, FloatSize relativeSize = new FloatSize(relativeWidth,
relativeHeight); relativeHeight);
if (cd.getRelativeSize() == null && cd.getOffsetSize() != null) {

if (paintableMap.getRelativeSize(paintable) == null
&& paintableMap.getOffsetSize(paintable) != null) {
// The component has changed from absolute size to relative size // The component has changed from absolute size to relative size
relativeSizeChanges.add(cd.getComponent());
relativeSizeChanges.add(paintable);
} }
cd.setRelativeSize(relativeSize);
paintableMap.setRelativeSize(paintable, relativeSize);
} else if (relativeHeight < 0.0 && relativeWidth < 0.0) { } else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
if (cd.getRelativeSize() != null) {
if (paintableMap.getRelativeSize(paintable) != null) {
// The component has changed from relative size to absolute size // The component has changed from relative size to absolute size
relativeSizeChanges.add(cd.getComponent());
relativeSizeChanges.add(paintable);
} }
cd.setRelativeSize(null);
paintableMap.setRelativeSize(paintable, null);
} }


Widget component = (Widget) cd.getComponent();
Widget component = paintableMap.getWidget(paintable);
// Set absolute sizes // Set absolute sizes
if (relativeHeight < 0.0) { if (relativeHeight < 0.0) {
component.setHeight(h); component.setHeight(h);
// Set relative sizes // Set relative sizes
if (relativeHeight >= 0.0 || relativeWidth >= 0.0) { if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
// One or both is relative // One or both is relative
handleComponentRelativeSize(cd);
handleComponentRelativeSize(paintable);
} }


} }
*/ */
public void forceLayout() { public void forceLayout() {
Set<Paintable> set = new HashSet<Paintable>(); Set<Paintable> set = new HashSet<Paintable>();
for (ComponentDetail cd : idToPaintableDetail.values()) {
set.add(cd.getComponent());
}
set.addAll(paintableMap.getPaintables());
Util.componentSizeUpdated(set); Util.componentSizeUpdated(set);
} }


* @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(ComponentDetail cd) {
if (cd == null) {
private boolean handleComponentRelativeSize(Paintable paintable) {
if (paintable == null) {
return false; return false;
} }
boolean debugSizes = false; boolean debugSizes = false;


FloatSize relativeSize = cd.getRelativeSize();
FloatSize relativeSize = paintableMap.getRelativeSize(paintable);
if (relativeSize == null) { if (relativeSize == null) {
return false; return false;
} }
Widget widget = (Widget) cd.getComponent();
Widget widget = paintableMap.getWidget(paintable);


boolean horizontalScrollBar = false; boolean horizontalScrollBar = false;
boolean verticalScrollBar = false; boolean verticalScrollBar = false;


Container parent = Util.getLayout(widget);
Container parentPaintable = Util.getLayout(widget);
RenderSpace renderSpace; RenderSpace renderSpace;


// Parent-less components (like sub-windows) are relative to browser // Parent-less components (like sub-windows) are relative to browser
// window. // window.
if (parent == null) {
if (parentPaintable == null) {
renderSpace = new RenderSpace(Window.getClientWidth(), renderSpace = new RenderSpace(Window.getClientWidth(),
Window.getClientHeight()); Window.getClientHeight());
} else { } else {
renderSpace = parent.getAllocatedSpace(widget);
renderSpace = parentPaintable.getAllocatedSpace(widget);
} }


if (relativeSize.getHeight() >= 0) { if (relativeSize.getHeight() >= 0) {
height -= renderSpace.getScrollbarSize(); height -= renderSpace.getScrollbarSize();
} }
if (validatingLayouts && height <= 0) { if (validatingLayouts && height <= 0) {
zeroHeightComponents.add(cd.getComponent());
zeroHeightComponents.add(paintable);
} }


height = (int) (height * relativeSize.getHeight() / 100.0); height = (int) (height * relativeSize.getHeight() / 100.0);
} }


if (debugSizes) { if (debugSizes) {
VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
+ getPid(widget.getElement()) + " relative height "
+ relativeSize.getHeight() + "% of "
+ renderSpace.getHeight() + "px (reported by "

+ Util.getSimpleName(parent) + "/"
+ (parent == null ? "?" : parent.hashCode())
+ ") : " + height + "px");
VConsole.log("Widget "
+ Util.getSimpleName(widget)
+ "/"
+ paintableMap.getPid(paintable)
+ " relative height "
+ relativeSize.getHeight()
+ "% of "
+ renderSpace.getHeight()
+ "px (reported by "

+ Util.getSimpleName(parentPaintable)
+ "/"
+ (parentPaintable == null ? "?" : parentPaintable
.hashCode()) + ") : " + height + "px");
} }
widget.setHeight(height + "px"); widget.setHeight(height + "px");
} else { } else {
width -= renderSpace.getScrollbarSize(); width -= renderSpace.getScrollbarSize();
} }
if (validatingLayouts && width <= 0) { if (validatingLayouts && width <= 0) {
zeroWidthComponents.add(cd.getComponent());
zeroWidthComponents.add(paintable);
} }


width = (int) (width * relativeSize.getWidth() / 100.0); width = (int) (width * relativeSize.getWidth() / 100.0);
} }


if (debugSizes) { if (debugSizes) {
VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
+ getPid(widget.getElement()) + " relative width "
+ relativeSize.getWidth() + "% of "
+ renderSpace.getWidth() + "px (reported by "
+ Util.getSimpleName(parent) + "/"
+ (parent == null ? "?" : getPid(parent)) + ") : "
+ width + "px");
VConsole.log("Widget "
+ Util.getSimpleName(widget)
+ "/"
+ paintableMap.getPid(paintable)
+ " relative width "
+ relativeSize.getWidth()
+ "% of "
+ renderSpace.getWidth()
+ "px (reported by "
+ Util.getSimpleName(parentPaintable)
+ "/"
+ (parentPaintable == null ? "?" : paintableMap
.getPid(parentPaintable)) + ") : " + width
+ "px");
} }
widget.setWidth(width + "px"); widget.setWidth(width + "px");
} else { } else {
* @param child * @param child
* @return true if the child has a relative size * @return true if the child has a relative size
*/ */
public boolean handleComponentRelativeSize(Widget child) {
return handleComponentRelativeSize(idToPaintableDetail.get(getPid(child
.getElement())));
public boolean handleComponentRelativeSize(Widget widget) {
return handleComponentRelativeSize(paintableMap.getPaintable(widget));


} }


* @return the the size if the paintable is relatively sized, -1 otherwise * @return the the size if the paintable is relatively sized, -1 otherwise
*/ */
public FloatSize getRelativeSize(Widget widget) { public FloatSize getRelativeSize(Widget widget) {
return idToPaintableDetail.get(getPid(widget.getElement()))
.getRelativeSize();
return paintableMap.getRelativeSize(paintableMap.getPaintable(widget));
} }


/** /**
* @return Either existing or new Paintable corresponding to UIDL. * @return Either existing or new Paintable corresponding to UIDL.
*/ */
public Paintable getPaintable(UIDL uidl) { public Paintable getPaintable(UIDL uidl) {
final String id = uidl.getId();
Paintable w = getPaintable(id);
if (w != null) {
return w;
} else {
w = widgetSet.createWidget(uidl, configuration);
registerPaintable(id, w);
return w;

final String pid = uidl.getId();
if (!paintableMap.hasPaintable(pid)) {
// Create and register a new paintable if no old was found
Paintable p = widgetSet.createWidget(uidl, configuration);
paintableMap.registerPaintable(pid, p);
} }
}

/**
* Returns a Paintable element by its root element
*
* @param element
* Root element of the paintable
*/
public Paintable getPaintable(Element element) {
return getPaintable(getPid(element));
return paintableMap.getPaintable(pid);
} }


/** /**
if (null == titleOwner) { if (null == titleOwner) {
return null; return null;
} }
ComponentDetail cd = idToPaintableDetail.get(getPid(titleOwner));
if (null != cd) {
return cd.getTooltipInfo(key);
} else {
return null;
}
return paintableMap.getTooltipInfo(titleOwner, key);
} }


private final VTooltip tooltip = new VTooltip(this); private final VTooltip tooltip = new VTooltip(this);
} }
}; };


private PaintableMap paintableMap = new PaintableMap();

/** /**
* Components can call this function to run all layout functions. This is * Components can call this function to run all layout functions. This is
* usually done, when component knows that its size has changed. * usually done, when component knows that its size has changed.
*/ */
public void registerTooltip(Paintable paintable, Object key, public void registerTooltip(Paintable paintable, Object key,
TooltipInfo tooltip) { TooltipInfo tooltip) {
ComponentDetail componentDetail = idToPaintableDetail
.get(getPid(paintable));
componentDetail.putAdditionalTooltip(key, tooltip);
paintableMap.registerTooltip(paintable, key, tooltip);
} }


/** /**
* for the event identified by eventIdentifier. * for the event identified by eventIdentifier.
*/ */
public boolean hasEventListeners(Paintable paintable, String eventIdentifier) { public boolean hasEventListeners(Paintable paintable, String eventIdentifier) {
return idToPaintableDetail.get(getPid(paintable)).hasEventListeners(
eventIdentifier);
return paintableMap.hasEventListeners(paintable, eventIdentifier);
} }


/** /**
return uri; return uri;
} }


PaintableMap getPaintableMap() {
return paintableMap;
}

@Deprecated
public void unregisterPaintable(Paintable p) {
paintableMap.unregisterPaintable(p);

}

} }

+ 23
- 19
src/com/vaadin/terminal/gwt/client/ComponentDetail.java View File



class ComponentDetail { class ComponentDetail {


private Paintable component;
// private Paintable paintable;
private TooltipInfo tooltipInfo = new TooltipInfo(); private TooltipInfo tooltipInfo = new TooltipInfo();
private String pid;


public ComponentDetail(ApplicationConnection client, String pid,
Paintable component) {
this.component = component;
this.pid = pid;
// private String pid;
public ComponentDetail() {
} }


// public ComponentDetail(String pid, Paintable paintable) {
// this.paintable = paintable;
// this.pid = pid;
// }

/** /**
* Returns a TooltipInfo assosiated with Component. If element is given, * Returns a TooltipInfo assosiated with Component. If element is given,
* returns an additional TooltipInfo. * returns an additional TooltipInfo.
private Size offsetSize; private Size offsetSize;
private HashMap<Object, TooltipInfo> additionalTooltips; private HashMap<Object, TooltipInfo> additionalTooltips;


/**
* @return the pid
*/
String getPid() {
return pid;
}
/**
* @return the component
*/
Paintable getComponent() {
return component;
}
// /**
// * @return the pid
// */
// String getPid() {
// return pid;
// }
// /**
// * @return the component
// */
// Paintable getPaintable() {
// return paintable;
// }


/** /**
* @return the relativeSize * @return the relativeSize

+ 4
- 4
src/com/vaadin/terminal/gwt/client/ComponentLocator.java View File

Element e = targetElement; Element e = targetElement;


while (true) { while (true) {
pid = client.getPid(e);
pid = PaintableMap.get(client).getPid(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 = (Widget) client.getPaintable(pid);
w = (Widget) PaintableMap.get(client).getPaintable(pid);


/* /*
* Still if the Paintable contains a widget that implements * Still if the Paintable contains a widget that implements
return null; return null;
} }


String pid = client.getPid(w.getElement());
String pid = PaintableMap.get(client).getPid(w.getElement());
if (isStaticPid(pid)) { if (isStaticPid(pid)) {
return pid; return pid;
} }
w = client.getView(); w = client.getView();
} else if (w == null) { } else if (w == null) {
// Must be static pid (PID_S*) // Must be static pid (PID_S*)
w = (Widget) client.getPaintable(part);
w = (Widget) PaintableMap.get(client).getPaintable(part);
} 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
// element // element

+ 356
- 0
src/com/vaadin/terminal/gwt/client/PaintableMap.java View File

package com.vaadin.terminal.gwt.client;
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.user.client.Element;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
public class PaintableMap {
private Map<String, Paintable> idToPaintable = new HashMap<String, Paintable>();
@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 Paintable getPaintable(String pid) {
return idToPaintable.get(pid);
}
/**
* Returns a Paintable element by its root element
*
* @param element
* Root element of the paintable
*/
public Paintable getPaintable(Element element) {
return getPaintable(getPid(element));
}
public static PaintableMap get(ApplicationConnection applicationConnection) {
return applicationConnection.getPaintableMap();
}
/**
* 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(Paintable paintable) {
return (Widget) paintable;
}
@Deprecated
public Paintable getPaintable(Widget widget) {
return (Paintable) widget;
}
public void registerPaintable(String pid, Paintable paintable) {
ComponentDetail componentDetail = GWT.create(ComponentDetail.class);
idToComponentDetail.put(pid, componentDetail);
idToPaintable.put(pid, paintable);
setPid(((Widget) paintable).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
*/
public String getPid(Paintable paintable) {
return getPid(getWidget(paintable));
}
@Deprecated
public String getPid(Widget widget) {
if (widget == null) {
return null;
}
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) {
return ((Widget) getPaintable(pid)).getElement();
}
/**
* 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(Paintable p) {
// add to unregistry que
if (p == null) {
VConsole.error("WARN: Trying to unregister null paintable");
return;
}
String id = getPid(p);
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.");
// }
if (p instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) p);
}
} else {
unregistryBag.add(id);
if (p instanceof HasWidgets) {
unregisterChildPaintables((HasWidgets) p);
}
}
}
void purgeUnregistryBag(boolean unregisterPaintables) {
if (unregisterPaintables) {
for (String pid : unregistryBag) {
Paintable 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;
}
// check if can be cleaned
Widget component = getWidget(paintable);
if (!component.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) {
final Iterator<Widget> it = container.iterator();
while (it.hasNext()) {
final Widget w = it.next();
if (w instanceof Paintable) {
unregisterPaintable((Paintable) w);
} else if (w instanceof HasWidgets) {
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(Paintable paintable) {
return getComponentDetail(paintable).getOffsetSize();
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public FloatSize getRelativeSize(Paintable paintable) {
return getComponentDetail(paintable).getRelativeSize();
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public void setOffsetSize(Paintable paintable, Size newSize) {
getComponentDetail(paintable).setOffsetSize(newSize);
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public void setRelativeSize(Paintable paintable, FloatSize relativeSize) {
getComponentDetail(paintable).setRelativeSize(relativeSize);
}
private ComponentDetail getComponentDetail(Paintable paintable) {
return idToComponentDetail.get(getPid(paintable));
}
public int size() {
return idToPaintable.size();
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public TooltipInfo getTooltipInfo(Paintable paintable, Object key) {
return getComponentDetail(paintable).getTooltipInfo(key);
}
public Collection<? extends Paintable> getPaintables() {
return Collections.unmodifiableCollection(idToPaintable.values());
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public void registerTooltip(Paintable paintable, Object key,
TooltipInfo tooltip) {
getComponentDetail(paintable).putAdditionalTooltip(key, tooltip);
}
/**
* FIXME: Should not be here
*
* @param paintable
* @return
*/
@Deprecated
public boolean hasEventListeners(Paintable paintable, String eventIdentifier) {
return getComponentDetail(paintable).hasEventListeners(eventIdentifier);
}
}

+ 4
- 2
src/com/vaadin/terminal/gwt/client/UIDL.java View File

*/ */
public Paintable getPaintableAttribute(String name, public Paintable getPaintableAttribute(String name,
ApplicationConnection connection) { ApplicationConnection connection) {
return connection.getPaintable(getStringAttribute(name));
return PaintableMap.get(connection).getPaintable(
getStringAttribute(name));
} }


/** /**
*/ */
public Paintable getPaintableVariable(String name, public Paintable getPaintableVariable(String name,
ApplicationConnection connection) { ApplicationConnection connection) {
return connection.getPaintable(getStringVariable(name));
return PaintableMap.get(connection).getPaintable(
getStringVariable(name));
} }


/** /**

+ 7
- 5
src/com/vaadin/terminal/gwt/client/Util.java View File

ApplicationConnection client, Container parent, Element element) { ApplicationConnection client, Container parent, Element element) {
Element rootElement = ((Widget) parent).getElement(); Element rootElement = ((Widget) parent).getElement();
while (element != null && element != rootElement) { while (element != null && element != rootElement) {
Paintable paintable = client.getPaintable(element);
Paintable paintable = PaintableMap.get(client)
.getPaintable(element);
if (paintable == null) { if (paintable == null) {
String ownerPid = VCaption.getCaptionOwnerPid(element); String ownerPid = VCaption.getCaptionOwnerPid(element);
if (ownerPid != null) { if (ownerPid != null) {
paintable = client.getPaintable(ownerPid);
paintable = PaintableMap.get(client).getPaintable(ownerPid);
} }
} }


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) {
Paintable paintable = client.getPaintable(element);
Paintable paintable = PaintableMap.get(client)
.getPaintable(element);
if (paintable == null) { if (paintable == null) {
String ownerPid = VCaption.getCaptionOwnerPid(element); String ownerPid = VCaption.getCaptionOwnerPid(element);
if (ownerPid != null) { if (ownerPid != null) {
paintable = client.getPaintable(ownerPid);
paintable = PaintableMap.get(client).getPaintable(ownerPid);
} }
} }




private static void printPaintablesVariables(ArrayList<String[]> vars, private static void printPaintablesVariables(ArrayList<String[]> vars,
String id, ApplicationConnection c) { String id, ApplicationConnection c) {
Paintable paintable = c.getPaintable(id);
Paintable paintable = PaintableMap.get(c).getPaintable(id);
if (paintable != null) { if (paintable != null) {
VConsole.log("\t" + id + " (" + paintable.getClass() + ") :"); VConsole.log("\t" + id + " (" + paintable.getClass() + ") :");
for (String[] var : vars) { for (String[] var : vars) {

+ 1
- 1
src/com/vaadin/terminal/gwt/client/VCaption.java View File

owner = component; owner = component;


if (client != null && owner != null) { if (client != null && owner != null) {
setOwnerPid(getElement(), client.getPid(owner));
setOwnerPid(getElement(), PaintableMap.get(client).getPid(owner));
} }


setStyleName(CLASSNAME); setStyleName(CLASSNAME);

+ 2
- 2
src/com/vaadin/terminal/gwt/client/VDebugConsole.java View File

RootPanel.get(), eventTarget); RootPanel.get(), eventTarget);
} }
if (paintable != null) { if (paintable != null) {
String pid = a.getPid(paintable);
String pid = PaintableMap.get(a).getPid(paintable);
VUIDLBrowser.highlight(paintable); VUIDLBrowser.highlight(paintable);
label.setText("Currently focused :" label.setText("Currently focused :"
+ paintable.getClass() + " ID:" + pid); + paintable.getClass() + " ID:" + pid);
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 Paintable paintable = ac.getPaintable(pid);
final Paintable paintable = PaintableMap.get(ac).getPaintable(pid);


SimpleTree errorNode = new SimpleTree(); SimpleTree errorNode = new SimpleTree();
VerticalPanel errorDetails = new VerticalPanel(); VerticalPanel errorDetails = new VerticalPanel();

+ 2
- 2
src/com/vaadin/terminal/gwt/client/VUIDLBrowser.java View File

// same // same
// host page // host page
for (ApplicationConnection applicationConnection : runningApplications) { for (ApplicationConnection applicationConnection : runningApplications) {
Paintable paintable = applicationConnection.getPaintable(uidl
.getId());
Paintable paintable = PaintableMap.get(applicationConnection)
.getPaintable(uidl.getId());
highlight(paintable); highlight(paintable);
if (event != null && event.getNativeEvent().getShiftKey()) { if (event != null && event.getNativeEvent().getShiftKey()) {
applicationConnection.highlightComponent(paintable); applicationConnection.highlightComponent(paintable);

+ 3
- 1
src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java View File

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.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;


public abstract class ClickEventHandler implements DoubleClickHandler, public abstract class ClickEventHandler implements DoubleClickHandler,
ContextMenuHandler, MouseUpHandler { ContextMenuHandler, MouseUpHandler {


protected void fireClick(NativeEvent event) { protected void fireClick(NativeEvent event) {
ApplicationConnection client = getApplicationConnection(); ApplicationConnection client = getApplicationConnection();
String pid = getApplicationConnection().getPid(paintable);
String pid = PaintableMap.get(getApplicationConnection()).getPid(
paintable);


MouseEventDetails mouseDetails = new MouseEventDetails(event, MouseEventDetails mouseDetails = new MouseEventDetails(event,
getRelativeToElement()); getRelativeToElement());

+ 3
- 1
src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java View File

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.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;


public abstract class LayoutClickEventHandler extends ClickEventHandler { public abstract class LayoutClickEventHandler extends ClickEventHandler {


@Override @Override
protected void fireClick(NativeEvent event) { protected void fireClick(NativeEvent event) {
ApplicationConnection client = getApplicationConnection(); ApplicationConnection client = getApplicationConnection();
String pid = getApplicationConnection().getPid(paintable);
String pid = PaintableMap.get(getApplicationConnection()).getPid(
paintable);


MouseEventDetails mouseDetails = new MouseEventDetails(event, MouseEventDetails mouseDetails = new MouseEventDetails(event,
getRelativeToElement()); getRelativeToElement());

+ 2
- 1
src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java View File

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.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.RenderInformation; import com.vaadin.terminal.gwt.client.RenderInformation;
import com.vaadin.terminal.gwt.client.RenderInformation.Size; import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.UIDL;
} }


private String getPid() { private String getPid() {
return client.getPid(this);
return PaintableMap.get(client).getPid((Paintable) this);
} }


public VDropHandler getDropHandler() { public VDropHandler getDropHandler() {

+ 3
- 2
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java View File

import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ContainerResizedListener; import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
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.Util; import com.vaadin.terminal.gwt.client.Util;
moreItem.setHTML(itemHTML.toString()); moreItem.setHTML(itemHTML.toString());
moreItem.setCommand(emptyCommand); moreItem.setCommand(emptyCommand);


collapsedRootItems = new VMenuBar(true,
(VMenuBar) client.getPaintable(uidlId));
collapsedRootItems = new VMenuBar(true, (VMenuBar) PaintableMap
.get(client).getPaintable(uidlId));
moreItem.setSubMenu(collapsedRootItems); moreItem.setSubMenu(collapsedRootItems);
moreItem.addStyleName(CLASSNAME + "-more-menuitem"); moreItem.addStyleName(CLASSNAME + "-more-menuitem");
} }

+ 2
- 1
src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java View File

import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size; import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.RenderSpace;


for (int i = 0; i < renderedWidgets.size(); i++) { for (int i = 0; i < renderedWidgets.size(); i++) {
Widget widget = renderedWidgets.get(i); Widget widget = renderedWidgets.get(i);
String pid = client.getPid(widget.getElement());
String pid = PaintableMap.get(client).getPid(widget);


ChildComponentContainer container = getComponentContainer(widget); ChildComponentContainer container = getComponentContainer(widget);



+ 2
- 1
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java View File

import com.vaadin.terminal.gwt.client.Focusable; import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.RenderSpace;
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;
private void purgeUnregistryBag() { private void purgeUnregistryBag() {
for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator
.hasNext();) { .hasNext();) {
client.unregisterChildPaintables(iterator.next());
PaintableMap.get(client).unregisterChildPaintables(iterator.next());
} }
lazyUnregistryBag.clear(); lazyUnregistryBag.clear();
} }

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VTextField.java View File

} }
focusedTextField = this; focusedTextField = this;
if (client.hasEventListeners(this, EventId.FOCUS)) { if (client.hasEventListeners(this, EventId.FOCUS)) {
client.updateVariable(client.getPid(this), EventId.FOCUS, "", true);
client.updateVariable(id, EventId.FOCUS, "", true);
} }
} }



+ 5
- 2
src/com/vaadin/terminal/gwt/client/ui/dd/VDragSourceIs.java View File

package com.vaadin.terminal.gwt.client.ui.dd; package com.vaadin.terminal.gwt.client.ui.dd;


import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.UIDL;


/** /**
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);
Paintable paintable = VDragAndDropManager.get()
.getCurrentDropHandler().getApplicationConnection()
VDropHandler currentDropHandler = VDragAndDropManager.get()
.getCurrentDropHandler();
Paintable paintable = PaintableMap.get(
currentDropHandler.getApplicationConnection())
.getPaintable(requiredPid); .getPaintable(requiredPid);
if (paintable == component) { if (paintable == component) {
return true; return true;

+ 8
- 4
src/com/vaadin/terminal/gwt/client/ui/dd/VIsOverId.java View File

package com.vaadin.terminal.gwt.client.ui.dd; package com.vaadin.terminal.gwt.client.ui.dd;


import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.UIDL;


final public class VIsOverId extends VAcceptCriterion { final public class VIsOverId extends VAcceptCriterion {
try { try {


String pid = configuration.getStringAttribute("s"); String pid = configuration.getStringAttribute("s");
Paintable paintable = VDragAndDropManager.get()
.getCurrentDropHandler().getPaintable();
String pid2 = VDragAndDropManager.get().getCurrentDropHandler()
.getApplicationConnection().getPid(paintable);
VDropHandler currentDropHandler = VDragAndDropManager.get()
.getCurrentDropHandler();
Paintable paintable = currentDropHandler.getPaintable();
PaintableMap paintableMap = PaintableMap.get(currentDropHandler
.getApplicationConnection());

String pid2 = paintableMap.getPid(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

+ 6
- 2
src/com/vaadin/terminal/gwt/client/ui/dd/VItemIdIs.java View File

package com.vaadin.terminal.gwt.client.ui.dd; package com.vaadin.terminal.gwt.client.ui.dd;


import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.PaintableMap;
import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.UIDL;


final public class VItemIdIs extends VAcceptCriterion { final public class VItemIdIs extends VAcceptCriterion {
try { try {
String pid = configuration.getStringAttribute("s"); String pid = configuration.getStringAttribute("s");
Paintable dragSource = drag.getTransferable().getDragSource(); Paintable dragSource = drag.getTransferable().getDragSource();
String pid2 = VDragAndDropManager.get().getCurrentDropHandler()
.getApplicationConnection().getPid(dragSource);
VDropHandler currentDropHandler = VDragAndDropManager.get()
.getCurrentDropHandler();
String pid2 = PaintableMap.get(
currentDropHandler.getApplicationConnection()).getPid(
dragSource);
if (pid2.equals(pid)) { if (pid2.equals(pid)) {
Object searchedId = drag.getTransferable().getData("itemId"); Object searchedId = drag.getTransferable().getData("itemId");
String[] stringArrayAttribute = configuration String[] stringArrayAttribute = configuration

Loading…
Cancel
Save