Example usage for com.google.gwt.user.client.ui Tree addTextItem

List of usage examples for com.google.gwt.user.client.ui Tree addTextItem

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Tree addTextItem.

Prototype

@Override
public TreeItem addTextItem(String itemText) 

Source Link

Document

Adds a simple tree item containing the specified text.

Usage

From source file:gov.nist.spectrumbrowser.admin.JSONViewer.java

License:Open Source License

public void draw() {

    Tree tree = new Tree();

    HorizontalPanel hpanel = new HorizontalPanel();
    HorizontalPanel treePanel = new HorizontalPanel();
    treePanel.add(tree);/* w ww .ja v  a  2 s. c  o  m*/
    treePanel.setCellHorizontalAlignment(tree, HasHorizontalAlignment.ALIGN_LEFT);
    JSONObject strJ = (JSONObject) jsonObject.get(rootName);
    TreeItem rootItem = tree.addTextItem(rootName);
    TreeItem madAdder = populate(rootItem, strJ);
    Button okButton = new Button("OK");
    Button logoffButton = new Button("Log Off");

    verticalPanel.clear();
    madAdder.setState(true);
    tree.addItem(madAdder);

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            String parentItem = item.getParentItem().getText();
            if (parentItem.equals("_dataKey")) {
                JSONValue messageData = sensor.getMessageData().get(rootName + "_DATA");
                JSONArray arrdata = (JSONArray) messageData;
                if (arrdata == null) {
                    Window.alert("Empty");
                } else {
                    List<String> strlist = new ArrayList<String>();
                    for (int i = 0; i < arrdata.size(); i++) {
                        strlist.add(arrdata.get(i).toString());
                    }
                    final MyPopup popup = new MyPopup();
                    final TextArea box = new TextArea();
                    final SimplePanel pane = new SimplePanel();
                    box.setText("The first five corresponding values are: \n" + strlist.subList(0, 5));
                    box.setReadOnly(true);
                    box.setCharacterWidth(50);
                    pane.add(box);
                    popup.setWidget(pane);
                    popup.center();
                    popup.setAutoHideEnabled(true);
                    popup.show();

                }
            }
        }
    });

    okButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showMessageDates.draw();

        }
    });
    hpanel.add(okButton);

    logoffButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            admin.logoff();
        }
    });

    hpanel.add(logoffButton);

    verticalPanel.add(treePanel);
    verticalPanel.add(hpanel);
    initWidget(verticalPanel);

}

From source file:gov.nist.spectrumbrowser.client.JSONViewer.java

License:Open Source License

public JSONViewer(JSONObject jsonObject, String rootName) {
    Tree tree = new Tree();
    initWidget(tree);/*from   w  w w  .ja va  2s .  c o  m*/
    TreeItem rootItem = tree.addTextItem(rootName);
    populate(rootItem, jsonObject);
}

From source file:nz.org.winters.appspot.acrareporter.client.ui.ACRAReportView.java

License:Apache License

private void loadDeviceFeaturesTree(Tree tree, String featuresString) {
    String lines[] = featuresString.split("\n");

    TreeItem root = tree.addTextItem(constants.android());

    for (String line : lines) {
        if (line.startsWith("android.")) {
            line = line.replace("android.", "");
            String items[] = line.split("\\p{Punct}");

            recurseAddItem(root, items, 0);
        } else {/*w  w  w  .j  a v a2s .c  o  m*/
            root.addTextItem(line);
        }
    }
    root.setState(true);
}

From source file:py.edu.uca.intercajas.client.menumail.Mailboxes.java

License:Apache License

private Tree crearFiltros() {

    //     Anchor beneficiario = new Anchor("Beneficiario");
    //     beneficiario.addClickHandler(new ClickHandler() {
    //      @Override
    //      public void onClick(ClickEvent event) {
    //         ListaBeneficiarios lb = new ListaBeneficiarios(10);
    //         lb.setListener(new Listener() {
    //            @Override
    //            public void onSelected(Beneficiario beneficiarioSelected) {
    //               AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(beneficiarioSelected.getId(), cajaIdFilter));
    //            }
    //         });
    //         lb.mostrarDialog();
    //      }//from  w  w  w  . j a  va  2 s.  co  m
    //   });

    caja = new ValueListBox<Caja>(

            new Renderer<Caja>() {
                @Override
                public String render(Caja object) {
                    return object.getSiglas();
                }

                @Override
                public void render(Caja object, Appendable appendable) throws IOException {
                    // TODO Auto-generated method stub
                }
            }, new SimpleKeyProvider<Caja>() {
                @Override
                public Object getKey(Caja item) {
                    return item == null ? null : item.getId();
                }
            });

    try {
        BeneficiarioService.Util.get().findCajaAll(new MethodCallback<List<Caja>>() {
            @Override
            public void onFailure(Method method, Throwable exception) {
                new UIErrorRestDialog(method, exception);
            }

            @Override
            public void onSuccess(Method method, List<Caja> response) {
                Caja cajaTodos = new Caja();
                cajaTodos.setSiglas("TODOS");
                response.add(0, cajaTodos);
                caja.setAcceptableValues(response);
            }
        });
    } catch (Exception e) {
        Window.alert(e.getMessage());
    }

    caja.addValueChangeHandler(new ValueChangeHandler<Caja>() {
        @Override
        public void onValueChange(ValueChangeEvent<Caja> event) {
            setCajaIdFilter(event.getValue().getId());
            AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(Mailboxes.this.beneficiarioIdFilter,
                    event.getValue().getId(), fechaDesde, fechaHasta));
        }
    });

    Tree staticTree = new Tree();
    staticTree.setAnimationEnabled(true);
    TreeItem filtrarItem = staticTree.addTextItem("Filtrar");

    BeneficiarioSelector bs = new BeneficiarioSelector();
    bs.setClearVisible(true);
    bs.setListener(new Listener() {
        @Override
        public void onSelected(Beneficiario beneficiarioSelected) {
            if (beneficiarioSelected == null) {
                beneficiarioIdFilter = null;
            } else {
                Mailboxes.this.beneficiarioIdFilter = beneficiarioSelected.getId();
            }
            AppUtils.EVENT_BUS.fireEvent(
                    new RefreshMailEvent(beneficiarioIdFilter, getCajaIdFilter(), fechaDesde, fechaHasta));
        }
    });

    DateBox fechaDesde = new DateBox();
    DateBox fechaHasta = new DateBox();

    fechaDesde.setFormat(new DateBox.DefaultFormat(dateFormat));
    fechaHasta.setFormat(new DateBox.DefaultFormat(dateFormat));

    fechaDesde.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            if (!AppUtils.esFecha(event.getValue().trim())) {
                Mailboxes.this.fechaDesde = null; //esto es asi porque este evento se dispara cuando es una fecha invalida
                AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(Mailboxes.this.beneficiarioIdFilter,
                        Mailboxes.this.cajaIdFilter, Mailboxes.this.fechaDesde, Mailboxes.this.fechaHasta));
            }
        }
    });

    fechaDesde.addValueChangeHandler(new ValueChangeHandler<Date>() {

        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            Mailboxes.this.fechaDesde = event.getValue();
            AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(Mailboxes.this.beneficiarioIdFilter,
                    Mailboxes.this.cajaIdFilter, Mailboxes.this.fechaDesde, Mailboxes.this.fechaHasta));
        }
    });
    fechaHasta.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            if (!AppUtils.esFecha(event.getValue().trim())) {
                Mailboxes.this.fechaHasta = null;//esto es asi porque este evento se dispara cuando es una fecha invalida
                AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(Mailboxes.this.beneficiarioIdFilter,
                        Mailboxes.this.cajaIdFilter, Mailboxes.this.fechaDesde, Mailboxes.this.fechaHasta));
            }
        }
    });

    fechaHasta.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            Mailboxes.this.fechaHasta = event.getValue();
            AppUtils.EVENT_BUS.fireEvent(new RefreshMailEvent(Mailboxes.this.beneficiarioIdFilter,
                    Mailboxes.this.cajaIdFilter, Mailboxes.this.fechaDesde, Mailboxes.this.fechaHasta));
        }
    });

    VerticalPanel vp = new VerticalPanel();
    vp.add(new HTML("<b>Caja de Jubilacion<b>"));
    vp.add(caja);
    vp.add(new HTML("<b>Beneficiario<b>"));
    vp.add(bs);
    vp.add(new HTML("<b>Fecha desde<b>"));
    //     HorizontalPanel hp = new HorizontalPanel();
    vp.add(fechaDesde);
    vp.add(new HTML("<b>Fecha hasta<b>"));
    vp.add(fechaHasta);
    //     vp.add(hp);

    filtrarItem.addItem(vp);
    return staticTree;

}