use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.
the class BundlesTab method initBundles.
private void initBundles() {
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtDeviceService.findBundles(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
callback.onSuccess(pairs);
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_loader.addLoadListener(new DataLoadListener());
m_store = new ListStore<GwtGroupedNVPair>(m_loader);
ColumnConfig id = new ColumnConfig("id", MSGS.deviceBndId(), 10);
ColumnConfig name = new ColumnConfig("name", MSGS.deviceBndName(), 50);
ColumnConfig status = new ColumnConfig("statusLoc", MSGS.deviceBndState(), 20);
ColumnConfig version = new ColumnConfig("version", MSGS.deviceBndVersion(), 20);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(id);
config.add(name);
config.add(status);
config.add(version);
ColumnModel cm = new ColumnModel(config);
GridView view = new GridView();
view.setForceFit(true);
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
GridSelectionModel<GwtGroupedNVPair> selectionModel = new GridSelectionModel<GwtGroupedNVPair>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtGroupedNVPair>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtGroupedNVPair> se) {
GwtGroupedNVPair selectedEntry = se.getSelectedItem();
if (selectedEntry != null) {
if ("bndActive".equals(selectedEntry.getStatus())) {
m_startButton.disable();
m_stopButton.enable();
} else {
m_stopButton.disable();
m_startButton.enable();
}
} else {
m_startButton.setEnabled(false);
m_stopButton.setEnabled(false);
}
}
});
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.
the class StatusPanel method initStatusPanel.
private void initStatusPanel() {
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
mask(MSGS.loading());
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtStatusService.getDeviceConfig(token, m_currentSession.isNetAdminAvailable(), new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onFailure(Throwable caught) {
unmask();
FailureHandler.handle(caught);
}
public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
List<GwtGroupedNVPair> results = pairs.getData();
for (GwtGroupedNVPair result : results) {
if ("Connection Status".equals(result.getName())) {
if ("CONNECTED".equals(result.getValue())) {
m_connectDataServiceButton.disable();
m_disconnectDataServiceButton.enable();
} else {
m_connectDataServiceButton.enable();
m_disconnectDataServiceButton.disable();
}
}
}
unmask();
callback.onSuccess(pairs);
}
});
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
m_store.groupBy("groupLoc");
m_store.setStoreSorter(new StoreSorter<GwtGroupedNVPair>(new Comparator<Object>() {
public int compare(Object o1, Object o2) {
if (o1 == null)
o1 = new Integer(-1);
else
o1 = getIntFromString((String) o1);
if (o2 == null)
o2 = new Integer(-1);
else
o2 = getIntFromString((String) o2);
return (Integer) o1 - (Integer) o2;
}
private Integer getIntFromString(String value) {
if ("Cloud and Data Service".equals(value))
return new Integer(0);
else if ("Ethernet Settings".equals(value))
return new Integer(1);
else if ("Wireless Settings".equals(value))
return new Integer(2);
else if ("Cellular Settings".equals(value))
return new Integer(3);
else if ("Position Status".equals(value))
return new Integer(4);
else
return new Integer(100);
}
}));
ColumnConfig name = new ColumnConfig("name", MSGS.devicePropName(), 50);
ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 50);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(name);
config.add(value);
ColumnModel cm = new ColumnModel(config);
GroupingView view = new GroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(true);
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setHideHeaders(true);
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.
the class NetworkInterfacesTable method initGrid.
private void initGrid() {
//
// Column Configuration
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("name", MSGS.netInterfaceName(), 125);
column.setAlignment(HorizontalAlignment.LEFT);
column.setSortable(false);
configs.add(column);
// loader and store
RpcProxy<ListLoadResult<GwtNetInterfaceConfig>> proxy = new RpcProxy<ListLoadResult<GwtNetInterfaceConfig>>() {
@Override
public void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtNetInterfaceConfig>> callback) {
gwtNetworkService.findNetInterfaceConfigurations(callback);
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtNetInterfaceConfig>>(proxy);
m_loader.setRemoteSort(false);
m_loader.setSortDir(SortDir.ASC);
m_loader.setSortField("name");
m_store = new ListStore<GwtNetInterfaceConfig>(m_loader);
m_store.setStoreSorter(new StoreSorter<GwtNetInterfaceConfig>(new Comparator<Object>() {
public int compare(Object o1, Object o2) {
if (o1 == null) {
o1 = new Integer(-1);
} else {
o1 = getIntFromName((String) o1);
}
if (o2 == null) {
o2 = new Integer(-1);
} else {
o2 = getIntFromName((String) o2);
}
return (Integer) o1 - (Integer) o2;
}
private Integer getIntFromName(String name) {
if ("lo".equals(name))
return new Integer(1);
else if ("eth0".equals(name))
return new Integer(2);
else if ("eth1".equals(name))
return new Integer(3);
else if (name.contains("eth"))
return new Integer(4);
else if ("wlan0".equals(name))
return new Integer(10);
else if ("ppp0".equals(name))
return new Integer(20);
else if (name.contains("ppp"))
return new Integer(21);
else
return new Integer(100);
}
}));
m_grid = new Grid<GwtNetInterfaceConfig>(m_store, new ColumnModel(configs));
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setAutoExpandColumn("name");
m_grid.getView().setAutoFill(true);
m_grid.getView().setEmptyText(MSGS.netTableNoInterfaces());
GridSelectionModel<GwtNetInterfaceConfig> selectionModel = new GridSelectionModel<GwtNetInterfaceConfig>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
//
// on selection, complete the switch
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtNetInterfaceConfig>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtNetInterfaceConfig> se) {
GwtNetInterfaceConfig gwtNetIfConfig = se.getSelectedItem();
if (gwtNetIfConfig != null) {
m_selectedIfConfig = gwtNetIfConfig;
m_netConfigTabs.setNetInterface(gwtNetIfConfig);
}
}
});
m_loader.addLoadListener(new DataLoadListener(m_netConfigTabs, m_grid));
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.
the class ProfileTab method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setBorders(false);
setId("device-profile");
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtDeviceService.findDeviceConfiguration(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
callback.onSuccess(pairs);
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
m_store.groupBy("groupLoc");
ColumnConfig name = new ColumnConfig("nameLoc", MSGS.devicePropName(), 50);
ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 50);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(name);
config.add(value);
ColumnModel cm = new ColumnModel(config);
GroupingView view = new GroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(true);
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
add(m_grid);
m_initialized = true;
}
use of com.extjs.gxt.ui.client.data.RpcProxy in project kura by eclipse.
the class SystemPropertiesTab method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setId("device-system-properties");
RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtDeviceService.findSystemProperties(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {
public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
callback.onSuccess(pairs);
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
m_store.groupBy("groupLoc");
ColumnConfig name = new ColumnConfig("name", MSGS.devicePropName(), 50);
ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 50);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(name);
config.add(value);
ColumnModel cm = new ColumnModel(config);
GroupingView view = new GroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(true);
m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
m_grid.setView(view);
m_grid.setBorders(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
add(m_grid);
m_initialized = true;
}
Aggregations