Search in sources :

Example 1 with RuleEditor

use of org.netxms.ui.eclipse.epp.widgets.RuleEditor 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);
}
Also used : EventProcessingPolicy(org.netxms.client.events.EventProcessingPolicy) ArrayList(java.util.ArrayList) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Example 2 with RuleEditor

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

the class EventProcessingPolicyEditor method cutRules.

/**
 * Cut selected rules to internal clipboard
 */
private void cutRules() {
    clipboard.clear();
    actionPaste.setEnabled(true);
    for (RuleEditor e : selection) {
        clipboard.add(e.getRule());
        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 3 with RuleEditor

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

the class EventProcessingPolicyEditor method onFilterModify.

/**
 * Handler for filter modification
 */
private void onFilterModify() {
    filterText = filterControl.getText().trim().toLowerCase();
    // change editors visibility
    RuleEditor prev = null;
    for (int i = 0; i < ruleEditors.size(); i++) {
        RuleEditor e = ruleEditors.get(i);
        boolean visible = isRuleVisible(e.getRule());
        if (!e.isDisposed() && !visible) {
            e.dispose();
            selection.remove(e);
        } else if (e.isDisposed() && visible) {
            e = new RuleEditor(dataArea, e.getRule(), this);
            GridData gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            e.setLayoutData(gd);
            if (prev != null)
                e.moveBelow(prev);
            else
                e.moveAbove(null);
            ruleEditors.set(i, e);
        }
        if (!e.isDisposed())
            prev = e;
    }
    updateEditorAreaLayout();
}
Also used : GridData(org.eclipse.swt.layout.GridData) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Example 4 with RuleEditor

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

the class EventProcessingPolicyEditor method copyRules.

/**
 * Copy selected rules to internal clipboard
 */
private void copyRules() {
    clipboard.clear();
    actionPaste.setEnabled(true);
    for (RuleEditor e : selection) clipboard.add(new EventProcessingPolicyRule(e.getRule()));
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Example 5 with RuleEditor

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

the class EventProcessingPolicyEditor method clearSelection.

/**
 * Clear selection
 */
private void clearSelection() {
    for (RuleEditor e : selection) e.setSelected(false);
    selection.clear();
    lastSelectedRule = -1;
}
Also used : 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