Search in sources :

Example 6 with ServerAction

use of org.netxms.client.ServerAction 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 7 with ServerAction

use of org.netxms.client.ServerAction in project netxms by netxms.

the class ActionSelectionDialog method okPressed.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
    final IStructuredSelection selection = (IStructuredSelection) eventList.getSelection();
    final List<ServerAction> list = selection.toList();
    selectedActions = list.toArray(new ServerAction[list.size()]);
    saveSettings();
    super.okPressed();
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ServerAction(org.netxms.client.ServerAction)

Example 8 with ServerAction

use of org.netxms.client.ServerAction in project netxms by netxms.

the class ActionManager method createAction.

/**
 * Create new action
 */
private void createAction() {
    final ServerAction action = new ServerAction(0);
    final EditActionDlg dlg = new EditActionDlg(getSite().getShell(), action, true);
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().ActionManager_CreateJobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

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

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                long id = session.createAction(action.getName());
                action.setId(id);
                session.modifyAction(action);
            }
        }.start();
    }
}
Also used : EditActionDlg(org.netxms.ui.eclipse.actionmanager.dialogs.EditActionDlg) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ServerAction(org.netxms.client.ServerAction)

Example 9 with ServerAction

use of org.netxms.client.ServerAction in project netxms by netxms.

the class ActionManager method deleteActions.

/**
 * Delete selected actions
 */
private void deleteActions() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.isEmpty())
        return;
    if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().ActionManager_Confirmation, Messages.get().ActionManager_ConfirmDelete))
        return;
    final Object[] objects = selection.toArray();
    new ConsoleJob(Messages.get().ActionManager_DeleteJobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

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

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (int i = 0; i < objects.length; i++) {
                session.deleteAction(((ServerAction) 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) ServerAction(org.netxms.client.ServerAction)

Example 10 with ServerAction

use of org.netxms.client.ServerAction in project netxms by netxms.

the class ActionManager method editAction.

/**
 * Edit currently selected action
 */
private void editAction() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final ServerAction action = (ServerAction) selection.getFirstElement();
    final EditActionDlg dlg = new EditActionDlg(getSite().getShell(), action, false);
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().ActionManager_UpdateJobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

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

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                session.modifyAction(action);
            }
        }.start();
    }
}
Also used : EditActionDlg(org.netxms.ui.eclipse.actionmanager.dialogs.EditActionDlg) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ServerAction(org.netxms.client.ServerAction)

Aggregations

ServerAction (org.netxms.client.ServerAction)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 EventTemplate (org.netxms.client.events.EventTemplate)2 EditActionDlg (org.netxms.ui.eclipse.actionmanager.dialogs.EditActionDlg)2 Comparator (java.util.Comparator)1 List (java.util.List)1 UUID (java.util.UUID)1 Action (org.eclipse.jface.action.Action)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 CLabel (org.eclipse.swt.custom.CLabel)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1