Search in sources :

Example 6 with ObjectTool

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

the class ObjectToolsEditor method deleteTools.

/**
 * Delete selected tools
 */
private void deleteTools() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.isEmpty())
        return;
    if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().ObjectToolsEditor_Confirmation, Messages.get().ObjectToolsEditor_DeleteConfirmation))
        return;
    final Object[] objects = selection.toArray();
    new ConsoleJob(Messages.get().ObjectToolsEditor_JobDelete, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        @Override
        protected String getErrorMessage() {
            return Messages.get(getDisplay()).ObjectToolsEditor_JobDeleteError;
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (int i = 0; i < objects.length; i++) {
                session.deleteObjectTool(((ObjectTool) objects[i]).getId());
            }
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 7 with ObjectTool

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

the class ObjectToolsComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    ObjectTool tool1 = (ObjectTool) e1;
    ObjectTool tool2 = (ObjectTool) e2;
    // $NON-NLS-1$
    final int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
    int result;
    switch(column) {
        case ObjectToolsEditor.COLUMN_ID:
            result = Long.signum(tool1.getId() - tool2.getId());
            break;
        case ObjectToolsEditor.COLUMN_NAME:
            result = tool1.getName().compareToIgnoreCase(tool2.getName());
            break;
        case ObjectToolsEditor.COLUMN_TYPE:
            final ObjectToolsLabelProvider labelProvider = (ObjectToolsLabelProvider) ((SortableTableViewer) viewer).getLabelProvider();
            result = labelProvider.getToolTypeName(tool1).compareTo(labelProvider.getToolTypeName(tool2));
            break;
        case ObjectToolsEditor.COLUMN_DESCRIPTION:
            result = tool1.getDescription().compareToIgnoreCase(tool2.getDescription());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 8 with ObjectTool

use of org.netxms.client.objecttools.ObjectTool 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)

Example 9 with ObjectTool

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

the class ExportFileBuilder method doExport.

/**
 * Do export operation and call completion handler when done
 *
 * @param completionHandler
 */
private void doExport(final ExportCompletionHandler completionHandler) {
    final long[] eventList = new long[events.size()];
    int i = 0;
    for (EventObject o : events.values()) eventList[i++] = o.getCode();
    final long[] templateList = new long[templates.size()];
    i = 0;
    for (Template t : templates.values()) templateList[i++] = t.getObjectId();
    final long[] trapList = new long[traps.size()];
    i = 0;
    for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
    final UUID[] ruleList = new UUID[rules.size()];
    i = 0;
    for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
    final long[] scriptList = new long[scripts.size()];
    i = 0;
    for (Script s : scripts.values()) scriptList[i++] = s.getId();
    final long[] toolList = new long[tools.size()];
    i = 0;
    for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
    final long[] summaryTableList = new long[summaryTables.size()];
    i = 0;
    for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
    final long[] actionList = new long[actions.size()];
    i = 0;
    for (ServerAction a : actions.values()) actionList[i++] = a.getId();
    final String descriptionText = description.getText();
    new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    completionHandler.exportCompleted(xml);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExportFileBuilder_ExportJobError;
        }
    }.start();
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) Script(org.netxms.client.Script) SnmpTrap(org.netxms.client.snmp.SnmpTrap) EventObject(org.netxms.client.events.EventObject) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) UUID(java.util.UUID) ServerAction(org.netxms.client.ServerAction) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 10 with ObjectTool

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

the class ObjectToolsTest method testGet.

public void testGet() throws Exception {
    final NXCSession session = connect();
    List<ObjectTool> tools = session.getObjectTools();
    for (ObjectTool tool : tools) {
        System.out.println(" >>Tool>> " + tool.getId() + " " + tool.getName());
    }
    session.disconnect();
}
Also used : ObjectTool(org.netxms.client.objecttools.ObjectTool)

Aggregations

ObjectTool (org.netxms.client.objecttools.ObjectTool)19 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 PartInitException (org.eclipse.ui.PartInitException)5 ObjectToolDetails (org.netxms.client.objecttools.ObjectToolDetails)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 GeoLocation (org.netxms.base.GeoLocation)2 Node (org.netxms.client.objects.Node)2 AlertDialog (android.app.AlertDialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Intent (android.content.Intent)1 SubMenu (android.view.SubMenu)1 AdapterView (android.widget.AdapterView)1