use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class ModifyKeyboardShortcutsWidget method showToolTip.
private void showToolTip(Object object, String text) {
assert object instanceof Element;
Element el = (Element) object;
int index = StringUtil.parseInt(el.getAttribute("__rstudio_masked_index"), -1);
KeyboardShortcutEntry conflictBinding = originalBindings_.get(index);
Element divEl = DOM.createDiv();
Element spanEl = DOM.createSpan();
spanEl.setInnerHTML(text);
divEl.appendChild(spanEl);
String conflictDescription = describeCommand(conflictBinding);
// We use an anchor element here just to get browser default styling for
// anchor links; we take over the click behaviour to ensure that the normal
// 'href' navigation doesn't actually occur.
Element conflictEl = DOM.createAnchor();
conflictEl.setAttribute("href", "#");
conflictEl.setInnerHTML(conflictDescription);
divEl.appendChild(conflictEl);
MiniPopupPanel tooltip = new MiniPopupPanel(true);
bindNativeClickToSelectRow(conflictEl, tooltip.getElement(), index);
tooltip.getElement().appendChild(divEl);
tooltip.show();
PopupPositioner.setPopupPosition(tooltip, el.getAbsoluteRight(), el.getAbsoluteBottom(), 10);
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class MultiSelectCellTable method handleContextMenu.
// handle context-menu clicks. this implementation (specifically the
// detection of table rows from dom events) is based on the code in
// AbstractCellTable.onBrowserEvent2. we first determine if the click
// applies to a row in the table -- if it does then we squelch the
// standard handling of the event and update the selection and then
// forward the event on to any external listeners
private void handleContextMenu(ContextMenuEvent cmEvent) {
// bail if there are no context menu handlers
if (handlerManager_.getHandlerCount(ContextMenuEvent.getType()) == 0)
return;
// Get the event target.
NativeEvent event = cmEvent.getNativeEvent();
EventTarget eventTarget = event.getEventTarget();
if (!Element.is(eventTarget))
return;
final Element target = event.getEventTarget().cast();
// always squelch default handling (when there is a handler)
event.stopPropagation();
event.preventDefault();
// find the table cell element then get its parent and cast to row
TableCellElement tableCell = findNearestParentCell(target);
if (tableCell == null)
return;
Element trElem = tableCell.getParentElement();
if (trElem == null)
return;
TableRowElement tr = TableRowElement.as(trElem);
// get the section of the row and confirm it is a tbody (as opposed
// to a thead or tfoot)
Element sectionElem = tr.getParentElement();
if (sectionElem == null)
return;
TableSectionElement section = TableSectionElement.as(sectionElem);
if (section != getTableBodyElement())
return;
// determine the row/item target
int row = tr.getSectionRowIndex();
T item = getVisibleItem(row);
// if this row isn't already selected then clear the existing selection
if (!getSelectionModel().isSelected(item))
clearSelection();
// select the clicked on item
getSelectionModel().setSelected(item, true);
// forward the event
DomEvent.fireNativeEvent(event, handlerManager_);
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class MiniPopupPanel method addDragHandler.
private void addDragHandler() {
if (dragHandler_ != null)
dragHandler_.removeHandler();
dragHandler_ = Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent npe) {
if (npe.getNativeEvent().getButton() != NativeEvent.BUTTON_LEFT)
return;
int type = npe.getTypeInt();
if (type == Event.ONMOUSEDOWN || type == Event.ONMOUSEMOVE || type == Event.ONMOUSEUP) {
if (dragging_) {
handleDrag(npe);
return;
}
Element target = npe.getNativeEvent().getEventTarget().cast();
String tagName = target.getTagName().toLowerCase();
for (String tag : TAGS_EXCLUDE_DRAG) if (tagName.equals(tag))
return;
if (DomUtils.isDescendantOfElementWithTag(target, TAGS_EXCLUDE_DRAG))
return;
Element self = MiniPopupPanel.this.getElement();
if (!DomUtils.isDescendant(target, self))
return;
handleDrag(npe);
}
}
});
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class GlassAttacher method createGlassWidget.
private static Widget createGlassWidget() {
HTML glass = new HTML();
glass.setSize("100%", "100%");
Element glassElem = glass.getElement();
glassElem.getStyle().setBackgroundColor("white");
glassElem.getStyle().setProperty("opacity", "0.0");
glassElem.getStyle().setProperty("filter", "alpha(opacity=0)");
return glass;
}
use of com.google.gwt.dom.client.Element in project rstudio by rstudio.
the class ChunkSatelliteWindow method onInitialize.
@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
chunkWindowParams_ = params.cast();
String title = "RStudio: Notebook Output";
Window.setTitle(title);
ChunkOutputHost chunkOutputHost = new ChunkOutputHost() {
@Override
public void onOutputRemoved(final ChunkOutputWidget widget) {
}
@Override
public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
}
};
chunkOutputWidget_ = new ChunkOutputWidget(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, // can close
false, chunkOutputHost, ChunkOutputSize.Full);
Element ele = chunkOutputWidget_.getElement();
ele.addClassName(ThemeStyles.INSTANCE.selectableText());
// Append the chunkOutputWidget as an HTML element, not as a widget.
// Why? Chunks are widgets that are attached to the ACE editor as HTML
// elements, not as widgets. The reason being that GWT does not support
// triggering events for widgets that are not attached to their hierarchy.
// Therefore, if we attach this element as a widget, GWT will remove
// events in some cases which will cause functionality to be lost.
mainPanel.getElement().appendChild(chunkOutputWidget_.getElement());
chunkOutputWidget_.getElement().getStyle().setHeight(100, Unit.PCT);
mainPanel.addStyleName("ace_editor");
pEventBus_.get().addHandler(ChunkSatelliteCodeExecutingEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkSatelliteCacheEditorStyleEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkPlotRefreshedEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkPlotRefreshFinishedEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkChangeEvent.TYPE, this);
pEventBus_.get().addHandler(RmdChunkOutputFinishedEvent.TYPE, this);
pEventBus_.get().addHandler(RmdChunkOutputEvent.TYPE, this);
Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent arg0) {
server_.cleanReplayNotebookChunkPlots(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), new ServerRequestCallback<Void>() {
@Override
public void onError(ServerError error) {
}
});
}
});
pEventBus_.get().fireEventToMainWindow(new ChunkSatelliteWindowOpenedEvent(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId()));
}
Aggregations