Example usage for com.google.gwt.user.client.ui TreeItem getText

List of usage examples for com.google.gwt.user.client.ui TreeItem getText

Introduction

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

Prototype

public String getText() 

Source Link

Usage

From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelPanel.java

License:Open Source License

public boolean addContact(String aChannel, String aContactName) {
    boolean isContactAdded = false;

    final Iterator<TreeItem> theIterator = myChannelTree.treeItemIterator();
    while (theIterator.hasNext()) {
        TreeItem theChannelTreeItem = theIterator.next();
        if (isChannelItem(theChannelTreeItem)) {
            if (aChannel.equals(theChannelTreeItem.getText())) {
                if (!containsContact(theChannelTreeItem, aContactName)) {
                    //adds the contact if the contact doesn't already exists in that channel
                    theChannelTreeItem.addItem(aContactName);
                    isContactAdded = true;
                }//from   ww  w.ja va 2  s  . com
            }
        }
    }
    return isContactAdded;
}

From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelPanel.java

License:Open Source License

public HandlerRegistration addChannelSelectListener(final ChannelSelectListener aChannelSelectListener) {
    final SelectionHandler<TreeItem> theTreeSelectionHandler = new SelectionHandler<TreeItem>() {
        public void onSelection(SelectionEvent<TreeItem> aSelectionEvent) {
            final TreeItem theSelectedItem = aSelectionEvent.getSelectedItem();
            if (isChannelItem(theSelectedItem)) {
                final String theChannelName = theSelectedItem.getText();
                aChannelSelectListener.onSelect(theChannelName);
            }//from ww w  . ja va  2 s  .co m
        }
    };

    final HandlerRegistration theSelectionHandlerRegistration = myChannelTree
            .addSelectionHandler(theTreeSelectionHandler);
    myHandlerRegistrations.add(theSelectionHandlerRegistration);
    return theSelectionHandlerRegistration;
}

From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelPanel.java

License:Open Source License

private boolean removeItem(TreeItem aParentItem, String anEntry) {
    for (int i = 0; i < aParentItem.getChildCount(); i++) {
        final TreeItem theChild = aParentItem.getChild(i);
        if (theChild != null) {
            if (anEntry.equals(theChild.getText())) {
                aParentItem.removeItem(theChild);
                return true;
            }/* w ww.j a va2  s .  c o m*/
        }
    }
    return false;
}

From source file:de.spartusch.nasfvi.client.NResponseWidget.java

License:Apache License

/**
 * Creates and returns a visual representation for a subtree.
 * @param data Data of the subtree// ww w. j  av  a2 s  .co  m
 * @param depth Depth of the subtree in the analysis
 * @return Visual representation of <code>data</code>
 */
private TreeItem getSubtree(final JSONArray data, final int depth) {
    TreeItem root = new TreeItem();
    int subtrees = 0;

    for (int i = 0; i < data.size(); i++) {
        JSONArray array = data.get(i).isArray();

        if (array == null) {
            // just a string
            root.addItem(data.get(i).isString().stringValue());
        } else if (array.size() == 1 && array.get(0).isString() != null) {
            // array with a single string as an element
            root.addItem(array.get(0).isString().stringValue());
            subtrees++;
        } else {
            // arrays
            TreeItem item = getSubtree(array, depth + 1);

            int x = (depth < LABELS.length) ? depth : LABELS.length - 2;
            int y = (subtrees < LABELS[x].length) ? subtrees : LABELS[x].length - 1;

            String label = LABELS[x][y];

            if (label == null && item.getChildCount() > 0) {
                TreeItem first = item.getChild(0);
                label = first.getText();
                item.removeItem(first);
            }

            item.setText(label);
            root.addItem(item);
            subtrees++;
        }
    }

    return root;
}

From source file:es.ugr.rodgom.ludiuca.client.profesor.Admin.java

License:Apache License

/**
 * Constructs a new tree widget.// w ww.java 2 s .c  o  m
 */
public Admin() {
    tree = new Tree();
    tree.addTextItem("Crear Tarea");
    tree.addTextItem("Configuracin");

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            // expand the selected item
            String text = item.getText();
            CentralPan centralPan = Context.getCentralPan();
            if (text == "Crear Tarea") {
                // Show the corresponding information
                centralPan.updateListBox();
                centralPan.deck.showWidget(Context.NUEVORETO);
                centralPan.setEmptyHeader();
            } else if (text == "Configuracin") {
                // Show the corresponding information
                centralPan.deck.showWidget(Context.CONFIGURACION);
                centralPan.setEmptyHeader();
            }
            Context.setCentralPan(centralPan);
        }
    });
    initWidget(tree);
}

From source file:es.ugr.rodgom.ludiuca.client.profesor.Courses.java

License:Apache License

public Courses() {
    // Images images = GWT.create(Images.class);
    this.coursesList = new ArrayList<Course>();
    obtenerMisGrupos(Context.getTeacher().getId());
    tree = new Tree();

    initWidget(tree);//from  w  w w. ja va2  s.c  o m
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            GWT.log("Seleccionado un elemento");
            GWT.log("Antes de getselectedItem");
            TreeItem item = event.getSelectedItem();
            GWT.log("Antes de getparentItem");
            String itemText = item.getText();
            int indexCourse = getIndexCourse(itemText);
            GWT.log("Antes de id del curso");
            setIdSelectedCourse(coursesList.get(indexCourse).getId());
            GWT.log("Id del curso: " + coursesList.get(indexCourse).getId());
            updateSelectedItem();
        }
    });
    Context.setCourses(this);
}

From source file:es.ugr.rodgom.ludiuca.client.profesor.Panel.java

License:Apache License

/**
 * Constructs a new tree widget.// www  .  jav a 2 s  .c  om
 */
public Panel() {
    tree = new Tree();
    tree.addTextItem("Mis Puntos");
    tree.addTextItem("Clasificacin");

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            // expand the selected item
            String text = item.getText();
            CentralPan centralPan = Context.getCentralPan();
            if (text == "Mis Puntos") {
                // Show the corresponding information
                Context.getCentralPan().updateCoursesListBox();
                loadPoints();
            } else if (text == "Clasificacin") {
                // Show the corresponding information
                loadClassification();
            }
            Context.setCentralPan(centralPan);
        }
    });
    initWidget(tree);
}

From source file:es.ugr.rodgom.ludiuca.client.student.Admin.java

License:Apache License

/**
 * Constructs a new tree widget.// w  w w.  j  ava  2  s.  co  m
 */
public Admin() {
    tree = new Tree();
    tree.addTextItem("Configuracin");

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            // expand the selected item
            String text = item.getText();
            CentralPan centralPan = ContextStudent.getCentralPan();
            if (text == "Configuracin") {
                // Show the corresponding information
                centralPan.deck.showWidget(ContextStudent.CONFIGURACION);
                centralPan.setEmptyHeader();
            }
            ContextStudent.setCentralPan(centralPan);
        }
    });
    initWidget(tree);
}

From source file:es.ugr.rodgom.ludiuca.client.student.Courses.java

License:Apache License

public Courses() {
    // Images images = GWT.create(Images.class);
    this.coursesList = new ArrayList<Course>();
    obtenerMisGrupos(ContextStudent.getStudent().getId());
    tree = new Tree();

    initWidget(tree);//from  ww w  .j  a v  a  2  s .  com
    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            GWT.log("Seleccionado un elemento");
            GWT.log("Antes de getselectedItem");
            TreeItem item = event.getSelectedItem();
            GWT.log("Antes de getparentItem");
            String itemText = item.getText();
            int indexCourse = getIndexCourse(itemText);
            GWT.log("Antes de id del curso");
            setIdSelectedCourse(coursesList.get(indexCourse).getId());
            GWT.log("Id del curso: " + coursesList.get(indexCourse).getId());
            updateSelectedItem();
        }
    });
    ContextStudent.setCourses(this);
}

From source file:es.ugr.rodgom.ludiuca.client.student.Panel.java

License:Apache License

/**
 * Constructs a new tree widget./*from   w w w. j  a va  2s  .co m*/
 */
public Panel() {
    tree = new Tree();
    tree.addTextItem("Mis Logros");
    tree.addTextItem("Clasificacin");

    tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            // expand the selected item
            String text = item.getText();
            CentralPan centralPan = ContextStudent.getCentralPan();
            switch (text) {
            case "Mis Logros":
                // Show the corresponding information
                ContextStudent.getCentralPan().updateCoursesListBox();
                loadAwards();
                break;
            case "Clasificacin":
                // Show the corresponding information
                ContextStudent.getCentralPan().updateFilterListBox();
                loadClassification();
                break;
            }
            ContextStudent.setCentralPan(centralPan);
        }
    });
    initWidget(tree);
}