Package org.appfuse.client.widget

Examples of org.appfuse.client.widget.ListItem


    final Label grow = new Label();
    panel.add(grow);
    grow.addStyleName("grow");
    final BulletList list = new BulletList();
    list.setStyleName("token-input-list-facebook");
    final ListItem item = new ListItem();
    item.setStyleName("token-input-input-token-facebook");
    itemBox
        .getElement()
        .setAttribute(
            "style",
            "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;");
    box.getElement().setId("suggestion_box");
    item.add(box);
    list.add(item);

    // this needs to be on the itemBox rather than box, or backspace will
    // get executed twice
    itemBox.addKeyDownHandler(new KeyDownHandler() {
      public void onKeyDown(KeyDownEvent event) {
        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
          // only allow manual entries with @ signs (assumed email
          // addresses)
          if (itemBox.getValue().contains("@"))
            deselectItem(itemBox, list);
        }
        // handle backspace
        if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
          if ("".equals(itemBox.getValue().trim())) {
            ListItem li = (ListItem) list.getWidget(list
                .getWidgetCount() - 2);
            Paragraph p = (Paragraph) li.getWidget(0);
            if (itemsSelected.contains(p.getText())) {
              itemsSelected.remove(p.getText());
              GWT.log("Removing selected item '" + p.getText()
                  + "'", null);
              GWT.log("Remaining: " + itemsSelected, null);
View Full Code Here


    componentHelper.fireComponentMoved(this);
  }

  private void deselectItem(final TextBox itemBox, final BulletList list) {
    if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
      /**
       * Change to the following structure: <li class="token-input-token-facebook">
       * <p>
       * What's New Scooby-Doo?
       * </p>
       * <span class="token-input-delete-token-facebook">x</span></li>
       */

      final ListItem displayItem = new ListItem();
      displayItem.setStyleName("token-input-token-facebook");
      Paragraph p = new Paragraph(itemBox.getValue());

      displayItem.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent clickEvent) {
          displayItem
              .addStyleName("token-input-selected-token-facebook");
        }
      });

      /**
       * TODO: Figure out how to select item and allow deleting with
       * backspace key displayItem.addKeyDownHandler(new KeyDownHandler()
       * { public void onKeyDown(KeyDownEvent event) { if
       * (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
       * removeListItem(displayItem, list); } } });
       * displayItem.addBlurHandler(new BlurHandler() { public void
       * onBlur(BlurEvent blurEvent) { displayItem.removeStyleName(
       * "token-input-selected-token-facebook"); } });
       */

      Span span = new Span("x");
      span.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent clickEvent) {
          removeListItem(displayItem, list);
        }
      });

      displayItem.add(p);
      displayItem.add(span);
      // hold the original value of the item selected

      GWT.log("Adding selected item '" + itemBox.getValue() + "'", null);
      itemsSelected.add(itemBox.getValue());
      GWT.log("Total: " + itemsSelected, null);
View Full Code Here

TOP

Related Classes of org.appfuse.client.widget.ListItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.