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 / DefaultJShowUnresolvedDependenciesAndAskContinuePanel.java @ 40560
History | View | Annotate | Download (4.2 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
|
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; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.event.ActionEvent; |
29 |
import java.awt.event.ActionListener; |
30 |
|
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.Box; |
33 |
import javax.swing.BoxLayout; |
34 |
import javax.swing.JButton; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JList; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JScrollPane; |
39 |
|
40 |
import org.gvsig.installer.lib.api.Dependencies; |
41 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
42 |
import org.gvsig.installer.swing.api.execution.JShowUnresolvedDependenciesAndAskContinuePanel; |
43 |
|
44 |
public class DefaultJShowUnresolvedDependenciesAndAskContinuePanel extends |
45 |
JShowUnresolvedDependenciesAndAskContinuePanel implements
|
46 |
ActionListener {
|
47 |
|
48 |
/**
|
49 |
*
|
50 |
*/
|
51 |
private static final long serialVersionUID = 2135985029410816305L; |
52 |
private Dependencies dependencies;
|
53 |
private boolean doCancel = true; |
54 |
|
55 |
public DefaultJShowUnresolvedDependenciesAndAskContinuePanel(
|
56 |
SwingInstallerManager manager, Dependencies dependencies, |
57 |
String message) {
|
58 |
// this.buildPackageList(dependencies);
|
59 |
this.dependencies = dependencies;
|
60 |
this.createUI(manager, message);
|
61 |
} |
62 |
|
63 |
// private void buildPackageList(Dependencies dependencies) {
|
64 |
// this.dependencies = new ArrayList<String>();
|
65 |
// for( int i=0 ; i<packages.size(); i++ ) {
|
66 |
// PackageInfo pkg = packages.get(i);
|
67 |
// this.packages.add(pkg.getName());
|
68 |
// }
|
69 |
// }
|
70 |
|
71 |
private void createUI(SwingInstallerManager manager, String message) { |
72 |
this.setLayout(new BorderLayout()); |
73 |
|
74 |
JButton cancelButton = new JButton(manager.getText("_cancel")); |
75 |
cancelButton.setActionCommand("cancel");
|
76 |
cancelButton.addActionListener(this);
|
77 |
//
|
78 |
final JButton continueButton = new JButton(manager.getText("_continue")); |
79 |
continueButton.setActionCommand("continue");
|
80 |
continueButton.addActionListener(this);
|
81 |
|
82 |
JList list = new JList(this.dependencies.toArray()); |
83 |
|
84 |
JScrollPane listScroller = new JScrollPane(list); |
85 |
listScroller.setPreferredSize(new Dimension(250, 80)); |
86 |
listScroller.setAlignmentX(LEFT_ALIGNMENT); |
87 |
|
88 |
JPanel listPane = new JPanel(); |
89 |
listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); |
90 |
|
91 |
String html_msg = DefaultJShowPackageStatusAndAskContinuePanel.getHtmlText(message);
|
92 |
JLabel label = new JLabel(html_msg); |
93 |
|
94 |
label.setLabelFor(list); |
95 |
listPane.add(label); |
96 |
listPane.add(Box.createRigidArea(new Dimension(0, 5))); |
97 |
listPane.add(listScroller); |
98 |
listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
99 |
|
100 |
JPanel buttonPane = new JPanel(); |
101 |
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); |
102 |
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
103 |
buttonPane.add(Box.createHorizontalGlue());
|
104 |
buttonPane.add(cancelButton); |
105 |
buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); |
106 |
buttonPane.add(continueButton); |
107 |
|
108 |
this.add(listPane, BorderLayout.CENTER); |
109 |
this.add(buttonPane, BorderLayout.PAGE_END); |
110 |
|
111 |
this.setPreferredSize(new Dimension(500, 300)); |
112 |
} |
113 |
|
114 |
@Override
|
115 |
public boolean cancelled() { |
116 |
return doCancel;
|
117 |
} |
118 |
|
119 |
@Override
|
120 |
public boolean needShow() { |
121 |
return this.dependencies.size() > 0; |
122 |
} |
123 |
|
124 |
public void actionPerformed(ActionEvent e) { |
125 |
if ("cancel".equals(e.getActionCommand())) { |
126 |
doCancel = true;
|
127 |
} else {
|
128 |
doCancel = false;
|
129 |
} |
130 |
this.setVisible(false); |
131 |
} |
132 |
} |