You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractComponent.java 45KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. /*
  2. * Copyright 2000-2016 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.ui;
  17. import java.lang.reflect.Method;
  18. import java.util.ArrayList;
  19. import java.util.Arrays;
  20. import java.util.Collection;
  21. import java.util.HashSet;
  22. import java.util.Iterator;
  23. import java.util.List;
  24. import java.util.Locale;
  25. import java.util.Map;
  26. import java.util.Map.Entry;
  27. import java.util.Objects;
  28. import java.util.Set;
  29. import java.util.StringTokenizer;
  30. import org.jsoup.nodes.Attribute;
  31. import org.jsoup.nodes.Attributes;
  32. import org.jsoup.nodes.Element;
  33. import com.vaadin.data.HasValue;
  34. import com.vaadin.event.ActionManager;
  35. import com.vaadin.event.ConnectorActionManager;
  36. import com.vaadin.event.ContextClickEvent;
  37. import com.vaadin.event.ContextClickEvent.ContextClickListener;
  38. import com.vaadin.event.ContextClickEvent.ContextClickNotifier;
  39. import com.vaadin.event.ShortcutListener;
  40. import com.vaadin.server.AbstractClientConnector;
  41. import com.vaadin.server.ClientConnector;
  42. import com.vaadin.server.ComponentSizeValidator;
  43. import com.vaadin.server.ErrorMessage;
  44. import com.vaadin.server.Extension;
  45. import com.vaadin.server.Resource;
  46. import com.vaadin.server.Responsive;
  47. import com.vaadin.server.SizeWithUnit;
  48. import com.vaadin.server.Sizeable;
  49. import com.vaadin.server.UserError;
  50. import com.vaadin.server.VaadinSession;
  51. import com.vaadin.shared.AbstractComponentState;
  52. import com.vaadin.shared.AbstractFieldState;
  53. import com.vaadin.shared.ComponentConstants;
  54. import com.vaadin.shared.ContextClickRpc;
  55. import com.vaadin.shared.EventId;
  56. import com.vaadin.shared.MouseEventDetails;
  57. import com.vaadin.shared.Registration;
  58. import com.vaadin.shared.ui.ComponentStateUtil;
  59. import com.vaadin.shared.ui.ContentMode;
  60. import com.vaadin.shared.ui.ErrorLevel;
  61. import com.vaadin.shared.util.SharedUtil;
  62. import com.vaadin.ui.declarative.DesignAttributeHandler;
  63. import com.vaadin.ui.declarative.DesignContext;
  64. import com.vaadin.util.ReflectTools;
  65. /**
  66. * An abstract class that defines default implementation for the
  67. * {@link Component} interface. Basic UI components that are not derived from an
  68. * external component can inherit this class to easily qualify as Vaadin
  69. * components. Most components in Vaadin do just that.
  70. *
  71. * @author Vaadin Ltd.
  72. * @since 3.0
  73. */
  74. @SuppressWarnings("serial")
  75. public abstract class AbstractComponent extends AbstractClientConnector
  76. implements Component, ContextClickNotifier {
  77. /* Private members */
  78. /**
  79. * Application specific data object. The component does not use or modify
  80. * this.
  81. */
  82. private Object applicationData;
  83. /**
  84. * The internal error message of the component.
  85. */
  86. private ErrorMessage componentError = null;
  87. /**
  88. * Locale of this component.
  89. */
  90. private Locale locale;
  91. /**
  92. * The component should receive focus (if {@link Focusable}) when attached.
  93. */
  94. private boolean delayedFocus;
  95. /* Sizeable fields */
  96. private float width = SIZE_UNDEFINED;
  97. private float height = SIZE_UNDEFINED;
  98. private Unit widthUnit = Unit.PIXELS;
  99. private Unit heightUnit = Unit.PIXELS;
  100. /**
  101. * Keeps track of the Actions added to this component; the actual
  102. * handling/notifying is delegated, usually to the containing window.
  103. */
  104. private ConnectorActionManager actionManager;
  105. private boolean visible = true;
  106. private HasComponents parent;
  107. protected static final String DESIGN_ATTR_PLAIN_TEXT = "plain-text";
  108. /* Constructor */
  109. /**
  110. * Constructs a new Component.
  111. */
  112. public AbstractComponent() {
  113. // ComponentSizeValidator.setCreationLocation(this);
  114. }
  115. /* Get/Set component properties */
  116. /*
  117. * (non-Javadoc)
  118. *
  119. * @see com.vaadin.ui.Component#setId(java.lang.String)
  120. */
  121. @Override
  122. public void setId(String id) {
  123. getState().id = id;
  124. }
  125. /*
  126. * (non-Javadoc)
  127. *
  128. * @see com.vaadin.ui.Component#getId()
  129. */
  130. @Override
  131. public String getId() {
  132. return getState(false).id;
  133. }
  134. /**
  135. * @deprecated As of 7.0. Use {@link #setId(String)}
  136. */
  137. @Deprecated
  138. public void setDebugId(String id) {
  139. setId(id);
  140. }
  141. /**
  142. * @deprecated As of 7.0. Use {@link #getId()}
  143. */
  144. @Deprecated
  145. public String getDebugId() {
  146. return getId();
  147. }
  148. /*
  149. * Gets the component's style. Don't add a JavaDoc comment here, we use the
  150. * default documentation from implemented interface.
  151. */
  152. @Override
  153. public String getStyleName() {
  154. String s = "";
  155. if (ComponentStateUtil.hasStyles(getState(false))) {
  156. for (final Iterator<String> it = getState(false).styles
  157. .iterator(); it.hasNext();) {
  158. s += it.next();
  159. if (it.hasNext()) {
  160. s += " ";
  161. }
  162. }
  163. }
  164. return s;
  165. }
  166. /*
  167. * Sets the component's style. Don't add a JavaDoc comment here, we use the
  168. * default documentation from implemented interface.
  169. */
  170. @Override
  171. public void setStyleName(String style) {
  172. if (style == null || style.isEmpty()) {
  173. getState().styles = null;
  174. return;
  175. }
  176. if (getState().styles == null) {
  177. getState().styles = new ArrayList<>();
  178. }
  179. List<String> styles = getState().styles;
  180. styles.clear();
  181. StringTokenizer tokenizer = new StringTokenizer(style, " ");
  182. while (tokenizer.hasMoreTokens()) {
  183. styles.add(tokenizer.nextToken());
  184. }
  185. }
  186. @Override
  187. public void setPrimaryStyleName(String style) {
  188. getState().primaryStyleName = style;
  189. }
  190. @Override
  191. public String getPrimaryStyleName() {
  192. return getState(false).primaryStyleName;
  193. }
  194. @Override
  195. public void addStyleName(String style) {
  196. if (style == null || style.isEmpty()) {
  197. return;
  198. }
  199. if (style.contains(" ")) {
  200. // Split space separated style names and add them one by one.
  201. StringTokenizer tokenizer = new StringTokenizer(style, " ");
  202. while (tokenizer.hasMoreTokens()) {
  203. addStyleName(tokenizer.nextToken());
  204. }
  205. return;
  206. }
  207. if (getState().styles == null) {
  208. getState().styles = new ArrayList<>();
  209. }
  210. List<String> styles = getState().styles;
  211. if (!styles.contains(style)) {
  212. styles.add(style);
  213. }
  214. }
  215. @Override
  216. public void removeStyleName(String style) {
  217. if (ComponentStateUtil.hasStyles(getState())) {
  218. StringTokenizer tokenizer = new StringTokenizer(style, " ");
  219. while (tokenizer.hasMoreTokens()) {
  220. getState().styles.remove(tokenizer.nextToken());
  221. }
  222. }
  223. }
  224. /**
  225. * Adds or removes a style name. Multiple styles can be specified as a
  226. * space-separated list of style names.
  227. *
  228. * If the {@code add} parameter is true, the style name is added to the
  229. * component. If the {@code add} parameter is false, the style name is
  230. * removed from the component.
  231. * <p>
  232. * Functionally this is equivalent to using {@link #addStyleName(String)} or
  233. * {@link #removeStyleName(String)}
  234. *
  235. * @since 7.5
  236. * @param style
  237. * the style name to be added or removed
  238. * @param add
  239. * <code>true</code> to add the given style, <code>false</code>
  240. * to remove it
  241. * @see #addStyleName(String)
  242. * @see #removeStyleName(String)
  243. */
  244. public void setStyleName(String style, boolean add) {
  245. if (add) {
  246. addStyleName(style);
  247. } else {
  248. removeStyleName(style);
  249. }
  250. }
  251. /*
  252. * Get's the component's caption. Don't add a JavaDoc comment here, we use
  253. * the default documentation from implemented interface.
  254. */
  255. @Override
  256. public String getCaption() {
  257. return getState(false).caption;
  258. }
  259. @Override
  260. public void setCaption(String caption) {
  261. getState().caption = caption;
  262. }
  263. /**
  264. * Sets whether the caption is rendered as HTML.
  265. * <p>
  266. * If set to true, the captions are rendered in the browser as HTML and the
  267. * developer is responsible for ensuring no harmful HTML is used. If set to
  268. * false, the caption is rendered in the browser as plain text.
  269. * <p>
  270. * The default is false, i.e. to render that caption as plain text.
  271. *
  272. * @param captionAsHtml
  273. * true if the captions are rendered as HTML, false if rendered
  274. * as plain text
  275. */
  276. public void setCaptionAsHtml(boolean captionAsHtml) {
  277. getState().captionAsHtml = captionAsHtml;
  278. }
  279. /**
  280. * Checks whether captions are rendered as HTML
  281. * <p>
  282. * The default is false, i.e. to render that caption as plain text.
  283. *
  284. * @return true if the captions are rendered as HTML, false if rendered as
  285. * plain text
  286. */
  287. public boolean isCaptionAsHtml() {
  288. return getState(false).captionAsHtml;
  289. }
  290. /*
  291. * Don't add a JavaDoc comment here, we use the default documentation from
  292. * implemented interface.
  293. */
  294. @Override
  295. public Locale getLocale() {
  296. if (locale != null) {
  297. return locale;
  298. }
  299. HasComponents parent = getParent();
  300. if (parent != null) {
  301. return parent.getLocale();
  302. }
  303. final VaadinSession session = getSession();
  304. if (session != null) {
  305. return session.getLocale();
  306. }
  307. return null;
  308. }
  309. /**
  310. * Sets the locale of this component.
  311. *
  312. * <pre>
  313. * // Component for which the locale is meaningful
  314. * InlineDateField date = new InlineDateField(&quot;Datum&quot;);
  315. *
  316. * // German language specified with ISO 639-1 language
  317. * // code and ISO 3166-1 alpha-2 country code.
  318. * date.setLocale(new Locale(&quot;de&quot;, &quot;DE&quot;));
  319. *
  320. * date.setResolution(DateField.RESOLUTION_DAY);
  321. * layout.addComponent(date);
  322. * </pre>
  323. *
  324. *
  325. * @param locale
  326. * the locale to become this component's locale.
  327. */
  328. public void setLocale(Locale locale) {
  329. this.locale = locale;
  330. if (locale != null && isAttached()) {
  331. getUI().getLocaleService().addLocale(locale);
  332. }
  333. markAsDirty();
  334. }
  335. /*
  336. * Gets the component's icon resource. Don't add a JavaDoc comment here, we
  337. * use the default documentation from implemented interface.
  338. */
  339. @Override
  340. public Resource getIcon() {
  341. return getResource(ComponentConstants.ICON_RESOURCE);
  342. }
  343. /**
  344. * Sets the component's icon.
  345. *
  346. * @param icon
  347. * the icon to be shown with the component's caption.
  348. */
  349. @Override
  350. public void setIcon(Resource icon) {
  351. setResource(ComponentConstants.ICON_RESOURCE, icon);
  352. }
  353. /*
  354. * (non-Javadoc)
  355. *
  356. * @see com.vaadin.ui.Component#isEnabled()
  357. */
  358. @Override
  359. public boolean isEnabled() {
  360. return getState(false).enabled;
  361. }
  362. /*
  363. * (non-Javadoc)
  364. *
  365. * @see com.vaadin.ui.Component#setEnabled(boolean)
  366. */
  367. @Override
  368. public void setEnabled(boolean enabled) {
  369. getState().enabled = enabled;
  370. }
  371. /*
  372. * (non-Javadoc)
  373. *
  374. * @see com.vaadin.client.Connector#isConnectorEnabled()
  375. */
  376. @Override
  377. public boolean isConnectorEnabled() {
  378. if (!isVisible()) {
  379. return false;
  380. } else if (!isEnabled()) {
  381. return false;
  382. } else if (!super.isConnectorEnabled()) {
  383. return false;
  384. }
  385. return !(getParent() instanceof SelectiveRenderer)
  386. || ((SelectiveRenderer) getParent()).isRendered(this);
  387. }
  388. /*
  389. * (non-Javadoc)
  390. *
  391. * @see com.vaadin.ui.Component#isVisible()
  392. */
  393. @Override
  394. public boolean isVisible() {
  395. return visible;
  396. }
  397. /*
  398. * (non-Javadoc)
  399. *
  400. * @see com.vaadin.ui.Component#setVisible(boolean)
  401. */
  402. @Override
  403. public void setVisible(boolean visible) {
  404. if (isVisible() == visible) {
  405. return;
  406. }
  407. this.visible = visible;
  408. if (visible) {
  409. /*
  410. * If the visibility state is toggled from invisible to visible it
  411. * affects all children (the whole hierarchy) in addition to this
  412. * component.
  413. */
  414. markAsDirtyRecursive();
  415. }
  416. if (getParent() != null) {
  417. // Must always repaint the parent (at least the hierarchy) when
  418. // visibility of a child component changes.
  419. getParent().markAsDirty();
  420. }
  421. }
  422. /*
  423. * (non-Javadoc)
  424. *
  425. * @see com.vaadin.ui.Component#getDescription()
  426. */
  427. @Override
  428. public String getDescription() {
  429. return getState(false).description;
  430. }
  431. /**
  432. * Sets the component's description. See {@link #getDescription()} for more
  433. * information on what the description is.
  434. *
  435. * @see #setDescription(String, ContentMode)
  436. * @param description
  437. * the new description string for the component.
  438. */
  439. public void setDescription(String description) {
  440. setDescription(description, ContentMode.PREFORMATTED);
  441. }
  442. /**
  443. * Sets the component's description using given content {@code mode}. See
  444. * {@link #getDescription()} for more information on what the description
  445. * is.
  446. * <p>
  447. * If the content {@code mode} is {@literal ContentMode.HTML} the
  448. * description is displayed as HTML in tooltips or directly in certain
  449. * components so care should be taken to avoid creating the possibility for
  450. * HTML injection and possibly XSS vulnerabilities.
  451. *
  452. * @param description
  453. * the new description string for the component.
  454. * @param mode
  455. * the content mode for the description
  456. * @since 8.0
  457. */
  458. public void setDescription(String description, ContentMode mode) {
  459. getState().description = description;
  460. getState().descriptionContentMode = mode;
  461. }
  462. /*
  463. * Gets the component's parent component. Don't add a JavaDoc comment here,
  464. * we use the default documentation from implemented interface.
  465. */
  466. @Override
  467. public HasComponents getParent() {
  468. return parent;
  469. }
  470. @Override
  471. public void setParent(HasComponents parent) {
  472. // If the parent is not changed, don't do anything
  473. if (parent == null ? this.parent == null : parent.equals(this.parent)) {
  474. return;
  475. }
  476. if (parent != null && this.parent != null) {
  477. throw new IllegalStateException(
  478. getClass().getName() + " already has a parent.");
  479. }
  480. ClientConnector oldParent = getParent();
  481. // Send a detach event if the component is currently attached
  482. if (isAttached()) {
  483. detach();
  484. }
  485. // Connect to new parent
  486. this.parent = parent;
  487. // Send attach event if the component is now attached
  488. if (isAttached()) {
  489. attach();
  490. }
  491. if (oldParent != null) {
  492. oldParent.markAsDirty();
  493. }
  494. }
  495. /**
  496. * Returns the closest ancestor with the given type.
  497. * <p>
  498. * To find the Window that contains the component, use {@code Window w =
  499. * getParent(Window.class);}
  500. * </p>
  501. *
  502. * @param <T>
  503. * The type of the ancestor
  504. * @param parentType
  505. * The ancestor class we are looking for
  506. * @return The first ancestor that can be assigned to the given class. Null
  507. * if no ancestor with the correct type could be found.
  508. */
  509. public <T extends HasComponents> T findAncestor(Class<T> parentType) {
  510. HasComponents p = getParent();
  511. while (p != null) {
  512. if (parentType.isAssignableFrom(p.getClass())) {
  513. return parentType.cast(p);
  514. }
  515. p = p.getParent();
  516. }
  517. return null;
  518. }
  519. /**
  520. * Gets the error message for this component.
  521. *
  522. * @return ErrorMessage containing the description of the error state of the
  523. * component or null, if the component contains no errors. Extending
  524. * classes should override this method if they support other error
  525. * message types such as validation errors or buffering errors. The
  526. * returned error message contains information about all the errors.
  527. */
  528. public ErrorMessage getErrorMessage() {
  529. return componentError;
  530. }
  531. /**
  532. * Gets the component's error message.
  533. *
  534. * @link Terminal.ErrorMessage#ErrorMessage(String, int)
  535. *
  536. * @return the component's error message.
  537. */
  538. public ErrorMessage getComponentError() {
  539. return componentError;
  540. }
  541. /**
  542. * Sets the component's error message. The message may contain certain XML
  543. * tags, for more information see
  544. *
  545. * @link Component.ErrorMessage#ErrorMessage(String, int)
  546. *
  547. * @param componentError
  548. * the new <code>ErrorMessage</code> of the component.
  549. */
  550. public void setComponentError(ErrorMessage componentError) {
  551. this.componentError = componentError;
  552. fireComponentErrorEvent();
  553. markAsDirty();
  554. }
  555. /*
  556. * Notify the component that it's attached to a window. Don't add a JavaDoc
  557. * comment here, we use the default documentation from implemented
  558. * interface.
  559. */
  560. @Override
  561. public void attach() {
  562. super.attach();
  563. if (delayedFocus) {
  564. focus();
  565. }
  566. setActionManagerViewer();
  567. if (locale != null) {
  568. getUI().getLocaleService().addLocale(locale);
  569. }
  570. }
  571. /*
  572. * Detach the component from application. Don't add a JavaDoc comment here,
  573. * we use the default documentation from implemented interface.
  574. */
  575. @Override
  576. public void detach() {
  577. super.detach();
  578. if (actionManager != null) {
  579. // Remove any existing viewer. UI cast is just to make the
  580. // compiler happy
  581. actionManager.setViewer((UI) null);
  582. }
  583. }
  584. /**
  585. * Sets the focus for this component if the component is {@link Focusable}.
  586. */
  587. protected void focus() {
  588. if (this instanceof Focusable) {
  589. final VaadinSession session = getSession();
  590. if (session != null) {
  591. getUI().setFocusedComponent((Focusable) this);
  592. delayedFocus = false;
  593. } else {
  594. delayedFocus = true;
  595. }
  596. }
  597. }
  598. /**
  599. * Build CSS compatible string representation of height.
  600. *
  601. * @return CSS height
  602. */
  603. private String getCSSHeight() {
  604. return getHeight() + getHeightUnits().getSymbol();
  605. }
  606. /**
  607. * Build CSS compatible string representation of width.
  608. *
  609. * @return CSS width
  610. */
  611. private String getCSSWidth() {
  612. return getWidth() + getWidthUnits().getSymbol();
  613. }
  614. /**
  615. * Returns the shared state bean with information to be sent from the server
  616. * to the client.
  617. *
  618. * Subclasses should override this method and set any relevant fields of the
  619. * state returned by super.getState().
  620. *
  621. * @since 7.0
  622. *
  623. * @return updated component shared state
  624. */
  625. @Override
  626. protected AbstractComponentState getState() {
  627. return (AbstractComponentState) super.getState();
  628. }
  629. @Override
  630. protected AbstractComponentState getState(boolean markAsDirty) {
  631. return (AbstractComponentState) super.getState(markAsDirty);
  632. }
  633. @Override
  634. public void beforeClientResponse(boolean initial) {
  635. super.beforeClientResponse(initial);
  636. // TODO This logic should be on the client side and the state should
  637. // simply be a data object with "width" and "height".
  638. if (getHeight() >= 0 && (getHeightUnits() != Unit.PERCENTAGE
  639. || ComponentSizeValidator.parentCanDefineHeight(this))) {
  640. getState().height = "" + getCSSHeight();
  641. } else {
  642. getState().height = "";
  643. }
  644. if (getWidth() >= 0 && (getWidthUnits() != Unit.PERCENTAGE
  645. || ComponentSizeValidator.parentCanDefineWidth(this))) {
  646. getState().width = "" + getCSSWidth();
  647. } else {
  648. getState().width = "";
  649. }
  650. ErrorMessage error = getErrorMessage();
  651. if (null != error) {
  652. getState().errorMessage = error.getFormattedHtmlMessage();
  653. getState().errorLevel = error.getErrorLevel();
  654. } else {
  655. getState().errorMessage = null;
  656. getState().errorLevel = null;
  657. }
  658. }
  659. /* General event framework */
  660. private static final Method COMPONENT_EVENT_METHOD = ReflectTools
  661. .findMethod(Component.Listener.class, "componentEvent",
  662. Component.Event.class);
  663. /* Component event framework */
  664. /*
  665. * Registers a new listener to listen events generated by this component.
  666. * Don't add a JavaDoc comment here, we use the default documentation from
  667. * implemented interface.
  668. */
  669. @Override
  670. public Registration addListener(Component.Listener listener) {
  671. return addListener(Component.Event.class, listener,
  672. COMPONENT_EVENT_METHOD);
  673. }
  674. @Override
  675. @Deprecated
  676. public void removeListener(Component.Listener listener) {
  677. removeListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD);
  678. }
  679. /**
  680. * Emits the component event. It is transmitted to all registered listeners
  681. * interested in such events.
  682. */
  683. protected void fireComponentEvent() {
  684. fireEvent(new Component.Event(this));
  685. }
  686. /**
  687. * Emits the component error event. It is transmitted to all registered
  688. * listeners interested in such events.
  689. */
  690. protected void fireComponentErrorEvent() {
  691. fireEvent(new Component.ErrorEvent(getComponentError(), this));
  692. }
  693. /**
  694. * Sets the data object, that can be used for any application specific data.
  695. * The component does not use or modify this data.
  696. *
  697. * @param data
  698. * the Application specific data.
  699. * @since 3.1
  700. */
  701. public void setData(Object data) {
  702. applicationData = data;
  703. }
  704. /**
  705. * Gets the application specific data. See {@link #setData(Object)}.
  706. *
  707. * @return the Application specific data set with setData function.
  708. * @since 3.1
  709. */
  710. public Object getData() {
  711. return applicationData;
  712. }
  713. /* Sizeable and other size related methods */
  714. /*
  715. * (non-Javadoc)
  716. *
  717. * @see com.vaadin.Sizeable#getHeight()
  718. */
  719. @Override
  720. public float getHeight() {
  721. return height;
  722. }
  723. /*
  724. * (non-Javadoc)
  725. *
  726. * @see com.vaadin.server.Sizeable#getHeightUnits()
  727. */
  728. @Override
  729. public Unit getHeightUnits() {
  730. return heightUnit;
  731. }
  732. /*
  733. * (non-Javadoc)
  734. *
  735. * @see com.vaadin.server.Sizeable#getWidth()
  736. */
  737. @Override
  738. public float getWidth() {
  739. return width;
  740. }
  741. /*
  742. * (non-Javadoc)
  743. *
  744. * @see com.vaadin.server.Sizeable#getWidthUnits()
  745. */
  746. @Override
  747. public Unit getWidthUnits() {
  748. return widthUnit;
  749. }
  750. /*
  751. * (non-Javadoc)
  752. *
  753. * @see com.vaadin.server.Sizeable#setHeight(float, Unit)
  754. */
  755. @Override
  756. public void setHeight(float height, Unit unit) {
  757. if (unit == null) {
  758. throw new IllegalArgumentException("Unit can not be null");
  759. }
  760. this.height = height;
  761. heightUnit = unit;
  762. markAsDirty();
  763. // ComponentSizeValidator.setHeightLocation(this);
  764. }
  765. /*
  766. * (non-Javadoc)
  767. *
  768. * @see com.vaadin.server.Sizeable#setSizeFull()
  769. */
  770. @Override
  771. public void setSizeFull() {
  772. setWidth(100, Unit.PERCENTAGE);
  773. setHeight(100, Unit.PERCENTAGE);
  774. }
  775. /*
  776. * (non-Javadoc)
  777. *
  778. * @see com.vaadin.server.Sizeable#setSizeUndefined()
  779. */
  780. @Override
  781. public void setSizeUndefined() {
  782. setWidthUndefined();
  783. setHeightUndefined();
  784. }
  785. /*
  786. * (non-Javadoc)
  787. *
  788. * @see com.vaadin.server.Sizeable#setWidthUndefined()
  789. */
  790. @Override
  791. public void setWidthUndefined() {
  792. setWidth(-1, Unit.PIXELS);
  793. }
  794. /*
  795. * (non-Javadoc)
  796. *
  797. * @see com.vaadin.server.Sizeable#setHeightUndefined()
  798. */
  799. @Override
  800. public void setHeightUndefined() {
  801. setHeight(-1, Unit.PIXELS);
  802. }
  803. /*
  804. * (non-Javadoc)
  805. *
  806. * @see com.vaadin.server.Sizeable#setWidth(float, Unit)
  807. */
  808. @Override
  809. public void setWidth(float width, Unit unit) {
  810. if (unit == null) {
  811. throw new IllegalArgumentException("Unit can not be null");
  812. }
  813. this.width = width;
  814. widthUnit = unit;
  815. markAsDirty();
  816. // ComponentSizeValidator.setWidthLocation(this);
  817. }
  818. /*
  819. * (non-Javadoc)
  820. *
  821. * @see com.vaadin.server.Sizeable#setWidth(java.lang.String)
  822. */
  823. @Override
  824. public void setWidth(String width) {
  825. SizeWithUnit size = SizeWithUnit.parseStringSize(width);
  826. if (size != null) {
  827. setWidth(size.getSize(), size.getUnit());
  828. } else {
  829. setWidth(-1, Unit.PIXELS);
  830. }
  831. }
  832. /*
  833. * (non-Javadoc)
  834. *
  835. * @see com.vaadin.server.Sizeable#setHeight(java.lang.String)
  836. */
  837. @Override
  838. public void setHeight(String height) {
  839. SizeWithUnit size = SizeWithUnit.parseStringSize(height);
  840. if (size != null) {
  841. setHeight(size.getSize(), size.getUnit());
  842. } else {
  843. setHeight(-1, Unit.PIXELS);
  844. }
  845. }
  846. /*
  847. * (non-Javadoc)
  848. *
  849. * @see com.vaadin.ui.Component#readDesign(org.jsoup.nodes.Element,
  850. * com.vaadin.ui.declarative.DesignContext)
  851. */
  852. @Override
  853. public void readDesign(Element design, DesignContext designContext) {
  854. Attributes attr = design.attributes();
  855. // handle default attributes
  856. for (String attribute : getDefaultAttributes()) {
  857. if (design.hasAttr(attribute)) {
  858. DesignAttributeHandler.assignValue(this, attribute,
  859. design.attr(attribute));
  860. }
  861. }
  862. // handle locale
  863. if (attr.hasKey("locale")) {
  864. setLocale(getLocaleFromString(attr.get("locale")));
  865. }
  866. // handle width and height
  867. readSize(attr);
  868. // handle component error
  869. if (attr.hasKey("error")) {
  870. UserError error = new UserError(attr.get("error"),
  871. com.vaadin.server.AbstractErrorMessage.ContentMode.HTML,
  872. ErrorLevel.ERROR);
  873. setComponentError(error);
  874. }
  875. // Tab index when applicable
  876. if (design.hasAttr("tabindex") && this instanceof Focusable) {
  877. ((Focusable) this).setTabIndex(DesignAttributeHandler.readAttribute(
  878. "tabindex", design.attributes(), Integer.class));
  879. }
  880. // check for unsupported attributes
  881. Set<String> supported = new HashSet<>();
  882. supported.addAll(getDefaultAttributes());
  883. supported.addAll(getCustomAttributes());
  884. for (Attribute a : attr) {
  885. if (!a.getKey().startsWith(":")
  886. && !supported.contains(a.getKey())) {
  887. // Add unknown attributes as custom attributes to the context
  888. designContext.setCustomAttribute(this, a.getKey(),
  889. a.getValue());
  890. }
  891. }
  892. }
  893. /**
  894. * Constructs a Locale corresponding to the given string. The string should
  895. * consist of one, two or three parts with '_' between the different parts
  896. * if there is more than one part. The first part specifies the language,
  897. * the second part the country and the third part the variant of the locale.
  898. *
  899. * @param localeString
  900. * the locale specified as a string
  901. * @return the Locale object corresponding to localeString
  902. */
  903. private Locale getLocaleFromString(String localeString) {
  904. if (localeString == null) {
  905. return null;
  906. }
  907. String[] parts = localeString.split("_");
  908. if (parts.length > 3) {
  909. throw new RuntimeException(
  910. "Cannot parse the locale string: " + localeString);
  911. }
  912. switch (parts.length) {
  913. case 1:
  914. return new Locale(parts[0]);
  915. case 2:
  916. return new Locale(parts[0], parts[1]);
  917. default:
  918. return new Locale(parts[0], parts[1], parts[2]);
  919. }
  920. }
  921. /**
  922. * Toggles responsiveness of this component.
  923. *
  924. * @since 7.5.0
  925. * @param responsive
  926. * boolean enables responsiveness, false disables
  927. */
  928. public void setResponsive(boolean responsive) {
  929. if (responsive) {
  930. // make responsive if necessary
  931. if (!isResponsive()) {
  932. Responsive.makeResponsive(this);
  933. }
  934. } else {
  935. // remove responsive extensions
  936. List<Extension> extensions = new ArrayList<>(getExtensions());
  937. for (Extension e : extensions) {
  938. if (e instanceof Responsive) {
  939. removeExtension(e);
  940. }
  941. }
  942. }
  943. }
  944. /**
  945. * Returns true if the component is responsive.
  946. *
  947. * @since 7.5.0
  948. * @return true if the component is responsive
  949. */
  950. public boolean isResponsive() {
  951. for (Extension e : getExtensions()) {
  952. if (e instanceof Responsive) {
  953. return true;
  954. }
  955. }
  956. return false;
  957. }
  958. /**
  959. * Sets the read-only status in the state of this {@code AbstractComponent}.
  960. * This method should be made public in {@link Component Components} that
  961. * implement {@link HasValue}.
  962. *
  963. * @param readOnly
  964. * a boolean value specifying whether the component is put
  965. * read-only mode or not
  966. */
  967. protected void setReadOnly(boolean readOnly) {
  968. if (getState(false) instanceof AbstractFieldState) {
  969. if (readOnly != isReadOnly()) {
  970. ((AbstractFieldState) getState()).readOnly = readOnly;
  971. }
  972. } else {
  973. throw new IllegalStateException(
  974. "This component does not support the read-only mode, since state is of type "
  975. + getStateType().getSimpleName()
  976. + " and does not inherit "
  977. + AbstractFieldState.class.getSimpleName());
  978. }
  979. }
  980. /**
  981. * Returns the read-only status from the state of this
  982. * {@code AbstractComponent}. This method should be made public in
  983. * {@link Component Components} that implement {@link HasValue}.
  984. *
  985. * @return {@code true} if state has read-only on; {@code false} if not
  986. * @see #setReadOnly(boolean)
  987. */
  988. protected boolean isReadOnly() {
  989. if (getState(false) instanceof AbstractFieldState) {
  990. return ((AbstractFieldState) getState(false)).readOnly;
  991. }
  992. throw new IllegalStateException(
  993. "This component does not support the read-only mode, since state is of type "
  994. + getStateType().getSimpleName()
  995. + " and does not inherit "
  996. + AbstractFieldState.class.getSimpleName());
  997. }
  998. /**
  999. * Reads the size of this component from the given design attributes. If the
  1000. * attributes do not contain relevant size information, defaults is
  1001. * consulted.
  1002. *
  1003. * @param attributes
  1004. * the design attributes
  1005. */
  1006. private void readSize(Attributes attributes) {
  1007. // read width
  1008. if (attributes.hasKey("width-auto") || attributes.hasKey("size-auto")) {
  1009. this.setWidth(null);
  1010. } else if (attributes.hasKey("width-full")
  1011. || attributes.hasKey("size-full")) {
  1012. this.setWidth("100%");
  1013. } else if (attributes.hasKey("width")) {
  1014. this.setWidth(attributes.get("width"));
  1015. }
  1016. // read height
  1017. if (attributes.hasKey("height-auto")
  1018. || attributes.hasKey("size-auto")) {
  1019. this.setHeight(null);
  1020. } else if (attributes.hasKey("height-full")
  1021. || attributes.hasKey("size-full")) {
  1022. this.setHeight("100%");
  1023. } else if (attributes.hasKey("height")) {
  1024. this.setHeight(attributes.get("height"));
  1025. }
  1026. }
  1027. /**
  1028. * Writes the size related attributes for the component if they differ from
  1029. * the defaults
  1030. *
  1031. * @param attributes
  1032. * the attribute map where the attribute are written
  1033. * @param defaultInstance
  1034. * the default instance of the class for fetching the default
  1035. * values
  1036. */
  1037. private void writeSize(Attributes attributes, Component defaultInstance) {
  1038. if (hasEqualSize(defaultInstance)) {
  1039. // we have default values -> ignore
  1040. return;
  1041. }
  1042. boolean widthFull = getWidth() == 100f
  1043. && getWidthUnits().equals(Sizeable.Unit.PERCENTAGE);
  1044. boolean heightFull = getHeight() == 100f
  1045. && getHeightUnits().equals(Sizeable.Unit.PERCENTAGE);
  1046. boolean widthAuto = getWidth() == -1;
  1047. boolean heightAuto = getHeight() == -1;
  1048. // first try the full shorthands
  1049. if (widthFull && heightFull) {
  1050. attributes.put("size-full", true);
  1051. } else if (widthAuto && heightAuto) {
  1052. attributes.put("size-auto", true);
  1053. } else {
  1054. // handle width
  1055. if (!hasEqualWidth(defaultInstance)) {
  1056. if (widthFull) {
  1057. attributes.put("width-full", true);
  1058. } else if (widthAuto) {
  1059. attributes.put("width-auto", true);
  1060. } else {
  1061. String widthString = DesignAttributeHandler.getFormatter()
  1062. .format(getWidth()) + getWidthUnits().getSymbol();
  1063. attributes.put("width", widthString);
  1064. }
  1065. }
  1066. if (!hasEqualHeight(defaultInstance)) {
  1067. // handle height
  1068. if (heightFull) {
  1069. attributes.put("height-full", true);
  1070. } else if (heightAuto) {
  1071. attributes.put("height-auto", true);
  1072. } else {
  1073. String heightString = DesignAttributeHandler.getFormatter()
  1074. .format(getHeight()) + getHeightUnits().getSymbol();
  1075. attributes.put("height", heightString);
  1076. }
  1077. }
  1078. }
  1079. }
  1080. /**
  1081. * Test if the given component has equal width with this instance
  1082. *
  1083. * @param component
  1084. * the component for the width comparison
  1085. * @return true if the widths are equal
  1086. */
  1087. private boolean hasEqualWidth(Component component) {
  1088. return getWidth() == component.getWidth()
  1089. && getWidthUnits().equals(component.getWidthUnits());
  1090. }
  1091. /**
  1092. * Test if the given component has equal height with this instance
  1093. *
  1094. * @param component
  1095. * the component for the height comparison
  1096. * @return true if the heights are equal
  1097. */
  1098. private boolean hasEqualHeight(Component component) {
  1099. return getHeight() == component.getHeight()
  1100. && getHeightUnits().equals(component.getHeightUnits());
  1101. }
  1102. /**
  1103. * Test if the given components has equal size with this instance
  1104. *
  1105. * @param component
  1106. * the component for the size comparison
  1107. * @return true if the sizes are equal
  1108. */
  1109. private boolean hasEqualSize(Component component) {
  1110. return hasEqualWidth(component) && hasEqualHeight(component);
  1111. }
  1112. /**
  1113. * Returns a collection of attributes that do not require custom handling
  1114. * when reading or writing design. These are typically attributes of some
  1115. * primitive type. The default implementation searches setters with
  1116. * primitive values
  1117. *
  1118. * @return a collection of attributes that can be read and written using the
  1119. * default approach.
  1120. */
  1121. private Collection<String> getDefaultAttributes() {
  1122. Collection<String> attributes = DesignAttributeHandler
  1123. .getSupportedAttributes(this.getClass());
  1124. attributes.removeAll(getCustomAttributes());
  1125. return attributes;
  1126. }
  1127. /**
  1128. * Returns a collection of attributes that should not be handled by the
  1129. * basic implementation of the {@link #readDesign(Element, DesignContext)}
  1130. * and {@link #writeDesign(Element, DesignContext)} methods. Typically these
  1131. * are handled in a custom way in the overridden versions of the above
  1132. * methods
  1133. *
  1134. * @since 7.4
  1135. *
  1136. * @return the collection of attributes that are not handled by the basic
  1137. * implementation
  1138. */
  1139. protected Collection<String> getCustomAttributes() {
  1140. ArrayList<String> l = new ArrayList<>(Arrays.asList(customAttributes));
  1141. if (this instanceof Focusable) {
  1142. l.add("tab-index");
  1143. l.add("tabindex");
  1144. }
  1145. return l;
  1146. }
  1147. private static final String[] customAttributes = { "width",
  1148. "height", "debug-id", "error", "width-auto", "height-auto",
  1149. "width-full", "height-full", "size-auto", "size-full", "immediate",
  1150. "locale", "read-only", "_id" };
  1151. /*
  1152. * (non-Javadoc)
  1153. *
  1154. * @see com.vaadin.ui.Component#writeDesign(org.jsoup.nodes.Element,
  1155. * com.vaadin.ui.declarative.DesignContext)
  1156. */
  1157. @Override
  1158. public void writeDesign(Element design, DesignContext designContext) {
  1159. AbstractComponent def = designContext.getDefaultInstance(this);
  1160. Attributes attr = design.attributes();
  1161. // handle default attributes
  1162. for (String attribute : getDefaultAttributes()) {
  1163. DesignAttributeHandler.writeAttribute(this, attribute, attr, def,
  1164. designContext);
  1165. }
  1166. // handle locale
  1167. if (getLocale() != null && (getParent() == null
  1168. || !getLocale().equals(getParent().getLocale()))) {
  1169. design.attr("locale", getLocale().toString());
  1170. }
  1171. // handle size
  1172. writeSize(attr, def);
  1173. // handle component error
  1174. String errorMsg = getComponentError() != null
  1175. ? getComponentError().getFormattedHtmlMessage() : null;
  1176. String defErrorMsg = def.getComponentError() != null
  1177. ? def.getComponentError().getFormattedHtmlMessage() : null;
  1178. if (!SharedUtil.equals(errorMsg, defErrorMsg)) {
  1179. attr.put("error", errorMsg);
  1180. }
  1181. // handle tab index
  1182. if (this instanceof Focusable) {
  1183. DesignAttributeHandler.writeAttribute("tabindex", attr,
  1184. ((Focusable) this).getTabIndex(),
  1185. ((Focusable) def).getTabIndex(), Integer.class,
  1186. designContext);
  1187. }
  1188. // handle custom attributes
  1189. Map<String, String> customAttributes = designContext
  1190. .getCustomAttributes(this);
  1191. if (customAttributes != null) {
  1192. for (Entry<String, String> entry : customAttributes.entrySet()) {
  1193. attr.put(entry.getKey(), entry.getValue());
  1194. }
  1195. }
  1196. }
  1197. /*
  1198. * Actions
  1199. */
  1200. /**
  1201. * Gets the {@link ActionManager} used to manage the
  1202. * {@link ShortcutListener}s added to this component.
  1203. *
  1204. * @return the ActionManager in use
  1205. */
  1206. protected ActionManager getActionManager() {
  1207. if (actionManager == null) {
  1208. actionManager = new ConnectorActionManager(this);
  1209. setActionManagerViewer();
  1210. }
  1211. return actionManager;
  1212. }
  1213. /**
  1214. * Set a viewer for the action manager to be the parent sub window (if the
  1215. * component is in a window) or the UI (otherwise). This is still a
  1216. * simplification of the real case as this should be handled by the parent
  1217. * VOverlay (on the client side) if the component is inside an VOverlay
  1218. * component.
  1219. */
  1220. private void setActionManagerViewer() {
  1221. if (actionManager != null && getUI() != null) {
  1222. // Attached and has action manager
  1223. Window w = findAncestor(Window.class);
  1224. if (w != null) {
  1225. actionManager.setViewer(w);
  1226. } else {
  1227. actionManager.setViewer(getUI());
  1228. }
  1229. }
  1230. }
  1231. public Registration addShortcutListener(ShortcutListener shortcut) {
  1232. Objects.requireNonNull(shortcut, "Listener must not be null.");
  1233. getActionManager().addAction(shortcut);
  1234. return () -> getActionManager().removeAction(shortcut);
  1235. }
  1236. @Deprecated
  1237. public void removeShortcutListener(ShortcutListener shortcut) {
  1238. getActionManager().removeAction(shortcut);
  1239. }
  1240. /**
  1241. * Determine whether a <code>content</code> component is equal to, or the
  1242. * ancestor of this component.
  1243. *
  1244. * @param content
  1245. * the potential ancestor element
  1246. * @return <code>true</code> if the relationship holds
  1247. */
  1248. protected boolean isOrHasAncestor(Component content) {
  1249. if (content instanceof HasComponents) {
  1250. for (Component parent = this; parent != null; parent = parent
  1251. .getParent()) {
  1252. if (parent.equals(content)) {
  1253. return true;
  1254. }
  1255. }
  1256. }
  1257. return false;
  1258. }
  1259. @Override
  1260. public Registration addContextClickListener(ContextClickListener listener) {
  1261. // Register default Context Click RPC if needed. This RPC won't be
  1262. // called if there are no listeners on the server-side. A client-side
  1263. // connector can override this and use a different RPC channel.
  1264. if (getRpcManager(ContextClickRpc.class.getName()) == null) {
  1265. registerRpc((ContextClickRpc) (MouseEventDetails details) -> {
  1266. fireEvent(
  1267. new ContextClickEvent(AbstractComponent.this, details));
  1268. });
  1269. }
  1270. return addListener(EventId.CONTEXT_CLICK, ContextClickEvent.class,
  1271. listener, ContextClickEvent.CONTEXT_CLICK_METHOD);
  1272. }
  1273. @Override
  1274. @Deprecated
  1275. public void removeContextClickListener(ContextClickListener listener) {
  1276. removeListener(EventId.CONTEXT_CLICK, ContextClickEvent.class,
  1277. listener);
  1278. }
  1279. /**
  1280. * Sets the visibility of the required indicator. <strong>NOTE: Does not
  1281. * apply for all components!</strong>.
  1282. * <p>
  1283. * If the component supports the required indicator (state extends
  1284. * {@link AbstractFieldState}), then expose this method and
  1285. * {@link #isRequiredIndicatorVisible()} as {@code public} in the component
  1286. * and call this method.
  1287. * <p>
  1288. * This method will throw a {@link IllegalStateException} if the component
  1289. * state (returned by {@link #getState()}) does not inherit
  1290. * {@link AbstractFieldState}.
  1291. *
  1292. * @param visible
  1293. * <code>true</code> to make the required indicator visible,
  1294. * <code>false</code> if not
  1295. * @since 8.0
  1296. */
  1297. protected void setRequiredIndicatorVisible(boolean visible) {
  1298. if (getState(false) instanceof AbstractFieldState) {
  1299. ((AbstractFieldState) getState()).required = visible;
  1300. } else {
  1301. throw new IllegalStateException(
  1302. "This component does not support the required indicator, since state is of type "
  1303. + getStateType().getSimpleName()
  1304. + " and does not inherit "
  1305. + AbstractFieldState.class.getSimpleName());
  1306. }
  1307. }
  1308. /**
  1309. * Checks whether the required indicator is visible or not. <strong>NOTE:
  1310. * Does not apply for all components!</strong>.
  1311. * <p>
  1312. * This method will throw a {@link IllegalStateException} if the component
  1313. * state (returned by {@link #getState()}) does not inherit
  1314. * {@link AbstractFieldState}.
  1315. *
  1316. * @return <code>true</code> if visible, <code>false</code> if not
  1317. * @see #setRequiredIndicatorVisible(boolean)
  1318. * @since 8.0
  1319. */
  1320. protected boolean isRequiredIndicatorVisible() {
  1321. if (getState(false) instanceof AbstractFieldState) {
  1322. return ((AbstractFieldState) getState(false)).required;
  1323. }
  1324. throw new IllegalStateException(
  1325. "This component does not support the required indicator, since state is of type "
  1326. + getStateType().getSimpleName()
  1327. + " and does not inherit "
  1328. + AbstractFieldState.class.getSimpleName());
  1329. }
  1330. }