Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.newlayer.app / org.gvsig.newlayer.app.extension / src / main / java / org / gvsig / newlayer / app / extension / NewLayerExtension.java @ 37891

History | View | Annotate | Download (2.73 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.newlayer.app.extension;
23

    
24
import org.gvsig.andami.plugins.Extension;
25
import org.gvsig.app.ApplicationLocator;
26
import org.gvsig.app.ApplicationManager;
27
import org.gvsig.app.project.documents.view.ViewDocument;
28
import org.gvsig.app.project.documents.view.ViewManager;
29
import org.gvsig.newlayer.NewLayerLocator;
30
import org.gvsig.newlayer.NewLayerManager;
31
import org.gvsig.newlayer.NewLayerService;
32
import org.gvsig.newlayer.NewLayerWizard;
33
import org.gvsig.tools.swing.api.ToolsSwingLocator;
34
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
35

    
36
/**
37
 * @author gvSIG Team
38
 * @version $Id$
39
 * 
40
 */
41
public class NewLayerExtension extends Extension {
42
        
43
        private ViewDocument view = null;
44

    
45
        public void initialize() {
46
                
47
        }
48

    
49
        @Override
50
        public void postInitialize() {
51
                super.postInitialize();
52
        }
53

    
54
        public void execute(String actionCommand) {
55
                
56
                ApplicationManager application = ApplicationLocator.getManager();
57
                ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
58

    
59
                if (view != null) {
60
                        NewLayerManager manager = NewLayerLocator.getManager();
61
                        NewLayerService service = manager.createNewLayerService(view.getMapContext());
62
                        NewLayerWizard wizard = manager.createNewLayerWizard(service);
63
                        
64
                        WindowManager windowMgr = ToolsSwingLocator.getWindowManager();
65
                        windowMgr.showWindow(wizard, "New layer wizard", WindowManager.MODE.DIALOG);
66
                }
67
        }
68

    
69
        public boolean isEnabled() {
70
                
71
                ApplicationManager application = ApplicationLocator.getManager();
72
                view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
73
                return (view != null);
74
                
75
        }
76

    
77
        public boolean isVisible() {
78
                
79
                ApplicationManager application = ApplicationLocator.getManager();
80
                view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
81
                return (view != null);
82
                
83
        }
84
        
85
        public ViewDocument getView() {
86
                return view;
87
        }
88
        
89
}