Search in sources :

Example 1 with ObjectAction

use of org.netxms.client.objecttools.ObjectAction in project netxms by netxms.

the class Filter method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    ObjectAction action = (ObjectAction) getElement().getAdapter(ObjectAction.class);
    if (action instanceof ObjectTool)
        objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
    filter = action.getMenuFilter();
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    checkAgent = new Button(dialogArea, SWT.CHECK);
    checkAgent.setText(Messages.get().Filter_AgentNeeded);
    checkAgent.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_AGENT) != 0);
    checkSNMP = new Button(dialogArea, SWT.CHECK);
    checkSNMP.setText(Messages.get().Filter_SNMPNeeded);
    checkSNMP.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_SNMP) != 0);
    checkMatchOID = new Button(dialogArea, SWT.CHECK);
    checkMatchOID.setText(Messages.get().Filter_OIDShouldMatch);
    checkMatchOID.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_OID_MATCH) != 0);
    checkMatchOID.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            textOID.setEnabled(checkMatchOID.getSelection());
            if (checkMatchOID.getSelection())
                textOID.setFocus();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    textOID = new Text(dialogArea, SWT.BORDER);
    textOID.setText(filter.snmpOid);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    textOID.setLayoutData(gd);
    textOID.setEnabled(checkMatchOID.getSelection());
    checkMatchNodeOS = new Button(dialogArea, SWT.CHECK);
    checkMatchNodeOS.setText(Messages.get().Filter_OSShouldMatch);
    checkMatchNodeOS.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_NODE_OS_MATCH) != 0);
    checkMatchNodeOS.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            textNodeOS.setEnabled(checkMatchNodeOS.getSelection());
            if (checkMatchNodeOS.getSelection())
                textNodeOS.setFocus();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    textNodeOS = new Text(dialogArea, SWT.BORDER);
    textNodeOS.setText(filter.toolNodeOS);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    textNodeOS.setLayoutData(gd);
    textNodeOS.setEnabled(checkMatchNodeOS.getSelection());
    if (action instanceof ObjectTool && action.getToolType() == ObjectTool.TYPE_LOCAL_COMMAND) {
        checkMatchWorkstationOS = new Button(dialogArea, SWT.CHECK);
        checkMatchWorkstationOS.setText("Workstation OS name should match this template(coma separated regular expression list)");
        checkMatchWorkstationOS.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_WORKSTATION_OS_MATCH) != 0);
        checkMatchWorkstationOS.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                textWorkstationOS.setEnabled(checkMatchWorkstationOS.getSelection());
                if (checkMatchWorkstationOS.getSelection())
                    textWorkstationOS.setFocus();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
        textWorkstationOS = new Text(dialogArea, SWT.BORDER);
        textWorkstationOS.setText(filter.toolWorkstationOS);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        gd.horizontalIndent = 20;
        textWorkstationOS.setLayoutData(gd);
        textWorkstationOS.setEnabled(checkMatchWorkstationOS.getSelection());
    }
    checkMatchTemplate = new Button(dialogArea, SWT.CHECK);
    checkMatchTemplate.setText(Messages.get().Filter_TemplateShouldMatch);
    checkMatchTemplate.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_TEMPLATE_MATCH) != 0);
    checkMatchTemplate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            textTemplate.setEnabled(checkMatchTemplate.getSelection());
            if (checkMatchTemplate.getSelection())
                textTemplate.setFocus();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    textTemplate = new Text(dialogArea, SWT.BORDER);
    textTemplate.setText(filter.toolTemplate);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    textTemplate.setLayoutData(gd);
    textTemplate.setEnabled(checkMatchTemplate.getSelection());
    checkMatchCustomAttributes = new Button(dialogArea, SWT.CHECK);
    checkMatchCustomAttributes.setText("The following custom attribute(s) should exist");
    checkMatchCustomAttributes.setSelection((filter.flags & ObjectMenuFilter.REQUIRES_CUSTOM_ATTRIBUTE_MATCH) != 0);
    checkMatchCustomAttributes.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            textCustomAttributes.setEnabled(checkMatchCustomAttributes.getSelection());
            if (checkMatchCustomAttributes.getSelection())
                textCustomAttributes.setFocus();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    textCustomAttributes = new Text(dialogArea, SWT.BORDER);
    textCustomAttributes.setText(filter.toolCustomAttributes);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalIndent = 20;
    textCustomAttributes.setLayoutData(gd);
    textCustomAttributes.setEnabled(checkMatchCustomAttributes.getSelection());
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ObjectAction(org.netxms.client.objecttools.ObjectAction) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) ObjectToolDetails(org.netxms.client.objecttools.ObjectToolDetails) ObjectTool(org.netxms.client.objecttools.ObjectTool) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

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 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Text (org.eclipse.swt.widgets.Text)1 ObjectAction (org.netxms.client.objecttools.ObjectAction)1 ObjectTool (org.netxms.client.objecttools.ObjectTool)1 ObjectToolDetails (org.netxms.client.objecttools.ObjectToolDetails)1