Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright 2011 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.terminal.gwt.client;
  17. import java.util.Collection;
  18. import java.util.List;
  19. import com.google.gwt.event.shared.GwtEvent;
  20. import com.google.web.bindery.event.shared.HandlerRegistration;
  21. import com.vaadin.shared.Connector;
  22. import com.vaadin.shared.communication.ClientRpc;
  23. import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
  24. /**
  25. * Interface implemented by all client side classes that can be communicate with
  26. * the server. Classes implementing this interface are initialized by the
  27. * framework when needed and have the ability to communicate with the server.
  28. *
  29. * @author Vaadin Ltd
  30. * @since 7.0.0
  31. */
  32. public interface ServerConnector extends Connector {
  33. /**
  34. * Gets ApplicationConnection instance that created this connector.
  35. *
  36. * @return The ApplicationConnection as set by
  37. * {@link #doInit(String, ApplicationConnection)}
  38. */
  39. public ApplicationConnection getConnection();
  40. /**
  41. * Tests whether the connector is enabled or not. This method checks that
  42. * the connector is enabled in context, i.e. if the parent connector is
  43. * disabled, this method must return false.
  44. *
  45. * @return true if the connector is enabled, false otherwise
  46. */
  47. public boolean isEnabled();
  48. /**
  49. *
  50. * Called once by the framework to initialize the connector.
  51. * <p>
  52. * Note that the shared state is not yet available at this point nor any
  53. * hierarchy information.
  54. */
  55. public void doInit(String connectorId, ApplicationConnection connection);
  56. /**
  57. * For internal use by the framework: returns the registered RPC
  58. * implementations for an RPC interface identifier.
  59. *
  60. * TODO interface identifier type or format may change
  61. *
  62. * @param rpcInterfaceId
  63. * RPC interface identifier: fully qualified interface type name
  64. * @return RPC interface implementations registered for an RPC interface,
  65. * not null
  66. */
  67. public <T extends ClientRpc> Collection<T> getRpcImplementations(
  68. String rpcInterfaceId);
  69. /**
  70. * Adds a handler that is called whenever some part of the state has been
  71. * updated by the server.
  72. *
  73. * @param handler
  74. * The handler that should be added.
  75. * @return A handler registration reference that can be used to unregister
  76. * the handler
  77. */
  78. public HandlerRegistration addStateChangeHandler(StateChangeHandler handler);
  79. /**
  80. * Sends the given event to all registered handlers.
  81. *
  82. * @param event
  83. * The event to send.
  84. */
  85. public void fireEvent(GwtEvent<?> event);
  86. /**
  87. * Event called when connector has been unregistered.
  88. */
  89. public void onUnregister();
  90. /**
  91. * Returns the parent of this connector. Can be null for only the root
  92. * connector.
  93. *
  94. * @return The parent of this connector, as set by
  95. * {@link #setParent(ServerConnector)}.
  96. */
  97. @Override
  98. public ServerConnector getParent();
  99. /**
  100. * Sets the parent for this connector. This method should only be called by
  101. * the framework to ensure that the connector hierarchy on the client side
  102. * and the server side are in sync.
  103. * <p>
  104. * Note that calling this method does not fire a
  105. * {@link ConnectorHierarchyChangeEvent}. The event is fired only when the
  106. * whole hierarchy has been updated.
  107. *
  108. * @param parent
  109. * The new parent of the connector
  110. */
  111. public void setParent(ServerConnector parent);
  112. public void updateEnabledState(boolean enabledState);
  113. public void setChildren(List<ServerConnector> children);
  114. public List<ServerConnector> getChildren();
  115. }