svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / creation / wizard / ProgressWizard.java @ 37591
History | View | Annotate | Download (4.4 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 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 {Prodevelop} {Task}
|
26 |
*/
|
27 |
package org.gvsig.installer.swing.impl.creation.wizard; |
28 |
|
29 |
import java.io.File; |
30 |
|
31 |
import javax.swing.JPanel; |
32 |
|
33 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
34 |
import org.gvsig.installer.lib.api.PackageInfo; |
35 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
36 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
37 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
38 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
39 |
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard; |
40 |
import org.gvsig.installer.swing.impl.panel.DefaultProgressPanel; |
41 |
import org.gvsig.tools.ToolsLocator; |
42 |
import org.gvsig.tools.task.SimpleTaskStatus; |
43 |
|
44 |
/**
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
46 |
*/
|
47 |
public class ProgressWizard extends DefaultProgressPanel implements OptionPanel { |
48 |
|
49 |
private static final long serialVersionUID = -2940454513497249659L; |
50 |
private DefaultMakePluginPackageWizard installerCreationWizard;
|
51 |
private DefaultSwingInstallerManager swingInstallerManager;
|
52 |
|
53 |
public ProgressWizard(DefaultMakePluginPackageWizard installerCreationWizard) {
|
54 |
super();
|
55 |
this.installerCreationWizard = installerCreationWizard;
|
56 |
swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator |
57 |
.getSwingInstallerManager(); |
58 |
} |
59 |
|
60 |
public JPanel getJPanel() { |
61 |
return this; |
62 |
} |
63 |
|
64 |
public String getPanelTitle() { |
65 |
return swingInstallerManager.getText("_Installer_progress"); |
66 |
} |
67 |
|
68 |
public void lastPanel() { |
69 |
installerCreationWizard.setFinishButtonEnabled(false);
|
70 |
installerCreationWizard.setCancelButtonEnabled(true);
|
71 |
} |
72 |
|
73 |
public void nextPanel() { |
74 |
// Do nothing
|
75 |
} |
76 |
|
77 |
public void updatePanel() { |
78 |
MakePluginPackageService installerCreationService = installerCreationWizard |
79 |
.getInstallerCreationService(); |
80 |
|
81 |
PackageInfo packageInfo = installerCreationWizard |
82 |
.getSelectedPackageInfo(); |
83 |
|
84 |
SimpleTaskStatus taskStatus = ToolsLocator.getTaskStatusManager() |
85 |
.createDefaultSimpleTaskStatus(packageInfo.getName()); |
86 |
this.bind(taskStatus);
|
87 |
try {
|
88 |
// Compress the plugin
|
89 |
taskStatus.message(swingInstallerManager.getText("_Compressing"));
|
90 |
installerCreationService.preparePackage(packageInfo); |
91 |
installerCreationService.createPackage(packageInfo, |
92 |
installerCreationWizard.getOutputStream()); |
93 |
if (installerCreationWizard.getIndexOutputStream() != null) { |
94 |
taskStatus.message(swingInstallerManager |
95 |
.getText("_Creating_index"));
|
96 |
PackageInfo info = installerCreationWizard |
97 |
.getSelectedPackageInfo(); |
98 |
File pluginFolder = installerCreationWizard
|
99 |
.getMakePluginPackageService().getPluginFolder(info); |
100 |
|
101 |
PackageInfo infoIndex = (PackageInfo) info.clone(); |
102 |
infoIndex.setDownloadURL(installerCreationWizard |
103 |
.getDownloadURL()); |
104 |
|
105 |
installerCreationService.writePackageInfoForIndex(infoIndex, |
106 |
pluginFolder); |
107 |
installerCreationService.createPackageIndex(info, |
108 |
installerCreationWizard.getIndexOutputStream()); |
109 |
} |
110 |
taskStatus.terminate(); |
111 |
|
112 |
// Set the finished text
|
113 |
taskStatus.message(swingInstallerManager.getText("_Finished"));
|
114 |
} catch (MakePluginPackageServiceException e) {
|
115 |
this.showErrorMessage(swingInstallerManager
|
116 |
.getText("_Cant_create_package"), e);
|
117 |
} catch (CloneNotSupportedException e) { |
118 |
this.showErrorMessage(swingInstallerManager
|
119 |
.getText("_Cant_create_package"), e);
|
120 |
} |
121 |
installerCreationWizard.setFinishButtonEnabled(true);
|
122 |
installerCreationWizard.setCancelButtonEnabled(false);
|
123 |
} |
124 |
|
125 |
} |