Search in sources :

Example 26 with Label

use of com.google.gwt.user.client.ui.Label in project rstudio by rstudio.

the class BranchToolbarButton method populateMenu.

private void populateMenu(final ToolbarPopupMenu menu, final Map<String, List<String>> branchMap) {
    MapUtil.forEach(branchMap, new MapUtil.ForEachCommand<String, List<String>>() {

        @Override
        public void execute(final String caption, final List<String> branches) {
            // place commonly-used branches at the top
            Collections.sort(branches, new Comparator<String>() {

                private final String[] specialBranches_ = new String[] { "master", "develop", "trunk" };

                @Override
                public int compare(String o1, String o2) {
                    for (String specialBranch : specialBranches_) {
                        if (o1.endsWith(specialBranch))
                            return -1;
                        else if (o2.endsWith(specialBranch))
                            return 1;
                    }
                    return o1.compareToIgnoreCase(o2);
                }
            });
            menu.addSeparator(new CustomMenuItemSeparator() {

                @Override
                public Widget createMainWidget() {
                    String branchLabel = caption.equals(LOCAL_BRANCHES) ? LOCAL_BRANCHES : "(Remote: " + caption + ")";
                    Label label = new Label(branchLabel);
                    label.addStyleName(ThemeStyles.INSTANCE.menuSubheader());
                    label.getElement().getStyle().setPaddingLeft(2, Unit.PX);
                    return label;
                }
            });
            menu.addSeparator();
            for (String branch : branches) {
                // skip detached branches
                if (branch.contains("HEAD detached at"))
                    continue;
                // skip HEAD branches
                if (branch.contains("HEAD ->"))
                    continue;
                // construct branch label without remotes prefix
                final String branchLabel = branch.replaceAll("^remotes/" + caption + "/", "");
                final String branchValue = branch.replaceAll("\\s+\\-\\>.*", "");
                menu.addItem(new MenuItem(branchLabel, new SwitchBranchCommand(branchLabel, branchValue)));
            }
        }
    });
}
Also used : CustomMenuItemSeparator(org.rstudio.core.client.widget.CustomMenuItemSeparator) MapUtil(org.rstudio.core.client.MapUtil) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) List(java.util.List) MenuItem(com.google.gwt.user.client.ui.MenuItem) JsArrayString(com.google.gwt.core.client.JsArrayString) Comparator(java.util.Comparator)

Example 27 with Label

use of com.google.gwt.user.client.ui.Label in project rstudio by rstudio.

the class TerminalPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    Toolbar toolbar = new Toolbar();
    activeTerminalToolbarButton_ = new TerminalPopupMenu(terminals_);
    toolbar.addLeftWidget(activeTerminalToolbarButton_.getToolbarButton());
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(commands_.previousTerminal().createToolbarButton());
    toolbar.addLeftWidget(commands_.nextTerminal().createToolbarButton());
    toolbar.addLeftSeparator();
    terminalTitle_ = new Label();
    terminalTitle_.setStyleName(ThemeStyles.INSTANCE.subtitle());
    toolbar.addLeftWidget(terminalTitle_);
    toolbar.addRightWidget(commands_.clearTerminalScrollbackBuffer().createToolbarButton());
    commands_.previousTerminal().setEnabled(false);
    commands_.nextTerminal().setEnabled(false);
    commands_.closeTerminal().setEnabled(false);
    commands_.renameTerminal().setEnabled(false);
    commands_.closeTerminal().setEnabled(false);
    commands_.clearTerminalScrollbackBuffer().setEnabled(false);
    return toolbar;
}
Also used : Label(com.google.gwt.user.client.ui.Label) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 28 with Label

use of com.google.gwt.user.client.ui.Label in project gwt-test-utils by gwt-test-utils.

the class PatcherTest method testModal.

// FIXME : reactive this test when using gwtbootstrap 2.1.1.0
/**
     * @Test public void testCollapse() { final CollapseTrigger trigger = new
     * CollapseTrigger("#myCollapse"); final Button triggerButton = new Button("trigger");
     * trigger.add(triggerButton);
     * <p>
     * final Collapse collapse = new Collapse(); collapse.setId("myCollapse");
     * collapse.setWidget(new Label("test")); collapse.setExistTrigger(true);
     * collapse.setToggle(true);
     * <p>
     * collapse.addShowHandler(showHandler); collapse.addShownHandler(shownHandler);
     * collapse.addHideHandler(hideHandler); collapse.addHiddenHandler(hiddenHandler);
     * <p>
     * collapse.asWidget(); trigger.asWidget();
     * <p>
     * getBrowserSimulator().fireLoopEnd();
     * <p>
     * collapse.hide(); verify(hideHandler).onHide(any(HideEvent.class));
     * verify(hiddenHandler).onHidden(any(HiddenEvent.class));
     * <p>
     * collapse.show(); verify(showHandler).onShow(any(ShowEvent.class));
     * verify(shownHandler).onShown(any(ShownEvent.class));
     * <p>
     * collapse.toggle(); verify(hideHandler, times(2)).onHide(any(HideEvent.class));
     * verify(hiddenHandler, times(2)).onHidden(any(HiddenEvent.class));
     * <p>
     * // call asWidget twice to invoke configure(String selector, String parent, boolean
     * toggle) trigger.asWidget();
     * <p>
     * // click to invoke changeVisibility(String target, String c)
     * Browser.click(triggerButton);
     * <p>
     * getBrowserSimulator().fireLoopEnd(); }
     * @Test public void testDropDown() { // onLoad GwtBootstrapModule module = new
     * GwtBootstrapModule(); module.onModuleLoad(); }
     **/
@Test
public void testModal() {
    Modal modal = new Modal();
    modal.add(new Label("Modal"));
    ModalFooter footer = new ModalFooter();
    footer.add(new Button("close"));
    modal.add(footer);
    modal.addShowHandler(showHandler);
    modal.addShownHandler(shownHandler);
    modal.addHideHandler(hideHandler);
    modal.addHiddenHandler(hiddenHandler);
    assertThat(modal.isVisible()).isFalse();
    modal.show();
    assertThat(modal.isVisible()).isTrue();
    verify(showHandler).onShow(any(ShowEvent.class));
    verify(shownHandler).onShown(any(ShownEvent.class));
    modal.hide();
    assertThat(modal.isVisible()).isFalse();
    verify(hideHandler).onHide(any(HideEvent.class));
    verify(hiddenHandler).onHidden(any(HiddenEvent.class));
    modal.toggle();
    assertThat(modal.isVisible()).isTrue();
    // for unsetHandlerFunctions
    modal.setDynamicSafe(true);
    modal.hide();
}
Also used : Label(com.google.gwt.user.client.ui.Label) Test(org.junit.Test)

Example 29 with Label

use of com.google.gwt.user.client.ui.Label in project gwt-test-utils by gwt-test-utils.

the class LabelTest method wrap.

@Test
public void wrap() {
    // Given
    // Element.setInnerHTML & Document.get().getElementById are supposed to
    // work
    Document.get().getBody().setInnerHTML("<div id=\"anId\"></div>");
    DivElement div = Document.get().getElementById("anId").cast();
    // When
    Label label = Label.wrap(div);
    label.setText("My wrapped label !");
    // Then
    assertThat(label.getElement()).isEqualTo(div);
    assertThat(div.getInnerText()).isEqualTo("My wrapped label !");
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) Label(com.google.gwt.user.client.ui.Label) Test(org.junit.Test)

Example 30 with Label

use of com.google.gwt.user.client.ui.Label in project gwt-test-utils by gwt-test-utils.

the class CompositeTest method beforeCompositeTest.

@Before
public void beforeCompositeTest() {
    label = new Label("wrapped label");
    composite = new MyComposite(label);
    RootPanel.get().add(composite);
    labelCount = 0;
    compositeCount = 0;
}
Also used : Label(com.google.gwt.user.client.ui.Label) Before(org.junit.Before)

Aggregations

Label (com.google.gwt.user.client.ui.Label)89 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)19 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)15 Test (org.junit.Test)11 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)10 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)9 TextBox (com.google.gwt.user.client.ui.TextBox)9 Image (com.google.gwt.user.client.ui.Image)8 CheckBox (com.google.gwt.user.client.ui.CheckBox)7 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)7 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)7 JsArrayString (com.google.gwt.core.client.JsArrayString)5 Element (com.google.gwt.dom.client.Element)5 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)5 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)5 Grid (com.google.gwt.user.client.ui.Grid)5 HTML (com.google.gwt.user.client.ui.HTML)4