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 @ 38550
History | View | Annotate | Download (2.8 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.i18n.Messages; |
30 |
import org.gvsig.newlayer.NewLayerLocator; |
31 |
import org.gvsig.newlayer.NewLayerManager; |
32 |
import org.gvsig.newlayer.NewLayerService; |
33 |
import org.gvsig.newlayer.NewLayerWizard; |
34 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
35 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
36 |
|
37 |
/**
|
38 |
* @author gvSIG Team
|
39 |
* @version $Id$
|
40 |
*
|
41 |
*/
|
42 |
public class NewLayerExtension extends Extension { |
43 |
|
44 |
private ViewDocument view = null; |
45 |
|
46 |
public void initialize() { |
47 |
|
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 |
} |