summaryrefslogtreecommitdiff
path: root/frontend/client/src/autotest/planner/test/TestViewPresenter.java
blob: d92220d19a23736784e9c24ec4e826a533a86c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package autotest.planner.test;

import autotest.common.JsonRpcCallback;
import autotest.common.JsonRpcProxy;
import autotest.planner.TestPlannerPresenter;
import autotest.planner.TestPlannerTableDisplay;

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;

public class TestViewPresenter extends TestPlannerPresenter {

    public static interface Display {
        public void setLoading(boolean loading);
        public void clearAllData();
        public TestPlannerTableDisplay generateTestViewTableDisplay();
    }

    private Display display;

    public void bindDisplay(Display display) {
        this.display = display;
    }

    @Override
    public void refresh(String planId) {
        display.setLoading(true);

        JSONObject params = new JSONObject();
        params.put("plan_id", new JSONString(planId));

        JsonRpcProxy.getProxy().rpcCall("get_test_view_data", params, new JsonRpcCallback() {
            @Override
            public void onSuccess(JSONValue result) {
                display.clearAllData();
                display.setLoading(false);

                TestViewTable table = new TestViewTable();
                table.bindDisplay(display.generateTestViewTableDisplay());
                table.setData(result.isObject());
            }

            @Override
            public void onError(JSONObject errorObject) {
                super.onError(errorObject);
                display.setLoading(false);
            }
        });
    }

}