Example usage for com.google.gwt.user.client.ui FlowPanel insert

List of usage examples for com.google.gwt.user.client.ui FlowPanel insert

Introduction

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

Prototype

public void insert(Widget w, int beforeIndex) 

Source Link

Document

Inserts a widget before the specified index.

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void replace(Widget current, Widget newWidget, Panel parent) {
    if (parent == null) {
        parent = (Panel) current.getParent();
    }/*from  w w  w  .j  av  a  2  s  .  com*/
    if (current == null || current.getParent() != parent) {
        parent.add(newWidget);
        return;
    }
    if (parent instanceof SimplePanel) {
        ((SimplePanel) parent).setWidget(newWidget);
        return;
    }
    ComplexPanel cp = (ComplexPanel) parent;
    int index = cp.getWidgetIndex(current);
    cp.remove(index);
    if (cp instanceof FlowPanel) {
        FlowPanel fp = (FlowPanel) cp;
        fp.insert(newWidget, index);
    }
}

From source file:cc.kune.sandbox.client.KuneSandboxEntryPoint.java

License:GNU Affero Public License

public void completeTests() {
    NotifyUser.info("Started");

    final Navbar simpleNavbar = new Navbar();
    final NavbarHeader header = new NavbarHeader();
    final NavbarCollapseButton navbarCollapseButton = new NavbarCollapseButton();
    navbarCollapseButton.setDataTarget("#test");
    header.add(navbarCollapseButton);/*from  w w  w .  ja  v  a  2s  .  c  o  m*/
    simpleNavbar.add(header);
    final NavbarCollapse navbarCollapse = new NavbarCollapse();
    navbarCollapse.setId("test");
    simpleNavbar.add(navbarCollapse);

    final NavbarNav navbarNav = new NavbarNav();
    final ComplexDropDownMenu<ListDropDown> listDropDown = new ComplexDropDownMenu<ListDropDown>(
            new ListDropDown());
    listDropDown.setMenuText("Plain menu");
    listDropDown.setIcon(IconType.GEAR);
    navbarCollapse.add(navbarNav);
    navbarNav.add(listDropDown.getWidget());

    final AnchorListItem simpleAnchor = new AnchorListItem("Anchor 1");
    simpleAnchor.setIcon(IconType.TWITTER_SQUARE);
    navbarNav.add(simpleAnchor);

    navbarNav.add(new AnchorListItem("Anchor 2"));
    navbarNav.add(new AnchorListItem("Anchor 3"));
    final AnchorListItem menuitem1 = new AnchorListItem("Anchor menuitem 1");
    menuitem1.setIcon(IconType.RANDOM);

    listDropDown.add(menuitem1);

    final CheckListItem checkitem = new CheckListItem("Check item");
    checkitem.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            checkitem.setChecked(!checkitem.isChecked());
        }
    });
    listDropDown.add(checkitem);

    final RadioListItem radioitem = new RadioListItem("Check item");
    radioitem.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            radioitem.setChecked(!radioitem.isChecked());
        }
    });
    listDropDown.add(radioitem);

    final CheckListItem checkitem2 = new CheckListItem("Check anchor");
    checkitem2.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            checkitem2.setChecked(!checkitem2.isChecked());
        }
    });

    navbarNav.add(checkitem2);
    listDropDown.add(new AnchorListItem("Anchor menuitem 2"));
    final ComplexAnchorListItem menuitem3 = new ComplexAnchorListItem("Anchor menuitem 3");
    menuitem3.setIconUrl("http://lorempixel.com/100/100");
    listDropDown.add(menuitem3);
    final AnchorListItem item1 = new AnchorListItem("Testingggg");
    item1.setIcon(IconType.HEART);
    listDropDown.add(item1);

    for (int i = 1; i < 50; i++) {
        listDropDown.add(new AnchorListItem("Anchor " + i));
    }

    final ComplexAnchorListItem itemSubmenu = new ComplexAnchorListItem("Testing submenu");
    itemSubmenu.setIcon(KuneIcon.FOLDER);
    final DropDownSubmenu submenu = new DropDownSubmenu();
    submenu.add(new AnchorListItem("sub item 1"));
    submenu.add(new AnchorListItem("sub item 2"));
    submenu.add(new AnchorListItem("sub item 3"));
    itemSubmenu.add(submenu);
    listDropDown.add(itemSubmenu);

    final DropDown dropDown = new DropDown();

    final Anchor dropDownAnchor = new Anchor();
    // FIXME This fails:
    // final BasicThumb thumb = testThumbs();
    final Image thumb = new Image("http://lorempixel.com/30/30");
    dropDownAnchor.add(thumb);
    dropDownAnchor.setDataToggle(Toggle.DROPDOWN);
    dropDown.add(dropDownAnchor);

    final DropDownMenu dropDownMenu = new DropDownMenu();
    dropDown.add(dropDownMenu);
    final ComplexAnchorListItem dditem1 = new ComplexAnchorListItem("Test 1");
    final ComplexAnchorListItem dditem2 = new ComplexAnchorListItem("Test 2");
    dditem1.setIcon(KuneIcon.BARTER);
    dditem2.setIconUrl("http://lorempixel.com/101/101");
    dropDownMenu.add(dditem1);
    dropDownMenu.add(dditem2);

    // The same with descriptors

    final Image thumb2 = new Image("http://lorempixel.com/30/30");
    final WidgetMenuDescriptor widgetMenu = new WidgetMenuDescriptor(thumb2);
    new MenuItemDescriptor(widgetMenu, new BaseAction("Menuitem desc in widget 1", "Some tooltip"));
    new MenuItemDescriptor(widgetMenu, new BaseAction("Menuitem desc in widget 2", "Some tooltip"));

    // Now with a button

    final MenuDescriptor classicMenu = new MenuDescriptor("Button classic menu");
    classicMenu.withIcon("http://lorempixel.com/30/30");
    new MenuItemDescriptor(classicMenu, new BaseAction("Menuitem desc in widget 1", "Some tooltip"));
    new MenuItemDescriptor(classicMenu, new BaseAction("Menuitem desc in widget 2", "Some tooltip"));

    final MenuDescriptor classicMenu2 = new MenuDescriptor("Button classic2 menu");
    classicMenu2.withIcon("http://lorempixel.com/30/30");
    new MenuItemDescriptor(classicMenu2, new BaseAction("Menuitem desc in widget 3", "Some tooltip"));
    new MenuItemDescriptor(classicMenu2, new BaseAction("Menuitem desc in widget 4", "Some tooltip"));

    final CustomButton btn = new CustomButton("Text custom button");
    Tooltip.to(btn, "Show the dropdown at 100,100 position (or hide it)");
    btn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            if (listDropDown.isMenuVisible()) {
                listDropDown.hide();
            } else {
                listDropDown.show(100, 100);
            }
        }
    });
    btn.setIcon(KuneIcon.FOLDER);

    // final cc.kune.bootstrap.client.ui.IconLabel iconLabel = new
    // cc.kune.bootstrap.client.ui.IconLabel(
    // "Text");
    // iconLabel.setIcon(new KuneIcon('g'));

    final FlowPanel flow = mainContainer.getFlow();
    flow.insert(btn, 0);
    flow.insert(new HTML("<br>"), 1);
    flow.insert(dropDown, 2);
    flow.insert(new HTML("<br>"), 3);

    final ToolbarDescriptor bottomToolbar = new ToolbarDescriptor();
    bottomToolbar.setPosition(NavbarPosition.FIXED_BOTTOM);

    final ButtonDescriptor btnDesc = new ButtonDescriptor(new TestAction("Button desc"));
    btnDesc.withIcon(KuneIcon.SETTINGS).withToolTip("Show me a tooltip");
    btnDesc.setParent(bottomToolbar);

    final IconLabelDescriptor labelDesc = new IconLabelDescriptor(new TestAction("IconLabel desc"));
    labelDesc.withIcon(KuneIcon.TASKS).withToolTip("Show me a tooltip");
    labelDesc.setParent(bottomToolbar);

    final MenuDescriptor menu = new MenuDescriptor("Menu btn");
    menu.setParent(bottomToolbar);
    final MenuItemDescriptor menuItemDescriptor = new MenuItemDescriptor(menu, new TestAction("Menu item"));
    menuItemDescriptor.withIcon(IconType.MAGIC);

    final SubMenuDescriptor submenuDesc = new SubMenuDescriptor(menu, "Some submenu");
    submenuDesc.withIcon(KuneIcon.BARTER);
    new MenuItemDescriptor(submenuDesc, new TestAction("Submenu item 1")).withIcon(IconType.FACEBOOK);
    new MenuItemDescriptor(submenuDesc, new TestAction("Submenu item 2")).withIcon(IconType.FAST_BACKWARD);

    // TODO Add more tests here

    final FlowActionExtensible sitebar = new FlowActionExtensible();
    sitebar.add(createSitebarActions());

    final FlowActionExtensible bottombar = new FlowActionExtensible();
    bottombar.add(bottomToolbar);

    // RootPanel.get().add(testActionToolbar());

    final FlowActionExtensible mainFlow = new FlowActionExtensible();
    mainFlow.add(widgetMenu, classicMenu, classicMenu2);

    final PaperFab paperFab = new PaperFab();
    paperFab.setIcon("polymer");

    mainContainer.getSitebar().add(sitebar);
    mainContainer.getFooter().add(bottombar);
    mainContainer.getFooter().add(paperFab);
    final PaperButton paperBtn = new PaperButton();
    mainContainer.getFooter().add(paperBtn);
    flow.add(mainFlow);
    flow.insert(simpleNavbar, 0);

    testBarButtons(flow);
    addNotifyUserTests(flow);
    addSimpleActions(flow);
    flow.add(new Text(LoremUtils.LOREM_MULTI + LoremUtils.LOREM_MULTI));

    RootLayoutPanel.get().add(mainContainer);
}

From source file:com.akanoo.client.views.CanvasView.java

License:Apache License

public void noteClicked(final Note note, final boolean isBackBody) {
    NoteRepresentation representation = findByNote(note);

    final FlowPanel notePanel = representation.notePanel;
    final Label bodyLabel = isBackBody ? representation.backBodyLabel : representation.bodyLabel;

    if (note != null) {
        final TextBoxBase textBox = new TextArea();

        textBox.setText(isBackBody ? note.getBackBody() : note.getBody());
        textBox.addStyleName(resources.canvasStyle().bodyLabelPosition());
        textBox.addStyleName(resources.canvasStyle().bodyBox());

        notePanel.insert(textBox, 0);
        bodyLabel.setVisible(false);/*from  w ww  .  j ava 2s .  c o  m*/

        editing = true;
        GWT.log("Editing started");

        textBox.addBlurHandler(new TextBlurHandler(textBox, bodyLabel, note, isBackBody));
        textBox.setFocus(true);
    }
}

From source file:com.alkacon.acacia.client.AttributeHandler.java

License:Open Source License

/**
 * Moves the give attribute value from one position to another.<p>
 * //from   w ww .  ja  va  2  s  .co  m
 * @param valueView the value to move
 * @param currentPosition the current position
 * @param targetPosition the target position
 */
public void moveAttributeValue(AttributeValueView valueView, int currentPosition, int targetPosition) {

    if (currentPosition == targetPosition) {
        return;
    }
    FlowPanel parent = (FlowPanel) valueView.getParent();

    valueView.removeFromParent();
    m_attributeValueViews.remove(valueView);
    AttributeValueView valueWidget = null;
    if (isChoiceHandler()) {
        removeHandlers(currentPosition);
        I_Entity value = m_entity.getAttribute(m_attributeName).getComplexValues().get(currentPosition);
        m_entity.removeAttributeValue(m_attributeName, currentPosition);
        m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
        String attributeChoice = getChoiceName(targetPosition);
        I_Type optionType = getAttributeType().getAttributeType(attributeChoice);
        valueWidget = new AttributeValueView(this, m_widgetService.getAttributeLabel(attributeChoice),
                m_widgetService.getAttributeHelp(attributeChoice));
        if (optionType.isSimpleType() && m_widgetService.isDisplaySingleLine(attributeChoice)) {
            valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
        }
        parent.insert(valueWidget, targetPosition);
        insertHandlers(targetPosition);
        if (optionType.isSimpleType()) {
            valueWidget.setValueWidget(m_widgetService.getAttributeFormWidget(attributeChoice),
                    value.getAttribute(attributeChoice).getSimpleValue(),
                    m_widgetService.getDefaultAttributeValue(attributeChoice), true);
        } else {
            valueWidget.setValueEntity(
                    m_widgetService.getRendererForAttribute(attributeChoice, getAttributeType()),
                    value.getAttribute(attributeChoice).getComplexValue());
        }

        List<ChoiceMenuEntryBean> menuEntries = Renderer.getChoiceEntries(getAttributeType(), true);
        for (ChoiceMenuEntryBean menuEntry : menuEntries) {
            valueWidget.addChoice(m_widgetService, menuEntry);
        }
    } else if (getAttributeType().isSimpleType()) {
        String value = m_entity.getAttribute(m_attributeName).getSimpleValues().get(currentPosition);
        m_entity.removeAttributeValue(m_attributeName, currentPosition);
        m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
        valueWidget = new AttributeValueView(this, m_widgetService.getAttributeLabel(m_attributeName),
                m_widgetService.getAttributeHelp(m_attributeName));
        if (m_widgetService.isDisplaySingleLine(m_attributeName)) {
            valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
        }
        parent.insert(valueWidget, targetPosition);
        valueWidget.setValueWidget(m_widgetService.getAttributeFormWidget(m_attributeName), value,
                m_widgetService.getDefaultAttributeValue(m_attributeName), true);
    } else {
        removeHandlers(currentPosition);
        I_Entity value = m_entity.getAttribute(m_attributeName).getComplexValues().get(currentPosition);
        m_entity.removeAttributeValue(m_attributeName, currentPosition);
        m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
        valueWidget = new AttributeValueView(this, m_widgetService.getAttributeLabel(m_attributeName),
                m_widgetService.getAttributeHelp(m_attributeName));
        parent.insert(valueWidget, targetPosition);
        insertHandlers(targetPosition);
        valueWidget.setValueEntity(m_widgetService.getRendererForAttribute(m_attributeName, getAttributeType()),
                value);

    }
    updateButtonVisisbility();
    UndoRedoHandler handler = UndoRedoHandler.getInstance();
    if (handler.isIntitalized()) {
        handler.addChange(m_entity.getId(), m_attributeName, 0, ChangeType.sort);
    }
}

From source file:com.edgenius.wiki.gwt.client.widgets.URLTabBar.java

License:Open Source License

public void resetTabTitle(int uniqueID, String title, Image titleIcon) {
    for (Iterator<Widget> iter1 = tabBar.iterator(); iter1.hasNext();) {
        FlowPanel tab = (FlowPanel) iter1.next();
        if (getTabUniqueID(tab) == uniqueID) {
            for (Iterator<Widget> iter = tab.iterator(); iter.hasNext();) {
                Widget w = iter.next();//from  w  w  w .  j  a v  a  2 s  .c  o m
                if (w instanceof ClickLink) {
                    ((ClickLink) w).setText(title);
                } else if (w instanceof Label) {
                    ((Label) w).setText(title);
                } else if (w instanceof Image) {
                    //remove current image
                    iter.remove();
                }
            }
            //add new image to first 
            if (titleIcon != null)
                tab.insert(titleIcon, 0);
            break;
        }
    }
}

From source file:com.google.gerrit.client.change.CommitBox.java

License:Apache License

private static void formatLink(GitPerson person, FlowPanel p, InlineHyperlink name, Element date,
        ChangeInfo change) {/*from   www. j  a v a 2  s.  com*/
    // only try to fetch the avatar image for author and committer if an avatar
    // plugin is installed, if the change owner has no avatar info assume that
    // no avatar plugin is installed
    if (change.owner().hasAvatarInfo()) {
        AvatarImage avatar;
        if (sameEmail(change.owner(), person)) {
            avatar = new AvatarImage(change.owner());
        } else {
            avatar = new AvatarImage(AccountInfo.create(0, person.name(), person.email(), null));
        }
        p.insert(avatar, 0);
    }

    name.setText(renderName(person));
    name.setTargetHistoryToken(PageLinks.toAccountQuery(owner(person), change.status()));
    date.setInnerText(FormatUtil.mediumFormat(person.date()));
}

From source file:com.TDDD24Project.client.DragAndDropHandler.java

License:Apache License

/**
 * On drop, insert the draggable at the drop index, remove handler on
 * the {@link DragEvent} of this draggable
 *//*from  w ww . j a  v a  2 s  . co m*/
public void onDrop(DropEvent event) {
    final DraggableWidget<?> draggable = event.getDraggableWidget();

    SuperWidget widget = (SuperWidget) panel.getWidget(currentDropIndex);
    SuperWidget widget2 = (SuperWidget) draggable;

    int userId = widget2.userId;
    int widget2Position = widget2.position % 10;

    swapWidgetPlaceInDatabase(userId, widget.position, widget2.position);

    int tempPosition = widget.position;
    widget.position = widget2.position;
    widget2.position = tempPosition;
    FlowPanel panel2 = (FlowPanel) widget2.getParent();
    panel2.insert(widget, widget2Position - 1);

    panel.insert(draggable, currentDropIndex);

    reset();
    widget2.isBeingDragged = false;

}

From source file:net.scran24.common.client.WidgetFactory.java

License:Apache License

public static FlowPanel createPromptPanel(SafeHtml prompt, Widget floatWidget) {
    FlowPanel result = createPromptPanel(prompt);
    result.insert(floatWidget, 0);
    floatWidget.addStyleName("intake24-prompt-float-widget");
    return result;
}

From source file:net.scran24.user.client.survey.flat.PromptUtil.java

License:Apache License

public static void addBackLink(FlowPanel container) {
    if (!History.getToken().equals("0")) {
        FlowPanel anchorDiv = new FlowPanel();
        anchorDiv.addStyleName("intake24-back-link-container");

        Anchor back = new Anchor(SafeHtmlUtils.fromSafeConstant(messages.goBackLabel()));
        back.addClickHandler(new ClickHandler() {
            @Override//from  w  w  w  .  ja  v a2s  .  c  o m
            public void onClick(ClickEvent event) {
                History.back();
            }
        });

        back.addStyleName("intake24-back-link");

        anchorDiv.add(back);
        container.insert(anchorDiv, 0);
    }
}

From source file:net.scran24.user.client.survey.flat.PromptUtil.java

License:Apache License

public static final SimplePrompt<UpdateFunc> withHeader(final SimplePrompt<UpdateFunc> prompt,
        final String headerText) {
    return new SimplePrompt<UpdateFunc>() {
        @Override//  www.  j a va 2 s.com
        public FlowPanel getInterface(final Callback1<UpdateFunc> onComplete) {
            FlowPanel contents = prompt.getInterface(onComplete);

            contents.insert(new HTMLPanel("h1", headerText), 0);

            return contents;
        }
    };
}