Example usage for com.google.gwt.query.client GQuery get

List of usage examples for com.google.gwt.query.client GQuery get

Introduction

In this page you can find the example usage for com.google.gwt.query.client GQuery get.

Prototype

public Element get(int i) 

Source Link

Document

Return the ith element matched.

Usage

From source file:gwtquery.plugins.droppable.client.DroppableHandler.java

License:Apache License

public void drag(Element droppable, Element draggable, GqEvent e) {
    if (options.isDisabled() || greedyChild || !visible) {
        return;/*from  www. j av a  2 s. com*/
    }

    boolean isIntersect = intersect(draggable);
    PositionStatus c = null;

    if (!isIntersect && isOver) {
        c = PositionStatus.IS_OUT;
    } else if (isIntersect && !isOver) {
        c = PositionStatus.IS_OVER;
    }
    if (c == null) {
        return;
    }

    DroppableHandler parentDroppableHandler = null;
    GQuery droppableParents = null;
    if (options.isGreedy()) {
        // TODO maybe filter the parent with droppable data instead of test on css
        // class name
        droppableParents = $(droppable).parents("." + CssClassNames.GWTQUERY_DROPPABLE);
        if (droppableParents.length() > 0) {
            parentDroppableHandler = DroppableHandler.getInstance(droppableParents.get(0));
            parentDroppableHandler.greedyChild = (c == PositionStatus.IS_OVER);
        }
    }

    if (parentDroppableHandler != null && c == PositionStatus.IS_OVER) {
        parentDroppableHandler.isOver = false;
        parentDroppableHandler.isOut = true;
        parentDroppableHandler.out(droppableParents.get(0), draggable, e);
    }

    if (c == PositionStatus.IS_OUT) {
        isOut = true;
        isOver = false;
        out(droppable, draggable, e);
    } else {
        isOver = true;
        isOut = false;
        over(droppable, draggable, e);
    }

    if (parentDroppableHandler != null && c == PositionStatus.IS_OUT) {
        parentDroppableHandler.isOut = false;
        parentDroppableHandler.isOver = true;
        parentDroppableHandler.over(droppableParents.get(0), draggable, e);
    }

}

From source file:gwtquery.plugins.enhance.client.gwt.StackPanelWidgetFactory.java

License:Apache License

public StackPanel create(Element e) {
    StackPanel stackPanel = options.isDecorated() ? new DecoratedStackPanel() : new StackPanel();

    WidgetsUtils.replaceOrAppend(e, stackPanel);

    GQuery contents = $(options.getContentSelector(), e);
    GQuery headers = $(options.getHeaderSelector(), e);

    for (int i = 0; i < contents.length(); i++) {
        Element content = contents.get(i);
        Element header = headers.get(i);

        Widget contentWidget = $(content).widget();
        if (contentWidget == null) {
            contentWidget = new WidgetsHtmlPanel(content);
        }//from   w w  w .  j a  va  2s. c  om

        stackPanel.add(contentWidget, header != null ? header.getInnerText() : "Undefined");

    }

    return stackPanel;
}

From source file:gwtquery.plugins.enhance.client.gwt.TabPanelWidgetFactory.java

License:Apache License

public TabPanel create(Element e) {
    TabPanel tabPanel = new TabPanel();

    GQuery tabs = $(options.getTabSelector(), e);
    GQuery titles = $(options.getTitleSelector(), e);

    for (int i = 0; i < tabs.length(); i++) {
        GQuery tab = tabs.eq(i);
        GQuery title = titles.eq(i);//from   w w w .  jav  a 2  s.c  o m

        Widget tabWidget = tab.widget();
        if (tabWidget == null) {
            tabWidget = new WidgetsHtmlPanel(tab.get(0));
        }

        tabPanel.add(tabWidget, title.get(0) != null ? title.text() : "Tab " + (i + 1));

    }
    if (tabs.length() > 0) {
        tabPanel.selectTab(0);
    }

    WidgetsUtils.replaceOrAppend(e, tabPanel);
    return tabPanel;
}

From source file:gwtquery.samples.client.GwtQueryDemoModule.java

License:Apache License

public void onModuleLoad() {
    // Ask GWT compiler to generate our interface
    final Slide s = GWT.create(Slide.class);
    final GQuery slides = $(s.allSlides());

    // we initially hide all slides and bullets
    slides.hide().eq(0).as(Effects).clipAppear();
    $(s.allSlideBullets()).hide();//from   www  . j  a va 2s  .co  m

    // add onclick handler to body element
    $(slides).click(new Function() {
        // two state variables to note current slide being shown
        // and current bullet
        int curSlide = 0;
        int curBullets = 0;

        // query and store all bullets of current slide
        GQuery bullets = $(s.slideBulletsCtx(slides.get(curSlide)));

        public boolean f(Event e) {
            // onclick, if not all bullets shown, show a bullet and increment
            if (curBullets < bullets.size()) {
                bullets.eq(curBullets++).as(Effects).fadeIn(Speed.SLOW);
            } else {
                // all bullets shown, hide them and current slide
                bullets.hide();

                // move to next slide, checking for wrap around
                int lastSlide = curSlide++;
                if (curSlide == slides.size()) {
                    curSlide = 0;
                }

                // query for new set of bullets, and show next slide
                curBullets = 0;
                bullets = $(s.slideBulletsCtx(slides.get(curSlide)));

                // Hide the last slide and show the next when the effects finishes
                slides.eq(lastSlide).as(Effects).fadeOut(new Function() {
                    public void f(Element e) {
                        slides.eq(curSlide).as(Effects).clipAppear();
                    }
                });
            }
            return true;
        }
    });
}

From source file:org.bonitasoft.web.toolkit.client.ui.component.menu.MenuFolder.java

License:Open Source License

@Override
protected Element makeElement() {
    this.items.setRootTagName("ul");
    this.items.setWrapTag(null, null);

    final GQuery root = $("<li>");
    root.addClass("menuitem");
    if (getJsId() != null) {
        root.addClass(getJsId().toString("menuitem"));
    }//from ww w.  j a v  a 2  s . com

    GQuery link = null;
    ;
    if (this.image != null || this.label != null && this.label.length() > 0) {
        link = $("<a href=\"#\">" + this.label + "</a>");
        root.append(link);

        if (this.label != null && this.label.length() > 0) {
            link.text(this.label);
        }

        if (this.image != null) {
            link.prepend(this.image.getElement());
        }

    }

    appendComponentToHtml((Element) root.get(0), this.items);

    return (Element) root.get(0);
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.choosen.AvroChoosenListBox.java

License:Apache License

public static void updateChoosenListBoxMaxTextWidth(ChosenListBox box, int width, TextWidthFunction function) {
    ChosenImpl impl = $(box.getElement()).data(CHOSEN_DATA_KEY, ChosenImpl.class);
    if (impl != null) {
        GQuery results = impl.getContainer().find("li." + avroChoosenResources.css().activeResult(),
                "li." + avroChoosenResources.css().resultSelected());
        GQuery searchchoiceSpan = impl.getContainer().find("li." + avroChoosenResources.css().searchChoice())
                .find("span");
        results = results.add(searchchoiceSpan);
        results = results.add($(box.getElement()).find("option"));
        for (int i = 0; i < results.size(); i++) {
            Element e = results.get(i);
            GQuery ge = $(e);/*from  w w w. ja va2s.c  om*/
            ge.text(function.updateTextWidth(ge.text(), width));
        }
    }
}

From source file:org.lirazs.gbackbone.client.core.view.View.java

License:Apache License

private void bindAnnotatedViewInjections() {
    try {/*from   w ww  .  jav a  2 s  .c  o m*/
        ClassType classType = TypeOracle.Instance.getClassType(getClass());

        Field[] fields = classType.getFields();
        for (final Field field : fields) {
            InjectView annotation = field.getAnnotation(InjectView.class);
            if (annotation != null && field.isPublic()) {
                GQuery $element = null;
                String value = annotation.value();

                if (!value.isEmpty()) { // using the value as selector
                    $element = $(value);
                } else {
                    $element = $("#" + field.getName());
                }

                String elementClass = field.getTypeName();
                if (elementClass != null) {
                    if (elementClass.equals("com.google.gwt.query.client.GQuery")) {
                        // we have a GQuery element field..
                        //field.setFieldValue(this, $element);
                        field.getEnclosingType().setFieldValue(this, field.getName(), $element);
                    } else {
                        // probably some other element type
                        //field.setFieldValue(this, $element.get(0));
                        field.getEnclosingType().setFieldValue(this, field.getName(), $element.get(0));
                    }
                }
            }
        }
    } catch (MethodInvokeException e) {
        e.printStackTrace();
    } catch (ReflectionRequiredException e) {
        // do nothing... a reflection operation was operated on an inner class
    }
}

From source file:org.lirazs.gbackbone.client.core.view.View.java

License:Apache License

public View setElement(GQuery element, boolean delegate) {
    if ($el != null)
        undelegateEvents();//from ww  w  . j  ava 2  s  .c  o  m

    $el = element;
    el = element.get(0);

    if (delegate)
        delegateEvents();

    return this;
}

From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java

License:Apache License

private boolean containerMouseDown(Event e) {
    if (isDisabled) {
        return true;
    }//from w  ww. j a va 2 s. co  m
    Element target = e.getEventTarget().cast();
    GQuery $e = $(target);

    boolean targetCloseLink = $e.hasClass(css.searchChoiceClose());

    if (!resultsShowing) {
        e.stopPropagation();
    }

    if (!pendingDestroyClick && !targetCloseLink) {
        if (!activeField) {
            if (isMultiple) {
                searchField.val("");
            }
            $(document).click(clickTestAction);
            //resultsShow();
        } else if (!isMultiple && !$e.isEmpty()
                && ($e.get(0) == selectedItem.get(0) || $e.parents("a." + css.chznSingle()).length() > 0)) {
            e.preventDefault();
            resultsToggle();
        }

        activateField(e);

    } else {
        pendingDestroyClick = false;
    }

    return false;
}