root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / TableCommandStackExtension.java @ 29616
History | View | Annotate | Download (2.68 KB)
1 | 29616 | jpiera | package org.gvsig.editing; |
---|---|---|---|
2 | 4118 | caballero | |
3 | 29616 | jpiera | import org.gvsig.andami.PluginServices; |
4 | import org.gvsig.andami.plugins.Extension; |
||
5 | import org.gvsig.app.gui.command.CommandStackDialog; |
||
6 | import org.gvsig.app.project.documents.table.FeatureTableDocument; |
||
7 | import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
||
8 | 24500 | jmvivo | import org.gvsig.fmap.dal.exception.DataException; |
9 | 24966 | vcaballero | import org.gvsig.fmap.dal.feature.FeatureStore; |
10 | 21666 | vcaballero | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
11 | |||
12 | 4118 | caballero | |
13 | /**
|
||
14 | * DOCUMENT ME!
|
||
15 | *
|
||
16 | * @author Vicente Caballero Navarro
|
||
17 | */
|
||
18 | 5005 | jorpiell | public class TableCommandStackExtension extends Extension { |
19 | 4118 | caballero | /**
|
20 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#initialize()
|
21 | 4118 | caballero | */
|
22 | 5005 | jorpiell | public void initialize() { |
23 | 15637 | jmvivo | PluginServices.getIconTheme().registerDefault( |
24 | 14810 | jmvivo | "commands-stack",
|
25 | this.getClass().getClassLoader().getResource("images/commandstack.png") |
||
26 | ); |
||
27 | 4118 | caballero | } |
28 | |||
29 | /**
|
||
30 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
31 | 4118 | caballero | */
|
32 | public void execute(String s) { |
||
33 | 29616 | jpiera | org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
34 | 24966 | vcaballero | .getActiveWindow(); |
35 | 4118 | caballero | |
36 | 25069 | vcaballero | FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f; |
37 | FeatureTableDocument model = table.getModel(); |
||
38 | 4118 | caballero | if (s.equals("COMMANDSTACK")) { |
39 | 24966 | vcaballero | try {
|
40 | 25069 | vcaballero | FeatureStore featureStore=((FLyrVect)model.getAssociatedLayer()).getFeatureStore(); |
41 | 24966 | vcaballero | featureStore.addObserver(table); |
42 | 4118 | caballero | |
43 | 24966 | vcaballero | // CommandsRecord cr=null;
|
44 | |||
45 | // if (model.getAssociatedTable()!=null){
|
||
46 | // try {
|
||
47 | // cr=((FLyrVect)model.getAssociatedTable()).getFeatureStore().getCommandsRecord();
|
||
48 | // } catch (ReadException e) {
|
||
49 | // // TODO Auto-generated catch block
|
||
50 | // e.printStackTrace();
|
||
51 | // } catch (DataException e) {
|
||
52 | // // TODO Auto-generated catch block
|
||
53 | // e.printStackTrace();
|
||
54 | // }
|
||
55 | // cr.addObserver(table);
|
||
56 | // }else{
|
||
57 | // try {
|
||
58 | // cr=model.getModel().getCommandsRecord();
|
||
59 | // } catch (DataException e) {
|
||
60 | // // TODO Auto-generated catch block
|
||
61 | // e.printStackTrace();
|
||
62 | // }
|
||
63 | // cr.addObserver(table);
|
||
64 | // }
|
||
65 | CommandStackDialog csd = new CommandStackDialog();
|
||
66 | |||
67 | 25563 | vcaballero | csd.setModel(featureStore); |
68 | 24966 | vcaballero | |
69 | PluginServices.getMDIManager().addWindow(csd); |
||
70 | } catch (DataException e) {
|
||
71 | e.printStackTrace(); |
||
72 | 4118 | caballero | } |
73 | } |
||
74 | } |
||
75 | |||
76 | /**
|
||
77 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
78 | 4118 | caballero | */
|
79 | public boolean isEnabled() { |
||
80 | return true; |
||
81 | } |
||
82 | |||
83 | /**
|
||
84 | 29616 | jpiera | * @see org.gvsig.andami.plugins.IExtension#isVisible()
|
85 | 4118 | caballero | */
|
86 | public boolean isVisible() { |
||
87 | 29616 | jpiera | org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
88 | 6880 | cesar | .getActiveWindow(); |
89 | 25069 | vcaballero | if (f instanceof FeatureTableDocumentPanel){ |
90 | FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f; |
||
91 | FeatureTableDocument model = table.getModel(); |
||
92 | if (model.getStore().isEditing())
|
||
93 | 4118 | caballero | return true; |
94 | } |
||
95 | return false; |
||
96 | |||
97 | } |
||
98 | } |