use of org.netxms.ui.eclipse.nxsl.widgets.ScriptSelector in project netxms by netxms.
the class NetworkDiscoveryConfigurator method createFilterSection.
/**
* Create "Filter" section
*/
private void createFilterSection() {
Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
section.setText(Messages.get().NetworkDiscoveryConfigurator_SectionFilter);
section.setDescription(Messages.get().NetworkDiscoveryConfigurator_SectionFilterDescr);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
clientArea.setLayout(layout);
section.setClient(clientArea);
final SelectionListener radioButtonListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateElementEnablement();
setModified();
if (radioFilterOff.getSelection()) {
config.setFilter(NetworkDiscovery.FILTER_NONE);
} else if (radioFilterAuto.getSelection()) {
config.setFilter(NetworkDiscovery.FILTER_AUTO);
} else {
config.setFilter(filterScript.getScriptName());
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
final SelectionListener checkBoxListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
setModified();
int flags = 0;
if (checkAgentOnly.getSelection())
flags |= NetworkDiscovery.FILTER_ALLOW_AGENT;
if (checkSnmpOnly.getSelection())
flags |= NetworkDiscovery.FILTER_ALLOW_SNMP;
if (checkRangeOnly.getSelection())
flags |= NetworkDiscovery.FILTER_LIMIT_BY_RANGE;
config.setFilterFlags(flags);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
radioFilterOff = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_NoFiltering, SWT.RADIO);
radioFilterOff.addSelectionListener(radioButtonListener);
radioFilterCustom = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_CustomScript, SWT.RADIO);
radioFilterCustom.addSelectionListener(radioButtonListener);
filterScript = new ScriptSelector(clientArea, SWT.NONE, true, false);
toolkit.adapt(filterScript);
filterScript.getTextControl().setBackground(clientArea.getBackground());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalIndent = 20;
filterScript.setLayoutData(gd);
filterScript.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (radioFilterCustom.getSelection()) {
setModified();
config.setFilter(filterScript.getScriptName());
}
}
});
radioFilterAuto = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_AutoScript, SWT.RADIO);
radioFilterAuto.addSelectionListener(radioButtonListener);
checkAgentOnly = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_AcceptAgent, SWT.CHECK);
checkAgentOnly.addSelectionListener(checkBoxListener);
gd = new GridData();
gd.horizontalIndent = 20;
checkAgentOnly.setLayoutData(gd);
checkSnmpOnly = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_AcceptSNMP, SWT.CHECK);
checkSnmpOnly.addSelectionListener(checkBoxListener);
gd = new GridData();
gd.horizontalIndent = 20;
checkSnmpOnly.setLayoutData(gd);
checkRangeOnly = toolkit.createButton(clientArea, Messages.get().NetworkDiscoveryConfigurator_AcceptRange, SWT.CHECK);
checkRangeOnly.addSelectionListener(checkBoxListener);
gd = new GridData();
gd.horizontalIndent = 20;
checkRangeOnly.setLayoutData(gd);
}
Aggregations