svn-gvsig-desktop / 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 / execution / wizard / AddBundlesWizardPage.java @ 43126
History | View | Annotate | Download (5.63 KB)
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 modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 {Prodevelop} {Task}
|
26 |
*/
|
27 |
package org.gvsig.installer.swing.impl.execution.wizard; |
28 |
|
29 |
import javax.swing.JOptionPane; |
30 |
|
31 |
import javax.swing.JPanel; |
32 |
import javax.swing.SwingUtilities; |
33 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
34 |
|
35 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
36 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
37 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
38 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
39 |
import org.gvsig.installer.swing.impl.execution.InstallWizardPanel_ext; |
40 |
import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel; |
41 |
import org.gvsig.installer.swing.impl.panel.DefaultProgressPanel; |
42 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
43 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
44 |
import org.gvsig.tools.task.SimpleTaskStatus; |
45 |
|
46 |
public class AddBundlesWizardPage extends DefaultProgressPanel implements OptionPanel { |
47 |
|
48 |
private static final long serialVersionUID = 8531884535246881448L; |
49 |
private final InstallWizardPanel_ext wizardPanel; |
50 |
|
51 |
public AddBundlesWizardPage(InstallWizardPanel_ext installerExecutionWizard) {
|
52 |
super();
|
53 |
this.wizardPanel = installerExecutionWizard;
|
54 |
} |
55 |
|
56 |
@Override
|
57 |
public JPanel getJPanel() { |
58 |
return this; |
59 |
} |
60 |
|
61 |
@Override
|
62 |
public String getPanelTitle() { |
63 |
return wizardPanel.getTranslation("_Loading_packages"); |
64 |
} |
65 |
|
66 |
@Override
|
67 |
public void lastPanel() { |
68 |
wizardPanel.setFinishButtonEnabled(false);
|
69 |
wizardPanel.setCancelButtonEnabled(true);
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public void nextPanel() { |
74 |
} |
75 |
|
76 |
@Override
|
77 |
public void updatePanel() { |
78 |
if( wizardPanel.getDirection() == WizardPanelWithLogo.ACTION_PREVIOUS ) {
|
79 |
wizardPanel.skip(); |
80 |
return;
|
81 |
} |
82 |
wizardPanel.setFinishButtonEnabled(false);
|
83 |
wizardPanel.setBackButtonEnabled(false);
|
84 |
wizardPanel.setNextButtonEnabled(false);
|
85 |
wizardPanel.setCancelButtonEnabled(true);
|
86 |
|
87 |
UpdatePanel task = new UpdatePanel(this); |
88 |
this.wizardPanel.addCancellableTask(task);
|
89 |
bind(task.getTaskStatus()); |
90 |
task.setDaemon(true);
|
91 |
task.start(); |
92 |
} |
93 |
|
94 |
private class UpdatePanel extends AbstractMonitorableTask { |
95 |
|
96 |
private final AddBundlesWizardPage panel; |
97 |
|
98 |
public UpdatePanel(AddBundlesWizardPage panel) {
|
99 |
super(panel.wizardPanel.getTranslation("_Loading_packages")); |
100 |
this.panel = panel;
|
101 |
} |
102 |
|
103 |
@Override
|
104 |
public synchronized void run() { |
105 |
|
106 |
try {
|
107 |
|
108 |
logger.info("loading packages");
|
109 |
SimpleTaskStatus taskStatus = (SimpleTaskStatus) this.getTaskStatus();
|
110 |
taskStatus.setIndeterminate(); |
111 |
|
112 |
InstallPackageService installerExecutionService = wizardPanel.getInstallerExecutionService(); |
113 |
SelectBundlesPanel bundlesPanel = wizardPanel.getBundlesPanel(); |
114 |
|
115 |
if (bundlesPanel.isStandardSelected()) {
|
116 |
installerExecutionService.addBundlesFromDirectory( |
117 |
wizardPanel.getInstallFolder(), taskStatus |
118 |
); |
119 |
|
120 |
} else if (bundlesPanel.isURLSelected() && bundlesPanel.getSelectedURL() != null) { |
121 |
installerExecutionService.addBundle(bundlesPanel.getSelectedURL(), taskStatus); |
122 |
|
123 |
} else if (bundlesPanel.isFileSelected() && bundlesPanel.getSelectedFile() != null && bundlesPanel.getSelectedFile().exists()) { |
124 |
installerExecutionService.addBundle(bundlesPanel.getSelectedFile(), taskStatus); |
125 |
|
126 |
} |
127 |
|
128 |
taskStatus.message(panel.wizardPanel.getTranslation("_Finished"));
|
129 |
|
130 |
taskStatus.terminate(); |
131 |
SwingUtilities.invokeAndWait(new Runnable() { |
132 |
|
133 |
@Override
|
134 |
public void run() { |
135 |
wizardPanel.setFinishButtonEnabled(false);
|
136 |
wizardPanel.setBackButtonEnabled(true);
|
137 |
wizardPanel.setNextButtonEnabled(true);
|
138 |
wizardPanel.setCancelButtonEnabled(true);
|
139 |
wizardPanel.doAction(WizardPanelWithLogo.ACTION_NEXT); |
140 |
} |
141 |
}); |
142 |
logger.info("Loading packages finished");
|
143 |
|
144 |
} catch (Throwable th) { |
145 |
logger.warn("Problems loading packages.", th);
|
146 |
ToolsSwingLocator.getThreadSafeDialogsManager().messageDialog( |
147 |
panel.wizardPanel.getTranslation("_Cant_load_packages"),
|
148 |
panel.wizardPanel.getTranslation("_Warning"),
|
149 |
JOptionPane.WARNING_MESSAGE
|
150 |
); |
151 |
|
152 |
} |
153 |
} |
154 |
|
155 |
} |
156 |
} |