0001-copy-or-cut-layer-above-agrupation.patch

Andrés Maneiro, 03/06/2012 07:07 PM

Download (4.09 KB)

View differences:

applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/actions/PasteLayersTocMenuEntry.java
88 88

  
89 89
		FLayer lyrOn = getNodeLayer(item);
90 90
		if (isTocItemBranch(item)) {
91
			if (lyrOn instanceof FLayers) {
92
				root = (FLayers)getNodeLayer(item);
93
			}
94
			else
95
			{
96
				// Cambio: Siempre arriba
97
//				JPopupMenu pop = new JPopupMenu(PluginServices.getText(this, "Paste"));
98
//				JMenuItem itUp = new JMenuItem(PluginServices.getText(this, "Paste_above_layer") + " " + lyrOn.getName());
99
//				JMenuItem itDown = new JMenuItem(PluginServices.getText(this, "Paste_below_layer") + " " + lyrOn.getName());
100
//				
101
//				itUp.setActionCommand("UP");
102
//				itDown.setActionCommand("DOWN");
103
//				
104
//				MyPasteListener lis = new MyPasteListener(pop, item, this.xml, lyrOn, getMapContext());		
105
//				
106
//				itUp.addActionListener(lis);
107
//				itDown.addActionListener(lis);
108
//				
109
//				pop.add(itUp);
110
//				pop.add(itDown);
111
//				
112
//				PointerInfo pi = MouseInfo.getPointerInfo();
113
//				
114
//				pop.show(null, pi.getLocation().x, pi.getLocation().y);
115

  
116
				MapContext mapContext = getMapContext();
117
				mapContext.beginAtomicEvent();
118
				try {
119
					
120
					FLayers all = mapContext.getLayers();
121
					CopyPasteLayersUtiles.getInstance().loadLayersFromXML(xml, all);
122
						// ponemos las capas en posici?n
123
						int pos = -1;
124
						for (int j=0; j < all.getLayersCount(); j++) {
125
							if (all.getLayer(j).getName().equalsIgnoreCase(lyrOn.getName())) {
126
								pos = j;
127
								break;
128
							}
129
						}
130
						int corrected = 2;
131
						all.moveTo(0, all.getLayersCount()-corrected-pos);
132
				} catch (Exception ex) {
133
					ex.printStackTrace();
91
			MapContext mapContext = getMapContext();
92
			mapContext.beginAtomicEvent();
93
			try {
94

  
95
				FLayers all = mapContext.getLayers();
96
				CopyPasteLayersUtiles.getInstance().loadLayersFromXML(xml, all);
97
				// ponemos las capas en posici?n
98
				int pos = -1;
99
				for (int j=0; j < all.getLayersCount(); j++) {
100
					if (all.getLayer(j).getName().equalsIgnoreCase(lyrOn.getName())) {
101
						pos = j;
102
						break;
103
					}
134 104
				}
135
						
136
				mapContext.endAtomicEvent();
137
				mapContext.invalidate();
138
				
139

  
140
				return;
105
				int corrected = 2;
106
				all.moveTo(0, all.getLayersCount()-corrected-pos);
107
			} catch (Exception ex) {
108
				ex.printStackTrace();
141 109
			}
142
		} else if (lyrOn == null){
143
			root = getMapContext().getLayers();
144
		} else {
110

  
111
			mapContext.endAtomicEvent();
112
			mapContext.invalidate();
113

  
114

  
145 115
			return;
146
		}
116
		} else if (lyrOn == null) {
117
			root = getMapContext().getLayers();
118
			getMapContext().beginAtomicEvent();
147 119

  
148
		getMapContext().beginAtomicEvent();
149
		
150
		boolean isOK = this.utiles.loadLayersFromXML(this.xml,root);
120
			boolean isOK = this.utiles.loadLayersFromXML(this.xml,root);
151 121

  
152
		getMapContext().endAtomicEvent();
122
			getMapContext().endAtomicEvent();
153 123

  
154
		if (isOK) {
155
			getMapContext().invalidate();
156
			Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
157
			project.setModified(true);
124
			if (isOK) {
125
				getMapContext().invalidate();
126
				Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
127
				project.setModified(true);
128
			}
129
		} else {
130
			return;
158 131
		}
132

  
159 133
	}
160 134

  
161 135

  
162
-