Revision 7565 branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/actions/LayersUngroupTocMenuEntry.java

View differences:

LayersUngroupTocMenuEntry.java
50 50
 *
51 51
 * $Id$
52 52
 * $Log$
53
 * Revision 1.2.2.1  2006-09-23 16:05:48  jorpiell
53
 * Revision 1.2.2.2  2006-09-25 14:57:30  jmvivo
54
 * * Modificada la condicion para que no muestre la opcion cuando el toc esta vacio.
55
 * * Modificada la implementacion.
56
 *
57
 * Revision 1.2.2.1  2006/09/23 16:05:48  jorpiell
54 58
 * Se han sacado las opciones de  men? del TOC de FPopupMenu a una nueva clase
55 59
 *
56 60
 *
......
84 88
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
85 89
		if (isTocItemBranch(item)){
86 90
			FLayer lyr = getNodeLayer(item);
87
			if (!(lyr instanceof FLayers)){
91
			if (!(lyr instanceof FLayers) || (lyr instanceof FLayers && lyr.getParentLayer() == null)){
88 92
				return false;
89 93
			}
94
			return true;
90 95
		}
91
		return true;
96
		return false;
92 97

  
93 98
	}
94 99

  
95 100

  
96 101
	public void execute(ITocItem item, FLayer[] selectedItems) {
97 102
		if (isTocItemBranch(item)){
103
					
104
			
98 105
			FLayers agrupa = (FLayers)getNodeLayer(item);
99 106
			FLayers parent=agrupa.getParentLayer();
107
			
100 108
			if (parent!=null){
101
				FLayers allLayers=getMapContext().getLayers();
102
				for (int i=0;i<allLayers.getLayersCount();i++) {
103
					FLayer layer=allLayers.getLayer(i);
104
					if (layer.equals(agrupa)) {
105
						for (int j=0;j<agrupa.getLayersCount();j++){
106
							parent.addLayer(i+j,agrupa.getLayer(j));
107
						}
108
						parent.removeLayer(agrupa);
109
					}
109
				getMapContext().beginAtomicEvent();
110
				while (agrupa.getLayersCount() > 0){
111
					FLayer layer = agrupa.getLayer(0);
112
					parent.addLayer(layer);
113
					agrupa.removeLayer(layer);
110 114
				}
115
				parent.removeLayer(agrupa);
116
				getMapContext().endAtomicEvent();
111 117
			}
112 118
		}
113 119
		// TRUCO PARA REFRESCAR.

Also available in: Unified diff