List of usage examples for com.google.gwt.user.client Element setClassName
@Override
public void setClassName(String className)
From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.LinkRenderer.java
License:Apache License
/** renders a div witch looks like an anchor (hand cursor is on div - block) */ public static String renderAsLink(final String message) { final Element div = DOM.createDiv(); div.setInnerHTML(message);/* w w w . j a v a 2s . c o m*/ div.setClassName("link-style"); return DOM.toString(div); }
From source file:com.alkacon.geranium.client.ui.Popup.java
License:Open Source License
/** * Constructor setting the width of the dialog.<p> * // w ww .j a va 2s . c o m * @param width the width to set */ public Popup(int width) { super(false, true); // super(autoHide, modal); m_containerElement = super.getContainerElement(); setStyleName(I_LayoutBundle.INSTANCE.dialogCss().popup()); m_containerElement.setClassName(I_LayoutBundle.INSTANCE.dialogCss().popupContent()); setGlassStyleName(I_LayoutBundle.INSTANCE.dialogCss().popupOverlay()); Element dragOverlay = DOM.createDiv(); dragOverlay.setClassName(I_LayoutBundle.INSTANCE.dialogCss().dragOverlay()); getElement().insertFirst(dragOverlay); m_caption = new Caption(); m_caption.setStyleName(I_LayoutBundle.INSTANCE.dialogCss().caption()); // Add the caption to the top of the popup-panel. We need to // logically adopt the caption so we can catch mouse events. DOM.appendChild(m_containerElement, m_caption.getElement()); adopt(m_caption); m_children = new WidgetCollection(this); m_main = DOM.createDiv(); m_main.addClassName(I_LayoutBundle.INSTANCE.dialogCss().popupMainContent()); m_main.addClassName(I_LayoutBundle.INSTANCE.dialogCss().contentPadding()); DOM.appendChild(m_containerElement, m_main); m_buttonPanel = new ButtonPanel(); m_buttonPanel.setStyleName(I_LayoutBundle.INSTANCE.dialogCss().hideButtonPanel()); // Add the caption to the top of the popup-panel. We need to // logically adopt the caption so we can catch mouse events. DOM.appendChild(m_containerElement, m_buttonPanel.getElement()); adopt(m_buttonPanel); MouseHandler mouseHandler = new MouseHandler(); addDomHandler(mouseHandler, MouseDownEvent.getType()); addDomHandler(mouseHandler, MouseUpEvent.getType()); addDomHandler(mouseHandler, MouseMoveEvent.getType()); setWidth(width); getElement().addClassName(I_LayoutBundle.INSTANCE.dialogCss().hideCaption()); }
From source file:com.alkacon.geranium.client.ui.ToolbarPopup.java
License:Open Source License
/** * Positions the menu popup the button.<p> * /* ww w .j a v a 2 s . com*/ * @param popup the popup to position * @param button the toolbar button * @param toolbarWidth the width of the toolbar * @param isToolbarMode a flag indicating whether the button is in toolbar mode * @param arrow the arrow shaped connector element */ protected static void positionPopup(Popup popup, Widget button, int toolbarWidth, boolean isToolbarMode, Element arrow) { int spaceAssurance = 20; int space = toolbarWidth + (2 * spaceAssurance); // get the window client width int windowWidth = Window.getClientWidth(); // get the min left position int minLeft = (windowWidth - space) / 2; if (minLeft < spaceAssurance) { minLeft = spaceAssurance; } // get the max right position int maxRight = minLeft + space; // get the middle button position PositionBean buttonPosition = PositionBean.generatePositionInfo(button.getElement()); int buttonMiddle = (buttonPosition.getLeft() - Window.getScrollLeft()) + (buttonPosition.getWidth() / 2); // get the content width int contentWidth = popup.getOffsetWidth(); // the optimum left position is in the middle of the button minus the half content width // assume that the optimum fits into the space int contentLeft = buttonMiddle - (contentWidth / 2); if (minLeft > contentLeft) { // if the optimum left position of the popup is outside the min left position: // move the popup to the right (take the min left position as left) contentLeft = minLeft; } else if ((contentLeft + contentWidth) > maxRight) { // if the left position plus the content width is outside the max right position: // move the popup to the left (take the max right position minus the content width) contentLeft = maxRight - contentWidth; } // limit the right position if the popup is right outside the window if ((contentLeft + contentWidth + spaceAssurance) > windowWidth) { contentLeft = windowWidth - contentWidth - spaceAssurance; } // limit the left position if the popup is left outside the window if (contentLeft < spaceAssurance) { contentLeft = spaceAssurance; } int arrowSpace = 10; int arrowWidth = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getWidth(); int arrowHeight = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getHeight(); // the optimum position for the arrow is in the middle of the button int arrowLeft = buttonMiddle - contentLeft - (arrowWidth / 2); if ((arrowLeft + arrowWidth + arrowSpace) > contentWidth) { // limit the arrow position if the maximum is reached (content width 'minus x') arrowLeft = contentWidth - arrowWidth - arrowSpace; } else if ((arrowLeft - arrowSpace) < 0) { // limit the arrow position if the minimum is reached ('plus x') arrowLeft = arrowWidth + arrowSpace; } int arrowTop = -(arrowHeight - 2); String arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowTop(); int contentTop = (((buttonPosition.getTop() + buttonPosition.getHeight()) - Window.getScrollTop()) + arrowHeight) - 2; if (!isToolbarMode) { contentTop = (buttonPosition.getTop() + buttonPosition.getHeight() + arrowHeight) - 2; int contentHeight = popup.getOffsetHeight(); int windowHeight = Window.getClientHeight(); if (((contentHeight + spaceAssurance) < windowHeight) && ((buttonPosition.getTop() - Window.getScrollTop()) > contentHeight) && (((contentHeight + spaceAssurance + contentTop) - Window.getScrollTop()) > windowHeight)) { // content fits into the window height, // there is enough space above the button // and there is to little space below the button // so show above contentTop = ((buttonPosition.getTop() - arrowHeight) + 2) - contentHeight; arrowTop = contentHeight - 1; arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowBottom(); } } else { contentLeft = contentLeft - Window.getScrollLeft(); popup.setPositionFixed(); } arrow.setClassName(arrowClass); arrow.getStyle().setLeft(arrowLeft, Unit.PX); arrow.getStyle().setTop(arrowTop, Unit.PX); popup.showArrow(arrow); popup.setPopupPosition(contentLeft + Window.getScrollLeft(), contentTop); }
From source file:com.ciplogic.web.codeeditor.render.html.ClassStyleResolver.java
License:Open Source License
private Element createElement() { Element containerDiv = DOM.createDiv(); containerDiv.setAttribute("style", "display : none"); containerDiv.setClassName("CodeMirror"); containerDiv.addClassName("cm-s-default"); Element div = DOM.createDiv(); containerDiv.appendChild(div);/*w w w. j a v a2s .c o m*/ Element preElement = DOM.createElement("pre"); div.appendChild(preElement); Element spanElement = DOM.createSpan(); preElement.appendChild(spanElement); Document.get().getBody().appendChild(containerDiv); return spanElement; }
From source file:com.explicatis.ext_token_field.client.TokenWidget.java
License:Apache License
public TokenWidget(final ExtTokenFieldWidget extTokenField, Token token, List<TokenAction> tokenActions) { this.extTokenField = extTokenField; this.token = token; rootPanel = new FlowPanel(); rootPanel.getElement().setClassName(TOKEN_CONTENT_CLASS_NAME); final Element rootElement = getElement(); rootElement.setClassName(TOKEN_CLASS_NAME); label = new Label(); label.getElement().setClassName(TOKEN_LABEL_CLASS_NAME); label.addClickHandler(labelClickHandler()); rootPanel.add(label);/*from ww w . j av a 2 s. com*/ buildTokenActions(tokenActions); internalSetLabel(); add(rootPanel); }
From source file:com.extjs.gxt.desktop.client.Desktop.java
License:Open Source License
public Desktop() { shortcuts = new ArrayList<Shortcut>(); windows = new ArrayList<Window>(); initListeners();/*from w ww. j a va 2s . com*/ viewport = new Viewport(); viewport.setLayout(new RowLayout()); desktop = new LayoutContainer() { @Override protected void onRender(Element parent, int index) { super.onRender(parent, index); getElement().appendChild(XDOM.getElementById("x-desktop")); } }; viewport.add(desktop, new RowData(1, 1)); viewport.add(taskBar, new RowData(1, 30)); Element el = XDOM.getElementById("x-shortcuts"); if (el == null) { el = DOM.createDiv(); el.setClassName("x-shortcuts"); XDOM.getBody().appendChild(el); } shortcutEl = new El(el); RootPanel.get().add(viewport); }
From source file:com.extjs.gxt.desktop.client.StartMenu.java
License:Open Source License
@Override protected void onRender(Element target, int index) { setElement(DOM.createDiv(), target, index); el().setStyleName("x-menu ux-start-menu"); El tl = el().createChild("<div class='ux-start-menu-tl'></div>"); El tr = tl.createChild("<div class='ux-start-menu-tr'></div>"); El tc = tr.createChild("<div class='ux-start-menu-tc'></div>"); header = tc//from w w w.j av a2s .c o m .createChild("<div class='x-window-header x-unselectable x-panel-icon " + iconStyle + "'></div>"); headerText = header.createChild("<span class='x-window-header-text'></span>"); headerText.setInnerHtml(heading); El bwrap = el().createChild("<div class='x-window-bwrap'></div>"); El ml = bwrap.createChild("<div class='ux-start-menu-ml'></div>"); El mc = ml.createChild("<div class='x-window-mc ux-start-menu-bwrap' style='border:none'></div>"); El bl = bwrap.createChild("<div class='ux-start-menu-bl x-panel-nofooter'></div>"); El br = bl.createChild("<div class='ux-start-menu-br'></div>"); br.createChild("<div class='ux-start-menu-bc'></div>"); menuBWrap = mc.createChild( "<div class='x-window-body ux-start-menu-body' style='position:relative;border: none'></div>"); menuBWrap.setHeight(300); menuPanel = menuBWrap.createChild( "<div class='x-panel x-border-panel ux-start-menu-apps-panel' style='border: none;padding: 2px'></div>"); toolsPanel = menuBWrap.createChild( "<div class='x-panel x-border-panel ux-start-menu-tools-panel' style='padding: 2px'></div>"); ul = menuPanel.createChild("<ul class='x-menu-list'></ul>"); El toolsUl = toolsPanel.createChild("<ul class='x-menu-list'></ul>"); for (Item item : tools) { Element li = DOM.createElement("li"); li.setClassName("x-menu-list-item"); toolsUl.dom.appendChild(li); item.render(li); item.addSelectionListener(new SelectionListener<MenuEvent>() { @Override public void componentSelected(MenuEvent ce) { hide(); } }); } eventPreview.getIgnoreList().add(getElement()); sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.KEYEVENTS); }
From source file:com.extjs.gxt.ui.client.GXT.java
License:sencha.com license
/** * Initializes GXT.//from w w w . j ava2 s . c om */ public static void init() { if (initialized) { return; } initialized = true; Element div = DOM.createDiv(); div.setClassName("x-contrast-test"); XDOM.getBody().appendChild(div); if ("none".equals(XDOM.getComputedStyle(div, "backgroundImage"))) { isHighContrastMode = true; XDOM.getBodyEl().addStyleName("x-contrast"); } XDOM.getBody().removeChild(div); String ua = getUserAgent(); isOpera = ua.indexOf("opera") != -1; isIE = !isOpera && ua.indexOf("msie") != -1; int docMode = getDocumentMode(); if (!isOpera && isIE) { if (docMode >= 10) { isIE10 = true; } else if (docMode == 9) { isIE9 = true; } else if (docMode == 8) { isIE8 = true; } else { isIE6 = !isOpera && ua.indexOf("msie 6") != -1; isIE7 = !isOpera && ua.indexOf("msie 7") != -1; } } isChrome = !isIE && ua.indexOf("chrome") != -1; isWebKit = ua.indexOf("webkit") != -1; isSafari = !isChrome && ua.indexOf("safari") != -1; isSafari3 = isSafari && ua.indexOf("version/3") != -1; isSafari4 = isSafari && ua.indexOf("version/4") != -1; isSafari2 = isSafari && !isSafari3 && !isSafari4; isGecko = !isWebKit && ua.indexOf("gecko") != -1; isGecko35 = isGecko && ua.indexOf("rv:1.9.1") != -1; isGecko3 = isGecko && ua.indexOf("rv:1.9.") != -1; isGecko2 = isGecko && ua.indexOf("rv:1.8.") != -1; isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1); isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1); isAir = (ua.indexOf("adobeair") != -1); isLinux = (ua.indexOf("linux") != -1); // don't override if set to true if (!useShims) { useShims = isIE6 || (isMac && isGecko2); } isStrict = Document.get().isCSS1Compat(); isBorderBox = El.isBorderBox(DOM.createDiv()); isSecure = Window.Location.getProtocol().toLowerCase().startsWith("https"); if (BLANK_IMAGE_URL == null) { if (isIE8 || (isGecko && !isSecure)) { BLANK_IMAGE_URL = "data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="; } else { BLANK_IMAGE_URL = GWT.getModuleBaseURL() + "clear.gif"; } } El bodyEl = XDOM.getBodyEl(); if (isBorderBox) { bodyEl.addStyleName("ext-border-box"); } if (isIE) { bodyEl.addStyleName("ext-ie"); String cls = (isIE6 ? "ext-ie6" : (isIE7 ? "ext-ie7" : (isIE8 ? "ext-ie8" : (isIE9 ? "ext-ie9" : null)))); bodyEl.addStyleName(cls); if (isIE7 && isIE8compatibility()) { bodyEl.addStyleName("ext-ie8-compatibility"); } } else if (isGecko) { bodyEl.addStyleName("ext-gecko"); String cls = (isGecko2 ? "ext-gecko2" : (isGecko3 ? "ext-gecko3" : null)); bodyEl.addStyleName(cls); } else if (isOpera) { bodyEl.addStyleName("ext-opera"); } else if (isWebKit) { bodyEl.addStyleName("ext-webkit"); if (isSafari) { bodyEl.addStyleName("ext-safari"); } else if (isChrome) { bodyEl.addStyleName("ext-chrome"); } } if (isWindows) { bodyEl.addStyleName("ext-windows"); } else if (isMac) { bodyEl.addStyleName("ext-mac"); } else if (isLinux) { bodyEl.addStyleName("ext-linux"); } if (StateManager.get().getProvider() == null) { StateManager.get().setProvider(new CookieProvider("/", null, null, isSecure)); } Map<String, Object> theme = StateManager.get().getMap(GWT.getModuleBaseURL() + "theme"); if ((defaultTheme != null && forceTheme) || (theme == null && defaultTheme != null)) { theme = defaultTheme.asMap(); } if (theme != null) { final String themeId = String.valueOf(theme.get("id")); Theme t = ThemeManager.findTheme(themeId); if (t != null) { t.init(); String fileName = theme.get("file").toString(); if (!fileName.contains("gxt-all.css")) { CSS.addStyleSheet(themeId, fileName); } bodyEl.addStyleName("x-theme-" + themeId); } StateManager.get().set(GWT.getModuleBaseURL() + "theme", theme); } if (isStrict) { // add to the parent to allow for selectors like // ".ext-strict .ext-ie" Element p = (Element) XDOM.getBody().getParentElement(); if (p != null) { El.fly(p).addStyleName("ext-strict"); } } if (isIE6) { removeBackgroundFlicker(); } }
From source file:com.extjs.gxt.ui.client.widget.Component.java
License:sencha.com license
private Element createHiddenInput() { Element input = DOM.createInputText(); input.setClassName("_focus"); com.google.gwt.dom.client.Style style = input.getStyle(); style.setProperty("opacity", "0"); style.setProperty("zIndex", "-1"); style.setProperty("overflow", "hidden"); style.setProperty("position", "absolute"); style.setPropertyPx("height", 0); style.setProperty("borderWidth", "0"); style.setPropertyPx("width", 0); return input; }
From source file:com.extjs.gxt.ui.client.widget.ContentPanel.java
License:sencha.com license
@Override protected void onRender(Element parent, int pos) { super.onRender(parent, pos); if (fbar.getItemCount() > 0) { footer = true;// ww w .j a v a 2 s . c om } if (frame) { String s = Format.substitute(Markup.BBOX, baseStyle); DomHelper.insertHtml("afterBegin", el().dom, s); head.baseStyle = headerStyle; head.setTextStyle(headerTextStyle); initTools(); head.render(el().dom); el().subChild(3).dom.appendChild(head.getElement()); bwrap = el().createChild("<div role=presentation class='" + bwrapStyle + "'></div>"); Element bw = bwrap.dom; Element ml = DOM.getChild(el().dom, 1); Element bl = DOM.getChild(el().dom, 2); DOM.appendChild(bw, ml); DOM.appendChild(bw, bl); Element mc = fly(bw).getSubChild(3); if (topComponent != null) { tbar = fly(mc).createChild("<div role=presentation class=" + tbarStyle + "></div>"); } body = fly(mc).createChild("<div role=presentation class=" + bodStyle + "></div>"); if (bottomComponent != null) { bbar = fly(mc).createChild("<div role=presentation class=" + bbarStyle + "></div>"); } El e = fly(bw).lastChild().firstChild().firstChild(); foot = e.createChild("<div role=presentation class=" + footerStyle + "></div>"); } else { head.baseStyle = headerStyle; head.setTextStyle(headerTextStyle); initTools(); head.render(el().dom); bwrap = el().createChild("<div role=presentation class=" + bwrapStyle + "></div>"); Element bw = bwrap.dom; if (topComponent != null) { tbar = fly(bw).createChild("<div role=presentation class=" + tbarStyle + "></div>"); } body = fly(bw).createChild("<div role=presentation class=" + bodStyle + "></div>"); if (bottomComponent != null) { bbar = fly(bw).createChild("<div role=presentation class=" + bbarStyle + "></div>"); } foot = fly(bw).createChild("<div role=presentation class=" + footerStyle + "></div>"); } if (!headerVisible) { head.hide(); body.addStyleName(bodStyle + "-noheader"); if (tbar != null) { tbar.addStyleName(tbarStyle + "-noheader"); } } if (footer && fbar.getItemCount() > 0) { Element div = DOM.createDiv(); fly(div).addStyleName("x-panel-btns"); foot.appendChild(div); fbar.render(div); Element clearDiv = DOM.createDiv(); clearDiv.setClassName("x-clear"); div.appendChild(clearDiv); } else if (!footer) { bwrap.lastChild().addStyleName(baseStyle + "-nofooter"); } if (!bodyBorder) { el().addStyleName(baseStyle + "-noborder"); body.addStyleName(bodStyle + "-noborder"); if (tbar != null) { tbar.addStyleName(tbarStyle + "-noborder"); } if (bbar != null) { bbar.addStyleName(bbarStyle + "-noborder"); } } if (bodyStyle != null) { body.applyStyles(bodyStyle); } if (bodyStyleName != null) { body.addStyleName(bodyStyleName); } if (headerVisible) { head.disableTextSelection(true); } if (topComponent != null) { topComponent.render(tbar.dom); } if (bottomComponent != null) { bottomComponent.render(bbar.dom); } if (titleCollapse) { head.setStyleAttribute("cursor", "pointer"); sinkEvents(Event.ONCLICK); } if (collapsible && GXT.isAriaEnabled()) { Accessibility.setState(getElement(), "aria-expanded", "true"); } if (GXT.isAriaEnabled()) { Accessibility.setRole(getElement(), "region"); if (head != null) { getAriaSupport().setLabelledBy(head.getId() + "-label"); } } // early render layoutBars(); if (collapsed) { boolean anim = animCollapse; collapsed = false; setAnimCollapse(false); collapse(); setAnimCollapse(anim); } }