aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/client/view/StateView.java
blob: 700d55a62e33353cd662ded20ea8f2661e0a7627 (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
53
54
55
56
57
58
package org.traccar.web.client.view;

import java.util.LinkedList;
import java.util.List;

import org.traccar.web.client.model.StateItem;
import org.traccar.web.client.model.StateItemProperties;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;

public class StateView {

    private static StateViewUiBinder uiBinder = GWT.create(StateViewUiBinder.class);

    interface StateViewUiBinder extends UiBinder<Widget, StateView> {
    }

    @UiField
    ContentPanel contentPanel;

    public ContentPanel getView() {
        return contentPanel;
    }

    @UiField(provided = true)
    ColumnModel<StateItem> columnModel;

    @UiField(provided = true)
    ListStore<StateItem> stateStore;

    @UiField
    Grid<StateItem> grid;

    public StateView(ListStore<StateItem> stateStore) {
        this.stateStore = stateStore;

        StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class);

        List<ColumnConfig<StateItem, ?>> columnConfigList = new LinkedList<ColumnConfig<StateItem, ?>>();
        columnConfigList.add(new ColumnConfig<StateItem, String>(stateItemProperties.name(), 0, "Attribute"));
        columnConfigList.add(new ColumnConfig<StateItem, String>(stateItemProperties.value(), 0, "Value"));
        columnModel = new ColumnModel<StateItem>(columnConfigList);

        uiBinder.createAndBindUi(this);

        grid.getSelectionModel().setLocked(true);
    }

}