Revision 42528
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.api/pom.xml | ||
---|---|---|
19 | 19 |
<artifactId>org.gvsig.installer.lib.api</artifactId> |
20 | 20 |
<scope>compile</scope> |
21 | 21 |
</dependency> |
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
22 | 27 |
</dependencies> |
23 | 28 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.api/src/main/java/org/gvsig/installer/swing/api/SwingInstallerManager.java | ||
---|---|---|
45 | 45 |
import org.gvsig.installer.swing.api.execution.InstallPackageWizardException; |
46 | 46 |
import org.gvsig.installer.swing.api.execution.JShowPackageStatusAndAskContinuePanel; |
47 | 47 |
import org.gvsig.installer.swing.api.execution.JShowPackagesAndAskContinuePanel; |
48 |
|
|
48 |
import org.gvsig.tools.swing.api.Component; |
|
49 | 49 |
/** |
50 | 50 |
* |
51 | 51 |
* <p> |
... | ... | |
213 | 213 |
* @return list of default urls and their labels |
214 | 214 |
*/ |
215 | 215 |
public List<UrlAndLabel> getDefaultDownloadUrlAndLabels(); |
216 |
|
|
217 |
public Component createPackagerPanel(String packageType, File selectionFolder, File outputFolder); |
|
218 |
|
|
216 | 219 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/DefaultSwingInstallerManager.java | ||
---|---|---|
63 | 63 |
import org.gvsig.installer.swing.api.execution.JShowUnresolvedDependenciesAndAskContinuePanel; |
64 | 64 |
import org.gvsig.installer.swing.impl.creation.panel.DefaultOutputPanel; |
65 | 65 |
import org.gvsig.installer.swing.impl.creation.panel.DefaultPackageInfoPanel; |
66 |
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard; |
|
66 | 67 |
import org.gvsig.installer.swing.impl.panel.DefaultProgressPanel; |
67 | 68 |
import org.gvsig.tools.ToolsLocator; |
68 | 69 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
69 | 70 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
71 |
import org.gvsig.tools.swing.api.Component; |
|
70 | 72 |
import org.slf4j.Logger; |
71 | 73 |
import org.slf4j.LoggerFactory; |
72 | 74 |
|
... | ... | |
510 | 512 |
} |
511 | 513 |
} |
512 | 514 |
|
515 |
public Component createPackagerPanel(String packageType, File selectionFolder, File outputFolder) { |
|
516 |
Component packager = new BasePackageWizard(packageType, selectionFolder, outputFolder); |
|
517 |
return packager; |
|
518 |
} |
|
513 | 519 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/BasePackageWizard.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.installer.swing.impl.packagebuilder; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.io.File; |
|
29 |
import java.net.URL; |
|
30 |
import javax.swing.JComponent; |
|
31 |
|
|
32 |
import javax.swing.JPanel; |
|
33 |
|
|
34 |
|
|
35 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
|
36 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
|
37 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
|
38 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
39 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
40 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
41 |
|
|
42 |
import org.gvsig.installer.swing.impl.packagebuilder.options.OutputOption; |
|
43 |
import org.gvsig.installer.swing.impl.packagebuilder.options.PackageInfoOption; |
|
44 |
import org.gvsig.installer.swing.impl.packagebuilder.options.ProgressOption; |
|
45 |
import org.gvsig.installer.swing.impl.packagebuilder.options.SelectFolderToPackagingOption; |
|
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 |
import org.gvsig.tools.i18n.I18nManager; |
|
48 |
import org.gvsig.tools.locator.LocatorException; |
|
49 |
import org.gvsig.tools.packageutils.PackageInfo; |
|
50 |
import org.gvsig.tools.swing.api.Component; |
|
51 |
|
|
52 |
public class BasePackageWizard extends JPanel implements WizardPanel, Component { |
|
53 |
|
|
54 |
private static final long serialVersionUID = 9205891710214122265L; |
|
55 |
|
|
56 |
private WizardPanelWithLogo wizardPanelWithLogo = null; |
|
57 |
|
|
58 |
private PackageInfo packageInfo = null; |
|
59 |
private File folderToPackaging = null; |
|
60 |
private WizardPanelActionListener wizardListenerAdapter = null; |
|
61 |
|
|
62 |
private OutputOption outputOption = null; |
|
63 |
private OptionPanel packageInfoOption = null; |
|
64 |
private OptionPanel progressOption = null; |
|
65 |
private SelectFolderToPackagingOption selectFolderToPackagingOption = null; |
|
66 |
private final String packageType; |
|
67 |
private final File baseFolder; |
|
68 |
private final File outputFolder; |
|
69 |
|
|
70 |
public BasePackageWizard(String packageType, File selectionFolder, File outputFolder) throws LocatorException { |
|
71 |
this.packageType = packageType; |
|
72 |
this.baseFolder = selectionFolder; |
|
73 |
this.outputFolder = outputFolder; |
|
74 |
initComponents(); |
|
75 |
} |
|
76 |
|
|
77 |
private void initComponents() { |
|
78 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
79 |
|
|
80 |
this.wizardPanelWithLogo = new WizardPanelWithLogo(); |
|
81 |
|
|
82 |
this.setCancelButtonEnabled(true); |
|
83 |
this.setFinishButtonEnabled(false); |
|
84 |
|
|
85 |
this.packageInfo = ToolsLocator.getPackageManager().createPackageInfo(); |
|
86 |
this.packageInfo.setType(this.packageType); |
|
87 |
|
|
88 |
this.addSelectFolderToPackagingOption( |
|
89 |
i18nManager.getTranslation("_Seleccione_la_carpeta_que_desea_empaquetar") |
|
90 |
); |
|
91 |
this.addPackageInfoOptionPanel(); |
|
92 |
this.addOutputOptionPanel(); |
|
93 |
this.addProgressOptionPanel(); |
|
94 |
this.setFolderToPackaging(this.baseFolder); |
|
95 |
|
|
96 |
wizardPanelWithLogo.setWizardListener(this); |
|
97 |
|
|
98 |
this.setLayout(new BorderLayout()); |
|
99 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
|
100 |
this.setPreferredSize(new Dimension(700, 550)); |
|
101 |
} |
|
102 |
|
|
103 |
protected void addPackageInfoOptionPanel() { |
|
104 |
if ( this.packageInfoOption == null ) { |
|
105 |
this.packageInfoOption = new PackageInfoOption(this); |
|
106 |
} |
|
107 |
this.wizardPanelWithLogo.addOptionPanel(this.packageInfoOption); |
|
108 |
} |
|
109 |
|
|
110 |
protected void addOutputOptionPanel() { |
|
111 |
if ( this.outputOption == null ) { |
|
112 |
this.outputOption = new OutputOption(this); |
|
113 |
} |
|
114 |
this.wizardPanelWithLogo.addOptionPanel(this.outputOption); |
|
115 |
} |
|
116 |
|
|
117 |
protected void addProgressOptionPanel() { |
|
118 |
if ( this.progressOption == null ) { |
|
119 |
|
|
120 |
this.progressOption = new ProgressOption(this); |
|
121 |
} |
|
122 |
this.wizardPanelWithLogo.addOptionPanel(this.progressOption); |
|
123 |
} |
|
124 |
|
|
125 |
protected void addSelectFolderToPackagingOption(String message) { |
|
126 |
if( this.selectFolderToPackagingOption == null ) { |
|
127 |
this.selectFolderToPackagingOption = new SelectFolderToPackagingOption(this, message); |
|
128 |
} |
|
129 |
this.wizardPanelWithLogo.addOptionPanel(this.selectFolderToPackagingOption); |
|
130 |
} |
|
131 |
|
|
132 |
public void setNextButtonEnabled(boolean isEnabled) { |
|
133 |
wizardPanelWithLogo.setNextButtonEnabled(isEnabled); |
|
134 |
} |
|
135 |
|
|
136 |
public void setCancelButtonEnabled(boolean isEnabled) { |
|
137 |
wizardPanelWithLogo.setCancelButtonEnabled(isEnabled); |
|
138 |
} |
|
139 |
|
|
140 |
public void setFinishButtonEnabled(boolean isEnabled) { |
|
141 |
wizardPanelWithLogo.setFinishButtonEnabled(isEnabled); |
|
142 |
} |
|
143 |
|
|
144 |
public void setBackButtonEnabled(boolean isEnabled) { |
|
145 |
wizardPanelWithLogo.setBackButtonEnabled(isEnabled); |
|
146 |
} |
|
147 |
|
|
148 |
@Override |
|
149 |
public WizardPanelActionListener getWizardPanelActionListener() { |
|
150 |
if ( this.wizardListenerAdapter == null ) { |
|
151 |
this.wizardListenerAdapter = new WizardPanelActionListener() { |
|
152 |
@Override |
|
153 |
public void finish(WizardPanel wizardPanel) { |
|
154 |
BasePackageWizard.this.setVisible(false); |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public void cancel(WizardPanel wizardPanel) { |
|
159 |
BasePackageWizard.this.setVisible(false); |
|
160 |
} |
|
161 |
}; |
|
162 |
} |
|
163 |
return this.wizardListenerAdapter; |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
public void setWizardPanelActionListener( |
|
168 |
WizardPanelActionListener wizardActionListener) { |
|
169 |
// this.wizardListenerAdapter = wizardActionListener; |
|
170 |
throw new RuntimeException("Esto falta por ver que hace"); |
|
171 |
} |
|
172 |
|
|
173 |
public void setFolderToPackaging(File file) { |
|
174 |
this.folderToPackaging = file; |
|
175 |
if( this.selectFolderToPackagingOption!=null ) { |
|
176 |
this.selectFolderToPackagingOption.setCurrentFolder(file); |
|
177 |
} |
|
178 |
File pinfo = new File(file, "package.info"); |
|
179 |
if ( pinfo.exists() ) { |
|
180 |
try { |
|
181 |
ToolsLocator.getPackageManager().readPacakgeInfo( |
|
182 |
(org.gvsig.tools.packageutils.PackageInfo) packageInfo, pinfo); |
|
183 |
packageInfo.setType(this.packageType); |
|
184 |
} catch (Exception e) { |
|
185 |
/* |
|
186 |
* Do nothing, packageInfo remains empty |
|
187 |
* form will be empty |
|
188 |
* |
|
189 |
*/ |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public File getFolderToPackaging() { |
|
196 |
return this.folderToPackaging; |
|
197 |
} |
|
198 |
|
|
199 |
public PackageInfo getPackageInfo() { |
|
200 |
return this.packageInfo; |
|
201 |
} |
|
202 |
|
|
203 |
public URL getDownloadURL() { |
|
204 |
return this.outputOption.getDownloadURL(); |
|
205 |
} |
|
206 |
|
|
207 |
public File getPackageIndexFile() { |
|
208 |
return this.outputOption.getPackageIndexFile(); |
|
209 |
} |
|
210 |
|
|
211 |
public boolean shouldCreateIndex() { |
|
212 |
return this.outputOption.shouldCreateIndex(); |
|
213 |
} |
|
214 |
|
|
215 |
public File getPackageFile() { |
|
216 |
return this.outputOption.getPackageFile(); |
|
217 |
} |
|
218 |
|
|
219 |
public void addOptionPanel(OptionPanel optionPanel) { |
|
220 |
this.wizardPanelWithLogo.addOptionPanel(optionPanel); |
|
221 |
} |
|
222 |
|
|
223 |
|
|
224 |
public File getDefaultPackageBundleFile() { |
|
225 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
226 |
String fname = installerManager.getPackageFileName(this.getPackageInfo()); |
|
227 |
return new File( this.outputFolder, fname); |
|
228 |
} |
|
229 |
|
|
230 |
public File getDefaultPackageIndexBundleFile() { |
|
231 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
232 |
String fname = installerManager.getPackageIndexFileName(this.getPackageInfo()); |
|
233 |
return new File( this.outputFolder, fname); |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public JComponent asJComponent() { |
|
238 |
return this; |
|
239 |
} |
|
240 |
|
|
241 |
} |
|
0 | 242 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/options/PackageInfoOption.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.installer.swing.impl.packagebuilder.options; |
|
25 |
|
|
26 |
|
|
27 |
import java.io.File; |
|
28 |
import javax.swing.JOptionPane; |
|
29 |
import javax.swing.JPanel; |
|
30 |
|
|
31 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
32 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
35 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
36 |
import org.gvsig.installer.swing.api.creation.JPackageInfoPanel; |
|
37 |
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.packageutils.PackageManager; |
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
43 |
|
|
44 |
public class PackageInfoOption implements OptionPanel { |
|
45 |
|
|
46 |
private static final Logger logger = LoggerFactory.getLogger(PackageInfoOption.class); |
|
47 |
|
|
48 |
private final JPackageInfoPanel packageInfoPanel; |
|
49 |
|
|
50 |
private final BasePackageWizard wizard; |
|
51 |
|
|
52 |
public PackageInfoOption(BasePackageWizard wizard) { |
|
53 |
super(); |
|
54 |
this.wizard = wizard; |
|
55 |
SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager(); |
|
56 |
|
|
57 |
this.packageInfoPanel = installerManager.createPackageInfoPanel(); |
|
58 |
} |
|
59 |
|
|
60 |
private String getText(String msg) { |
|
61 |
return Messages.getText(msg); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public JPanel getJPanel() { |
|
66 |
return this.packageInfoPanel; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public String getPanelTitle() { |
|
71 |
return getText("_package_description"); |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public void lastPanel() { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public void nextPanel() throws NotContinueWizardException { |
|
82 |
if (!this.packageInfoPanel.validatePanel()) { |
|
83 |
throw new NotContinueWizardException("", null, false); |
|
84 |
} |
|
85 |
this.packageInfoPanel.panelToPackageInfo(this.wizard.getPackageInfo()); |
|
86 |
PackageManager pkgmgr = ToolsLocator.getPackageManager(); |
|
87 |
File fileout = new File(wizard.getFolderToPackaging(),"package.info"); |
|
88 |
try { |
|
89 |
pkgmgr.writePacakgeInfo( |
|
90 |
(org.gvsig.tools.packageutils.PackageInfo)(wizard.getPackageInfo()), |
|
91 |
fileout |
|
92 |
); |
|
93 |
} catch (Exception ex) { |
|
94 |
logger.warn("Can't save package information (file="+fileout.getAbsolutePath()+").",ex); |
|
95 |
JOptionPane.showMessageDialog( |
|
96 |
null, |
|
97 |
Messages.getText("_cant_save_package_information_in_the_selected_folder"), |
|
98 |
Messages.getText("_Warning"), |
|
99 |
JOptionPane.INFORMATION_MESSAGE |
|
100 |
); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public void updatePanel() { |
|
106 |
this.packageInfoPanel.packageInfoToPanel(this.wizard.getPackageInfo()); |
|
107 |
} |
|
108 |
|
|
109 |
} |
|
0 | 110 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/options/OutputOption.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
|
|
26 |
package org.gvsig.installer.swing.impl.packagebuilder.options; |
|
27 |
|
|
28 |
import java.io.File; |
|
29 |
import java.net.URL; |
|
30 |
|
|
31 |
import javax.swing.JOptionPane; |
|
32 |
import javax.swing.JPanel; |
|
33 |
|
|
34 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
35 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
36 |
import org.gvsig.i18n.Messages; |
|
37 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
38 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
39 |
import org.gvsig.installer.swing.api.creation.JOutputPanel; |
|
40 |
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard; |
|
41 |
|
|
42 |
|
|
43 |
public class OutputOption implements OptionPanel { |
|
44 |
|
|
45 |
private final JOutputPanel outputPanel; |
|
46 |
private final BasePackageWizard wizard; |
|
47 |
|
|
48 |
public OutputOption(BasePackageWizard wizard) { |
|
49 |
super(); |
|
50 |
this.wizard = wizard; |
|
51 |
SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager(); |
|
52 |
|
|
53 |
outputPanel = installerManager.createOutputPanel(); |
|
54 |
this.outputPanel.setPackageInfo(wizard.getPackageInfo()); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public JPanel getJPanel() { |
|
59 |
return this.outputPanel; |
|
60 |
} |
|
61 |
|
|
62 |
private String getText(String msg) { |
|
63 |
return Messages.getText(msg); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public String getPanelTitle() { |
|
68 |
return getText("_output_options"); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void lastPanel() { |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public void nextPanel() throws NotContinueWizardException { |
|
78 |
|
|
79 |
File file = outputPanel.getPackageFile(); |
|
80 |
File filePath = new File(file.getParent()); |
|
81 |
if (!filePath.exists()) { |
|
82 |
JOptionPane.showMessageDialog(outputPanel, |
|
83 |
getText("_the_package_file_folder_does_not_exist") + ": " |
|
84 |
+ filePath); |
|
85 |
throw new NotContinueWizardException("", null, false); |
|
86 |
} |
|
87 |
if (outputPanel.isCreatePackageIndex()) { |
|
88 |
URL url = outputPanel.getDownloadURL(); |
|
89 |
if (url == null) { |
|
90 |
throw new NotContinueWizardException("", null, false); |
|
91 |
} |
|
92 |
File indexFile = outputPanel.getPackageIndexFile(); |
|
93 |
File indexFilePath = new File(indexFile.getParent()); |
|
94 |
if (!indexFilePath.exists()) { |
|
95 |
JOptionPane.showMessageDialog(outputPanel, |
|
96 |
getText("_the_package_index_file_folder_does_not_exist") |
|
97 |
+ ": " + indexFilePath); |
|
98 |
throw new NotContinueWizardException("", null, false); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public void updatePanel() { |
|
106 |
outputPanel.setPackageFile(this.wizard.getDefaultPackageBundleFile()); |
|
107 |
outputPanel.setPackageIndexFile(this.wizard.getDefaultPackageIndexBundleFile()); |
|
108 |
} |
|
109 |
|
|
110 |
public URL getDownloadURL() { |
|
111 |
return this.outputPanel.getDownloadURL(); |
|
112 |
} |
|
113 |
|
|
114 |
public File getPackageIndexFile() { |
|
115 |
return this.outputPanel.getPackageIndexFile(); |
|
116 |
} |
|
117 |
|
|
118 |
public boolean shouldCreateIndex() { |
|
119 |
return this.outputPanel.isCreatePackageIndex(); |
|
120 |
} |
|
121 |
|
|
122 |
public File getPackageFile() { |
|
123 |
return this.outputPanel.getPackageFile(); |
|
124 |
} |
|
125 |
} |
|
0 | 126 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/options/SelectFolderToPackagingOption.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.installer.swing.impl.packagebuilder.options; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.io.File; |
|
28 |
import javax.swing.JFileChooser; |
|
29 |
import javax.swing.JLabel; |
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
|
33 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
34 |
import org.gvsig.i18n.Messages; |
|
35 |
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard; |
|
36 |
|
|
37 |
/** |
|
38 |
* |
|
39 |
* @author usuario |
|
40 |
*/ |
|
41 |
public class SelectFolderToPackagingOption extends JPanel implements OptionPanel { |
|
42 |
|
|
43 |
private BasePackageWizard wizard = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* Creates new form SelectFolderToPackagingOption |
|
47 |
* @param wizard |
|
48 |
* @param message |
|
49 |
*/ |
|
50 |
public SelectFolderToPackagingOption(BasePackageWizard wizard, String message) { |
|
51 |
this.wizard = wizard; |
|
52 |
initComponents(); |
|
53 |
if( message == null ) { |
|
54 |
this.jLabel1.setText(Messages.getText(this.jLabel1.getText())); |
|
55 |
} else { |
|
56 |
this.jLabel1.setText(message); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public JPanel getJPanel() { |
|
62 |
return this; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public void lastPanel() { |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void nextPanel() throws NotContinueWizardException { |
|
72 |
File file = jFileChooser1.getSelectedFile(); |
|
73 |
if( file!=null ) { |
|
74 |
wizard.setFolderToPackaging(file); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public void updatePanel() { |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public String getPanelTitle() { |
|
85 |
return Messages.getText("_select_translations_folder"); |
|
86 |
} |
|
87 |
|
|
88 |
public void setCurrentFolder(File folder) { |
|
89 |
this.jFileChooser1.setCurrentDirectory(folder); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* This method is called from within the constructor to |
|
94 |
* initialize the form. |
|
95 |
* WARNING: Do NOT modify this code. The content of this method is |
|
96 |
* always regenerated by the Form Editor. |
|
97 |
*/ |
|
98 |
@SuppressWarnings("unchecked") |
|
99 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
|
100 |
private void initComponents() { |
|
101 |
|
|
102 |
jLabel1 = new JLabel(); |
|
103 |
jFileChooser1 = new JFileChooser(); |
|
104 |
|
|
105 |
setLayout(new BorderLayout()); |
|
106 |
|
|
107 |
jLabel1.setText("_Seleccione_la_carpeta_donde_estan_los _contenidos_a_empaquetar"); |
|
108 |
add(jLabel1, BorderLayout.PAGE_START); |
|
109 |
|
|
110 |
jFileChooser1.setControlButtonsAreShown(false); |
|
111 |
jFileChooser1.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
|
112 |
add(jFileChooser1, BorderLayout.CENTER); |
|
113 |
}// </editor-fold>//GEN-END:initComponents |
|
114 |
|
|
115 |
|
|
116 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
|
117 |
protected JFileChooser jFileChooser1; |
|
118 |
protected JLabel jLabel1; |
|
119 |
// End of variables declaration//GEN-END:variables |
|
120 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/options/ProgressOption.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.installer.swing.impl.packagebuilder.options; |
|
26 |
|
|
27 |
import java.io.File; |
|
28 |
import java.io.FileNotFoundException; |
|
29 |
import java.io.FileOutputStream; |
|
30 |
import java.io.OutputStream; |
|
31 |
|
|
32 |
import javax.swing.JOptionPane; |
|
33 |
import javax.swing.JPanel; |
|
34 |
|
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
|
39 |
import org.gvsig.i18n.Messages; |
|
40 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
41 |
import org.gvsig.installer.lib.api.creation.MakePackageService; |
|
42 |
import org.gvsig.installer.lib.api.creation.MakePackageServiceException; |
|
43 |
import org.gvsig.installer.swing.api.JProgressPanel; |
|
44 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
45 |
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard; |
|
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
48 |
|
|
49 |
public class ProgressOption implements OptionPanel { |
|
50 |
|
|
51 |
private static final Logger logger = LoggerFactory.getLogger(ProgressOption.class); |
|
52 |
private final BasePackageWizard wizard; |
|
53 |
private final JProgressPanel progressPanel; |
|
54 |
|
|
55 |
public ProgressOption(BasePackageWizard wizard) { |
|
56 |
super(); |
|
57 |
this.wizard = wizard; |
|
58 |
progressPanel = |
|
59 |
SwingInstallerLocator.getSwingInstallerManager() |
|
60 |
.createProgressPanel(); |
|
61 |
} |
|
62 |
|
|
63 |
private String getText(String msg) { |
|
64 |
return Messages.getText(msg); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public JPanel getJPanel() { |
|
69 |
return this.progressPanel; |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String getPanelTitle() { |
|
74 |
return Messages.getText("_Installer_progress"); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void lastPanel() { |
|
79 |
wizard.setFinishButtonEnabled(false); |
|
80 |
wizard.setCancelButtonEnabled(true); |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void nextPanel() { |
|
85 |
// Do nothing |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public void updatePanel() { |
|
90 |
|
|
91 |
OutputStream outputStream = |
|
92 |
openFileOutputStream(wizard.getPackageFile()); |
|
93 |
if (outputStream == null) { |
|
94 |
return; |
|
95 |
} |
|
96 |
OutputStream indexOutputStream = null; |
|
97 |
if (wizard.shouldCreateIndex()) { |
|
98 |
indexOutputStream = |
|
99 |
openFileOutputStream(wizard.getPackageIndexFile()); |
|
100 |
if (indexOutputStream == null) { |
|
101 |
return; |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
wizard.setFinishButtonEnabled(false); |
|
106 |
wizard.setCancelButtonEnabled(false); |
|
107 |
|
|
108 |
SimpleTaskStatus taskStatus = |
|
109 |
ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus( |
|
110 |
wizard.getPackageInfo().getName()); |
|
111 |
|
|
112 |
this.progressPanel.bind(taskStatus); |
|
113 |
|
|
114 |
try { |
|
115 |
String downloadURL = wizard.getPackageInfo().getDownloadURLAsString(); |
|
116 |
wizard.getPackageInfo().setDownloadURL(""); |
|
117 |
|
|
118 |
MakePackageService makePackageService = |
|
119 |
InstallerLocator.getInstallerManager().createMakePackage( |
|
120 |
wizard.getFolderToPackaging(), wizard.getPackageInfo()); |
|
121 |
|
|
122 |
taskStatus.message(getText("_Compressing")); |
|
123 |
|
|
124 |
makePackageService.preparePackage(); |
|
125 |
makePackageService.createPackage(outputStream); |
|
126 |
if (indexOutputStream != null) { |
|
127 |
taskStatus.message(getText("_Creating_index")); |
|
128 |
makePackageService.createPackageIndex( |
|
129 |
wizard.getDownloadURL(), indexOutputStream); |
|
130 |
} |
|
131 |
|
|
132 |
wizard.getPackageInfo().setDownloadURL(downloadURL); |
|
133 |
taskStatus.terminate(); |
|
134 |
|
|
135 |
// Set the finished text |
|
136 |
taskStatus.message(getText("_Finished")); |
|
137 |
} catch (MakePackageServiceException e) { |
|
138 |
logger.info("Error while creating package.", e); |
|
139 |
JOptionPane.showMessageDialog(null, getText("_cant_create_the_package") |
|
140 |
+ "\n\n" + e.getLocalizedMessageStack(), |
|
141 |
getText("_create_package"), JOptionPane.ERROR_MESSAGE); |
|
142 |
} |
|
143 |
wizard.setFinishButtonEnabled(true); |
|
144 |
wizard.setCancelButtonEnabled(false); |
|
145 |
} |
|
146 |
|
|
147 |
private OutputStream openFileOutputStream(File file) { |
|
148 |
OutputStream os; |
|
149 |
|
|
150 |
try { |
|
151 |
os = new FileOutputStream(file); |
|
152 |
} catch (FileNotFoundException e1) { |
|
153 |
JOptionPane.showMessageDialog(null, |
|
154 |
getText("_cant_create_the_package") + " (" + file + ").", |
|
155 |
getText("_create_package"), JOptionPane.WARNING_MESSAGE); |
|
156 |
return null; |
|
157 |
} |
|
158 |
return os; |
|
159 |
} |
|
160 |
} |
|
0 | 161 |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/packagebuilder/options/SelectFolderToPackagingOption.form | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
|
|
3 |
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> |
|
4 |
<AuxValues> |
|
5 |
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> |
|
6 |
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
|
7 |
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="false"/> |
|
8 |
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
|
9 |
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> |
|
10 |
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> |
|
11 |
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
|
12 |
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
|
13 |
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="4"/> |
|
14 |
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-69,0,0,2,49"/> |
|
15 |
</AuxValues> |
|
16 |
|
|
17 |
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> |
|
18 |
<SubComponents> |
|
19 |
<Component class="javax.swing.JLabel" name="jLabel1"> |
|
20 |
<Properties> |
|
21 |
<Property name="text" type="java.lang.String" value="_Seleccione_la_carpeta_donde_estan_los _contenidos_a_empaquetar"/> |
|
22 |
</Properties> |
|
23 |
<Constraints> |
|
24 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> |
|
25 |
<BorderConstraints direction="First"/> |
|
26 |
</Constraint> |
|
27 |
</Constraints> |
|
28 |
</Component> |
|
29 |
<Component class="javax.swing.JFileChooser" name="jFileChooser1"> |
|
30 |
<Properties> |
|
31 |
<Property name="controlButtonsAreShown" type="boolean" value="false"/> |
|
32 |
<Property name="fileSelectionMode" type="int" value="1"/> |
|
33 |
</Properties> |
|
34 |
<Constraints> |
|
35 |
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> |
|
36 |
<BorderConstraints direction="Center"/> |
|
37 |
</Constraint> |
|
38 |
</Constraints> |
|
39 |
</Component> |
|
40 |
</SubComponents> |
|
41 |
</Form> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/TranslationsPackageExtension.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.extension; |
25 | 25 |
|
26 |
import java.io.File; |
|
27 |
import org.cresques.Messages; |
|
26 |
import javax.swing.JPanel; |
|
28 | 27 |
import org.gvsig.andami.PluginsLocator; |
29 | 28 |
import org.gvsig.andami.PluginsManager; |
30 |
import org.gvsig.andami.installer.packagebuilder.BasePackageWizard; |
|
31 | 29 |
import org.gvsig.andami.installer.translations.TranslationsInstallerFactory; |
32 | 30 |
import org.gvsig.andami.plugins.Extension; |
33 | 31 |
import org.gvsig.app.ApplicationLocator; |
34 | 32 |
import org.gvsig.app.ApplicationManager; |
33 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
34 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
35 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
36 |
import org.gvsig.tools.swing.api.Component; |
|
35 | 37 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
36 | 38 |
import org.slf4j.Logger; |
37 | 39 |
import org.slf4j.LoggerFactory; |
... | ... | |
52 | 54 |
public void execute(String actionCommand) { |
53 | 55 |
if ( "tools-devel-translations-package".equalsIgnoreCase(actionCommand) ) { |
54 | 56 |
ApplicationManager application = ApplicationLocator.getManager(); |
57 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
58 |
SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager(); |
|
59 |
Component packager = installerManager.createPackagerPanel( |
|
60 |
TranslationsInstallerFactory.PROVIDER_NAME, |
|
61 |
pluginsManager.getApplicationI18nFolder(), |
|
62 |
pluginsManager.getApplicationFolder() |
|
63 |
); |
|
55 | 64 |
application.getUIManager().showWindow( |
56 |
new TranslationsPackageWizard(),
|
|
65 |
(JPanel)packager.asJComponent(),
|
|
57 | 66 |
application.translate("_Translations_package"), |
58 | 67 |
WindowManager.MODE.WINDOW |
59 | 68 |
); |
... | ... | |
67 | 76 |
public boolean isVisible() { |
68 | 77 |
return true; |
69 | 78 |
} |
70 |
|
|
71 |
private class TranslationsPackageWizard extends BasePackageWizard { |
|
72 |
|
|
73 |
private static final long serialVersionUID = 9205891710214122265L; |
|
74 |
|
|
75 |
TranslationsPackageWizard() { |
|
76 |
super(TranslationsInstallerFactory.PROVIDER_NAME); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
protected void initOptionPanels() { |
|
81 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
82 |
this.addSelectFolderToPackagingOption(Messages.getText("_Seleccione_la_carpeta_en_la_que_se_encuentran_las_traducciones_a_empaquetar")); |
|
83 |
super.addDefaultOptionPanels(); |
|
84 |
this.setFolderToPackaging(new File(pluginsManager.getApplicationFolder(), "i18n")); |
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 | 79 |
} |
Also available in: Unified diff