Statistics
| Revision:

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

History | View | Annotate | Download (3.91 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
 * Punto de entrada del menu del recorte.
33
 *
34
 * @version 17/04/2007
35
 * @author Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class CuttingTocMenuEntry extends AbstractTocContextMenuAction {
38
        private ArrayList listeners = new ArrayList();
39

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

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

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

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

    
72
        /**
73
         * Los objetos que quieren que se ejecute su listerner deben ser
74
         * registrados a traves de este m?todo. Cuando se ejecute el actionPerformed
75
         * se buscar? todos los objetos registrados y ejecutar? el actionPerformed de
76
         * cada uno,
77
         * @param obj Objeto a registrar
78
         */
79
        public void register(Object obj){
80
                if (obj instanceof IRasterPropertiesRegistrable)
81
                        listeners.add(obj);
82
        }
83
        
84
        /*
85
         * (non-Javadoc)
86
         * @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[])
87
         */
88
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
89
                return selectedItems.length == 1;
90
        }
91

    
92
        /*
93
         * (non-Javadoc)
94
         * @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[])
95
         */
96
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
97
                if (isTocItemBranch(item)) 
98
                        return (getNodeLayer(item) instanceof FLyrRasterSE);
99
                return false;
100
        }
101

    
102
        /*
103
         * (non-Javadoc)
104
         * @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[])
105
         */
106
        public void execute(ITocItem item, FLayer[] selectedItems) {
107
                FLayer fLayer = null;
108
                CuttingDialog cuttingDialog = null;
109
                
110
                if (selectedItems.length == 1 )
111
                        fLayer = selectedItems[0];
112
                else
113
                        return;
114

    
115
                fLayer = getNodeLayer(item);
116
                
117
                cuttingDialog = new CuttingDialog(650, 500);
118

    
119
                cuttingDialog.setVisible(true);
120
                                                                
121
                PluginServices.getMDIManager().addWindow(cuttingDialog);
122
        }
123
}