use of com.extjs.gxt.ui.client.data.ListLoadResult 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.ListLoadResult 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.ListLoadResult 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.ListLoadResult 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;
}
use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.
the class NatConfigTab method initGrid.
private void initGrid() {
//
// Column Configuration
ColumnConfig column = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
column = new ColumnConfig("inInterface", MSGS.firewallNatInInterface(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("outInterface", MSGS.firewallNatOutInterface(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("protocol", MSGS.firewallNatProtocol(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("sourceNetwork", MSGS.firewallNatSourceNetwork(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("destinationNetwork", MSGS.firewallNatDestinationNetwork(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("masquerade", MSGS.firewallNatMasquerade(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
// rpc data proxy
RpcProxy<ListLoadResult<GwtFirewallNatEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallNatEntry>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallNatEntry>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtNetworkService.findDeviceFirewallNATs(token, callback);
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtFirewallNatEntry>>(proxy);
m_loader.setSortDir(SortDir.DESC);
m_loader.setSortField("inInterface");
SwappableListStore<GwtFirewallNatEntry> m_store = new SwappableListStore<GwtFirewallNatEntry>(m_loader);
m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallNatEntry>() {
public String getKey(GwtFirewallNatEntry firewallNatEntry) {
return firewallNatEntry.getInInterface();
}
});
m_grid = new Grid<GwtFirewallNatEntry>(m_store, new ColumnModel(configs));
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setAutoExpandColumn("inInterface");
m_grid.getView().setAutoFill(true);
m_loader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtFirewallNatEntry> selectionModel = new GridSelectionModel<GwtFirewallNatEntry>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallNatEntry>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtFirewallNatEntry> se) {
m_selectedEntry = se.getSelectedItem();
if (m_selectedEntry != null) {
m_editButton.setEnabled(true);
m_deleteButton.setEnabled(true);
} else {
m_editButton.setEnabled(false);
m_deleteButton.setEnabled(false);
}
}
});
}
Aggregations