com.cedarsolutions.client.gwt.widget.ListItem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cedar-common-gwt Show documentation
Show all versions of cedar-common-gwt Show documentation
Utility code for use with GWT and Mvp4g.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* C E D A R
* S O L U T I O N S "Software done right."
* S O F T W A R E
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (c) 2013-2014 Kenneth J. Pronovici.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Apache License, Version 2.0.
* See LICENSE for more information about the licensing terms.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Author : Kenneth J. Pronovici
* Language : Java 6
* Project : Common Java Functionality
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package com.cedarsolutions.client.gwt.widget;
import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.HasText;
/**
* List item (li) to be added to an ordered (ol) or unordered (ul) list.
*
*
* This is a simplistic list item that only accepts text values. If and when
* I need something more sophisticated -- and I know how to test it -- I will
* enhance this class.
*
*
* @see Google Groups
* @author Kenneth J. Pronovici
*/
public class ListItem extends ComplexPanel implements HasText {
/** Create an empty list item. */
public ListItem() {
this(null);
}
/** Create a list item with specified text. */
public ListItem(String text) {
this.setElement(Document.get().createElement("li"));
this.setText(text);
}
/** Set the text. */
@Override
public void setText(String text) {
// This safe because we know we set an object of this type in the constructor.
com.google.gwt.dom.client.Element element = this.getElement();
if (element != null) {
element.setInnerText(text == null ? "" : text);
}
}
/** Get the text. */
@Override
public String getText() {
// This safe because we know we set an object of this type in the constructor.
com.google.gwt.dom.client.Element element = this.getElement();
return element == null ? null : element.getInnerText();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy