Implemented map configuration options for dashboard element
authorEriks Jenkevics <eriks@netxms.org>
Thu, 2 Nov 2017 13:22:46 +0000 (15:22 +0200)
committerEriks Jenkevics <eriks@netxms.org>
Wed, 8 Nov 2017 08:04:33 +0000 (10:04 +0200)
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/ServiceComponents.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/ServiceComponentsElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/ServiceComponentsConfig.java
src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/widgets/NetworkMapWidget.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/ServiceComponents.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/ServiceComponentsElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/ServiceComponentsConfig.java
webui/webapp/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/widgets/NetworkMapWidget.java

index e398be7..23b76f8 100644 (file)
  */
 package org.netxms.ui.eclipse.dashboard.propertypages;
 
+import org.eclipse.jface.preference.ColorSelector;
 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.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Scale;
 import org.eclipse.swt.widgets.Spinner;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.client.maps.MapLayoutAlgorithm;
+import org.netxms.client.maps.MapObjectDisplayMode;
 import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.NetworkMap;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.ServiceComponentsConfig;
 import org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog;
 import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;
+import org.netxms.ui.eclipse.tools.ColorConverter;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
 import org.netxms.ui.eclipse.widgets.LabeledText;
 
 /**
@@ -47,6 +55,15 @@ public class ServiceComponents extends PropertyPage
    private Scale zoomLevelScale;
    private Spinner zoomLevelSpinner;
    private Button enableObjectDoubleClick;
+   private Button checkShowStatusIcon;
+   private Button checkShowStatusFrame;
+   private Button checkShowStatusBkgnd;
+   private Combo objectDisplayMode;
+   private Combo routingAlgorithm;
+   private Combo layoutAlgorithm;
+   private Button radioColorDefault;
+   private Button radioColorCustom;
+   private ColorSelector linkColor;
 
    @Override
    protected Control createContents(Composite parent)
@@ -128,6 +145,108 @@ public class ServiceComponents extends PropertyPage
       enableObjectDoubleClick = new Button(dialogArea, SWT.CHECK);
       enableObjectDoubleClick.setText("Enable double click action on objects");
       enableObjectDoubleClick.setSelection(config.isObjectDoubleClickEnabled());
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalSpan = 2;
+      enableObjectDoubleClick.setLayoutData(gd);
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.LEFT;
+      gd.horizontalSpan = 2;
+      layoutAlgorithm = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, "Layout algorithm", gd);
+      layoutAlgorithm.add("Spring");
+      layoutAlgorithm.add("Radial");
+      layoutAlgorithm.add("Horizontal tree");
+      layoutAlgorithm.add("Vertical tree");
+      layoutAlgorithm.add("Sparse vertical tree");
+      layoutAlgorithm.select(config.getDefaultLayoutAlgorithm().getValue());
+      
+      /**** object display ****/
+      Group objectDisplayGroup = new Group(dialogArea, SWT.NONE);
+      objectDisplayGroup.setText("Default display options");
+      gd = new GridData();
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalAlignment = SWT.FILL;
+      gd.verticalAlignment = SWT.FILL;
+      objectDisplayGroup.setLayoutData(gd);
+      layout = new GridLayout();
+      objectDisplayGroup.setLayout(layout);
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      objectDisplayMode = WidgetHelper.createLabeledCombo(objectDisplayGroup, SWT.READ_ONLY, "Display object as", gd);
+      objectDisplayMode.add("Icons");
+      objectDisplayMode.add("Small labels");
+      objectDisplayMode.add("Large labels");
+      objectDisplayMode.add("Status icons");
+      objectDisplayMode.select(config.getObjectDisplayMode().getValue());
+      
+      checkShowStatusIcon = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusIcon.setText("Show status icon");
+      checkShowStatusIcon.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_ICON) != 0);
+      
+      checkShowStatusFrame = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusFrame.setText("Show status frame");
+      checkShowStatusFrame.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_FRAME) != 0);
+      
+      checkShowStatusBkgnd = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusBkgnd.setText("Show status background");
+      checkShowStatusBkgnd.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_BKGND) != 0);
+      
+      /**** default link appearance ****/
+      Group linkGroup = new Group(dialogArea, SWT.NONE);
+      linkGroup.setText("Default connection options");
+      gd = new GridData();
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalAlignment = SWT.FILL;
+      gd.verticalAlignment = SWT.FILL;
+      linkGroup.setLayoutData(gd);
+      layout = new GridLayout();
+      linkGroup.setLayout(layout);
+
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      routingAlgorithm = WidgetHelper.createLabeledCombo(linkGroup, SWT.READ_ONLY, "Routing algorithm", gd);
+      routingAlgorithm.add("Direct");
+      routingAlgorithm.add("Manhattan");
+      routingAlgorithm.select(config.getDefaultLinkRouting() - 1);
+
+      final SelectionListener listener = new SelectionListener() {
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            linkColor.setEnabled(radioColorCustom.getSelection());
+         }
+         
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);
+         }
+      };
+      
+      radioColorDefault = new Button(linkGroup, SWT.RADIO);
+      radioColorDefault.setText("Default color");
+      radioColorDefault.setSelection(config.getDefaultLinkColor() < 0);
+      radioColorDefault.addSelectionListener(listener);
+      gd = new GridData();
+      gd.verticalIndent = WidgetHelper.OUTER_SPACING * 2;
+      radioColorDefault.setLayoutData(gd);
+
+      radioColorCustom = new Button(linkGroup, SWT.RADIO);
+      radioColorCustom.setText("Custom color");
+      radioColorCustom.setSelection(config.getDefaultLinkColor() >= 0);
+      radioColorCustom.addSelectionListener(listener);
+
+      linkColor = new ColorSelector(linkGroup);
+      linkColor.setColorValue(ColorConverter.rgbFromInt(config.getDefaultLinkColor()));
+      linkColor.setEnabled(config.getDefaultLinkColor() >= 0);
+      gd = new GridData();
+      gd.horizontalIndent = 20;
+      linkColor.getButton().setLayoutData(gd);
 
       return dialogArea;
    }
@@ -142,6 +261,25 @@ public class ServiceComponents extends PropertyPage
       config.setTitle(title.getText());
       config.setZoomLevel(zoomLevelSpinner.getSelection());
       config.setObjectDoubleClickEnabled(enableObjectDoubleClick.getSelection());
+      config.setObjectDisplayMode(MapObjectDisplayMode.getByValue(objectDisplayMode.getSelectionIndex()));
+      config.setDefaultLayoutAlgorithm(MapLayoutAlgorithm.getByValue(layoutAlgorithm.getSelectionIndex()));
+      if (checkShowStatusIcon.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_ICON);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_ICON);
+      if (checkShowStatusFrame.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_FRAME);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_FRAME);
+      if (checkShowStatusBkgnd.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_BKGND);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_BKGND);
+      config.setDefaultLinkRouting(routingAlgorithm.getSelectionIndex() + 1);
+      if (radioColorDefault.getSelection())
+         config.setDefaultLinkColor(-1);
+      else
+         config.setDefaultLinkColor(ColorConverter.rgbToInt(linkColor.getColorValue()));
       return true;
    }
 
index 920da59..5072f9c 100644 (file)
@@ -20,11 +20,11 @@ package org.netxms.ui.eclipse.dashboard.widgets;
 
 import java.util.Iterator;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.NXCSession;
 import org.netxms.client.dashboards.DashboardElement;
-import org.netxms.client.maps.MapLayoutAlgorithm;
 import org.netxms.client.maps.NetworkMapLink;
 import org.netxms.client.maps.NetworkMapPage;
 import org.netxms.client.maps.elements.NetworkMapObject;
@@ -32,11 +32,13 @@ import org.netxms.client.objects.AbstractObject;
 import org.netxms.client.objects.Cluster;
 import org.netxms.client.objects.Condition;
 import org.netxms.client.objects.Container;
+import org.netxms.client.objects.NetworkMap;
 import org.netxms.client.objects.Node;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.ServiceComponentsConfig;
 import org.netxms.ui.eclipse.networkmaps.views.ServiceComponents;
 import org.netxms.ui.eclipse.networkmaps.widgets.NetworkMapWidget;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 
 /**
  * Service components map element for dashboard
@@ -85,9 +87,16 @@ public class ServiceComponentsElement extends ElementWidget
       if (mapPage != null)
       {
          mapWidget = new NetworkMapWidget(this, viewPart, SWT.NONE);
-         mapWidget.setLayoutAlgorithm(MapLayoutAlgorithm.SPARSE_VTREE);
-         mapWidget.setContent(mapPage);
+         mapWidget.setLayoutAlgorithm(config.getDefaultLayoutAlgorithm());
          mapWidget.zoomTo((double)config.getZoomLevel() / 100.0);
+         mapWidget.getLabelProvider().setObjectFigureType(config.getObjectDisplayMode());
+         mapWidget.getLabelProvider().setShowStatusIcons((config.getFlags() & NetworkMap.MF_SHOW_STATUS_ICON) != 0);
+         mapWidget.getLabelProvider().setShowStatusFrame((config.getFlags() & NetworkMap.MF_SHOW_STATUS_FRAME) != 0);
+         mapWidget.getLabelProvider().setShowStatusBackground((config.getFlags() & NetworkMap.MF_SHOW_STATUS_BKGND) != 0);
+         mapWidget.setConnectionRouter(config.getDefaultLinkRouting());
+         if (config.getDefaultLinkColor() >= 0)
+            mapWidget.getLabelProvider().setDefaultLinkColor(new Color(mapWidget.getControl().getDisplay(), ColorConverter.rgbFromInt(config.getDefaultLinkColor())));
+         mapWidget.setContent(mapPage);
       }
 
       if (config.isObjectDoubleClickEnabled())
index 8ebd2f2..f112a97 100644 (file)
@@ -22,6 +22,8 @@ import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Map;
 import java.util.Set;
+import org.netxms.client.maps.MapLayoutAlgorithm;
+import org.netxms.client.maps.MapObjectDisplayMode;
 import org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.Serializer;
@@ -44,6 +46,21 @@ public class ServiceComponentsConfig extends DashboardElementConfig
    @Element(required=false)
    private boolean objectDoubleClickEnabled = false;
 
+   @Element(required=false)
+   private MapObjectDisplayMode objectDisplayMode = MapObjectDisplayMode.ICON;
+   
+   @Element(required=false)
+   private int flags = 0;
+   
+   @Element(required=false)
+   private int linkRouting = 0;
+
+   @Element(required=false)
+   private int defaultLinkColor = -1;
+
+   @Element(required=false)
+   private MapLayoutAlgorithm mapLayout = MapLayoutAlgorithm.SPARSE_VTREE;
+   
    /**
     * Create line chart settings object from XML document
     * 
@@ -155,4 +172,93 @@ public class ServiceComponentsConfig extends DashboardElementConfig
    {
       this.objectDoubleClickEnabled = objectDoubleClickEnabled;
    }
+   
+   /**
+    * Get map object display mode
+    * @return object display mode
+    */
+   public MapObjectDisplayMode getObjectDisplayMode()
+   {
+      return objectDisplayMode;
+   }
+   
+   /**
+    * Set object display mode
+    * @param mode of object display
+    */
+   public void setObjectDisplayMode(MapObjectDisplayMode mode)
+   {
+      objectDisplayMode = mode;
+   }
+   
+   /**
+    * Get object flags
+    * @return flags
+    */
+   public int getFlags()
+   {
+      return flags;
+   }
+   
+   /**
+    * Set object flags
+    * @param flags to set
+    */
+   public void setFlags(int flags)
+   {
+      this.flags = flags;
+   }
+   
+   /**
+    * Get default link routing
+    * @return default link routing
+    */
+   public int getDefaultLinkRouting()
+   {
+      return linkRouting;
+   }
+   
+   /**
+    * Set default link routing
+    * @param linkRouting to set
+    */
+   public void setDefaultLinkRouting(int linkRouting)
+   {
+      this.linkRouting = linkRouting;
+   }
+   
+   /**
+    * @return the defaultLinkColor
+    */
+   public int getDefaultLinkColor()
+   {
+      return defaultLinkColor;
+   }
+   
+   /**
+    * Set default link color
+    * @param defaultLinkColor to set
+    */
+   public void setDefaultLinkColor(int defaultLinkColor)
+   {
+      this.defaultLinkColor = defaultLinkColor;
+   }
+   
+   /**
+    * Get map layout algorithm
+    * @return layout algorithm
+    */
+   public MapLayoutAlgorithm getDefaultLayoutAlgorithm()
+   {
+      return mapLayout;
+   }
+   
+   /**
+    * Set map layoyut algorithm
+    * @param algorithm to set
+    */
+   public void setDefaultLayoutAlgorithm(MapLayoutAlgorithm algorithm)
+   {
+      mapLayout = algorithm;
+   }
 }
index 74de6e7..45499b4 100644 (file)
@@ -47,6 +47,7 @@ import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
@@ -555,4 +556,22 @@ public class NetworkMapWidget extends Composite
          }
       }
    }
+   
+   /**
+    * Get map label provider
+    * @return label provider
+    */ 
+   public MapLabelProvider getLabelProvider()
+   {
+      return labelProvider;
+   }
+   
+   /**
+    * Get control
+    * @return control
+    */
+   public Control getControl()
+   {
+      return viewer.getControl();
+   }
 }
index e398be7..23b76f8 100644 (file)
  */
 package org.netxms.ui.eclipse.dashboard.propertypages;
 
+import org.eclipse.jface.preference.ColorSelector;
 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.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Scale;
 import org.eclipse.swt.widgets.Spinner;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.client.maps.MapLayoutAlgorithm;
+import org.netxms.client.maps.MapObjectDisplayMode;
 import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.NetworkMap;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.ServiceComponentsConfig;
 import org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog;
 import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;
+import org.netxms.ui.eclipse.tools.ColorConverter;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
 import org.netxms.ui.eclipse.widgets.LabeledText;
 
 /**
@@ -47,6 +55,15 @@ public class ServiceComponents extends PropertyPage
    private Scale zoomLevelScale;
    private Spinner zoomLevelSpinner;
    private Button enableObjectDoubleClick;
+   private Button checkShowStatusIcon;
+   private Button checkShowStatusFrame;
+   private Button checkShowStatusBkgnd;
+   private Combo objectDisplayMode;
+   private Combo routingAlgorithm;
+   private Combo layoutAlgorithm;
+   private Button radioColorDefault;
+   private Button radioColorCustom;
+   private ColorSelector linkColor;
 
    @Override
    protected Control createContents(Composite parent)
@@ -128,6 +145,108 @@ public class ServiceComponents extends PropertyPage
       enableObjectDoubleClick = new Button(dialogArea, SWT.CHECK);
       enableObjectDoubleClick.setText("Enable double click action on objects");
       enableObjectDoubleClick.setSelection(config.isObjectDoubleClickEnabled());
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalSpan = 2;
+      enableObjectDoubleClick.setLayoutData(gd);
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.LEFT;
+      gd.horizontalSpan = 2;
+      layoutAlgorithm = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, "Layout algorithm", gd);
+      layoutAlgorithm.add("Spring");
+      layoutAlgorithm.add("Radial");
+      layoutAlgorithm.add("Horizontal tree");
+      layoutAlgorithm.add("Vertical tree");
+      layoutAlgorithm.add("Sparse vertical tree");
+      layoutAlgorithm.select(config.getDefaultLayoutAlgorithm().getValue());
+      
+      /**** object display ****/
+      Group objectDisplayGroup = new Group(dialogArea, SWT.NONE);
+      objectDisplayGroup.setText("Default display options");
+      gd = new GridData();
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalAlignment = SWT.FILL;
+      gd.verticalAlignment = SWT.FILL;
+      objectDisplayGroup.setLayoutData(gd);
+      layout = new GridLayout();
+      objectDisplayGroup.setLayout(layout);
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      objectDisplayMode = WidgetHelper.createLabeledCombo(objectDisplayGroup, SWT.READ_ONLY, "Display object as", gd);
+      objectDisplayMode.add("Icons");
+      objectDisplayMode.add("Small labels");
+      objectDisplayMode.add("Large labels");
+      objectDisplayMode.add("Status icons");
+      objectDisplayMode.select(config.getObjectDisplayMode().getValue());
+      
+      checkShowStatusIcon = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusIcon.setText("Show status icon");
+      checkShowStatusIcon.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_ICON) != 0);
+      
+      checkShowStatusFrame = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusFrame.setText("Show status frame");
+      checkShowStatusFrame.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_FRAME) != 0);
+      
+      checkShowStatusBkgnd = new Button(objectDisplayGroup, SWT.CHECK);
+      checkShowStatusBkgnd.setText("Show status background");
+      checkShowStatusBkgnd.setSelection((config.getFlags() & NetworkMap.MF_SHOW_STATUS_BKGND) != 0);
+      
+      /**** default link appearance ****/
+      Group linkGroup = new Group(dialogArea, SWT.NONE);
+      linkGroup.setText("Default connection options");
+      gd = new GridData();
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalAlignment = SWT.FILL;
+      gd.verticalAlignment = SWT.FILL;
+      linkGroup.setLayoutData(gd);
+      layout = new GridLayout();
+      linkGroup.setLayout(layout);
+
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      routingAlgorithm = WidgetHelper.createLabeledCombo(linkGroup, SWT.READ_ONLY, "Routing algorithm", gd);
+      routingAlgorithm.add("Direct");
+      routingAlgorithm.add("Manhattan");
+      routingAlgorithm.select(config.getDefaultLinkRouting() - 1);
+
+      final SelectionListener listener = new SelectionListener() {
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            linkColor.setEnabled(radioColorCustom.getSelection());
+         }
+         
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);
+         }
+      };
+      
+      radioColorDefault = new Button(linkGroup, SWT.RADIO);
+      radioColorDefault.setText("Default color");
+      radioColorDefault.setSelection(config.getDefaultLinkColor() < 0);
+      radioColorDefault.addSelectionListener(listener);
+      gd = new GridData();
+      gd.verticalIndent = WidgetHelper.OUTER_SPACING * 2;
+      radioColorDefault.setLayoutData(gd);
+
+      radioColorCustom = new Button(linkGroup, SWT.RADIO);
+      radioColorCustom.setText("Custom color");
+      radioColorCustom.setSelection(config.getDefaultLinkColor() >= 0);
+      radioColorCustom.addSelectionListener(listener);
+
+      linkColor = new ColorSelector(linkGroup);
+      linkColor.setColorValue(ColorConverter.rgbFromInt(config.getDefaultLinkColor()));
+      linkColor.setEnabled(config.getDefaultLinkColor() >= 0);
+      gd = new GridData();
+      gd.horizontalIndent = 20;
+      linkColor.getButton().setLayoutData(gd);
 
       return dialogArea;
    }
@@ -142,6 +261,25 @@ public class ServiceComponents extends PropertyPage
       config.setTitle(title.getText());
       config.setZoomLevel(zoomLevelSpinner.getSelection());
       config.setObjectDoubleClickEnabled(enableObjectDoubleClick.getSelection());
+      config.setObjectDisplayMode(MapObjectDisplayMode.getByValue(objectDisplayMode.getSelectionIndex()));
+      config.setDefaultLayoutAlgorithm(MapLayoutAlgorithm.getByValue(layoutAlgorithm.getSelectionIndex()));
+      if (checkShowStatusIcon.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_ICON);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_ICON);
+      if (checkShowStatusFrame.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_FRAME);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_FRAME);
+      if (checkShowStatusBkgnd.getSelection())
+         config.setFlags(config.getFlags() | NetworkMap.MF_SHOW_STATUS_BKGND);
+      else
+         config.setFlags(config.getFlags() & ~NetworkMap.MF_SHOW_STATUS_BKGND);
+      config.setDefaultLinkRouting(routingAlgorithm.getSelectionIndex() + 1);
+      if (radioColorDefault.getSelection())
+         config.setDefaultLinkColor(-1);
+      else
+         config.setDefaultLinkColor(ColorConverter.rgbToInt(linkColor.getColorValue()));
       return true;
    }
 
index 920da59..5072f9c 100644 (file)
@@ -20,11 +20,11 @@ package org.netxms.ui.eclipse.dashboard.widgets;
 
 import java.util.Iterator;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.ui.IViewPart;
 import org.netxms.client.NXCSession;
 import org.netxms.client.dashboards.DashboardElement;
-import org.netxms.client.maps.MapLayoutAlgorithm;
 import org.netxms.client.maps.NetworkMapLink;
 import org.netxms.client.maps.NetworkMapPage;
 import org.netxms.client.maps.elements.NetworkMapObject;
@@ -32,11 +32,13 @@ import org.netxms.client.objects.AbstractObject;
 import org.netxms.client.objects.Cluster;
 import org.netxms.client.objects.Condition;
 import org.netxms.client.objects.Container;
+import org.netxms.client.objects.NetworkMap;
 import org.netxms.client.objects.Node;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.ServiceComponentsConfig;
 import org.netxms.ui.eclipse.networkmaps.views.ServiceComponents;
 import org.netxms.ui.eclipse.networkmaps.widgets.NetworkMapWidget;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 
 /**
  * Service components map element for dashboard
@@ -85,9 +87,16 @@ public class ServiceComponentsElement extends ElementWidget
       if (mapPage != null)
       {
          mapWidget = new NetworkMapWidget(this, viewPart, SWT.NONE);
-         mapWidget.setLayoutAlgorithm(MapLayoutAlgorithm.SPARSE_VTREE);
-         mapWidget.setContent(mapPage);
+         mapWidget.setLayoutAlgorithm(config.getDefaultLayoutAlgorithm());
          mapWidget.zoomTo((double)config.getZoomLevel() / 100.0);
+         mapWidget.getLabelProvider().setObjectFigureType(config.getObjectDisplayMode());
+         mapWidget.getLabelProvider().setShowStatusIcons((config.getFlags() & NetworkMap.MF_SHOW_STATUS_ICON) != 0);
+         mapWidget.getLabelProvider().setShowStatusFrame((config.getFlags() & NetworkMap.MF_SHOW_STATUS_FRAME) != 0);
+         mapWidget.getLabelProvider().setShowStatusBackground((config.getFlags() & NetworkMap.MF_SHOW_STATUS_BKGND) != 0);
+         mapWidget.setConnectionRouter(config.getDefaultLinkRouting());
+         if (config.getDefaultLinkColor() >= 0)
+            mapWidget.getLabelProvider().setDefaultLinkColor(new Color(mapWidget.getControl().getDisplay(), ColorConverter.rgbFromInt(config.getDefaultLinkColor())));
+         mapWidget.setContent(mapPage);
       }
 
       if (config.isObjectDoubleClickEnabled())
index 8ebd2f2..f112a97 100644 (file)
@@ -22,6 +22,8 @@ import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Map;
 import java.util.Set;
+import org.netxms.client.maps.MapLayoutAlgorithm;
+import org.netxms.client.maps.MapObjectDisplayMode;
 import org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.Serializer;
@@ -44,6 +46,21 @@ public class ServiceComponentsConfig extends DashboardElementConfig
    @Element(required=false)
    private boolean objectDoubleClickEnabled = false;
 
+   @Element(required=false)
+   private MapObjectDisplayMode objectDisplayMode = MapObjectDisplayMode.ICON;
+   
+   @Element(required=false)
+   private int flags = 0;
+   
+   @Element(required=false)
+   private int linkRouting = 0;
+
+   @Element(required=false)
+   private int defaultLinkColor = -1;
+
+   @Element(required=false)
+   private MapLayoutAlgorithm mapLayout = MapLayoutAlgorithm.SPARSE_VTREE;
+   
    /**
     * Create line chart settings object from XML document
     * 
@@ -155,4 +172,93 @@ public class ServiceComponentsConfig extends DashboardElementConfig
    {
       this.objectDoubleClickEnabled = objectDoubleClickEnabled;
    }
+   
+   /**
+    * Get map object display mode
+    * @return object display mode
+    */
+   public MapObjectDisplayMode getObjectDisplayMode()
+   {
+      return objectDisplayMode;
+   }
+   
+   /**
+    * Set object display mode
+    * @param mode of object display
+    */
+   public void setObjectDisplayMode(MapObjectDisplayMode mode)
+   {
+      objectDisplayMode = mode;
+   }
+   
+   /**
+    * Get object flags
+    * @return flags
+    */
+   public int getFlags()
+   {
+      return flags;
+   }
+   
+   /**
+    * Set object flags
+    * @param flags to set
+    */
+   public void setFlags(int flags)
+   {
+      this.flags = flags;
+   }
+   
+   /**
+    * Get default link routing
+    * @return default link routing
+    */
+   public int getDefaultLinkRouting()
+   {
+      return linkRouting;
+   }
+   
+   /**
+    * Set default link routing
+    * @param linkRouting to set
+    */
+   public void setDefaultLinkRouting(int linkRouting)
+   {
+      this.linkRouting = linkRouting;
+   }
+   
+   /**
+    * @return the defaultLinkColor
+    */
+   public int getDefaultLinkColor()
+   {
+      return defaultLinkColor;
+   }
+   
+   /**
+    * Set default link color
+    * @param defaultLinkColor to set
+    */
+   public void setDefaultLinkColor(int defaultLinkColor)
+   {
+      this.defaultLinkColor = defaultLinkColor;
+   }
+   
+   /**
+    * Get map layout algorithm
+    * @return layout algorithm
+    */
+   public MapLayoutAlgorithm getDefaultLayoutAlgorithm()
+   {
+      return mapLayout;
+   }
+   
+   /**
+    * Set map layoyut algorithm
+    * @param algorithm to set
+    */
+   public void setDefaultLayoutAlgorithm(MapLayoutAlgorithm algorithm)
+   {
+      mapLayout = algorithm;
+   }
 }
index eae4fc7..1144e63 100644 (file)
@@ -47,6 +47,7 @@ import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
@@ -555,4 +556,22 @@ public class NetworkMapWidget extends Composite
          }
       }
    }
+   
+   /**
+    * Get map label provider
+    * @return label provider
+    */ 
+   public MapLabelProvider getLabelProvider()
+   {
+      return labelProvider;
+   }
+   
+   /**
+    * Get control
+    * @return control
+    */
+   public Control getControl()
+   {
+      return viewer.getControl();
+   }
 }