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 @ 36022
History | View | Annotate | Download (2.9 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 javax.swing.JOptionPane; |
25 |
|
26 |
import org.gvsig.andami.plugins.Extension; |
27 |
import org.gvsig.app.ApplicationLocator; |
28 |
import org.gvsig.app.ApplicationManager; |
29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 |
import org.gvsig.app.project.documents.view.ViewManager; |
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 |
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 |
int resp = JOptionPane.showConfirmDialog(null, |
57 |
"Esta extensi?n no funciona todav?a. ?Desea continuar?",
|
58 |
"En construcci?n", JOptionPane.YES_NO_OPTION); |
59 |
if (resp!=JOptionPane.YES_OPTION){ |
60 |
return;
|
61 |
} |
62 |
ApplicationManager application = ApplicationLocator.getManager(); |
63 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
64 |
|
65 |
if (view != null) { |
66 |
NewLayerManager manager = NewLayerLocator.getManager(); |
67 |
NewLayerService service = manager.createNewLayerService(); |
68 |
NewLayerWizard wizard = manager.createNewLayerWizard(service); |
69 |
|
70 |
WindowManager windowMgr = ToolsSwingLocator.getWindowManager(); |
71 |
windowMgr.showWindow(wizard, "New layer wizard", WindowManager.MODE.DIALOG);
|
72 |
} |
73 |
} |
74 |
|
75 |
public boolean isEnabled() { |
76 |
|
77 |
ApplicationManager application = ApplicationLocator.getManager(); |
78 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
79 |
return (view != null); |
80 |
|
81 |
} |
82 |
|
83 |
public boolean isVisible() { |
84 |
|
85 |
ApplicationManager application = ApplicationLocator.getManager(); |
86 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
87 |
return (view != null); |
88 |
|
89 |
} |
90 |
} |