use of org.netxms.client.events.EventProcessingPolicy in project netxms by netxms.
the class EventProcessingPolicyEditor method moveSelection.
/**
* Moves rule selection
*
* @param anchor - where the selection is being moved
*/
public void moveSelection(RuleEditor anchor) {
if (selection.contains(anchor)) {
for (RuleEditor s : selection) s.setDragged(false);
return;
}
List<RuleEditor> movedRuleEditors = new ArrayList<RuleEditor>();
for (RuleEditor e : ruleEditors) {
if (!selection.contains(e)) {
movedRuleEditors.add(e);
if (e.equals(anchor)) {
RuleEditor curr = anchor;
for (RuleEditor s : selection) {
movedRuleEditors.add(s);
s.moveBelow(curr);
curr = s;
s.setDragged(false);
}
}
}
}
policy = new EventProcessingPolicy(movedRuleEditors.size());
int i = 0;
for (RuleEditor e : movedRuleEditors) {
policy.addRule(e.getRule());
e.setRuleNumber(++i);
}
ruleEditors = movedRuleEditors;
anchor.setDragged(false);
updateEditorAreaLayout();
setModified(true);
}
use of org.netxms.client.events.EventProcessingPolicy in project netxms by netxms.
the class EventProcessingPolicyEditor method savePolicy.
/**
* Save policy to server
*/
private void savePolicy() {
actionSave.setEnabled(false);
new ConsoleJob(Messages.get().EventProcessingPolicyEditor_SaveJob_Title, this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
EventProcessingPolicy newPolicy = new EventProcessingPolicy(ruleEditors.size());
for (RuleEditor editor : ruleEditors) newPolicy.addRule(editor.getRule());
session.saveEventProcessingPolicy(policy);
runInUIThread(new Runnable() {
@Override
public void run() {
modified = false;
firePropertyChange(PROP_DIRTY);
}
});
}
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
actionSave.setEnabled(modified);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().EventProcessingPolicyEditor_SaveJob_Error;
}
}.start();
}
use of org.netxms.client.events.EventProcessingPolicy in project netxms by netxms.
the class NXCSession method getEventProcessingPolicyInternal.
/**
* Internal implementation for open/get event processing policy.
*
* @param readOnly true to get read-only copy of the policy
* @return Event processing policy
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
private EventProcessingPolicy getEventProcessingPolicyInternal(boolean readOnly) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_OPEN_EPP);
msg.setFieldInt16(NXCPCodes.VID_READ_ONLY, readOnly ? 1 : 0);
sendMessage(msg);
NXCPMessage response = waitForRCC(msg.getMessageId());
int numRules = response.getFieldAsInt32(NXCPCodes.VID_NUM_RULES);
final EventProcessingPolicy policy = new EventProcessingPolicy(numRules);
for (int i = 0; i < numRules; i++) {
response = waitForMessage(NXCPCodes.CMD_EPP_RECORD, msg.getMessageId());
policy.addRule(new EventProcessingPolicyRule(response, i + 1));
}
return policy;
}
use of org.netxms.client.events.EventProcessingPolicy in project netxms by netxms.
the class EventProcessingPolicyTest method testGetPolicy.
public void testGetPolicy() throws Exception {
final NXCSession session = connect();
EventProcessingPolicy p = session.getEventProcessingPolicy();
for (EventProcessingPolicyRule r : p.getRules()) System.out.println(" " + r.getGuid() + " " + r.getComments());
session.disconnect();
}
use of org.netxms.client.events.EventProcessingPolicy in project netxms by netxms.
the class RuleSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
layout.numColumns = 2;
dialogArea.setLayout(layout);
filterText = new FilterText(dialogArea, SWT.NONE, null, false);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
filterText.setLayoutData(gd);
// $NON-NLS-1$
final String filterString = settings.get("SelectRule.Filter");
if (filterString != null)
filterText.setText(filterString);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | (multiSelection ? SWT.MULTI : SWT.SINGLE) | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableColumn column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("Rule #");
column.setWidth(60);
column = new TableColumn(viewer.getTable(), SWT.LEFT);
column.setText("Rule Name");
column.setWidth(250);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new RuleComparator());
viewer.setLabelProvider(new RuleLabelProvider());
filter = new RuleListFilter();
if (filterString != null)
filter.setFilterString(filterString);
viewer.addFilter(filter);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 350;
viewer.getTable().setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
viewer.refresh();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
RuleSelectionDialog.this.okPressed();
}
});
if (rulesCache == null) {
viewer.getTable().setEnabled(false);
getButton(IDialogConstants.OK_ID).setEnabled(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().RuleSelectionDialog_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final EventProcessingPolicy policy = session.getEventProcessingPolicy();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.getTable().setEnabled(true);
getButton(IDialogConstants.OK_ID).setEnabled(true);
viewer.setInput(policy.getRules().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().RuleSelectionDialog_JobError;
}
};
job.setUser(false);
job.start();
} else {
viewer.setInput(rulesCache.toArray());
}
return dialogArea;
}
Aggregations