use of com.google.gwt.user.client.ui.PopupPanel in project gwt-test-utils by gwt-test-utils.
the class PopupPanelTest method show.
@Test
public void show() {
// Given
PopupPanel popup = new PopupPanel();
// Preconditions
assertThat(popup.isVisible()).isTrue();
assertThat(popup.isShowing()).isFalse();
// When
popup.show();
// Then
assertThat(popup.isShowing()).isTrue();
}
use of com.google.gwt.user.client.ui.PopupPanel in project rstudio by rstudio.
the class ToolbarButton method addMenuHandlers.
private void addMenuHandlers(final ToolbarPopupMenu popupMenu, final boolean rightAlign) {
menu_ = popupMenu;
/*
* We want clicks on this button to toggle the visibility of the menu,
* as well as having the menu auto-hide itself as it normally does.
* It's necessary to manually track the visibility (menuShowing) because
* in the case where the menu is showing, clicking on this button first
* causes the menu to auto-hide and then our mouseDown handler is called
* (so we can't rely on menu.isShowing(), it'll always be false by the
* time you get into the mousedown handler).
*/
final boolean[] menuShowing = new boolean[1];
addMouseDownHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
event.preventDefault();
event.stopPropagation();
addStyleName(styles_.toolbarButtonPushed());
// Some menus are rebuilt on every invocation. Ask the menu for
// the most up-to-date version before proceeding.
popupMenu.getDynamicPopupMenu(new ToolbarPopupMenu.DynamicPopupMenuCallback() {
@Override
public void onPopupMenu(final ToolbarPopupMenu menu) {
if (menuShowing[0]) {
removeStyleName(styles_.toolbarButtonPushed());
menu.hide();
} else {
if (rightAlign) {
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
menu.setPopupPosition((rightImageWidget_ != null ? rightImageWidget_.getAbsoluteLeft() : leftImageWidget_.getAbsoluteLeft()) + 20 - offsetWidth, ToolbarButton.this.getAbsoluteTop() + ToolbarButton.this.getOffsetHeight());
}
});
} else {
menu.showRelativeTo(ToolbarButton.this);
}
menuShowing[0] = true;
}
}
});
}
});
popupMenu.addCloseHandler(new CloseHandler<PopupPanel>() {
public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
removeStyleName(styles_.toolbarButtonPushed());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
menuShowing[0] = false;
}
});
}
});
}
use of com.google.gwt.user.client.ui.PopupPanel in project rstudio by rstudio.
the class SupportPopupMenu method addMenuItem.
private void addMenuItem(FlexTable supportTable, String caption, final String email, final GlobalDisplay globalDisplay) {
// maintain reference to containing class for closing
final PopupPanel popupPanel = this;
// create a hyperlink label for this URL
HyperlinkLabel link = new HyperlinkLabel(caption, new ClickHandler() {
public void onClick(ClickEvent event) {
globalDisplay.openEmailComposeWindow(email, null);
popupPanel.hide();
}
});
int row = supportTable.getRowCount();
supportTable.setWidget(row, 0, link);
}
use of com.google.gwt.user.client.ui.PopupPanel in project rstudio by rstudio.
the class EditingTargetInlineChunkExecution method execute.
public void execute(Range range) {
// synthesize an identifier for this chunk execution
final String chunkId = "i" + StringUtil.makeRandomId(12);
// are, remove it to make way for the new one
for (ChunkInlineOutput output : outputs_.values()) {
if (output.range().isEqualTo(range)) {
if (output.state() == ChunkInlineOutput.State.Finished) {
// remove old, completed output for this input
output.hide();
outputs_.remove(output.chunkId());
} else {
// unintended duplicate.
return;
}
}
}
// create dummy scope for execution
Scope scope = Scope.createRScopeNode(chunkId, range.getStart(), range.getEnd(), Scope.SCOPE_TYPE_CHUNK);
// create popup panel to host output
final ChunkInlineOutput output = new ChunkInlineOutput(chunkId, display_.createAnchoredSelection(range.getStart(), range.getEnd()));
// auto dismiss the panel when the cursor leaves the inline chunk
final Mutable<HandlerRegistration> cursorHandler = new Mutable<HandlerRegistration>();
cursorHandler.set(display_.addCursorChangedHandler(new CursorChangedHandler() {
@Override
public void onCursorChanged(CursorChangedEvent event) {
Position position = event.getPosition();
if (!output.range().contains(position)) {
output.hide();
}
}
}));
// when the popup is dismissed, clean up local state
output.addCloseHandler(new CloseHandler<PopupPanel>() {
@Override
public void onClose(CloseEvent<PopupPanel> event) {
outputs_.remove(chunkId);
cursorHandler.get().removeHandler();
}
});
// render offscreen until complete
output.setPopupPosition(-100000, -100000);
output.show();
outputs_.put(chunkId, output);
SendToChunkConsoleEvent event = new SendToChunkConsoleEvent(docId_, scope, range, NotebookQueueUnit.EXEC_SCOPE_INLINE);
events_.fireEvent(event);
}
use of com.google.gwt.user.client.ui.PopupPanel in project gerrit by GerritCodeReview.
the class CherryPickAction method call.
static void call(final Button b, final ChangeInfo info, final String revision, String project, final String commitMessage) {
// TODO Replace CherryPickDialog with a nicer looking display.
b.setEnabled(false);
new CherryPickDialog(new Project.NameKey(project)) {
{
sendButton.setText(Util.C.buttonCherryPickChangeSend());
if (info.status() == Change.Status.MERGED) {
message.setText(Util.M.cherryPickedChangeDefaultMessage(commitMessage.trim(), revision));
} else {
message.setText(commitMessage.trim());
}
}
@Override
public void onSend() {
ChangeApi.cherrypick(info.legacyId().get(), revision, getDestinationBranch(), getMessageText(), new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) {
sent = true;
hide();
Gerrit.display(PageLinks.toChange(result.legacyId()));
}
@Override
public void onFailure(Throwable caught) {
enableButtons(true);
super.onFailure(caught);
}
});
}
@Override
public void onClose(CloseEvent<PopupPanel> event) {
super.onClose(event);
b.setEnabled(true);
}
}.center();
}
Aggregations