svn-gvsig-desktop / tags / v2_0_0_Build_2059 / extensions / org.gvsig.newlayer.app / org.gvsig.newlayer.app.extension / src / main / java / org / gvsig / newlayer / app / extension / NewLayerExtension.java @ 39332
History | View | Annotate | Download (2.84 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.IconThemeHelper; |
25 |
import org.gvsig.andami.plugins.Extension; |
26 |
import org.gvsig.app.ApplicationLocator; |
27 |
import org.gvsig.app.ApplicationManager; |
28 |
import org.gvsig.app.project.documents.view.ViewDocument; |
29 |
import org.gvsig.app.project.documents.view.ViewManager; |
30 |
import org.gvsig.i18n.Messages; |
31 |
import org.gvsig.newlayer.NewLayerLocator; |
32 |
import org.gvsig.newlayer.NewLayerManager; |
33 |
import org.gvsig.newlayer.NewLayerService; |
34 |
import org.gvsig.newlayer.NewLayerWizard; |
35 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
36 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
37 |
|
38 |
/**
|
39 |
* @author gvSIG Team
|
40 |
* @version $Id$
|
41 |
*
|
42 |
*/
|
43 |
public class NewLayerExtension extends Extension { |
44 |
|
45 |
private ViewDocument view = null; |
46 |
|
47 |
public void initialize() { |
48 |
} |
49 |
|
50 |
@Override
|
51 |
public void postInitialize() { |
52 |
super.postInitialize();
|
53 |
} |
54 |
|
55 |
public void execute(String actionCommand) { |
56 |
|
57 |
ApplicationManager application = ApplicationLocator.getManager(); |
58 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
59 |
|
60 |
if (view != null) { |
61 |
NewLayerManager manager = NewLayerLocator.getManager(); |
62 |
NewLayerService service = manager.createNewLayerService(view.getMapContext()); |
63 |
NewLayerWizard wizard = manager.createNewLayerWizard(service); |
64 |
|
65 |
WindowManager windowMgr = ToolsSwingLocator.getWindowManager(); |
66 |
windowMgr.showWindow( |
67 |
wizard, |
68 |
Messages.getText("_New_layer_wizard"),
|
69 |
WindowManager.MODE.DIALOG); |
70 |
} |
71 |
} |
72 |
|
73 |
public boolean isEnabled() { |
74 |
|
75 |
ApplicationManager application = ApplicationLocator.getManager(); |
76 |
view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
77 |
return (view != null); |
78 |
|
79 |
} |
80 |
|
81 |
public boolean isVisible() { |
82 |
|
83 |
ApplicationManager application = ApplicationLocator.getManager(); |
84 |
view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
85 |
return (view != null); |
86 |
|
87 |
} |
88 |
|
89 |
public ViewDocument getView() {
|
90 |
return view;
|
91 |
} |
92 |
|
93 |
} |