Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / InsertMultiPointExtension.java @ 40557

History | View | Annotate | Download (3.44 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.editing;
25

    
26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.messages.NotificationManager;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
31
import org.gvsig.editing.gui.cad.tools.MultiPointCADTool;
32
import org.gvsig.fmap.dal.exception.ReadException;
33
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
34
import org.gvsig.fmap.mapcontrol.MapControl;
35

    
36
/**
37
 * Extensi?n que gestiona la inserci?n de multipuntos en edici?n.
38
 *
39
 * @author Vicente Caballero Navarro
40
 */
41
public class InsertMultiPointExtension extends Extension {
42
   private DefaultViewPanel view;
43
   private MapControl mapControl;
44
   private MultiPointCADTool multipoint;
45

    
46
   /**
47
     * @see org.gvsig.andami.plugins.IExtension#initialize()
48
     */
49
    public void initialize() {
50
        multipoint = new MultiPointCADTool();
51
        CADExtension.addCADTool("_multipoint", multipoint);
52

    
53
        registerIcons();
54
    }
55

    
56
    private void registerIcons(){
57
            IconThemeHelper.registerIcon("action", "layer-insert-multipoint", this);
58

    
59
    }
60
    /**
61
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
62
     */
63
    public void execute(String s) {
64
            CADExtension.initFocus();
65

    
66
        if (s.equals("layer-insert-multipoint")) {
67
                CADExtension.setCADTool("_multipoint",true);
68
                CADExtension.getEditionManager().setMapControl(mapControl);
69
        }
70
        CADExtension.getCADToolAdapter().configureMenu();
71
    }
72
    /**
73
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
74
     */
75
    public boolean isEnabled() {
76

    
77
              try {
78
                        if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE){
79
                                view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
80
                        mapControl = view.getMapControl();
81
                        if (CADExtension.getEditionManager().getActiveLayerEdited()==null)
82
                                        return false;
83
                        FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer();
84
                                if (multipoint.isApplicable(lv.getShapeType())){
85
                                        return true;
86
                                }
87
                        }
88
                } catch (ReadException e) {
89
                        NotificationManager.addError(e.getMessage(),e);
90
                }
91
                return false;
92
    }
93

    
94
    /**
95
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
96
     */
97
    public boolean isVisible() {
98
            if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
99
                        return true;
100
                return false;
101
    }
102
        }