Revision 42878
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
60 | 60 |
|
61 | 61 |
<extension class-name="org.gvsig.app.extension.selectioncount.SelectionCountExtension" |
62 | 62 |
description="Counts selected features" |
63 |
active="true">
|
|
63 |
active="false">
|
|
64 | 64 |
</extension> |
65 | 65 |
|
66 | 66 |
<extension class-name="org.gvsig.app.extension.CheckSOAndArquitectureExtension" |
... | ... | |
155 | 155 |
<menu text="tools" |
156 | 156 |
position="900000000" |
157 | 157 |
is_separator="true"/> |
158 |
|
|
158 |
|
|
159 | 159 |
<menu text="tools/Development" |
160 | 160 |
position="908500000" |
161 | 161 |
is_separator="true"/> |
162 |
|
|
162 |
|
|
163 | 163 |
<menu text="tools/Development/sep1" |
164 | 164 |
position="908500190" |
165 | 165 |
is_separator="true"/> |
166 |
|
|
166 |
|
|
167 | 167 |
<menu text="tools/Development/sep2" |
168 | 168 |
position="908500290" |
169 | 169 |
is_separator="true"/> |
170 |
|
|
170 |
|
|
171 | 171 |
<menu text="tools/Development/sep3" |
172 | 172 |
position="908500590" |
173 | 173 |
is_separator="true"/> |
174 |
|
|
174 |
|
|
175 | 175 |
<menu text="tools/Development/sep4" |
176 | 176 |
position="908500690" |
177 | 177 |
is_separator="true"/> |
... | ... | |
183 | 183 |
<menu text="tools/Development/sep6" |
184 | 184 |
position="908501390" |
185 | 185 |
is_separator="true"/> |
186 |
|
|
186 |
|
|
187 | 187 |
<menu text="tools/Development/sep7" |
188 | 188 |
position="908501490" |
189 | 189 |
is_separator="true"/> |
190 |
|
|
190 |
|
|
191 | 191 |
<menu text="Window" |
192 | 192 |
position="960000000" |
193 | 193 |
is_separator="true"/> |
... | ... | |
1050 | 1050 |
/> |
1051 | 1051 |
|
1052 | 1052 |
</extension> |
1053 |
|
|
1053 |
|
|
1054 | 1054 |
<extension class-name="org.gvsig.app.extension.logviewer.LogViewerExtension" |
1055 | 1055 |
description="Muestra el registro de errores de la aplicacion." |
1056 | 1056 |
active="true" |
... | ... | |
1072 | 1072 |
/> |
1073 | 1073 |
|
1074 | 1074 |
</extension> |
1075 |
|
|
1075 |
|
|
1076 | 1076 |
<extension |
1077 | 1077 |
class-name="org.gvsig.app.extension.BrowseSymbolsExtension" |
1078 | 1078 |
description="" active="true"> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/selectioncount/SelectionCountExtension.java | ||
---|---|---|
12 | 12 |
import org.gvsig.andami.PluginsLocator; |
13 | 13 |
import org.gvsig.andami.plugins.Extension; |
14 | 14 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
15 |
import org.gvsig.andami.ui.mdiFrame.NewStatusBar; |
|
15 | 16 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
16 | 17 |
import org.gvsig.app.ApplicationLocator; |
17 | 18 |
import org.gvsig.app.ApplicationManager; |
... | ... | |
32 | 33 |
*/ |
33 | 34 |
public class SelectionCountExtension extends Extension { |
34 | 35 |
private IControl control; |
35 |
private SelectionCount selectionCount=null;
|
|
36 |
private SelectionCount selectionCount; |
|
36 | 37 |
|
37 | 38 |
@Override |
38 | 39 |
public void initialize() { |
... | ... | |
48 | 49 |
|
49 | 50 |
@Override |
50 | 51 |
public boolean isEnabled() { |
51 |
//FIXME This should been done through a window listener to be triggered when it changes to another one. |
|
52 |
if (this.control==null){ |
|
53 |
this.control=createLabel(); |
|
54 |
} |
|
55 |
if (selectionCount==null){ |
|
56 |
selectionCount=new SelectionCount(control); |
|
57 |
} |
|
58 |
|
|
59 |
IView view = getActiveView(); |
|
60 |
if (view != null) { |
|
61 |
selectionCount.showFeatureCount(view.getMapControl()); |
|
62 |
} |
|
63 |
|
|
64 | 52 |
return true; |
65 | 53 |
} |
66 | 54 |
|
... | ... | |
70 | 58 |
if (window instanceof IView) { |
71 | 59 |
IView view = (IView)window; |
72 | 60 |
ViewDocument viewDocument = view.getViewDocument(); |
73 |
FLayers layers = viewDocument.getMapContext().getLayers(); |
|
74 |
if (layers!=null){ |
|
75 |
FLayer[] activeLayers = layers.getActives(); |
|
76 |
if (activeLayers!=null && activeLayers.length>0){ |
|
77 |
return true; |
|
78 |
} |
|
79 |
} |
|
61 |
return viewDocument.getMapContext().hasActiveVectorLayers(); |
|
80 | 62 |
} |
81 |
|
|
82 | 63 |
return false; |
83 | 64 |
} |
84 | 65 |
|
... | ... | |
98 | 79 |
if (this.control==null){ |
99 | 80 |
this.control=createLabel(); |
100 | 81 |
} |
101 |
MapControlLocator.getMapControlManager().addMapControlCreationListener(new MapControlCreationListener() { |
|
102 |
|
|
103 |
@Override |
|
104 |
public MapControl mapControlCreated(MapControl mapControl) { |
|
105 |
new SelectionCount(mapControl,control); |
|
106 |
return mapControl; |
|
107 |
} |
|
108 |
}); |
|
82 |
selectionCount = new SelectionCount(this.control); |
|
109 | 83 |
} |
110 | 84 |
|
111 | 85 |
private IControl createLabel(){ |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/selectioncount/SelectionCount.java | ||
---|---|---|
8 | 8 |
|
9 | 9 |
import javax.swing.JLabel; |
10 | 10 |
|
11 |
import org.gvsig.app.ApplicationLocator; |
|
12 |
import org.gvsig.app.ApplicationManager; |
|
13 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
14 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
11 | 15 |
import org.gvsig.fmap.dal.exception.DataException; |
12 | 16 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
13 | 17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
14 | 18 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
19 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
20 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
15 | 21 |
import org.gvsig.fmap.mapcontext.events.AtomicEvent; |
16 | 22 |
import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener; |
17 | 23 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
... | ... | |
20 | 26 |
import org.gvsig.fmap.mapcontext.layers.LayerListener; |
21 | 27 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
22 | 28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
29 |
import org.gvsig.fmap.mapcontrol.MapControlCreationListener; |
|
30 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
|
31 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
|
23 | 32 |
import org.gvsig.gui.beans.controls.IControl; |
24 | 33 |
import org.gvsig.tools.observer.Observable; |
25 | 34 |
import org.gvsig.tools.observer.Observer; |
... | ... | |
31 | 40 |
* @author Daniel Martinez |
32 | 41 |
* |
33 | 42 |
*/ |
34 |
public class SelectionCount implements AtomicEventListener, LayerListener,Observer{
|
|
43 |
public class SelectionCount implements LayerListener,Observer{ |
|
35 | 44 |
private static Logger logger = |
36 | 45 |
LoggerFactory.getLogger(SelectionCount.class); |
37 | 46 |
|
38 |
private MapControl mapControl; |
|
39 | 47 |
private IControl control; |
40 | 48 |
|
41 | 49 |
/** |
... | ... | |
43 | 51 |
* @param mapControl |
44 | 52 |
* @param control |
45 | 53 |
*/ |
46 |
public SelectionCount (MapControl mapControl, IControl control){ |
|
47 |
this.mapControl=mapControl; |
|
48 |
this.control=control; |
|
49 |
mapControl.getMapContext().addAtomicEventListener(this); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* To use methods showFeatureCount and clean with another map control |
|
54 |
* @param control |
|
55 |
*/ |
|
56 | 54 |
public SelectionCount (IControl control){ |
57 | 55 |
this.control=control; |
56 |
MapControlManager mapControlManager = MapControlLocator.getMapControlManager(); |
|
57 |
mapControlManager.addMapControlCreationListener(new MapControlCreationListener() { |
|
58 |
@Override |
|
59 |
public MapControl mapControlCreated(final MapControl mapControl) { |
|
60 |
final MapContext mapContext = mapControl.getMapContext(); |
|
61 |
mapContext.addAtomicEventListener(new AtomicEventListener() { |
|
62 |
@Override |
|
63 |
public void atomicEvent(AtomicEvent e) { |
|
64 |
doAtomicEvent(mapContext, e); |
|
65 |
} |
|
66 |
}); |
|
67 |
return mapControl; |
|
68 |
} |
|
69 |
}); |
|
58 | 70 |
} |
59 | 71 |
|
60 |
@Override |
|
61 |
public void atomicEvent(AtomicEvent e) { |
|
72 |
public void doAtomicEvent(MapContext mapContext, AtomicEvent e) { |
|
62 | 73 |
LayerCollectionEvent[] events = e.getLayerCollectionEvents(); |
63 | 74 |
for( int i=0; i<events.length ; i++ ) { |
64 | 75 |
if( events[i].getEventType() == LayerCollectionEvent.LAYER_ADDED ) { |
... | ... | |
68 | 79 |
if( events[i].getEventType() == LayerCollectionEvent.LAYER_REMOVED ) { |
69 | 80 |
FLayer fLayer = events[i].getAffectedLayer(); |
70 | 81 |
fLayer.removeLayerListener(this); |
71 |
showFeatureCount(mapControl);
|
|
82 |
showFeatureCount(); |
|
72 | 83 |
} |
73 | 84 |
} |
74 | 85 |
} |
... | ... | |
83 | 94 |
if (e.getEventType()==LayerEvent.ACTIVATION_CHANGED){ |
84 | 95 |
FLayer fLayer =e.getSource(); |
85 | 96 |
if( fLayer.isAvailable() ) { |
86 |
showFeatureCount(mapControl);
|
|
97 |
showFeatureCount(); |
|
87 | 98 |
if (fLayer.isActive()){ |
88 | 99 |
if (fLayer instanceof FLyrVect) { |
89 | 100 |
FLyrVect lyrVect = (FLyrVect) fLayer; |
... | ... | |
125 | 136 |
event.getType() == FeatureStoreNotification.SELECTION_CHANGE ){ |
126 | 137 |
|
127 | 138 |
if (event.getSource() instanceof FeatureStore){ |
128 |
showFeatureCount(mapControl);
|
|
139 |
showFeatureCount(); |
|
129 | 140 |
} |
130 | 141 |
} |
131 | 142 |
} |
... | ... | |
135 | 146 |
* Gets the features from the selected layers and shows them through the control |
136 | 147 |
* @param mapControl |
137 | 148 |
*/ |
138 |
public void showFeatureCount(MapControl mapControl){ |
|
149 |
public void showFeatureCount(){ |
|
150 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
151 |
ViewDocument viewDoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
152 |
if( viewDoc == null ) { |
|
153 |
return; |
|
154 |
} |
|
155 |
MapContext mapContext = viewDoc.getMapContext(); |
|
139 | 156 |
Long totalFeaturesCount=Long.valueOf(0); |
140 | 157 |
Long selectedFeaturesCount=Long.valueOf(0);; |
141 |
if (mapControl!=null){
|
|
142 |
FLayer[] actives =mapControl.getMapContext().getLayers().getActives();
|
|
158 |
if (mapContext!=null){
|
|
159 |
FLayer[] actives =mapContext.getLayers().getActives();
|
|
143 | 160 |
if (actives!=null && actives.length>0){ |
144 | 161 |
for(FLayer fLayer:actives){ |
145 | 162 |
if (fLayer instanceof FLyrVect) { |
Also available in: Unified diff