List of usage examples for com.google.gwt.user.client.ui AbstractImagePrototype createElement
public ImagePrototypeElement createElement()
From source file:com.extjs.gxt.desktop.client.Shortcut.java
License:Open Source License
public void setIcon(AbstractImagePrototype icon) { if (rendered) { iconEl.setInnerHtml(""); iconEl.appendChild((Element) icon.createElement().cast()); }//from ww w . jav a 2 s . c o m this.icon = icon; }
From source file:com.extjs.gxt.desktop.client.TaskBar.java
License:Open Source License
@Override public void setIcon(AbstractImagePrototype icon) { super.setIcon(icon); if (rendered) { if (buttonEl.selectNode("img") != null) { buttonEl.selectNode("img").remove(); }/* w w w . j a va 2 s . c om*/ if (icon != null) { buttonEl.setPadding(new Padding(7, 0, 7, 28)); Element e = (Element) icon.createElement().cast(); buttonEl.insertFirst(e); El.fly(e).makePositionable(true); String align = "b-b"; if (getIconAlign() == IconAlign.BOTTOM) { align = "b-b"; } else if (getIconAlign() == IconAlign.TOP) { align = "t-t"; } else if (getIconAlign() == IconAlign.LEFT) { align = "l-l"; } else if (getIconAlign() == IconAlign.RIGHT) { align = "r-r"; } El.fly(e).alignTo(buttonEl.dom, align, null); } } }
From source file:com.extjs.gxt.desktop.client.TaskBar.java
License:Open Source License
@Override public void setIcon(AbstractImagePrototype icon) { super.setIcon(icon); if (rendered) { if (buttonEl.selectNode("img") != null) { buttonEl.selectNode("img").remove(); }/* w ww .j av a2 s . c o m*/ if (icon != null) { buttonEl.setPadding(new Padding(7, 0, 7, 20)); Element e = (Element) icon.createElement().cast(); buttonEl.insertFirst(e); El.fly(e).makePositionable(true); String align = "b-b"; if (getIconAlign() == IconAlign.BOTTOM) { align = "b-b"; } else if (getIconAlign() == IconAlign.TOP) { align = "t-t"; } else if (getIconAlign() == IconAlign.LEFT) { align = "l-l"; } else if (getIconAlign() == IconAlign.RIGHT) { align = "r-r"; } El.fly(e).alignTo(buttonEl.dom, align, null); } } }
From source file:com.extjs.gxt.ui.client.widget.button.Button.java
License:sencha.com license
/** * Sets the button's icon style. The style name should match a CSS style that * specifies a background image using the following format: * /*from w w w.j ava 2 s . c om*/ * <pre> * * <code> .my-icon { background: url(images/icons/my-icon.png) no-repeat * center left !important; } </code> * * </pre> * * @param icon the icon */ public void setIcon(AbstractImagePrototype icon) { if (rendered) { El oldIcon = buttonEl.selectNode("." + baseStyle + "-image"); if (oldIcon != null) { oldIcon.remove(); el().removeStyleName(baseStyle + "-text-icon", baseStyle + "-icon", baseStyle + "-noicon"); } el().addStyleName((icon != null ? (!Util.isEmptyString(html) ? " " + baseStyle + "-text-icon" : " " + baseStyle + "-icon") : " " + baseStyle + "-noicon")); Element e = null; if (icon != null) { e = (Element) icon.createElement().cast(); Accessibility.setRole(e, "presentation"); fly(e).addStyleName(baseStyle + "-image"); buttonEl.insertFirst(e); El.fly(e).makePositionable(true); } autoWidth(); alignIcon(e); } this.icon = icon; }
From source file:com.extjs.gxt.ui.client.widget.Header.java
License:sencha.com license
/** * Sets the header's icon style. The style name should match a CSS style that * specifies a background image using the following format: * /*from ww w . j a va 2 s . co m*/ * <pre> * <code> * .my-icon { * background: url(images/icons/my-icon.png) no-repeat center left !important; * } * </code> * </pre> * * @param icon the icon */ public void setIcon(AbstractImagePrototype icon) { if (rendered) { El oldIcon = el().selectNode(".x-panel-inline-icon"); if (oldIcon != null) { oldIcon.remove(); } if (icon != null) { ImagePrototypeElement i = icon.createElement(); El.fly(i).addStyleName("x-panel-inline-icon"); El.fly(i).setStyleAttribute("cursor", "default"); El.fly(i).setStyleAttribute("float", "left"); if (altIconText != null || GXT.isAriaEnabled()) { i.setAttribute("alt", altIconText != null ? altIconText : "Panel Icon"); } el().insertChild((Element) i.cast(), 0); } } this.icon = icon; }
From source file:com.extjs.gxt.ui.client.widget.menu.MenuItem.java
License:sencha.com license
/** * Sets the item's icon style. The style name should match a CSS style that * specifies a background image using the following format: * //from ww w . j a v a 2 s. co m * <pre> * <code> * .my-icon { * background: url(images/icons/my-icon.png) no-repeat center left !important; * } * </code> * </pre> * * @param icon the icon */ public void setIcon(AbstractImagePrototype icon) { this.icon = icon; if (rendered) { El oldIcon = el().selectNode(".x-menu-item-icon"); if (oldIcon != null) { oldIcon.remove(); } if (icon != null) { Element e = icon.createElement().cast(); El.fly(e).addStyleName("x-menu-item-icon"); el().insertChild(e, 0); } } this.icon = icon; }
From source file:com.extjs.gxt.ui.client.widget.treegrid.TreeGridView.java
License:sencha.com license
public SafeHtml getTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon, boolean checkable, Joint joint, int level) { StringBuilder sb = new StringBuilder(); sb.append("<div role=\"presentation\" unselectable=\"on\" id=\""); sb.append(id);/*from w w w .j a va 2 s . c o m*/ sb.append("\" class=\"x-tree3-node\">"); String cls = "x-tree3-el"; if (GXT.isHighContrastMode) { switch (joint) { case COLLAPSED: cls += " x-tree3-node-joint-collapse"; break; case EXPANDED: cls += " x-tree3-node-joint-expand"; break; } } sb.append("<div role=\"presentation\" unselectable=\"on\" class=\"" + cls + "\">"); Element jointElement = null; switch (joint) { case COLLAPSED: jointElement = (Element) tree.getStyle().getJointCollapsedIcon().createElement().cast(); break; case EXPANDED: jointElement = (Element) tree.getStyle().getJointExpandedIcon().createElement().cast(); break; } if (jointElement != null) { El.fly(jointElement).addStyleName("x-tree3-node-joint"); } sb.append("<img src=\""); sb.append(GXT.BLANK_IMAGE_URL); sb.append("\" style=\"height:18px;width:"); sb.append(level * getIndenting(findNode(m))); sb.append("px;\" />"); sb.append(jointElement == null ? "<img src=\"" + GXT.BLANK_IMAGE_URL + "\" style=\"width: 16px\" class=\"x-tree3-node-joint\" />" : DOM.toString(jointElement)); if (checkable) { Element e = (Element) GXT.IMAGES.unchecked().createElement().cast(); El.fly(e).addStyleName("x-tree3-node-check"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-check\"></span>"); } if (icon != null) { Element e = icon.createElement().cast(); El.fly(e).addStyleName("x-tree3-node-icon"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-icon\"></span>"); } sb.append("<span unselectable=\"on\" class=\"x-tree3-node-text\">"); sb.append(text.asString()); sb.append("</span>"); sb.append("</div>"); sb.append("</div>"); return SafeHtmlUtils.fromTrustedString(sb.toString()); }
From source file:com.extjs.gxt.ui.client.widget.treegrid.TreeGridView.java
License:sencha.com license
public SafeHtml getWidgetTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon, boolean checkable, Joint joint, int level) { StringBuffer sb = new StringBuffer(); sb.append("<div unselectable=\"on\" id=\""); sb.append(id);// w ww . j a v a 2 s .c o m sb.append("\" class=\"x-tree3-node\">"); // jumping content when inserting in column with cell widget the column // extra width fixes sb.append( "<div role=\"presentation\" unselectable=\"on\" class=\"x-tree3-el\" style=\"width: 1000px;height: auto;\">"); sb.append( "<table cellpadding=0 cellspacing=0 role=presentation><tr role=presentation><td role=presentation>"); Element jointElement = null; switch (joint) { case COLLAPSED: jointElement = (Element) tree.getStyle().getJointCollapsedIcon().createElement().cast(); break; case EXPANDED: jointElement = (Element) tree.getStyle().getJointExpandedIcon().createElement().cast(); break; } if (jointElement != null) { El.fly(jointElement).addStyleName("x-tree3-node-joint"); } sb.append("</td><td><img src=\""); sb.append(GXT.BLANK_IMAGE_URL); sb.append("\" style=\"height:18px;width:"); sb.append(level * getIndenting(findNode(m))); sb.append("px;\" /></td><td class='x-tree3-el-jnt'>"); sb.append(jointElement == null ? "<img src=\"" + GXT.BLANK_IMAGE_URL + "\" style=\"width: 16px\" class=\"x-tree3-node-joint\" />" : DOM.toString(jointElement)); if (checkable) { Element e = (Element) GXT.IMAGES.unchecked().createElement().cast(); El.fly(e).addStyleName("x-tree3-node-check"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-check\"></span>"); } sb.append("</td><td>"); if (icon != null) { Element e = icon.createElement().cast(); El.fly(e).addStyleName("x-tree3-node-icon"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-icon\"></span>"); } sb.append("</td><td>"); sb.append("<span unselectable=\"on\" class=\"x-tree3-node-text\">"); sb.append(text.asString()); sb.append("</span>"); sb.append("</td></tr></table>"); sb.append("</div>"); sb.append("</div>"); return SafeHtmlUtils.fromTrustedString(sb.toString()); }
From source file:com.extjs.gxt.ui.client.widget.treegrid.TreeGridView.java
License:sencha.com license
public void onIconStyleChange(TreeNode node, AbstractImagePrototype icon) { Element iconEl = getIconElement(node); if (iconEl != null) { Element e;/*www . j a v a 2 s . co m*/ if (icon != null) { e = (Element) icon.createElement().cast(); } else { e = DOM.createSpan(); } El.fly(e).addStyleName("x-tree3-node-icon"); node.icon = (Element) iconEl.getParentElement().insertBefore(e, iconEl); El.fly(iconEl).remove(); } }
From source file:com.extjs.gxt.ui.client.widget.treepanel.TreePanelView.java
License:sencha.com license
public String getTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon, boolean checkable, boolean checked, Joint joint, int level, TreeViewRenderMode renderMode) { if (renderMode == TreeViewRenderMode.CONTAINER) { if (GXT.isIE6 || GXT.isIE7) { return "<div unselectable=on class=\"x-tree3-node-ct\" style=\"position:relative;\" role=\"group\"></div>"; } else {/*from w w w . j a v a2 s . com*/ return "<div unselectable=on class=\"x-tree3-node-ct\" style=\"position:relative;\" role=\"group\"><table cellpadding=0 cellspacing=0 width=100%><tr><td></td></tr></table></div>"; } } StringBuilder sb = new StringBuilder(); if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.MAIN) { sb.append("<div unselectable=on id=\""); sb.append(id); sb.append("\""); sb.append(" class=\"x-tree3-node\" role=\"presentation\">"); String cls = "x-tree3-el"; if (GXT.isHighContrastMode) { switch (joint) { case COLLAPSED: cls += " x-tree3-node-joint-collapse"; break; case EXPANDED: cls += " x-tree3-node-joint-expand"; break; } } sb.append("<div unselectable=on class=\"" + cls + "\" id=\"" + tree.getId() + "__" + id + "\" role=\"treeitem\" "); sb.append(" aria-level=\"" + (level + 1) + "\">"); } if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.BODY) { Element jointElement = null; switch (joint) { case COLLAPSED: jointElement = (Element) tree.getStyle().getJointCollapsedIcon().createElement().cast(); break; case EXPANDED: jointElement = (Element) tree.getStyle().getJointExpandedIcon().createElement().cast(); break; } if (jointElement != null) { El.fly(jointElement).addStyleName("x-tree3-node-joint"); } sb.append("<img src=\""); sb.append(GXT.BLANK_IMAGE_URL); sb.append("\" style=\"height: 18px; width: "); sb.append(level * getIndenting(findNode((M) m))); sb.append("px;\" />"); sb.append(jointElement == null ? "<img src=\"" + GXT.BLANK_IMAGE_URL + "\" style=\"width: 16px\" class=\"x-tree3-node-joint\" />" : DOM.toString(jointElement)); if (checkable) { Element e = (Element) (checked ? GXT.IMAGES.checked().createElement().cast() : GXT.IMAGES.unchecked().createElement().cast()); El.fly(e).addStyleName("x-tree3-node-check"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-check\"></span>"); } if (icon != null) { Element e = icon.createElement().cast(); El.fly(e).addStyleName("x-tree3-node-icon"); sb.append(DOM.toString(e)); } else { sb.append("<span class=\"x-tree3-node-icon\"></span>"); } sb.append("<span unselectable=on class=\"x-tree3-node-text\">"); sb.append(text.asString()); sb.append("</span>"); } if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.MAIN) { sb.append("</div>"); sb.append("</div>"); } return sb.toString(); }