Renamed Paintable -> Connector.tags/7.0.0.alpha2
* Sends a request to the server to print details to console that will help | * Sends a request to the server to print details to console that will help | ||||
* developer to locate component in the source code. | * developer to locate component in the source code. | ||||
* | * | ||||
* @param paintable | |||||
* @param componentConnector | |||||
*/ | */ | ||||
void highlightComponent(ComponentConnector paintable) { | |||||
void highlightComponent(ComponentConnector componentConnector) { | |||||
String params = getRepaintAllParameters() + "&highlightComponent=" | String params = getRepaintAllParameters() + "&highlightComponent=" | ||||
+ connectorMap.getConnectorId(paintable); | |||||
+ componentConnector.getConnectorId(); | |||||
makeUidlRequest("", params, false); | makeUidlRequest("", params, false); | ||||
} | } | ||||
idToComponentDetail.clear(); | idToComponentDetail.clear(); | ||||
} | } | ||||
/** | |||||
* Retrieves the connector whose widget matches the parameter. | |||||
* | |||||
* @param widget | |||||
* The widget | |||||
* @return A connector with {@literal widget} as its root widget or null if | |||||
* no connector was found | |||||
*/ | |||||
public ComponentConnector getConnector(Widget widget) { | public ComponentConnector getConnector(Widget widget) { | ||||
return getConnector(widget.getElement()); | return getConnector(widget.getElement()); | ||||
} | } | ||||
el.tkPid = 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 ServerConnector#getConnectorId()} instead | |||||
*/ | |||||
@Deprecated | |||||
public String getConnectorId(ServerConnector connector) { | |||||
if (connector == null) { | |||||
return null; | |||||
} | |||||
return connector.getConnectorId(); | |||||
} | |||||
@Deprecated | |||||
public String getConnectorId(Widget widget) { | |||||
return getConnectorId(widget.getElement()); | |||||
} | |||||
/** | /** | ||||
* Gets the connector id using a DOM element - the element should be the | * 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 | * root element for a connector, otherwise no id will be found. Use | ||||
return result.toArray(new ComponentConnector[result.size()]); | return result.toArray(new ComponentConnector[result.size()]); | ||||
} | } | ||||
@Deprecated | |||||
private ComponentDetail getComponentDetail( | private ComponentDetail getComponentDetail( | ||||
ComponentConnector componentConnector) { | ComponentConnector componentConnector) { | ||||
return idToComponentDetail.get(getConnectorId(componentConnector)); | |||||
return idToComponentDetail.get(componentConnector.getConnectorId()); | |||||
} | } | ||||
public int size() { | public int size() { | ||||
* {@link ComponentConnector}, false otherwise | * {@link ComponentConnector}, false otherwise | ||||
*/ | */ | ||||
public boolean isConnector(Widget w) { | public boolean isConnector(Widget w) { | ||||
return getConnectorId(w) != null; | |||||
return getConnectorId(w.getElement()) != null; | |||||
} | } | ||||
} | } |
List<ApplicationConnection> runningApplications = ApplicationConfiguration | List<ApplicationConnection> runningApplications = ApplicationConfiguration | ||||
.getRunningApplications(); | .getRunningApplications(); | ||||
for (ApplicationConnection applicationConnection : runningApplications) { | for (ApplicationConnection applicationConnection : runningApplications) { | ||||
ConnectorMap paintableMap = applicationConnection.getConnectorMap(); | |||||
ComponentConnector paintable = paintableMap.getConnector(widget); | |||||
if (paintable == null) { | |||||
ConnectorMap connectorMap = applicationConnection.getConnectorMap(); | |||||
ComponentConnector connector = connectorMap.getConnector(widget); | |||||
if (connector == null) { | |||||
continue; | continue; | ||||
} | } | ||||
String pid = paintableMap.getConnectorId(paintable); | |||||
if (pid != null) { | |||||
ServerConnector otherPaintable = paintableMap.getConnector(pid); | |||||
if (otherPaintable == paintable) { | |||||
return applicationConnection; | |||||
} | |||||
if (connector.getConnection() == 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 ComponentConnector getPaintableForElement( | |||||
public static ComponentConnector getConnectorForElement( | |||||
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) { | ||||
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 ServerConnector ? c | |||||
.getConnectorMap().getConnectorId( | |||||
(ServerConnector) value) : String | |||||
.valueOf(value); | |||||
String formattedValue = value instanceof ServerConnector ? ((ServerConnector) value) | |||||
.getConnectorId() : String.valueOf(value); | |||||
formattedParams = parameters[0] + " : " + formattedValue; | formattedParams = parameters[0] + " : " + formattedValue; | ||||
} | } | ||||
if (null == formattedParams) { | if (null == formattedParams) { |
owner = component; | owner = component; | ||||
if (client != null && owner != null) { | if (client != null && owner != null) { | ||||
setOwnerPid(getElement(), | |||||
ConnectorMap.get(client).getConnectorId(owner)); | |||||
setOwnerPid(getElement(), owner.getConnectorId()); | |||||
} | } | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); |
for (ApplicationConnection a : ApplicationConfiguration | for (ApplicationConnection a : ApplicationConfiguration | ||||
.getRunningApplications()) { | .getRunningApplications()) { | ||||
ComponentConnector paintable = Util.getPaintableForElement( | |||||
ComponentConnector connector = Util.getConnectorForElement( | |||||
a, a.getView().getWidget(), eventTarget); | a, a.getView().getWidget(), eventTarget); | ||||
if (paintable == null) { | |||||
paintable = Util.getPaintableForElement(a, | |||||
if (connector == null) { | |||||
connector = Util.getConnectorForElement(a, | |||||
RootPanel.get(), eventTarget); | RootPanel.get(), eventTarget); | ||||
} | } | ||||
if (paintable != null) { | |||||
String pid = ConnectorMap.get(a).getConnectorId( | |||||
paintable); | |||||
VUIDLBrowser.highlight(paintable); | |||||
if (connector != null) { | |||||
String pid = connector.getConnectorId(); | |||||
VUIDLBrowser.highlight(connector); | |||||
label.setText("Currently focused :" | label.setText("Currently focused :" | ||||
+ paintable.getClass() + " ID:" + pid); | |||||
+ connector.getClass() + " ID:" + pid); | |||||
event.cancel(); | event.cancel(); | ||||
event.consume(); | event.consume(); | ||||
event.getNativeEvent().stopPropagation(); | event.getNativeEvent().stopPropagation(); | ||||
.getClientY()); | .getClientY()); | ||||
for (ApplicationConnection a : ApplicationConfiguration | for (ApplicationConnection a : ApplicationConfiguration | ||||
.getRunningApplications()) { | .getRunningApplications()) { | ||||
ComponentConnector paintable = Util.getPaintableForElement( | |||||
ComponentConnector paintable = Util.getConnectorForElement( | |||||
a, a.getView().getWidget(), eventTarget); | a, a.getView().getWidget(), eventTarget); | ||||
if (paintable == null) { | if (paintable == null) { | ||||
paintable = Util.getPaintableForElement(a, | |||||
paintable = Util.getConnectorForElement(a, | |||||
RootPanel.get(), eventTarget); | RootPanel.get(), eventTarget); | ||||
} | } | ||||
@Override | @Override | ||||
protected ComponentConnector getChildComponent(Element element) { | protected ComponentConnector getChildComponent(Element element) { | ||||
return Util.getPaintableForElement(getConnection(), getWidget(), | |||||
return Util.getConnectorForElement(getConnection(), getWidget(), | |||||
element); | element); | ||||
} | } | ||||
private HandlerRegistration contextMenuHandlerRegistration; | private HandlerRegistration contextMenuHandlerRegistration; | ||||
protected String clickEventIdentifier; | protected String clickEventIdentifier; | ||||
protected ComponentConnector paintable; | |||||
protected ComponentConnector connector; | |||||
public ClickEventHandler(ComponentConnector paintable, | |||||
public ClickEventHandler(ComponentConnector connector, | |||||
String clickEventIdentifier) { | String clickEventIdentifier) { | ||||
this.paintable = paintable; | |||||
this.connector = connector; | |||||
this.clickEventIdentifier = clickEventIdentifier; | this.clickEventIdentifier = clickEventIdentifier; | ||||
} | } | ||||
final H handler, DomEvent.Type<H> type); | final H handler, DomEvent.Type<H> type); | ||||
protected ApplicationConnection getApplicationConnection() { | protected ApplicationConnection getApplicationConnection() { | ||||
return paintable.getConnection(); | |||||
return connector.getConnection(); | |||||
} | } | ||||
public boolean hasEventListener() { | public boolean hasEventListener() { | ||||
return paintable.hasEventListener(clickEventIdentifier); | |||||
return connector.hasEventListener(clickEventIdentifier); | |||||
} | } | ||||
protected void fireClick(NativeEvent event) { | protected void fireClick(NativeEvent event) { | ||||
String pid = paintable.getConnectorId(); | |||||
String pid = connector.getConnectorId(); | |||||
MouseEventDetails mouseDetails = MouseEventDetailsBuilder | MouseEventDetails mouseDetails = MouseEventDetailsBuilder | ||||
.buildMouseEventDetails(event, getRelativeToElement()); | .buildMouseEventDetails(event, getRelativeToElement()); | ||||
Map<String, Object> parameters = new HashMap<String, Object>(); | Map<String, Object> parameters = new HashMap<String, Object>(); | ||||
parameters.put("mouseDetails", mouseDetails.serialize()); | parameters.put("mouseDetails", mouseDetails.serialize()); | ||||
paintable.getConnection().updateVariable(pid, clickEventIdentifier, | |||||
connector.getConnection().updateVariable(pid, clickEventIdentifier, | |||||
parameters, true); | parameters, true); | ||||
} | } | ||||
* or null if no relative coordinates can be calculated. | * or null if no relative coordinates can be calculated. | ||||
*/ | */ | ||||
protected Element getRelativeToElement() { | protected Element getRelativeToElement() { | ||||
return paintable.getWidget().getElement(); | |||||
return connector.getWidget().getElement(); | |||||
} | } | ||||
} | } |
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.ComponentConnector; | import com.vaadin.terminal.gwt.client.ComponentConnector; | ||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | import com.vaadin.terminal.gwt.client.MouseEventDetails; | ||||
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; | import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; | ||||
public abstract class LayoutClickEventHandler extends ClickEventHandler { | public abstract class LayoutClickEventHandler extends ClickEventHandler { | ||||
public LayoutClickEventHandler(ComponentConnector paintable, | |||||
public LayoutClickEventHandler(ComponentConnector connector, | |||||
String clickEventIdentifier) { | String clickEventIdentifier) { | ||||
super(paintable, clickEventIdentifier); | |||||
super(connector, clickEventIdentifier); | |||||
} | } | ||||
protected abstract ComponentConnector 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 = ConnectorMap.get(getApplicationConnection()) | |||||
.getConnectorId(paintable); | |||||
String pid = connector.getConnectorId(); | |||||
MouseEventDetails mouseDetails = MouseEventDetailsBuilder | MouseEventDetails mouseDetails = MouseEventDetailsBuilder | ||||
.buildMouseEventDetails(event, getRelativeToElement()); | .buildMouseEventDetails(event, getRelativeToElement()); |
* belongs to the layout and not to a child. | * belongs to the layout and not to a child. | ||||
*/ | */ | ||||
ComponentConnector getComponent(Element element) { | ComponentConnector getComponent(Element element) { | ||||
return Util.getPaintableForElement(client, this, element); | |||||
return Util.getConnectorForElement(client, this, element); | |||||
} | } | ||||
} | } |
ComponentConnector getComponent(Element element) { | ComponentConnector getComponent(Element element) { | ||||
return Util | return Util | ||||
.getPaintableForElement(client, VCssLayout.this, element); | |||||
.getConnectorForElement(client, VCssLayout.this, element); | |||||
} | } | ||||
} | } |
import com.google.gwt.xhr.client.XMLHttpRequest; | import com.google.gwt.xhr.client.XMLHttpRequest; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.ComponentConnector; | import com.vaadin.terminal.gwt.client.ComponentConnector; | ||||
import com.vaadin.terminal.gwt.client.ServerConnector; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | import com.vaadin.terminal.gwt.client.ConnectorMap; | ||||
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; | import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation; | import com.vaadin.terminal.gwt.client.RenderInformation; | ||||
files.add(file); | files.add(file); | ||||
} | } | ||||
private String getPid() { | |||||
return ConnectorMap.get(client).getConnectorId((ServerConnector) this); | |||||
} | |||||
public VDropHandler getDropHandler() { | public VDropHandler getDropHandler() { | ||||
return dropHandler; | return dropHandler; | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public ComponentConnector getPaintable() { | |||||
public ComponentConnector getConnector() { | |||||
return ConnectorMap.get(client).getConnector( | return ConnectorMap.get(client).getConnector( | ||||
VDragAndDropWrapper.this); | VDragAndDropWrapper.this); | ||||
} | } |
* belongs to the layout and not to a child. | * belongs to the layout and not to a child. | ||||
*/ | */ | ||||
ComponentConnector getComponent(Element element) { | ComponentConnector getComponent(Element element) { | ||||
return Util.getPaintableForElement(client, this, element); | |||||
return Util.getConnectorForElement(client, this, element); | |||||
} | } | ||||
void setCaption(Widget widget, VCaption caption) { | void setCaption(Widget widget, VCaption caption) { |
} | } | ||||
@Override | @Override | ||||
public ComponentConnector getPaintable() { | |||||
public ComponentConnector getConnector() { | |||||
return ConnectorMap.get(client).getConnector(VScrollTable.this); | return ConnectorMap.get(client).getConnector(VScrollTable.this); | ||||
} | } | ||||
if (BrowserInfo.get().isIE()) { | if (BrowserInfo.get().isIE()) { | ||||
// IE sometimes moves focus to a clicked table cell... | // IE sometimes moves focus to a clicked table cell... | ||||
Element focusedElement = Util.getIEFocusedElement(); | Element focusedElement = Util.getIEFocusedElement(); | ||||
if (Util.getPaintableForElement(client, getParent(), focusedElement) == this) { | |||||
if (Util.getConnectorForElement(client, getParent(), focusedElement) == this) { | |||||
// ..in that case, steal the focus back to the focus handler | // ..in that case, steal the focus back to the focus handler | ||||
// but not if focus is in a child component instead (#7965) | // but not if focus is in a child component instead (#7965) | ||||
focus(); | focus(); |
} | } | ||||
@Override | @Override | ||||
public ComponentConnector getPaintable() { | |||||
public ComponentConnector getConnector() { | |||||
return ConnectorMap.get(client).getConnector(VTree.this); | return ConnectorMap.get(client).getConnector(VTree.this); | ||||
} | } | ||||
* 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 ComponentConnector getPaintable(); | |||||
public abstract ComponentConnector getConnector(); | |||||
} | } |
if (currentDropHandler == null) { | if (currentDropHandler == null) { | ||||
return; | return; | ||||
} | } | ||||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||||
ComponentConnector paintable = currentDropHandler.getConnector(); | |||||
ApplicationConnection client = currentDropHandler | ApplicationConnection client = currentDropHandler | ||||
.getApplicationConnection(); | .getApplicationConnection(); | ||||
/* | /* |
public void dragOver(VDragEvent currentDrag); | public void dragOver(VDragEvent currentDrag); | ||||
/** | /** | ||||
* Returns the Paintable into which this DragHandler is associated | |||||
* Returns the ComponentConnector with which this DropHandler is associated | |||||
*/ | */ | ||||
public ComponentConnector getPaintable(); | |||||
public ComponentConnector getConnector(); | |||||
/** | /** | ||||
* Returns the application connection to which this {@link VDropHandler} | * Returns the application connection to which this {@link VDropHandler} |
String pid = configuration.getStringAttribute("s"); | String pid = configuration.getStringAttribute("s"); | ||||
VDropHandler currentDropHandler = VDragAndDropManager.get() | VDropHandler currentDropHandler = VDragAndDropManager.get() | ||||
.getCurrentDropHandler(); | .getCurrentDropHandler(); | ||||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||||
ComponentConnector dropHandlerConnector = currentDropHandler | |||||
.getConnector(); | |||||
ConnectorMap paintableMap = ConnectorMap.get(currentDropHandler | ConnectorMap paintableMap = ConnectorMap.get(currentDropHandler | ||||
.getApplicationConnection()); | .getApplicationConnection()); | ||||
String pid2 = paintableMap.getConnectorId(paintable); | |||||
String pid2 = dropHandlerConnector.getConnectorId(); | |||||
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.ComponentConnector; | import com.vaadin.terminal.gwt.client.ComponentConnector; | ||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
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 { | ||||
.getDragSource(); | .getDragSource(); | ||||
VDropHandler currentDropHandler = VDragAndDropManager.get() | VDropHandler currentDropHandler = VDragAndDropManager.get() | ||||
.getCurrentDropHandler(); | .getCurrentDropHandler(); | ||||
String pid2 = ConnectorMap.get( | |||||
currentDropHandler.getApplicationConnection()) | |||||
.getConnectorId(dragSource); | |||||
String pid2 = dragSource.getConnectorId(); | |||||
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 |
protected boolean accept(VDragEvent drag, UIDL configuration) { | protected boolean accept(VDragEvent drag, UIDL configuration) { | ||||
ComponentConnector dragSource = drag.getTransferable().getDragSource(); | ComponentConnector dragSource = drag.getTransferable().getDragSource(); | ||||
ComponentConnector paintable = VDragAndDropManager.get() | ComponentConnector paintable = VDragAndDropManager.get() | ||||
.getCurrentDropHandler().getPaintable(); | |||||
.getCurrentDropHandler().getConnector(); | |||||
return paintable == dragSource; | return paintable == dragSource; | ||||
} | } |
protected boolean accept(VDragEvent drag, UIDL configuration) { | protected boolean accept(VDragEvent drag, UIDL configuration) { | ||||
VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() | VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() | ||||
.getPaintable(); | |||||
.getConnector(); | |||||
TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() | TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() | ||||
.get("itemIdOver")); | .get("itemIdOver")); | ||||
if (treeNode != null) { | if (treeNode != null) { |
return this; | return this; | ||||
} | } | ||||
public ComponentConnector getPaintable() { | |||||
public ComponentConnector getConnector() { | |||||
// TODO Auto-generated method stub | // TODO Auto-generated method stub | ||||
return null; | return null; | ||||
} | } |