svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / ShowEditedFeatures.java @ 47391
History | View | Annotate | Download (2.75 KB)
1 | 42489 | jjdelcerro | package org.gvsig.app.extension; |
---|---|---|---|
2 | |||
3 | import org.gvsig.andami.plugins.Extension; |
||
4 | import org.gvsig.app.ApplicationLocator; |
||
5 | import org.gvsig.app.ApplicationManager; |
||
6 | 45788 | jjdelcerro | import org.gvsig.app.extension.editedfeatures.EditedFeaturesPanel; |
7 | 42489 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
8 | 42683 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureType; |
9 | 42489 | jjdelcerro | import org.gvsig.fmap.mapcontext.layers.FLayer; |
10 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
11 | import org.gvsig.tools.ToolsLocator; |
||
12 | import org.gvsig.tools.i18n.I18nManager; |
||
13 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
14 | 47391 | fdiaz | import org.gvsig.tools.swing.api.ToolsSwingUtils; |
15 | 42489 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
16 | |||
17 | 44281 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
18 | 45788 | jjdelcerro | public class ShowEditedFeatures extends Extension { |
19 | 42489 | jjdelcerro | |
20 | @Override
|
||
21 | public void initialize() { |
||
22 | } |
||
23 | |||
24 | @Override
|
||
25 | public void execute(String actionCommand) { |
||
26 | ApplicationManager application = ApplicationLocator.getManager(); |
||
27 | 45788 | jjdelcerro | if ("layer-show-editedfeatures".equalsIgnoreCase(actionCommand)) { |
28 | FLayer layer = application.getCurrentLayer(); |
||
29 | if (layer == null || !(layer instanceof FLyrVect)) { |
||
30 | 42489 | jjdelcerro | return;
|
31 | } |
||
32 | 45788 | jjdelcerro | FLyrVect vectLayer = (FLyrVect)layer; |
33 | FeatureStore featureStore = vectLayer.getFeatureStore(); |
||
34 | if( !featureStore.isEditing() ) {
|
||
35 | 42683 | jjdelcerro | return;
|
36 | 45788 | jjdelcerro | } |
37 | 42683 | jjdelcerro | try {
|
38 | 45788 | jjdelcerro | FeatureType type = featureStore.getDefaultFeatureType(); |
39 | if( !type.supportReferences() ) {
|
||
40 | return;
|
||
41 | 42683 | jjdelcerro | } |
42 | 45788 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
43 | EditedFeaturesPanel panel = new EditedFeaturesPanel(featureStore);
|
||
44 | WindowManager windowManager = ToolsSwingLocator.getWindowManager(); |
||
45 | 47391 | fdiaz | String title = ToolsSwingUtils.makeTitle(
|
46 | "_Edited_features",
|
||
47 | layer.getName(), |
||
48 | featureStore.getName() |
||
49 | ); |
||
50 | |||
51 | 45788 | jjdelcerro | windowManager.showWindow( |
52 | panel.asJComponent(), |
||
53 | title, |
||
54 | WindowManager.MODE.WINDOW |
||
55 | 43020 | jjdelcerro | ); |
56 | 45788 | jjdelcerro | } catch (Exception ex) { |
57 | logger.warn("Can't show form of edited features",ex);
|
||
58 | 42683 | jjdelcerro | } |
59 | 45788 | jjdelcerro | } |
60 | 42683 | jjdelcerro | } |
61 | |||
62 | 42489 | jjdelcerro | @Override
|
63 | public boolean isEnabled() { |
||
64 | return true; |
||
65 | } |
||
66 | |||
67 | @Override
|
||
68 | public boolean isVisible() { |
||
69 | ApplicationManager application = ApplicationLocator.getManager(); |
||
70 | 45788 | jjdelcerro | FLayer layer = application.getCurrentLayer(); |
71 | if (layer == null || !(layer instanceof FLyrVect)) { |
||
72 | 42489 | jjdelcerro | return false; |
73 | } |
||
74 | 45788 | jjdelcerro | return ((FLyrVect)layer).getFeatureStore().isEditing();
|
75 | 42489 | jjdelcerro | } |
76 | 45788 | jjdelcerro | |
77 | 42489 | jjdelcerro | } |