Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / properties / dialog / RasterPropertiesTocMenuEntry.java @ 13622

History | View | Annotate | Download (3 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.raster.gui.properties.dialog;
20

    
21
import java.util.logging.Logger;
22

    
23
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
24
import org.gvsig.raster.util.RasterToolsUtil;
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
 * Entrada en del men? contextual del TOC correspondiente al cuadro de 
32
 * propiedades del raster
33
 * 
34
 * @author Nacho Brodin (nachobrodin@gmail.com)
35
 */
36
public class RasterPropertiesTocMenuEntry extends AbstractTocContextMenuAction {
37
        private PropertiesRasterRegistrableDialog properties = null;
38
        private FLayer                            lyr        = null;
39

    
40
        /**
41
         * Variable para controlar si los eventos de los paneles se deben interpretar.
42
         * En la carga inicial se deben desactivar todos los eventos
43
         */
44
        public static boolean                     enableEvents = false;
45

    
46
        public String getGroup() {
47
                return "raster";
48
        }
49

    
50
        public int getGroupOrder() {
51
                return 60;
52
        }
53

    
54
        public int getOrder() {
55
                return 0;
56
        }
57

    
58
        public String getText() {
59
                return PluginServices.getText(this, "propiedades_raster");
60
        }
61

    
62
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
63
                return selectedItems.length == 1;
64
        }
65

    
66
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
67
                if (isTocItemBranch(item))
68
                        return (getNodeLayer(item) instanceof FLyrRasterSE);
69
                return false;
70
        }
71

    
72
        /**
73
         * Gestiona la apertura del dialogo de propiedades de raster cuando se pulsa
74
         * la opci?n asignando a este las propiedades iniciales.
75
         */
76
        public void execute(ITocItem item, FLayer[] selectedItems) {
77
                if (selectedItems.length == 1 )
78
                        lyr = selectedItems[0];
79
                else
80
                        return;
81

    
82
                try {
83
                        enableEvents = false;
84
            properties = new PropertiesRasterRegistrableDialog(lyr, lyr.getName());
85
                        PluginServices.getMDIManager().addWindow(properties);
86
    } catch (EmptyTabsException e) {
87
                        RasterToolsUtil.messageBoxInfo("El panel de propiedades se cerr? por falta de pesta?as.", this);
88
                        Logger.getLogger(getClass().getName()).finest(e.getMessage());
89
    } finally  {
90
            enableEvents = true;
91
    }
92
        }
93
}