Added Table DCI summary table functionality to webUI
authorEriks Jenkevics <eriks@netxms.org>
Fri, 1 Sep 2017 06:25:33 +0000 (09:25 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 2 Sep 2017 08:18:40 +0000 (11:18 +0300)
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/DciSummaryTable.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/SummaryTableGeneral.java
webui/webapp/DataCollection/plugin.xml
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/DciSummaryTablePropertyTester.java [new file with mode: 0644]
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/SummaryTableGeneral.java
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/views/SummaryTableManager.java

index 896687c..a01053b 100644 (file)
@@ -45,6 +45,7 @@ public class DciSummaryTable
         * 
         * @param menuPath The menu path
         * @param title The title
+        * @param isSingleValue if table is single value DCI
         */
        public DciSummaryTable(String menuPath, String title, boolean isSingleValue)
        {
index 3ca4648..2b4f78c 100644 (file)
@@ -118,6 +118,8 @@ public class SummaryTableGeneral extends PropertyPage
        private void selectDci()
        {
           SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
+          dlg.setDcObjectType(2);
+          dlg.setSingleSelection(true);
           if (dlg.open() == Window.OK)
           {
              table.setTableDciName(dlg.getSelection().get(0).getName());
index b1f8eca..f01fdd9 100644 (file)
               id="org.netxms.ui.eclipse.datacollection.propertypages.SummaryTableColumns#10"
               name="%page.name.Columns">
            <enabledWhen>
-              <instanceof
-                    value="org.netxms.client.datacollection.DciSummaryTable">
-              </instanceof>
+              <and>
+                 <or>
+                    <instanceof
+                          value="org.netxms.client.datacollection.DciSummaryTable">
+                    </instanceof>
+                 </or>
+                 <test
+                       forcePluginActivation="true"
+                       property="org.netxms.ui.eclipse.datacollection.isSingleValue">
+                 </test>
+              </and>
            </enabledWhen>
         </page>
         <page
             properties="isClusterObject,isTemplateObject"
             type="org.netxms.client.datacollection.DataCollectionObject">
       </propertyTester>
+      <propertyTester
+            class="org.netxms.ui.eclipse.datacollection.DciSummaryTablePropertyTester"
+            id="org.netxms.ui.eclipse.datacollection.SummaryTableDciPropertyTester"
+            namespace="org.netxms.ui.eclipse.datacollection"
+            properties="isSingleValue"
+            type="org.netxms.client.datacollection.DciSummaryTable">
+      </propertyTester>
    </extension>
    <extension
          point="org.eclipse.ui.services">
diff --git a/webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/DciSummaryTablePropertyTester.java b/webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/DciSummaryTablePropertyTester.java
new file mode 100644 (file)
index 0000000..832645c
--- /dev/null
@@ -0,0 +1,23 @@
+package org.netxms.ui.eclipse.datacollection;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.netxms.client.datacollection.DciSummaryTable;
+
+public class DciSummaryTablePropertyTester extends PropertyTester
+{
+   /* (non-Javadoc)
+    * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+    */
+   @Override
+   public boolean test(Object receiver, String property, Object[] args, Object expectedValue)
+   {
+      if (!(receiver instanceof DciSummaryTable))
+         return false;
+      
+      if (property.equals("isSingleValue"))
+         return ((DciSummaryTable)receiver).isSingleValue();
+      
+      return false;
+   }
+   
+}
index 35f57dd..2b4f78c 100644 (file)
 package org.netxms.ui.eclipse.datacollection.propertypages;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.dialogs.PropertyPage;
@@ -29,6 +33,7 @@ import org.netxms.client.NXCSession;
 import org.netxms.client.datacollection.DciSummaryTable;
 import org.netxms.ui.eclipse.datacollection.Activator;
 import org.netxms.ui.eclipse.datacollection.Messages;
+import org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
@@ -42,6 +47,8 @@ public class SummaryTableGeneral extends PropertyPage
        private DciSummaryTable table;
        private LabeledText menuPath;
        private LabeledText title;
+       private LabeledText dciName;
+       private Button select;
        
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
@@ -57,20 +64,68 @@ public class SummaryTableGeneral extends PropertyPage
                layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
                layout.marginWidth = 0;
                layout.marginHeight = 0;
+               layout.numColumns = 2;
       dialogArea.setLayout(layout);
       
       menuPath = new LabeledText(dialogArea, SWT.NONE);
       menuPath.setLabel(Messages.get().SummaryTableGeneral_MenuPath);
       menuPath.setText(table.getMenuPath());
-      menuPath.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+      menuPath.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
 
       title = new LabeledText(dialogArea, SWT.NONE);
       title.setLabel(Messages.get().SummaryTableGeneral_Title);
       title.setText(table.getTitle());
-      title.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+      title.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
+      
+      if (!table.isSingleValue())
+      {         
+         dciName = new LabeledText(dialogArea, SWT.NONE);
+         dciName.setLabel("DCI name");
+         dciName.getTextControl().setTextLimit(255);
+         dciName.setText(table.getTableDciName());
+         dciName.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+         select = new Button(dialogArea, SWT.PUSH);
+         select.setText("Select");
+         GridData gd = new GridData(SWT.FILL);
+         gd.verticalIndent = 20;
+         select.setLayoutData(gd);
+         select.addSelectionListener(new SelectionListener() {            
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+             */
+            @Override
+            public void widgetSelected(SelectionEvent e)
+            {
+               selectDci();
+            }
+            
+            /* (non-Javadoc)
+             * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+             */
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e)
+            {
+               widgetSelected(e);               
+            }
+         });
+         
+      }
 
       return dialogArea;
        }
+       
+       private void selectDci()
+       {
+          SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
+          dlg.setDcObjectType(2);
+          dlg.setSingleSelection(true);
+          if (dlg.open() == Window.OK)
+          {
+             table.setTableDciName(dlg.getSelection().get(0).getName());
+             dciName.setText(table.getTableDciName());
+          }
+       }
 
        /**
         * Apply changes
index bcd3615..aac7e62 100644 (file)
@@ -90,7 +90,8 @@ public class SummaryTableManager extends ViewPart
        private Map<Integer, DciSummaryTableDescriptor> descriptors = new HashMap<Integer, DciSummaryTableDescriptor>();
        
        private Action actionRefresh;
-       private Action actionCreate;
+       private Action actionCreateSingleValue;
+   private Action actionCreateTableValue;
        private Action actionEdit;
        private Action actionDelete;
        private Action actionShowFilter;
@@ -345,14 +346,22 @@ public class SummaryTableManager extends ViewPart
                        }
                };
 
-               // create add action
-               actionCreate = new Action(Messages.get().SummaryTableManager_ActionNew, SharedIcons.ADD_OBJECT) {
+               // create add action for single value table
+               actionCreateSingleValue = new Action("Create new single value table", SharedIcons.ADD_OBJECT) {
                        @Override
                        public void run()
                        {
-                               createSummaryTable();
+                               createSummaryTable(true);
                        }
                };
+               
+               actionCreateTableValue = new Action("Create new table value table", Activator.getImageDescriptor("icons/new.png")) {
+                  @Override
+                  public void run()
+                  {
+                     createSummaryTable(false);
+                  }
+               };
 
                // create edit action
                actionEdit = new Action(Messages.get().SummaryTableManager_ActionEdit, SharedIcons.EDIT) {
@@ -392,7 +401,8 @@ public class SummaryTableManager extends ViewPart
         */
        private void fillLocalPullDown(IMenuManager manager)
        {
-               manager.add(actionCreate);
+               manager.add(actionCreateSingleValue);
+      manager.add(actionCreateTableValue);
                manager.add(actionShowFilter);
                manager.add(new Separator());
                manager.add(actionRefresh);
@@ -405,7 +415,8 @@ public class SummaryTableManager extends ViewPart
         */
        private void fillLocalToolBar(IToolBarManager manager)
        {
-               manager.add(actionCreate);
+      manager.add(actionCreateSingleValue);
+      manager.add(actionCreateTableValue);
                manager.add(new Separator());
                manager.add(actionRefresh);
        }
@@ -421,7 +432,8 @@ public class SummaryTableManager extends ViewPart
                menuMgr.addMenuListener(new IMenuListener() {
                        public void menuAboutToShow(IMenuManager mgr)
                        {
-                                       mgr.add(actionCreate);
+                                       mgr.add(actionCreateSingleValue);
+                                       mgr.add(actionCreateTableValue);
                                        mgr.add(actionEdit);
                                        mgr.add(actionDelete);
                        }
@@ -438,9 +450,9 @@ public class SummaryTableManager extends ViewPart
        /**
         * Create new loyalty program
         */
-       private void createSummaryTable()
+       private void createSummaryTable(boolean isSingleValue)
        {
-               DciSummaryTable t = new DciSummaryTable("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+               DciSummaryTable t = new DciSummaryTable("", "", isSingleValue); //$NON-NLS-1$ //$NON-NLS-2$
                PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
                if (dlg != null)
                {