Browse Source

Connector interface. Renamed getId() -> getConnectorId() to avoid mixups

tags/7.0.0.alpha2
Artur Signell 12 years ago
parent
commit
697baba1cb

+ 29
- 0
src/com/vaadin/terminal/gwt/client/Connector.java View File

package com.vaadin.terminal.gwt.client;

import com.vaadin.terminal.gwt.client.communication.SharedState;

/**
* TODO Add javadoc
*
* @author Vaadin Ltd
* @version @VERSION@
* @since 7.0.0
*
*/
public interface Connector {
/**
* Gets the current shared state of the connector.
*
* @return state
*/
public SharedState getState();

/**
* Returns the id for this connector. This must always be what has been set
* in {@link #doInit(String, ApplicationConnection)} and must never change.
*
* @return The id for the connector.
*/
public String getConnectorId();

}

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

* the connector whose id is needed * the connector whose id is needed
* @return the id for the given connector or null if the connector could not * @return the id for the given connector or null if the connector could not
* be found * be found
* @deprecated use {@link ServerConnector#getId()} instead
* @deprecated use {@link ServerConnector#getConnectorId()} instead
*/ */
@Deprecated @Deprecated
public String getConnectorId(ServerConnector connector) { public String getConnectorId(ServerConnector connector) {
if (connector == null) { if (connector == null) {
return null; return null;
} }
return connector.getId();
return connector.getConnectorId();
} }


@Deprecated @Deprecated
VConsole.error("WARN: Trying to unregister null connector"); VConsole.error("WARN: Trying to unregister null connector");
return; return;
} }
String id = connector.getId();
String id = connector.getConnectorId();
Widget widget = null; Widget widget = null;
if (connector instanceof ComponentConnector) { if (connector instanceof ComponentConnector) {
widget = ((ComponentConnector) connector).getWidget(); widget = ((ComponentConnector) connector).getWidget();
for (ServerConnector connector : getConnectors()) { for (ServerConnector connector : getConnectors()) {
if (connector instanceof ComponentConnector) { if (connector instanceof ComponentConnector) {
ComponentConnector componentConnector = (ComponentConnector) connector; ComponentConnector componentConnector = (ComponentConnector) connector;
if (!unregistryBag.contains(connector.getId())) {
if (!unregistryBag.contains(connector.getConnectorId())) {
result.add(componentConnector); result.add(componentConnector);
} }
} }

+ 6
- 6
src/com/vaadin/terminal/gwt/client/LayoutManager.java View File

if (measuredSize.isWidthNeedsUpdate()) { if (measuredSize.isWidthNeedsUpdate()) {
ownerSize.setWidthNeedsUpdate(); ownerSize.setWidthNeedsUpdate();
} }
measuredSize.addDependent(owner.getId());
measuredSize.addDependent(owner.getConnectorId());
} }


private MeasuredSize ensureMeasured(Element element) { private MeasuredSize ensureMeasured(Element element) {
if (measuredSize == null) { if (measuredSize == null) {
return; return;
} }
measuredSize.removeDependent(owner.getId());
measuredSize.removeDependent(owner.getConnectorId());
if (!needsMeasure(element)) { if (!needsMeasure(element)) {
nonPaintableElements.remove(element); nonPaintableElements.remove(element);
setMeasuredSize(element, null); setMeasuredSize(element, null);


if (measuredSize.isHeightNeedsUpdate()) { if (measuredSize.isHeightNeedsUpdate()) {
if (managed) { if (managed) {
needsHeightUpdate.add(paintable.getId());
needsHeightUpdate.add(paintable.getConnectorId());
} }
if (!paintable.isRelativeHeight() && managedParent) { if (!paintable.isRelativeHeight() && managedParent) {
needsHeightUpdate.add(parent.getId());
needsHeightUpdate.add(parent.getConnectorId());
} }
} }
if (measuredSize.isWidthNeedsUpdate()) { if (measuredSize.isWidthNeedsUpdate()) {
if (managed) { if (managed) {
needsWidthUpdate.add(paintable.getId());
needsWidthUpdate.add(paintable.getConnectorId());
} }
if (!paintable.isRelativeWidth() && managedParent) { if (!paintable.isRelativeWidth() && managedParent) {
needsWidthUpdate.add(parent.getId());
needsWidthUpdate.add(parent.getConnectorId());
} }
} }
measuredSize.clearDirtyState(); measuredSize.clearDirtyState();

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

* @version @VERSION@ * @version @VERSION@
* @since 7.0.0 * @since 7.0.0
*/ */
public interface ServerConnector {
public interface ServerConnector extends Connector {
/** /**
* TODO * TODO
* *
*/ */
public void updateFromUIDL(UIDL uidl, ApplicationConnection client); public void updateFromUIDL(UIDL uidl, ApplicationConnection client);


/**
* Gets the current shared state of the connector.
*
* @return state
*/
public SharedState getState();

/** /**
* Sets a new state for the connector. * Sets a new state for the connector.
* *
@Deprecated @Deprecated
public void setState(SharedState state); public void setState(SharedState state);


/**
* Returns the id for this connector. This must always be what has been set
* in {@link #doInit(String, ApplicationConnection)} and must never change.
*
* @return The id for the connector.
*/
public String getId();

/** /**
* Gets ApplicationConnection instance that created this connector. * Gets ApplicationConnection instance that created this connector.
* *

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

ConnectorMap paintableMap = ConnectorMap.get(getConnection()); ConnectorMap paintableMap = ConnectorMap.get(getConnection());
// register the listened events by the server-side to the event-handler // register the listened events by the server-side to the event-handler
// of the component // of the component
paintableMap.registerEventListenersFromUIDL(getId(), uidl);
paintableMap.registerEventListenersFromUIDL(getConnectorId(), uidl);


// Visibility // Visibility
setVisible(!uidl.getBooleanAttribute("invisible"), uidl); setVisible(!uidl.getBooleanAttribute("invisible"), uidl);
w = componentState.getWidth(); w = componentState.getWidth();
} else { } else {
// TODO move logging to VUIDLBrowser and VDebugConsole // TODO move logging to VUIDLBrowser and VDebugConsole
VConsole.log("No state for paintable " + getId()
VConsole.log("No state for paintable " + getConnectorId()
+ " in VAbstractPaintableWidget.updateComponentSize()"); + " in VAbstractPaintableWidget.updateComponentSize()");
} }


* GWT.create(). * GWT.create().
*/ */
protected <T extends ServerRpc> T initRPC(T clientToServerRpc) { protected <T extends ServerRpc> T initRPC(T clientToServerRpc) {
((InitializableClientToServerRpc) clientToServerRpc).initRpc(getId(),
((InitializableClientToServerRpc) clientToServerRpc).initRpc(getConnectorId(),
getConnection()); getConnection());
return clientToServerRpc; return clientToServerRpc;
} }

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

* *
* @see com.vaadin.terminal.gwt.client.Connector#getId() * @see com.vaadin.terminal.gwt.client.Connector#getId()
*/ */
public String getId() {
public String getConnectorId() {
return id; return id;
} }



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

} }
layout.addOrMove(slot, currentIndex++); layout.addOrMove(slot, currentIndex++);


String pid = child.getId();
String pid = child.getConnectorId();


AlignmentInfo alignment; AlignmentInfo alignment;
if (alignments.containsKey(pid)) { if (alignments.containsKey(pid)) {

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

if (childUidl != null) { if (childUidl != null) {
if (getWidget().shortcutHandler == null) { if (getWidget().shortcutHandler == null) {
getWidget().shortcutHandler = new ShortcutActionHandler( getWidget().shortcutHandler = new ShortcutActionHandler(
getId(), client);
getConnectorId(), client);
getWidget().keyDownRegistration = getWidget() getWidget().keyDownRegistration = getWidget()
.addDomHandler(getWidget(), KeyDownEvent.getType()); .addDomHandler(getWidget(), KeyDownEvent.getType());
} }

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

if (childUidl.getTag().equals("actions")) { if (childUidl.getTag().equals("actions")) {
if (getWidget().shortcutHandler == null) { if (getWidget().shortcutHandler == null) {
getWidget().shortcutHandler = new ShortcutActionHandler( getWidget().shortcutHandler = new ShortcutActionHandler(
getId(), client);
getConnectorId(), client);
} }
getWidget().shortcutHandler.updateActionMap(childUidl); getWidget().shortcutHandler.updateActionMap(childUidl);
} }

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

ConnectorMap paintableMap = ConnectorMap.get(getConnection()); ConnectorMap paintableMap = ConnectorMap.get(getConnection());
// register the listened events by the server-side to the event-handler // register the listened events by the server-side to the event-handler
// of the component // of the component
paintableMap.registerEventListenersFromUIDL(getId(), uidl);
paintableMap.registerEventListenersFromUIDL(getConnectorId(), uidl);


getWidget().rendering = true; getWidget().rendering = true;
getWidget().id = getId();
getWidget().id = getConnectorId();
boolean firstPaint = getWidget().connection == null; boolean firstPaint = getWidget().connection == null;
getWidget().connection = client; getWidget().connection = client;



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



@Override @Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
getWidget().id = getId();
getWidget().id = getConnectorId();
getWidget().client = client; getWidget().client = client;


// Workaround needed for Testing Tools (GWT generates window DOM // Workaround needed for Testing Tools (GWT generates window DOM
// slightly different in different browsers). // slightly different in different browsers).
DOM.setElementProperty(getWidget().closeBox, "id", getId()
DOM.setElementProperty(getWidget().closeBox, "id", getConnectorId()
+ "_window_close"); + "_window_close");


if (uidl.hasAttribute("invisible")) { if (uidl.hasAttribute("invisible")) {
if (childUidl.getTag().equals("actions")) { if (childUidl.getTag().equals("actions")) {
if (getWidget().shortcutHandler == null) { if (getWidget().shortcutHandler == null) {
getWidget().shortcutHandler = new ShortcutActionHandler( getWidget().shortcutHandler = new ShortcutActionHandler(
getId(), client);
getConnectorId(), client);
} }
getWidget().shortcutHandler.updateActionMap(childUidl); getWidget().shortcutHandler.updateActionMap(childUidl);
} }

Loading…
Cancel
Save