Search in sources :

Example 1 with ScriptSelector

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);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ScriptSelector(org.netxms.ui.eclipse.nxsl.widgets.ScriptSelector) Section(org.eclipse.ui.forms.widgets.Section) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Section (org.eclipse.ui.forms.widgets.Section)1 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)1 ScriptSelector (org.netxms.ui.eclipse.nxsl.widgets.ScriptSelector)1