Search in sources :

Example 6 with AlarmCategory

use of org.netxms.client.events.AlarmCategory in project netxms by netxms.

the class AlarmCategorySelector method setCategoryId.

/**
 * Set category Id
 *
 * @param categoryId
 */
public void setCategoryId(List<Long> categoryId) {
    if (this.categoryId.equals(categoryId))
        // Nothing to change
        return;
    if (categoryId != null && !categoryId.isEmpty()) {
        if (categoryId.get(0) == 0) {
            setText("<none>");
        } else {
            List<AlarmCategory> categories = ((NXCSession) ConsoleSharedData.getSession()).findMultipleAlarmCategories(categoryId);
            if (categories != null) {
                StringBuilder sb = new StringBuilder();
                this.categoryId.clear();
                for (AlarmCategory c : categories) {
                    sb.append(c.getName() + ";");
                    this.categoryId.add(c.getId());
                }
                setText(sb.toString());
            } else {
                setText("<unknown>");
            }
        }
    } else {
        setText("<none>");
    }
    fireModifyListeners();
}
Also used : NXCSession(org.netxms.client.NXCSession) AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 7 with AlarmCategory

use of org.netxms.client.events.AlarmCategory in project netxms by netxms.

the class AlarmCategoryList method createCategory.

/**
 * Create new category
 */
public void createCategory() {
    AlarmCategoryEditor editor = new AlarmCategoryEditor(new AlarmCategory());
    PropertyDialog dlg = PropertyDialog.createDialogOn(getShell(), null, editor);
    dlg.open();
}
Also used : AlarmCategoryEditor(org.netxms.ui.eclipse.alarmviewer.editors.AlarmCategoryEditor) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 8 with AlarmCategory

use of org.netxms.client.events.AlarmCategory in project netxms by netxms.

the class AlarmCategoryList method refreshView.

/**
 * Refresh dialog
 */
public void refreshView() {
    new ConsoleJob("Open alarm category list", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<AlarmCategory> list = session.getAlarmCategories();
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    alarmCategories = new HashMap<Long, AlarmCategory>(list.size());
                    for (final AlarmCategory c : list) {
                        alarmCategories.put(c.getId(), c);
                    }
                    viewer.setInput(alarmCategories.values().toArray());
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot open alarm category list";
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 9 with AlarmCategory

use of org.netxms.client.events.AlarmCategory in project netxms by netxms.

the class RuleEditor method createActionControl.

/**
 * Create action summary control
 *
 * @param parent
 * @param rule
 * @return
 */
private Control createActionControl(Composite parent, final EventProcessingPolicyRule rule) {
    Composite clientArea = new Composite(parent, SWT.NONE);
    clientArea.setBackground(SharedColors.getColor(SharedColors.RULE_EDITOR_BACKGROUND, getDisplay()));
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    clientArea.setLayout(layout);
    /* alarm */
    if ((rule.getFlags() & EventProcessingPolicyRule.GENERATE_ALARM) != 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleAlarm#10");
        if (rule.getAlarmSeverity().compareTo(Severity.TERMINATE) < 0) {
            addActionGroupLabel(clientArea, Messages.get().RuleEditor_GenerateAlarm, editor.getImageAlarm(), listener);
            CLabel clabel = createCLabel(clientArea, 1, false);
            clabel.setImage(StatusDisplayInfo.getStatusImage(rule.getAlarmSeverity()));
            clabel.setText(rule.getAlarmMessage());
            clabel.addMouseListener(listener);
            if ((rule.getAlarmKey() != null) && !rule.getAlarmKey().isEmpty()) {
                createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), null);
            }
        } else if (rule.getAlarmSeverity() == Severity.TERMINATE) {
            addActionGroupLabel(clientArea, Messages.get().RuleEditor_TerminateAlarms, editor.getImageTerminate(), listener);
            createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), listener);
            if ((rule.getFlags() & EventProcessingPolicyRule.TERMINATE_BY_REGEXP) != 0)
                createLabel(clientArea, 1, false, Messages.get().RuleEditor_UserRegexpForTerminate, listener);
        } else if (rule.getAlarmSeverity() == Severity.RESOLVE) {
            addActionGroupLabel(clientArea, Messages.get().RuleEditor_ResolveAlarms, editor.getImageTerminate(), listener);
            createLabel(clientArea, 1, false, String.format(Messages.get().RuleEditor_WithKey, rule.getAlarmKey()), listener);
            if ((rule.getFlags() & EventProcessingPolicyRule.TERMINATE_BY_REGEXP) != 0)
                createLabel(clientArea, 1, false, Messages.get().RuleEditor_UseRegexpForResolve, listener);
        }
        if (rule.getAlarmCategories().size() > 0) {
            createLabel(clientArea, 1, false, rule.getAlarmCategories().size() == 1 ? "with category: " : "with categories: ", null);
            for (Long id : rule.getAlarmCategories()) {
                AlarmCategory category = editor.findAlarmCategoryById(id);
                if (category != null) {
                    createLabel(clientArea, 2, false, category.getName(), null);
                }
            }
        }
        if ((rule.getFlags() & EventProcessingPolicyRule.CREATE_TICKET) != 0) {
            createLabel(clientArea, 1, false, "creates helpdesk ticket", null);
        }
    }
    /* persistent storage */
    if (rule.getPStorageSet().size() != 0 || rule.getPStorageDelete().size() != 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RulePStorage#20");
        addActionGroupLabel(clientArea, "Update persistent storage entries", editor.getImageSituation(), listener);
        if (rule.getPStorageSet().size() != 0) {
            // $NON-NLS-1$ //$NON-NLS-2$
            createLabel(clientArea, 1, false, "Set Persistent storage values", listener);
            for (Entry<String, String> e : rule.getPStorageSet().entrySet()) {
                // $NON-NLS-1$ //$NON-NLS-2$
                createLabel(clientArea, 2, false, e.getKey() + " = \"" + e.getValue() + "\"", listener);
            }
        }
        if (rule.getPStorageDelete().size() != 0) {
            createLabel(clientArea, 1, false, "Delete persistent storage values", listener);
            List<String> pStorageList = rule.getPStorageDelete();
            for (int i = 0; i < pStorageList.size(); i++) {
                createLabel(clientArea, 2, false, pStorageList.get(i), listener);
            }
        }
    }
    /* actions */
    if (rule.getActions().size() > 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleServerActions#30");
        addActionGroupLabel(clientArea, Messages.get().RuleEditor_ExecuteActions, editor.getImageExecute(), listener);
        for (Long id : rule.getActions()) {
            CLabel clabel = createCLabel(clientArea, 1, false);
            clabel.addMouseListener(listener);
            ServerAction action = editor.findActionById(id);
            if (action != null) {
                clabel.setText(action.getName());
                clabel.setImage(labelProvider.getImage(action));
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                clabel.setText("<" + id.toString() + ">");
            }
        }
    }
    /* flags */
    if ((rule.getFlags() & EventProcessingPolicyRule.STOP_PROCESSING) != 0) {
        // $NON-NLS-1$
        final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleAction#1");
        addActionGroupLabel(clientArea, Messages.get().RuleEditor_StopProcessing, editor.getImageStop(), listener);
    }
    return clientArea;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) Composite(org.eclipse.swt.widgets.Composite) AlarmCategory(org.netxms.client.events.AlarmCategory) ServerAction(org.netxms.client.ServerAction)

Aggregations

AlarmCategory (org.netxms.client.events.AlarmCategory)9 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 CLabel (org.eclipse.swt.custom.CLabel)1 MouseListener (org.eclipse.swt.events.MouseListener)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NXCSession (org.netxms.client.NXCSession)1 ServerAction (org.netxms.client.ServerAction)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 AlarmCategorySelectionDialog (org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmCategorySelectionDialog)1 AlarmCategoryEditor (org.netxms.ui.eclipse.alarmviewer.editors.AlarmCategoryEditor)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1