Summary Table "Import" button merged to Web
authorAlex Kirhenshtein <alk@netxms.org>
Tue, 14 May 2013 13:58:55 +0000 (13:58 +0000)
committerAlex Kirhenshtein <alk@netxms.org>
Tue, 14 May 2013 13:58:55 +0000 (13:58 +0000)
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/SummaryTableColumns.java

index 8e91897..71a5308 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Iterator;\r
 import java.util.List;\r
 import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.jface.dialogs.Dialog;\r
 import org.eclipse.jface.viewers.ArrayContentProvider;\r
 import org.eclipse.jface.viewers.DoubleClickEvent;\r
 import org.eclipse.jface.viewers.IDoubleClickListener;\r
@@ -49,10 +50,12 @@ import org.eclipse.ui.dialogs.PropertyPage;
 import org.netxms.client.NXCSession;\r
 import org.netxms.client.datacollection.DciSummaryTable;\r
 import org.netxms.client.datacollection.DciSummaryTableColumn;\r
+import org.netxms.client.datacollection.DciValue;\r
 import org.netxms.client.datacollection.Threshold;\r
 import org.netxms.ui.eclipse.datacollection.Activator;\r
 import org.netxms.ui.eclipse.datacollection.Messages;\r
 import org.netxms.ui.eclipse.datacollection.dialogs.EditDciSummaryTableColumnDlg;\r
+import org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog;\r
 import org.netxms.ui.eclipse.datacollection.propertypages.helpers.SummaryTableColumnLabelProvider;\r
 import org.netxms.ui.eclipse.jobs.ConsoleJob;\r
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;\r
@@ -74,6 +77,7 @@ public class SummaryTableColumns extends PropertyPage
        private Button deleteButton;\r
        private Button upButton;\r
        private Button downButton;\r
+       private Button importButton;\r
        \r
        /* (non-Javadoc)\r
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)\r
@@ -175,9 +179,30 @@ public class SummaryTableColumns extends PropertyPage
                buttonsLayout.pack = false;\r
                buttons.setLayout(buttonsLayout);\r
 \r
+               importButton = new Button(buttons, SWT.PUSH);\r
+               importButton.setText("Import");\r
+               RowData rd = new RowData();\r
+               rd.width = WidgetHelper.BUTTON_WIDTH_HINT;\r
+               importButton.setLayoutData(rd);\r
+\r
+               importButton.addSelectionListener(new SelectionListener() {\r
+\r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e)\r
+                       {\r
+                               importColumns();\r
+                       }\r
+\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e)\r
+                       {\r
+                               widgetSelected(e);\r
+                       }\r
+               });\r
+\r
                addButton = new Button(buttons, SWT.PUSH);\r
                addButton.setText(Messages.Thresholds_Add);\r
-               RowData rd = new RowData();\r
+               rd = new RowData();\r
                rd.width = WidgetHelper.BUTTON_WIDTH_HINT;\r
                addButton.setLayoutData(rd);\r
                addButton.addSelectionListener(new SelectionListener() {\r
@@ -466,4 +491,22 @@ public class SummaryTableColumns extends PropertyPage
                        viewer.setSelection(new StructuredSelection(column));\r
                }\r
        }\r
+\r
+       /**\r
+        * Import Columns from node\r
+        */\r
+       private void importColumns()\r
+       {\r
+               final SelectDciDialog dialog = new SelectDciDialog(getShell(), 0);\r
+               dialog.setAllowTemplateItems(true);\r
+               dialog.setEnableEmptySelection(false);\r
+               if (dialog.open() == Dialog.OK)\r
+               {\r
+                       final DciValue selection = dialog.getSelection();\r
+                       DciSummaryTableColumn column = new DciSummaryTableColumn(selection.getDescription(), selection.getName());\r
+                       columns.add(column);\r
+                       viewer.setInput(columns.toArray());\r
+                       viewer.setSelection(new StructuredSelection(column));\r
+               }\r
+       }\r
 }\r