0003-allow-pasting-layers-within-agrupations.patch
applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/actions/PasteLayersTocMenuEntry.java | ||
---|---|---|
83 | 83 |
if (isTocItemBranch(item)) { |
84 | 84 |
MapContext mapContext = getMapContext(); |
85 | 85 |
mapContext.beginAtomicEvent(); |
86 |
try { |
|
87 | ||
88 |
FLayers all = mapContext.getLayers(); |
|
89 |
CopyPasteLayersUtiles.getInstance().loadLayersFromXML(xml, all); |
|
90 |
// ponemos las capas en posici?n |
|
91 |
int pos = -1; |
|
92 |
for (int j=0; j < all.getLayersCount(); j++) { |
|
93 |
if (all.getLayer(j).getName().equalsIgnoreCase(lyrOn.getName())) { |
|
94 |
pos = j; |
|
95 |
break; |
|
96 |
} |
|
97 |
} |
|
98 |
int corrected = 2; |
|
99 |
all.moveTo(0, all.getLayersCount()-corrected-pos); |
|
100 |
} catch (Exception ex) { |
|
101 |
ex.printStackTrace(); |
|
102 |
} |
|
86 |
FLayers all = lyrOn.getParentLayer(); |
|
87 | ||
88 |
CopyPasteLayersUtiles.getInstance().loadLayersFromXML(xml, all); |
|
89 |
int position = getPosition(all, lyrOn); |
|
90 |
all.moveTo(0, position); |
|
103 | 91 | |
104 | 92 |
mapContext.endAtomicEvent(); |
105 | 93 |
mapContext.invalidate(); |
106 | ||
107 | ||
108 |
return; |
|
109 | 94 |
} else if (lyrOn == null) { |
110 | 95 |
root = getMapContext().getLayers(); |
111 | 96 |
getMapContext().beginAtomicEvent(); |
... | ... | |
119 | 104 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
120 | 105 |
project.setModified(true); |
121 | 106 |
} |
122 |
} else { |
|
123 |
return; |
|
124 | 107 |
} |
125 | ||
126 | 108 |
} |
127 | 109 | |
110 |
private int getPosition(FLayers layerGroup, FLayer lyrSelected){ |
|
111 |
int pos = -1; |
|
112 |
for (int j=0; j < layerGroup.getLayersCount(); j++) { |
|
113 |
if (layerGroup.getLayer(j).getName().equalsIgnoreCase(lyrSelected.getName())) { |
|
114 |
pos = j; |
|
115 |
break; |
|
116 |
} |
|
117 |
} |
|
118 |
int offset = 2; |
|
119 |
return layerGroup.getLayersCount() - offset - pos; |
|
120 |
} |
|
128 | 121 | |
129 | 122 |
} |
130 |
- |