Statistics
| Revision:

gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.extension / src / main / java / org / gvsig / gvsig3d / app / import3D / CreateNewLayerOSG.java @ 346

History | View | Annotate | Download (2.91 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
20
package org.gvsig.gvsig3d.app.import3D;
21

    
22
import java.io.File;
23

    
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.project.documents.view.ViewDocument;
28
import org.gvsig.gvsig3d.app.extension.DefaultView3DPanel;
29
import org.gvsig.gvsig3d.map3d.MapContext3D;
30

    
31

    
32
/**
33
 * @author �ngel Fraile Gri��n e-mail: angel.fraile@iver.es
34
 * @since 1.1
35
 * 
36
 * @author jzarzoso gvSIG 2.0 port
37
 * 
38
 */
39
public class CreateNewLayerOSG extends Extension {
40
        
41
        private File _file = null;
42

    
43
        /**
44
         * Creating a new layer OSG editable, ready to insert OSG objects
45
         */
46
        public void execute(String actionCommand) {
47
                if (actionCommand.equals("CREARCAPA")) {
48
                        IWindow activeWindow = PluginServices
49
                                        .getMDIManager().getActiveWindow();
50
                        
51
                        if (activeWindow instanceof DefaultView3DPanel) {
52
                                DefaultView3DPanel vista = (DefaultView3DPanel) activeWindow;
53
                                ViewDocument model = vista.getModel();
54

    
55
                                MapContext3D mapa = (MapContext3D) model.getMapContext();
56
                                PluginServices.getMDIManager().addCentredWindow(new CreateNewLayerOSGPanel(mapa));
57
                        }
58
                        
59
                        return;
60
                }
61
        }
62

    
63
        public void initialize() {
64
                PluginServices.getIconTheme().registerDefault(
65
                                "create_new_layer_OSG",
66
                                this.getClass().getClassLoader().getResource(
67
                                                "images/plugin_link.png"));
68
        }
69
        
70
        public void setFile(File f) {
71
                _file = f;
72
        }
73
        
74
        public File getFile() {
75
                return _file;
76
        }
77

    
78
        public boolean isEnabled() {
79
                IWindow f = PluginServices
80
                                .getMDIManager().getActiveWindow();
81

    
82
                if (f == null) {
83
                        return false;
84
                }
85

    
86
                // Only isEnable = true, where the view has a view3D.
87
                if (f instanceof DefaultView3DPanel) {
88
                        return true;
89
                }
90
                return false;
91

    
92
        }
93

    
94
        public boolean isVisible() {
95
                IWindow f = PluginServices
96
                                .getMDIManager().getActiveWindow();
97

    
98
                if (f == null) {
99
                        return false;
100
                }
101

    
102
                // Only isVisible = true, where the view has a view3D.
103
                if (f instanceof DefaultView3DPanel) {
104
                        return true;
105
                }
106
                return false;
107

    
108
        }
109

    
110
}