Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / StartEditing.java @ 3829

History | View | Annotate | Download (4.47 KB)

1
package com.iver.cit.gvsig;
2

    
3
import com.iver.andami.PluginServices;
4
import com.iver.andami.plugins.Extension;
5
import com.iver.cit.gvsig.fmap.FMap;
6
import com.iver.cit.gvsig.fmap.edition.EditionException;
7
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
8
import com.iver.cit.gvsig.fmap.layers.FBitSet;
9
import com.iver.cit.gvsig.fmap.layers.FLayer;
10
import com.iver.cit.gvsig.fmap.layers.FLayers;
11
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
12
import com.iver.cit.gvsig.gui.View;
13
import com.iver.cit.gvsig.project.ProjectView;
14

    
15

    
16

    
17

    
18

    
19
/**
20
 * DOCUMENT ME!
21
 *
22
 * @author Vicente Caballero Navarro
23
 */
24
public class StartEditing implements Extension {
25
    /**
26
     * @see com.iver.andami.plugins.Extension#inicializar()
27
     */
28
    public void inicializar() {
29
    }
30

    
31
    /**
32
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
33
     */
34
    public void execute(String actionCommand) {
35
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
36
                                                             .getActiveView();
37

    
38
        if (f instanceof View) {
39
            View vista = (View) f;
40
            vista.showConsole();
41
            ProjectView model = vista.getModel();
42
            FMap mapa = model.getMapContext();
43
            FLayers layers = mapa.getLayers();
44

    
45
            for (int i = 0; i < layers.getLayersCount(); i++) {
46
                if (layers.getLayer(i) instanceof FLyrVect &&
47
                        layers.getLayer(i).isActive()) {
48
                    /* for (int j = 0; j < i; j++) {
49
                        layers.getLayer(j).setVisible(false);
50
                    } */
51

    
52
                    FLyrVect lv = (FLyrVect) layers.getLayer(i);
53
                    // lv.setVisible(true);
54

    
55
                    VectorialEditableAdapter vea = new VectorialEditableAdapter(lv.getSource());
56
                    try{
57
                    vea.startEdition();
58
                    }catch (EditionException e) {
59
                                                // TODO: handle exception
60
                                        }
61
                    lv.setSource(vea);
62
                    //CADExtension.getCADToolAdapter().setVectorialAdapter(vea,new FBitSet());
63
                    lv.setEditing(true);
64
                    /* if (!(layers.getLayer(0)==(lv))){
65
                            layers.removeLayer(lv);
66
                            layers.addLayer(lv);
67
                    } */
68
                    return;
69
                }
70
            }
71

    
72
            /*
73
               PluginServices.getMDIManager().setWaitCursor();
74
               try {
75
                   if (((FLyrVect) capa).getSource().getDriver().getClass() == DXFCadDriver.class) {
76
                       if (JOptionPane.showConfirmDialog(
77
                                   (Component) PluginServices.getMainFrame(),
78
                                   "Todas las geometr?as del formato DXF no se pueden editar, de momento podemos editar: Line, Point, Polyline, Arc, Circle y Ellipse. \n El resto de geometr?as se perder?n con la edici?n. \n ?Desea continuar?") == JOptionPane.YES_OPTION) {
79
                           capa.startEdition();
80
                           vista.getMapControl().setCadTool("selection");
81
                       } else {
82
                       }
83
                   } else {
84
                       capa.startEdition();
85
                       vista.getMapControl().setCadTool("selection");
86
                   }
87
               } catch (EditionException e) {
88
                   // TODO Auto-generated catch block
89
                   e.printStackTrace();
90
               }
91
               PluginServices.getMDIManager().restoreCursor();
92
             */
93
            // vista.getMapControl().drawMap(false);
94
        }
95
    }
96

    
97
    /**
98
     * @see com.iver.andami.plugins.Extension#isEnabled()
99
     */
100
    public boolean isEnabled() {
101
                View f = (View) PluginServices.getMDIManager().getActiveView();
102

    
103
                if (f == null) {
104
                        return false;
105
                }
106

    
107
                FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
108
                if (selected.length == 1 && selected[0] instanceof FLyrVect){
109
                        if (selected[0].isEditing())
110
                                return false;
111
                        else
112
                                return true;
113
                }
114
                return false;
115
    }
116

    
117
    /**
118
     * @see com.iver.andami.plugins.Extension#isVisible()
119
     */
120
    public boolean isVisible() {
121
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
122
                                                             .getActiveView();
123

    
124
        if (f == null) {
125
            return false;
126
        }
127

    
128
        if (f.getClass() == View.class) {
129
            return true;
130
        } else {
131
            return false;
132
        }
133
    }
134
}