root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / ViewCommandStackExtension.java @ 30638
History | View | Annotate | Download (3 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
4 |
import com.iver.andami.PluginServices; |
5 |
import com.iver.andami.messages.NotificationManager; |
6 |
import com.iver.andami.plugins.Extension; |
7 |
import com.iver.cit.gvsig.fmap.MapContext; |
8 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
9 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
10 |
import com.iver.cit.gvsig.fmap.edition.commands.CommandListener; |
11 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
12 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
13 |
import com.iver.cit.gvsig.gui.cad.CADTool; |
14 |
import com.iver.cit.gvsig.gui.command.CommandStackDialog; |
15 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
16 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
17 |
|
18 |
/**
|
19 |
* DOCUMENT ME!
|
20 |
*
|
21 |
* @author Vicente Caballero Navarro
|
22 |
*/
|
23 |
public class ViewCommandStackExtension extends Extension implements CommandListener{ |
24 |
public static CommandStackDialog csd=null; |
25 |
/**
|
26 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
27 |
*/
|
28 |
public void initialize() { |
29 |
PluginServices.getIconTheme().registerDefault( |
30 |
"commands-stack",
|
31 |
this.getClass().getClassLoader().getResource("images/commandstack.png") |
32 |
); |
33 |
} |
34 |
|
35 |
/**
|
36 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
37 |
*/
|
38 |
public void execute(String s) { |
39 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
40 |
.getActiveWindow(); |
41 |
|
42 |
View vista = (View) f; |
43 |
IProjectView model = vista.getModel(); |
44 |
MapContext mapa = model.getMapContext(); |
45 |
FLayers layers = mapa.getLayers(); |
46 |
if (s.equals("COMMANDSTACK")) { |
47 |
for (int i =0;i<layers.getLayersCount();i++){ |
48 |
if (layers.getLayer(i) instanceof FLyrVect){ |
49 |
FLyrVect lyrVect=(FLyrVect)layers.getLayer(i); |
50 |
if (lyrVect.isEditing() && lyrVect.isActive()){
|
51 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) lyrVect |
52 |
.getSource(); |
53 |
vea.getCommandRecord().addCommandListener(this);
|
54 |
csd=new CommandStackDialog();
|
55 |
csd.setModel(((IEditableSource)lyrVect.getSource()).getCommandRecord()); |
56 |
PluginServices.getMDIManager().addWindow(csd); |
57 |
return;
|
58 |
} |
59 |
} |
60 |
} |
61 |
} |
62 |
|
63 |
//PluginServices.getMainFrame().enableControls();
|
64 |
|
65 |
} |
66 |
|
67 |
/**
|
68 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
69 |
*/
|
70 |
public boolean isEnabled() { |
71 |
|
72 |
return true; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
77 |
*/
|
78 |
public boolean isVisible() { |
79 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
80 |
return true; |
81 |
return false; |
82 |
|
83 |
} |
84 |
|
85 |
public void commandRepaint() { |
86 |
try {
|
87 |
CADTool cadTool=CADExtension.getCADTool(); |
88 |
if (cadTool!=null){ |
89 |
cadTool.clearSelection(); |
90 |
} |
91 |
} catch (ReadDriverException e) {
|
92 |
NotificationManager.addError(e.getMessage(),e); |
93 |
} |
94 |
|
95 |
} |
96 |
|
97 |
public void commandRefresh() { |
98 |
try {
|
99 |
CADTool cadTool=CADExtension.getCADTool(); |
100 |
if (cadTool!=null){ |
101 |
cadTool.clearSelection(); |
102 |
} |
103 |
} catch (ReadDriverException e) {
|
104 |
NotificationManager.addError(e.getMessage(),e); |
105 |
} |
106 |
} |
107 |
} |