Search in sources :

Example 11 with RuleEditor

use of org.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.

the class EventProcessingPolicyEditor method deleteSelectedRules.

/**
 * Delete selected rules
 */
private void deleteSelectedRules() {
    for (RuleEditor e : selection) {
        policy.deleteRule(e.getRule());
        ruleEditors.remove(e);
        e.dispose();
    }
    // Renumber rules
    for (int i = 0; i < ruleEditors.size(); i++) ruleEditors.get(i).setRuleNumber(i + 1);
    selection.clear();
    lastSelectedRule = -1;
    onSelectionChange();
    updateEditorAreaLayout();
    setModified(true);
}
Also used : RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Example 12 with RuleEditor

use of org.netxms.ui.eclipse.epp.widgets.RuleEditor in project netxms by netxms.

the class EventProcessingPolicyEditor method pasteRules.

/**
 * Paste rules from internal clipboard
 */
private void pasteRules() {
    int position = lastSelectedRule;
    RuleEditor anchor = null;
    if (position < ruleEditors.size() - 1) {
        for (int i = position; i < ruleEditors.size(); i++) if (!ruleEditors.get(i).isDisposed()) {
            anchor = ruleEditors.get(i);
            break;
        }
    }
    for (EventProcessingPolicyRule rule : clipboard.paste()) {
        rule.setRuleNumber(position + 1);
        policy.insertRule(rule, position);
        RuleEditor editor = new RuleEditor(dataArea, rule, this);
        ruleEditors.add(position, editor);
        GridData gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        editor.setLayoutData(gd);
        if (anchor != null)
            editor.moveAbove(anchor);
        position++;
    }
    for (int i = position; i < ruleEditors.size(); i++) ruleEditors.get(i).setRuleNumber(i + 1);
    updateEditorAreaLayout();
    setModified(true);
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) GridData(org.eclipse.swt.layout.GridData) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Aggregations

RuleEditor (org.netxms.ui.eclipse.epp.widgets.RuleEditor)12 GridData (org.eclipse.swt.layout.GridData)4 EventProcessingPolicyRule (org.netxms.client.events.EventProcessingPolicyRule)4 Rectangle (org.eclipse.swt.graphics.Rectangle)2 EventProcessingPolicy (org.netxms.client.events.EventProcessingPolicy)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Action (org.eclipse.jface.action.Action)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1