use of com.extjs.gxt.ui.client.store.GroupingStore in project kura by eclipse.
the class WirelessConfigTab method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setId("network-wireless");
FormData formData = new FormData();
formData.setWidth(250);
m_formPanel = new FormPanel();
m_formPanel.setFrame(false);
m_formPanel.setBodyBorder(false);
m_formPanel.setHeaderVisible(false);
m_formPanel.setLayout(new FlowLayout());
m_formPanel.setStyleAttribute("min-width", "775px");
m_formPanel.setStyleAttribute("padding-left", "30px");
FieldSet fieldSet = new FieldSet();
FormLayout layoutAccount = new FormLayout();
layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
fieldSet.setLayout(layoutAccount);
fieldSet.setBorders(false);
//
// Tool Tip Box
//
toolTipField.setText(defaultToolTip);
fieldSet.add(toolTipField);
//
// Wireless Mode
//
m_wirelessModeListStore = new ListStore<GwtWifiWirelessModeModel>();
/*
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeDisabled,
MessageUtils.get("netWifiWirelessModeDisabled"),
MSGS.netWifiToolTipWirelessModeDisabled()));
*/
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeStation, MessageUtils.get("netWifiWirelessModeStation"), MSGS.netWifiToolTipWirelessModeStation()));
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint, MessageUtils.get("netWifiWirelessModeAccessPoint"), MSGS.netWifiToolTipWirelessModeAccessPoint()));
/*
m_wirelessModeListStore.add(new GwtWifiWirelessModeModel(GwtWifiWirelessMode.netWifiWirelessModeAdHoc,
MessageUtils.get("netWifiWirelessModeAdHoc"),
MSGS.netWifiToolTipWirelessModeAdhoc()));
*/
m_modeCombo = new ComboBox<GwtWifiWirelessModeModel>();
m_modeCombo.setName("comboMode");
m_modeCombo.setDisplayField(GwtWifiWirelessModeModel.NAME);
m_modeCombo.setFieldLabel(MSGS.netWifiWirelessMode());
m_modeCombo.setEditable(false);
m_modeCombo.setTypeAhead(true);
m_modeCombo.setTriggerAction(TriggerAction.ALL);
m_modeCombo.addStyleName("kura-combobox");
m_modeCombo.setStore(m_wirelessModeListStore);
m_modeCombo.setTemplate(getTemplate());
m_modeCombo.setValue(m_wirelessModeListStore.findModel(GwtWifiWirelessModeModel.MODE, GwtWifiWirelessMode.netWifiWirelessModeStation.name()));
m_modeCombo.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
if (m_tcpIpConfigTab.getStatus().equals(GwtNetIfStatus.netIPv4StatusEnabledWAN) && value.equals(MessageUtils.get(GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.name()))) {
return MSGS.netWifiWirelessEnabledForWANError();
}
return null;
}
});
m_modeCombo.addSelectionChangedListener(new SelectionChangedListener<GwtWifiWirelessModeModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtWifiWirelessModeModel> se) {
// Station mode selected
if (GwtWifiWirelessMode.netWifiWirelessModeStation.equals(se.getSelectedItem().getMode())) {
// Use values from station config
m_activeWifiConfig = m_selectNetIfConfig.getStationWifiConfig();
} else {
// Use values from access point config
m_activeWifiConfig = m_selectNetIfConfig.getAccessPointWifiConfig();
}
setPasswordValidation();
setValues(false);
refreshForm();
}
});
m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipWirelessMode()));
m_modeCombo.addPlugin(m_dirtyPlugin);
Button ssidPickerButton = new Button("", AbstractImagePrototype.create(Resources.INSTANCE.magnifier16()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
m_wifiNetworksWindow = createWifiNetworksWindow();
m_wifiNetworksWindow.show();
m_wifiHotspotLoader.load();
}
});
//
// SSID
//
m_ssidField = new TextFieldWithButton<String>(ssidPickerButton, 10);
m_ssidField.setAllowBlank(true);
m_ssidField.setId("ssid-input");
m_ssidField.setName("ssid");
m_ssidField.setFieldLabel(MSGS.netWifiNetworkName());
m_ssidField.setEnabled(true, false);
m_ssidField.addPlugin(m_dirtyPlugin);
m_ssidField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipNetworkName()));
m_ssidField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_ssidField.setMaxLength(MAX_SSID_LENGTH);
//
// Radio Mode
//
m_radioModeCombo = new SimpleComboBox<String>();
m_radioModeCombo.setName("radioMode");
m_radioModeCombo.setFieldLabel(MSGS.netWifiRadioMode());
m_radioModeCombo.setEditable(false);
m_radioModeCombo.setTypeAhead(true);
m_radioModeCombo.setTriggerAction(TriggerAction.ALL);
for (GwtWifiRadioMode mode : GwtWifiRadioMode.values()) {
if (mode != GwtWifiRadioMode.netWifiRadioModeA) {
// we don't support 802.11a yet
m_radioModeCombo.add(MessageUtils.get(mode.name()));
}
}
m_radioModeCombo.setSimpleValue(MessageUtils.get(GwtWifiRadioMode.netWifiRadioModeBGN.name()));
m_radioModeCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_radioModeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipRadioMode()));
m_radioModeCombo.addStyleName("kura-combobox");
m_radioModeCombo.addPlugin(m_dirtyPlugin);
//
// Wireless Security
//
m_securityCombo = new SimpleComboBox<String>();
m_securityCombo.setName("security");
m_securityCombo.setFieldLabel(MSGS.netWifiWirelessSecurity());
m_securityCombo.setEditable(false);
m_securityCombo.setTypeAhead(true);
m_securityCombo.setTriggerAction(TriggerAction.ALL);
m_securityCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiSecurity mode : GwtWifiSecurity.values()) {
m_securityCombo.add(MessageUtils.get(mode.name()));
}
m_securityCombo.setSimpleValue(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()));
m_securityCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
setPasswordValidation();
refreshForm();
}
});
m_securityCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipSecurity()));
m_securityCombo.addStyleName("kura-combobox");
m_securityCombo.addPlugin(m_dirtyPlugin);
Button passwordButton = new Button("", AbstractImagePrototype.create(Resources.INSTANCE.connect16()), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.hourglass16()));
m_passwordField.setEnabled(true, false);
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
GwtWifiConfig gwtWifiConfig = getGwtWifiConfig();
gwtNetworkService.verifyWifiCredentials(token, m_selectNetIfConfig.getName(), gwtWifiConfig, new AsyncCallback<Boolean>() {
public void onSuccess(Boolean result) {
Log.warn("verifyWifiCredentials() :: result=" + result);
if (!result.booleanValue()) {
m_passwordField.setValue("");
}
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.connect16()));
m_passwordField.setEnabled(true, true);
}
public void onFailure(Throwable caught) {
Log.warn("verifyWifiCredentials() :: caught: " + caught.toString());
m_passwordField.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.connect16()));
m_passwordField.setEnabled(true, true);
}
});
}
});
}
});
//
// Password
//
m_passwordField = new TextFieldWithButton<String>(passwordButton, 10);
m_passwordField.setId("wifi-password");
m_passwordField.setName("password");
m_passwordField.setFieldLabel(MSGS.netWifiWirelessPassword());
m_passwordField.setPassword(true);
m_passwordField.setRegex(PASSWORD_REGEX_ANY);
m_passwordField.getMessages().setRegexText(MSGS.netWifiWirelessInvalidWPAPassword());
m_passwordField.addPlugin(m_dirtyPlugin);
m_passwordField.setAutoValidate(true);
m_passwordField.setAllowBlank(false);
m_passwordField.addKeyListener(new KeyListener() {
@Override
public void componentKeyUp(ComponentEvent event) {
super.componentKeyUp(event);
m_verifyPasswordField.validate();
}
});
m_passwordField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPassword()));
m_passwordField.addListener(Events.OnChange, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
setPasswordValidation();
refreshForm();
}
});
//
// Verify Password
//
m_verifyPasswordField = new TextField<String>();
m_verifyPasswordField.setName("verifyPassword");
m_verifyPasswordField.setFieldLabel(MSGS.netWifiWirelessVerifyPassword());
m_verifyPasswordField.setPassword(true);
m_verifyPasswordField.addPlugin(m_dirtyPlugin);
// TODO:
m_verifyPasswordField.getMessages().setInvalidText("Invalid text 123");
m_verifyPasswordField.setAutoValidate(true);
m_verifyPasswordField.setAllowBlank(false);
m_verifyPasswordField.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
if (m_modeCombo != null && GwtWifiWirelessMode.netWifiWirelessModeAccessPoint.equals(m_modeCombo.getValue().getMode())) {
// Check that the verify password field matches
if (m_passwordField == null || !value.equals(m_passwordField.getValue())) {
return MSGS.netWifiWirelessPasswordDoesNotMatch();
}
}
return null;
}
});
m_verifyPasswordField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipVerifyPassword()));
m_verifyPasswordField.addStyleName("kura-textfield");
// pairwise ciphers
m_pairwiseCiphersCombo = new SimpleComboBox<String>();
m_pairwiseCiphersCombo.setName("pairwiseCiphers");
m_pairwiseCiphersCombo.setFieldLabel(MSGS.netWifiWirelessPairwiseCiphers());
m_pairwiseCiphersCombo.setEditable(false);
m_pairwiseCiphersCombo.setTypeAhead(true);
m_pairwiseCiphersCombo.setTriggerAction(TriggerAction.ALL);
// m_pairwiseCiphersCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
m_pairwiseCiphersCombo.add(MessageUtils.get(ciphers.name()));
}
m_pairwiseCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
m_pairwiseCiphersCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_pairwiseCiphersCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPairwiseCiphers()));
m_pairwiseCiphersCombo.addStyleName("kura-combobox");
m_pairwiseCiphersCombo.addPlugin(m_dirtyPlugin);
// group ciphers
m_groupCiphersCombo = new SimpleComboBox<String>();
m_groupCiphersCombo.setName("groupCiphers");
m_groupCiphersCombo.setFieldLabel(MSGS.netWifiWirelessGroupCiphers());
m_groupCiphersCombo.setEditable(false);
m_groupCiphersCombo.setTypeAhead(true);
m_groupCiphersCombo.setTriggerAction(TriggerAction.ALL);
// m_groupCiphersCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiCiphers ciphers : GwtWifiCiphers.values()) {
m_groupCiphersCombo.add(MessageUtils.get(ciphers.name()));
}
m_groupCiphersCombo.setSimpleValue(MessageUtils.get(GwtWifiCiphers.netWifiCiphers_CCMP_TKIP.name()));
m_groupCiphersCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_groupCiphersCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipGroupCiphers()));
m_groupCiphersCombo.addStyleName("kura-combobox");
m_groupCiphersCombo.addPlugin(m_dirtyPlugin);
// bgscan module
m_bgscanModuleCombo = new SimpleComboBox<String>();
m_bgscanModuleCombo.setName("groupCiphers");
m_bgscanModuleCombo.setFieldLabel(MSGS.netWifiWirelessBgscanModule());
m_bgscanModuleCombo.setEditable(false);
m_bgscanModuleCombo.setTypeAhead(true);
m_bgscanModuleCombo.setTriggerAction(TriggerAction.ALL);
m_bgscanModuleCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
for (GwtWifiBgscanModule module : GwtWifiBgscanModule.values()) {
m_bgscanModuleCombo.add(MessageUtils.get(module.name()));
}
m_bgscanModuleCombo.setSimpleValue(MessageUtils.get(GwtWifiBgscanModule.netWifiBgscanMode_NONE.name()));
m_bgscanModuleCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
refreshForm();
}
});
m_bgscanModuleCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScan()));
m_bgscanModuleCombo.addStyleName("kura-combobox");
m_bgscanModuleCombo.addPlugin(m_dirtyPlugin);
// bgscan RSSI Threshold
m_bgscanRssiThresholdSlider = new Slider();
m_bgscanRssiThresholdSlider.setWidth(200);
m_bgscanRssiThresholdSlider.setIncrement(1);
m_bgscanRssiThresholdSlider.setMinValue(-90);
m_bgscanRssiThresholdSlider.setMaxValue(-20);
m_bgscanRssiThresholdSlider.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanStrength()));
m_bgscanRssiThresholdSlider.setClickToChange(false);
m_bgscanRssiThresholdSliderField = new SliderField(m_bgscanRssiThresholdSlider);
m_bgscanRssiThresholdSliderField.setFieldLabel(MSGS.netWifiWirelessBgscanSignalStrengthThreshold());
// bgscan short interval
m_bgscanShortIntervalField = new NumberField();
m_bgscanShortIntervalField.setPropertyEditorType(Integer.class);
m_bgscanShortIntervalField.setAllowDecimals(false);
m_bgscanShortIntervalField.setAllowNegative(false);
m_bgscanShortIntervalField.setAllowBlank(true);
m_bgscanShortIntervalField.setName("bgscanShortInterval");
m_bgscanShortIntervalField.setFieldLabel(MSGS.netWifiWirelessBgscanShortInterval());
m_bgscanShortIntervalField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanShortInterval()));
m_bgscanShortIntervalField.addPlugin(m_dirtyPlugin);
// m_bgscanShortInterval.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
// bgscan long interval
m_bgscanLongIntervalField = new NumberField();
m_bgscanLongIntervalField.setPropertyEditorType(Integer.class);
m_bgscanLongIntervalField.setAllowDecimals(false);
m_bgscanLongIntervalField.setAllowNegative(false);
m_bgscanLongIntervalField.setAllowBlank(true);
m_bgscanLongIntervalField.setName("bgscanLongInterval");
m_bgscanLongIntervalField.setFieldLabel(MSGS.netWifiWirelessBgscanLongInterval());
m_bgscanLongIntervalField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipBgScanLongInterval()));
m_bgscanLongIntervalField.addPlugin(m_dirtyPlugin);
m_pingAccessPointRadioTrue = new Radio();
m_pingAccessPointRadioTrue.setBoxLabel(MSGS.trueLabel());
m_pingAccessPointRadioTrue.setItemId("true");
m_pingAccessPointRadioTrue.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPingAccessPoint()));
m_pingAccessPointRadioFalse = new Radio();
m_pingAccessPointRadioFalse.setBoxLabel(MSGS.falseLabel());
m_pingAccessPointRadioFalse.setItemId("false");
m_pingAccessPointRadioFalse.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipPingAccessPoint()));
m_pingAccessPointRadioGroup = new RadioGroup();
m_pingAccessPointRadioGroup.setName("pingAccessPoint");
m_pingAccessPointRadioGroup.setFieldLabel(MSGS.netWifiWirelessPingAccessPoint());
m_pingAccessPointRadioGroup.add(m_pingAccessPointRadioTrue);
m_pingAccessPointRadioGroup.add(m_pingAccessPointRadioFalse);
m_pingAccessPointRadioGroup.addPlugin(m_dirtyPlugin);
m_pingAccessPointRadioGroup.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_ignoreSsidRadioTrue = new Radio();
m_ignoreSsidRadioTrue.setBoxLabel(MSGS.trueLabel());
m_ignoreSsidRadioTrue.setItemId("true");
m_ignoreSsidRadioTrue.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipIgnoreSSID()));
m_ignoreSsidRadioFalse = new Radio();
m_ignoreSsidRadioFalse.setBoxLabel(MSGS.falseLabel());
m_ignoreSsidRadioFalse.setItemId("false");
m_ignoreSsidRadioFalse.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipIgnoreSSID()));
m_ignoreSsidRadioGroup = new RadioGroup();
m_ignoreSsidRadioGroup.setName("ignoreSSID");
m_ignoreSsidRadioGroup.setFieldLabel(MSGS.netWifiWirelessIgnoreSSID());
m_ignoreSsidRadioGroup.add(m_ignoreSsidRadioTrue);
m_ignoreSsidRadioGroup.add(m_ignoreSsidRadioFalse);
m_ignoreSsidRadioGroup.addPlugin(m_dirtyPlugin);
m_ignoreSsidRadioGroup.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
//
// Channel
//
GroupingStore<GwtWifiChannelModel> grtoupingStore = new GroupingStore<GwtWifiChannelModel>();
grtoupingStore.setMonitorChanges(true);
grtoupingStore.add(GwtWifiChannelModel.getChannels());
grtoupingStore.groupBy("band");
ColumnConfig channel = new ColumnConfig("name", "All Available Channels", 20);
ColumnConfig frequency = new ColumnConfig("frequency", "Frequency (MHz)", 10);
ColumnConfig band = new ColumnConfig("band", "Spectrum Band", 20);
List<ColumnConfig> channelColumnConfig = new ArrayList<ColumnConfig>();
channelColumnConfig.add(m_checkboxChannelSelectionModel.getColumn());
channelColumnConfig.add(channel);
channelColumnConfig.add(frequency);
channelColumnConfig.add(band);
final ColumnModel columnModel = new ColumnModel(channelColumnConfig);
m_channelGroupingView = new GroupingView() {
@Override
protected void onMouseDown(GridEvent<ModelData> ge) {
El hd = ge.getTarget(".x-grid-group-hd", 10);
El target = ge.getTargetEl();
if (hd != null && target.hasStyleName(m_uncheckedStyle) || target.hasStyleName(m_checkedStyle)) {
boolean checked = !ge.getTargetEl().hasStyleName(m_uncheckedStyle);
checked = !checked;
if (checked) {
ge.getTargetEl().replaceStyleName(m_uncheckedStyle, m_checkedStyle);
} else {
ge.getTargetEl().replaceStyleName(m_checkedStyle, m_uncheckedStyle);
}
Element group = (Element) findGroup(ge.getTarget());
if (group != null) {
NodeList<Element> rows = El.fly(group).select(".x-grid3-row");
List<ModelData> temp = new ArrayList<ModelData>();
for (int i = 0; i < rows.getLength(); i++) {
Element r = rows.getItem(i);
int idx = findRowIndex(r);
ModelData m = grid.getStore().getAt(idx);
temp.add(m);
}
if (checked) {
grid.getSelectionModel().select(temp, true);
} else {
grid.getSelectionModel().deselect(temp);
}
}
return;
}
super.onMouseDown(ge);
}
};
m_channelGroupingView.setShowGroupedColumn(false);
m_channelGroupingView.setForceFit(true);
m_channelGroupingView.setShowDirtyCells(true);
m_channelGroupingView.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = columnModel.getColumnById(data.field).getHeader();
String l = data.models.size() == 1 ? "Item" : "Items";
return "<div class='x-grid3-group-checker'><div class='" + m_uncheckedStyle + "'> </div></div> " + f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});
final Grid<GwtWifiChannelModel> channelGrid = new Grid<GwtWifiChannelModel>(grtoupingStore, columnModel);
channelGrid.setView(m_channelGroupingView);
channelGrid.setBorders(true);
channelGrid.addPlugin(m_checkboxChannelSelectionModel);
channelGrid.setSelectionModel(m_checkboxChannelSelectionModel);
channelGrid.addPlugin(m_dirtyPlugin);
m_channelPanel = new ContentPanel();
m_channelPanel.setHeading("Select Channel(s)");
m_channelPanel.setCollapsible(true);
m_channelPanel.setFrame(true);
m_channelPanel.setSize(430, 200);
m_channelPanel.setLayout(new FitLayout());
m_channelPanel.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_channelPanel.add(channelGrid);
m_channelPanel.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netWifiToolTipChannels()));
m_checkboxChannelSelectionModel.addSelectionChangedListener(new SelectionChangedListener<GwtWifiChannelModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtWifiChannelModel> se) {
updateSelectedChannels(se.getSelection());
}
});
// Adjust the number of channels shown based on defined property
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> results) {
if (results != null) {
List<GwtGroupedNVPair> pairs = results.getData();
if (pairs != null) {
for (GwtGroupedNVPair pair : pairs) {
String name = pair.getName();
if (name != null && name.equals("devLastWifiChannel")) {
int topChannel = Integer.parseInt(pair.getValue());
// Remove channels 12 and 13
if (topChannel < MAX_WIFI_CHANNEL) {
channelGrid.getStore().remove(MAX_WIFI_CHANNEL - 1);
channelGrid.getStore().remove(MAX_WIFI_CHANNEL - 2);
}
}
}
}
}
}
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}
});
fieldSet.add(m_modeCombo, formData);
fieldSet.add(m_ssidField, formData);
fieldSet.add(m_radioModeCombo, formData);
fieldSet.add(m_securityCombo, formData);
fieldSet.add(m_passwordField, formData);
fieldSet.add(m_verifyPasswordField, formData);
fieldSet.add(m_pairwiseCiphersCombo, formData);
fieldSet.add(m_groupCiphersCombo, formData);
fieldSet.add(m_bgscanModuleCombo, formData);
fieldSet.add(m_bgscanRssiThresholdSliderField, formData);
fieldSet.add(m_bgscanShortIntervalField, formData);
fieldSet.add(m_bgscanLongIntervalField, formData);
fieldSet.add(m_pingAccessPointRadioGroup, formData);
fieldSet.add(m_ignoreSsidRadioGroup, formData);
fieldSet.add(m_channelPanel, formData);
if ((m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA2.name()))) || (m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA.name()))) || (m_securityCombo.getSimpleValue().equals(MessageUtils.get(GwtWifiSecurity.netWifiSecurityWPA_WPA2.name())))) {
if (GwtWifiWirelessMode.netWifiWirelessModeStation.equals(m_modeCombo.getValue().getMode())) {
m_pairwiseCiphersCombo.setEnabled(true);
m_groupCiphersCombo.setEnabled(true);
} else {
// m_pairwiseCiphersCombo.setEnabled(false); // enable it for AP mode as well
m_pairwiseCiphersCombo.setEnabled(true);
m_groupCiphersCombo.setEnabled(false);
}
} else {
m_pairwiseCiphersCombo.setEnabled(false);
m_groupCiphersCombo.setEnabled(false);
}
m_formPanel.add(fieldSet);
m_formPanel.setScrollMode(Scroll.AUTO);
add(m_formPanel);
setScrollMode(Scroll.AUTOX);
m_initialized = true;
}
use of com.extjs.gxt.ui.client.store.GroupingStore in project jahia by Jahia.
the class HistoryPanel method init.
private void init() {
setBorders(false);
final JahiaContentManagementServiceAsync service = JahiaContentManagementService.App.getInstance();
// data proxy
RpcProxy<PagingLoadResult<GWTJahiaContentHistoryEntry>> proxy = new RpcProxy<PagingLoadResult<GWTJahiaContentHistoryEntry>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<GWTJahiaContentHistoryEntry>> callback) {
if (loadConfig == null) {
service.getContentHistory(node.getUUID(), 0, Integer.MAX_VALUE, callback);
} else if (loadConfig instanceof BasePagingLoadConfig) {
BasePagingLoadConfig pagingLoadConfig = (BasePagingLoadConfig) loadConfig;
int limit = pagingLoadConfig.getLimit();
int offset = pagingLoadConfig.getOffset();
service.getContentHistory(node.getUUID(), offset, limit, callback);
} else {
callback.onSuccess(new BasePagingLoadResult<GWTJahiaContentHistoryEntry>(new ArrayList<GWTJahiaContentHistoryEntry>()));
}
}
};
// tree loader
final PagingLoader<BasePagingLoadResult<ModelData>> loader = new BasePagingLoader<BasePagingLoadResult<ModelData>>(proxy);
loader.setRemoteSort(true);
// trees store
final GroupingStore<GWTJahiaContentHistoryEntry> store = new GroupingStore<GWTJahiaContentHistoryEntry>(loader);
store.groupBy("status");
pagingToolBar = new PagingToolBar(50);
PagingToolBar.PagingToolBarMessages pagingMessages = pagingToolBar.getMessages();
pagingMessages.setEmptyMsg(pagingMessages.getEmptyMsg() + ". " + Messages.get("label.historyMayBeDelayed", "History may be delayed."));
if (pagingMessages.getDisplayMsg() != null) {
pagingMessages.setDisplayMsg(pagingMessages.getDisplayMsg() + ". " + Messages.get("label.historyMayBeDelayed", "History may be delayed."));
}
pagingToolBar.bind(loader);
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("date", Messages.get("label.date", "Date"), 125);
column.setDateTimeFormat(DateTimeFormat.getFormat(SECONDS_PRECISION_DATETIME_FORMAT));
column.setSortable(false);
config.add(column);
column = new ColumnConfig("action", Messages.get("label.action", "Action"), 90);
column.setSortable(false);
config.add(column);
column = new ColumnConfig("userKey", Messages.get("label.user", "User"), 90);
column.setSortable(false);
config.add(column);
column = new ColumnConfig("propertyName", Messages.get("label.property", "Property"), 90);
column.setSortable(false);
config.add(column);
column = new ColumnConfig("languageCode", Messages.get("label.language", "Language"), 70);
column.setSortable(false);
config.add(column);
column = new ColumnConfig("message", Messages.get("label.message", "Message"), 300);
column.setSortable(false);
column.setRenderer(new GridCellRenderer<GWTJahiaContentHistoryEntry>() {
public Object render(GWTJahiaContentHistoryEntry gwtJahiaContentHistoryEntry, String s, ColumnData columnData, int i, int i1, ListStore<GWTJahiaContentHistoryEntry> gwtJahiaContentHistoryEntryListStore, Grid<GWTJahiaContentHistoryEntry> gwtJahiaContentHistoryEntryGrid) {
String message = buildMessage(gwtJahiaContentHistoryEntry);
return new Label(message);
}
});
config.add(column);
final ColumnModel cm = new ColumnModel(config);
final Grid<GWTJahiaContentHistoryEntry> grid = new Grid<GWTJahiaContentHistoryEntry>(store, cm);
grid.setBorders(true);
grid.setAutoExpandColumn("message");
grid.setTrackMouseOver(false);
grid.setStateId("historyPagingGrid");
grid.setStateful(true);
grid.addListener(Events.Attach, new Listener<GridEvent<GWTJahiaContentHistoryEntry>>() {
public void handleEvent(GridEvent<GWTJahiaContentHistoryEntry> be) {
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(50);
Map<String, Object> state = grid.getState();
if (state.containsKey("offset")) {
int offset = (Integer) state.get("offset");
int limit = (Integer) state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
if (state.containsKey("sortField")) {
config.setSortField((String) state.get("sortField"));
config.setSortDir(Style.SortDir.valueOf((String) state.get("sortDir")));
}
loader.load(config);
}
});
grid.setLoadMask(true);
grid.setBorders(true);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaContentHistoryEntry>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaContentHistoryEntry> gwtJahiaJobDetailSelectionChangedEvent) {
selectedItems = gwtJahiaJobDetailSelectionChangedEvent.getSelection();
updateDetails();
}
});
ContentPanel listPanel = new ContentPanel();
listPanel.setFrame(true);
listPanel.setCollapsible(false);
listPanel.setAnimCollapse(false);
// panel.setIcon(Resources.ICONS.table());
// panel.setHeading("");
listPanel.setHeaderVisible(false);
listPanel.setLayout(new FitLayout());
listPanel.add(grid);
listPanel.setSize(600, 350);
listPanel.setBottomComponent(pagingToolBar);
grid.getAriaSupport().setLabelledBy(listPanel.getId());
add(listPanel);
BorderLayoutData centerData = new BorderLayoutData(Style.LayoutRegion.CENTER);
add(listPanel, centerData);
FormPanel detailPanel = new FormPanel();
detailPanel.setBorders(true);
detailPanel.setBodyBorder(true);
detailPanel.setHeaderVisible(true);
detailPanel.setHeadingHtml(Messages.get("label.detailed", "Details"));
detailPanel.setScrollMode(Style.Scroll.AUTOY);
detailPanel.setLabelWidth(100);
detailsPanel = detailPanel;
BorderLayoutData southData = new BorderLayoutData(Style.LayoutRegion.SOUTH, 200);
southData.setSplit(true);
southData.setCollapsible(true);
add(detailPanel, southData);
}
use of com.extjs.gxt.ui.client.store.GroupingStore in project jahia by Jahia.
the class JobListPanel method init.
private void init() {
setBorders(false);
activeGroupNames = new ArrayList<String>();
activeGroupNames.add("ActionJob");
activeGroupNames.add("PublicationJob");
activeGroupNames.add("ImportJob");
activeGroupNames.add("SitemapJob");
activeGroupNames.add("RuleJob");
final JahiaContentManagementServiceAsync service = JahiaContentManagementService.App.getInstance();
// data proxy
RpcProxy<PagingLoadResult<GWTJahiaJobDetail>> proxy = new RpcProxy<PagingLoadResult<GWTJahiaJobDetail>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<GWTJahiaJobDetail>> callback) {
if (loadConfig == null) {
service.getJobs(0, Integer.MAX_VALUE, null, null, null, activeGroupNames, callback);
} else if (loadConfig instanceof BasePagingLoadConfig) {
BasePagingLoadConfig pagingLoadConfig = (BasePagingLoadConfig) loadConfig;
int limit = pagingLoadConfig.getLimit();
int offset = pagingLoadConfig.getOffset();
Style.SortDir sortDir = pagingLoadConfig.getSortDir();
String sortField = pagingLoadConfig.getSortField();
service.getJobs(offset, limit, sortField, sortDir.name(), ((GroupingLoadConfig) loadConfig).getGroupBy(), activeGroupNames, callback);
} else {
callback.onSuccess(new BasePagingLoadResult<GWTJahiaJobDetail>(new ArrayList<GWTJahiaJobDetail>()));
}
}
};
// tree loader
final BasePagingLoader<BasePagingLoadResult<ModelData>> loader = new BasePagingLoader<BasePagingLoadResult<ModelData>>(proxy);
loader.setRemoteSort(true);
loader.setReuseLoadConfig(true);
// trees store
final GroupingStore<GWTJahiaJobDetail> store = new GroupingStore<GWTJahiaJobDetail>(loader) {
@Override
public void groupBy(String field) {
super.groupBy(field);
grid.getState().put("groupBy", field);
grid.saveState();
}
};
pagingToolBar = new PagingToolBar(50);
pagingToolBar.bind(loader);
pagingToolBar.addStyleName("jobs-paging-toolbar");
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("creationTime", Messages.get("label.creationTime", "Start date"), 100);
column.setDateTimeFormat(Formatter.DEFAULT_DATETIME_FORMAT);
column.setSortable(true);
config.add(column);
column = new ColumnConfig("group", Messages.get("label.type", "Type"), 100);
column.setSortable(false);
column.setRenderer(new GridCellRenderer<GWTJahiaJobDetail>() {
public Object render(GWTJahiaJobDetail jobDetail, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaJobDetail> gwtJahiaJobDetailListStore, Grid<GWTJahiaJobDetail> gwtJahiaJobDetailGrid) {
return new Label(Messages.get("label." + jobDetail.getGroup() + ".task", jobDetail.getGroup()));
}
});
config.add(column);
column = new ColumnConfig("description", Messages.get("label.description", "Description"), 100);
column.setSortable(false);
column.setGroupable(false);
config.add(column);
column = new ColumnConfig("status", Messages.get("label.status", "Status"), 100);
column.setRenderer(new GridCellRenderer<GWTJahiaJobDetail>() {
@Override
public Object render(GWTJahiaJobDetail jobDetail, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) {
return Messages.get("label.job.status." + jobDetail.getStatus());
}
});
column.setSortable(false);
config.add(column);
column = new ColumnConfig("duration", Messages.get("label.duration", "Duration"), 140);
column.setSortable(true);
column.setGroupable(false);
column.setRenderer(new GridCellRenderer<GWTJahiaJobDetail>() {
public Object render(GWTJahiaJobDetail jobDetail, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GWTJahiaJobDetail> store, Grid<GWTJahiaJobDetail> grid) {
Long duration = jobDetail.getDuration();
String display = "-";
if (duration != null) {
if (duration < 1000) {
display = duration + " " + Messages.get("label.milliseconds.short", "ms");
} else if (duration < 60 * 1000L) {
display = ((int) (duration / 1000L)) + " " + Messages.get("label.seconds.short", "sec");
} else if (duration < 60 * 60 * 1000L) {
display = ((int) (duration / (60 * 1000L))) + " " + Messages.get("label.minutes.short", "min") + " " + (((int) (duration / 1000L)) % 60) + " " + Messages.get("label.seconds.short", "sec");
} else {
display = ((int) (duration / (60 * 60 * 1000L))) + " " + Messages.get("label.hours.short", "h") + " " + (((int) (duration / 60 * 1000L)) % 60) + " " + Messages.get("label.minutes.short", "min");
}
}
if (STATUS_EXECUTING.equals(jobDetail.getStatus())) {
return new Label(Messages.get("label.executingSince", "Executing since ") + display + "...");
} else {
return new Label(display);
}
}
});
config.add(column);
column = new ColumnConfig("user", Messages.get("label.user", "User"), 100);
column.setSortable(false);
column.setGroupable(true);
column.setHidden(true);
config.add(column);
column = new ColumnConfig("message", Messages.get("label.message", "Message"), 100);
column.setSortable(false);
column.setGroupable(false);
column.setHidden(true);
config.add(column);
column = new ColumnConfig("name", Messages.get("label.name", "Name"), 100);
column.setSortable(false);
column.setGroupable(false);
column.setHidden(true);
config.add(column);
final ColumnModel cm = new ColumnModel(config);
GroupingView view = new JahiaGroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(true);
view.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = cm.getColumnById(data.field).getHeaderHtml();
String l = data.models.size() == 1 ? Messages.get("label.item", "Item") : Messages.get("label.items", "Items");
if (data.field.equals("status")) {
return f + ": " + Messages.get("label.job.status." + data.group) + " (" + data.models.size() + " " + l + ")";
} else {
return f + ": " + (data.group) + " (" + data.models.size() + " " + l + ")";
}
}
});
grid = new Grid<GWTJahiaJobDetail>(store, cm);
grid.setBorders(true);
grid.setView(view);
grid.setAutoExpandColumn("description");
grid.setTrackMouseOver(false);
grid.setStateId("jobPagingGrid");
grid.setStateful(true);
grid.addListener(Events.Attach, new Listener<GridEvent<GWTJahiaJobDetail>>() {
public void handleEvent(GridEvent<GWTJahiaJobDetail> be) {
LoadConfig config = new LoadConfig();
config.setOffset(0);
config.setLimit(50);
Map<String, Object> state = grid.getState();
String groupBy = (String) (state.get("groupBy") != null ? state.get("groupBy") : "status");
config.setGroupBy(groupBy);
store.groupBy(groupBy);
store.setRemoteGroup(true);
if (state.containsKey("offset")) {
int offset = (Integer) state.get("offset");
int limit = (Integer) state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
if (state.containsKey("sortField")) {
config.setSortField((String) state.get("sortField"));
config.setSortDir(Style.SortDir.valueOf((String) state.get("sortDir")));
}
loader.load(config);
}
});
grid.setLoadMask(true);
grid.setBorders(true);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaJobDetail>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaJobDetail> gwtJahiaJobDetailSelectionChangedEvent) {
selectedItems = gwtJahiaJobDetailSelectionChangedEvent.getSelection();
if (adminMode) {
for (GWTJahiaJobDetail jobDetail : selectedItems) {
if (STATUS_EXECUTING.equals(jobDetail.getStatus()) || STATUS_SCHEDULED.equals(jobDetail.getStatus())) {
deleteButton.disable();
break;
} else {
deleteButton.enable();
}
}
}
updateDetails();
}
});
ToolBar topToolBar = new ToolBar();
topToolBar.addStyleName("jobs-top-toolbar");
Button filterButton = new Button(Messages.get("label.typeFilter", "Type filter"));
final Menu filterMenu = new Menu();
filterMenu.addStyleName("filter-menu");
service.getAllJobGroupNames(new BaseAsyncCallback<List<String>>() {
public void onSuccess(List<String> groupNames) {
for (String groupName : groupNames) {
final CheckMenuItem groupActivated = new CheckMenuItem(Messages.get("label." + groupName + ".task", groupName));
groupActivated.setStateId(groupName);
if (activeGroupNames.contains(groupName)) {
groupActivated.setChecked(true);
} else {
groupActivated.setChecked(false);
}
groupActivated.addListener(Events.CheckChange, new Listener<MenuEvent>() {
public void handleEvent(MenuEvent be) {
String groupName = groupActivated.getStateId();
if (groupActivated.isChecked()) {
if (!activeGroupNames.contains(groupName)) {
activeGroupNames.add(groupName);
}
} else {
activeGroupNames.remove(groupName);
}
pagingToolBar.refresh();
}
});
filterMenu.add(groupActivated);
}
}
});
filterButton.setMenu(filterMenu);
filterButton.addStyleName("jobs-filter-combo");
topToolBar.add(filterButton);
topToolBar.add(new SeparatorToolItem());
final CheckBox autoRefreshCheckBox = new CheckBox();
autoRefreshCheckBox.addStyleName("jobs-auto-refresh");
autoRefreshCheckBox.setValue(autoRefreshActivated);
autoRefreshCheckBox.setBoxLabel(Messages.get("label.autoRefresh", "Auto-refresh every"));
autoRefreshCheckBox.addListener(Events.Change, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent be) {
Boolean autoRefreshEnabled = autoRefreshCheckBox.getValue();
if (autoRefreshEnabled.booleanValue()) {
autoRefreshActivated = true;
stopAutoRefresh();
startAutoRefresh();
} else {
autoRefreshActivated = false;
stopAutoRefresh();
}
}
});
topToolBar.add(autoRefreshCheckBox);
final TextBox refreshIntervalTextBox = new TextBox();
refreshIntervalTextBox.setWidth("3em");
refreshIntervalTextBox.setText(Integer.toString(autoRefreshInterval));
refreshIntervalTextBox.addChangeHandler(new ChangeHandler() {
public void onChange(com.google.gwt.event.dom.client.ChangeEvent event) {
String refreshTextValue = refreshIntervalTextBox.getText();
int newRefreshInterval = -1;
try {
newRefreshInterval = Integer.parseInt(refreshTextValue);
} catch (NumberFormatException nfe) {
newRefreshInterval = -1;
}
if ((newRefreshInterval >= 5) && (newRefreshInterval <= 120)) {
autoRefreshInterval = newRefreshInterval;
if (autoRefreshActivated) {
stopAutoRefresh();
startAutoRefresh();
}
} else {
refreshIntervalTextBox.setText(Integer.toString(autoRefreshInterval));
}
}
});
topToolBar.add(new WidgetComponent(refreshIntervalTextBox));
Label secondsLabel = new Label(" " + Messages.get("label.seconds", "seconds"));
topToolBar.add(secondsLabel);
if (adminMode) {
topToolBar.add(new SeparatorToolItem());
deleteButton = new Button(Messages.get("label.delete", "Delete"), StandardIconsProvider.STANDARD_ICONS.delete(), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
showDeleteConfirmation(false);
}
});
deleteButton.disable();
topToolBar.add(deleteButton);
topToolBar.add(new Button(Messages.get("label.deleteCompletedJobs", "Delete all completed"), StandardIconsProvider.STANDARD_ICONS.delete(), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
showDeleteConfirmation(true);
}
}));
}
ContentPanel listPanel = new ContentPanel();
listPanel.setFrame(true);
listPanel.setCollapsible(false);
listPanel.setAnimCollapse(false);
// panel.setIcon(Resources.ICONS.table());
// panel.setHeadingHtml("");
listPanel.setHeaderVisible(false);
listPanel.setLayout(new FitLayout());
listPanel.add(grid);
listPanel.setSize(600, 350);
listPanel.setBottomComponent(pagingToolBar);
listPanel.setTopComponent(topToolBar);
grid.getAriaSupport().setLabelledBy(listPanel.getId());
add(listPanel);
BorderLayoutData centerData = new BorderLayoutData(Style.LayoutRegion.CENTER);
add(listPanel, centerData);
FormPanel detailPanel = new FormPanel();
detailPanel.setBorders(true);
detailPanel.setBodyBorder(true);
detailPanel.setHeaderVisible(true);
detailPanel.setHeadingHtml(Messages.get("label.detailed", "Details"));
detailPanel.setScrollMode(Style.Scroll.AUTOY);
detailPanel.setLabelWidth(100);
detailsPanel = detailPanel;
BorderLayoutData southData = new BorderLayoutData(Style.LayoutRegion.SOUTH, 200);
southData.setSplit(true);
southData.setCollapsible(true);
add(detailPanel, southData);
addListener(Events.Detach, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent be) {
stopAutoRefresh();
}
});
}
Aggregations