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 / InstallersWizardPage.java @ 43126
History | View | Annotate | Download (5.51 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40560 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 43126 | jjdelcerro | * 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 | 40560 | jjdelcerro | *
|
11 | 43126 | jjdelcerro | * 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 | 40560 | jjdelcerro | *
|
16 | 43126 | jjdelcerro | * 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 | 40560 | jjdelcerro | *
|
20 | 43126 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2010 {Prodevelop} {Task}
|
||
26 | */
|
||
27 | package org.gvsig.installer.swing.impl.execution.wizard; |
||
28 | |||
29 | 41718 | jjdelcerro | import javax.swing.JOptionPane; |
30 | 40435 | jjdelcerro | |
31 | import javax.swing.JPanel; |
||
32 | 41718 | jjdelcerro | import javax.swing.SwingUtilities; |
33 | 43126 | jjdelcerro | import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
34 | 40435 | jjdelcerro | |
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 | 43126 | jjdelcerro | import org.gvsig.installer.swing.api.SwingInstallerManager; |
39 | 40435 | jjdelcerro | import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
40 | 43126 | jjdelcerro | import org.gvsig.installer.swing.impl.execution.InstallWizardPanel_ext; |
41 | 40435 | jjdelcerro | import org.gvsig.installer.swing.impl.panel.DefaultProgressPanel; |
42 | import org.gvsig.tools.task.AbstractMonitorableTask; |
||
43 | import org.gvsig.tools.task.SimpleTaskStatus; |
||
44 | |||
45 | 43126 | jjdelcerro | public class InstallersWizardPage extends DefaultProgressPanel implements OptionPanel { |
46 | 40435 | jjdelcerro | |
47 | 41718 | jjdelcerro | private static final long serialVersionUID = 8531884535246881448L; |
48 | 43126 | jjdelcerro | private final InstallWizardPanel_ext wizardPanel; |
49 | 40435 | jjdelcerro | |
50 | 43126 | jjdelcerro | public InstallersWizardPage(InstallWizardPanel_ext installerExecutionWizard) {
|
51 | 41718 | jjdelcerro | super();
|
52 | 43126 | jjdelcerro | this.wizardPanel = installerExecutionWizard;
|
53 | 41718 | jjdelcerro | } |
54 | 40435 | jjdelcerro | |
55 | 43126 | jjdelcerro | @Override
|
56 | 41718 | jjdelcerro | public JPanel getJPanel() { |
57 | return this; |
||
58 | } |
||
59 | 40435 | jjdelcerro | |
60 | 43126 | jjdelcerro | @Override
|
61 | 41718 | jjdelcerro | public String getPanelTitle() { |
62 | 43126 | jjdelcerro | return wizardPanel.getTranslation("_Install_required_addons"); |
63 | 41718 | jjdelcerro | } |
64 | 40435 | jjdelcerro | |
65 | 43126 | jjdelcerro | @Override
|
66 | 41718 | jjdelcerro | public void lastPanel() { |
67 | 43126 | jjdelcerro | wizardPanel.setFinishButtonEnabled(false);
|
68 | wizardPanel.setCancelButtonEnabled(true);
|
||
69 | 41718 | jjdelcerro | } |
70 | 40435 | jjdelcerro | |
71 | 43126 | jjdelcerro | @Override
|
72 | 41718 | jjdelcerro | public void nextPanel() { |
73 | } |
||
74 | 40435 | jjdelcerro | |
75 | 43126 | jjdelcerro | @Override
|
76 | 41718 | jjdelcerro | public void updatePanel() { |
77 | 43126 | jjdelcerro | if( wizardPanel.getDirection() == WizardPanelWithLogo.ACTION_PREVIOUS ) {
|
78 | wizardPanel.skip(); |
||
79 | return;
|
||
80 | } |
||
81 | InstallPackageService bundle = wizardPanel.getInstallerExecutionService(); |
||
82 | if (! bundle.needInstallPackageProviders()) {
|
||
83 | wizardPanel.skip(); |
||
84 | return;
|
||
85 | } |
||
86 | 40435 | jjdelcerro | |
87 | 43126 | jjdelcerro | wizardPanel.setFinishButtonEnabled(false);
|
88 | wizardPanel.setBackButtonEnabled(false);
|
||
89 | wizardPanel.setNextButtonEnabled(false);
|
||
90 | wizardPanel.setCancelButtonEnabled(true);
|
||
91 | 40435 | jjdelcerro | |
92 | 43126 | jjdelcerro | UpdatePanel task = new UpdatePanel(this); |
93 | this.wizardPanel.addCancellableTask(task);
|
||
94 | 41718 | jjdelcerro | bind(task.getTaskStatus()); |
95 | task.setDaemon(true);
|
||
96 | task.start(); |
||
97 | } |
||
98 | 40435 | jjdelcerro | |
99 | 43126 | jjdelcerro | private class UpdatePanel extends AbstractMonitorableTask { |
100 | 40435 | jjdelcerro | |
101 | 43126 | jjdelcerro | private final InstallersWizardPage panel; |
102 | 40435 | jjdelcerro | |
103 | 43126 | jjdelcerro | public UpdatePanel(InstallersWizardPage panel) {
|
104 | super(panel.wizardPanel.getTranslation("_Installing prerequisites...")); |
||
105 | 41718 | jjdelcerro | this.panel = panel;
|
106 | } |
||
107 | 40435 | jjdelcerro | |
108 | 41718 | jjdelcerro | private void showWarning(final String msg) { |
109 | 43126 | jjdelcerro | if (!SwingUtilities.isEventDispatchThread()) { |
110 | 41718 | jjdelcerro | try {
|
111 | SwingUtilities.invokeAndWait(new Runnable() { |
||
112 | 43126 | jjdelcerro | @Override
|
113 | 41718 | jjdelcerro | public void run() { |
114 | } |
||
115 | }); |
||
116 | } catch (Exception ex) { |
||
117 | 43126 | jjdelcerro | logger.warn("Cant show message to the user. " + msg);
|
118 | 41718 | jjdelcerro | } |
119 | return;
|
||
120 | } |
||
121 | JOptionPane.showMessageDialog(panel, msg, "Warning", JOptionPane.WARNING_MESSAGE); |
||
122 | } |
||
123 | 43126 | jjdelcerro | |
124 | 41718 | jjdelcerro | @Override
|
125 | public synchronized void run() { |
||
126 | 40435 | jjdelcerro | |
127 | 41718 | jjdelcerro | try {
|
128 | 43126 | jjdelcerro | |
129 | logger.info("Package installation initiated");
|
||
130 | SimpleTaskStatus taskStatus = (SimpleTaskStatus) this.getTaskStatus();
|
||
131 | |||
132 | InstallPackageService bundle = wizardPanel.getInstallerExecutionService(); |
||
133 | if (bundle.needInstallPackageProviders()) {
|
||
134 | bundle.installPackageProviders(taskStatus); |
||
135 | 41718 | jjdelcerro | } |
136 | 40435 | jjdelcerro | |
137 | 43126 | jjdelcerro | taskStatus.message(panel.wizardPanel.getTranslation("_Finished"));
|
138 | |||
139 | 41718 | jjdelcerro | taskStatus.terminate(); |
140 | 43126 | jjdelcerro | SwingUtilities.invokeAndWait(new Runnable() { |
141 | |||
142 | @Override
|
||
143 | public void run() { |
||
144 | wizardPanel.setFinishButtonEnabled(false);
|
||
145 | wizardPanel.setBackButtonEnabled(true);
|
||
146 | wizardPanel.setNextButtonEnabled(true);
|
||
147 | wizardPanel.setCancelButtonEnabled(true);
|
||
148 | wizardPanel.doAction(WizardPanelWithLogo.ACTION_NEXT); |
||
149 | } |
||
150 | }); |
||
151 | 41718 | jjdelcerro | logger.info("Package installation finished");
|
152 | } catch (Throwable th) { |
||
153 | 43126 | jjdelcerro | logger.warn("Problems install packages.", th);
|
154 | showWarning(panel.wizardPanel.getTranslation("_Cant_install_package"));
|
||
155 | 41718 | jjdelcerro | } |
156 | } |
||
157 | |||
158 | } |
||
159 | 40435 | jjdelcerro | } |