svn changeset:8619/svn branch:6.1tags/6.7.0.beta1
/* | |||||
/* | |||||
@ITMillApache2LicenseForJavaFiles@ | @ITMillApache2LicenseForJavaFiles@ | ||||
*/ | */ | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import com.google.gwt.event.dom.client.ClickEvent; | |||||
import com.google.gwt.event.dom.client.ClickHandler; | |||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.Timer; | import com.google.gwt.user.client.Timer; | ||||
import com.google.gwt.user.client.ui.MouseListener; | import com.google.gwt.user.client.ui.MouseListener; | ||||
import com.google.gwt.user.client.ui.MouseListenerCollection; | import com.google.gwt.user.client.ui.MouseListenerCollection; | ||||
import com.google.gwt.user.client.ui.SourcesMouseEvents; | import com.google.gwt.user.client.ui.SourcesMouseEvents; | ||||
import com.google.gwt.user.client.ui.SourcesTableEvents; | |||||
import com.google.gwt.user.client.ui.TableListener; | |||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.DateTimeService; | import com.vaadin.terminal.gwt.client.DateTimeService; | ||||
import com.vaadin.terminal.gwt.client.LocaleService; | import com.vaadin.terminal.gwt.client.LocaleService; | ||||
datefield = parent; | datefield = parent; | ||||
setStyleName(VDateField.CLASSNAME + "-calendarpanel"); | setStyleName(VDateField.CLASSNAME + "-calendarpanel"); | ||||
// buildCalendar(true); | // buildCalendar(true); | ||||
days.addTableListener(new DateClickListener(this)); | |||||
days.addClickHandler(new DateClickHandler(this)); | |||||
} | } | ||||
public VCalendarPanel(VDateField parent, Date min, Date max) { | public VCalendarPanel(VDateField parent, Date min, Date max) { | ||||
datefield = parent; | datefield = parent; | ||||
setStyleName(VDateField.CLASSNAME + "-calendarpanel"); | setStyleName(VDateField.CLASSNAME + "-calendarpanel"); | ||||
days.addTableListener(new DateClickListener(this)); | |||||
days.addClickHandler(new DateClickHandler(this)); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* | |||||
* @param forceRedraw | * @param forceRedraw | ||||
* Build all from scratch, in case of e.g. locale changes | * Build all from scratch, in case of e.g. locale changes | ||||
*/ | */ | ||||
switch (DOM.eventGetType(event)) { | switch (DOM.eventGetType(event)) { | ||||
case Event.ONMOUSEDOWN: | case Event.ONMOUSEDOWN: | ||||
case Event.ONMOUSEUP: | case Event.ONMOUSEUP: | ||||
case Event.ONMOUSEMOVE: | |||||
case Event.ONMOUSEOVER: | |||||
case Event.ONMOUSEOUT: | case Event.ONMOUSEOUT: | ||||
if (mouseListeners != null) { | if (mouseListeners != null) { | ||||
mouseListeners.fireMouseEvent(this, event); | mouseListeners.fireMouseEvent(this, event); | ||||
} | } | ||||
} | } | ||||
private class DateClickListener implements TableListener { | |||||
private class DateClickHandler implements ClickHandler { | |||||
private final VCalendarPanel cal; | private final VCalendarPanel cal; | ||||
public DateClickListener(VCalendarPanel panel) { | |||||
public DateClickHandler(VCalendarPanel panel) { | |||||
cal = panel; | cal = panel; | ||||
} | } | ||||
public void onCellClicked(SourcesTableEvents sender, int row, int col) { | |||||
if (sender != cal.days || row < 1 || row > 6 | |||||
public void onClick(ClickEvent event) { | |||||
Object sender = event.getSource(); | |||||
Cell cell = cal.days.getCellForEvent(event); | |||||
if (sender != cal.days || cell == null || cell.getRowIndex() < 1 | |||||
|| cell.getRowIndex() > 6 | |||||
|| !cal.datefield.isEnabled() || cal.datefield.isReadonly()) { | || !cal.datefield.isEnabled() || cal.datefield.isReadonly()) { | ||||
return; | return; | ||||
} | } | ||||
final String text = cal.days.getText(row, col); | |||||
final String text = cal.days.getText(cell.getRowIndex(), cell | |||||
.getCellIndex()); | |||||
if (text.equals(" ")) { | if (text.equals(" ")) { | ||||
return; | return; | ||||
} | } | ||||
/** | /** | ||||
* Sets focus to Calendar panel. | * Sets focus to Calendar panel. | ||||
* | |||||
* | |||||
* @param focus | * @param focus | ||||
*/ | */ | ||||
public void setFocus(boolean focus) { | public void setFocus(boolean focus) { |
import com.google.gwt.event.dom.client.KeyUpHandler; | import com.google.gwt.event.dom.client.KeyUpHandler; | ||||
import com.google.gwt.event.dom.client.LoadEvent; | import com.google.gwt.event.dom.client.LoadEvent; | ||||
import com.google.gwt.event.dom.client.LoadHandler; | import com.google.gwt.event.dom.client.LoadHandler; | ||||
import com.google.gwt.event.logical.shared.CloseEvent; | |||||
import com.google.gwt.event.logical.shared.CloseHandler; | |||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.HTML; | import com.google.gwt.user.client.ui.HTML; | ||||
import com.google.gwt.user.client.ui.Image; | import com.google.gwt.user.client.ui.Image; | ||||
import com.google.gwt.user.client.ui.PopupListener; | |||||
import com.google.gwt.user.client.ui.PopupPanel; | import com.google.gwt.user.client.ui.PopupPanel; | ||||
import com.google.gwt.user.client.ui.TextBox; | import com.google.gwt.user.client.ui.TextBox; | ||||
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; | import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; | ||||
} | } | ||||
public class SuggestionPopup extends VOverlay implements PositionCallback, | public class SuggestionPopup extends VOverlay implements PositionCallback, | ||||
PopupListener { | |||||
CloseHandler<PopupPanel> { | |||||
private static final String Z_INDEX = "30000"; | private static final String Z_INDEX = "30000"; | ||||
DOM.appendChild(root, status); | DOM.appendChild(root, status); | ||||
DOM.setElementProperty(status, "className", CLASSNAME + "-status"); | DOM.setElementProperty(status, "className", CLASSNAME + "-status"); | ||||
addPopupListener(this); | |||||
addCloseHandler(this); | |||||
} | } | ||||
public void showSuggestions( | public void showSuggestions( | ||||
return (lastAutoClosed > 0 && (now - lastAutoClosed) < 200); | return (lastAutoClosed > 0 && (now - lastAutoClosed) < 200); | ||||
} | } | ||||
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | |||||
if (autoClosed) { | |||||
public void onClose(CloseEvent<PopupPanel> event) { | |||||
if (event.isAutoClosed()) { | |||||
lastAutoClosed = (new Date()).getTime(); | lastAutoClosed = (new Date()).getTime(); | ||||
} | } | ||||
} | } |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.ui.ListBox; | import com.google.gwt.user.client.ui.ListBox; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
super(new TooltipListBox(true), CLASSNAME); | super(new TooltipListBox(true), CLASSNAME); | ||||
select = (TooltipListBox) optionsContainer; | select = (TooltipListBox) optionsContainer; | ||||
select.setSelect(this); | select.setSelect(this); | ||||
select.addChangeListener(this); | |||||
select.addChangeHandler(this); | |||||
select.addClickHandler(this); | select.addClickHandler(this); | ||||
select.setStyleName(CLASSNAME + "-select"); | select.setStyleName(CLASSNAME + "-select"); | ||||
select.setVisibleItemCount(VISIBLE_COUNT); | select.setVisibleItemCount(VISIBLE_COUNT); | ||||
} | } | ||||
@Override | @Override | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
final int si = select.getSelectedIndex(); | final int si = select.getSelectedIndex(); | ||||
if (si == -1 && !isNullSelectionAllowed()) { | if (si == -1 && !isNullSelectionAllowed()) { | ||||
select.setSelectedIndex(lastSelectedIndex); | select.setSelectedIndex(lastSelectedIndex); |
import java.util.List; | import java.util.List; | ||||
import java.util.Stack; | import java.util.Stack; | ||||
import com.google.gwt.event.logical.shared.CloseEvent; | |||||
import com.google.gwt.event.logical.shared.CloseHandler; | |||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.DeferredCommand; | import com.google.gwt.user.client.DeferredCommand; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.ui.HasHTML; | import com.google.gwt.user.client.ui.HasHTML; | ||||
import com.google.gwt.user.client.ui.PopupListener; | |||||
import com.google.gwt.user.client.ui.PopupPanel; | import com.google.gwt.user.client.ui.PopupPanel; | ||||
import com.google.gwt.user.client.ui.UIObject; | import com.google.gwt.user.client.ui.UIObject; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VMenuBar extends Widget implements Paintable, PopupListener { | |||||
public class VMenuBar extends Widget implements Paintable, | |||||
CloseHandler<PopupPanel> { | |||||
/** Set the CSS class name to allow styling. */ | /** Set the CSS class name to allow styling. */ | ||||
public static final String CLASSNAME = "v-menubar"; | public static final String CLASSNAME = "v-menubar"; | ||||
/** | /** | ||||
* This method must be implemented to update the client-side component from | * This method must be implemented to update the client-side component from | ||||
* UIDL data received from server. | * UIDL data received from server. | ||||
* | |||||
* | |||||
* This method is called when the page is loaded for the first time, and | * This method is called when the page is loaded for the first time, and | ||||
* every time UI changes in the component are received from the server. | * every time UI changes in the component are received from the server. | ||||
*/ | */ | ||||
/** | /** | ||||
* This is called by the items in the menu and it communicates the | * This is called by the items in the menu and it communicates the | ||||
* information to the server | * information to the server | ||||
* | |||||
* | |||||
* @param clickedItemId | * @param clickedItemId | ||||
* id of the item that was clicked | * id of the item that was clicked | ||||
*/ | */ | ||||
/** | /** | ||||
* Returns the containing element of the menu | * Returns the containing element of the menu | ||||
* | |||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public Element getContainingElement() { | public Element getContainingElement() { | ||||
/** | /** | ||||
* Returns a new child element to add an item to | * Returns a new child element to add an item to | ||||
* | |||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public Element getNewChildElement() { | public Element getNewChildElement() { | ||||
/** | /** | ||||
* Add a new item to this menu | * Add a new item to this menu | ||||
* | |||||
* | |||||
* @param html | * @param html | ||||
* items text | * items text | ||||
* @param cmd | * @param cmd | ||||
/** | /** | ||||
* Add a new item to this menu | * Add a new item to this menu | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void addItem(CustomMenuItem item) { | public void addItem(CustomMenuItem item) { | ||||
/** | /** | ||||
* Remove the given item from this menu | * Remove the given item from this menu | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void removeItem(CustomMenuItem item) { | public void removeItem(CustomMenuItem item) { | ||||
/** | /** | ||||
* When an item is clicked | * When an item is clicked | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void itemClick(CustomMenuItem item) { | public void itemClick(CustomMenuItem item) { | ||||
/** | /** | ||||
* When the user hovers the mouse over the item | * When the user hovers the mouse over the item | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void itemOver(CustomMenuItem item) { | public void itemOver(CustomMenuItem item) { | ||||
/** | /** | ||||
* When the mouse is moved away from an item | * When the mouse is moved away from an item | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void itemOut(CustomMenuItem item) { | public void itemOut(CustomMenuItem item) { | ||||
/** | /** | ||||
* Shows the child menu of an item. The caller must ensure that the item has | * Shows the child menu of an item. The caller must ensure that the item has | ||||
* a submenu. | * a submenu. | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void showChildMenu(CustomMenuItem item) { | public void showChildMenu(CustomMenuItem item) { | ||||
popup = new VOverlay(true, false, true); | popup = new VOverlay(true, false, true); | ||||
popup.setWidget(item.getSubMenu()); | popup.setWidget(item.getSubMenu()); | ||||
popup.addPopupListener(this); | |||||
popup.addCloseHandler(this); | |||||
if (subMenu) { | if (subMenu) { | ||||
popup.setPopupPosition(item.getParentMenu().getAbsoluteLeft() | popup.setPopupPosition(item.getParentMenu().getAbsoluteLeft() | ||||
/** | /** | ||||
* Hides the submenu of an item | * Hides the submenu of an item | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void hideChildMenu(CustomMenuItem item) { | public void hideChildMenu(CustomMenuItem item) { | ||||
/** | /** | ||||
* Returns the parent menu of this menu, or null if this is the top-level | * Returns the parent menu of this menu, or null if this is the top-level | ||||
* menu | * menu | ||||
* | |||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public VMenuBar getParentMenu() { | public VMenuBar getParentMenu() { | ||||
/** | /** | ||||
* Set the parent menu of this menu | * Set the parent menu of this menu | ||||
* | |||||
* | |||||
* @param parent | * @param parent | ||||
*/ | */ | ||||
public void setParentMenu(VMenuBar parent) { | public void setParentMenu(VMenuBar parent) { | ||||
/** | /** | ||||
* Returns the currently selected item of this menu, or null if nothing is | * Returns the currently selected item of this menu, or null if nothing is | ||||
* selected | * selected | ||||
* | |||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public CustomMenuItem getSelected() { | public CustomMenuItem getSelected() { | ||||
/** | /** | ||||
* Set the currently selected item of this menu | * Set the currently selected item of this menu | ||||
* | |||||
* | |||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void setSelected(CustomMenuItem item) { | public void setSelected(CustomMenuItem item) { | ||||
/** | /** | ||||
* Listener method, fired when this menu is closed | * Listener method, fired when this menu is closed | ||||
*/ | */ | ||||
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | |||||
public void onClose(CloseEvent<PopupPanel> event) { | |||||
hideChildren(); | hideChildren(); | ||||
if (autoClosed) { | |||||
if (event.isAutoClosed()) { | |||||
hideParents(); | hideParents(); | ||||
} | } | ||||
// setSelected(null); | // setSelected(null); | ||||
} | } | ||||
/** | /** | ||||
* | |||||
* | |||||
* A class to hold information on menu items | * A class to hold information on menu items | ||||
* | |||||
* | |||||
*/ | */ | ||||
private class CustomMenuItem extends UIObject implements HasHTML { | private class CustomMenuItem extends UIObject implements HasHTML { | ||||
/* | |||||
/* | |||||
@ITMillApache2LicenseForJavaFiles@ | @ITMillApache2LicenseForJavaFiles@ | ||||
*/ | */ | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
import com.vaadin.terminal.gwt.client.Util; | import com.vaadin.terminal.gwt.client.Util; | ||||
select = (TooltipListBox) optionsContainer; | select = (TooltipListBox) optionsContainer; | ||||
select.setSelect(this); | select.setSelect(this); | ||||
select.setVisibleItemCount(1); | select.setVisibleItemCount(1); | ||||
select.addChangeListener(this); | |||||
select.addChangeHandler(this); | |||||
select.setStyleName(CLASSNAME + "-select"); | select.setStyleName(CLASSNAME + "-select"); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
if (select.isMultipleSelect()) { | if (select.isMultipleSelect()) { | ||||
client.updateVariable(id, "selected", getSelectedItems(), | client.updateVariable(id, "selected", getSelectedItems(), |
op.setStyleName("v-radiobutton"); | op.setStyleName("v-radiobutton"); | ||||
} | } | ||||
op.addStyleName(CLASSNAME_OPTION); | op.addStyleName(CLASSNAME_OPTION); | ||||
op.setChecked(opUidl.getBooleanAttribute("selected")); | |||||
op.setValue(opUidl.getBooleanAttribute("selected")); | |||||
op.setEnabled(!opUidl.getBooleanAttribute("disabled") | op.setEnabled(!opUidl.getBooleanAttribute("disabled") | ||||
&& !isReadonly() && !isDisabled()); | && !isReadonly() && !isDisabled()); | ||||
op.addClickHandler(this); | op.addClickHandler(this); |
import java.util.Set; | import java.util.Set; | ||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.event.dom.client.ChangeHandler; | |||||
import com.google.gwt.event.dom.client.ClickEvent; | import com.google.gwt.event.dom.client.ClickEvent; | ||||
import com.google.gwt.event.dom.client.ClickHandler; | import com.google.gwt.event.dom.client.ClickHandler; | ||||
import com.google.gwt.event.dom.client.KeyCodes; | import com.google.gwt.event.dom.client.KeyCodes; | ||||
import com.google.gwt.event.dom.client.KeyPressEvent; | import com.google.gwt.event.dom.client.KeyPressEvent; | ||||
import com.google.gwt.event.dom.client.KeyPressHandler; | import com.google.gwt.event.dom.client.KeyPressHandler; | ||||
import com.google.gwt.user.client.ui.ChangeListener; | |||||
import com.google.gwt.user.client.ui.Composite; | import com.google.gwt.user.client.ui.Composite; | ||||
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.Panel; | import com.google.gwt.user.client.ui.Panel; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
abstract class VOptionGroupBase extends Composite implements Paintable, Field, | abstract class VOptionGroupBase extends Composite implements Paintable, Field, | ||||
ClickHandler, ChangeListener, KeyPressHandler, Focusable { | |||||
ClickHandler, ChangeHandler, KeyPressHandler, Focusable { | |||||
public static final String CLASSNAME_OPTION = "v-select-option"; | public static final String CLASSNAME_OPTION = "v-select-option"; | ||||
} | } | ||||
} | } | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
if (multiselect) { | if (multiselect) { | ||||
client | client | ||||
.updateVariable(id, "selected", getSelectedItems(), | .updateVariable(id, "selected", getSelectedItems(), |
/* | |||||
/* | |||||
@ITMillApache2LicenseForJavaFiles@ | @ITMillApache2LicenseForJavaFiles@ | ||||
*/ | */ | ||||
import com.google.gwt.animation.client.Animation; | import com.google.gwt.animation.client.Animation; | ||||
import com.google.gwt.dom.client.Document; | import com.google.gwt.dom.client.Document; | ||||
import com.google.gwt.event.logical.shared.CloseEvent; | |||||
import com.google.gwt.event.logical.shared.CloseHandler; | |||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.ui.PopupListener; | |||||
import com.google.gwt.user.client.ui.PopupPanel; | import com.google.gwt.user.client.ui.PopupPanel; | ||||
import com.google.gwt.user.client.ui.RootPanel; | import com.google.gwt.user.client.ui.RootPanel; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
/** | /** | ||||
* The HTML snippet that is used to render the actual shadow. In consists of | * The HTML snippet that is used to render the actual shadow. In consists of | ||||
* nine different DIV-elements with the following class names: | * nine different DIV-elements with the following class names: | ||||
* | |||||
* | |||||
* <pre> | * <pre> | ||||
* .v-shadow[-stylename] | * .v-shadow[-stylename] | ||||
* ---------------------------------------------- | * ---------------------------------------------- | ||||
* | .bottom-left | .bottom | .bottom-right | | * | .bottom-left | .bottom | .bottom-right | | ||||
* ---------------------------------------------- | * ---------------------------------------------- | ||||
* </pre> | * </pre> | ||||
* | |||||
* | |||||
* See default theme 'shadow.css' for implementation example. | * See default theme 'shadow.css' for implementation example. | ||||
*/ | */ | ||||
private static final String SHADOW_HTML = "<div class=\"top-left\"></div><div class=\"top\"></div><div class=\"top-right\"></div><div class=\"left\"></div><div class=\"center\"></div><div class=\"right\"></div><div class=\"bottom-left\"></div><div class=\"bottom\"></div><div class=\"bottom-right\"></div>"; | private static final String SHADOW_HTML = "<div class=\"top-left\"></div><div class=\"top\"></div><div class=\"top-right\"></div><div class=\"left\"></div><div class=\"center\"></div><div class=\"right\"></div><div class=\"bottom-left\"></div><div class=\"bottom\"></div><div class=\"bottom-right\"></div>"; | ||||
shadow.setInnerHTML(SHADOW_HTML); | shadow.setInnerHTML(SHADOW_HTML); | ||||
DOM.setStyleAttribute(shadow, "position", "absolute"); | DOM.setStyleAttribute(shadow, "position", "absolute"); | ||||
addPopupListener(new PopupListener() { | |||||
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | |||||
addCloseHandler(new CloseHandler<PopupPanel>() { | |||||
public void onClose(CloseEvent<PopupPanel> event) { | |||||
if (shadow.getParentElement() != null) { | if (shadow.getParentElement() != null) { | ||||
shadow.getParentElement().removeChild(shadow); | shadow.getParentElement().removeChild(shadow); | ||||
} | } | ||||
/** | /** | ||||
* Set the z-index (visual stack position) for this overlay. | * Set the z-index (visual stack position) for this overlay. | ||||
* | |||||
* | |||||
* @param zIndex | * @param zIndex | ||||
* The new z-index | * The new z-index | ||||
*/ | */ | ||||
/** | /** | ||||
* Get the z-index (visual stack position) of this overlay. | * Get the z-index (visual stack position) of this overlay. | ||||
* | |||||
* | |||||
* @return The z-index for this overlay. | * @return The z-index for this overlay. | ||||
*/ | */ | ||||
private int getZIndex() { | private int getZIndex() { | ||||
private native void adjustIE6Frame(Element popup, int zindex) | private native void adjustIE6Frame(Element popup, int zindex) | ||||
/*-{ | /*-{ | ||||
// relies on PopupImplIE6 | // relies on PopupImplIE6 | ||||
if(popup.__frame) | |||||
if(popup.__frame) | |||||
popup.__frame.style.zIndex = zindex; | popup.__frame.style.zIndex = zindex; | ||||
}-*/; | }-*/; | ||||
* Sets the shadow style for this overlay. Will override any previous style | * Sets the shadow style for this overlay. Will override any previous style | ||||
* for the shadow. The default style name is defined by CLASSNAME_SHADOW. | * for the shadow. The default style name is defined by CLASSNAME_SHADOW. | ||||
* The given style will be prefixed with CLASSNAME_SHADOW. | * The given style will be prefixed with CLASSNAME_SHADOW. | ||||
* | |||||
* | |||||
* @param style | * @param style | ||||
* The new style name for the shadow element. Will be prefixed by | * The new style name for the shadow element. Will be prefixed by | ||||
* CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style | * CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style | ||||
* be used to animate the shadow, using the 'progress' parameter (used to | * be used to animate the shadow, using the 'progress' parameter (used to | ||||
* animate the shadow in sync with GWT PopupPanel's default animation | * animate the shadow in sync with GWT PopupPanel's default animation | ||||
* 'PopupPanel.AnimationType.CENTER'). | * 'PopupPanel.AnimationType.CENTER'). | ||||
* | |||||
* | |||||
* @param progress | * @param progress | ||||
* A value between 0.0 and 1.0, indicating the progress of the | * A value between 0.0 and 1.0, indicating the progress of the | ||||
* animation (0=start, 1=end). | * animation (0=start, 1=end). |
import com.google.gwt.event.dom.client.ClickEvent; | import com.google.gwt.event.dom.client.ClickEvent; | ||||
import com.google.gwt.event.dom.client.ClickHandler; | import com.google.gwt.event.dom.client.ClickHandler; | ||||
import com.google.gwt.event.logical.shared.CloseEvent; | |||||
import com.google.gwt.event.logical.shared.CloseHandler; | |||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.Timer; | import com.google.gwt.user.client.Timer; | ||||
import com.google.gwt.user.client.Window; | import com.google.gwt.user.client.Window; | ||||
import com.google.gwt.user.client.ui.Button; | import com.google.gwt.user.client.ui.Button; | ||||
import com.google.gwt.user.client.ui.PopupListener; | |||||
import com.google.gwt.user.client.ui.PopupPanel; | import com.google.gwt.user.client.ui.PopupPanel; | ||||
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; | import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.UIDL; | import com.vaadin.terminal.gwt.client.UIDL; | ||||
public class VPopupCalendar extends VTextualDate implements Paintable, Field, | public class VPopupCalendar extends VTextualDate implements Paintable, Field, | ||||
ClickHandler, PopupListener { | |||||
ClickHandler, CloseHandler<PopupPanel> { | |||||
private final Button calendarToggle; | private final Button calendarToggle; | ||||
popup = new VOverlay(true, true, true); | popup = new VOverlay(true, true, true); | ||||
popup.setStyleName(VDateField.CLASSNAME + "-popup"); | popup.setStyleName(VDateField.CLASSNAME + "-popup"); | ||||
popup.setWidget(calendar); | popup.setWidget(calendar); | ||||
popup.addPopupListener(this); | |||||
popup.addCloseHandler(this); | |||||
DOM.setElementProperty(calendar.getElement(), "id", | DOM.setElementProperty(calendar.getElement(), "id", | ||||
"PID_VAADIN_POPUPCAL"); | "PID_VAADIN_POPUPCAL"); | ||||
} | } | ||||
} | } | ||||
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | |||||
if (sender == popup) { | |||||
public void onClose(CloseEvent<PopupPanel> event) { | |||||
if (event.getSource() == popup) { | |||||
buildDate(); | buildDate(); | ||||
// Sigh. | // Sigh. | ||||
Timer t = new Timer() { | Timer t = new Timer() { |
/* | |||||
/* | |||||
@ITMillApache2LicenseForJavaFiles@ | @ITMillApache2LicenseForJavaFiles@ | ||||
*/ | */ | ||||
import java.util.Set; | import java.util.Set; | ||||
import com.google.gwt.dom.client.Style; | import com.google.gwt.dom.client.Style; | ||||
import com.google.gwt.event.dom.client.ClickEvent; | |||||
import com.google.gwt.event.dom.client.ClickHandler; | |||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.DeferredCommand; | import com.google.gwt.user.client.DeferredCommand; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.ui.ClickListener; | |||||
import com.google.gwt.user.client.ui.ComplexPanel; | import com.google.gwt.user.client.ui.ComplexPanel; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
} | } | ||||
class TabBar extends ComplexPanel implements ClickListener { | |||||
class TabBar extends ComplexPanel implements ClickHandler { | |||||
private final Element tr = DOM.createTR(); | private final Element tr = DOM.createTR(); | ||||
setStyleName(div, CLASSNAME + "-tabitem"); | setStyleName(div, CLASSNAME + "-tabitem"); | ||||
DOM.appendChild(td, div); | DOM.appendChild(td, div); | ||||
DOM.insertBefore(tr, td, spacerTd); | DOM.insertBefore(tr, td, spacerTd); | ||||
c.addClickListener(this); | |||||
c.addClickHandler(this); | |||||
add(c, div); | add(c, div); | ||||
} | } | ||||
public void onClick(Widget sender) { | |||||
int index = getWidgetIndex(sender); | |||||
public void onClick(ClickEvent event) { | |||||
int index = getWidgetIndex((Widget) event.getSource()); | |||||
onTabSelected(index); | onTabSelected(index); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public boolean remove(Widget w) { | |||||
((VCaption) w).removeClickListener(this); | |||||
return super.remove(w); | |||||
} | |||||
public TabSheetCaption getTab(int index) { | public TabSheetCaption getTab(int index) { | ||||
if (index >= getWidgetCount()) { | if (index >= getWidgetCount()) { | ||||
return null; | return null; |
import com.google.gwt.event.dom.client.BlurEvent; | import com.google.gwt.event.dom.client.BlurEvent; | ||||
import com.google.gwt.event.dom.client.BlurHandler; | import com.google.gwt.event.dom.client.BlurHandler; | ||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.event.dom.client.ChangeHandler; | |||||
import com.google.gwt.event.dom.client.FocusEvent; | import com.google.gwt.event.dom.client.FocusEvent; | ||||
import com.google.gwt.event.dom.client.FocusHandler; | import com.google.gwt.event.dom.client.FocusHandler; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.ui.ChangeListener; | |||||
import com.google.gwt.user.client.ui.TextBoxBase; | import com.google.gwt.user.client.ui.TextBoxBase; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
* | * | ||||
*/ | */ | ||||
public class VTextField extends TextBoxBase implements Paintable, Field, | public class VTextField extends TextBoxBase implements Paintable, Field, | ||||
ChangeListener, FocusHandler, BlurHandler { | |||||
ChangeHandler, FocusHandler, BlurHandler { | |||||
/** | /** | ||||
* The input node CSS classname. | * The input node CSS classname. | ||||
DOM.setStyleAttribute(node, "marginBottom", "-1px"); | DOM.setStyleAttribute(node, "marginBottom", "-1px"); | ||||
} | } | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
addChangeListener(this); | |||||
addChangeHandler(this); | |||||
addFocusHandler(this); | addFocusHandler(this); | ||||
addBlurHandler(this); | addBlurHandler(this); | ||||
sinkEvents(VTooltip.TOOLTIP_EVENTS); | sinkEvents(VTooltip.TOOLTIP_EVENTS); | ||||
return maxLength; | return maxLength; | ||||
} | } | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
if (client != null && id != null) { | if (client != null && id != null) { | ||||
String newText = getText(); | String newText = getText(); | ||||
if (!prompting && newText != null | if (!prompting && newText != null | ||||
setText(inputPrompt); | setText(inputPrompt); | ||||
addStyleDependentName(CLASSNAME_PROMPT); | addStyleDependentName(CLASSNAME_PROMPT); | ||||
} | } | ||||
onChange((Widget) event.getSource()); | |||||
onChange(null); | |||||
} | } | ||||
private void setPrompting(boolean prompting) { | private void setPrompting(boolean prompting) { |
/* | |||||
/* | |||||
@ITMillApache2LicenseForJavaFiles@ | @ITMillApache2LicenseForJavaFiles@ | ||||
*/ | */ | ||||
import java.util.Date; | import java.util.Date; | ||||
import com.google.gwt.user.client.ui.ChangeListener; | |||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.event.dom.client.ChangeHandler; | |||||
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.ListBox; | import com.google.gwt.user.client.ui.ListBox; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
public class VTime extends FlowPanel implements ChangeListener { | |||||
public class VTime extends FlowPanel implements ChangeHandler { | |||||
private final VDateField datefield; | private final VDateField datefield; | ||||
for (int i = 0; i < numHours; i++) { | for (int i = 0; i < numHours; i++) { | ||||
hours.addItem((i < 10) ? "0" + i : "" + i); | hours.addItem((i < 10) ? "0" + i : "" + i); | ||||
} | } | ||||
hours.addChangeListener(this); | |||||
hours.addChangeHandler(this); | |||||
if (thc) { | if (thc) { | ||||
ampm = new ListBox(); | ampm = new ListBox(); | ||||
ampm.setStyleName(VNativeSelect.CLASSNAME); | ampm.setStyleName(VNativeSelect.CLASSNAME); | ||||
.getAmPmStrings(); | .getAmPmStrings(); | ||||
ampm.addItem(ampmText[0]); | ampm.addItem(ampmText[0]); | ||||
ampm.addItem(ampmText[1]); | ampm.addItem(ampmText[1]); | ||||
ampm.addChangeListener(this); | |||||
ampm.addChangeHandler(this); | |||||
} | } | ||||
if (datefield.getCurrentResolution() >= VDateField.RESOLUTION_MIN) { | if (datefield.getCurrentResolution() >= VDateField.RESOLUTION_MIN) { | ||||
for (int i = 0; i < 60; i++) { | for (int i = 0; i < 60; i++) { | ||||
mins.addItem((i < 10) ? "0" + i : "" + i); | mins.addItem((i < 10) ? "0" + i : "" + i); | ||||
} | } | ||||
mins.addChangeListener(this); | |||||
mins.addChangeHandler(this); | |||||
} | } | ||||
if (datefield.getCurrentResolution() >= VDateField.RESOLUTION_SEC) { | if (datefield.getCurrentResolution() >= VDateField.RESOLUTION_SEC) { | ||||
sec = new ListBox(); | sec = new ListBox(); | ||||
for (int i = 0; i < 60; i++) { | for (int i = 0; i < 60; i++) { | ||||
sec.addItem((i < 10) ? "0" + i : "" + i); | sec.addItem((i < 10) ? "0" + i : "" + i); | ||||
} | } | ||||
sec.addChangeListener(this); | |||||
sec.addChangeHandler(this); | |||||
} | } | ||||
if (datefield.getCurrentResolution() == VDateField.RESOLUTION_MSEC) { | if (datefield.getCurrentResolution() == VDateField.RESOLUTION_MSEC) { | ||||
msec = new ListBox(); | msec = new ListBox(); | ||||
msec.addItem("" + i); | msec.addItem("" + i); | ||||
} | } | ||||
} | } | ||||
msec.addChangeListener(this); | |||||
msec.addChangeHandler(this); | |||||
} | } | ||||
final String delimiter = datefield.getDateTimeService() | final String delimiter = datefield.getDateTimeService() | ||||
readonly = datefield.isReadonly(); | readonly = datefield.isReadonly(); | ||||
} | } | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
if (datefield.getCurrentDate() == null) { | if (datefield.getCurrentDate() == null) { | ||||
// was null on server, need to set | // was null on server, need to set | ||||
Date now = datefield.getShowingDate(); | Date now = datefield.getShowingDate(); | ||||
datefield.getClient().updateVariable(datefield.getId(), "msec", | datefield.getClient().updateVariable(datefield.getId(), "msec", | ||||
datefield.getMilliseconds(), false); | datefield.getMilliseconds(), false); | ||||
} | } | ||||
if (sender == hours) { | |||||
if (event.getSource() == hours) { | |||||
int h = hours.getSelectedIndex(); | int h = hours.getSelectedIndex(); | ||||
if (datefield.getDateTimeService().isTwelveHourClock()) { | if (datefield.getDateTimeService().isTwelveHourClock()) { | ||||
h = h + ampm.getSelectedIndex() * 12; | h = h + ampm.getSelectedIndex() * 12; | ||||
datefield.getClient().updateVariable(datefield.getId(), "hour", h, | datefield.getClient().updateVariable(datefield.getId(), "hour", h, | ||||
datefield.isImmediate()); | datefield.isImmediate()); | ||||
updateTime(false); | updateTime(false); | ||||
} else if (sender == mins) { | |||||
} else if (event.getSource() == mins) { | |||||
final int m = mins.getSelectedIndex(); | final int m = mins.getSelectedIndex(); | ||||
datefield.getCurrentDate().setMinutes(m); | datefield.getCurrentDate().setMinutes(m); | ||||
datefield.getShowingDate().setMinutes(m); | datefield.getShowingDate().setMinutes(m); | ||||
datefield.getClient().updateVariable(datefield.getId(), "min", m, | datefield.getClient().updateVariable(datefield.getId(), "min", m, | ||||
datefield.isImmediate()); | datefield.isImmediate()); | ||||
updateTime(false); | updateTime(false); | ||||
} else if (sender == sec) { | |||||
} else if (event.getSource() == sec) { | |||||
final int s = sec.getSelectedIndex(); | final int s = sec.getSelectedIndex(); | ||||
datefield.getCurrentDate().setSeconds(s); | datefield.getCurrentDate().setSeconds(s); | ||||
datefield.getShowingDate().setSeconds(s); | datefield.getShowingDate().setSeconds(s); | ||||
datefield.getClient().updateVariable(datefield.getId(), "sec", s, | datefield.getClient().updateVariable(datefield.getId(), "sec", s, | ||||
datefield.isImmediate()); | datefield.isImmediate()); | ||||
updateTime(false); | updateTime(false); | ||||
} else if (sender == msec) { | |||||
} else if (event.getSource() == msec) { | |||||
final int ms = msec.getSelectedIndex(); | final int ms = msec.getSelectedIndex(); | ||||
datefield.setMilliseconds(ms); | datefield.setMilliseconds(ms); | ||||
datefield.setShowingMilliseconds(ms); | datefield.setShowingMilliseconds(ms); | ||||
datefield.getClient().updateVariable(datefield.getId(), "msec", ms, | datefield.getClient().updateVariable(datefield.getId(), "msec", ms, | ||||
datefield.isImmediate()); | datefield.isImmediate()); | ||||
updateTime(false); | updateTime(false); | ||||
} else if (sender == ampm) { | |||||
} else if (event.getSource() == ampm) { | |||||
final int h = hours.getSelectedIndex() + ampm.getSelectedIndex() | final int h = hours.getSelectedIndex() + ampm.getSelectedIndex() | ||||
* 12; | * 12; | ||||
datefield.getCurrentDate().setHours(h); | datefield.getCurrentDate().setHours(h); |
import com.google.gwt.dom.client.DivElement; | import com.google.gwt.dom.client.DivElement; | ||||
import com.google.gwt.dom.client.Document; | import com.google.gwt.dom.client.Document; | ||||
import com.google.gwt.event.logical.shared.ResizeEvent; | |||||
import com.google.gwt.event.logical.shared.ResizeHandler; | |||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.DeferredCommand; | import com.google.gwt.user.client.DeferredCommand; | ||||
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.Timer; | import com.google.gwt.user.client.Timer; | ||||
import com.google.gwt.user.client.Window; | import com.google.gwt.user.client.Window; | ||||
import com.google.gwt.user.client.WindowCloseListener; | |||||
import com.google.gwt.user.client.WindowResizeListener; | |||||
import com.google.gwt.user.client.ui.RootPanel; | import com.google.gwt.user.client.ui.RootPanel; | ||||
import com.google.gwt.user.client.ui.SimplePanel; | import com.google.gwt.user.client.ui.SimplePanel; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
* | * | ||||
*/ | */ | ||||
public class VView extends SimplePanel implements Container, | public class VView extends SimplePanel implements Container, | ||||
WindowResizeListener, WindowCloseListener { | |||||
ResizeHandler, Window.ClosingHandler { | |||||
private static final String CLASSNAME = "v-view"; | private static final String CLASSNAME = "v-view"; | ||||
final String url = open.getStringAttribute("src"); | final String url = open.getStringAttribute("src"); | ||||
final String target = open.getStringAttribute("name"); | final String target = open.getStringAttribute("name"); | ||||
if (target == null) { | if (target == null) { | ||||
// This window is closing. Send close event before | |||||
// going to the new url | |||||
// This window is closing. Nothing was done in the close event, | |||||
// so don't need to call it before going to the new url | |||||
isClosed = true; | isClosed = true; | ||||
onWindowClosed(); | |||||
goTo(url); | goTo(url); | ||||
} else { | } else { | ||||
String options; | String options; | ||||
// Add window listeners on first paint, to prevent premature | // Add window listeners on first paint, to prevent premature | ||||
// variablechanges | // variablechanges | ||||
if (firstPaint) { | if (firstPaint) { | ||||
Window.addWindowCloseListener(this); | |||||
Window.addWindowResizeListener(this); | |||||
Window.addWindowClosingHandler(this); | |||||
Window.addResizeHandler(this); | |||||
} | } | ||||
onWindowResized(Window.getClientWidth(), Window.getClientHeight()); | |||||
onResize(Window.getClientWidth(), Window.getClientHeight()); | |||||
if (BrowserInfo.get().isSafari()) { | if (BrowserInfo.get().isSafari()) { | ||||
Util.runWebkitOverflowAutoFix(getElement()); | Util.runWebkitOverflowAutoFix(getElement()); | ||||
} | } | ||||
} | } | ||||
public void onWindowResized(int width, int height) { | |||||
public void onResize(ResizeEvent event) { | |||||
onResize(event.getWidth(), event.getHeight()); | |||||
} | |||||
public void onResize(int wwidth, int wheight) { | |||||
if (BrowserInfo.get().isIE()) { | if (BrowserInfo.get().isIE()) { | ||||
/* | /* | ||||
* IE will give us some false resized events due bugs with | * IE will give us some false resized events due bugs with | ||||
@Override | @Override | ||||
public void run() { | public void run() { | ||||
boolean changed = false; | boolean changed = false; | ||||
if (VView.this.width != getOffsetWidth()) { | |||||
VView.this.width = getOffsetWidth(); | |||||
if (width != getOffsetWidth()) { | |||||
width = getOffsetWidth(); | |||||
changed = true; | changed = true; | ||||
ApplicationConnection.getConsole().log( | ApplicationConnection.getConsole().log( | ||||
"window w" + VView.this.width); | |||||
"window w" + width); | |||||
} | } | ||||
if (VView.this.height != getOffsetHeight()) { | |||||
VView.this.height = getOffsetHeight(); | |||||
if (height != getOffsetHeight()) { | |||||
height = getOffsetHeight(); | |||||
changed = true; | changed = true; | ||||
ApplicationConnection.getConsole().log( | ApplicationConnection.getConsole().log( | ||||
"window h" + VView.this.height); | |||||
"window h" + height); | |||||
} | } | ||||
if (changed) { | if (changed) { | ||||
ApplicationConnection | ApplicationConnection | ||||
} | } | ||||
resizeTimer.schedule(200); | resizeTimer.schedule(200); | ||||
} else { | } else { | ||||
if (width == VView.this.width && height == VView.this.height) { | |||||
if (wwidth == width && wheight == height) { | |||||
// No point in doing resize operations if window size has not | // No point in doing resize operations if window size has not | ||||
// changed | // changed | ||||
return; | return; | ||||
} | } | ||||
VView.this.width = Window.getClientWidth(); | |||||
VView.this.height = Window.getClientHeight(); | |||||
width = Window.getClientWidth(); | |||||
height = Window.getClientHeight(); | |||||
ApplicationConnection.getConsole().log( | ApplicationConnection.getConsole().log( | ||||
"Running layout functions due window resize"); | "Running layout functions due window resize"); | ||||
$wnd.location = url; | $wnd.location = url; | ||||
}-*/; | }-*/; | ||||
public void onWindowClosed() { | |||||
} | |||||
public String onWindowClosing() { | |||||
public void onWindowClosing(Window.ClosingEvent event) { | |||||
// Change focus on this window in order to ensure that all state is | // Change focus on this window in order to ensure that all state is | ||||
// collected from textfields | // collected from textfields | ||||
VTextField.flushChangesFromFocusedTextField(); | VTextField.flushChangesFromFocusedTextField(); | ||||
// Send the closing state to server | // Send the closing state to server | ||||
connection.updateVariable(id, "close", true, false); | connection.updateVariable(id, "close", true, false); | ||||
connection.sendPendingVariableChangesSync(); | connection.sendPendingVariableChangesSync(); | ||||
return null; | |||||
} | } | ||||
private final RenderSpace myRenderSpace = new RenderSpace() { | private final RenderSpace myRenderSpace = new RenderSpace() { |
import com.google.gwt.event.dom.client.BlurEvent; | import com.google.gwt.event.dom.client.BlurEvent; | ||||
import com.google.gwt.event.dom.client.BlurHandler; | import com.google.gwt.event.dom.client.BlurHandler; | ||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.event.dom.client.ChangeHandler; | |||||
import com.google.gwt.event.dom.client.KeyPressEvent; | |||||
import com.google.gwt.event.dom.client.KeyPressHandler; | |||||
import com.google.gwt.event.shared.HandlerRegistration; | |||||
import com.google.gwt.user.client.Command; | import com.google.gwt.user.client.Command; | ||||
import com.google.gwt.user.client.DOM; | import com.google.gwt.user.client.DOM; | ||||
import com.google.gwt.user.client.DeferredCommand; | import com.google.gwt.user.client.DeferredCommand; | ||||
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.ui.ChangeListener; | |||||
import com.google.gwt.user.client.ui.Composite; | import com.google.gwt.user.client.ui.Composite; | ||||
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.HTML; | import com.google.gwt.user.client.ui.HTML; | ||||
import com.google.gwt.user.client.ui.KeyboardListener; | |||||
import com.google.gwt.user.client.ui.RichTextArea; | import com.google.gwt.user.client.ui.RichTextArea; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.BrowserInfo; | import com.vaadin.terminal.gwt.client.BrowserInfo; | ||||
import com.vaadin.terminal.gwt.client.Paintable; | import com.vaadin.terminal.gwt.client.Paintable; | ||||
* | * | ||||
*/ | */ | ||||
public class VRichTextArea extends Composite implements Paintable, Field, | public class VRichTextArea extends Composite implements Paintable, Field, | ||||
ChangeListener, BlurHandler, KeyboardListener { | |||||
ChangeHandler, BlurHandler, KeyPressHandler { | |||||
/** | /** | ||||
* The input node CSS classname. | * The input node CSS classname. | ||||
private int toolbarNaturalWidth = 500; | private int toolbarNaturalWidth = 500; | ||||
private HandlerRegistration keyPressHandler; | |||||
public VRichTextArea() { | public VRichTextArea() { | ||||
fp.add(formatter); | fp.add(formatter); | ||||
.getIntAttribute("maxLength") : -1; | .getIntAttribute("maxLength") : -1; | ||||
if (newMaxLength >= 0) { | if (newMaxLength >= 0) { | ||||
if (maxLength == -1) { | if (maxLength == -1) { | ||||
rta.addKeyboardListener(this); | |||||
keyPressHandler = rta.addKeyPressHandler(this); | |||||
} | } | ||||
maxLength = newMaxLength; | maxLength = newMaxLength; | ||||
} else if (maxLength != -1) { | } else if (maxLength != -1) { | ||||
getElement().setAttribute("maxlength", ""); | getElement().setAttribute("maxlength", ""); | ||||
maxLength = -1; | maxLength = -1; | ||||
rta.removeKeyboardListener(this); | |||||
keyPressHandler.removeHandler(); | |||||
} | } | ||||
} | } | ||||
public void onChange(Widget sender) { | |||||
// TODO is this really used, or does everything go via onBlur() only? | |||||
public void onChange(ChangeEvent event) { | |||||
if (client != null && id != null) { | if (client != null && id != null) { | ||||
client.updateVariable(id, "text", rta.getText(), immediate); | client.updateVariable(id, "text", rta.getText(), immediate); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public void onKeyDown(Widget sender, char keyCode, int modifiers) { | |||||
// NOP | |||||
} | |||||
public void onKeyPress(Widget sender, char keyCode, int modifiers) { | |||||
public void onKeyPress(KeyPressEvent event) { | |||||
if (maxLength >= 0) { | if (maxLength >= 0) { | ||||
DeferredCommand.addCommand(new Command() { | DeferredCommand.addCommand(new Command() { | ||||
public void execute() { | public void execute() { | ||||
} | } | ||||
} | } | ||||
public void onKeyUp(Widget sender, char keyCode, int modifiers) { | |||||
// NOP | |||||
} | |||||
} | } |
package com.vaadin.terminal.gwt.client.ui.richtextarea; | package com.vaadin.terminal.gwt.client.ui.richtextarea; | ||||
import com.google.gwt.core.client.GWT; | import com.google.gwt.core.client.GWT; | ||||
import com.google.gwt.event.dom.client.ChangeEvent; | |||||
import com.google.gwt.event.dom.client.ChangeHandler; | |||||
import com.google.gwt.event.dom.client.ClickEvent; | import com.google.gwt.event.dom.client.ClickEvent; | ||||
import com.google.gwt.event.dom.client.ClickHandler; | import com.google.gwt.event.dom.client.ClickHandler; | ||||
import com.google.gwt.event.dom.client.KeyUpEvent; | import com.google.gwt.event.dom.client.KeyUpEvent; | ||||
import com.google.gwt.i18n.client.Constants; | import com.google.gwt.i18n.client.Constants; | ||||
import com.google.gwt.user.client.Window; | import com.google.gwt.user.client.Window; | ||||
import com.google.gwt.user.client.ui.AbstractImagePrototype; | import com.google.gwt.user.client.ui.AbstractImagePrototype; | ||||
import com.google.gwt.user.client.ui.ChangeListener; | |||||
import com.google.gwt.user.client.ui.Composite; | import com.google.gwt.user.client.ui.Composite; | ||||
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.ImageBundle; | import com.google.gwt.user.client.ui.ImageBundle; | ||||
import com.google.gwt.user.client.ui.PushButton; | import com.google.gwt.user.client.ui.PushButton; | ||||
import com.google.gwt.user.client.ui.RichTextArea; | import com.google.gwt.user.client.ui.RichTextArea; | ||||
import com.google.gwt.user.client.ui.ToggleButton; | import com.google.gwt.user.client.ui.ToggleButton; | ||||
import com.google.gwt.user.client.ui.Widget; | |||||
/** | /** | ||||
* A modified version of sample toolbar for use with {@link RichTextArea}. It | * A modified version of sample toolbar for use with {@link RichTextArea}. It | ||||
} | } | ||||
/** | /** | ||||
* We use an inner EventListener class to avoid exposing event methods on | |||||
* the RichTextToolbar itself. | |||||
* We use an inner EventHandler class to avoid exposing event methods on the | |||||
* RichTextToolbar itself. | |||||
*/ | */ | ||||
private class EventListener implements ClickHandler, ChangeListener, | |||||
private class EventHandler implements ClickHandler, ChangeHandler, | |||||
KeyUpHandler { | KeyUpHandler { | ||||
public void onChange(Widget sender) { | |||||
public void onChange(ChangeEvent event) { | |||||
Object sender = event.getSource(); | |||||
if (sender == backColors) { | if (sender == backColors) { | ||||
basic.setBackColor(backColors.getValue(backColors | basic.setBackColor(backColors.getValue(backColors | ||||
.getSelectedIndex())); | .getSelectedIndex())); | ||||
private final Images images = (Images) GWT.create(Images.class); | private final Images images = (Images) GWT.create(Images.class); | ||||
private final Strings strings = (Strings) GWT.create(Strings.class); | private final Strings strings = (Strings) GWT.create(Strings.class); | ||||
private final EventListener listener = new EventListener(); | |||||
private final EventHandler listener = new EventHandler(); | |||||
private final RichTextArea richText; | private final RichTextArea richText; | ||||
private final RichTextArea.BasicFormatter basic; | private final RichTextArea.BasicFormatter basic; | ||||
private ListBox createColorList(String caption) { | private ListBox createColorList(String caption) { | ||||
final ListBox lb = new ListBox(); | final ListBox lb = new ListBox(); | ||||
lb.addChangeListener(listener); | |||||
lb.addChangeHandler(listener); | |||||
lb.setVisibleItemCount(1); | lb.setVisibleItemCount(1); | ||||
lb.addItem(caption); | lb.addItem(caption); | ||||
private ListBox createFontList() { | private ListBox createFontList() { | ||||
final ListBox lb = new ListBox(); | final ListBox lb = new ListBox(); | ||||
lb.addChangeListener(listener); | |||||
lb.addChangeHandler(listener); | |||||
lb.setVisibleItemCount(1); | lb.setVisibleItemCount(1); | ||||
lb.addItem(strings.font(), ""); | lb.addItem(strings.font(), ""); | ||||
private ListBox createFontSizes() { | private ListBox createFontSizes() { | ||||
final ListBox lb = new ListBox(); | final ListBox lb = new ListBox(); | ||||
lb.addChangeListener(listener); | |||||
lb.addChangeHandler(listener); | |||||
lb.setVisibleItemCount(1); | lb.setVisibleItemCount(1); | ||||
lb.addItem(strings.size()); | lb.addItem(strings.size()); |