Statistics
| Revision:

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

History | View | Annotate | Download (3.79 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 org.gvsig.fmap.raster.layers.FLyrRasterSE;
22
import org.gvsig.fmap.raster.layers.ILayerState;
23
import org.gvsig.fmap.raster.layers.IRasterLayerActions;
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.project.documents.view.toc.AbstractTocContextMenuAction;
29
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
30
/**
31
 * <code>CuttingTocMenuEntry</code> es el punto de entrada del menu del
32
 * recorte.
33
 *
34
 * @version 17/04/2007
35
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class CuttingTocMenuEntry extends AbstractTocContextMenuAction {
38
        /*
39
         * (non-Javadoc)
40
         * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
41
         */
42
        public String getGroup() {
43
                return "Save";
44
        }
45

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

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

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

    
70
        /*
71
         * (non-Javadoc)
72
         * @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[])
73
         */
74
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
75
                if(getNodeLayer(item) instanceof ILayerState) 
76
                        if(!((ILayerState)getNodeLayer(item)).isOpen()) 
77
                                return false;
78
                return selectedItems.length == 1;
79
        }
80

    
81
        /*
82
         * (non-Javadoc)
83
         * @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[])
84
         */
85
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
86
                if (isTocItemBranch(item)) {
87
                        if(selectedItems == null || selectedItems.length != 1)
88
                                return false;
89
                        return( getNodeLayer(item) instanceof FLyrRasterSE && 
90
                                    ((FLyrRasterSE)getNodeLayer(item)).isActionEnabled(IRasterLayerActions.FILTER));
91
                }
92
                return false;
93
        }
94

    
95
        /*
96
         * (non-Javadoc)
97
         * @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[])
98
         */
99
        public void execute(ITocItem item, FLayer[] selectedItems) {
100
                FLayer fLayer = null;
101

    
102
                if (selectedItems.length != 1)
103
                        return;
104

    
105
                fLayer = selectedItems[0];
106

    
107
                if (!(fLayer instanceof FLyrRasterSE))
108
                        return;
109

    
110
                CuttingDialog cuttingDialog = new CuttingDialog(420, 290);
111
                cuttingDialog.setLayer(fLayer);
112
                PluginServices.getMDIManager().addWindow(cuttingDialog);
113
        }
114
}