import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.CalendarEntry; | import com.itmill.toolkit.terminal.gwt.client.ui.CalendarEntry; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.CalendarPanel; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.ICalendarPanel; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.IDateField; | import com.itmill.toolkit.terminal.gwt.client.ui.IDateField; | ||||
public class ICalendarField extends IDateField { | public class ICalendarField extends IDateField { | ||||
private final CalendarPanel calPanel; | |||||
private final ICalendarPanel calPanel; | |||||
private SimplePanel hourPanel; | private SimplePanel hourPanel; | ||||
public ICalendarField() { | public ICalendarField() { | ||||
super(); | super(); | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
calPanel = new CalendarPanel(this); | |||||
calPanel = new ICalendarPanel(this); | |||||
add(calPanel); | add(calPanel); | ||||
entrySource = new EntrySource(); | entrySource = new EntrySource(); | ||||
calPanel.setCalendarEntrySource(entrySource); | calPanel.setCalendarEntrySource(entrySource); | ||||
} | } | ||||
private class EntrySource implements CalendarPanel.CalendarEntrySource { | |||||
private class EntrySource implements ICalendarPanel.CalendarEntrySource { | |||||
private final HashMap dates = new HashMap(); | private final HashMap dates = new HashMap(); | ||||
import com.google.gwt.user.client.ui.HasFocus; | import com.google.gwt.user.client.ui.HasFocus; | ||||
import com.google.gwt.user.client.ui.HasWidgets; | import com.google.gwt.user.client.ui.HasWidgets; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.ContextMenu; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.IContextMenu; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.Field; | import com.itmill.toolkit.terminal.gwt.client.ui.Field; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.IView; | import com.itmill.toolkit.terminal.gwt.client.ui.IView; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.Notification; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.Notification.HideEvent; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.INotification; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.INotification.HideEvent; | |||||
/** | /** | ||||
* Entry point classes define <code>onModuleLoad()</code>. | * Entry point classes define <code>onModuleLoad()</code>. | ||||
private final WidgetSet widgetSet; | private final WidgetSet widgetSet; | ||||
private ContextMenu contextMenu = null; | |||||
private IContextMenu contextMenu = null; | |||||
private Timer loadTimer; | private Timer loadTimer; | ||||
private Timer loadTimer2; | private Timer loadTimer2; | ||||
configuration = cnf; | configuration = cnf; | ||||
if (isDebugMode()) { | if (isDebugMode()) { | ||||
console = new DebugConsole(this, cnf); | |||||
console = new IDebugConsole(this, cnf); | |||||
} else { | } else { | ||||
console = new NullConsole(); | console = new NullConsole(); | ||||
} | } | ||||
} | } | ||||
if (html.length() != 0) { | if (html.length() != 0) { | ||||
Notification n = new Notification(1000 * 60 * 45); // 45min | |||||
INotification n = new INotification(1000 * 60 * 45); // 45min | |||||
n.addEventListener(new NotificationRedirect(url)); | n.addEventListener(new NotificationRedirect(url)); | ||||
n.show(html, Notification.CENTERED_TOP, "system"); | |||||
n.show(html, INotification.CENTERED_TOP, "system"); | |||||
} else { | } else { | ||||
redirect(url); | redirect(url); | ||||
} | } | ||||
* | * | ||||
* @return IContextMenu object | * @return IContextMenu object | ||||
*/ | */ | ||||
public ContextMenu getContextMenu() { | |||||
public IContextMenu getContextMenu() { | |||||
if (contextMenu == null) { | if (contextMenu == null) { | ||||
contextMenu = new ContextMenu(); | |||||
contextMenu = new IContextMenu(); | |||||
if (usePaintableIdsInDOM) { | if (usePaintableIdsInDOM) { | ||||
DOM.setElementProperty(contextMenu.getElement(), "id", | DOM.setElementProperty(contextMenu.getElement(), "id", | ||||
"PID_TOOLKIT_CM"); | "PID_TOOLKIT_CM"); | ||||
* messages, such as session expired. | * messages, such as session expired. | ||||
* | * | ||||
*/ | */ | ||||
private class NotificationRedirect implements Notification.EventListener { | |||||
private class NotificationRedirect implements INotification.EventListener { | |||||
String url; | String url; | ||||
NotificationRedirect(String url) { | NotificationRedirect(String url) { | ||||
return info; | return info; | ||||
} | } | ||||
private final Tooltip tooltip = new Tooltip(this); | |||||
private final ITooltip tooltip = new ITooltip(this); | |||||
/** | /** | ||||
* Component may want to delegate Tooltip handling to client. Layouts add | * Component may want to delegate Tooltip handling to client. Layouts add |
import com.google.gwt.user.client.ui.HTML; | import com.google.gwt.user.client.ui.HTML; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.Icon; | import com.itmill.toolkit.terminal.gwt.client.ui.Icon; | ||||
public class Caption extends HTML { | |||||
public class ICaption extends HTML { | |||||
public static final String CLASSNAME = "i-caption"; | public static final String CLASSNAME = "i-caption"; | ||||
/** | /** | ||||
* | * | ||||
* @param component | * @param component | ||||
* optional owner of caption. If not set, getOwner will | |||||
* return null | |||||
* optional owner of caption. If not set, getOwner will return | |||||
* null | |||||
* @param client | * @param client | ||||
*/ | */ | ||||
public Caption(Paintable component, ApplicationConnection client) { | |||||
public ICaption(Paintable component, ApplicationConnection client) { | |||||
super(); | super(); | ||||
this.client = client; | this.client = client; | ||||
owner = component; | owner = component; |
import com.google.gwt.user.client.ui.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
public class CaptionWrapper extends FlowPanel { | |||||
public class ICaptionWrapper extends FlowPanel { | |||||
public static final String CLASSNAME = "i-captionwrapper"; | public static final String CLASSNAME = "i-captionwrapper"; | ||||
Caption caption; | |||||
ICaption caption; | |||||
Paintable widget; | Paintable widget; | ||||
public CaptionWrapper(Paintable toBeWrapped, ApplicationConnection client) { | |||||
caption = new Caption(toBeWrapped, client); | |||||
public ICaptionWrapper(Paintable toBeWrapped, ApplicationConnection client) { | |||||
caption = new ICaption(toBeWrapped, client); | |||||
add(caption); | add(caption); | ||||
widget = toBeWrapped; | widget = toBeWrapped; | ||||
add((Widget) widget); | add((Widget) widget); |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.IWindow; | import com.itmill.toolkit.terminal.gwt.client.ui.IWindow; | ||||
public final class DebugConsole extends IWindow implements Console { | |||||
public final class IDebugConsole extends IWindow implements Console { | |||||
/** | /** | ||||
* Builds number. For example 0-custom_tag in 5.0.0-custom_tag. | * Builds number. For example 0-custom_tag in 5.0.0-custom_tag. | ||||
private final Panel panel; | private final Panel panel; | ||||
public DebugConsole(ApplicationConnection client, | |||||
public IDebugConsole(ApplicationConnection client, | |||||
ApplicationConfiguration cnf) { | ApplicationConfiguration cnf) { | ||||
super(); | super(); | ||||
this.client = client; | this.client = client; | ||||
private void minimize() { | private void minimize() { | ||||
// TODO stack to bottom (create window manager of some sort) | // TODO stack to bottom (create window manager of some sort) | ||||
setPixelSize(60, 60); | setPixelSize(60, 60); | ||||
setPopupPosition(Window.getClientWidth() | |||||
- 142, 0); | |||||
setPopupPosition(Window.getClientWidth() - 142, 0); | |||||
} | } | ||||
/* | /* | ||||
/* | /* | ||||
* (non-Javadoc) | * (non-Javadoc) | ||||
* | * | ||||
* @see com.itmill.toolkit.terminal.gwt.client.Console#error(java.lang.String) | |||||
* @see | |||||
* com.itmill.toolkit.terminal.gwt.client.Console#error(java.lang.String) | |||||
*/ | */ | ||||
public void error(String msg) { | public void error(String msg) { | ||||
panel.add((new HTML(msg))); | panel.add((new HTML(msg))); | ||||
/* | /* | ||||
* (non-Javadoc) | * (non-Javadoc) | ||||
* | * | ||||
* @see com.itmill.toolkit.terminal.gwt.client.Console#printObject(java.lang.Object) | |||||
* @see | |||||
* com.itmill.toolkit.terminal.gwt.client.Console#printObject(java.lang. | |||||
* Object) | |||||
*/ | */ | ||||
public void printObject(Object msg) { | public void printObject(Object msg) { | ||||
panel.add((new Label(msg.toString()))); | panel.add((new Label(msg.toString()))); | ||||
/* | /* | ||||
* (non-Javadoc) | * (non-Javadoc) | ||||
* | * | ||||
* @see com.itmill.toolkit.terminal.gwt.client.Console#dirUIDL(com.itmill.toolkit.terminal.gwt.client.UIDL) | |||||
* @see | |||||
* com.itmill.toolkit.terminal.gwt.client.Console#dirUIDL(com.itmill.toolkit | |||||
* .terminal.gwt.client.UIDL) | |||||
*/ | */ | ||||
public void dirUIDL(UIDL u) { | public void dirUIDL(UIDL u) { | ||||
panel.add(u.print_r()); | panel.add(u.print_r()); |
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.itmill.toolkit.terminal.gwt.client.ui.ToolkitOverlay; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.IToolkitOverlay; | |||||
public class ErrorMessage extends FlowPanel { | |||||
public class IErrorMessage extends FlowPanel { | |||||
public static final String CLASSNAME = "i-errormessage"; | public static final String CLASSNAME = "i-errormessage"; | ||||
public ErrorMessage() { | |||||
public IErrorMessage() { | |||||
super(); | super(); | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
} | } | ||||
final UIDL.XML xml = (UIDL.XML) child; | final UIDL.XML xml = (UIDL.XML) child; | ||||
add(new HTML(xml.getXMLAsString())); | add(new HTML(xml.getXMLAsString())); | ||||
} else { | } else { | ||||
final ErrorMessage childError = new ErrorMessage(); | |||||
final IErrorMessage childError = new IErrorMessage(); | |||||
add(childError); | add(childError); | ||||
childError.updateFromUIDL((UIDL) child); | childError.updateFromUIDL((UIDL) child); | ||||
} | } | ||||
* @param indicatorElement | * @param indicatorElement | ||||
*/ | */ | ||||
public void showAt(Element indicatorElement) { | public void showAt(Element indicatorElement) { | ||||
ToolkitOverlay errorContainer = (ToolkitOverlay) getParent(); | |||||
IToolkitOverlay errorContainer = (IToolkitOverlay) getParent(); | |||||
if (errorContainer == null) { | if (errorContainer == null) { | ||||
errorContainer = new ToolkitOverlay(); | |||||
errorContainer = new IToolkitOverlay(); | |||||
errorContainer.setWidget(this); | errorContainer.setWidget(this); | ||||
} | } | ||||
errorContainer.setPopupPosition(DOM.getAbsoluteLeft(indicatorElement) | errorContainer.setPopupPosition(DOM.getAbsoluteLeft(indicatorElement) | ||||
} | } | ||||
public void hide() { | public void hide() { | ||||
final ToolkitOverlay errorContainer = (ToolkitOverlay) getParent(); | |||||
final IToolkitOverlay errorContainer = (IToolkitOverlay) getParent(); | |||||
if (errorContainer != null) { | if (errorContainer != null) { | ||||
errorContainer.hide(); | errorContainer.hide(); | ||||
} | } |
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.FlowPanel; | import com.google.gwt.user.client.ui.FlowPanel; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.ToolkitOverlay; | |||||
import com.itmill.toolkit.terminal.gwt.client.ui.IToolkitOverlay; | |||||
/** | /** | ||||
* TODO open for extension | * TODO open for extension | ||||
*/ | */ | ||||
public class Tooltip extends ToolkitOverlay { | |||||
public class ITooltip extends IToolkitOverlay { | |||||
private static final String CLASSNAME = "i-tooltip"; | private static final String CLASSNAME = "i-tooltip"; | ||||
private static final int MARGIN = 4; | private static final int MARGIN = 4; | ||||
public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN | public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN | ||||
| Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE | | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE | ||||
| Event.ONCLICK; | | Event.ONCLICK; | ||||
protected static final int MAX_WIDTH = 500; | protected static final int MAX_WIDTH = 500; | ||||
ErrorMessage em = new ErrorMessage(); | |||||
IErrorMessage em = new IErrorMessage(); | |||||
Element description = DOM.createDiv(); | Element description = DOM.createDiv(); | ||||
private Paintable tooltipOwner; | private Paintable tooltipOwner; | ||||
private boolean closing = false; | private boolean closing = false; | ||||
private boolean opening = false; | private boolean opening = false; | ||||
private ApplicationConnection ac; | private ApplicationConnection ac; | ||||
public Tooltip(ApplicationConnection client) { | |||||
public ITooltip(ApplicationConnection client) { | |||||
super(false, false, true); | super(false, false, true); | ||||
ac = client; | ac = client; | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
public void handleTooltipEvent(Event event, Paintable owner) { | public void handleTooltipEvent(Event event, Paintable owner) { | ||||
final int type = DOM.eventGetType(event); | final int type = DOM.eventGetType(event); | ||||
if ((Tooltip.TOOLTIP_EVENTS & type) == type) { | |||||
if ((ITooltip.TOOLTIP_EVENTS & type) == type) { | |||||
if (type == Event.ONMOUSEOVER) { | if (type == Event.ONMOUSEOVER) { | ||||
showTooltip(owner, event); | showTooltip(owner, event); | ||||
} else if (type == Event.ONMOUSEMOVE) { | } else if (type == Event.ONMOUSEMOVE) { |
return s; | return s; | ||||
} | } | ||||
public UIDLBrowser print_r() { | |||||
return new UIDLBrowser(); | |||||
public IUIDLBrowser print_r() { | |||||
return new IUIDLBrowser(); | |||||
} | } | ||||
private class UIDLBrowser extends Tree { | |||||
public UIDLBrowser() { | |||||
private class IUIDLBrowser extends Tree { | |||||
public IUIDLBrowser() { | |||||
DOM.setStyleAttribute(getElement(), "position", ""); | DOM.setStyleAttribute(getElement(), "position", ""); | ||||
public void onTreeItemStateChanged(TreeItem item) { | public void onTreeItemStateChanged(TreeItem item) { | ||||
if (item == root) { | if (item == root) { | ||||
removeItem(root); | removeItem(root); | ||||
UIDLBrowser.this.removeTreeListener(this); | |||||
IUIDLBrowser.this.removeTreeListener(this); | |||||
addItem(dir()); | addItem(dir()); | ||||
final Iterator it = treeItemIterator(); | final Iterator it = treeItemIterator(); | ||||
while (it.hasNext()) { | while (it.hasNext()) { |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
*/ | */ | ||||
protected class StackItem extends ComplexPanel implements ClickListener { | protected class StackItem extends ComplexPanel implements ClickListener { | ||||
private Caption caption; | |||||
private ICaption caption; | |||||
private boolean open = false; | private boolean open = false; | ||||
private Element content = DOM.createDiv(); | private Element content = DOM.createDiv(); | ||||
private Element captionNode = DOM.createDiv(); | private Element captionNode = DOM.createDiv(); | ||||
public StackItem(UIDL tabUidl) { | public StackItem(UIDL tabUidl) { | ||||
setElement(DOM.createDiv()); | setElement(DOM.createDiv()); | ||||
caption = new Caption(null, client); | |||||
caption = new ICaption(null, client); | |||||
caption.addClickListener(this); | caption.addClickListener(this); | ||||
super.add(caption, captionNode); | super.add(caption, captionNode); | ||||
DOM.appendChild(captionNode, caption.getElement()); | DOM.appendChild(captionNode, caption.getElement()); |
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
public class IButton extends Button implements Paintable { | public class IButton extends Button implements Paintable { | ||||
client.updateVariable(id, "state", true, true); | client.updateVariable(id, "state", true, true); | ||||
} | } | ||||
}); | }); | ||||
sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | ||||
import com.itmill.toolkit.terminal.gwt.client.LocaleService; | import com.itmill.toolkit.terminal.gwt.client.LocaleService; | ||||
public class CalendarPanel extends FlexTable implements MouseListener, | |||||
public class ICalendarPanel extends FlexTable implements MouseListener, | |||||
ClickListener { | ClickListener { | ||||
private final IDateField datefield; | private final IDateField datefield; | ||||
private IEventButton nextMonth; | private IEventButton nextMonth; | ||||
private Time time; | |||||
private ITime time; | |||||
private Date minDate = null; | private Date minDate = null; | ||||
/* Needed to identify locale changes */ | /* Needed to identify locale changes */ | ||||
private String locale = LocaleService.getDefaultLocale(); | private String locale = LocaleService.getDefaultLocale(); | ||||
public CalendarPanel(IDateField parent) { | |||||
public ICalendarPanel(IDateField parent) { | |||||
datefield = parent; | datefield = parent; | ||||
setStyleName(IDateField.CLASSNAME + "-calendarpanel"); | setStyleName(IDateField.CLASSNAME + "-calendarpanel"); | ||||
// buildCalendar(true); | // buildCalendar(true); | ||||
addTableListener(new DateClickListener(this)); | addTableListener(new DateClickListener(this)); | ||||
} | } | ||||
public CalendarPanel(IDateField parent, Date min, Date max) { | |||||
public ICalendarPanel(IDateField parent, Date min, Date max) { | |||||
datefield = parent; | datefield = parent; | ||||
setStyleName(IDateField.CLASSNAME + "-calendarpanel"); | setStyleName(IDateField.CLASSNAME + "-calendarpanel"); | ||||
// buildCalendar(true); | // buildCalendar(true); | ||||
private void buildTime(boolean forceRedraw) { | private void buildTime(boolean forceRedraw) { | ||||
if (time == null) { | if (time == null) { | ||||
time = new Time(datefield); | |||||
time = new ITime(datefield); | |||||
setText(8, 0, ""); // Add new row | setText(8, 0, ""); // Add new row | ||||
getFlexCellFormatter().setColSpan(8, 0, 7); | getFlexCellFormatter().setColSpan(8, 0, 7); | ||||
setWidget(8, 0, time); | setWidget(8, 0, time); | ||||
/** | /** | ||||
* | * | ||||
* @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 | |||||
*/ | */ | ||||
public void updateCalendar() { | public void updateCalendar() { | ||||
// Locale and resolution changes force a complete redraw | // Locale and resolution changes force a complete redraw | ||||
private class DateClickListener implements TableListener { | private class DateClickListener implements TableListener { | ||||
private final CalendarPanel cal; | |||||
private final ICalendarPanel cal; | |||||
public DateClickListener(CalendarPanel panel) { | |||||
public DateClickListener(ICalendarPanel panel) { | |||||
cal = panel; | cal = panel; | ||||
} | } | ||||
if (datefield instanceof ITextualDate | if (datefield instanceof ITextualDate | ||||
&& resolution < IDateField.RESOLUTION_HOUR) { | && resolution < IDateField.RESOLUTION_HOUR) { | ||||
((ToolkitOverlay) getParent()).hide(); | |||||
((IToolkitOverlay) getParent()).hide(); | |||||
} else { | } else { | ||||
updateCalendar(); | updateCalendar(); | ||||
} | } |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements | public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements | ||||
} | } | ||||
}); | }); | ||||
sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
import com.google.gwt.user.client.ui.MenuItem; | import com.google.gwt.user.client.ui.MenuItem; | ||||
import com.google.gwt.user.client.ui.PopupPanel; | import com.google.gwt.user.client.ui.PopupPanel; | ||||
public class ContextMenu extends ToolkitOverlay { | |||||
public class IContextMenu extends IToolkitOverlay { | |||||
private ActionOwner actionOwner; | private ActionOwner actionOwner; | ||||
* should exists. Request an instance via client.getContextMenu(); | * should exists. Request an instance via client.getContextMenu(); | ||||
* | * | ||||
* @param cli | * @param cli | ||||
* to be set as an owner of menu | |||||
* to be set as an owner of menu | |||||
*/ | */ | ||||
public ContextMenu() { | |||||
public IContextMenu() { | |||||
super(true, false, true); | super(true, false, true); | ||||
setWidget(menu); | setWidget(menu); | ||||
setStyleName("i-contextmenu"); | setStyleName("i-contextmenu"); | ||||
// mac FF gets bad width due GWT popups overflow hacks, | // mac FF gets bad width due GWT popups overflow hacks, | ||||
// re-determine width | // re-determine width | ||||
offsetWidth = menu.getOffsetWidth(); | offsetWidth = menu.getOffsetWidth(); | ||||
int left = ContextMenu.this.left; | |||||
int top = ContextMenu.this.top; | |||||
int left = IContextMenu.this.left; | |||||
int top = IContextMenu.this.top; | |||||
if (offsetWidth + left > Window.getClientWidth()) { | if (offsetWidth + left > Window.getClientWidth()) { | ||||
left = left - offsetWidth; | left = left - offsetWidth; | ||||
if (left < 0) { | if (left < 0) { | ||||
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | public void onPopupClosed(PopupPanel sender, boolean autoClosed) { | ||||
super.onPopupClosed(sender, autoClosed); | super.onPopupClosed(sender, autoClosed); | ||||
ContextMenu.this.hide(); | |||||
hide(); | |||||
} | } | ||||
/*public void onBrowserEvent(Event event) { | |||||
// Remove current selection when mouse leaves | |||||
if (DOM.eventGetType(event) == Event.ONMOUSEOUT) { | |||||
Element to = DOM.eventGetToElement(event); | |||||
if (!DOM.isOrHasChild(getElement(), to)) { | |||||
DOM.setElementProperty( | |||||
super.getSelectedItem().getElement(), "className", | |||||
super.getSelectedItem().getStylePrimaryName()); | |||||
} | |||||
} | |||||
super.onBrowserEvent(event); | |||||
}*/ | |||||
/* | |||||
* public void onBrowserEvent(Event event) { // Remove current selection | |||||
* when mouse leaves if (DOM.eventGetType(event) == Event.ONMOUSEOUT) { | |||||
* Element to = DOM.eventGetToElement(event); if | |||||
* (!DOM.isOrHasChild(getElement(), to)) { DOM.setElementProperty( | |||||
* super.getSelectedItem().getElement(), "className", | |||||
* super.getSelectedItem().getStylePrimaryName()); } } | |||||
* | |||||
* super.onBrowserEvent(event); } | |||||
*/ | |||||
} | } | ||||
} | } |
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.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
/** Update caption for given widget */ | /** Update caption for given widget */ | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper | |||||
ICaptionWrapper wrapper = (ICaptionWrapper) widgetToCaptionWrapper | |||||
.get(component); | .get(component); | ||||
if (Caption.isNeeded(uidl)) { | |||||
if (ICaption.isNeeded(uidl)) { | |||||
if (wrapper == null) { | if (wrapper == null) { | ||||
final String loc = getLocation((Widget) component); | final String loc = getLocation((Widget) component); | ||||
super.remove((Widget) component); | super.remove((Widget) component); | ||||
wrapper = new CaptionWrapper(component, client); | |||||
wrapper = new ICaptionWrapper(component, client); | |||||
super.add(wrapper, (Element) locationToElement.get(loc)); | super.add(wrapper, (Element) locationToElement.get(loc)); | ||||
widgetToCaptionWrapper.put(component, wrapper); | widgetToCaptionWrapper.put(component, wrapper); | ||||
} | } | ||||
if (location != null) { | if (location != null) { | ||||
locationToWidget.remove(location); | locationToWidget.remove(location); | ||||
} | } | ||||
final CaptionWrapper cw = (CaptionWrapper) widgetToCaptionWrapper | |||||
final ICaptionWrapper cw = (ICaptionWrapper) widgetToCaptionWrapper | |||||
.get(w); | .get(w); | ||||
if (cw != null) { | if (cw != null) { | ||||
widgetToCaptionWrapper.remove(w); | widgetToCaptionWrapper.remove(w); |
import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | import com.itmill.toolkit.terminal.gwt.client.DateTimeService; | ||||
import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; | import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
public class IDateField extends FlowPanel implements Paintable, Field { | public class IDateField extends FlowPanel implements Paintable, Field { | ||||
public IDateField() { | public IDateField() { | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
dts = new DateTimeService(); | dts = new DateTimeService(); | ||||
sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
} | } | ||||
public void onBrowserEvent(Event event) { | public void onBrowserEvent(Event event) { |
public class IDateFieldCalendar extends IDateField { | public class IDateFieldCalendar extends IDateField { | ||||
private final CalendarPanel date; | |||||
private final ICalendarPanel date; | |||||
public IDateFieldCalendar() { | public IDateFieldCalendar() { | ||||
super(); | super(); | ||||
date = new CalendarPanel(this); | |||||
date = new ICalendarPanel(this); | |||||
add(date); | add(date); | ||||
} | } | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
} | } | ||||
protected void insert(Widget w, int beforeIndex) { | protected void insert(Widget w, int beforeIndex) { | ||||
if (w instanceof Caption) { | |||||
final Caption c = (Caption) w; | |||||
if (w instanceof ICaption) { | |||||
final ICaption c = (ICaption) w; | |||||
// captions go into same container element as their | // captions go into same container element as their | ||||
// owners | // owners | ||||
final Element container = DOM.getParent(((UIObject) c.getOwner()) | final Element container = DOM.getParent(((UIObject) c.getOwner()) | ||||
final WidgetWrapper ww = getWidgetWrapperFor(w); | final WidgetWrapper ww = getWidgetWrapperFor(w); | ||||
final boolean removed = super.remove(w); | final boolean removed = super.remove(w); | ||||
if (removed) { | if (removed) { | ||||
if (!(w instanceof Caption)) { | |||||
if (!(w instanceof ICaption)) { | |||||
DOM.removeChild(childContainer, ww.getElement()); | DOM.removeChild(childContainer, ww.getElement()); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
public void removeCaption(Widget w) { | public void removeCaption(Widget w) { | ||||
final Caption c = (Caption) componentToCaption.get(w); | |||||
final ICaption c = (ICaption) componentToCaption.get(w); | |||||
if (c != null) { | if (c != null) { | ||||
this.remove(c); | this.remove(c); | ||||
componentToCaption.remove(w); | componentToCaption.remove(w); | ||||
} | } | ||||
public boolean removePaintable(Paintable p) { | public boolean removePaintable(Paintable p) { | ||||
final Caption c = (Caption) componentToCaption.get(p); | |||||
final ICaption c = (ICaption) componentToCaption.get(p); | |||||
if (c != null) { | if (c != null) { | ||||
componentToCaption.remove(c); | componentToCaption.remove(c); | ||||
remove(c); | remove(c); | ||||
public void replaceChildComponent(Widget from, Widget to) { | public void replaceChildComponent(Widget from, Widget to) { | ||||
client.unregisterPaintable((Paintable) from); | client.unregisterPaintable((Paintable) from); | ||||
final Caption c = (Caption) componentToCaption.get(from); | |||||
final ICaption c = (ICaption) componentToCaption.get(from); | |||||
if (c != null) { | if (c != null) { | ||||
remove(c); | remove(c); | ||||
componentToCaption.remove(c); | componentToCaption.remove(c); | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
Caption c = (Caption) componentToCaption.get(component); | |||||
ICaption c = (ICaption) componentToCaption.get(component); | |||||
if (Caption.isNeeded(uidl)) { | |||||
if (ICaption.isNeeded(uidl)) { | |||||
if (c == null) { | if (c == null) { | ||||
final int index = getWidgetIndex((Widget) component); | final int index = getWidgetIndex((Widget) component); | ||||
c = new Caption(component, client); | |||||
c = new ICaption(component, client); | |||||
insert(c, index); | insert(c, index); | ||||
componentToCaption.put(component, c); | componentToCaption.put(component, c); | ||||
} | } |
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Focusable; | import com.itmill.toolkit.terminal.gwt.client.Focusable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
import com.itmill.toolkit.terminal.gwt.client.Util; | import com.itmill.toolkit.terminal.gwt.client.Util; | ||||
* @author mattitahvonen | * @author mattitahvonen | ||||
* | * | ||||
*/ | */ | ||||
public class SuggestionPopup extends ToolkitOverlay implements | |||||
public class SuggestionPopup extends IToolkitOverlay implements | |||||
PositionCallback, PopupListener { | PositionCallback, PopupListener { | ||||
private static final int EXTRASPACE = 8; | private static final int EXTRASPACE = 8; | ||||
public IFilterSelect() { | public IFilterSelect() { | ||||
selectedItemIcon.setVisible(false); | selectedItemIcon.setVisible(false); | ||||
panel.add(selectedItemIcon); | panel.add(selectedItemIcon); | ||||
tb.sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
tb.sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
panel.add(tb); | panel.add(tb); | ||||
panel.add(popupOpener); | panel.add(popupOpener); | ||||
initWidget(panel); | initWidget(panel); |
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.ErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.IErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
import com.itmill.toolkit.terminal.gwt.client.Util; | import com.itmill.toolkit.terminal.gwt.client.Util; | ||||
private Element errorIndicatorElement = DOM.createDiv(); | private Element errorIndicatorElement = DOM.createDiv(); | ||||
private Element desc = DOM.createDiv(); | private Element desc = DOM.createDiv(); | ||||
private Icon icon; | private Icon icon; | ||||
private ErrorMessage errorMessage = new ErrorMessage(); | |||||
private IErrorMessage errorMessage = new IErrorMessage(); | |||||
private Element fieldContainer = DOM.createDiv(); | private Element fieldContainer = DOM.createDiv(); | ||||
import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant; | import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
formatter.setAlignment(row, column, ha, va); | formatter.setAlignment(row, column, ha, va); | ||||
final Paintable child = client.getPaintable(u); | final Paintable child = client.getPaintable(u); | ||||
CaptionWrapper wr; | |||||
ICaptionWrapper wr; | |||||
if (widgetToCaptionWrapper.containsKey(child)) { | if (widgetToCaptionWrapper.containsKey(child)) { | ||||
wr = (CaptionWrapper) widgetToCaptionWrapper | |||||
wr = (ICaptionWrapper) widgetToCaptionWrapper | |||||
.get(child); | .get(child); | ||||
oldWidgetWrappers.remove(wr); | oldWidgetWrappers.remove(wr); | ||||
} else { | } else { | ||||
wr = new CaptionWrapper(child, client); | |||||
wr = new ICaptionWrapper(child, client); | |||||
widgetToCaptionWrapper.put(child, wr); | widgetToCaptionWrapper.put(child, wr); | ||||
} | } | ||||
// loop oldWidgetWrappers that where not re-attached and unregister | // loop oldWidgetWrappers that where not re-attached and unregister | ||||
// them | // them | ||||
for (final Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) { | for (final Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) { | ||||
final CaptionWrapper w = (CaptionWrapper) it.next(); | |||||
final ICaptionWrapper w = (ICaptionWrapper) it.next(); | |||||
client.unregisterPaintable(w.getPaintable()); | client.unregisterPaintable(w.getPaintable()); | ||||
widgetToCaptionWrapper.remove(w.getPaintable()); | widgetToCaptionWrapper.remove(w.getPaintable()); | ||||
} | } | ||||
} | } | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
final CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper | |||||
final ICaptionWrapper wrapper = (ICaptionWrapper) widgetToCaptionWrapper | |||||
.get(component); | .get(component); | ||||
wrapper.updateCaption(uidl); | wrapper.updateCaption(uidl); | ||||
} | } |
import com.google.gwt.user.client.ui.HTML; | import com.google.gwt.user.client.ui.HTML; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.ErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.IErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
private final Element captionElement = DOM.createSpan(); | private final Element captionElement = DOM.createSpan(); | ||||
private ErrorMessage errorMessage; | |||||
private IErrorMessage errorMessage; | |||||
private Icon icon; | private Icon icon; | ||||
} | } | ||||
DOM.insertChild(getElement(), errorIndicatorElement, 0); | DOM.insertChild(getElement(), errorIndicatorElement, 0); | ||||
if (errorMessage == null) { | if (errorMessage == null) { | ||||
errorMessage = new ErrorMessage(); | |||||
errorMessage = new IErrorMessage(); | |||||
} | } | ||||
errorMessage.updateFromUIDL(errorUidl); | errorMessage.updateFromUIDL(errorUidl); | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
public class IListSelect extends IOptionGroupBase { | public class IListSelect extends IOptionGroupBase { | ||||
TooltipListBox(boolean isMultiselect) { | TooltipListBox(boolean isMultiselect) { | ||||
super(isMultiselect); | super(isMultiselect); | ||||
sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
} | } | ||||
public void setClient(ApplicationConnection client) { | public void setClient(ApplicationConnection client) { |
boolean subMenu; | boolean subMenu; | ||||
ArrayList items; | ArrayList items; | ||||
Element containerElement; | Element containerElement; | ||||
ToolkitOverlay popup; | |||||
IToolkitOverlay popup; | |||||
IMenuBar visibleChildMenu; | IMenuBar visibleChildMenu; | ||||
IMenuBar parentMenu; | IMenuBar parentMenu; | ||||
CustomMenuItem selected; | CustomMenuItem selected; | ||||
* @param item | * @param item | ||||
*/ | */ | ||||
public void showChildMenu(CustomMenuItem item) { | public void showChildMenu(CustomMenuItem item) { | ||||
popup = new ToolkitOverlay(true, false, true); | |||||
popup = new IToolkitOverlay(true, false, true); | |||||
popup.setWidget(item.getSubMenu()); | popup.setWidget(item.getSubMenu()); | ||||
popup.addPopupListener(this); | popup.addPopupListener(this); | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
public class Notification extends ToolkitOverlay { | |||||
public class INotification extends IToolkitOverlay { | |||||
public static final int CENTERED = 1; | public static final int CENTERED = 1; | ||||
public static final int CENTERED_TOP = 2; | public static final int CENTERED_TOP = 2; | ||||
private ArrayList listeners; | private ArrayList listeners; | ||||
public Notification() { | |||||
public INotification() { | |||||
setStylePrimaryName(STYLENAME); | setStylePrimaryName(STYLENAME); | ||||
sinkEvents(Event.ONCLICK); | sinkEvents(Event.ONCLICK); | ||||
DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE); | DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE); | ||||
} | } | ||||
public Notification(int delayMsec) { | |||||
public INotification(int delayMsec) { | |||||
this(); | this(); | ||||
this.delayMsec = delayMsec; | this.delayMsec = delayMsec; | ||||
} | } | ||||
public Notification(int delayMsec, int fadeMsec, int startOpacity) { | |||||
public INotification(int delayMsec, int fadeMsec, int startOpacity) { | |||||
this(delayMsec); | this(delayMsec); | ||||
this.fadeMsec = fadeMsec; | this.fadeMsec = fadeMsec; | ||||
this.startOpacity = startOpacity; | this.startOpacity = startOpacity; |
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
Element clipperDiv; | Element clipperDiv; | ||||
/** Caption element when used. */ | /** Caption element when used. */ | ||||
Caption caption = null; | |||||
ICaption caption = null; | |||||
/** | /** | ||||
* Last set pixel height for the wrapper. -1 if vertical clipping is not | * Last set pixel height for the wrapper. -1 if vertical clipping is not | ||||
final Element captionWrapper = getElementWrappingWidgetAndCaption(); | final Element captionWrapper = getElementWrappingWidgetAndCaption(); | ||||
// The widget needs caption | // The widget needs caption | ||||
if (Caption.isNeeded(uidl)) { | |||||
if (ICaption.isNeeded(uidl)) { | |||||
// If the caption element is missing, create it | // If the caption element is missing, create it | ||||
boolean justAdded = false; | boolean justAdded = false; | ||||
if (caption == null) { | if (caption == null) { | ||||
justAdded = true; | justAdded = true; | ||||
caption = new Caption(paintable, client); | |||||
caption = new ICaption(paintable, client); | |||||
} | } | ||||
// Update caption contents | // Update caption contents |
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.ErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.IErrorMessage; | |||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
import com.itmill.toolkit.terminal.gwt.client.Util; | import com.itmill.toolkit.terminal.gwt.client.Util; | ||||
private Element errorIndicatorElement; | private Element errorIndicatorElement; | ||||
private ErrorMessage errorMessage; | |||||
private IErrorMessage errorMessage; | |||||
private String height; | private String height; | ||||
} | } | ||||
DOM.insertBefore(captionNode, errorIndicatorElement, captionText); | DOM.insertBefore(captionNode, errorIndicatorElement, captionText); | ||||
if (errorMessage == null) { | if (errorMessage == null) { | ||||
errorMessage = new ErrorMessage(); | |||||
errorMessage = new IErrorMessage(); | |||||
} | } | ||||
errorMessage.updateFromUIDL(errorUidl); | errorMessage.updateFromUIDL(errorUidl); | ||||
private final Button calendarToggle; | private final Button calendarToggle; | ||||
private final CalendarPanel calendar; | |||||
private final ICalendarPanel calendar; | |||||
private final ToolkitOverlay popup; | |||||
private final IToolkitOverlay popup; | |||||
private boolean open = false; | private boolean open = false; | ||||
public IPopupCalendar() { | public IPopupCalendar() { | ||||
calendarToggle.addClickListener(this); | calendarToggle.addClickListener(this); | ||||
add(calendarToggle); | add(calendarToggle); | ||||
calendar = new CalendarPanel(this); | |||||
popup = new ToolkitOverlay(true, true, true); | |||||
calendar = new ICalendarPanel(this); | |||||
popup = new IToolkitOverlay(true, true, true); | |||||
popup.setStyleName(IDateField.CLASSNAME + "-popup"); | popup.setStyleName(IDateField.CLASSNAME + "-popup"); | ||||
popup.setWidget(calendar); | popup.setWidget(calendar); | ||||
popup.addPopupListener(this); | popup.addPopupListener(this); |
import com.google.gwt.user.client.ui.RootPanel; | import com.google.gwt.user.client.ui.RootPanel; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaptionWrapper; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
} | } | ||||
}-*/; | }-*/; | ||||
private class CustomPopup extends ToolkitOverlay implements Container { | |||||
private class CustomPopup extends IToolkitOverlay implements Container { | |||||
private Paintable popupComponentPaintable = null; | private Paintable popupComponentPaintable = null; | ||||
private Widget popupComponentWidget = null; | private Widget popupComponentWidget = null; | ||||
private CaptionWrapper captionWrapper = null; | |||||
private ICaptionWrapper captionWrapper = null; | |||||
private boolean hasHadMouseOver = false; | private boolean hasHadMouseOver = false; | ||||
private Set activeChildren; | private Set activeChildren; | ||||
} | } | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
if (Caption.isNeeded(uidl)) { | |||||
if (ICaption.isNeeded(uidl)) { | |||||
if (captionWrapper != null) { | if (captionWrapper != null) { | ||||
captionWrapper.updateCaption(uidl); | captionWrapper.updateCaption(uidl); | ||||
} else { | } else { | ||||
captionWrapper = new CaptionWrapper(component, client); | |||||
captionWrapper = new ICaptionWrapper(component, client); | |||||
setWidget(captionWrapper); | setWidget(captionWrapper); | ||||
captionWrapper.updateCaption(uidl); | captionWrapper.updateCaption(uidl); | ||||
} | } |
import com.google.gwt.user.client.ui.Label; | import com.google.gwt.user.client.ui.Label; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
return getWidgetCount(); | return getWidgetCount(); | ||||
} | } | ||||
public void addTab(Caption c) { | |||||
public void addTab(ICaption c) { | |||||
Element td = DOM.createTD(); | Element td = DOM.createTD(); | ||||
setStyleName(td, CLASSNAME + "-tabitemcell"); | setStyleName(td, CLASSNAME + "-tabitemcell"); | ||||
} | } | ||||
public boolean remove(Widget w) { | public boolean remove(Widget w) { | ||||
((Caption) w).removeClickListener(this); | |||||
((ICaption) w).removeClickListener(this); | |||||
return super.remove(w); | return super.remove(w); | ||||
} | } | ||||
public Caption getTab(int index) { | |||||
public ICaption getTab(int index) { | |||||
if (index >= getWidgetCount()) { | if (index >= getWidgetCount()) { | ||||
return null; | return null; | ||||
} | } | ||||
return (Caption) getWidget(index); | |||||
return (ICaption) getWidget(index); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
protected void renderTab(final UIDL tabUidl, int index, boolean selected) { | protected void renderTab(final UIDL tabUidl, int index, boolean selected) { | ||||
Caption c = tb.getTab(index); | |||||
ICaption c = tb.getTab(index); | |||||
if (c == null) { | if (c == null) { | ||||
c = new Caption(null, client); | |||||
c = new ICaption(null, client); | |||||
tb.addTab(c); | tb.addTab(c); | ||||
} | } | ||||
c.updateCaption(tabUidl); | c.updateCaption(tabUidl); | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
int i = tp.getWidgetIndex((Widget) component); | int i = tp.getWidgetIndex((Widget) component); | ||||
Caption c = (Caption) captions.get("" + i); | |||||
ICaption c = (ICaption) captions.get("" + i); | |||||
c.updateCaption(uidl); | c.updateCaption(uidl); | ||||
} | } | ||||
} | } |
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.Tooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.ITooltip; | |||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
import com.itmill.toolkit.terminal.gwt.client.Util; | import com.itmill.toolkit.terminal.gwt.client.Util; | ||||
setStyleName(CLASSNAME); | setStyleName(CLASSNAME); | ||||
addChangeListener(this); | addChangeListener(this); | ||||
addFocusListener(this); | addFocusListener(this); | ||||
sinkEvents(Tooltip.TOOLTIP_EVENTS); | |||||
sinkEvents(ITooltip.TOOLTIP_EVENTS); | |||||
} | } | ||||
public void onBrowserEvent(Event event) { | public void onBrowserEvent(Event 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.google.gwt.user.client.ui.Widget; | ||||
public class Time extends FlowPanel implements ChangeListener { | |||||
public class ITime extends FlowPanel implements ChangeListener { | |||||
private final IDateField datefield; | private final IDateField datefield; | ||||
private boolean readonly; | private boolean readonly; | ||||
public Time(IDateField parent) { | |||||
public ITime(IDateField parent) { | |||||
super(); | super(); | ||||
datefield = parent; | datefield = parent; | ||||
setStyleName(IDateField.CLASSNAME + "-time"); | setStyleName(IDateField.CLASSNAME + "-time"); |
* temporary float over other components like context menus etc. This is to deal | * temporary float over other components like context menus etc. This is to deal | ||||
* stacking order correctly with IWindow objects. | * stacking order correctly with IWindow objects. | ||||
*/ | */ | ||||
public class ToolkitOverlay extends PopupPanel { | |||||
public class IToolkitOverlay extends PopupPanel { | |||||
public static final int Z_INDEX = 20000; | public static final int Z_INDEX = 20000; | ||||
private Shadow shadow; | private Shadow shadow; | ||||
public ToolkitOverlay() { | |||||
public IToolkitOverlay() { | |||||
super(); | super(); | ||||
adjustZIndex(); | adjustZIndex(); | ||||
} | } | ||||
public ToolkitOverlay(boolean autoHide) { | |||||
public IToolkitOverlay(boolean autoHide) { | |||||
super(autoHide); | super(autoHide); | ||||
adjustZIndex(); | adjustZIndex(); | ||||
} | } | ||||
public ToolkitOverlay(boolean autoHide, boolean modal) { | |||||
public IToolkitOverlay(boolean autoHide, boolean modal) { | |||||
super(autoHide, modal); | super(autoHide, modal); | ||||
adjustZIndex(); | adjustZIndex(); | ||||
} | } | ||||
public ToolkitOverlay(boolean autoHide, boolean modal, boolean showShadow) { | |||||
public IToolkitOverlay(boolean autoHide, boolean modal, boolean showShadow) { | |||||
super(autoHide, modal); | super(autoHide, modal); | ||||
if (showShadow) { | if (showShadow) { | ||||
shadow = new Shadow(); | shadow = new Shadow(); | ||||
public void updateSizeAndPosition() { | public void updateSizeAndPosition() { | ||||
// Calculate proper z-index | // Calculate proper z-index | ||||
String zIndex = DOM.getStyleAttribute(ToolkitOverlay.this | |||||
String zIndex = DOM.getStyleAttribute(IToolkitOverlay.this | |||||
.getElement(), "zIndex"); | .getElement(), "zIndex"); | ||||
if (zIndex == null) { | if (zIndex == null) { | ||||
zIndex = "" + Z_INDEX; | zIndex = "" + Z_INDEX; | ||||
// Calculate position and size | // Calculate position and size | ||||
if (BrowserInfo.get().isIE()) { | if (BrowserInfo.get().isIE()) { | ||||
// Shake IE | // Shake IE | ||||
ToolkitOverlay.this.getOffsetHeight(); | |||||
ToolkitOverlay.this.getOffsetWidth(); | |||||
IToolkitOverlay.this.getOffsetHeight(); | |||||
IToolkitOverlay.this.getOffsetWidth(); | |||||
} | } | ||||
int x = ToolkitOverlay.this.getAbsoluteLeft() - left; | |||||
int y = ToolkitOverlay.this.getAbsoluteTop() - top; | |||||
int width = ToolkitOverlay.this.getOffsetWidth() + left + right; | |||||
int height = ToolkitOverlay.this.getOffsetHeight() + top + bottom; | |||||
int x = IToolkitOverlay.this.getAbsoluteLeft() - left; | |||||
int y = IToolkitOverlay.this.getAbsoluteTop() - top; | |||||
int width = IToolkitOverlay.this.getOffsetWidth() + left + right; | |||||
int height = IToolkitOverlay.this.getOffsetHeight() + top + bottom; | |||||
if (width < 0) { | if (width < 0) { | ||||
width = 0; | width = 0; | ||||
} | } | ||||
this.right = right; | this.right = right; | ||||
this.bottom = bottom; | this.bottom = bottom; | ||||
this.left = left; | this.left = left; | ||||
if (ToolkitOverlay.this.isAttached()) { | |||||
if (IToolkitOverlay.this.isAttached()) { | |||||
updateSizeAndPosition(); | updateSizeAndPosition(); | ||||
} | } | ||||
} | } |
final int position = notification | final int position = notification | ||||
.getIntAttribute("position"); | .getIntAttribute("position"); | ||||
final int delay = notification.getIntAttribute("delay"); | final int delay = notification.getIntAttribute("delay"); | ||||
new Notification(delay).show(html, position, style); | |||||
new INotification(delay).show(html, position, style); | |||||
} | } | ||||
} | } | ||||
} | } |
final int position = notification | final int position = notification | ||||
.getIntAttribute("position"); | .getIntAttribute("position"); | ||||
final int delay = notification.getIntAttribute("delay"); | final int delay = notification.getIntAttribute("delay"); | ||||
new Notification(delay).show(html, position, style); | |||||
new INotification(delay).show(html, position, style); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
DOM.setStyleAttribute(draggingCurtain, "width", "100%"); | DOM.setStyleAttribute(draggingCurtain, "width", "100%"); | ||||
DOM.setStyleAttribute(draggingCurtain, "height", "100%"); | DOM.setStyleAttribute(draggingCurtain, "height", "100%"); | ||||
DOM.setStyleAttribute(draggingCurtain, "zIndex", "" | DOM.setStyleAttribute(draggingCurtain, "zIndex", "" | ||||
+ ToolkitOverlay.Z_INDEX); | |||||
+ IToolkitOverlay.Z_INDEX); | |||||
DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain); | DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain); | ||||
} else if (!show && draggingCurtain != null) { | } else if (!show && draggingCurtain != null) { |
* <img class='gallery' src='MenuBar.png'/> | * <img class='gallery' src='MenuBar.png'/> | ||||
* </p> | * </p> | ||||
* | * | ||||
* <h3>CSS Style Rules</h3> | |||||
* <ul class='css'> | |||||
* <li>.gwt-MenuBar { the menu bar itself }</li> | |||||
* <li>.gwt-MenuBar .gwt-MenuItem { menu items }</li> | |||||
* <li>.gwt-MenuBar .gwt-MenuItem-selected { selected menu items }</li> | |||||
* </ul> | |||||
* <h3>CSS Style Rules</h3> <ul class='css'> <li>.gwt-MenuBar { the menu bar | |||||
* itself }</li> <li>.gwt-MenuBar .gwt-MenuItem { menu items }</li> <li> | |||||
* .gwt-MenuBar .gwt-MenuItem-selected { selected menu items }</li> </ul> | |||||
* | * | ||||
* <p> | * <p> | ||||
* <h3>Example</h3> | * <h3>Example</h3> | ||||
* Creates an empty menu bar. | * Creates an empty menu bar. | ||||
* | * | ||||
* @param vertical | * @param vertical | ||||
* <code>true</code> to orient the menu bar vertically | |||||
* <code>true</code> to orient the menu bar vertically | |||||
*/ | */ | ||||
public MenuBar(boolean vertical) { | public MenuBar(boolean vertical) { | ||||
super(); | super(); | ||||
* Adds a menu item to the bar. | * Adds a menu item to the bar. | ||||
* | * | ||||
* @param item | * @param item | ||||
* the item to be added | |||||
* the item to be added | |||||
*/ | */ | ||||
public void addItem(MenuItem item) { | public void addItem(MenuItem item) { | ||||
Element tr; | Element tr; | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param asHTML | * @param asHTML | ||||
* <code>true</code> to treat the specified text as html | |||||
* <code>true</code> to treat the specified text as html | |||||
* @param cmd | * @param cmd | ||||
* the command to be fired | |||||
* the command to be fired | |||||
* @return the {@link MenuItem} object created | * @return the {@link MenuItem} object created | ||||
*/ | */ | ||||
public MenuItem addItem(String text, boolean asHTML, Command cmd) { | public MenuItem addItem(String text, boolean asHTML, Command cmd) { | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param asHTML | * @param asHTML | ||||
* <code>true</code> to treat the specified text as html | |||||
* <code>true</code> to treat the specified text as html | |||||
* @param popup | * @param popup | ||||
* the menu to be cascaded from it | |||||
* the menu to be cascaded from it | |||||
* @return the {@link MenuItem} object created | * @return the {@link MenuItem} object created | ||||
*/ | */ | ||||
public MenuItem addItem(String text, boolean asHTML, MenuBar popup) { | public MenuItem addItem(String text, boolean asHTML, MenuBar popup) { | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param cmd | * @param cmd | ||||
* the command to be fired | |||||
* the command to be fired | |||||
* @return the {@link MenuItem} object created | * @return the {@link MenuItem} object created | ||||
*/ | */ | ||||
public MenuItem addItem(String text, Command cmd) { | public MenuItem addItem(String text, Command cmd) { | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param popup | * @param popup | ||||
* the menu to be cascaded from it | |||||
* the menu to be cascaded from it | |||||
* @return the {@link MenuItem} object created | * @return the {@link MenuItem} object created | ||||
*/ | */ | ||||
public MenuItem addItem(String text, MenuBar popup) { | public MenuItem addItem(String text, MenuBar popup) { | ||||
* Removes the specified menu item from the bar. | * Removes the specified menu item from the bar. | ||||
* | * | ||||
* @param item | * @param item | ||||
* the item to be removed | |||||
* the item to be removed | |||||
*/ | */ | ||||
public void removeItem(MenuItem item) { | public void removeItem(MenuItem item) { | ||||
final int idx = items.indexOf(item); | final int idx = items.indexOf(item); | ||||
* moved over it. | * moved over it. | ||||
* | * | ||||
* @param autoOpen | * @param autoOpen | ||||
* <code>true</code> to cause child menus to auto-open | |||||
* <code>true</code> to cause child menus to auto-open | |||||
*/ | */ | ||||
public void setAutoOpen(boolean autoOpen) { | public void setAutoOpen(boolean autoOpen) { | ||||
this.autoOpen = autoOpen; | this.autoOpen = autoOpen; | ||||
* fired. Popups associated with other items will be hidden. | * fired. Popups associated with other items will be hidden. | ||||
* | * | ||||
* @param item the item whose popup is to be shown. @param fireCommand | * @param item the item whose popup is to be shown. @param fireCommand | ||||
* <code>true</code> if the item's command should be fired, <code>false</code> | |||||
* otherwise. | |||||
* <code>true</code> if the item's command should be fired, | |||||
* <code>false</code> otherwise. | |||||
*/ | */ | ||||
void doItemAction(final MenuItem item, boolean fireCommand) { | void doItemAction(final MenuItem item, boolean fireCommand) { | ||||
// If the given item is already showing its menu, we're done. | // If the given item is already showing its menu, we're done. | ||||
// Create a new popup for this item, and position it next to | // Create a new popup for this item, and position it next to | ||||
// the item (below if this is a horizontal menu bar, to the | // the item (below if this is a horizontal menu bar, to the | ||||
// right if it's a vertical bar). | // right if it's a vertical bar). | ||||
popup = new ToolkitOverlay(true) { | |||||
popup = new IToolkitOverlay(true) { | |||||
{ | { | ||||
setWidget(item.getSubMenu()); | setWidget(item.getSubMenu()); | ||||
item.getSubMenu().onShow(); | item.getSubMenu().onShow(); |
* Constructs a new menu item that fires a command when it is selected. | * Constructs a new menu item that fires a command when it is selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param cmd | * @param cmd | ||||
* the command to be fired when it is selected | |||||
* the command to be fired when it is selected | |||||
*/ | */ | ||||
public MenuItem(String text, Command cmd) { | public MenuItem(String text, Command cmd) { | ||||
this(text, false); | this(text, false); | ||||
* Constructs a new menu item that fires a command when it is selected. | * Constructs a new menu item that fires a command when it is selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param asHTML | * @param asHTML | ||||
* <code>true</code> to treat the specified text as html | |||||
* <code>true</code> to treat the specified text as html | |||||
* @param cmd | * @param cmd | ||||
* the command to be fired when it is selected | |||||
* the command to be fired when it is selected | |||||
*/ | */ | ||||
public MenuItem(String text, boolean asHTML, Command cmd) { | public MenuItem(String text, boolean asHTML, Command cmd) { | ||||
this(text, asHTML); | this(text, asHTML); | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param subMenu | * @param subMenu | ||||
* the sub-menu to be displayed when it is selected | |||||
* the sub-menu to be displayed when it is selected | |||||
*/ | */ | ||||
public MenuItem(String text, MenuBar subMenu) { | public MenuItem(String text, MenuBar subMenu) { | ||||
this(text, false); | this(text, false); | ||||
* selected. | * selected. | ||||
* | * | ||||
* @param text | * @param text | ||||
* the item's text | |||||
* the item's text | |||||
* @param asHTML | * @param asHTML | ||||
* <code>true</code> to treat the specified text as html | |||||
* <code>true</code> to treat the specified text as html | |||||
* @param subMenu | * @param subMenu | ||||
* the sub-menu to be displayed when it is selected | |||||
* the sub-menu to be displayed when it is selected | |||||
*/ | */ | ||||
public MenuItem(String text, boolean asHTML, MenuBar subMenu) { | public MenuItem(String text, boolean asHTML, MenuBar subMenu) { | ||||
this(text, asHTML); | this(text, asHTML); | ||||
* Sets the command associated with this item. | * Sets the command associated with this item. | ||||
* | * | ||||
* @param cmd | * @param cmd | ||||
* the command to be associated with this item | |||||
* the command to be associated with this item | |||||
*/ | */ | ||||
public void setCommand(Command cmd) { | public void setCommand(Command cmd) { | ||||
command = cmd; | command = cmd; | ||||
* Sets the sub-menu associated with this item. | * Sets the sub-menu associated with this item. | ||||
* | * | ||||
* @param subMenu | * @param subMenu | ||||
* this item's new sub-menu | |||||
* this item's new sub-menu | |||||
*/ | */ | ||||
public void setSubMenu(MenuBar subMenu) { | public void setSubMenu(MenuBar subMenu) { | ||||
this.subMenu = subMenu; | this.subMenu = subMenu; |
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; | ||||
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; | ||||
import com.itmill.toolkit.terminal.gwt.client.Util; | import com.itmill.toolkit.terminal.gwt.client.Util; | ||||
import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo; | import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo; | ||||
* GridLayout and OrderedLayout. Supports size, margins, spacing, but has bit | * GridLayout and OrderedLayout. Supports size, margins, spacing, but has bit | ||||
* expensive layout function. | * expensive layout function. | ||||
*/ | */ | ||||
public class AbsoluteGrid extends Composite implements ContainerResizedListener { | |||||
public class IAbsoluteGrid extends Composite implements | |||||
ContainerResizedListener { | |||||
protected HashMap cells = new HashMap(); | protected HashMap cells = new HashMap(); | ||||
private int offsetHeight; | private int offsetHeight; | ||||
public AbsoluteGrid() { | |||||
public IAbsoluteGrid() { | |||||
ap = new AbsolutePanel(); | ap = new AbsolutePanel(); | ||||
initWidget(ap); | initWidget(ap); | ||||
} | } | ||||
public AbsoluteGridCell getCell(int col, int row) { | |||||
AbsoluteGridCell p = (AbsoluteGridCell) cells.get(col + "." + row); | |||||
public IAbsoluteGridCell getCell(int col, int row) { | |||||
IAbsoluteGridCell p = (IAbsoluteGridCell) cells.get(col + "." + row); | |||||
if (p == null) { | if (p == null) { | ||||
p = new AbsoluteGridCell(col, row); | |||||
p = new IAbsoluteGridCell(col, row); | |||||
cells.put(col + "." + row, p); | cells.put(col + "." + row, p); | ||||
ap.add(p); | ap.add(p); | ||||
} | } | ||||
* TODO contains Caption (which is a widget) in a very bad way, cannot be | * TODO contains Caption (which is a widget) in a very bad way, cannot be | ||||
* simple panel | * simple panel | ||||
*/ | */ | ||||
public class AbsoluteGridCell extends SimplePanel { | |||||
public class IAbsoluteGridCell extends SimplePanel { | |||||
int rowIndex; | int rowIndex; | ||||
int colIndex; | int colIndex; | ||||
int rowSpan = 1; | int rowSpan = 1; | ||||
private Element container = DOM.createDiv(); | private Element container = DOM.createDiv(); | ||||
private Caption caption; | |||||
private ICaption caption; | |||||
private AlignmentInfo alignmentInfo = new AlignmentInfo( | private AlignmentInfo alignmentInfo = new AlignmentInfo( | ||||
AlignmentInfo.ALIGNMENT_TOP + AlignmentInfo.ALIGNMENT_LEFT); | AlignmentInfo.ALIGNMENT_TOP + AlignmentInfo.ALIGNMENT_LEFT); | ||||
AbsoluteGridCell(int colIndex, int rowIndex) { | |||||
IAbsoluteGridCell(int colIndex, int rowIndex) { | |||||
super(); | super(); | ||||
if (BrowserInfo.get().isIE6()) { | if (BrowserInfo.get().isIE6()) { | ||||
DOM.setStyleAttribute(getElement(), "overflow", "hidden"); | DOM.setStyleAttribute(getElement(), "overflow", "hidden"); | ||||
return (caption == null) ? 0 : caption.getOffsetHeight(); | return (caption == null) ? 0 : caption.getOffsetHeight(); | ||||
} | } | ||||
public Caption getCaption() { | |||||
public ICaption getCaption() { | |||||
return caption; | return caption; | ||||
} | } | ||||
public void setCaption(Caption newCaption) { | |||||
public void setCaption(ICaption newCaption) { | |||||
// TODO check for existing, shouldn't happen though | // TODO check for existing, shouldn't happen though | ||||
caption = newCaption; | caption = newCaption; | ||||
DOM.insertChild(getElement(), caption.getElement(), 0); | DOM.insertChild(getElement(), caption.getElement(), 0); | ||||
} | } | ||||
if (sizeChanged) { | if (sizeChanged) { | ||||
for (Iterator it = cells.values().iterator(); it.hasNext();) { | for (Iterator it = cells.values().iterator(); it.hasNext();) { | ||||
AbsoluteGridCell cell = (AbsoluteGridCell) it.next(); | |||||
IAbsoluteGridCell cell = (IAbsoluteGridCell) it.next(); | |||||
cell.render(); | cell.render(); | ||||
cell.vAling(); | cell.vAling(); | ||||
} | } |
import com.google.gwt.user.client.Element; | import com.google.gwt.user.client.Element; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; | ||||
import com.itmill.toolkit.terminal.gwt.client.Caption; | |||||
import com.itmill.toolkit.terminal.gwt.client.ICaption; | |||||
import com.itmill.toolkit.terminal.gwt.client.Container; | import com.itmill.toolkit.terminal.gwt.client.Container; | ||||
import com.itmill.toolkit.terminal.gwt.client.Paintable; | import com.itmill.toolkit.terminal.gwt.client.Paintable; | ||||
import com.itmill.toolkit.terminal.gwt.client.UIDL; | import com.itmill.toolkit.terminal.gwt.client.UIDL; | ||||
* All cell's will be equally sized. | * All cell's will be equally sized. | ||||
* | * | ||||
*/ | */ | ||||
public class ISizeableGridLayout extends AbsoluteGrid implements Paintable, | |||||
public class ISizeableGridLayout extends IAbsoluteGrid implements Paintable, | |||||
Container { | Container { | ||||
public static final String CLASSNAME = "i-gridlayout"; | public static final String CLASSNAME = "i-gridlayout"; | ||||
private int spacing; | private int spacing; | ||||
final UIDL u = c.getChildUIDL(0); | final UIDL u = c.getChildUIDL(0); | ||||
if (u != null) { | if (u != null) { | ||||
final Paintable child = client.getPaintable(u); | final Paintable child = client.getPaintable(u); | ||||
AbsoluteGridCell cell = getCell(column, row); | |||||
IAbsoluteGridCell cell = getCell(column, row); | |||||
paintableToCellMap.put(child, cell); | paintableToCellMap.put(child, cell); | ||||
cell.rowSpan = rowSpan; | cell.rowSpan = rowSpan; | ||||
cell.colSpan = colSpan; | cell.colSpan = colSpan; | ||||
// loop oldWidgetWrappers that where not re-attached and unregister them | // loop oldWidgetWrappers that where not re-attached and unregister them | ||||
for (final Iterator it = oldCells.iterator(); it.hasNext();) { | for (final Iterator it = oldCells.iterator(); it.hasNext();) { | ||||
final AbsoluteGridCell w = (AbsoluteGridCell) it.next(); | |||||
final IAbsoluteGridCell w = (IAbsoluteGridCell) it.next(); | |||||
client.unregisterPaintable((Paintable) w.getWidget()); | client.unregisterPaintable((Paintable) w.getWidget()); | ||||
w.removeFromParent(); | w.removeFromParent(); | ||||
paintableToCellMap.remove(w.getWidget()); | paintableToCellMap.remove(w.getWidget()); | ||||
} | } | ||||
public void updateCaption(Paintable component, UIDL uidl) { | public void updateCaption(Paintable component, UIDL uidl) { | ||||
AbsoluteGridCell cell = (AbsoluteGridCell) paintableToCellMap | |||||
IAbsoluteGridCell cell = (IAbsoluteGridCell) paintableToCellMap | |||||
.get(component); | .get(component); | ||||
Caption c = cell.getCaption(); | |||||
ICaption c = cell.getCaption(); | |||||
if (c == null) { | if (c == null) { | ||||
c = new Caption(component, client); | |||||
c = new ICaption(component, client); | |||||
cell.setCaption(c); | cell.setCaption(c); | ||||
} | } | ||||
c.updateCaption(uidl); | c.updateCaption(uidl); |
private RichTextArea rta = new RichTextArea(); | private RichTextArea rta = new RichTextArea(); | ||||
private RichTextToolbar formatter = new RichTextToolbar(rta); | |||||
private IRichTextToolbar formatter = new IRichTextToolbar(rta); | |||||
private HTML html = new HTML(); | private HTML html = new HTML(); | ||||
* for all rich text formatting, dynamically displayed only for the available | * for all rich text formatting, dynamically displayed only for the available | ||||
* functionality. | * functionality. | ||||
*/ | */ | ||||
public class RichTextToolbar extends Composite { | |||||
public class IRichTextToolbar extends Composite { | |||||
/** | /** | ||||
* This {@link ImageBundle} is used for all the button icons. Using an image | * This {@link ImageBundle} is used for all the button icons. Using an image | ||||
* Creates a new toolbar that drives the given rich text area. | * Creates a new toolbar that drives the given rich text area. | ||||
* | * | ||||
* @param richText | * @param richText | ||||
* the rich text area to be controlled | |||||
* the rich text area to be controlled | |||||
*/ | */ | ||||
public RichTextToolbar(RichTextArea richText) { | |||||
public IRichTextToolbar(RichTextArea richText) { | |||||
this.richText = richText; | this.richText = richText; | ||||
basic = richText.getBasicFormatter(); | basic = richText.getBasicFormatter(); | ||||
extended = richText.getExtendedFormatter(); | extended = richText.getExtendedFormatter(); |