org.gwtwidgets.client.ui
Class EditableLabel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.gwtwidgets.client.ui.EditableLabel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.ui.HasWordWrap

public class EditableLabel
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.user.client.ui.HasWordWrap, com.google.gwt.user.client.ui.HasText

Editable Label class, funcionality displays a Label UI Element until clicked on, then if element is set to be editable (default) then an editable area and Buttons are displayed instead. If the Label is not set to be word wrapped (default) then the editable area is a Text Box and clicking the OK button or hitting return key in the TextBox will display the Label with the updated text. If the Label is set to be word wrapped, using the setWordWrap(boolean) method, then the editable area is a Text Area and clicking the OK button will display the Label with the updated text. In both cases, clicking Cancel button or hitting Escape key in the TextBox/TextArea then the Label is displayed with original text.

Version:
0.0.2 Changes since version 0.0.1 + made cancelLabelChange public [ref request id: 1518134] + made originalText have default value of empty string [to support ref request id: 1518134] *End*
Author:
Adam Tacy

Constructor Summary
EditableLabel(java.lang.String labelText, com.google.gwt.user.client.ui.ChangeListener onUpdate)
          Constructor that uses default text values for buttons.
EditableLabel(java.lang.String labelText, com.google.gwt.user.client.ui.ChangeListener onUpdate, boolean wordWrap)
          Constructor that uses default text values for buttons and sets the word wrap property.
EditableLabel(java.lang.String labelText, com.google.gwt.user.client.ui.ChangeListener onUpdate, java.lang.String okText, java.lang.String cancelText)
          Constructor that changes default button text.
EditableLabel(java.lang.String labelText, com.google.gwt.user.client.ui.ChangeListener onUpdate, java.lang.String okText, java.lang.String cancelText, boolean wordWrap)
          Constructor that changes default text for buttons and allows the setting of the wordwrap property directly.
 
Method Summary
 void cancelLabelChange()
          Sets the Label text to the original value, restores the display.
protected  com.google.gwt.user.client.ui.Widget createCancelButton(java.lang.String cancelButtonText)
           
protected  com.google.gwt.user.client.ui.Widget createConfirmButton(java.lang.String okButtonText)
           
 int getMaxLength()
          Get maximum length of editable area.
 java.lang.String getText()
          Return the text value of the Label
 int getVisibleLength()
          Get the visible length of the editable area.
 int getVisibleLines()
          Get the number of Visible Lines of editable area of a word-wrapped editable Label.
 boolean getWordWrap()
          Return whether the Label is word wrapped or not.
 boolean isFieldEditable()
          Returns the value of the isEditable flag.
 boolean isInEditingMode()
          Returns the value of the isEditing flag, allowing outside users to see if the Label is being edited or not.
 void setEditable(boolean flag)
          Allows the setting of the isEditable flag, marking the label as editable or not.
 void setMaxLength(int length)
          Set maximum length of editable area.
 void setText(java.lang.String newText)
          Set the text value of the Label
 void setVisibleLength(int length)
          Set the visible length of the editable area.
 void setVisibleLines(int number)
          Sets the number of visible lines for a word-wrapped editable label.
 void setWordWrap(boolean b)
          Set the word wrapping on the label (if word wrapped then the editable field becomes a TextArea, if not then the editable field is a TextBox.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getElement, getWidget, initWidget, isAttached, onAttach, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, onBrowserEvent, onLoad, onUnload, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EditableLabel

public EditableLabel(java.lang.String labelText,
                     com.google.gwt.user.client.ui.ChangeListener onUpdate,
                     java.lang.String okText,
                     java.lang.String cancelText,
                     boolean wordWrap)
Constructor that changes default text for buttons and allows the setting of the wordwrap property directly.

Parameters:
labelText - The initial text of the label.
onUpdate - Handler object for performing actions once label is updated.
okText - Text for use in overiding the default OK button text.
cancelText - Text for use in overiding the default CANCEL button text.
wordWrap - Boolean representing if the label should be word wrapped or not

EditableLabel

public EditableLabel(java.lang.String labelText,
                     com.google.gwt.user.client.ui.ChangeListener onUpdate,
                     boolean wordWrap)
Constructor that uses default text values for buttons and sets the word wrap property.

Parameters:
labelText - The initial text of the label.
onUpdate - Handler object for performing actions once label is updated.
wordWrap - Boolean representing if the label should be word wrapped or not

EditableLabel

public EditableLabel(java.lang.String labelText,
                     com.google.gwt.user.client.ui.ChangeListener onUpdate,
                     java.lang.String okText,
                     java.lang.String cancelText)
Constructor that changes default button text.

Parameters:
labelText - The initial text of the label.
onUpdate - Handler object for performing actions once label is updated.
okText - Text for use in overiding the default OK button text.
cancelText - Text for use in overiding the default CANCEL button text.

EditableLabel

public EditableLabel(java.lang.String labelText,
                     com.google.gwt.user.client.ui.ChangeListener onUpdate)
Constructor that uses default text values for buttons.

Parameters:
labelText - The initial text of the label.
onUpdate - Handler object for performing actions once label is updated.
Method Detail

setEditable

public void setEditable(boolean flag)
Allows the setting of the isEditable flag, marking the label as editable or not.

Parameters:
flag - True or False value depending if the Label is to be editable or not

isFieldEditable

public boolean isFieldEditable()
Returns the value of the isEditable flag.

Returns:

isInEditingMode

public boolean isInEditingMode()
Returns the value of the isEditing flag, allowing outside users to see if the Label is being edited or not.

Returns:

cancelLabelChange

public void cancelLabelChange()
Sets the Label text to the original value, restores the display.


createCancelButton

protected com.google.gwt.user.client.ui.Widget createCancelButton(java.lang.String cancelButtonText)
Parameters:
cancelButtonText -

createConfirmButton

protected com.google.gwt.user.client.ui.Widget createConfirmButton(java.lang.String okButtonText)
Parameters:
okButtonText -

setWordWrap

public void setWordWrap(boolean b)
Set the word wrapping on the label (if word wrapped then the editable field becomes a TextArea, if not then the editable field is a TextBox.

Specified by:
setWordWrap in interface com.google.gwt.user.client.ui.HasWordWrap
Parameters:
b - Boolean value, true means Label is word wrapped, false means it is not.

getWordWrap

public boolean getWordWrap()
Return whether the Label is word wrapped or not.

Specified by:
getWordWrap in interface com.google.gwt.user.client.ui.HasWordWrap

getText

public java.lang.String getText()
Return the text value of the Label

Specified by:
getText in interface com.google.gwt.user.client.ui.HasText

setText

public void setText(java.lang.String newText)
Set the text value of the Label

Specified by:
setText in interface com.google.gwt.user.client.ui.HasText

setVisibleLines

public void setVisibleLines(int number)
Sets the number of visible lines for a word-wrapped editable label.

Parameters:
number - Number of visible lines.
Throws:
java.lang.RuntimeException - if the editable label is not word-wrapped.

getVisibleLines

public int getVisibleLines()
Get the number of Visible Lines of editable area of a word-wrapped editable Label.

Returns:
Number of Visible Lines.
Throws:
java.lang.RuntimeException - If the Label is not word-wrapped.

setMaxLength

public void setMaxLength(int length)
Set maximum length of editable area.

Parameters:
length - Length of editable area.

getMaxLength

public int getMaxLength()
Get maximum length of editable area.

Returns:
maximum length of editable area.

setVisibleLength

public void setVisibleLength(int length)
Set the visible length of the editable area.

Throws:
RuntimeExcpetion - If editable label is word wrapped.

getVisibleLength

public int getVisibleLength()
Get the visible length of the editable area.

Returns:
Visible length of editable area if not a word wrapped label.
Throws:
RuntimeExcpetion - If editable label is word wrapped.


Copyright © 2009. All Rights Reserved.