Search in sources :

Example 1 with AlarmCategory

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

the class NXCSession method syncAlarmCategories.

/**
 * Synchronize alarm category configuration. After call to this method
 * session object will maintain internal list of configured alarm categories
 *
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void syncAlarmCategories() throws IOException, NXCException {
    List<AlarmCategory> categories = getAlarmCategories();
    synchronized (alarmCategories) {
        alarmCategories.clear();
        for (AlarmCategory c : categories) {
            alarmCategories.put(c.getId(), c);
        }
        alarmCategoriesNeedSync = true;
    }
}
Also used : AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 2 with AlarmCategory

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

the class NXCSession method getAlarmCategories.

/**
 * Get alarm categories from server
 *
 * @return List of configured alarm categories
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<AlarmCategory> getAlarmCategories() throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_ALARM_CATEGORIES);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    ArrayList<AlarmCategory> list = new ArrayList<AlarmCategory>();
    long fieldId = NXCPCodes.VID_ELEMENT_LIST_BASE;
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
    for (int i = 0; i < count; i++) {
        list.add(new AlarmCategory(response, fieldId));
        fieldId += 10;
    }
    return list;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) AlarmCategory(org.netxms.client.events.AlarmCategory) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 3 with AlarmCategory

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

the class General method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    final String newName = textName.getText();
    final String newDescription = textDescription.getText();
    if (newName.equals("")) {
        MessageDialogHelper.openError(getShell(), "Error", "Category name cannot be empty!");
        return false;
    }
    if (newName.equals(category.getName()) && newDescription.equals(category.getDescription()))
        // Nothing to apply
        return true;
    if (!newName.equals(category.getName())) {
        AlarmCategory c = session.findAlarmCategoryByName(newName);
        if (c != null) {
            MessageDialogHelper.openError(getShell(), "Error", "Category name already exists!");
            return false;
        }
        category.setName(newName);
    }
    category.setDescription(newDescription);
    editor.modify();
    return true;
}
Also used : AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 4 with AlarmCategory

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

the class AlarmCategorySelectionDialog method okPressed.

@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
    final IStructuredSelection selection = (IStructuredSelection) alarmCategoryList.getSelection();
    final List<AlarmCategory> list = selection.toList();
    selectedEvents = list.toArray(new AlarmCategory[list.size()]);
    saveSettings();
    super.okPressed();
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AlarmCategory(org.netxms.client.events.AlarmCategory)

Example 5 with AlarmCategory

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

the class AlarmCategorySelector method selectionButtonHandler.

/*
    * (non-Javadoc)
    * 
    * @see org.netxms.ui.eclipse.widgets.AbstractSelector#selectionButtonHandler()
    */
@Override
protected void selectionButtonHandler() {
    AlarmCategorySelectionDialog dlg = new AlarmCategorySelectionDialog(getShell());
    if (dlg.open() == Window.OK) {
        categoryId.clear();
        AlarmCategory[] categories = dlg.getSelectedCategories();
        if ((categories != null) && (categories.length > 0)) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < categories.length; i++) {
                categoryId.add(categories[i].getId());
                sb.append(categories[i].getName() + "; ");
            }
            setText(sb.toString());
        } else {
            setText("<none>");
        }
    }
}
Also used : AlarmCategorySelectionDialog(org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmCategorySelectionDialog) AlarmCategory(org.netxms.client.events.AlarmCategory)

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