Search in sources :

Example 1 with TabReorderEvent

use of org.rstudio.core.client.events.TabReorderEvent in project rstudio by rstudio.

the class DocTabLayoutPanel method moveTab.

public void moveTab(int index, int delta) {
    // do no work if we haven't been asked to move anywhere
    if (delta == 0)
        return;
    Element tabHost = getTabBarElement();
    // ignore moving left if the tab is already the leftmost tab (same for
    // right)
    int dest = index + delta;
    if (dest < 0 || dest >= tabHost.getChildCount())
        return;
    // rearrange the DOM 
    Element tab = Element.as(tabHost.getChild(index));
    Element prev = Element.as(tabHost.getChild(dest));
    tabHost.removeChild(tab);
    if (delta > 0)
        tabHost.insertAfter(tab, prev);
    else
        tabHost.insertBefore(tab, prev);
    // fire the tab reorder event (this syncs the editor state)
    TabReorderEvent event = new TabReorderEvent(index, dest);
    fireEvent(event);
}
Also used : Element(com.google.gwt.dom.client.Element) Point(org.rstudio.core.client.Point) TabReorderEvent(org.rstudio.core.client.events.TabReorderEvent)

Aggregations

Element (com.google.gwt.dom.client.Element)1 Point (org.rstudio.core.client.Point)1 TabReorderEvent (org.rstudio.core.client.events.TabReorderEvent)1