Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / cutting / CuttingTocMenuEntry.java @ 12264

History | View | Annotate | Download (3.92 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.cutting;
20

    
21
import java.util.ArrayList;
22

    
23
import org.gvsig.fmap.layers.FLyrRasterSE;
24
import org.gvsig.rastertools.cutting.ui.CuttingDialog;
25

    
26
import com.iver.andami.PluginServices;
27
import com.iver.cit.gvsig.fmap.layers.FLayer;
28
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable;
29
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
30
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
31
/**
32
 * <code>CuttingTocMenuEntry</code> es el punto de entrada del menu del
33
 * recorte.
34
 *
35
 * @version 17/04/2007
36
 * @author Borja S?nchez Zamorano (borja.sanchez@iver.es)
37
 */
38
public class CuttingTocMenuEntry extends AbstractTocContextMenuAction {
39
        private ArrayList listeners = new ArrayList();
40

    
41
        /*
42
         * (non-Javadoc)
43
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
44
         */
45
        public String getGroup() {
46
                return "Save";
47
        }
48

    
49
        /*
50
         * (non-Javadoc)
51
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
52
         */
53
        public int getGroupOrder() {
54
                return 50;
55
        }
56

    
57
        /*
58
         * (non-Javadoc)
59
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
60
         */
61
        public int getOrder() {
62
                return 1;
63
        }
64

    
65
        /*
66
         * (non-Javadoc)
67
         * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
68
         */
69
        public String getText() {
70
                return PluginServices.getText(this, "recorte");
71
        }
72

    
73
        /**
74
         * Los objetos que quieren que se ejecute su listerner deben ser
75
         * registrados a traves de este m?todo. Cuando se ejecute el actionPerformed
76
         * se buscar? todos los objetos registrados y ejecutar? el actionPerformed de
77
         * cada uno,
78
         * @param obj Objeto a registrar
79
         */
80
        public void register(Object obj){
81
                if (obj instanceof IRasterPropertiesRegistrable)
82
                        listeners.add(obj);
83
        }
84

    
85
        /*
86
         * (non-Javadoc)
87
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
88
         */
89
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
90
                return selectedItems.length == 1;
91
        }
92

    
93
        /*
94
         * (non-Javadoc)
95
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
96
         */
97
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
98
                if (isTocItemBranch(item))
99
                        return (getNodeLayer(item) instanceof FLyrRasterSE);
100
                return false;
101
        }
102

    
103
        /*
104
         * (non-Javadoc)
105
         * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
106
         */
107
        public void execute(ITocItem item, FLayer[] selectedItems) {
108
                FLayer fLayer = null;
109

    
110
                if (selectedItems.length != 1)
111
                        return;
112

    
113
                fLayer = selectedItems[0];
114

    
115
                if (!(fLayer instanceof FLyrRasterSE))
116
                        return;
117

    
118
                CuttingDialog cuttingDialog = new CuttingDialog(435, 263);
119
                cuttingDialog.setLayer(fLayer);
120
                PluginServices.getMDIManager().addWindow(cuttingDialog);
121
        }
122
}