DCI property page "Visibility" renamed to "Access COntrol"; fixed property page layou...
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 12 Nov 2017 16:29:27 +0000 (18:29 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 12 Nov 2017 16:29:27 +0000 (18:29 +0200)
src/client/java/netxms-client/src/main/java/org/netxms/client/datacollection/DataCollectionObject.java
src/java/netxms-eclipse/DataCollection/plugin.xml
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/AccessControl.java [moved from webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/VisibilityControl.java with 87% similarity]
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/helpers/AccessListLabelProvider.java [moved from webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/helpers/VisibilityUserListLabelProvider.java with 60% similarity]
webui/webapp/DataCollection/plugin.xml
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/AccessControl.java [moved from src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/VisibilityControl.java with 87% similarity]
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/helpers/AccessListLabelProvider.java [moved from src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/helpers/VisibilityUserListLabelProvider.java with 60% similarity]

index a45e962..3ff8191 100644 (file)
@@ -101,7 +101,7 @@ public abstract class DataCollectionObject
    private int instanceDiscoveryMethod;
    private String instanceDiscoveryData;
    private String instanceDiscoveryFilter;
-   private List<Long> accessRightList;
+   private List<Long> accessList;
 
        /**
         * Create data collection object from NXCP message
@@ -144,9 +144,9 @@ public abstract class DataCollectionObject
 
       Long arr[] = msg.getFieldAsUInt32ArrayEx(NXCPCodes.VID_ACL);
       if(arr == null)
-         accessRightList = new ArrayList<Long>(0);
+         accessList = new ArrayList<Long>(0);
       else
-         accessRightList = new ArrayList<Long>(Arrays.asList(arr));
+         accessList = new ArrayList<Long>(Arrays.asList(arr));
        }
 
        /**
@@ -176,7 +176,7 @@ public abstract class DataCollectionObject
                schedules = new ArrayList<String>(0);
                comments = "";
       instance = "";
-      accessRightList = new ArrayList<Long>(0);
+      accessList = new ArrayList<Long>(0);
        }
        
        /**
@@ -217,7 +217,7 @@ public abstract class DataCollectionObject
       if (instanceDiscoveryFilter != null)
          msg.setField(NXCPCodes.VID_INSTD_FILTER, instanceDiscoveryFilter);
       
-      msg.setField(NXCPCodes.VID_ACL, accessRightList.toArray(new Long[accessRightList.size()]));
+      msg.setField(NXCPCodes.VID_ACL, accessList.toArray(new Long[accessList.size()]));
        }
 
        /**
@@ -715,13 +715,23 @@ public abstract class DataCollectionObject
       this.instanceDiscoveryFilter = instanceDiscoveryFilter;
    }
 
+   /**
+    * Get data collection object access list
+    * 
+    * @return access list
+    */
    public List<Long> getAccessList()
    {
-      return accessRightList;
+      return accessList;
    }
 
+   /**
+    * Set data collection object access list
+    * 
+    * @param list new access list
+    */
    public void setAccessList(List<Long> list)
    {
-      accessRightList = list;
+      accessList = list;
    }
 }
index dd36b9b..77896c7 100644 (file)
         </page>
         <page
               class="org.netxms.ui.eclipse.datacollection.propertypages.OtherOptions"
-              id="org.netxms.ui.eclipse.datacollection.propertypages.NetworkMaps#110"
+              id="org.netxms.ui.eclipse.datacollection.propertypages.NetworkMaps#200"
               name="%page.name.OtherOptions">
            <enabledWhen>
               <instanceof
            </enabledWhen>
         </page>
         <page
-              class="org.netxms.ui.eclipse.datacollection.propertypages.VisibilityControl"
-              id="org.netxms.ui.eclipse.datacollection.propertypages.InstanceDiscovery#50"
-              name="Visibility">
+              class="org.netxms.ui.eclipse.datacollection.propertypages.AccessControl"
+              id="org.netxms.ui.eclipse.datacollection.propertypages.AccessControl#120"
+              name="Access Control">
            <enabledWhen>
               <instanceof
                     value="org.netxms.client.datacollection.DataCollectionObject">
@@ -43,9 +43,8 @@ import org.netxms.client.NXCSession;
 import org.netxms.client.datacollection.DataCollectionObject;
 import org.netxms.client.users.AbstractUserObject;
 import org.netxms.client.users.User;
-import org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor;
+import org.netxms.ui.eclipse.datacollection.propertypages.helpers.AccessListLabelProvider;
 import org.netxms.ui.eclipse.datacollection.propertypages.helpers.DCIPropertyPageDialog;
-import org.netxms.ui.eclipse.datacollection.propertypages.helpers.VisibilityUserListLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ObjectLabelComparator;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
@@ -54,9 +53,8 @@ import org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog;
 /**
  * "Access Control" property page
  */
-public class VisibilityControl extends DCIPropertyPageDialog
+public class AccessControl extends DCIPropertyPageDialog
 {
-   private DataCollectionObjectEditor editor;
    private DataCollectionObject dco;
        private Set<AbstractUserObject> acl = new HashSet<AbstractUserObject>();
        private TableViewer viewer;
@@ -65,22 +63,12 @@ public class VisibilityControl extends DCIPropertyPageDialog
        private static final String info[] = {"Inherited from object access rights"};
        
        /* (non-Javadoc)
-        * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
-        */
-       @Override
-       public void createControl(Composite parent)
-       {
-               noDefaultAndApplyButton();
-               super.createControl(parent);
-       }
-       
-       /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
         */
        @Override
        protected Control createContents(Composite parent)
        {
-      editor = (DataCollectionObjectEditor)getElement().getAdapter(DataCollectionObjectEditor.class);
+      Composite dialogArea = (Composite)super.createContents(parent);
       dco = editor.getObject();      
 
       // Initiate loading of user manager plugin if it was not loaded before
@@ -95,8 +83,6 @@ public class VisibilityControl extends DCIPropertyPageDialog
                                acl.add(o);
                }
                
-               Composite dialogArea = new Composite(parent, SWT.NONE);
-               
                GridLayout layout = new GridLayout();
                layout.verticalSpacing = WidgetHelper.INNER_SPACING;
                layout.marginWidth = 0;
@@ -104,11 +90,11 @@ public class VisibilityControl extends DCIPropertyPageDialog
                dialogArea.setLayout(layout);
                
                Label label = new Label(dialogArea, SWT.NONE);
-               label.setText("Visible to:");
+               label.setText("Restrict access to the following users");
                
                viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
                viewer.setContentProvider(new ArrayContentProvider());
-               viewer.setLabelProvider(new VisibilityUserListLabelProvider());
+               viewer.setLabelProvider(new AccessListLabelProvider());
                viewer.setComparator(new ObjectLabelComparator((ILabelProvider)viewer.getLabelProvider()));
                viewer.getTable().setSortDirection(SWT.UP);
                GridData gd = new GridData();
@@ -118,8 +104,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                gd.grabExcessVerticalSpace = true;
                gd.heightHint = 300;
                viewer.getTable().setLayoutData(gd);
-               viewer.setInput(acl.toArray());
-               updateInfoNote();
+               setViewerInput();
                
       Composite buttons = new Composite(dialogArea, SWT.NONE);
       RowLayout buttonLayout = new RowLayout();
@@ -174,14 +159,14 @@ public class VisibilityControl extends DCIPropertyPageDialog
        }
        
        /**
-        * Adds info element to the list if empty
+        * Set viewer input
         */
-       public void updateInfoNote()
+       private void setViewerInput()
        {
-      if(acl.size() == 0)
-      {
+      if (acl.isEmpty())
          viewer.setInput(info);
-      }
+      else
+         viewer.setInput(acl.toArray());
        }
        
        /**
@@ -194,7 +179,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                {
                        for(AbstractUserObject o : dlg.getSelection())
                                acl.add(o);
-                       viewer.setInput(acl.toArray());
+                       setViewerInput();
                }
        }
        
@@ -206,8 +191,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
                for(Object o : selection.toList())
                        acl.remove(o);
-               viewer.setInput(acl.toArray());
-               updateInfoNote();
+      setViewerInput();
        }
        
        /**
@@ -241,4 +225,14 @@ public class VisibilityControl extends DCIPropertyPageDialog
                applyChanges(false);
                return true;
        }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+    */
+   @Override
+   protected void performDefaults()
+   {
+      acl.clear();
+      setViewerInput();
+   }
 }
@@ -1,7 +1,10 @@
 package org.netxms.ui.eclipse.datacollection.propertypages.helpers;
 
+import org.eclipse.jface.viewers.IColorProvider;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
 
 /**
@@ -9,14 +12,16 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
  * Uses default workbench label provider for user object and 
  * implements own for String like with warning. 
  */
-public class VisibilityUserListLabelProvider extends LabelProvider
+public class AccessListLabelProvider extends LabelProvider implements IColorProvider
 {
+   private static final Color HINT_FOREGROUND = new Color(Display.getDefault(), 192, 192, 192);
+   
    private WorkbenchLabelProvider workbenchLabelProvider;
    
    /**
     * Default constructor
     */
-   public VisibilityUserListLabelProvider()
+   public AccessListLabelProvider()
    {
       workbenchLabelProvider = new WorkbenchLabelProvider();
    }    
@@ -27,7 +32,7 @@ public class VisibilityUserListLabelProvider extends LabelProvider
    @Override
    public Image getImage(Object element)
    {
-      if(element instanceof String)
+      if (element instanceof String)
          return null;
       return workbenchLabelProvider.getImage(element);
    }
@@ -52,4 +57,24 @@ public class VisibilityUserListLabelProvider extends LabelProvider
       workbenchLabelProvider.dispose();
       super.dispose();
    }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+    */
+   @Override
+   public Color getForeground(Object element)
+   {
+      if (element instanceof String)
+         return HINT_FOREGROUND;
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+    */
+   @Override
+   public Color getBackground(Object element)
+   {
+      return null;
+   }
 }
index dd36b9b..77896c7 100644 (file)
         </page>
         <page
               class="org.netxms.ui.eclipse.datacollection.propertypages.OtherOptions"
-              id="org.netxms.ui.eclipse.datacollection.propertypages.NetworkMaps#110"
+              id="org.netxms.ui.eclipse.datacollection.propertypages.NetworkMaps#200"
               name="%page.name.OtherOptions">
            <enabledWhen>
               <instanceof
            </enabledWhen>
         </page>
         <page
-              class="org.netxms.ui.eclipse.datacollection.propertypages.VisibilityControl"
-              id="org.netxms.ui.eclipse.datacollection.propertypages.InstanceDiscovery#50"
-              name="Visibility">
+              class="org.netxms.ui.eclipse.datacollection.propertypages.AccessControl"
+              id="org.netxms.ui.eclipse.datacollection.propertypages.AccessControl#120"
+              name="Access Control">
            <enabledWhen>
               <instanceof
                     value="org.netxms.client.datacollection.DataCollectionObject">
@@ -43,9 +43,8 @@ import org.netxms.client.NXCSession;
 import org.netxms.client.datacollection.DataCollectionObject;
 import org.netxms.client.users.AbstractUserObject;
 import org.netxms.client.users.User;
-import org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor;
+import org.netxms.ui.eclipse.datacollection.propertypages.helpers.AccessListLabelProvider;
 import org.netxms.ui.eclipse.datacollection.propertypages.helpers.DCIPropertyPageDialog;
-import org.netxms.ui.eclipse.datacollection.propertypages.helpers.VisibilityUserListLabelProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.ObjectLabelComparator;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
@@ -54,9 +53,8 @@ import org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog;
 /**
  * "Access Control" property page
  */
-public class VisibilityControl extends DCIPropertyPageDialog
+public class AccessControl extends DCIPropertyPageDialog
 {
-   private DataCollectionObjectEditor editor;
    private DataCollectionObject dco;
        private Set<AbstractUserObject> acl = new HashSet<AbstractUserObject>();
        private TableViewer viewer;
@@ -65,22 +63,12 @@ public class VisibilityControl extends DCIPropertyPageDialog
        private static final String info[] = {"Inherited from object access rights"};
        
        /* (non-Javadoc)
-        * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
-        */
-       @Override
-       public void createControl(Composite parent)
-       {
-               noDefaultAndApplyButton();
-               super.createControl(parent);
-       }
-       
-       /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
         */
        @Override
        protected Control createContents(Composite parent)
        {
-      editor = (DataCollectionObjectEditor)getElement().getAdapter(DataCollectionObjectEditor.class);
+      Composite dialogArea = (Composite)super.createContents(parent);
       dco = editor.getObject();      
 
       // Initiate loading of user manager plugin if it was not loaded before
@@ -95,8 +83,6 @@ public class VisibilityControl extends DCIPropertyPageDialog
                                acl.add(o);
                }
                
-               Composite dialogArea = new Composite(parent, SWT.NONE);
-               
                GridLayout layout = new GridLayout();
                layout.verticalSpacing = WidgetHelper.INNER_SPACING;
                layout.marginWidth = 0;
@@ -104,11 +90,11 @@ public class VisibilityControl extends DCIPropertyPageDialog
                dialogArea.setLayout(layout);
                
                Label label = new Label(dialogArea, SWT.NONE);
-               label.setText("Visible to:");
+               label.setText("Restrict access to the following users");
                
                viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
                viewer.setContentProvider(new ArrayContentProvider());
-               viewer.setLabelProvider(new VisibilityUserListLabelProvider());
+               viewer.setLabelProvider(new AccessListLabelProvider());
                viewer.setComparator(new ObjectLabelComparator((ILabelProvider)viewer.getLabelProvider()));
                viewer.getTable().setSortDirection(SWT.UP);
                GridData gd = new GridData();
@@ -118,8 +104,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                gd.grabExcessVerticalSpace = true;
                gd.heightHint = 300;
                viewer.getTable().setLayoutData(gd);
-               viewer.setInput(acl.toArray());
-               updateInfoNote();
+               setViewerInput();
                
       Composite buttons = new Composite(dialogArea, SWT.NONE);
       RowLayout buttonLayout = new RowLayout();
@@ -174,14 +159,14 @@ public class VisibilityControl extends DCIPropertyPageDialog
        }
        
        /**
-        * Adds info element to the list if empty
+        * Set viewer input
         */
-       public void updateInfoNote()
+       private void setViewerInput()
        {
-      if(acl.size() == 0)
-      {
+      if (acl.isEmpty())
          viewer.setInput(info);
-      }
+      else
+         viewer.setInput(acl.toArray());
        }
        
        /**
@@ -194,7 +179,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                {
                        for(AbstractUserObject o : dlg.getSelection())
                                acl.add(o);
-                       viewer.setInput(acl.toArray());
+                       setViewerInput();
                }
        }
        
@@ -206,8 +191,7 @@ public class VisibilityControl extends DCIPropertyPageDialog
                IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
                for(Object o : selection.toList())
                        acl.remove(o);
-               viewer.setInput(acl.toArray());
-               updateInfoNote();
+      setViewerInput();
        }
        
        /**
@@ -241,4 +225,14 @@ public class VisibilityControl extends DCIPropertyPageDialog
                applyChanges(false);
                return true;
        }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+    */
+   @Override
+   protected void performDefaults()
+   {
+      acl.clear();
+      setViewerInput();
+   }
 }
@@ -1,7 +1,10 @@
 package org.netxms.ui.eclipse.datacollection.propertypages.helpers;
 
+import org.eclipse.jface.viewers.IColorProvider;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
 
 /**
@@ -9,14 +12,16 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
  * Uses default workbench label provider for user object and 
  * implements own for String like with warning. 
  */
-public class VisibilityUserListLabelProvider extends LabelProvider
+public class AccessListLabelProvider extends LabelProvider implements IColorProvider
 {
+   private static final Color HINT_FOREGROUND = new Color(Display.getDefault(), 192, 192, 192);
+   
    private WorkbenchLabelProvider workbenchLabelProvider;
    
    /**
     * Default constructor
     */
-   public VisibilityUserListLabelProvider()
+   public AccessListLabelProvider()
    {
       workbenchLabelProvider = new WorkbenchLabelProvider();
    }    
@@ -27,7 +32,7 @@ public class VisibilityUserListLabelProvider extends LabelProvider
    @Override
    public Image getImage(Object element)
    {
-      if(element instanceof String)
+      if (element instanceof String)
          return null;
       return workbenchLabelProvider.getImage(element);
    }
@@ -52,4 +57,24 @@ public class VisibilityUserListLabelProvider extends LabelProvider
       workbenchLabelProvider.dispose();
       super.dispose();
    }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+    */
+   @Override
+   public Color getForeground(Object element)
+   {
+      if (element instanceof String)
+         return HINT_FOREGROUND;
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+    */
+   @Override
+   public Color getBackground(Object element)
+   {
+      return null;
+   }
 }