use of org.netxms.client.objecttools.ObjectToolDetails 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;
}
use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class ObjectToolsTest method testCreateAndDelete.
public void testCreateAndDelete() throws Exception {
final NXCSession session = connect();
long id = session.generateObjectToolId();
assertFalse(id == 0);
System.out.println("Object tool ID generated: " + id);
ObjectToolDetails td = new ObjectToolDetails(id, ObjectTool.TYPE_LOCAL_COMMAND, "UnitTest");
td.setData("ping %{10%(not a field)} -t %(address) -s %(size)");
td.addInputField(new InputField("size", InputFieldType.NUMBER, "Size (bytes)", null));
td.addInputField(new InputField("unused", InputFieldType.PASSWORD, "Unused field", null));
session.modifyObjectTool(td);
td = session.getObjectToolDetails(id);
for (InputField f : td.getInputFields()) System.out.println(f);
session.deleteObjectTool(id);
session.disconnect();
}
use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class ObjectToolsTest method testGetDetails.
public void testGetDetails() throws Exception {
final NXCSession session = connect();
ObjectToolDetails td = session.getObjectToolDetails(1);
System.out.println("Object tool details:");
System.out.println(" id = " + td.getId());
System.out.println(" name = " + td.getName());
System.out.println(" type = " + td.getToolType());
System.out.println(" OID = " + td.getSnmpOid());
System.out.println(" confirmation = " + td.getConfirmationText());
System.out.println(" columnCount = " + td.getColumns().size());
session.disconnect();
}
use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class NXCSession method getObjectToolDetails.
/**
* Get object tool details
*
* @param toolId Tool ID
* @return Object tool details
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public ObjectToolDetails getObjectToolDetails(long toolId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_OBJECT_TOOL_DETAILS);
msg.setFieldInt32(NXCPCodes.VID_TOOL_ID, (int) toolId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return new ObjectToolDetails(response);
}
use of org.netxms.client.objecttools.ObjectToolDetails in project netxms by netxms.
the class ObjectToolsAdapterFactory method getAdapter.
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject.getClass() != ObjectTool.class)
return null;
// Adapt to tool details
if (adapterType == ObjectToolDetails.class) {
final long toolId = ((ObjectTool) adaptableObject).getId();
ObjectToolDetails details = cache.get(toolId);
if (details == null) {
ToolDetailLoader job = new ToolDetailLoader(toolId, PlatformUI.getWorkbench().getDisplay());
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
service.busyCursorWhile(job);
details = job.getResult();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return details;
}
// Adapt to IWorkbenchAdapter
if (adapterType == IWorkbenchAdapter.class) {
return new IWorkbenchAdapter() {
@Override
public Object getParent(Object o) {
return null;
}
@Override
public String getLabel(Object o) {
return ((ObjectTool) o).getDisplayName();
}
@Override
public ImageDescriptor getImageDescriptor(Object object) {
return null;
}
@Override
public Object[] getChildren(Object o) {
return null;
}
};
}
return null;
}
Aggregations