Implemented EPP rule sorting by rule number durring export. Fixes #NX-1345
authorEriks Jenkevics <eriks@netxms.org>
Wed, 25 Oct 2017 08:53:12 +0000 (11:53 +0300)
committerEriks Jenkevics <eriks@netxms.org>
Fri, 3 Nov 2017 13:43:03 +0000 (15:43 +0200)
18 files changed:
src/client/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/client/java/netxms-client/src/main/java/org/netxms/client/events/EventProcessingPolicyRule.java
src/java/netxms-eclipse/EPP/src/org/netxms/ui/eclipse/epp/dialogs/RuleSelectionDialog.java
src/java/netxms-eclipse/EPP/src/org/netxms/ui/eclipse/epp/dialogs/helpers/RuleComparator.java
src/java/netxms-eclipse/EPP/src/org/netxms/ui/eclipse/epp/dialogs/helpers/RuleLabelProvider.java
src/java/netxms-eclipse/EPP/src/org/netxms/ui/eclipse/epp/views/EventProcessingPolicyEditor.java
src/java/netxms-eclipse/EPP/src/org/netxms/ui/eclipse/epp/widgets/RuleEditor.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/ExportFileBuilder.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/RuleComparator.java
src/java/netxms-eclipse/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/RuleLabelProvider.java
webui/webapp/EPP/src/org/netxms/ui/eclipse/epp/dialogs/RuleSelectionDialog.java
webui/webapp/EPP/src/org/netxms/ui/eclipse/epp/dialogs/helpers/RuleComparator.java
webui/webapp/EPP/src/org/netxms/ui/eclipse/epp/dialogs/helpers/RuleLabelProvider.java
webui/webapp/EPP/src/org/netxms/ui/eclipse/epp/views/EventProcessingPolicyEditor.java
webui/webapp/EPP/src/org/netxms/ui/eclipse/epp/widgets/RuleEditor.java
webui/webapp/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/ExportFileBuilder.java
webui/webapp/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/RuleComparator.java
webui/webapp/ServerConfig/src/org/netxms/ui/eclipse/serverconfig/views/helpers/RuleLabelProvider.java

index fdef4c4..765ea60 100644 (file)
@@ -5816,7 +5816,7 @@ public class NXCSession
       for(int i = 0; i < numRules; i++)
       {
          response = waitForMessage(NXCPCodes.CMD_EPP_RECORD, msg.getMessageId());
-         policy.addRule(new EventProcessingPolicyRule(response));
+         policy.addRule(new EventProcessingPolicyRule(response, i+1));
       }
 
       return policy;
index 53958e5..aa25f8a 100644 (file)
@@ -66,6 +66,7 @@ public class EventProcessingPolicyRule
        private Map<String, String> persistentStorageSet;
        private List<String> persistentStorageDelete;
        private String comments;
+       private int ruleNumber;
        
        /**
         * Create empty rule
@@ -87,6 +88,7 @@ public class EventProcessingPolicyRule
                persistentStorageSet = new HashMap<String, String>(0);
                persistentStorageDelete = new ArrayList<String>(0);
                comments = "";
+          ruleNumber = 0;
        }
        
        /**
@@ -109,6 +111,7 @@ public class EventProcessingPolicyRule
                persistentStorageSet = new HashMap<String, String>(src.persistentStorageSet);
                persistentStorageDelete = new ArrayList<String>(src.persistentStorageDelete);
                comments = src.comments;
+               ruleNumber = src.ruleNumber;
        }
        
        /**
@@ -116,7 +119,7 @@ public class EventProcessingPolicyRule
         * 
         * @param msg NXCP message
         */
-       public EventProcessingPolicyRule(NXCPMessage msg)
+       public EventProcessingPolicyRule(NXCPMessage msg, int ruleNumber)
        {
                guid = msg.getFieldAsUUID(NXCPCodes.VID_GUID);
                sources = Arrays.asList(msg.getFieldAsUInt32ArrayEx(NXCPCodes.VID_RULE_SOURCES));
@@ -150,6 +153,7 @@ public class EventProcessingPolicyRule
          final String key = msg.getFieldAsString(varId++); 
          persistentStorageDelete.add(key);
       }
+      this.ruleNumber = ruleNumber;
        }
        
        /**
@@ -475,4 +479,22 @@ public class EventProcessingPolicyRule
        {
                return guid;
        }
+       
+       /**
+        * Get rule number
+        * @return rule number
+        */
+       public int getRuleNumber()
+       {
+          return ruleNumber;
+       }
+       
+       /**
+        * Set rule number
+        * @param ruleNumber to set
+        */
+       public void setRuleNumber(int ruleNumber)
+       {
+          this.ruleNumber = ruleNumber;
+       }
 }
index 6836250..2c27f54 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TableColumn;
 import org.netxms.client.NXCSession;
 import org.netxms.client.events.EventProcessingPolicy;
 import org.netxms.client.events.EventProcessingPolicyRule;
@@ -118,6 +119,17 @@ public class RuleSelectionDialog extends Dialog
                        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());
@@ -202,12 +214,11 @@ public class RuleSelectionDialog extends Dialog
        /* (non-Javadoc)
         * @see org.eclipse.jface.dialogs.Dialog#okPressed()
         */
-       @Override
+       @SuppressWarnings("unchecked")
+   @Override
        protected void okPressed()
        {
-               final IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
-               for(Object o : selection.toList())
-                       selectedRules.add((EventProcessingPolicyRule)o);
+          selectedRules = ((IStructuredSelection)viewer.getSelection()).toList();
                saveSettings();
                super.okPressed();
        }
index e066092..9376d91 100644 (file)
@@ -33,6 +33,6 @@ public class RuleComparator extends ViewerComparator
        @Override
        public int compare(Viewer viewer, Object e1, Object e2)
        {
-               return ((EventProcessingPolicyRule)e1).getComments().compareToIgnoreCase(((EventProcessingPolicyRule)e2).getComments());
+               return ((EventProcessingPolicyRule)e1).getRuleNumber() - ((EventProcessingPolicyRule)e2).getRuleNumber();
        }
 }
index 386d2b1..c1f5939 100644 (file)
@@ -43,17 +43,10 @@ public class RuleLabelProvider extends LabelProvider implements ITableLabelProvi
        @Override
        public String getColumnText(Object element, int columnIndex)
        {
-               if (columnIndex == 0)
-                       return getText(element);
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-        */
-       @Override
-       public String getText(Object element)
-       {
-               return ((EventProcessingPolicyRule)element).getComments();
+      if (columnIndex == 0)
+         return Integer.toString(((EventProcessingPolicyRule)element).getRuleNumber());
+      else if (columnIndex == 1)
+         return ((EventProcessingPolicyRule)element).getComments();
+      return null;
        }
 }
index 7343428..ebf507b 100644 (file)
@@ -533,12 +533,11 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
     */
    private void initPolicyEditor()
    {
-      int ruleNumber = 1;
       for(EventProcessingPolicyRule rule : policy.getRules())
       {
          if (isRuleVisible(rule))
          {
-            RuleEditor editor = new RuleEditor(dataArea, rule, ruleNumber++, this);
+            RuleEditor editor = new RuleEditor(dataArea, rule, this);
             editor.setDragDetect(true);
             ruleEditors.add(editor);
             GridData gd = new GridData();
@@ -546,10 +545,6 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
             gd.grabExcessHorizontalSpace = true;
             editor.setLayoutData(gd);
          }
-         else
-         {
-            ruleNumber++;
-         }
       }
       dataArea.layout();
 
@@ -1016,9 +1011,10 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
    private void insertRule(int position)
    {
       EventProcessingPolicyRule rule = new EventProcessingPolicyRule();
+      rule.setRuleNumber(position + 1);
       policy.insertRule(rule, position);
 
-      RuleEditor editor = new RuleEditor(dataArea, rule, position + 1, this);
+      RuleEditor editor = new RuleEditor(dataArea, rule, this);
       ruleEditors.add(position, editor);
       GridData gd = new GridData();
       gd.horizontalAlignment = SWT.FILL;
@@ -1105,9 +1101,10 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
 
       for(EventProcessingPolicyRule rule : clipboard.paste())
       {
+         rule.setRuleNumber(position + 1);
          policy.insertRule(rule, position);
 
-         RuleEditor editor = new RuleEditor(dataArea, rule, position + 1, this);
+         RuleEditor editor = new RuleEditor(dataArea, rule, this);
          ruleEditors.add(position, editor);
          GridData gd = new GridData();
          gd.horizontalAlignment = SWT.FILL;
@@ -1257,7 +1254,7 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
          }
          else if (e.isDisposed() && visible)
          {
-            e = new RuleEditor(dataArea, e.getRule(), e.getRuleNumber(), this);
+            e = new RuleEditor(dataArea, e.getRule(), this);
             GridData gd = new GridData();
             gd.horizontalAlignment = SWT.FILL;
             gd.grabExcessHorizontalSpace = true;
index 7cb1e31..6ca1be1 100644 (file)
@@ -114,11 +114,11 @@ public class RuleEditor extends Composite
     * @param parent
     * @param rule
     */
-   public RuleEditor(Composite parent, EventProcessingPolicyRule rule, int ruleNumber, EventProcessingPolicyEditor editor)
+   public RuleEditor(Composite parent, EventProcessingPolicyRule rule, EventProcessingPolicyEditor editor)
    {
       super(parent, SWT.NONE);
       this.rule = rule;
-      this.ruleNumber = ruleNumber;
+      this.ruleNumber = rule.getRuleNumber();
       this.editor = editor;
 
       session = (NXCSession)ConsoleSharedData.getSession();
index dc4c0d5..07748f3 100644 (file)
@@ -46,6 +46,7 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.ISaveablePart;
 import org.eclipse.ui.contexts.IContextService;
@@ -100,6 +101,7 @@ import org.netxms.ui.eclipse.serverconfig.views.helpers.ToolComparator;
 import org.netxms.ui.eclipse.serverconfig.views.helpers.ToolLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ObjectLabelComparator;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
 import org.netxms.ui.eclipse.widgets.LabeledText;
 
 /**
@@ -126,7 +128,7 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
        private Map<Long, EventObject> events = new HashMap<Long, EventObject>();
        private Map<Long, Template> templates = new HashMap<Long, Template>();
        private Map<Long, SnmpTrap> traps = new HashMap<Long, SnmpTrap>();
-       private Map<UUID, EventProcessingPolicyRule> rules = new HashMap<UUID, EventProcessingPolicyRule>();
+       private Map<Integer, EventProcessingPolicyRule> rules = new HashMap<Integer, EventProcessingPolicyRule>();
        private Map<Long, Script> scripts = new HashMap<Long, Script>();
        private Map<Long, ObjectTool> tools = new HashMap<Long, ObjectTool>();
    private Map<Integer, DciSummaryTableDescriptor> summaryTables = new HashMap<Integer, DciSummaryTableDescriptor>();
@@ -451,6 +453,17 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
                section.setClient(clientArea);
                
                ruleViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
+               ruleViewer.getTable().setLinesVisible(true);
+               ruleViewer.getTable().setHeaderVisible(true);
+
+      TableColumn column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
+      column.setText("Rule #");
+      column.setWidth(60);
+
+      column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
+      column.setText("Rule Name");
+      column.setWidth(250);
+      
                toolkit.adapt(ruleViewer.getTable());
                GridData gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
@@ -1293,7 +1306,7 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
                        final Set<Long> eventCodes = new HashSet<Long>();
                        for(EventProcessingPolicyRule r : dlg.getSelectedRules())
                        {
-                               rules.put(r.getGuid(), r);
+                               rules.put(r.getRuleNumber(), r);
                                for(Long e : r.getEvents())
                                {
                                        if (e >= 100000)
index 17e200c..51186ee 100644 (file)
@@ -33,6 +33,6 @@ public class RuleComparator extends ViewerComparator
        @Override
        public int compare(Viewer viewer, Object e1, Object e2)
        {
-               return ((EventProcessingPolicyRule)e1).getComments().compareToIgnoreCase(((EventProcessingPolicyRule)e2).getComments());
+      return ((EventProcessingPolicyRule)e1).getRuleNumber() - ((EventProcessingPolicyRule)e2).getRuleNumber();
        }
 }
index 4f1c14c..03f3a34 100644 (file)
@@ -43,17 +43,10 @@ public class RuleLabelProvider extends LabelProvider implements ITableLabelProvi
        @Override
        public String getColumnText(Object element, int columnIndex)
        {
-               if (columnIndex == 0)
-                       return getText(element);
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-        */
-       @Override
-       public String getText(Object element)
-       {
-               return ((EventProcessingPolicyRule)element).getComments();
+      if (columnIndex == 0)
+         return Integer.toString(((EventProcessingPolicyRule)element).getRuleNumber());
+      else if (columnIndex == 1)
+         return ((EventProcessingPolicyRule)element).getComments();
+      return null;
        }
 }
index 6836250..2c27f54 100644 (file)
@@ -38,6 +38,7 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TableColumn;
 import org.netxms.client.NXCSession;
 import org.netxms.client.events.EventProcessingPolicy;
 import org.netxms.client.events.EventProcessingPolicyRule;
@@ -118,6 +119,17 @@ public class RuleSelectionDialog extends Dialog
                        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());
@@ -202,12 +214,11 @@ public class RuleSelectionDialog extends Dialog
        /* (non-Javadoc)
         * @see org.eclipse.jface.dialogs.Dialog#okPressed()
         */
-       @Override
+       @SuppressWarnings("unchecked")
+   @Override
        protected void okPressed()
        {
-               final IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
-               for(Object o : selection.toList())
-                       selectedRules.add((EventProcessingPolicyRule)o);
+          selectedRules = ((IStructuredSelection)viewer.getSelection()).toList();
                saveSettings();
                super.okPressed();
        }
index e066092..9376d91 100644 (file)
@@ -33,6 +33,6 @@ public class RuleComparator extends ViewerComparator
        @Override
        public int compare(Viewer viewer, Object e1, Object e2)
        {
-               return ((EventProcessingPolicyRule)e1).getComments().compareToIgnoreCase(((EventProcessingPolicyRule)e2).getComments());
+               return ((EventProcessingPolicyRule)e1).getRuleNumber() - ((EventProcessingPolicyRule)e2).getRuleNumber();
        }
 }
index 386d2b1..c1f5939 100644 (file)
@@ -43,17 +43,10 @@ public class RuleLabelProvider extends LabelProvider implements ITableLabelProvi
        @Override
        public String getColumnText(Object element, int columnIndex)
        {
-               if (columnIndex == 0)
-                       return getText(element);
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-        */
-       @Override
-       public String getText(Object element)
-       {
-               return ((EventProcessingPolicyRule)element).getComments();
+      if (columnIndex == 0)
+         return Integer.toString(((EventProcessingPolicyRule)element).getRuleNumber());
+      else if (columnIndex == 1)
+         return ((EventProcessingPolicyRule)element).getComments();
+      return null;
        }
 }
index 7f18f08..1055ea4 100644 (file)
@@ -519,33 +519,28 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
                job.start();
        }
 
-       /**
-        * Init policy editor
-        */
-       private void initPolicyEditor()
-       {
-               int ruleNumber = 1;
-               for(EventProcessingPolicyRule rule : policy.getRules())
-               {
-                  if (isRuleVisible(rule))
-                  {
-            RuleEditor editor = new RuleEditor(dataArea, rule, ruleNumber++, this);
+   /**
+    * Init policy editor
+    */
+   private void initPolicyEditor()
+   {
+      for(EventProcessingPolicyRule rule : policy.getRules())
+      {
+         if (isRuleVisible(rule))
+         {
+            RuleEditor editor = new RuleEditor(dataArea, rule, this);
             ruleEditors.add(editor);
             GridData gd = new GridData();
             gd.horizontalAlignment = SWT.FILL;
             gd.grabExcessHorizontalSpace = true;
             editor.setLayoutData(gd);
          }
-                  else
-                  {
-                     ruleNumber++;
-                  }
-               }
-               dataArea.layout();
+      }
+      dataArea.layout();
 
-               Rectangle r = scroller.getClientArea();
-               scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
-       }
+      Rectangle r = scroller.getClientArea();
+      scroller.setMinSize(dataArea.computeSize(r.width, SWT.DEFAULT));
+   }
 
        /**
         * Update editor's layout
@@ -983,42 +978,43 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
                setModified(true);
        }
 
-       /**
-        * Insert new rule at given position
-        * 
-        * @param position
-        */
-       private void insertRule(int position)
-       {
-               EventProcessingPolicyRule rule = new EventProcessingPolicyRule();
-               policy.insertRule(rule, position);
+   /**
+    * Insert new rule at given position
+    * 
+    * @param position
+    */
+   private void insertRule(int position)
+   {
+      EventProcessingPolicyRule rule = new EventProcessingPolicyRule();
+      rule.setRuleNumber(position + 1);
+      policy.insertRule(rule, position);
 
-               RuleEditor editor = new RuleEditor(dataArea, rule, position + 1, this);
-               ruleEditors.add(position, editor);
-               GridData gd = new GridData();
-               gd.horizontalAlignment = SWT.FILL;
-               gd.grabExcessHorizontalSpace = true;
-               editor.setLayoutData(gd);
+      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);
 
-               for(int i = position + 1; i < ruleEditors.size(); i++)
-                       ruleEditors.get(i).setRuleNumber(i + 1);
+      for(int i = position + 1; i < ruleEditors.size(); i++)
+         ruleEditors.get(i).setRuleNumber(i + 1);
 
-               if (position < ruleEditors.size() - 1)
-               {
-                  RuleEditor anchor = null;
-             for(int i = position + 1; i < ruleEditors.size(); i++)
-                if (!ruleEditors.get(i).isDisposed())
-                {
-                   anchor = ruleEditors.get(i);
-                   break;
-                }
-             if (anchor != null)
-                editor.moveAbove(anchor);
-               }
-               updateEditorAreaLayout();
+      if (position < ruleEditors.size() - 1)
+      {
+         RuleEditor anchor = null;
+         for(int i = position + 1; i < ruleEditors.size(); i++)
+            if (!ruleEditors.get(i).isDisposed())
+            {
+               anchor = ruleEditors.get(i);
+               break;
+            }
+         if (anchor != null)
+            editor.moveAbove(anchor);
+      }
+      updateEditorAreaLayout();
 
-               setModified(true);
-       }
+      setModified(true);
+   }
 
        /**
         * Cut selected rules to internal clipboard
@@ -1060,14 +1056,14 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
                        clipboard.add(new EventProcessingPolicyRule(e.getRule()));
        }
 
-       /**
-        * Paste rules from internal clipboard
-        */
-       private void pasteRules()
-       {
-               int position = lastSelectedRule;
+   /**
+    * Paste rules from internal clipboard
+    */
+   private void pasteRules()
+   {
+      int position = lastSelectedRule;
 
-               RuleEditor anchor = null;
+      RuleEditor anchor = null;
       if (position < ruleEditors.size() - 1)
       {
          for(int i = position; i < ruleEditors.size(); i++)
@@ -1077,12 +1073,13 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
                break;
             }
       }
-               
+
       for(EventProcessingPolicyRule rule : clipboard.paste())
                {
+         rule.setRuleNumber(position + 1);
                        policy.insertRule(rule, position);
 
-                       RuleEditor editor = new RuleEditor(dataArea, rule, position + 1, this);
+                       RuleEditor editor = new RuleEditor(dataArea, rule, this);
                        ruleEditors.add(position, editor);
                        GridData gd = new GridData();
                        gd.horizontalAlignment = SWT.FILL;
@@ -1218,7 +1215,7 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
    private void onFilterModify()
    {
       filterText = filterControl.getText().trim().toLowerCase();
-      
+
       // change editors visibility
       RuleEditor prev = null;
       for(int i = 0; i < ruleEditors.size(); i++)
@@ -1232,7 +1229,7 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
          }
          else if (e.isDisposed() && visible)
          {
-            e = new RuleEditor(dataArea, e.getRule(), e.getRuleNumber(), this);
+            e = new RuleEditor(dataArea, e.getRule(), this);
             GridData gd = new GridData();
             gd.horizontalAlignment = SWT.FILL;
             gd.grabExcessHorizontalSpace = true;
@@ -1246,10 +1243,10 @@ public class EventProcessingPolicyEditor extends ViewPart implements ISaveablePa
          if (!e.isDisposed())
             prev = e;
       }
-      
+
       updateEditorAreaLayout();
    }
-   
+
    /**
     * Check if given rule should be visible
     * 
index 4d457e2..9987e2c 100644 (file)
@@ -114,11 +114,11 @@ public class RuleEditor extends Composite
     * @param parent
     * @param rule
     */
-   public RuleEditor(Composite parent, EventProcessingPolicyRule rule, int ruleNumber, EventProcessingPolicyEditor editor)
+   public RuleEditor(Composite parent, EventProcessingPolicyRule rule, EventProcessingPolicyEditor editor)
    {
       super(parent, SWT.NONE);
       this.rule = rule;
-      this.ruleNumber = ruleNumber;
+      this.ruleNumber = rule.getRuleNumber();
       this.editor = editor;
 
       session = (NXCSession)ConsoleSharedData.getSession();
index b1bfff8..9263d6a 100644 (file)
@@ -46,6 +46,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.ISaveablePart;
 import org.eclipse.ui.contexts.IContextService;
@@ -127,7 +128,7 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
        private Map<Long, EventObject> events = new HashMap<Long, EventObject>();
        private Map<Long, Template> templates = new HashMap<Long, Template>();
        private Map<Long, SnmpTrap> traps = new HashMap<Long, SnmpTrap>();
-       private Map<UUID, EventProcessingPolicyRule> rules = new HashMap<UUID, EventProcessingPolicyRule>();
+       private Map<Integer, EventProcessingPolicyRule> rules = new HashMap<Integer, EventProcessingPolicyRule>();
        private Map<Long, Script> scripts = new HashMap<Long, Script>();
        private Map<Long, ObjectTool> tools = new HashMap<Long, ObjectTool>();
    private Map<Integer, DciSummaryTableDescriptor> summaryTables = new HashMap<Integer, DciSummaryTableDescriptor>();
@@ -451,6 +452,17 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
                section.setClient(clientArea);
                
                ruleViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
+               ruleViewer.getTable().setLinesVisible(true);
+               ruleViewer.getTable().setHeaderVisible(true);
+
+      TableColumn column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
+      column.setText("Rule #");
+      column.setWidth(60);
+
+      column = new TableColumn(ruleViewer.getTable(), SWT.LEFT);
+      column.setText("Rule Name");
+      column.setWidth(250);
+      
                toolkit.adapt(ruleViewer.getTable());
                GridData gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
@@ -1286,7 +1298,7 @@ public class ExportFileBuilder extends ViewPart implements ISaveablePart
                        final Set<Long> eventCodes = new HashSet<Long>();
                        for(EventProcessingPolicyRule r : dlg.getSelectedRules())
                        {
-                               rules.put(r.getGuid(), r);
+                               rules.put(r.getRuleNumber(), r);
                                for(Long e : r.getEvents())
                                {
                                        if (e >= 100000)
index 17e200c..51186ee 100644 (file)
@@ -33,6 +33,6 @@ public class RuleComparator extends ViewerComparator
        @Override
        public int compare(Viewer viewer, Object e1, Object e2)
        {
-               return ((EventProcessingPolicyRule)e1).getComments().compareToIgnoreCase(((EventProcessingPolicyRule)e2).getComments());
+      return ((EventProcessingPolicyRule)e1).getRuleNumber() - ((EventProcessingPolicyRule)e2).getRuleNumber();
        }
 }
index 4f1c14c..03f3a34 100644 (file)
@@ -43,17 +43,10 @@ public class RuleLabelProvider extends LabelProvider implements ITableLabelProvi
        @Override
        public String getColumnText(Object element, int columnIndex)
        {
-               if (columnIndex == 0)
-                       return getText(element);
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-        */
-       @Override
-       public String getText(Object element)
-       {
-               return ((EventProcessingPolicyRule)element).getComments();
+      if (columnIndex == 0)
+         return Integer.toString(((EventProcessingPolicyRule)element).getRuleNumber());
+      else if (columnIndex == 1)
+         return ((EventProcessingPolicyRule)element).getComments();
+      return null;
        }
 }