Revision 37598 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/DefaultJShowPackageStatusAndAskContinuePanel.java
DefaultJShowPackageStatusAndAskContinuePanel.java | ||
---|---|---|
21 | 21 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
22 | 22 |
import org.gvsig.installer.swing.api.execution.JShowPackageStatusAndAskContinuePanel; |
23 | 23 |
|
24 |
public class DefaultJShowPackageStatusAndAskContinuePanel extends JShowPackageStatusAndAskContinuePanel implements ActionListener { |
|
24 |
public class DefaultJShowPackageStatusAndAskContinuePanel extends |
|
25 |
JShowPackageStatusAndAskContinuePanel implements ActionListener { |
|
25 | 26 |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
*/ |
|
30 | 27 |
private static final long serialVersionUID = -3142143854199963997L; |
31 | 28 |
private List<String> packages; |
32 | 29 |
private boolean doCancel = true; |
33 |
|
|
34 |
public DefaultJShowPackageStatusAndAskContinuePanel(SwingInstallerManager manager, List<PackageInfo> packages, String message) { |
|
30 |
DefaultSwingInstallerManager swingInstallerManager; |
|
31 |
|
|
32 |
public DefaultJShowPackageStatusAndAskContinuePanel( |
|
33 |
SwingInstallerManager manager, List<PackageInfo> packages, |
|
34 |
String message) { |
|
35 |
this.swingInstallerManager = (DefaultSwingInstallerManager) manager; |
|
35 | 36 |
this.buildPackageList(packages); |
36 | 37 |
this.createUI(manager, message); |
37 | 38 |
} |
38 |
|
|
39 |
|
|
39 | 40 |
private void buildPackageList(List<PackageInfo> packages) { |
40 | 41 |
this.packages = new ArrayList<String>(); |
41 |
for( int i=0 ; i<packages.size(); i++ ) {
|
|
42 |
for (int i = 0; i < packages.size(); i++) {
|
|
42 | 43 |
PackageInfo pkg = packages.get(i); |
43 |
if( !pkg.isOfficial()) { |
|
44 |
this.packages.add(pkg.getName()+"(no oficial)"); |
|
45 |
} else if(!InstallerManager.STATE.FINAL.equalsIgnoreCase(pkg.getState()) ) { |
|
46 |
this.packages.add(pkg.getName()+ "("+pkg.getState()+")"); |
|
44 |
if (!pkg.isOfficial()) { |
|
45 |
this.packages.add(pkg.getName() + " (" |
|
46 |
+ swingInstallerManager.getText("_not_official") + ")"); |
|
47 |
} else if (!InstallerManager.STATE.FINAL.equalsIgnoreCase(pkg |
|
48 |
.getState())) { |
|
49 |
this.packages.add(pkg.getName() + " (" + pkg.getState() + ")"); |
|
47 | 50 |
} |
48 | 51 |
} |
49 | 52 |
} |
50 |
|
|
51 |
private void createUI(SwingInstallerManager manager,String message) { |
|
52 |
this.setLayout( new BorderLayout()); |
|
53 |
|
|
54 |
JButton cancelButton = new JButton("Cancel"); |
|
55 |
cancelButton.setActionCommand("cancel"); |
|
56 |
cancelButton.addActionListener(this); |
|
57 |
// |
|
58 |
final JButton continueButton = new JButton("Continue"); |
|
59 |
continueButton.setActionCommand("continue"); |
|
60 |
continueButton.addActionListener(this); |
|
61 | 53 |
|
62 |
JList list = new JList(this.packages.toArray()); |
|
54 |
private void createUI(SwingInstallerManager manager, String message) { |
|
55 |
this.setLayout(new BorderLayout()); |
|
63 | 56 |
|
64 |
JScrollPane listScroller = new JScrollPane(list); |
|
65 |
listScroller.setPreferredSize(new Dimension(250, 80)); |
|
66 |
listScroller.setAlignmentX(LEFT_ALIGNMENT); |
|
57 |
JButton cancelButton = new JButton(swingInstallerManager |
|
58 |
.getText("_cancel")); |
|
59 |
cancelButton.setActionCommand("cancel"); |
|
60 |
cancelButton.addActionListener(this); |
|
61 |
// |
|
62 |
final JButton continueButton = new JButton(swingInstallerManager |
|
63 |
.getText("_continue")); |
|
64 |
continueButton.setActionCommand("continue"); |
|
65 |
continueButton.addActionListener(this); |
|
67 | 66 |
|
68 |
JPanel listPane = new JPanel(); |
|
69 |
listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); |
|
70 |
JLabel label = new JLabel(message); |
|
71 |
label.setLabelFor(list); |
|
72 |
listPane.add(label); |
|
73 |
listPane.add(Box.createRigidArea(new Dimension(0,5))); |
|
74 |
listPane.add(listScroller); |
|
75 |
listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); |
|
67 |
JList list = new JList(this.packages.toArray()); |
|
76 | 68 |
|
77 |
JPanel buttonPane = new JPanel(); |
|
78 |
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); |
|
79 |
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
|
80 |
buttonPane.add(Box.createHorizontalGlue()); |
|
81 |
buttonPane.add(cancelButton); |
|
82 |
buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); |
|
83 |
buttonPane.add(continueButton); |
|
69 |
JScrollPane listScroller = new JScrollPane(list); |
|
70 |
listScroller.setPreferredSize(new Dimension(250, 80)); |
|
71 |
listScroller.setAlignmentX(LEFT_ALIGNMENT); |
|
84 | 72 |
|
85 |
this.add(listPane, BorderLayout.CENTER); |
|
86 |
this.add(buttonPane, BorderLayout.PAGE_END); |
|
73 |
JPanel listPane = new JPanel(); |
|
74 |
listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); |
|
75 |
JLabel label = new JLabel(message); |
|
76 |
label.setLabelFor(list); |
|
77 |
listPane.add(label); |
|
78 |
listPane.add(Box.createRigidArea(new Dimension(0, 5))); |
|
79 |
listPane.add(listScroller); |
|
80 |
listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
81 |
|
|
82 |
JPanel buttonPane = new JPanel(); |
|
83 |
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); |
|
84 |
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
|
85 |
buttonPane.add(Box.createHorizontalGlue()); |
|
86 |
buttonPane.add(cancelButton); |
|
87 |
buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); |
|
88 |
buttonPane.add(continueButton); |
|
89 |
|
|
90 |
this.add(listPane, BorderLayout.CENTER); |
|
91 |
this.add(buttonPane, BorderLayout.PAGE_END); |
|
87 | 92 |
} |
88 |
|
|
93 |
|
|
89 | 94 |
public boolean cancelled() { |
90 | 95 |
return doCancel; |
91 | 96 |
} |
92 |
|
|
97 |
|
|
93 | 98 |
public boolean needShow() { |
94 |
return this.packages.size()>0;
|
|
99 |
return this.packages.size() > 0;
|
|
95 | 100 |
} |
96 | 101 |
|
97 | 102 |
public void actionPerformed(ActionEvent e) { |
Also available in: Unified diff