List of usage examples for com.google.gwt.user.client.ui HTML HTML
protected HTML(Element element)
From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java
License:Apache License
/** * Inserts a new tab at the specified index. * /* w w w . ja v a 2 s.com*/ * @param text * the new tab's text * @param asHTML * <code>true</code> to treat the specified text as HTML * @param beforeIndex * the index before which this tab will be inserted */ public void insertTab(String text, boolean asHTML, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); Label item; if (asHTML) { item = new HTML(text); } else { item = new Label(text); } item.setWordWrap(false); insertTabWidget(item, beforeIndex); }
From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java
License:Apache License
/** * Sets a tab's contents via HTML./* w w w. j a va 2s .com*/ * * Use care when setting an object's HTML; it is an easy way to expose * script-based security problems. Consider using * {@link #setTabText(int, String)} whenever possible. * * @param index * the index of the tab whose HTML is to be set * @param html * the tab new HTML */ public void setTabHTML(int index, String html) { assert (index >= 0) && (index < getTabCount()) : "Tab index out of bounds"; ClickDelegatePanel delPanel = tabs.get(index); SimplePanel focusablePanel = delPanel.getFocusablePanel(); focusablePanel.setWidget(new HTML(html)); }
From source file:cc.alcina.framework.gwt.client.widget.RelativePopupValidationFeedback.java
License:Apache License
@SuppressWarnings("unchecked") protected Widget renderExceptionWidget(ValidationException exception) { return asHtml ? new HTML(this.getMessage(exception)) : new Label(this.getMessage(exception)); }
From source file:cc.alcina.framework.gwt.client.widget.SelectWithSearch.java
License:Apache License
public Widget createWidget(Map<G, List<T>> itemMap, ClickHandler clickHandler, int charWidth, LazyDataProvider<G, T> lazyProvider) { this.clickHandler = clickHandler; this.charWidth = charWidth; this.lazyProvider = lazyProvider; this.holder = isFlowLayout() ? new FlowPanelClickable() : new FlowPanel100pcHeight(); filter = new FilterWidget(hint); filter.getTextBox().addKeyUpHandler(selectableNavigation); filter.getTextBox().addKeyDownHandler(selectableNavigation); if (getInitialFilterValue() != null) { filter.setInitialCursorPos(getInitialFilterCursorPos()); filter.setValue(getInitialFilterValue()); }//from ww w. j a va 2 s.co m filter.setFocusOnAttach(isFocusOnAttach()); filter.addAttachHandler(filterAttachHandler); filter.registerFilterable(this); selectableNavigation.setWrappedEnterListener(new ClickHandler() { // the listeners aren't registered on every source...pretty sure // this is logical... @Override public void onClick(ClickEvent event) { HasClickHandlers sender = (HasClickHandlers) event.getSource(); if (enterHandler != null) { WidgetUtils.fireClickOnHandler(sender, enterHandler); } if (popdown) { WidgetUtils.fireClickOnHandler(sender, popdownHider); } } }); createItemHolder(); if (inPanelHint != null) { hintLabel = new HTML(inPanelHint); hintLabel.setStyleName("hint"); if (showHintStrategy != null) { showHintStrategy.registerHintWidget(hintLabel); showHintStrategy.registerFilter(filter); } itemHolderAsHasWidgets().add(hintLabel); } groupCaptions = new ArrayList<Label>(); popdownHider = new ClickHandler() { @Override public void onClick(ClickEvent event) { maybeClosePopdown(event); } }; filter.getTextBox().addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { System.out.println("onblur - ignore:" + ignoreNextBlur); if (System.currentTimeMillis() - ignoreNextBlur < 100) { ignoreNextBlur = 0; filter.getTextBox().setFocus(true); } else { handleFilterBlur(); } } }); if (itemMap != null) { setItemMap(itemMap); } this.scroller = isFlowLayout() ? new ScrollPanel(itemHolder) : new ScrollPanel100pcHeight300px(itemHolder); if (!isFlowLayout()) { scroller.setSize("100%", "100%"); } scroller.setStyleName("selector-scroller"); holder.setStyleName("alcina-Chooser"); holder.add(filter); if (popdown) { filter.getTextBox().addFocusHandler(this); filter.getTextBox().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { checkShowPopup(); } }); filter.getTextBox().addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { if (Event.getCurrentEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { if (popdown) { maybeClosePopdown(null); } } else { checkShowPopup(); } if (CommonUtils.isNullOrEmpty(filter.getTextBox().getText()) && popdown && isCloseOnPopdownFilterEmpty()) { maybeClosePopdown(null); } } }); } else { if (!isFlowLayout()) { holder.setHeight(holderHeight); } holder.add(scroller); } if (!popdown && lazyProvider != null) { AsyncCallback<LazyData> callback = new AsyncCallbackStd<SelectWithSearch.LazyData>() { @Override public void onSuccess(LazyData lazyData) { if (lazyData != null) { setKeys(lazyData.keys); setItemMap(lazyData.data); } } }; lazyProvider.getData(callback); } return holder; }
From source file:cc.alcina.framework.gwt.client.widget.UsefulWidgetFactory.java
License:Apache License
public static HTML createEmptyLabel() { return new HTML(" "); }
From source file:cc.alcina.framework.gwt.client.widget.UsefulWidgetFactory.java
License:Apache License
public static FlowPanel lowTitleWidget(String title) { FlowPanel fp = new FlowPanel(); fp.setStyleName("low-title"); Label l = new HTML(title); l.setStyleName(""); fp.add(l);//w w w.ja v a 2 s.c o m return fp; }
From source file:cc.alcina.framework.gwt.client.widget.UsefulWidgetFactory.java
License:Apache License
public static FlowPanel mediumTitleWidget(String title) { FlowPanel fp = new FlowPanel(); fp.setStyleName("medium-title"); Label l = new HTML(title); l.setStyleName(""); fp.add(l);// w ww .j av a 2 s .c om return fp; }
From source file:cc.kune.common.client.notify.UserNotifierGrowl.java
License:GNU Affero Public License
/** * Instantiates a new user notifier growl. * * @param eventBus// ww w. ja va 2 s. c om * the event bus */ @Inject public UserNotifierGrowl(final EventBus eventBus) { eventBus.addHandler(UserNotifyEvent.getType(), new UserNotifyEvent.UserNotifyHandler() { @Override public void onUserNotify(final UserNotifyEvent event) { final GrowlOptions options = GrowlHelper.getNewOptions(); final GrowlPosition position = GrowlHelper.getNewPosition(); position.setCenter(); position.setTop(false); options.setGrowlPosition(position); String id = event.getId(); boolean hasId = TextUtils.notEmpty(id); if (hasId && DOM.getElementById(id) != null) { // this notification is already present so, don't do nothing return; } final GrowlTemplate gt = GrowlHelper.getNewTemplate(); // As a workaround, we set the id in the <br> gt.setTitleDivider(hasId ? "<br id=\"" + id + "\">" : "<br>"); options.setTemplateObject(gt); final Boolean closeable = event.getCloseable(); if (closeable) { options.setDelay(0); } options.setAllowDismiss(closeable); options.setPauseOnMouseOver(true); final String message = event.getMessage(); String icon = ""; final String iconStyleBase = Styles.FONT_AWESOME_BASE + SEPARATOR + IconSize.TIMES2.getCssName() + " growl-icon-margin "; final NotifyLevel level = event.getLevel(); switch (level) { case error: options.setDangerType(); icon = iconStyleBase + IconType.EXCLAMATION_CIRCLE.getCssName(); break; case avatar: final ClickHandler clickHandler = event.getClickHandler(); final Container container = new Container(); container.setFluid(true); final Image avatar = new Image(event.getLevel().getUrl()); avatar.setSize(AVATAR_SIZE, AVATAR_SIZE); avatar.addStyleName("k-fl"); avatar.addStyleName("growl-icon-margin"); container.add(avatar); container.add(new HTML(message)); container.addDomHandler(clickHandler, ClickEvent.getType()); Growl.growl(container.getElement().getInnerHTML(), options); return; case veryImportant: case important: options.setWarningType(); icon = iconStyleBase + IconType.WARNING.getCssName(); break; case success: options.setSuccessType(); icon = iconStyleBase + IconType.CHECK_CIRCLE.getCssName(); break; case info: options.setInfoType(); icon = iconStyleBase + IconType.INFO_CIRCLE.getCssName(); break; case log: // Do nothing with this level return; default: break; } Growl.growl(event.getTitle(), message, icon, options); } }); }
From source file:cc.kune.core.client.cookies.MotdManager.java
License:GNU Affero Public License
public MotdManager() { SessionInstance.get().onAppStart(true, new AppStartHandler() { @Override//from ww w . ja v a2 s. c o m public void onAppStart(final AppStartEvent event) { final Timer timer = new Timer() { @Override public void run() { final MotdDTO motd = event.getInitData().getMotd(); if (motd == null) { return; } final String cookieName = motd.getCookieName(); final String motdCookie = Cookies.getCookie(cookieName); if (motdCookie == null) { final Builder builder = new BasicTopDialog.Builder("k-motd", true, false, I18n.getDirection()); // motdDialog.addStyleName("k-motd-dialog"); if (motd.getTitle() != null) { builder.title(motd.getTitle()); } final BasicTopDialog dialog = builder.build(); dialog.setFirstBtnText(motd.getOkBtnText()); dialog.setCloseBtnVisible(true); Log.info("Motd message: " + motd.getMessage()); final HTML message = new HTML(motd.getMessage() + motd.getMessageBottom()); dialog.getInnerPanel().add(message); dialog.setSecondBtnText(motd.getCloseBtnText()); dialog.getSecondBtn().addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(90)); dialog.hide(); } }); if (motd.getShouldRemember() > 0) { final CustomButton laterBtn = new CustomButton((I18n.t("Maybe later"))); laterBtn.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(motd.getShouldRemember())); dialog.hide(); } }); dialog.getBtnPanel().add(laterBtn); } dialog.getFirstBtn().addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { setCookie(cookieName, CookieUtils.inDays(7)); KuneWindowUtils.open(motd.getOkBtnUrl()); dialog.hide(); } }); dialog.show(); } } }; timer.schedule(10000); } }); }
From source file:cc.kune.core.client.ui.ContentPosition.java
License:GNU Affero Public License
/** * Sets the position.//from w ww . j av a 2 s . c om * * @param elementCode * the element code * @param wraptext * the wraptext * @param position * the position * @return the string */ public static String setPosition(final String elementCode, final boolean wraptext, final String position) { final HTML html = new HTML(elementCode); html.removeStyleName("gwt-HTML"); return setPosition(html.getElement(), wraptext, position).getString(); }