Revision 52

View differences:

org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/src/main/resources/config.xml
9 9
			description="" active="true" priority="1">
10 10
		</extension>
11 11
		<extension
12
			class-name="org.gvsig.educa.thematicmap.app.viewer.OpenThematicMapInstallerExtension"
13
			description="" active="true" priority="1">
14
			<menu text="Thematic_Map/install_thematic_map"
15
				action-command="INSTALL_THEMATIC_MAP"/>
16

  
17
		</extension>
18
		<extension
19 12
			class-name="org.gvsig.educa.thematicmap.app.viewer.ThematicMapBasicMapControlExtension"
20 13
			description="" active="true" priority="1">
21 14
			<combo-scale name="scale" label="1:"
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.viewer/src/main/java/org/gvsig/educa/thematicmap/app/viewer/OpenThematicMapInstallerExtension.java
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.thematicmap.app.viewer;
23

  
24
import java.io.File;
25

  
26
import javax.swing.JPanel;
27

  
28
import org.gvsig.andami.PluginsLocator;
29
import org.gvsig.andami.PluginsManager;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.educa.thematicmap.ThematicMapManager;
32
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator;
33
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingManager;
34
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager;
35
import org.gvsig.installer.swing.api.SwingInstallerLocator;
36
import org.gvsig.installer.swing.api.SwingInstallerManager;
37
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException;
38
import org.gvsig.installer.swing.api.wizard.AbstractInstallerWizard;
39
import org.gvsig.installer.swing.api.wizard.InstallerWizardActionListener;
40
import org.gvsig.installer.swing.api.wizard.InstallerWizardPanel;
41
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
42

  
43
/**
44
 * Andami extension to show ThematicMap installer.
45
 * 
46
 * @author gvSIG Team
47
 * @version $Id$
48
 */
49
public class OpenThematicMapInstallerExtension extends Extension {
50

  
51
    private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory
52
        .getLogger(OpenThematicMapInstallerExtension.class);
53

  
54
    private ThematicMapManager manager;
55
    private ThematicMapSwingManager swingManager;
56
    private SwingInstallerManager swingInstallerManager;
57

  
58
    private ThematicMapWindowManager winManager;
59

  
60
    private PluginsManager pluginsManager;
61

  
62
    public void initialize() {
63
        // Do nothing
64
    }
65

  
66
    @Override
67
    public void postInitialize() {
68
        super.postInitialize();
69
        swingManager = ThematicMapSwingLocator.getSwingManager();
70
        winManager = swingManager.getWindowManager();
71
        manager = swingManager.getManager();
72
        swingInstallerManager =
73
            SwingInstallerLocator.getSwingInstallerManager();
74
        pluginsManager = PluginsLocator.getManager();
75

  
76
        // TODO Add repos url
77

  
78
    }
79

  
80
    public void execute(String actionCommand) {
81
        AbstractInstallerWizard panel;
82

  
83
        try {
84
            panel =
85
                swingInstallerManager.createInstallPackageWizard(
86
                    pluginsManager.getApplicationFolder(),
87
                    new File(manager.getInstallationMapFolder()), null);
88
        } catch (InstallPackageWizardException ex) {
89
            LOG.error("Error opening installer panel", ex);
90
            return;
91

  
92
        }
93
        panel.setWizardActionListener(new WizardListener(panel));
94

  
95
        winManager.showWindow(panel,
96
            swingManager.getTranslation("install_thematic_map"), MODE.DIALOG);
97
    }
98

  
99
    public boolean isEnabled() {
100
        return true;
101
    }
102

  
103
    public boolean isVisible() {
104
        return true;
105
    }
106

  
107
    /**
108
     * Listener to close wizard window on finish or cancel
109
     * 
110
     * @author gvSIG Team
111
     * @version $Id$
112
     * 
113
     */
114
    private class WizardListener implements InstallerWizardActionListener {
115

  
116
        private final JPanel panel;
117

  
118
        /**
119
         *
120
         */
121
        public WizardListener(JPanel panel) {
122
            this.panel = panel;
123
        }
124

  
125
        public void finish(InstallerWizardPanel installerWizard) {
126
            panel.setVisible(false);
127

  
128
        }
129

  
130
        public void cancel(InstallerWizardPanel installerWizard) {
131
            panel.setVisible(false);
132
        }
133

  
134
    }
135
}

Also available in: Unified diff