root / tags / v2_0_0_Build_2030 / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / wizard / SelectPackagesWizard.java @ 35836
History | View | Annotate | Download (6.25 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 |
|
28 |
package org.gvsig.installer.swing.impl.execution.wizard; |
29 |
|
30 |
import java.util.List; |
31 |
|
32 |
import javax.swing.JPanel; |
33 |
|
34 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
35 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
36 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
37 |
import org.gvsig.installer.lib.api.PackageInfo; |
38 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
39 |
import org.gvsig.installer.swing.api.execution.JShowPackageStatusAndAskContinuePanel; |
40 |
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard; |
41 |
import org.gvsig.installer.swing.impl.execution.model.PackagesTableModel; |
42 |
import org.gvsig.installer.swing.impl.execution.panel.SelectPackagesPanel; |
43 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
44 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
45 |
|
46 |
/**
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
48 |
*/
|
49 |
public class SelectPackagesWizard extends SelectPackagesPanel implements |
50 |
OptionPanel { |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = 7123332873297652726L; |
56 |
protected DefaultInstallPackageWizard installerExecutionWizard;
|
57 |
PackagesTableModel officialPluginsTableModel = null;
|
58 |
PackagesTableModel notOfficialPluginsTableModel = null;
|
59 |
|
60 |
private int direccion = WizardPanelWithLogo.ACTION_NEXT; |
61 |
|
62 |
public SelectPackagesWizard(
|
63 |
DefaultInstallPackageWizard installerExecutionWizard) { |
64 |
super();
|
65 |
this.installerExecutionWizard = installerExecutionWizard;
|
66 |
} |
67 |
|
68 |
public JPanel getJPanel() { |
69 |
return this; |
70 |
} |
71 |
|
72 |
public String getPanelTitle() { |
73 |
return swingInstallerManager.getText("select_plugins"); |
74 |
} |
75 |
|
76 |
public void lastPanel() { |
77 |
direccion = WizardPanelWithLogo.ACTION_NEXT; |
78 |
} |
79 |
|
80 |
public void nextPanel() throws NotContinueWizardException { |
81 |
List<PackageInfo> packagesToInstall =
|
82 |
this.installerExecutionWizard.getInstallersToInstall();
|
83 |
|
84 |
JShowPackageStatusAndAskContinuePanel dlg = this.swingInstallerManager.createJShowPackageStatusAndAskContinuePanel(
|
85 |
packagesToInstall, |
86 |
"Ha seleccionado versiones de desarrollo o no oficiales\n?Desea Continuar?"
|
87 |
); |
88 |
if( dlg.needShow() ) {
|
89 |
WindowManager wm = ToolsSwingLocator.getWindowManager(); |
90 |
wm.showWindow(dlg,"? Desea continuar ?", WindowManager.MODE.DIALOG);
|
91 |
if( dlg.cancelled() ) {
|
92 |
throw new NotContinueWizardException("",null,false); |
93 |
} |
94 |
} |
95 |
direccion = WizardPanelWithLogo.ACTION_PREVIOUS; |
96 |
installerExecutionWizard.setNextButtonEnabled(false);
|
97 |
} |
98 |
|
99 |
public void updatePanel() { |
100 |
|
101 |
InstallPackageService installerExecutionService = |
102 |
installerExecutionWizard.getInstallerExecutionService(); |
103 |
|
104 |
if (officialPluginsTableModel == null) { |
105 |
officialPluginsTableModel = |
106 |
new PackagesTableModel(swingInstallerManager,
|
107 |
installerExecutionService, true, installerExecutionWizard
|
108 |
.getPluginsFolder()); |
109 |
} else {
|
110 |
officialPluginsTableModel.updatePackages(); |
111 |
} |
112 |
if (notOfficialPluginsTableModel == null) { |
113 |
notOfficialPluginsTableModel = |
114 |
new PackagesTableModel(swingInstallerManager,
|
115 |
installerExecutionService, false, installerExecutionWizard
|
116 |
.getPluginsFolder()); |
117 |
} else {
|
118 |
notOfficialPluginsTableModel.updatePackages(); |
119 |
} |
120 |
updateTableModel(officialPluginsTableModel, |
121 |
notOfficialPluginsTableModel); |
122 |
|
123 |
|
124 |
// if default packages must be selected or not
|
125 |
if (installerExecutionWizard.getSelectDefaultPackages()) {
|
126 |
selectPackages(); |
127 |
} |
128 |
|
129 |
// if this panel has not to be shown
|
130 |
if (!installerExecutionWizard.showSelectPackagesPanel()) {
|
131 |
saltaOno(installerExecutionService); |
132 |
} |
133 |
|
134 |
|
135 |
|
136 |
checkIfPluginSelected(); |
137 |
} |
138 |
|
139 |
@Override
|
140 |
public void checkIfPluginSelected() { |
141 |
if (installerExecutionWizard.showSelectPackagesPanel()) {
|
142 |
installerExecutionWizard.setNextButtonEnabled(isPackageSelected()); |
143 |
} |
144 |
} |
145 |
|
146 |
private void saltaOno(InstallPackageService installerExecutionService) { |
147 |
|
148 |
List<String> defaultPackageIDs = |
149 |
installerExecutionService.getDefaultSelectedPackagesIDs(); |
150 |
|
151 |
boolean defaultPacketsExist = false; |
152 |
|
153 |
// check if there is any default package
|
154 |
if (defaultPackageIDs != null) { |
155 |
for (int i = 0; i < installerExecutionService.getPackageCount(); i++) { |
156 |
if (defaultPackageIDs.contains(installerExecutionService
|
157 |
.getPackageInfo(i).getID())) { |
158 |
defaultPacketsExist = true;
|
159 |
} |
160 |
} |
161 |
} |
162 |
|
163 |
if (defaultPacketsExist) {
|
164 |
(installerExecutionWizard).doAction(direccion); |
165 |
// if there is not any package, show error and jump back.
|
166 |
} else {
|
167 |
(installerExecutionWizard) |
168 |
.doAction(WizardPanelWithLogo.ACTION_PREVIOUS); |
169 |
try {
|
170 |
throw new Exception( |
171 |
"_There_are_no_packages_in_typical_installation_to_select");
|
172 |
} catch (Exception e) { |
173 |
// TODO Auto-generated catch block
|
174 |
e.printStackTrace(); |
175 |
} |
176 |
|
177 |
} |
178 |
|
179 |
} |
180 |
|
181 |
} |