appGvSIG_Correct_OldTocActions_registration_patch.txt

Francisco José Peñarrubia, 02/07/2012 04:02 PM

Download (3.15 KB)

 
1
Index: src/com/iver/cit/gvsig/project/documents/view/toc/gui/FPopupMenu.java
2
===================================================================
3
--- src/com/iver/cit/gvsig/project/documents/view/toc/gui/FPopupMenu.java	(revision 37875)
4
+++ src/com/iver/cit/gvsig/project/documents/view/toc/gui/FPopupMenu.java	(working copy)
5
@@ -126,7 +126,7 @@
6
 
7
     	OldTocContextMenuAction action = new OldTocContextMenuAction();
8
     	action.setEntry(entry);
9
-    	
10
+    	System.out.println("Add old TocMenuEntry: " + entry);
11
     	TOCManager tm = TOCLocator.getInstance().getTOCManager();
12
 		tm.addServiceFactory(action);
13
     }
14
@@ -296,6 +296,10 @@
15
 			if (!action.isVisible() ||
16
 					(action instanceof TOCActionAdapter &&
17
 							((TOCActionAdapter) action).getContextMenuAction() instanceof OldTocContextMenuAction)) {
18
+				if (((action instanceof TOCActionAdapter) && ((TOCActionAdapter) action).getContextMenuAction() instanceof OldTocContextMenuAction)) {
19
+					OldTocContextMenuAction oldAct = (OldTocContextMenuAction) ((TOCActionAdapter) action).getContextMenuAction();
20
+					oldAct.getEntry().initialize(this);
21
+				}
22
 				continue;
23
 			}
24
 			
25
Index: src/org/gvsig/fmap/swing/impl/toc/DefaultTOCManager.java
26
===================================================================
27
--- src/org/gvsig/fmap/swing/impl/toc/DefaultTOCManager.java	(revision 37875)
28
+++ src/org/gvsig/fmap/swing/impl/toc/DefaultTOCManager.java	(working copy)
29
@@ -27,6 +27,7 @@
30
 
31
 import com.iver.cit.gvsig.fmap.MapContext;
32
 import com.iver.cit.gvsig.project.documents.IContextMenuAction;
33
+import com.iver.cit.gvsig.project.documents.view.toc.actions.OldTocContextMenuAction;
34
 import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
35
 
36
 import org.gvsig.fmap.swing.toc.TOC;
37
@@ -77,6 +78,9 @@
38
 
39
     public void addServiceFactory(IContextMenuAction icma) {
40
         TOCActionFactoryAdapter ada = new TOCActionFactoryAdapter(icma);
41
+        if (icma instanceof OldTocContextMenuAction) {
42
+        	ada.setName(((OldTocContextMenuAction) icma).getEntry().getClass().toString()); 
43
+        }
44
         addServiceFactory(ada);
45
     }
46
 
47
Index: src/org/gvsig/fmap/swing/toc/action/TOCActionFactoryAdapter.java
48
===================================================================
49
--- src/org/gvsig/fmap/swing/toc/action/TOCActionFactoryAdapter.java	(revision 37875)
50
+++ src/org/gvsig/fmap/swing/toc/action/TOCActionFactoryAdapter.java	(working copy)
51
@@ -40,6 +40,7 @@
52
 public class TOCActionFactoryAdapter implements TOCActionFactory {
53
 
54
     private IContextMenuAction icma = null;
55
+    private String name = null;
56
 
57
     public static final String DYN_CLASS_NAME =
58
         TOCActionFactoryAdapter.class.getName() + "_DynClass";
59
@@ -71,9 +72,20 @@
60
     }
61
 
62
     public String getName() {
63
-        return icma.getClass().getName() + "_TOCActionFactoryAdapter";
64
+    	if (name == null) {
65
+    		name = icma.getClass().getName() + "_TOCActionFactoryAdapter";
66
+    	}
67
+        return name;
68
     }
69
-
70
+    
71
+    /**
72
+     * Useful to register OldTocMenuEntry wrappers.
73
+     * @param name
74
+     */
75
+    public void setName(String name) {
76
+    	this.name = name + "_TOCActionFactoryAdapter";
77
+    }
78
+ 
79
     public void initialize() {
80
     }
81