Statistics
| Revision:

root / org.gvsig.educa.portableview.app / org.gvsig.educa.portableview.app.editor / src / main / java / org / gvsig / educa / portableview / app / editor / ExportPortableViewToViewExtension.java @ 254

History | View | Annotate | Download (2.99 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.educa.portableview.app.editor;
23

    
24
import javax.swing.SwingUtilities;
25

    
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.messages.NotificationManager;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.educa.portableview.app.viewer.PortableViewDocument;
31
import org.gvsig.educa.portableview.app.viewer.ui.PortableViewDocumentViewer;
32
import org.gvsig.educa.portableview.swing.PortableViewSwingLocator;
33
import org.gvsig.educa.portableview.swing.PortableViewSwingManager;
34

    
35
/**
36
 * Andami extension to create a View from a Portable view data.
37
 *
38
 * @author gvSIG Team
39
 * @version $Id$
40
 */
41
public class ExportPortableViewToViewExtension extends Extension {
42

    
43
    private PortableViewEditorManager editorManager;
44
    private PortableViewSwingManager swingManager;
45

    
46
    public void initialize() {
47
        // Do nothing
48
    }
49

    
50
    @Override
51
    public void postInitialize() {
52
        editorManager = PortableViewEditorLocator.getManager();
53
        swingManager = PortableViewSwingLocator.getSwingManager();
54
    }
55

    
56
    public void execute(String actionCommand) {
57
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
58
        if (!(window instanceof PortableViewDocumentViewer)) {
59
            return;
60
        }
61
        final PortableViewDocument tmDocument =
62
            ((PortableViewDocumentViewer) window).getPortableViewDocument();
63

    
64
        SwingUtilities.invokeLater(new Runnable() {
65

    
66
            public void run() {
67
                try {
68
                    editorManager.exportPortableViewToView(tmDocument, true);
69
                } catch (Exception ex) {
70
                    NotificationManager.addError(
71
                        swingManager
72
                            .getTranslation("problems_exporting_portable_view_to_view"),
73
                        ex);
74
                }
75

    
76
            }
77
        });
78
    }
79

    
80
    public boolean isEnabled() {
81
        return true;
82
    }
83

    
84
    public boolean isVisible() {
85
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
86
        return window instanceof PortableViewDocumentViewer;
87
    }
88
}