List of usage examples for com.google.gwt.user.client.ui HTMLPanel getElementById
public Element getElementById(String id)
From source file:org.spiffyui.client.JSUtil.java
License:Apache License
/** * Toggle hiding or showing a section/*from w ww. j av a 2s .c o m*/ * @param target - the event's onclick target * @param panel - the parent HTMLPanel of the target * @param targetId - the ID of the target * @param sectionId - the ID of the section to toggle * @return boolean true if the target does match the element with the targetId */ public static boolean toggleSection(Element target, HTMLPanel panel, String targetId, String sectionId) { if (!((target != null) && DOM.isOrHasChild(panel.getElementById(targetId), target))) { return false; } String trimmedSectionId = sectionId; if (!sectionId.startsWith("#")) { trimmedSectionId = "#" + sectionId; } if (JSUtil.isVisible(trimmedSectionId)) { collapseSection(panel, targetId, trimmedSectionId, true); } else { expandSection(panel, targetId, trimmedSectionId, true); } return true; }
From source file:org.spiffyui.client.JSUtil.java
License:Apache License
/** * Expands a section//from w w w .ja v a2 s . co m * @param panel - HTMLPanel holding the target * @param targetId - the ID of the target * @param sectionId - the ID of the section to toggle * @param animate - boolean true to use slide down effect, false to just display:none */ public static void expandSection(HTMLPanel panel, String targetId, String sectionId, boolean animate) { if (animate) { JSUtil.slideDown(sectionId, "fast"); } else { Style style = panel.getElementById(sectionId).getStyle(); style.setDisplay(Display.BLOCK); } prependClassName(panel.getElementById(targetId), "expanded"); }
From source file:org.spiffyui.client.JSUtil.java
License:Apache License
/** * Collapses a section/* www . j a v a 2 s. c om*/ * @param panel - HTMLPanel holding the target * @param targetId - the ID of the target * @param sectionId - the ID of the section to toggle * @param animate - boolean true to use slide down effect, false to just display:none */ public static void collapseSection(HTMLPanel panel, String targetId, String sectionId, boolean animate) { if (animate) { JSUtil.slideUp(sectionId, "fast"); } else { Style style = panel.getElementById(sectionId).getStyle(); style.setDisplay(Display.NONE); } panel.getElementById(targetId).removeClassName("expanded"); }
From source file:org.spiffyui.spsample.client.Index.java
License:Apache License
private static void addTocLi(final HTMLPanel panel, final String liDisplay, final String h2Id, final String liId) { Anchor anchor = new Anchor(liDisplay, "#"); anchor.addClickHandler(new ClickHandler() { @Override//from w w w . j av a 2 s .c o m public void onClick(ClickEvent event) { Index.scrollTo(h2Id); event.preventDefault(); } }); if (panel.getElementById(liId) != null) { panel.add(anchor, liId); } }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * Create the refresh anchor and add it to the sliding grid *///from w ww .ja v a 2 s . co m private void addRefreshAnchor() { /* * Add a refresh anchor to our page */ m_refresh = new RefreshAnchor("Widgets_refreshAnchor"); HTMLPanel p = addToSlidingGrid(m_refresh, "WidgetsRefreshAnchor", Index.getStrings().refreshAnchor(), STRINGS.RefreshAnchor_html(), TALL); Element h3 = p.getElementById("WID_WidgetsRefreshAnchor"); //Set the title so that the TOC's list item for this isn't too long h3.setTitle(Index.getStrings().refreshAnchorConfirmDialog_toc()); m_refresh.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { m_refresh.setLoading(true); m_dlg.center(); m_dlg.show(); event.preventDefault(); } }); }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * Create the mutli-value auto-complete field and add it to the sliding grid */// w ww .j a v a2 s . c o m private void addMultiValueAutoComplete() { /* * Add the multivalue suggest box */ final FancyAutocompleter msb = new FancyAutocompleter( new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") { @Override public String buildUrl(String q, int indexFrom, int indexTo) { return "multivaluesuggestboxexample/colors?q=" + q + "&indexFrom=" + indexFrom + "&indexTo=" + indexTo; } }, true); msb.getFeedback().addStyleName("msg-feedback"); msb.setPageSize(8); //since each value takes up more space, let's cut the size. String spanId = "WidgetsSuggestBox"; HTMLPanel panel = addToSlidingGrid(msb, spanId, Index.getStrings().mvsp(), STRINGS.MultiVal_html(), BIG); /* * so that spellcheck is not done on a selected crayon color of "Screamin' Green" */ Element span = panel.getElementById(spanId); span.setAttribute("spellcheck", "false"); // /* // * temp to show how to get values and how to // * have a default value of Electric Lime // */ // Map<String, String> valueMap = new HashMap<String, String>(); // valueMap.put("Electric Lime", "#CEFF1D"); // msb.setValueMap(valueMap); // // final Button b = new Button("get values"); // panel.add(b); // b.addClickHandler(new ClickHandler() { // // @Override // public void onClick(ClickEvent event) // { // Map<String, String> values = msb.getValueMap(); // ConfirmDialog c = new ConfirmDialog("mvsb-results-dialog", "Results"); // StringBuffer sb = new StringBuffer(); // for (String key : values.keySet()) { // sb.append("<div style=\"background-color:" + values.get(key) + "\">" + key + "</div>"); // } // c.replaceDialogBodyContents(new HTML(sb.toString())); // c.addButton("mvsb-dialog-ok", "Close", "OK"); // c.showRelativeTo(b); // } // }); // /* // * end temp // */ }