Search in sources :

Example 1 with TableRowElement

use of com.google.gwt.dom.client.TableRowElement in project rstudio by rstudio.

the class FindOutputCodec method getRowForItem.

@Override
public TableRowElement getRowForItem(FindResult entry) {
    if (entry == null) {
        // Overflow message
        TableRowElement tr = Document.get().createTRElement();
        TableCellElement td = Document.get().createTDElement();
        td.setClassName(styles_.overflowWarning());
        td.setColSpan(2);
        td.setInnerText("More than 1000 matching lines were found. " + "Only the first 1000 lines are shown.");
        tr.appendChild(td);
        return tr;
    }
    TableRowElement tr = Document.get().createTRElement();
    tr.setAttribute(DATA_FILE, entry.getFile());
    tr.setAttribute(DATA_LINE, entry.getLine() + "");
    TableCellElement td1 = Document.get().createTDElement();
    td1.setClassName(styles_.line());
    td1.setInnerText(entry.getLine() + ": ");
    tr.appendChild(td1);
    TableCellElement td2 = Document.get().createTDElement();
    td2.setClassName(styles_.lineValue());
    td2.setInnerHTML(entry.getLineHTML().asString());
    tr.appendChild(td2);
    return tr;
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 2 with TableRowElement

use of com.google.gwt.dom.client.TableRowElement 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_);
}
Also used : TableSectionElement(com.google.gwt.dom.client.TableSectionElement) TableRowElement(com.google.gwt.dom.client.TableRowElement) TableCellElement(com.google.gwt.dom.client.TableCellElement) TableSectionElement(com.google.gwt.dom.client.TableSectionElement) TableRowElement(com.google.gwt.dom.client.TableRowElement) TableElement(com.google.gwt.dom.client.TableElement) Element(com.google.gwt.dom.client.Element) EventTarget(com.google.gwt.dom.client.EventTarget) TableCellElement(com.google.gwt.dom.client.TableCellElement) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 3 with TableRowElement

use of com.google.gwt.dom.client.TableRowElement in project rstudio by rstudio.

the class DirectoryContentsWidget method setSelectedRow.

public void setSelectedRow(Integer row) {
    if (selectedRow_ != null) {
        table_.getRowFormatter().removeStyleName(selectedRow_.intValue(), "gwt-MenuItem-selected");
        selectedRow_ = null;
        selectedValue_ = null;
    }
    if (row != null && row.intValue() >= 0 && row.intValue() < table_.getRowCount()) {
        selectedRow_ = row.intValue();
        table_.getRowFormatter().addStyleName(selectedRow_, "gwt-MenuItem-selected");
        selectedValue_ = table_.getText(row.intValue(), COL_NAME);
        TableRowElement rowEl = ((TableElement) table_.getElement().cast()).getRows().getItem(selectedRow_);
        int horizScroll = scrollPanel_.getHorizontalScrollPosition();
        rowEl.scrollIntoView();
        scrollPanel_.setHorizontalScrollPosition(horizScroll);
    }
    SelectionEvent.fire(DirectoryContentsWidget.this, getSelectedItem());
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) Point(org.rstudio.core.client.Point)

Example 4 with TableRowElement

use of com.google.gwt.dom.client.TableRowElement in project gerrit by GerritCodeReview.

the class CommitBox method setParents.

private void setParents(JsArray<CommitInfo> commits) {
    setVisible(firstParent, true);
    TableRowElement next = firstParent;
    TableRowElement previous = null;
    for (CommitInfo c : Natives.asList(commits)) {
        if (next == firstParent) {
            CopyableLabel copyLabel = getCommitLabel(c);
            parentCommits.add(copyLabel);
            setWebLinks(parentWebLinks, c);
        } else {
            next.appendChild(DOM.createTD());
            Element td1 = DOM.createTD();
            td1.appendChild(getCommitLabel(c).getElement());
            next.appendChild(td1);
            FlowPanel linksPanel = new FlowPanel();
            linksPanel.addStyleName(style.parentWebLink());
            setWebLinks(linksPanel, c);
            Element td2 = DOM.createTD();
            td2.appendChild(linksPanel.getElement());
            next.appendChild(td2);
            previous.getParentElement().insertAfter(next, previous);
        }
        previous = next;
        next = DOM.createTR().cast();
    }
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) TableRowElement(com.google.gwt.dom.client.TableRowElement) Element(com.google.gwt.dom.client.Element) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) CommitInfo(com.google.gerrit.client.info.ChangeInfo.CommitInfo) CopyableLabel(com.google.gwtexpui.clippy.client.CopyableLabel)

Example 5 with TableRowElement

use of com.google.gwt.dom.client.TableRowElement in project gerrit by GerritCodeReview.

the class IncludedInBox method appendRow.

private void appendRow(String title, JsArrayString l) {
    TableRowElement row = table.insertRow(-1);
    TableCellElement th = Document.get().createTHElement();
    th.setInnerText(title);
    row.appendChild(th);
    row.insertCell(-1).setInnerSafeHtml(formatList(l));
}
Also used : TableRowElement(com.google.gwt.dom.client.TableRowElement) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Aggregations

TableRowElement (com.google.gwt.dom.client.TableRowElement)11 TableCellElement (com.google.gwt.dom.client.TableCellElement)5 Element (com.google.gwt.dom.client.Element)2 TableElement (com.google.gwt.dom.client.TableElement)2 Point (org.rstudio.core.client.Point)2 CommitInfo (com.google.gerrit.client.info.ChangeInfo.CommitInfo)1 EventTarget (com.google.gwt.dom.client.EventTarget)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 TableSectionElement (com.google.gwt.dom.client.TableSectionElement)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 CopyableLabel (com.google.gwtexpui.clippy.client.CopyableLabel)1 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)1 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)1