Renamed Paintable -> Connector.tags/7.0.0.alpha2
@@ -423,11 +423,11 @@ public class ApplicationConnection { | |||
* Sends a request to the server to print details to console that will help | |||
* developer to locate component in the source code. | |||
* | |||
* @param paintable | |||
* @param componentConnector | |||
*/ | |||
void highlightComponent(ComponentConnector paintable) { | |||
void highlightComponent(ComponentConnector componentConnector) { | |||
String params = getRepaintAllParameters() + "&highlightComponent=" | |||
+ connectorMap.getConnectorId(paintable); | |||
+ componentConnector.getConnectorId(); | |||
makeUidlRequest("", params, false); | |||
} | |||
@@ -79,6 +79,14 @@ public class ConnectorMap { | |||
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) { | |||
return getConnector(widget.getElement()); | |||
} | |||
@@ -98,32 +106,6 @@ public class ConnectorMap { | |||
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 | |||
* root element for a connector, otherwise no id will be found. Use | |||
@@ -221,9 +203,10 @@ public class ConnectorMap { | |||
return result.toArray(new ComponentConnector[result.size()]); | |||
} | |||
@Deprecated | |||
private ComponentDetail getComponentDetail( | |||
ComponentConnector componentConnector) { | |||
return idToComponentDetail.get(getConnectorId(componentConnector)); | |||
return idToComponentDetail.get(componentConnector.getConnectorId()); | |||
} | |||
public int size() { | |||
@@ -273,7 +256,7 @@ public class ConnectorMap { | |||
* {@link ComponentConnector}, false otherwise | |||
*/ | |||
public boolean isConnector(Widget w) { | |||
return getConnectorId(w) != null; | |||
return getConnectorId(w.getElement()) != null; | |||
} | |||
} |
@@ -99,17 +99,13 @@ public class Util { | |||
List<ApplicationConnection> runningApplications = ApplicationConfiguration | |||
.getRunningApplications(); | |||
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; | |||
} | |||
String pid = paintableMap.getConnectorId(paintable); | |||
if (pid != null) { | |||
ServerConnector otherPaintable = paintableMap.getConnector(pid); | |||
if (otherPaintable == paintable) { | |||
return applicationConnection; | |||
} | |||
if (connector.getConnection() == applicationConnection) { | |||
return applicationConnection; | |||
} | |||
} | |||
@@ -645,7 +641,7 @@ public class Util { | |||
* @return The VPaintableWidget which the element is a part of. Null if the | |||
* element does not belong to a child. | |||
*/ | |||
public static ComponentConnector getPaintableForElement( | |||
public static ComponentConnector getConnectorForElement( | |||
ApplicationConnection client, Widget parent, Element element) { | |||
Element rootElement = parent.getElement(); | |||
while (element != null && element != rootElement) { | |||
@@ -834,10 +830,8 @@ public class Util { | |||
Object value = parameters[1]; | |||
// TODO paintables inside lists/maps get rendered as | |||
// 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; | |||
} | |||
if (null == formattedParams) { |
@@ -70,8 +70,7 @@ public class VCaption extends HTML { | |||
owner = component; | |||
if (client != null && owner != null) { | |||
setOwnerPid(getElement(), | |||
ConnectorMap.get(client).getConnectorId(owner)); | |||
setOwnerPid(getElement(), owner.getConnectorId()); | |||
} | |||
setStyleName(CLASSNAME); |
@@ -94,18 +94,17 @@ public class VDebugConsole extends VOverlay implements Console { | |||
for (ApplicationConnection a : ApplicationConfiguration | |||
.getRunningApplications()) { | |||
ComponentConnector paintable = Util.getPaintableForElement( | |||
ComponentConnector connector = Util.getConnectorForElement( | |||
a, a.getView().getWidget(), eventTarget); | |||
if (paintable == null) { | |||
paintable = Util.getPaintableForElement(a, | |||
if (connector == null) { | |||
connector = Util.getConnectorForElement(a, | |||
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 :" | |||
+ paintable.getClass() + " ID:" + pid); | |||
+ connector.getClass() + " ID:" + pid); | |||
event.cancel(); | |||
event.consume(); | |||
event.getNativeEvent().stopPropagation(); | |||
@@ -124,10 +123,10 @@ public class VDebugConsole extends VOverlay implements Console { | |||
.getClientY()); | |||
for (ApplicationConnection a : ApplicationConfiguration | |||
.getRunningApplications()) { | |||
ComponentConnector paintable = Util.getPaintableForElement( | |||
ComponentConnector paintable = Util.getConnectorForElement( | |||
a, a.getView().getWidget(), eventTarget); | |||
if (paintable == null) { | |||
paintable = Util.getPaintableForElement(a, | |||
paintable = Util.getConnectorForElement(a, | |||
RootPanel.get(), eventTarget); | |||
} | |||
@@ -31,7 +31,7 @@ public abstract class AbstractOrderedLayoutConnector extends | |||
@Override | |||
protected ComponentConnector getChildComponent(Element element) { | |||
return Util.getPaintableForElement(getConnection(), getWidget(), | |||
return Util.getConnectorForElement(getConnection(), getWidget(), | |||
element); | |||
} | |||
@@ -30,11 +30,11 @@ public abstract class ClickEventHandler implements DoubleClickHandler, | |||
private HandlerRegistration contextMenuHandlerRegistration; | |||
protected String clickEventIdentifier; | |||
protected ComponentConnector paintable; | |||
protected ComponentConnector connector; | |||
public ClickEventHandler(ComponentConnector paintable, | |||
public ClickEventHandler(ComponentConnector connector, | |||
String clickEventIdentifier) { | |||
this.paintable = paintable; | |||
this.connector = connector; | |||
this.clickEventIdentifier = clickEventIdentifier; | |||
} | |||
@@ -70,22 +70,22 @@ public abstract class ClickEventHandler implements DoubleClickHandler, | |||
final H handler, DomEvent.Type<H> type); | |||
protected ApplicationConnection getApplicationConnection() { | |||
return paintable.getConnection(); | |||
return connector.getConnection(); | |||
} | |||
public boolean hasEventListener() { | |||
return paintable.hasEventListener(clickEventIdentifier); | |||
return connector.hasEventListener(clickEventIdentifier); | |||
} | |||
protected void fireClick(NativeEvent event) { | |||
String pid = paintable.getConnectorId(); | |||
String pid = connector.getConnectorId(); | |||
MouseEventDetails mouseDetails = MouseEventDetailsBuilder | |||
.buildMouseEventDetails(event, getRelativeToElement()); | |||
Map<String, Object> parameters = new HashMap<String, Object>(); | |||
parameters.put("mouseDetails", mouseDetails.serialize()); | |||
paintable.getConnection().updateVariable(pid, clickEventIdentifier, | |||
connector.getConnection().updateVariable(pid, clickEventIdentifier, | |||
parameters, true); | |||
} | |||
@@ -124,7 +124,7 @@ public abstract class ClickEventHandler implements DoubleClickHandler, | |||
* or null if no relative coordinates can be calculated. | |||
*/ | |||
protected Element getRelativeToElement() { | |||
return paintable.getWidget().getElement(); | |||
return connector.getWidget().getElement(); | |||
} | |||
} |
@@ -10,15 +10,14 @@ import com.google.gwt.dom.client.NativeEvent; | |||
import com.google.gwt.user.client.Element; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
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.MouseEventDetailsBuilder; | |||
public abstract class LayoutClickEventHandler extends ClickEventHandler { | |||
public LayoutClickEventHandler(ComponentConnector paintable, | |||
public LayoutClickEventHandler(ComponentConnector connector, | |||
String clickEventIdentifier) { | |||
super(paintable, clickEventIdentifier); | |||
super(connector, clickEventIdentifier); | |||
} | |||
protected abstract ComponentConnector getChildComponent(Element element); | |||
@@ -26,8 +25,7 @@ public abstract class LayoutClickEventHandler extends ClickEventHandler { | |||
@Override | |||
protected void fireClick(NativeEvent event) { | |||
ApplicationConnection client = getApplicationConnection(); | |||
String pid = ConnectorMap.get(getApplicationConnection()) | |||
.getConnectorId(paintable); | |||
String pid = connector.getConnectorId(); | |||
MouseEventDetails mouseDetails = MouseEventDetailsBuilder | |||
.buildMouseEventDetails(event, getRelativeToElement()); |
@@ -197,7 +197,7 @@ public class VAbsoluteLayout extends ComplexPanel { | |||
* belongs to the layout and not to a child. | |||
*/ | |||
ComponentConnector getComponent(Element element) { | |||
return Util.getPaintableForElement(client, this, element); | |||
return Util.getConnectorForElement(client, this, element); | |||
} | |||
} |
@@ -166,7 +166,7 @@ public class VCssLayout extends SimplePanel { | |||
ComponentConnector getComponent(Element element) { | |||
return Util | |||
.getPaintableForElement(client, VCssLayout.this, element); | |||
.getConnectorForElement(client, VCssLayout.this, element); | |||
} | |||
} |
@@ -24,7 +24,6 @@ import com.google.gwt.xhr.client.ReadyStateChangeHandler; | |||
import com.google.gwt.xhr.client.XMLHttpRequest; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
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.MouseEventDetailsBuilder; | |||
import com.vaadin.terminal.gwt.client.RenderInformation; | |||
@@ -419,10 +418,6 @@ public class VDragAndDropWrapper extends VCustomComponent implements | |||
files.add(file); | |||
} | |||
private String getPid() { | |||
return ConnectorMap.get(client).getConnectorId((ServerConnector) this); | |||
} | |||
public VDropHandler getDropHandler() { | |||
return dropHandler; | |||
} | |||
@@ -499,7 +494,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements | |||
} | |||
@Override | |||
public ComponentConnector getPaintable() { | |||
public ComponentConnector getConnector() { | |||
return ConnectorMap.get(client).getConnector( | |||
VDragAndDropWrapper.this); | |||
} |
@@ -603,7 +603,7 @@ public class VGridLayout extends ComplexPanel { | |||
* belongs to the layout and not to a child. | |||
*/ | |||
ComponentConnector getComponent(Element element) { | |||
return Util.getPaintableForElement(client, this, element); | |||
return Util.getConnectorForElement(client, this, element); | |||
} | |||
void setCaption(Widget widget, VCaption caption) { |
@@ -6116,7 +6116,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
} | |||
@Override | |||
public ComponentConnector getPaintable() { | |||
public ComponentConnector getConnector() { | |||
return ConnectorMap.get(client).getConnector(VScrollTable.this); | |||
} | |||
@@ -6472,7 +6472,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
if (BrowserInfo.get().isIE()) { | |||
// IE sometimes moves focus to a clicked table cell... | |||
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 | |||
// but not if focus is in a child component instead (#7965) | |||
focus(); |
@@ -359,7 +359,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, | |||
} | |||
@Override | |||
public ComponentConnector getPaintable() { | |||
public ComponentConnector getConnector() { | |||
return ConnectorMap.get(client).getConnector(VTree.this); | |||
} | |||
@@ -129,6 +129,6 @@ public abstract class VAbstractDropHandler implements VDropHandler { | |||
* side counterpart of the Paintable is expected to implement | |||
* {@link DropTarget} interface. | |||
*/ | |||
public abstract ComponentConnector getPaintable(); | |||
public abstract ComponentConnector getConnector(); | |||
} |
@@ -583,7 +583,7 @@ public class VDragAndDropManager { | |||
if (currentDropHandler == null) { | |||
return; | |||
} | |||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||
ComponentConnector paintable = currentDropHandler.getConnector(); | |||
ApplicationConnection client = currentDropHandler | |||
.getApplicationConnection(); | |||
/* |
@@ -59,9 +59,9 @@ public interface VDropHandler { | |||
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} |
@@ -19,11 +19,12 @@ final public class VIsOverId extends VAcceptCriterion { | |||
String pid = configuration.getStringAttribute("s"); | |||
VDropHandler currentDropHandler = VDragAndDropManager.get() | |||
.getCurrentDropHandler(); | |||
ComponentConnector paintable = currentDropHandler.getPaintable(); | |||
ComponentConnector dropHandlerConnector = currentDropHandler | |||
.getConnector(); | |||
ConnectorMap paintableMap = ConnectorMap.get(currentDropHandler | |||
.getApplicationConnection()); | |||
String pid2 = paintableMap.getConnectorId(paintable); | |||
String pid2 = dropHandlerConnector.getConnectorId(); | |||
if (pid2.equals(pid)) { | |||
Object searchedId = drag.getDropDetails().get("itemIdOver"); | |||
String[] stringArrayAttribute = configuration |
@@ -7,7 +7,6 @@ | |||
package com.vaadin.terminal.gwt.client.ui.dd; | |||
import com.vaadin.terminal.gwt.client.ComponentConnector; | |||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||
import com.vaadin.terminal.gwt.client.UIDL; | |||
final public class VItemIdIs extends VAcceptCriterion { | |||
@@ -20,9 +19,7 @@ final public class VItemIdIs extends VAcceptCriterion { | |||
.getDragSource(); | |||
VDropHandler currentDropHandler = VDragAndDropManager.get() | |||
.getCurrentDropHandler(); | |||
String pid2 = ConnectorMap.get( | |||
currentDropHandler.getApplicationConnection()) | |||
.getConnectorId(dragSource); | |||
String pid2 = dragSource.getConnectorId(); | |||
if (pid2.equals(pid)) { | |||
Object searchedId = drag.getTransferable().getData("itemId"); | |||
String[] stringArrayAttribute = configuration |
@@ -15,7 +15,7 @@ final public class VSourceIsTarget extends VAcceptCriterion { | |||
protected boolean accept(VDragEvent drag, UIDL configuration) { | |||
ComponentConnector dragSource = drag.getTransferable().getDragSource(); | |||
ComponentConnector paintable = VDragAndDropManager.get() | |||
.getCurrentDropHandler().getPaintable(); | |||
.getCurrentDropHandler().getConnector(); | |||
return paintable == dragSource; | |||
} |
@@ -17,7 +17,7 @@ final public class VTargetInSubtree extends VAcceptCriterion { | |||
protected boolean accept(VDragEvent drag, UIDL configuration) { | |||
VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() | |||
.getPaintable(); | |||
.getConnector(); | |||
TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() | |||
.get("itemIdOver")); | |||
if (treeNode != null) { |
@@ -34,7 +34,7 @@ public class VMyDropTarget extends Composite implements VHasDropHandler, | |||
return this; | |||
} | |||
public ComponentConnector getPaintable() { | |||
public ComponentConnector getConnector() { | |||
// TODO Auto-generated method stub | |||
return null; | |||
} |