List of usage examples for com.google.gwt.user.client.ui HTMLPanel add
public void add(Widget widget, String id)
From source file:org.spiffyui.mvsb.samples.client.Index.java
License:Apache License
private void addValuesAsString(HTMLPanel panel) { final FancyAutocompleter msb = new FancyAutocompleter( new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") { @Override//from w w w .ja va 2 s . c o m 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. panel.add(msb, "fancyGetSet"); m_valuesAsStringDlg = new ConfirmDialog("mvsb-results-dialog", "Values as String"); m_valuesAsStringDlg.setAutoHideEnabled(true); m_valuesAsStringDlg.setModal(false); m_valuesAsStringText = new TextArea(); m_valuesAsStringDlg.replaceDialogBodyContents(m_valuesAsStringText); m_valuesAsStringDlg.addButton("mvsb-vas-ok", "Close", "OK"); m_valuesAsStringDlg.addButton("mvsb-vas-set", "Set new value", "SET", new ClickHandler() { @Override public void onClick(ClickEvent event) { msb.setValuesAsString(m_valuesAsStringText.getText()); m_valuesAsStringDlg.hide(); } }); final Button b = new Button("Get Values as String"); panel.add(b, "fancyGetSet"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String values = msb.getValuesAsString(); m_valuesAsStringText.setText(values); m_valuesAsStringDlg.showRelativeTo(b); } }); }
From source file:org.spiffyui.mvsb.samples.client.Index.java
License:Apache License
private void addFancier(HTMLPanel panel) { final FancierAutocompleter msb = new FancierAutocompleter( new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") { @Override/* w w w . j a v a2 s . c o m*/ 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. panel.add(msb, "fancier"); createShowValuesButton(panel, msb, "fancier"); m_selectedOptionsDlg = new ConfirmDialog("mvsb-results-dialog", "Selected Options"); m_selectedOptionsDlg.setAutoHideEnabled(true); m_selectedOptionsDlg.setModal(false); m_selectedOptionsDlg.addButton("mvsb-dialog-ok", "Close", "OK"); final Button b = new Button("Get Selected Options"); panel.add(b, "fancier"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { List<Option> options = msb.getSelectedOptions(); StringBuffer sb = new StringBuffer(); for (Option o : options) { sb.append("<div class=\"facSoItem\">" + "<div class=\"facSoRgb\" style=\"background-color: rgb" + ((FancyOption) o).getRgb() + "\">" + "</div>" + "<div class=\"facName\">" + ((FancyOption) o).getName() + "</div>" + "<div class=\"facDesc\">" + ((FancyOption) o).getDescription() + "</div>" + "</div>"); } m_selectedOptionsDlg.replaceDialogBodyContents(new HTML(sb.toString())); m_selectedOptionsDlg.showRelativeTo(b); } }); }
From source file:org.spiffyui.spiffyauthnode.client.Index.java
License:Apache License
@Override public void onModuleLoad() { /*//from w ww . j ava 2 s . c o m This is where we load our module and create our dynamic controls. The MainHeader displays our title bar at the top of our page. */ final MainHeader header = new MainHeader(); header.setHeaderTitle("Hello Spiffy Auth Node!"); Anchor logout = new Anchor("Logout", "#"); logout.getElement().setId("header_logout"); header.setLogout(logout); if (!Index.userLoggedIn()) { logout.setVisible(false); header.setWelcomeString(""); } else { header.setWelcomeString("You are logged in!"); } logout.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { event.preventDefault(); doLogout(); } }); /* The main footer shows our message at the bottom of the page. */ MainFooter footer = new MainFooter(); footer.setFooterString( "SpiffyAuthNode was built with the <a href=\"http://www.spiffyui.org\">Spiffy UI Framework</a>"); /* This HTMLPanel holds most of our content. MainPanel_html was built in the HTMLProps task from MainPanel.html, which allows you to use large passages of html without having to string escape them. */ HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html()) { @Override public void onLoad() { super.onLoad(); /* Let's set focus into the text field when the page first loads */ m_text.setFocus(true); } }; RootPanel.get("mainContent").add(panel); /* These dynamic controls add interactivity to our page. */ panel.add(m_longMessage, "longMsg"); panel.add(m_text, "nameField"); final Button button = new Button("Submit"); panel.add(button, "submitButton"); button.addClickHandler(this); m_text.addKeyPressHandler(this); RESTility.addLoginListener(new RESTLoginCallBack() { @Override public void onLoginSuccess() { if (RESTility.getUserToken() == null) { return; } header.setWelcomeString("Welcome " + RESTility.getUsername()); JSUtil.bounce("#" + MainHeader.HEADER_ACTIONS_BLOCK, 5, 500, 30); JSUtil.show("#header_logout", "fast"); } @Override public void loginPrompt() { //do nothing } }); }
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 ww w . j a va 2s.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 status indicators and add them to the sliding grid */// w w w.j av a 2 s. co m private void addStatusIndicators() { /* * Add 3 status indicators */ StatusIndicator status1 = new StatusIndicator(StatusIndicator.IN_PROGRESS); StatusIndicator status2 = new StatusIndicator(StatusIndicator.SUCCEEDED); StatusIndicator status3 = new StatusIndicator(StatusIndicator.FAILED); HTMLPanel statusPanel = addToSlidingGrid(status1, "WidgetsStatus", Index.getStrings().statusIndicator(), STRINGS.Status_html()); statusPanel.add(status2, "WidgetsStatus"); statusPanel.add(status3, "WidgetsStatus"); }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
private void addNavPanelInfo() { Anchor css = new Anchor(Index.getStrings().cssPage(), "CSSPanel"); css.addClickHandler(new ClickHandler() { @Override//from w w w . jav a2s. c om public void onClick(ClickEvent event) { event.preventDefault(); Index.selectItem(Index.CSS_NAV_ITEM_ID); } }); HTMLPanel panel = addToSlidingGrid(null, "NavPanelGridCell", Index.getStrings().navBar(), STRINGS.NavBar_html(), TALL); panel.add(css, "cssPageWidgetsLink"); }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * Create login panel and add it to the sliding grid */// w ww . j a va 2 s .c o m private void addLoginPanel() { String buttonText = ""; if (Index.userLoggedIn()) { buttonText = Index.getStrings().secData(); } else { buttonText = Index.getStrings().getSecData(); } final SimpleButton doLoginButton = new SimpleButton(buttonText); if (Index.isAppEngine()) { doLoginButton.setText(Index.getStrings().installMessage()); doLoginButton.setEnabled(false); } doLoginButton.getElement().setId("doLoginBtn"); doLoginButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { doLoginButton.setInProgress(true); //a little timer to simulate time it takes to set in progress back to false Timer t = new Timer() { @Override public void run() { doLoginButton.setInProgress(false); AuthPanel.getData(true); } }; t.schedule(1000); } }); HTMLPanel loginButtonPanel = addToSlidingGrid(doLoginButton, "WidgetsLoginPanel", Index.getStrings().loginPanel(), STRINGS.LoginWidget_html(), TALL); loginButtonPanel.add((new HTML("<p><div id=\"loginResult\"></div>")), "WidgetsLoginPanel"); Anchor auth = new Anchor(Index.getStrings().authPage(), "AuthPanel"); auth.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { event.preventDefault(); Index.selectItem(Index.AUTH_NAV_ITEM_ID); } }); loginButtonPanel.add(auth, "authPanelSpan"); }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * A helper method that adds a widget and some HTML description to the sliding * grid panel/* w w w .j a v a2 s . c om*/ * * @param widget the widget to add * @param id the ID of the new cell * @param title the title of the new cell * @param htmlText the HTML description of the widget * @param type the type of cell to add: TALL, BIG, or WIDE * * @return the HTMLPanel used to add the contents to the new cell */ private HTMLPanel addToSlidingGrid(Widget widget, String id, String title, String htmlText, int type) { HTMLPanel p = new HTMLPanel("div", "<h3 id=\"WID_" + id + "\">" + title + "</h3>" + htmlText + "<span id=\"" + id + "\"></span>"); if (widget != null) { p.add(widget, id); } switch (type) { case WIDE: m_slideGridPanel.addWide(p); break; case TALL: m_slideGridPanel.addTall(p); break; case BIG: m_slideGridPanel.addBig(p); break; default: m_slideGridPanel.add(p); break; } return p; }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * Add the message buttons to the sliding grid *///from w ww . j a va 2 s .c o m private void addMessageButton() { /* * Add the message buttons */ Button b = new Button(Index.getStrings().showInfoMessage()); HTMLPanel p = addToSlidingGrid(b, "WidgetsMessages", Index.getStrings().humanMsg(), STRINGS.HumanMsg_html(), TALL); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { MessageUtil.showMessage(Index.getStrings().infoMsg()); } }); b = new Button(Index.getStrings().showWrnMsg()); p.add(b, "WidgetsMessages"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { MessageUtil.showWarning(Index.getStrings().wrnMsg(), false); } }); b = new Button(Index.getStrings().showErrMsg()); p.add(b, "WidgetsMessages"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { MessageUtil.showError(Index.getStrings().errMsg()); } }); b = new Button(Index.getStrings().showFatalErrMsg()); p.add(b, "WidgetsMessages"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { MessageUtil.showFatalError(Index.getStrings().fatalErrMsg()); } }); b = new Button(Index.getStrings().showPageWarningMsg()); p.add(b, "WidgetsMessages"); b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { MessageUtil.showPageLevelWarning(Index.getStrings().pageWarningMsg()); } }); }