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;
}
}
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;
}
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;
}
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();
}
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>");
}
}
}
Aggregations