Skip to content

Commit

Permalink
#63: various improvements on RichTextArea (Font settings popup with p…
Browse files Browse the repository at this point in the history
…review)
  • Loading branch information
hohwille committed Dec 18, 2013
1 parent e9b14ee commit 5f897fa
Show file tree
Hide file tree
Showing 26 changed files with 619 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void onClick(UiEventClick evt) {
}
};
button1.addClickHandler(clickHandler);
clickHandler.onClick(null);
// clickHandler.onClick(null);
UiWidgetButton button2 = factory.create(UiWidgetButton.class);
button2.setLabel("button2:" + Locale.getDefault());
verticalPanel2.addChild(button2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,16 @@ public interface NlsBundleClientUiRoot extends NlsBundle {
@NlsBundleMessage("Undefined option")
NlsMessage failureUndefinedOption();

/**
* @return the {@link NlsMessage} for the label of the preview (e.g. for font-settings).
*/
@NlsBundleMessage("Preview")
NlsMessage labelPreview();

/**
* @return the {@link NlsMessage} for the label of the actual text to preview the font settings.
*/
@NlsBundleMessage("Abcdefghijklmnopqrstuvwxyz0123456789")
NlsMessage labelFontSettingsPreviewText();

}
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,7 @@ public interface CssStyles {
/** The name of the CSS style for the glass panel used for modal popups. */
String GLASS_PANEL = "GlassPanel";

/** The name of the CSS style for a label corresponding to a field. */
String FIELD_LABEL = "FieldLabel";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,51 @@
import net.sf.mmm.client.ui.api.attribute.AttributeWriteLabel;
import net.sf.mmm.client.ui.api.attribute.AttributeWriteTrimValue;
import net.sf.mmm.client.ui.api.attribute.AttributeWriteValidationFailure;
import net.sf.mmm.client.ui.api.common.CssStyles;
import net.sf.mmm.client.ui.api.widget.UiWidget;
import net.sf.mmm.client.ui.api.widget.UiWidgetActive;
import net.sf.mmm.client.ui.api.widget.UiWidgetRegularComposite;
import net.sf.mmm.client.ui.api.widget.UiWidgetWithValue;
import net.sf.mmm.client.ui.api.widget.core.UiWidgetLabel;

/**
* This is the abstract interface for a {@link UiWidgetRegularComposite regular composite widget} that represents a
* (potentially) editable field (text field, combobox, text area, radio-buttons, checkbox, etc.). Such a field is
* associated with a {@link #getLabel() label}. To build a form with multiple fields a
* {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetGridPanel} should be used (typically indirectly via a custom
* widget). Such form can be used to display the fields with their values in
* This is the abstract interface for a {@link UiWidgetRegularComposite regular composite widget} that
* represents a (potentially) editable field (text field, combobox, text area, radio-buttons, checkbox, etc.).
* Such a field is associated with a {@link #getLabel() label}. To build a form with multiple fields a
* {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetGridPanel} should be used (typically indirectly via a
* custom widget). Such form can be used to display the fields with their values in
* {@link net.sf.mmm.client.ui.api.common.UiMode#VIEW view mode} (read-only) or in
* {@link net.sf.mmm.client.ui.api.common.UiMode#EDIT edit mode}. This can be changed dynamically via
* {@link #setMode(net.sf.mmm.client.ui.api.common.UiMode)}. To prevent a single field from switching to
* {@link net.sf.mmm.client.ui.api.common.UiMode#EDIT edit mode} you can call
* {@link #setModeFixed(net.sf.mmm.client.ui.api.common.UiMode)} with
* {@link net.sf.mmm.client.ui.api.common.UiMode#VIEW} so it will remain immutable. Besides a field can also be
* {@link #isEnabled() disabled} so in {@link net.sf.mmm.client.ui.api.common.UiMode#EDIT edit mode} it will be grayed
* out and prevents the user from changing its value. This is suggested for fields that dynamically change their (
* {@link #isEnabled() editable}) status based on a particular condition (e.g. the current value of another field). A
* field widget is a composite because it may also be composed out of multiple native input widgets (e.g. to edit a
* composite {@link net.sf.mmm.util.lang.api.Datatype} - see
* {@link net.sf.mmm.client.ui.api.common.UiMode#VIEW} so it will remain immutable. Besides a field can also
* be {@link #isEnabled() disabled} so in {@link net.sf.mmm.client.ui.api.common.UiMode#EDIT edit mode} it
* will be grayed out and prevents the user from changing its value. This is suggested for fields that
* dynamically change their ( {@link #isEnabled() editable}) status based on a particular condition (e.g. the
* current value of another field). A field widget is a composite because it may also be composed out of
* multiple native input widgets (e.g. to edit a composite {@link net.sf.mmm.util.lang.api.Datatype} - see
* {@link net.sf.mmm.client.ui.api.widget.factory.UiWidgetFactoryDatatype#createForDatatype(Class)}).
*
* @param <VALUE> is the generic type of the {@link #getValue() value}.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.0.0
*/
public abstract interface UiWidgetField<VALUE> extends UiWidgetRegularComposite<UiWidget>,
UiWidgetWithValue<VALUE>, AttributeWriteValidationFailure, AttributeWriteTrimValue, AttributeWriteLabel,
UiWidgetActive {
public abstract interface UiWidgetField<VALUE> extends UiWidgetRegularComposite<UiWidget>, UiWidgetWithValue<VALUE>,
AttributeWriteValidationFailure, AttributeWriteTrimValue, AttributeWriteLabel, UiWidgetActive {

/** The default top-level {@link #hasStyle(String) style} of this widget. */
String STYLE_FIELD = "Field";

/**
* The {@link #getPrimaryStyle() primary style} of the internal widget to display the {@link #getValue() value} in
* {@link net.sf.mmm.client.ui.api.common.UiMode#VIEW view-mode}.
* The {@link #getPrimaryStyle() primary style} of the internal widget to display the {@link #getValue()
* value} in {@link net.sf.mmm.client.ui.api.common.UiMode#VIEW view-mode}.
*/
String STYLE_VIEW = "FieldView";

/** The {@link #getPrimaryStyle() primary style} of the {@link #getLabelWidget() field label widget}. */
String STYLE_LABEL = "FieldLabel";
String STYLE_LABEL = CssStyles.FIELD_LABEL;

/**
* The {@link #addStyle(String) additional style} of the {@link #getLabelWidget() field label widget} if
Expand All @@ -63,18 +63,20 @@ public abstract interface UiWidgetField<VALUE> extends UiWidgetRegularComposite<
* <br/>
* <br/>
* <b>NOTE:</b><br/>
* Every field widget ({@link UiWidgetField}) has an associated {@link #getLabelWidget() label widget}. This method
* gets its label text. Please note that the {@link #getLabelWidget() label widget} is not contained in this field
* widget itself, so if you regularly add this field widget to some other widget you will not see the label. However,
* {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetGridPanel} also automatically
* Every field widget ({@link UiWidgetField}) has an associated {@link #getLabelWidget() label widget}. This
* method gets its label text. Please note that the {@link #getLabelWidget() label widget} is not contained
* in this field widget itself, so if you regularly add this field widget to some other widget you will not
* see the label. However, {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetGridPanel} also
* automatically
* {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetGridPanel#addChildren(net.sf.mmm.client.ui.api.widget.UiWidgetRegular...)
* adds} the {@link #getLabelWidget() label widget}. The recommended use-case is to create a form to view and edit
* your business object extending {@link net.sf.mmm.client.ui.base.widget.custom.panel.UiWidgetCustomGridPanel} and
* use {@link net.sf.mmm.client.ui.base.binding.UiDataBinding}.<br/>
* Unlike <code>{@link #getLabelWidget()}.{@link UiWidgetLabel#getLabel() getLabel()}</code> this method prevents
* actually creating the {@link #getLabelWidget() label widget} if it does NOT yet exist. Further it will only return
* what has been set via {@link #setLabel(String)} and NOT what has potentially been set via {@link #getLabelWidget()}
* . {@link UiWidgetLabel#setLabel(String) setLabel} (what should be avoided).
* adds} the {@link #getLabelWidget() label widget}. The recommended use-case is to create a form to view
* and edit your business object extending
* {@link net.sf.mmm.client.ui.base.widget.custom.panel.UiWidgetCustomGridPanel} and use
* {@link net.sf.mmm.client.ui.base.binding.UiDataBinding}.<br/>
* Unlike <code>{@link #getLabelWidget()}.{@link UiWidgetLabel#getLabel() getLabel()}</code> this method
* prevents actually creating the {@link #getLabelWidget() label widget} if it does NOT yet exist. Further
* it will only return what has been set via {@link #setLabel(String)} and NOT what has potentially been set
* via {@link #getLabelWidget()} . {@link UiWidgetLabel#setLabel(String) setLabel} (what should be avoided).
*/
String getLabel();

Expand All @@ -89,11 +91,12 @@ public abstract interface UiWidgetField<VALUE> extends UiWidgetRegularComposite<
* This method gets the {@link UiWidgetLabel label widget} associated with this field.<br/>
* <b>ATTENTION:</b><br/>
* Depending on the underlying toolkit the label widget is lazily created on the first call of this method.
* Additionally users of this API (unlike implementors of the API) may only use this for very specific cases (e.g.
* setting the style of the label). Therefore you should avoid calling this method unless you are aware of what you
* are doing. To access the label-text simply use {@link #getLabel()} and {@link #setLabel(String)}. Be aware that
* some native toolkits (e.g. SmartGWT) already implement field widgets including the label. In this case this method
* will return a different view on the same native widget.
* Additionally users of this API (unlike implementors of the API) may only use this for very specific cases
* (e.g. setting the style of the label). Therefore you should avoid calling this method unless you are
* aware of what you are doing. To access the label-text simply use {@link #getLabel()} and
* {@link #setLabel(String)}. Be aware that some native toolkits (e.g. SmartGWT) already implement field
* widgets including the label. In this case this method will return a different view on the same native
* widget.
*
* @return the associated label widget.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.client.ui.impl.gwt.gwtwidgets;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;

/**
* This is a custom {@link com.google.gwt.user.client.ui.Widget} that represents a
* {@link net.sf.mmm.client.ui.api.widget.panel.UiWidgetBorderPanel} (fieldset-tag).
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.0.0
*/
public class BorderPanel extends SingleCompositePanel {

/** The labeled legend element. */
private final Element legend;

/**
* The constructor.
*/
public BorderPanel() {

super();
setElement(Document.get().createElement("fieldset"));
this.legend = Document.get().createElement("legend");
getElement().appendChild(this.legend);
}

/**
* @param label is the label for the border text.
*/
public void setLabel(String label) {

// HTML injection???
this.legend.setInnerText(label);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@ public PopupWindow(boolean autoHide) {
public PopupWindow(boolean autoHide, boolean modal) {

super(autoHide, modal);
setGlassStyleName(CssStyles.GLASS_PANEL);
setGlassEnabled(true);
getGlassElement().getStyle().setPosition(Position.FIXED);
if (modal) {
setGlassStyleName(CssStyles.GLASS_PANEL);
setGlassEnabled(true);
getGlassElement().getStyle().setPosition(Position.FIXED);
}
this.resizable = true;
this.maximized = false;
this.maximizable = true;
Expand Down Expand Up @@ -278,7 +280,9 @@ public void setResizable(boolean resizable) {
if (this.resizable == resizable) {
return;
}
doSetResizable(resizable);
if (!this.maximized) {
doSetResizable(resizable);
}
this.resizable = resizable;
}

Expand Down Expand Up @@ -316,7 +320,9 @@ public void setMovable(boolean movable) {
return;
}
if (movable) {
this.titleBar.addStyleName(CssStyles.MOVABLE);
if (!this.maximized) {
this.titleBar.addStyleName(CssStyles.MOVABLE);
}
} else {
this.titleBar.removeStyleName(CssStyles.MOVABLE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.client.ui.impl.gwt.gwtwidgets;

import java.util.Iterator;

import net.sf.mmm.util.collection.base.SingleElementIterator;

import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

/**
* This is a custom {@link Widget} that represents a {@link Panel} owing a single child.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.0.0
*/
public abstract class SingleCompositePanel extends Panel {

/** @see #setChild(Widget) */
private Widget childWidget;

/**
* The constructor.
*/
public SingleCompositePanel() {

super();
}

/**
* @param child is the Widget to set as child. A potential previous child will be removed.
*/
public void setChild(Widget child) {

if (this.childWidget != null) {
remove(this.childWidget);
}
if (child != null) {
add(child);
}
}

/**
* {@inheritDoc}
*/
@Override
public Iterator<Widget> iterator() {

return new SingleElementIterator<Widget>(this.childWidget);
}

/**
* {@inheritDoc}
*/
@Override
public void add(Widget child) {

if (this.childWidget == null) {
getElement().appendChild(child.getElement());
this.childWidget = child;
adopt(child);
} else {
throw new IllegalStateException("Multiple children not supported!");
}
}

/**
* {@inheritDoc}
*/
@Override
public boolean remove(Widget child) {

if (child == null) {
return false;
}
if (this.childWidget == child) {
orphan(child);
getElement().removeChild(child.getElement());
this.childWidget = null;
return true;
}
return false;
}

}
Loading

0 comments on commit 5f897fa

Please sign in to comment.