Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

EmbeddedBrowserExample.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.demo.featurebrowser;
  5. import com.itmill.toolkit.data.Property.ValueChangeEvent;
  6. import com.itmill.toolkit.terminal.ExternalResource;
  7. import com.itmill.toolkit.ui.Embedded;
  8. import com.itmill.toolkit.ui.ExpandLayout;
  9. import com.itmill.toolkit.ui.Select;
  10. /**
  11. * Demonstrates the use of Embedded and "suggesting" Select by creating a simple
  12. * web-browser. Note: does not check for recursion.
  13. *
  14. * @author IT Mill Ltd.
  15. * @see com.itmill.toolkit.ui.Window
  16. */
  17. public class EmbeddedBrowserExample extends ExpandLayout implements
  18. Select.ValueChangeListener {
  19. // Default URL to open.
  20. private static final String DEFAULT_URL = "http://www.itmill.com/index_itmill_toolkit.htm";
  21. // The embedded page
  22. Embedded emb = new Embedded();
  23. public EmbeddedBrowserExample() {
  24. this(new String[] { DEFAULT_URL,
  25. "http://www.itmill.com/index_developers.htm",
  26. "http://toolkit.itmill.com/demo/doc/api/",
  27. "http://www.itmill.com/manual/index.html" });
  28. }
  29. public EmbeddedBrowserExample(String[] urls) {
  30. setSizeFull();
  31. // create the address combobox
  32. final Select select = new Select();
  33. // allow input
  34. select.setNewItemsAllowed(true);
  35. // no empty selection
  36. select.setNullSelectionAllowed(false);
  37. // no 'go' -button clicking necessary
  38. select.setImmediate(true);
  39. // add some pre-configured URLs
  40. for (int i = 0; i < urls.length; i++) {
  41. select.addItem(urls[i]);
  42. }
  43. // add to layout
  44. addComponent(select);
  45. // add listener and select initial URL
  46. select.addListener(this);
  47. select.setValue(urls[0]);
  48. // configure the embedded and add to layout
  49. emb.setType(Embedded.TYPE_BROWSER);
  50. addComponent(emb);
  51. // make the embedded as large as possible
  52. expand(emb);
  53. }
  54. public void valueChange(ValueChangeEvent event) {
  55. final String url = (String) event.getProperty().getValue();
  56. if (url != null) {
  57. // the selected url has changed, let's go there
  58. emb.setSource(new ExternalResource(url));
  59. }
  60. }
  61. }