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)));
}
}
});
}
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;
}
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();
}
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 !");
}
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;
}
Aggregations