Search in sources :

Example 1 with RpcObjectList

use of org.rstudio.core.client.jsonrpc.RpcObjectList in project rstudio by rstudio.

the class History method onHistoryShowContext.

@Handler
void onHistoryShowContext() {
    ArrayList<Long> indexes = view_.getSelectedCommandIndexes();
    if (indexes.size() != 1)
        return;
    final String command = view_.getSelectedCommands().get(0);
    final Long min = indexes.get(0);
    final long max = indexes.get(indexes.size() - 1) + 1;
    final long start = Math.max(0, min - CONTEXT_LINES);
    final long end = max + CONTEXT_LINES;
    server_.getHistoryArchiveItems(start, end, new SimpleRequestCallback<RpcObjectList<HistoryEntry>>() {

        @Override
        public void onResponseReceived(RpcObjectList<HistoryEntry> response) {
            ArrayList<HistoryEntry> entries = toList(response);
            view_.showContext(command, entries, min - start, max - min);
        }
    });
}
Also used : RpcObjectList(org.rstudio.core.client.jsonrpc.RpcObjectList) ArrayList(java.util.ArrayList) HistoryEntry(org.rstudio.studio.client.workbench.views.history.model.HistoryEntry) JsArrayString(com.google.gwt.core.client.JsArrayString) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 2 with RpcObjectList

use of org.rstudio.core.client.jsonrpc.RpcObjectList in project rstudio by rstudio.

the class HistoryAsyncDataProvider method onRangeChanged.

@Override
public void onRangeChanged(final HasData<CommitInfo> display) {
    final Range rng = display.getVisibleRange();
    final int start = rng.getStart();
    final int length = rng.getLength();
    if (length == 0)
        return;
    getHistory(rev_, fileFilter_.getValue(), start, length, searchText_.getValue(), new SimpleRequestCallback<RpcObjectList<CommitInfo>>("Error Fetching History") {

        @Override
        public void onResponseReceived(RpcObjectList<CommitInfo> response) {
            super.onResponseReceived(response);
            if (response.length() < length)
                updateRowCount(start + response.length(), true);
            updateRowData(start, response.toArrayList());
        }

        @Override
        public void onError(ServerError error) {
            if (display instanceof AbstractHasData) {
                display.setVisibleRangeAndClearData(new Range(start, 0), true);
            }
            if (strategy_.getShowHistoryErrors())
                super.onError(error);
            else
                Debug.logError(error);
        }
    });
}
Also used : RpcObjectList(org.rstudio.core.client.jsonrpc.RpcObjectList) ServerError(org.rstudio.studio.client.server.ServerError) Range(com.google.gwt.view.client.Range) AbstractHasData(com.google.gwt.user.cellview.client.AbstractHasData)

Aggregations

RpcObjectList (org.rstudio.core.client.jsonrpc.RpcObjectList)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 AbstractHasData (com.google.gwt.user.cellview.client.AbstractHasData)1 Range (com.google.gwt.view.client.Range)1 ArrayList (java.util.ArrayList)1 Handler (org.rstudio.core.client.command.Handler)1 SelectionCommitHandler (org.rstudio.core.client.events.SelectionCommitHandler)1 ServerError (org.rstudio.studio.client.server.ServerError)1 ConsoleResetHistoryHandler (org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler)1 FetchCommandsHandler (org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler)1 HistoryEntriesAddedHandler (org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler)1 HistoryEntry (org.rstudio.studio.client.workbench.views.history.model.HistoryEntry)1