Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.newlayer.app / org.gvsig.newlayer.app.mainplugin / src / main / java / org / gvsig / newlayer / app / extension / NewLayerExtension.java @ 40557

History | View | Annotate | Download (2.89 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.newlayer.app.extension;
25

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

    
40
/**
41
 * @author gvSIG Team
42
 * @version $Id$
43
 * 
44
 */
45
public class NewLayerExtension extends Extension {
46
        
47
        private ViewDocument view = null;
48

    
49
        public void initialize() {
50
        }
51

    
52
        @Override
53
        public void postInitialize() {
54
                super.postInitialize();
55
        }
56

    
57
        public void execute(String actionCommand) {
58
                
59
                ApplicationManager application = ApplicationLocator.getManager();
60
                ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
61

    
62
                if (view != null) {
63
                        NewLayerManager manager = NewLayerLocator.getManager();
64
                        NewLayerService service = manager.createNewLayerService(view.getMapContext());
65
                        NewLayerWizard wizard = manager.createNewLayerWizard(service);
66
                        
67
                        WindowManager windowMgr = ToolsSwingLocator.getWindowManager();
68
                        windowMgr.showWindow(
69
                            wizard,
70
                            Messages.getText("_New_layer_wizard"),
71
                            WindowManager.MODE.DIALOG);
72
                }
73
        }
74

    
75
        public boolean isEnabled() {
76
                
77
                ApplicationManager application = ApplicationLocator.getManager();
78
                view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
79
                return (view != null);
80
                
81
        }
82

    
83
        public boolean isVisible() {
84
                
85
                ApplicationManager application = ApplicationLocator.getManager();
86
                view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
87
                return (view != null);
88
                
89
        }
90
        
91
        public ViewDocument getView() {
92
                return view;
93
        }
94
        
95
}