manual map layout can be saved and restored
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 17 Dec 2010 17:59:49 +0000 (17:59 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 17 Dec 2010 17:59:49 +0000 (17:59 +0000)
14 files changed:
.gitattributes
COPYING
doc/internal/licensing_problems.txt
include/nxclapi.h
src/java/netxms-base/src/main/java/org/netxms/base/NXCPVariable.java
src/java/netxms-client/src/main/java/org/netxms/client/maps/elements/NetworkMapElement.java
src/java/netxms-client/src/main/java/org/netxms/client/objects/NetworkMap.java
src/java/netxms-eclipse/NXSL/src/org/netxms/ui/eclipse/nxsl/views/ScriptEditorView.java
src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/algorithms/ManualLayout.java [new file with mode: 0644]
src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/views/NetworkMap.java
src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/views/PredefinedMap.java
src/java/netxms-eclipse/library/icons/save.gif [moved from src/java/netxms-eclipse/NXSL/icons/save_edit.gif with 100% similarity]
src/java/netxms-eclipse/library/src/org/netxms/ui/eclipse/shared/SharedIcons.java
src/server/tools/nxconfig/PollCfgPage.cpp

index 1a363b4..3578bc0 100644 (file)
@@ -640,7 +640,6 @@ src/java/netxms-eclipse/NXSL/icons/folder.png -text
 src/java/netxms-eclipse/NXSL/icons/function.gif -text
 src/java/netxms-eclipse/NXSL/icons/library.png -text
 src/java/netxms-eclipse/NXSL/icons/new.png -text
-src/java/netxms-eclipse/NXSL/icons/save_edit.gif -text
 src/java/netxms-eclipse/NXSL/icons/script.png -text
 src/java/netxms-eclipse/NXSL/icons/var_global.gif -text
 src/java/netxms-eclipse/NXSL/icons/var_local.gif -text
@@ -692,6 +691,7 @@ src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/action
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/actions/ShowLayer2Topology.java -text
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/actions/ShowServiceComponents.java -text
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/actions/ShowServiceDependency.java -text
+src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/algorithms/ManualLayout.java -text
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/algorithms/SparseTree.java -text
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/dialogs/CreateNetworkMapDialog.java -text
 src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/preferencepages/GeneralMapPreferences.java -text
@@ -966,6 +966,7 @@ src/java/netxms-eclipse/library/icons/alarm.png -text
 src/java/netxms-eclipse/library/icons/checkbox_off.png -text
 src/java/netxms-eclipse/library/icons/checkbox_on.png -text
 src/java/netxms-eclipse/library/icons/refresh.gif -text
+src/java/netxms-eclipse/library/icons/save.gif -text
 src/java/netxms-eclipse/library/icons/zoom_in.png -text
 src/java/netxms-eclipse/library/icons/zoom_out.png -text
 src/java/netxms-eclipse/library/jar/simple-xml-2.3.5.jar -text
diff --git a/COPYING b/COPYING
index 82458d7..89c8a04 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -48,6 +48,7 @@ libgd           BSD-like
 libipfix        LGPL
 libjpeg         BSD-like
 libpng          BSD-like
+libtre          BSD-like
 scilexer        BSD-like
 sqlite          BSD-like
 zlib            BSD-like
index bc386d9..ca329a6 100644 (file)
@@ -6,7 +6,5 @@ base64.h        - GPL
 base64.cpp     - GPL
 ice.h          - actual license unknown
 ice.c          - actual license unknown
-netxms-regex.h - GPL
-regex.c                - GPL
 netxms-getopt.h        - GPL
 getopt.c       - GPL
index d5175b6..cd57fd5 100644 (file)
@@ -713,8 +713,12 @@ enum
 // Network map layouts
 //
 
-#define MAP_LAYOUT_MANUAL     0
-#define MAP_LAYOUT_RADIAL     1
+#define MAP_LAYOUT_MANUAL        0x7FFF
+#define MAP_LAYOUT_SPRING        0
+#define MAP_LAYOUT_RADIAL        1
+#define MAP_LAYOUT_HTREE         2
+#define MAP_LAYOUT_VTREE                  3
+#define MAP_LAYOUT_SPARSE_VTREE  4
 
 
 //
index b381995..974701b 100644 (file)
@@ -243,7 +243,7 @@ public class NXCPVariable
                        switch(variableType)
                        {
                                case TYPE_INTEGER:
-                                       integerValue = (long)in.readUnsignedInt();
+                                       integerValue = in.readUnsignedInt();
                                        realValue = integerValue.doubleValue();
                                        stringValue = integerValue.toString();
                                        break;
index 0ea5351..917d8ee 100644 (file)
@@ -126,6 +126,18 @@ public class NetworkMapElement
        {\r
                return id;\r
        }\r
+       \r
+       /**\r
+        * Set elements's location\r
+        * \r
+        * @param x\r
+        * @param y\r
+        */\r
+       public void setLocation(int x, int y)\r
+       {\r
+               this.x = x;\r
+               this.y = y;\r
+       }\r
 \r
        /* (non-Javadoc)\r
         * @see java.lang.Object#equals(java.lang.Object)\r
index 6fafb28..45c07a3 100644 (file)
@@ -34,6 +34,13 @@ import org.netxms.client.maps.elements.NetworkMapElement;
  */\r
 public class NetworkMap extends GenericObject\r
 {\r
+       public static final int LAYOUT_MANUAL = 0x7FFF;\r
+       public static final int LAYOUT_SPRING = 0;\r
+       public static final int LAYOUT_RADIAL = 1;\r
+       public static final int LAYOUT_HTREE = 2;\r
+       public static final int LAYOUT_VTREE = 3;\r
+       public static final int LAYOUT_SPARSE_VTREE = 4;\r
+       \r
        private int mapType;\r
        private int layout;\r
        private int background;\r
index 54ef375..8d27f42 100644 (file)
@@ -50,6 +50,7 @@ import org.netxms.ui.eclipse.jobs.ConsoleJob;
 import org.netxms.ui.eclipse.nxsl.Activator;\r
 import org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor;\r
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;\r
+import org.netxms.ui.eclipse.shared.SharedIcons;\r
 \r
 /**\r
  * Script editor view\r
@@ -175,7 +176,7 @@ public class ScriptEditorView extends ViewPart
                        }\r
                };\r
                actionSave.setText("&Save");\r
-               actionSave.setImageDescriptor(Activator.getImageDescriptor("icons/save_edit.gif"));\r
+               actionSave.setImageDescriptor(SharedIcons.SAVE);\r
        }\r
 \r
        /**\r
diff --git a/src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/algorithms/ManualLayout.java b/src/java/netxms-eclipse/NetworkMaps/src/org/netxms/ui/eclipse/networkmaps/algorithms/ManualLayout.java
new file mode 100644 (file)
index 0000000..cfe1143
--- /dev/null
@@ -0,0 +1,126 @@
+/**\r
+ * NetXMS - open source network management system\r
+ * Copyright (C) 2003-2010 Victor Kirhenshtein\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+package org.netxms.ui.eclipse.networkmaps.algorithms;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.eclipse.zest.core.widgets.Graph;\r
+import org.eclipse.zest.core.widgets.GraphNode;\r
+import org.eclipse.zest.layouts.LayoutEntity;\r
+import org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm;\r
+import org.eclipse.zest.layouts.dataStructures.InternalNode;\r
+import org.eclipse.zest.layouts.dataStructures.InternalRelationship;\r
+import org.netxms.client.maps.elements.NetworkMapObject;\r
+\r
+/**\r
+ * Manual layout of graph nodes\r
+ *\r
+ */\r
+public class ManualLayout extends AbstractLayoutAlgorithm\r
+{\r
+       private Graph graph;\r
+       \r
+       /**\r
+        * @param styles\r
+        */\r
+       public ManualLayout(int styles, Graph graph)\r
+       {\r
+               super(styles);\r
+               this.graph = graph;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#setLayoutArea(double, double, double, double)\r
+        */\r
+       @Override\r
+       public void setLayoutArea(double x, double y, double width, double height)\r
+       {\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#isValidConfiguration(boolean, boolean)\r
+        */\r
+       @Override\r
+       protected boolean isValidConfiguration(boolean asynchronous, boolean continuous)\r
+       {\r
+               return true;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[], org.eclipse.zest.layouts.dataStructures.InternalRelationship[], double, double, double, double)\r
+        */\r
+       @Override\r
+       protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider,\r
+                       double boundsX, double boundsY, double boundsWidth, double boundsHeight)\r
+       {\r
+               List<?> nodes = graph.getNodes();\r
+               Map<LayoutEntity, GraphNode> nodeMap = new HashMap<LayoutEntity, GraphNode>(nodes.size());\r
+               for(Object n : nodes)\r
+               {\r
+                       nodeMap.put(((GraphNode)n).getLayoutEntity(), (GraphNode)n);\r
+               }\r
+               \r
+               for(int i = 0; i < entitiesToLayout.length; i++)\r
+               {\r
+                       LayoutEntity entity = entitiesToLayout[i].getLayoutEntity();\r
+                       GraphNode node = nodeMap.get(entity);\r
+                       if ((node != null) && (node.getData() instanceof NetworkMapObject))\r
+                       {\r
+                               NetworkMapObject mapObject = (NetworkMapObject)node.getData();\r
+                               entitiesToLayout[i].setLocation(mapObject.getX(), mapObject.getY());\r
+                       }\r
+               }\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[], org.eclipse.zest.layouts.dataStructures.InternalRelationship[], double, double, double, double)\r
+        */\r
+       @Override\r
+       protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x,\r
+                       double y, double width, double height)\r
+       {\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[], org.eclipse.zest.layouts.dataStructures.InternalRelationship[])\r
+        */\r
+       @Override\r
+       protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider)\r
+       {\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#getTotalNumberOfLayoutSteps()\r
+        */\r
+       @Override\r
+       protected int getTotalNumberOfLayoutSteps()\r
+       {\r
+               return 0;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#getCurrentLayoutStep()\r
+        */\r
+       @Override\r
+       protected int getCurrentLayoutStep()\r
+       {\r
+               return 0;\r
+       }\r
+}\r
index fa1b94c..373b9ad 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Set;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Status;\r
+import org.eclipse.draw2d.geometry.Point;\r
 import org.eclipse.jface.action.Action;\r
 import org.eclipse.jface.action.GroupMarker;\r
 import org.eclipse.jface.action.IContributionItem;\r
@@ -55,6 +56,8 @@ import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.progress.UIJob;\r
 import org.eclipse.zest.core.viewers.AbstractZoomableViewer;\r
 import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;\r
+import org.eclipse.zest.core.widgets.Graph;\r
+import org.eclipse.zest.core.widgets.GraphNode;\r
 import org.eclipse.zest.layouts.LayoutAlgorithm;\r
 import org.eclipse.zest.layouts.LayoutStyles;\r
 import org.eclipse.zest.layouts.algorithms.CompositeLayoutAlgorithm;\r
@@ -70,6 +73,7 @@ import org.netxms.client.maps.NetworkMapPage;
 import org.netxms.client.maps.elements.NetworkMapObject;\r
 import org.netxms.client.objects.GenericObject;\r
 import org.netxms.ui.eclipse.actions.RefreshAction;\r
+import org.netxms.ui.eclipse.networkmaps.algorithms.ManualLayout;\r
 import org.netxms.ui.eclipse.networkmaps.algorithms.SparseTree;\r
 import org.netxms.ui.eclipse.networkmaps.views.helpers.ExtendedGraphViewer;\r
 import org.netxms.ui.eclipse.networkmaps.views.helpers.MapContentProvider;\r
@@ -84,7 +88,6 @@ import org.netxms.ui.eclipse.shared.SharedIcons;
  */\r
 public abstract class NetworkMap extends ViewPart implements ISelectionProvider, IZoomableWorkbenchPart\r
 {\r
-       protected static final int LAYOUT_MANUAL = -1;\r
        protected static final int LAYOUT_SPRING = 0;\r
        protected static final int LAYOUT_RADIAL = 1;\r
        protected static final int LAYOUT_HTREE = 2;\r
@@ -101,6 +104,8 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
        protected SessionListener sessionListener;\r
        protected MapLabelProvider labelProvider;\r
        protected int layoutAlgorithm = LAYOUT_SPRING;\r
+       protected boolean allowManualLayout = false;     // True if manual layout can be switched on\r
+       protected boolean automaticLayoutEnabled = true; // Current layout mode - automatic or manual\r
        \r
        private RefreshAction actionRefresh;\r
        private Action actionShowStatusIcon;\r
@@ -110,6 +115,8 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
        private Action actionZoomOut;\r
        private Action[] actionZoomTo;\r
        private Action[] actionSetAlgorithm;\r
+       private Action actionEnableAutomaticLayout;\r
+       private Action actionSaveLayout;\r
        \r
        private IStructuredSelection currentSelection = new StructuredSelection(new Object[0]);\r
        private Set<ISelectionChangedListener> selectionListeners = new HashSet<ISelectionChangedListener>();\r
@@ -147,8 +154,6 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                viewer.setContentProvider(new MapContentProvider());\r
                labelProvider = new MapLabelProvider(viewer);\r
                viewer.setLabelProvider(labelProvider);\r
-               viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));\r
-               viewer.setInput(mapPage);\r
                \r
                getSite().setSelectionProvider(this);\r
                viewer.addSelectionChangedListener(new ISelectionChangedListener() {\r
@@ -167,10 +172,6 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                        }\r
                });\r
                \r
-               createActions();\r
-               contributeToActionBars();\r
-               createPopupMenu();\r
-               \r
                sessionListener = new SessionListener() {\r
                        @Override\r
                        public void notificationHandler(SessionNotification n)\r
@@ -180,6 +181,20 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                        }\r
                };\r
                session.addListener(sessionListener);\r
+\r
+               createActions();\r
+               contributeToActionBars();\r
+               createPopupMenu();\r
+               \r
+               if (automaticLayoutEnabled)\r
+               {\r
+                       setLayoutAlgorithm(layoutAlgorithm);\r
+               }\r
+               else\r
+               {\r
+                       viewer.setLayoutAlgorithm(new ManualLayout(LayoutStyles.NO_LAYOUT_NODE_RESIZING, viewer.getGraphControl()));\r
+               }\r
+               viewer.setInput(mapPage);\r
        }\r
 \r
        /**\r
@@ -249,6 +264,55 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                layoutAlgorithm = alg;\r
                actionSetAlgorithm[layoutAlgorithm].setChecked(true);\r
        }\r
+       \r
+       /**\r
+        * Update stored object positions with actual positions read from graph control\r
+        */\r
+       protected void updateObjectPositions()\r
+       {\r
+               Graph graph = viewer.getGraphControl();\r
+               List<?> nodes = graph.getNodes();\r
+               for(Object o : nodes)\r
+               {\r
+                       if (o instanceof GraphNode)\r
+                       {\r
+                               Object data = ((GraphNode)o).getData();\r
+                               if (data instanceof NetworkMapObject)\r
+                               {\r
+                                       Point loc = ((GraphNode)o).getLocation();\r
+                                       ((NetworkMapObject)data).setLocation(loc.x, loc.y);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Set manual layout mode\r
+        */\r
+       protected void setManualLayout()\r
+       {\r
+               updateObjectPositions();\r
+               \r
+               automaticLayoutEnabled = false;\r
+               viewer.setLayoutAlgorithm(new ManualLayout(LayoutStyles.NO_LAYOUT_NODE_RESIZING, viewer.getGraphControl()), true);\r
+               \r
+               for(int i = 0; i < actionSetAlgorithm.length; i++)\r
+                       actionSetAlgorithm[i].setEnabled(false);\r
+               actionSaveLayout.setEnabled(true);\r
+       }\r
+       \r
+       /**\r
+        * Set automatic layout mode\r
+        */\r
+       protected void setAutomaticLayout()\r
+       {\r
+               automaticLayoutEnabled = true;\r
+               setLayoutAlgorithm(layoutAlgorithm);\r
+               \r
+               for(int i = 0; i < actionSetAlgorithm.length; i++)\r
+                       actionSetAlgorithm[i].setEnabled(true);\r
+               actionSaveLayout.setEnabled(false);\r
+       }\r
 \r
        /**\r
         * Create actions\r
@@ -328,7 +392,36 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                                }\r
                        };\r
                        actionSetAlgorithm[i].setChecked(layoutAlgorithm == i);\r
+                       actionSetAlgorithm[i].setEnabled(automaticLayoutEnabled);\r
                }\r
+               \r
+               actionEnableAutomaticLayout = new Action("Enable &automatic layout", Action.AS_CHECK_BOX) {\r
+                       @Override\r
+                       public void run()\r
+                       {\r
+                               if (automaticLayoutEnabled)\r
+                               {\r
+                                       setManualLayout();\r
+                               }\r
+                               else\r
+                               {\r
+                                       setAutomaticLayout();\r
+                               }\r
+                               setChecked(automaticLayoutEnabled);\r
+                       }\r
+               };\r
+               actionEnableAutomaticLayout.setChecked(automaticLayoutEnabled);\r
+               \r
+               actionSaveLayout = new Action("&Save layout") {\r
+                       @Override\r
+                       public void run()\r
+                       {\r
+                               updateObjectPositions();\r
+                               saveLayout();\r
+                       }\r
+               };\r
+               actionSaveLayout.setImageDescriptor(SharedIcons.SAVE);\r
+               actionSaveLayout.setEnabled(!automaticLayoutEnabled);\r
        }\r
        \r
        /**\r
@@ -338,8 +431,18 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
        protected IContributionItem createLayoutSubmenu()\r
        {\r
                MenuManager layout = new MenuManager("&Layout");\r
+               if (allowManualLayout)\r
+               {\r
+                       layout.add(actionEnableAutomaticLayout);\r
+                       layout.add(new Separator());\r
+               }\r
                for(int i = 0; i < actionSetAlgorithm.length; i++)\r
                        layout.add(actionSetAlgorithm[i]);\r
+               if (allowManualLayout)\r
+               {\r
+                       layout.add(new Separator());\r
+                       layout.add(actionSaveLayout);\r
+               }\r
                return layout;\r
        }\r
        \r
@@ -378,10 +481,14 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
         * @param manager\r
         */\r
        protected void fillLocalToolBar(IToolBarManager manager)\r
-       {       \r
+       {\r
                manager.add(actionZoomIn);\r
                manager.add(actionZoomOut);\r
                manager.add(new Separator());\r
+               if (allowManualLayout)\r
+               {\r
+                       manager.add(actionSaveLayout);\r
+               }\r
                manager.add(actionRefresh);\r
        }\r
        \r
@@ -474,6 +581,14 @@ public abstract class NetworkMap extends ViewPart implements ISelectionProvider,
                        }\r
                }.schedule();\r
        }\r
+       \r
+       /**\r
+        * Called when map layout has to be saved. Object positions already updated\r
+        * when this method is called. Default implementation does nothing.\r
+        */\r
+       protected void saveLayout()\r
+       {\r
+       }\r
 \r
        /* (non-Javadoc)\r
         * @see org.eclipse.ui.part.WorkbenchPart#setFocus()\r
index 769ad0b..85f0ca1 100644 (file)
@@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IViewSite;\r
 import org.eclipse.ui.PartInitException;\r
 import org.eclipse.ui.progress.UIJob;\r
-import org.eclipse.zest.core.widgets.ZestStyles;\r
 import org.netxms.client.NXCObjectModificationData;\r
 import org.netxms.client.maps.NetworkMapLink;\r
 import org.netxms.client.maps.elements.NetworkMapObject;\r
@@ -55,6 +54,15 @@ public class PredefinedMap extends NetworkMap
        private Action actionAddObject;\r
        private Action actionLinkObjects;\r
        \r
+       /**\r
+        * Creare predefined map view\r
+        */\r
+       public PredefinedMap()\r
+       {\r
+               super();\r
+               allowManualLayout = true;\r
+       }\r
+       \r
        /* (non-Javadoc)\r
         * @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#init(org.eclipse.ui.IViewSite)\r
         */\r
@@ -64,6 +72,16 @@ public class PredefinedMap extends NetworkMap
                super.init(site);\r
                mapObject = (org.netxms.client.objects.NetworkMap)rootObject;\r
                setPartName(rootObject.getObjectName());\r
+               \r
+               if (mapObject.getLayout() == org.netxms.client.objects.NetworkMap.LAYOUT_MANUAL)\r
+               {\r
+                       automaticLayoutEnabled = false;\r
+               }\r
+               else\r
+               {\r
+                       automaticLayoutEnabled = true;\r
+                       layoutAlgorithm = mapObject.getLayout();\r
+               }\r
        }\r
 \r
        /* (non-Javadoc)\r
@@ -167,6 +185,15 @@ public class PredefinedMap extends NetworkMap
                super.fillLocalToolBar(manager);\r
        }\r
 \r
+       /* (non-Javadoc)\r
+        * @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#saveLayout()\r
+        */\r
+       @Override\r
+       protected void saveLayout()\r
+       {\r
+               saveMap();\r
+       }\r
+\r
        /**\r
         * Add object to map\r
         */\r
@@ -216,6 +243,7 @@ public class PredefinedMap extends NetworkMap
        {\r
                final NXCObjectModificationData md = new NXCObjectModificationData(rootObject.getObjectId());\r
                md.setMapContent(mapPage.getElements(), mapPage.getLinks());\r
+               md.setMapLayout(automaticLayoutEnabled ? layoutAlgorithm : org.netxms.client.objects.NetworkMap.LAYOUT_MANUAL);\r
                new ConsoleJob("Save map object " + rootObject.getObjectName(), this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {\r
                        @Override\r
                        protected void runInternal(IProgressMonitor monitor) throws Exception\r
@@ -228,7 +256,7 @@ public class PredefinedMap extends NetworkMap
                                                viewer.setInput(mapPage);\r
                                                return Status.OK_STATUS;\r
                                        }\r
-                               };\r
+                               }.schedule();\r
                        }\r
 \r
                        @Override\r
index 13b1efe..be2b564 100644 (file)
@@ -31,6 +31,7 @@ public class SharedIcons
        public static ImageDescriptor CHECKBOX_OFF;\r
        public static ImageDescriptor CHECKBOX_ON;\r
        public static ImageDescriptor REFRESH;\r
+       public static ImageDescriptor SAVE;\r
        public static ImageDescriptor ZOOM_IN;\r
        public static ImageDescriptor ZOOM_OUT;\r
        \r
@@ -43,6 +44,7 @@ public class SharedIcons
                CHECKBOX_OFF = Activator.getImageDescriptor("icons/checkbox_off.png");\r
                CHECKBOX_ON = Activator.getImageDescriptor("icons/checkbox_on.png");\r
                REFRESH = Activator.getImageDescriptor("icons/refresh.gif");\r
+               SAVE = Activator.getImageDescriptor("icons/save.gif");\r
                ZOOM_IN = Activator.getImageDescriptor("icons/zoom_in.png");\r
                ZOOM_OUT = Activator.getImageDescriptor("icons/zoom_out.png");\r
        }\r
index d6de2c5..e1ab533 100644 (file)
@@ -69,7 +69,7 @@ BOOL CPollCfgPage::OnInitDialog()
        CPropertyPage::OnInitDialog();
 
    // Discovery
-   _stprintf(szBuffer, _T("%d"), pc->m_dwDiscoveryPI);
+   _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwDiscoveryPI);
    SetDlgItemText(IDC_EDIT_INT_DP, szBuffer);
    SendDlgItemMessage(IDC_CHECK_RUN_DISCOVERY, BM_SETCHECK, pc->m_bRunAutoDiscovery);
    EnableDlgItem(this, IDC_STATIC_DI, pc->m_bRunAutoDiscovery);
@@ -77,15 +77,15 @@ BOOL CPollCfgPage::OnInitDialog()
    EnableDlgItem(this, IDC_EDIT_INT_DP, pc->m_bRunAutoDiscovery);
 
    // Status poll
-   _stprintf(szBuffer, _T("%d"), pc->m_dwNumStatusPollers);
+   _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwNumStatusPollers);
    SetDlgItemText(IDC_EDIT_NUM_SP, szBuffer);
-   _stprintf(szBuffer, _T("%d"), pc->m_dwStatusPI);
+   _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwStatusPI);
    SetDlgItemText(IDC_EDIT_INT_SP, szBuffer);
        
    // Configuration poll
-   _stprintf(szBuffer, _T("%d"), pc->m_dwNumConfigPollers);
+   _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwNumConfigPollers);
    SetDlgItemText(IDC_EDIT_NUM_CP, szBuffer);
-   _stprintf(szBuffer, _T("%d"), pc->m_dwConfigurationPI);
+   _sntprintf(szBuffer, 32, _T("%d"), pc->m_dwConfigurationPI);
    SetDlgItemText(IDC_EDIT_INT_CP, szBuffer);
        
        return TRUE;