Revision 41104 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewControls.java
ViewControls.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import javax.swing.JOptionPane; |
28 | 28 |
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 | 29 |
import org.gvsig.andami.IconThemeHelper; |
33 | 30 |
import org.gvsig.andami.PluginServices; |
34 | 31 |
import org.gvsig.andami.plugins.Extension; |
35 | 32 |
import org.gvsig.andami.preferences.IPreference; |
36 | 33 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
34 |
import org.gvsig.app.ApplicationLocator; |
|
35 |
import org.gvsig.app.ApplicationManager; |
|
37 | 36 |
import org.gvsig.app.gui.preferencespage.GridPage; |
38 | 37 |
import org.gvsig.app.gui.preferencespage.ViewPage; |
39 | 38 |
import org.gvsig.app.project.Project; |
40 | 39 |
import org.gvsig.app.project.documents.view.Encuadrator; |
41 | 40 |
import org.gvsig.app.project.documents.view.ViewDocument; |
41 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
42 | 42 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
43 | 43 |
import org.gvsig.app.project.documents.view.gui.ExtentListSelectorModel; |
44 | 44 |
import org.gvsig.app.project.documents.view.gui.FPanelExtentSelector; |
45 | 45 |
import org.gvsig.app.project.documents.view.gui.FPanelLocConfig; |
46 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
46 | 47 |
import org.gvsig.app.project.documents.view.toc.gui.FPopupMenu; |
47 | 48 |
import org.gvsig.app.project.documents.view.toolListeners.snapping.Snapping; |
48 | 49 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
52 | 53 |
import org.gvsig.tools.ToolsLocator; |
53 | 54 |
import org.gvsig.tools.dataTypes.DataTypes; |
54 | 55 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
56 |
import org.slf4j.Logger; |
|
57 |
import org.slf4j.LoggerFactory; |
|
55 | 58 |
|
56 | 59 |
|
57 | 60 |
|
58 |
//import com.iver.utiles.FPanelExtentSelector; |
|
59 |
|
|
60 | 61 |
/** |
61 | 62 |
* Extensi?n que controla las operaciones b?sicas realizadas sobre la vista. |
62 | 63 |
* |
63 |
* @author vcn |
|
64 | 64 |
*/ |
65 | 65 |
public class ViewControls extends Extension implements IPreferenceExtension{ |
66 | 66 |
private static final Logger logger = LoggerFactory |
67 | 67 |
.getLogger(ViewInvertSelection.class); |
68 | 68 |
|
69 | 69 |
private static ViewPage viewPropertiesPage = null; |
70 |
// private DefaultViewPanel vista; |
|
71 | 70 |
/** |
72 | 71 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
73 | 72 |
*/ |
... | ... | |
76 | 75 |
} |
77 | 76 |
|
78 | 77 |
public void execute(String command, Object[] args) { |
78 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
79 | 79 |
|
80 |
DefaultViewPanel vista = getView();
|
|
81 |
if (vista==null) {
|
|
82 |
return;
|
|
80 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
|
|
81 |
if( document == null ) {
|
|
82 |
return;
|
|
83 | 83 |
} |
84 | 84 |
|
85 |
|
|
86 |
ViewDocument document = vista.getViewDocument(); |
|
85 |
IView vista = (IView) document.getMainWindow(); |
|
87 | 86 |
MapContext mapa = document.getMapContext(); |
88 | 87 |
MapControl mapCtrl = vista.getMapControl(); |
89 | 88 |
|
90 | 89 |
if (command.equalsIgnoreCase("view-navigation-zoom-all") ) { |
91 |
// mapa.beginAtomicEvent(); |
|
92 | 90 |
mapa.getViewPort().setEnvelope(mapa.getLayers().getFullEnvelope()); |
93 | 91 |
document.setModified(true); |
94 |
// mapa.endAtomicEvent(); |
|
95 | 92 |
|
96 | 93 |
} else if (command.equalsIgnoreCase("view-navigation-frame-manager") ) { |
97 | 94 |
FPanelExtentSelector l = new FPanelExtentSelector(); |
... | ... | |
99 | 96 |
ProjectExtension p = (ProjectExtension) PluginServices.getExtension(org.gvsig.app.extension.ProjectExtension.class); |
100 | 97 |
Project project = p.getProject(); |
101 | 98 |
ExtentListSelectorModel modelo = new ExtentListSelectorModel(project); |
102 |
//ProjectExtent[] extents = project.getExtents(); |
|
103 | 99 |
project.addPropertyChangeListener(modelo); |
104 | 100 |
l.setModel(modelo); |
105 | 101 |
l.addSelectionListener(new Encuadrator(project, mapa, vista)); |
... | ... | |
107 | 103 |
PluginServices.getMDIManager().addWindow(l); |
108 | 104 |
|
109 | 105 |
} else if (command.equalsIgnoreCase("view-locator-setup") ) { |
110 |
//Set up the map overview |
|
111 |
FPanelLocConfig m_panelLoc = new FPanelLocConfig(vista.getMapOverview()); |
|
106 |
FPanelLocConfig m_panelLoc = new FPanelLocConfig(((DefaultViewPanel)vista).getMapOverview()); |
|
112 | 107 |
PluginServices.getMDIManager().addCentredWindow(m_panelLoc); |
113 | 108 |
document.setModified(true); |
114 | 109 |
|
... | ... | |
127 | 122 |
} else if (command.equalsIgnoreCase("layer-set-visible") ) { |
128 | 123 |
setVisibles(true, mapa.getLayers()); |
129 | 124 |
document.setModified(true); |
130 |
PluginServices.getMainFrame().enableControls();
|
|
125 |
application.refreshMenusAndToolBars();
|
|
131 | 126 |
|
132 | 127 |
} else if (command.equalsIgnoreCase("layer-set-hide") ) { |
133 | 128 |
setVisibles(false, mapa.getLayers()); |
134 | 129 |
document.setModified(true); |
135 |
PluginServices.getMainFrame().enableControls();
|
|
130 |
application.refreshMenusAndToolBars();
|
|
136 | 131 |
|
137 | 132 |
} else if (command.equalsIgnoreCase("layer-set-active") ) { |
138 | 133 |
setActives(true, mapa.getLayers()); |
139 | 134 |
document.setModified(true); |
140 |
PluginServices.getMainFrame().enableControls();
|
|
135 |
application.refreshMenusAndToolBars();
|
|
141 | 136 |
|
142 | 137 |
} else if (command.equalsIgnoreCase("layer-set-inactive") ) { |
143 | 138 |
setActives(false, mapa.getLayers()); |
144 | 139 |
document.setModified(true); |
145 |
PluginServices.getMainFrame().enableControls();
|
|
140 |
application.refreshMenusAndToolBars();
|
|
146 | 141 |
|
147 | 142 |
} else if (command.equalsIgnoreCase("view-navigation-zoom-in-center") ) { |
148 | 143 |
mapCtrl.zoomIn(); |
... | ... | |
159 | 154 |
document.setModified(true); |
160 | 155 |
} catch(Throwable ex) { |
161 | 156 |
logger.info("Can't change scale of view.", ex); |
162 |
PluginServices.getMainFrame().getStatusBar().message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE);
|
|
157 |
application.message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE);
|
|
163 | 158 |
} |
164 | 159 |
} |
165 | 160 |
} |
... | ... | |
207 | 202 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
208 | 203 |
*/ |
209 | 204 |
public boolean isVisible() { |
205 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
210 | 206 |
|
211 |
DefaultViewPanel vista = getView(); |
|
212 |
|
|
213 |
if (vista!=null) { |
|
214 |
ViewDocument model = vista.getViewDocument(); |
|
215 |
MapContext mapa = model.getMapContext(); |
|
216 |
|
|
217 |
return mapa.getLayers().getLayersCount() > 0; |
|
218 |
} |
|
219 |
return false; |
|
207 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
208 |
if( document == null ) { |
|
209 |
return false; |
|
210 |
} |
|
211 |
MapContext mapa = document.getMapContext(); |
|
212 |
return mapa.getLayers().getLayersCount() > 0; |
|
220 | 213 |
} |
221 | 214 |
|
222 |
private DefaultViewPanel getView() { |
|
223 |
|
|
224 |
|
|
225 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
226 |
.getActiveWindow(); |
|
227 |
|
|
228 |
if (f!=null && f instanceof DefaultViewPanel) { |
|
229 |
return (DefaultViewPanel) f; |
|
230 |
} |
|
231 |
return null; |
|
232 |
|
|
233 |
} |
|
234 |
|
|
235 | 215 |
/** |
236 | 216 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
237 | 217 |
*/ |
238 | 218 |
public void initialize() { |
239 |
|
|
240 |
ExtensionPointManager epManager = ToolsLocator.getExtensionPointManager(); |
|
241 |
|
|
242 |
if (!epManager.has("View_TocActions")) { |
|
243 |
epManager.add( |
|
244 |
"View_TocActions", |
|
245 |
"Context menu options of the TOC " + |
|
246 |
" in the view window "+ |
|
247 |
"(register instances of " + |
|
248 |
"org.gvsig.app.gui.toc.AbstractTocContextMenuAction)" |
|
249 |
); |
|
250 |
} |
|
251 |
|
|
252 |
FPopupMenu.registerExtensionPoint(); |
|
253 |
|
|
254 | 219 |
registerIcons(); |
255 | 220 |
Snapping.register(); |
256 | 221 |
} |
257 | 222 |
|
223 |
public void postInitialize() { |
|
224 |
FPopupMenu.registerExtensionPoint(); |
|
225 |
} |
|
226 |
|
|
258 | 227 |
private void registerIcons(){ |
259 | 228 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-in-topoint", this); |
260 | 229 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-out-topoint", this); |
... | ... | |
274 | 243 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
275 | 244 |
*/ |
276 | 245 |
public boolean isEnabled() { |
277 |
|
|
278 |
DefaultViewPanel vista = getView(); |
|
279 |
|
|
280 |
if (vista != null) { |
|
281 |
|
|
282 |
ViewDocument model = vista.getViewDocument(); |
|
283 |
MapContext mapa = model.getMapContext(); |
|
284 |
|
|
285 |
FLayers layers = mapa.getLayers(); |
|
286 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
287 |
if (layers.getLayer(i).isAvailable()) { |
|
288 |
return true; |
|
289 |
} |
|
246 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
247 |
|
|
248 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
|
249 |
if( document == null ) { |
|
250 |
return false; |
|
251 |
} |
|
252 |
MapContext mapa = document.getMapContext(); |
|
253 |
FLayers layers = mapa.getLayers(); |
|
254 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
255 |
if (layers.getLayer(i).isAvailable()) { |
|
256 |
return true; |
|
290 | 257 |
} |
291 | 258 |
} |
292 | 259 |
return false; |
Also available in: Unified diff