use of org.eclipse.kura.web.client.util.SwappableListStore in project kura by eclipse.
the class WirelessConfigTab method createWifiNetworksWindow.
private Window createWifiNetworksWindow() {
final Window window = new Window();
window.setSize(700, 400);
window.setPlain(true);
window.setModal(true);
window.setBlinkModal(true);
window.setHeading("Wireless Networks");
// Create a table to layout the content
VerticalPanel dialogContents = new VerticalPanel();
dialogContents.setSpacing(4);
window.add(dialogContents);
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = null;
column = new ColumnConfig("ssid", "SSID", 100);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);
column = new ColumnConfig("macAddress", "MAC Address", 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("signalStrength", "Signal (dBm)", 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("channel", "Channel", 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("frequency", "Frequency", 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("security", "Security", 100);
column.setAlignment(HorizontalAlignment.LEFT);
configs.add(column);
/*
CheckColumnConfig checkColumn = new CheckColumnConfig("selectAP", "Select", 55);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkColumn.setEditor(checkBoxEditor);
configs.add(checkColumn);
*/
// rpc data proxy
RpcProxy<ListLoadResult<GwtWifiHotspotEntry>> proxy = new RpcProxy<ListLoadResult<GwtWifiHotspotEntry>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtWifiHotspotEntry>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtNetworkService.findWifiHotspots(token, m_selectNetIfConfig.getName(), callback);
}
});
}
};
m_wifiHotspotLoader = new BaseListLoader<ListLoadResult<GwtWifiHotspotEntry>>(proxy);
m_wifiHotspotLoader.setSortDir(SortDir.ASC);
m_wifiHotspotLoader.setSortField("signalStrength");
// m_wifiHotspotLoader.setRemoteSort(true);
SwappableListStore<GwtWifiHotspotEntry> store = new SwappableListStore<GwtWifiHotspotEntry>(m_wifiHotspotLoader);
store.setKeyProvider(new ModelKeyProvider<GwtWifiHotspotEntry>() {
public String getKey(GwtWifiHotspotEntry wifiHotspotEntry) {
return wifiHotspotEntry.getSignalStrength().toString();
}
});
m_grid = new Grid<GwtWifiHotspotEntry>(store, new ColumnModel(configs));
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setColumnLines(true);
m_grid.setColumnReordering(true);
m_grid.setAutoExpandColumn("ssid");
m_grid.getView().setAutoFill(true);
// m_grid.addPlugin(checkColumn);
m_wifiHotspotLoader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtWifiHotspotEntry> selectionModel = new GridSelectionModel<GwtWifiHotspotEntry>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
// m_grid.addPlugin(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtWifiHotspotEntry>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtWifiHotspotEntry> se) {
if (se != null) {
List<GwtWifiHotspotEntry> list = se.getSelection();
if ((list != null) && (list.size() > 0)) {
GwtWifiHotspotEntry wifiHotspotEntry = list.get(0);
if (wifiHotspotEntry != null) {
m_ssidField.setValue(GwtSafeHtmlUtils.htmlUnescape(wifiHotspotEntry.getSSID()));
String security = wifiHotspotEntry.getSecurity();
if (security.equals("None")) {
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityNONE.name()));
} else if (security.equals("WEP")) {
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWEP.name()));
} else if (security.equals("WPA")) {
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA.name()));
} else if (security.equals("WPA2") || security.equals("WPA/WPA2")) {
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()));
} else {
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityNONE.name()));
}
if (security.equals("WPA") || security.equals("WPA2") || security.equals("WPA/WPA2")) {
GwtWifiCiphers pairwiseCiphers = wifiHotspotEntry.getPairwiseCiphersEnum();
if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_TKIP) {
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_TKIP.name()));
} else if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_CCMP) {
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP.name()));
} else if (pairwiseCiphers == GwtWifiCiphers.netWifiCiphers_CCMP_TKIP) {
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
} else {
// let's set it for CCMP TKIP
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
}
GwtWifiCiphers groupCiphers = wifiHotspotEntry.getGroupCiphersEnum();
if (groupCiphers == GwtWifiCiphers.netWifiCiphers_TKIP) {
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_TKIP.name()));
} else if (groupCiphers == GwtWifiCiphers.netWifiCiphers_CCMP) {
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP.name()));
} else if (groupCiphers == GwtWifiCiphers.netWifiCiphers_CCMP_TKIP) {
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
} else {
// let's set it for CCMP TKIP
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
}
}
// deselect all channels
for (int channel = 1; channel <= MAX_WIFI_CHANNEL; channel++) {
m_checkboxChannelSelectionModel.deselect(channel - 1);
}
// select proper channels
m_checkboxChannelSelectionModel.select(wifiHotspotEntry.getChannel() - 1, true);
window.hide();
}
}
}
}
});
ContentPanel cp = new ContentPanel();
cp.setHeading("Wireless Networks in Range");
cp.setFrame(true);
cp.setSize(680, 365);
FillLayout layout = new FillLayout();
layout.setAdjustForScroll(true);
cp.setLayout(layout);
cp.add(m_grid);
dialogContents.add(cp);
window.add(dialogContents);
return window;
}
use of org.eclipse.kura.web.client.util.SwappableListStore 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);
}
}
});
}
use of org.eclipse.kura.web.client.util.SwappableListStore in project kura by eclipse.
the class PortForwardingConfigTab method initGrid.
private void initGrid() {
//
// Column Configuration
ColumnConfig column = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
column = new ColumnConfig("inboundInterface", MSGS.firewallPortForwardInboundInterface(), 80);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("outboundInterface", MSGS.firewallPortForwardOutboundInterface(), 80);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("address", MSGS.firewallPortForwardAddress(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("protocol", MSGS.firewallPortForwardProtocol(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("inPort", MSGS.firewallPortForwardInPort(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("outPort", MSGS.firewallPortForwardOutPort(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("masquerade", MSGS.firewallPortForwardMasquerade(), 60);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("permittedNetwork", MSGS.firewallPortForwardPermittedNetwork(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("permittedMAC", MSGS.firewallPortForwardPermittedMac(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("sourcePortRange", MSGS.firewallPortForwardSourcePortRange(), 120);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
// rpc data proxy
RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallPortForwardEntry>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtNetworkService.findDeviceFirewallPortForwards(token, callback);
}
});
}
};
m_loader = new BaseListLoader<ListLoadResult<GwtFirewallPortForwardEntry>>(proxy);
m_loader.setSortDir(SortDir.DESC);
m_loader.setSortField("inPort");
m_loader.setRemoteSort(true);
SwappableListStore<GwtFirewallPortForwardEntry> m_store = new SwappableListStore<GwtFirewallPortForwardEntry>(m_loader);
m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallPortForwardEntry>() {
public String getKey(GwtFirewallPortForwardEntry portForwardEntry) {
return portForwardEntry.getInPort().toString();
}
});
m_grid = new Grid<GwtFirewallPortForwardEntry>(m_store, new ColumnModel(configs));
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setAutoExpandColumn("inPort");
m_grid.getView().setAutoFill(true);
// m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
m_loader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtFirewallPortForwardEntry> selectionModel = new GridSelectionModel<GwtFirewallPortForwardEntry>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallPortForwardEntry>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtFirewallPortForwardEntry> 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);
}
}
});
}
use of org.eclipse.kura.web.client.util.SwappableListStore in project kura by eclipse.
the class OpenPortsConfigTab method initOpenPortsGrid.
private void initOpenPortsGrid() {
//
// Column Configuration
ColumnConfig column = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
column = new ColumnConfig("portRange", MSGS.firewallOpenPort(), 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("protocol", MSGS.firewallOpenPortProtocol(), 100);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("permittedNetwork", MSGS.firewallOpenPortPermittedNetwork(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("permittedInterfaceName", MSGS.firewallOpenPortPermittedInterfaceName(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("unpermittedInterfaceName", MSGS.firewallOpenPortUnpermittedInterfaceName(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("permittedMAC", MSGS.firewallOpenPortPermittedMac(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
column = new ColumnConfig("sourcePortRange", MSGS.firewallOpenPortSourcePortRange(), 130);
column.setAlignment(HorizontalAlignment.CENTER);
configs.add(column);
// rpc data proxy
RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>>() {
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallOpenPortEntry>> callback) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtNetworkService.findDeviceFirewallOpenPorts(token, callback);
}
});
}
};
m_openPortsLoader = new BaseListLoader<ListLoadResult<GwtFirewallOpenPortEntry>>(proxy);
m_openPortsLoader.setSortDir(SortDir.DESC);
m_openPortsLoader.setSortField("port");
m_openPortsLoader.setRemoteSort(true);
SwappableListStore<GwtFirewallOpenPortEntry> m_store = new SwappableListStore<GwtFirewallOpenPortEntry>(m_openPortsLoader);
m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallOpenPortEntry>() {
public String getKey(GwtFirewallOpenPortEntry openPortEntry) {
return openPortEntry.getPortRange();
}
});
m_grid = new Grid<GwtFirewallOpenPortEntry>(m_store, new ColumnModel(configs));
m_grid.setBorders(false);
m_grid.setStateful(false);
m_grid.setLoadMask(true);
m_grid.setStripeRows(true);
m_grid.setAutoExpandColumn("portRange");
m_grid.getView().setAutoFill(true);
// m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
m_openPortsLoader.addLoadListener(new DataLoadListener(m_grid));
GridSelectionModel<GwtFirewallOpenPortEntry> selectionModel = new GridSelectionModel<GwtFirewallOpenPortEntry>();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
m_grid.setSelectionModel(selectionModel);
m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallOpenPortEntry>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtFirewallOpenPortEntry> 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