root / 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 / DefaultJShowUnresolvedDependenciesAndAskContinuePanel.java @ 38608
History | View | Annotate | Download (3.12 KB)
1 | 37409 | fdiaz | package org.gvsig.installer.swing.impl; |
---|---|---|---|
2 | |||
3 | import java.awt.BorderLayout; |
||
4 | import java.awt.Dimension; |
||
5 | import java.awt.event.ActionEvent; |
||
6 | import java.awt.event.ActionListener; |
||
7 | |||
8 | import javax.swing.BorderFactory; |
||
9 | import javax.swing.Box; |
||
10 | import javax.swing.BoxLayout; |
||
11 | import javax.swing.JButton; |
||
12 | import javax.swing.JLabel; |
||
13 | import javax.swing.JList; |
||
14 | import javax.swing.JPanel; |
||
15 | import javax.swing.JScrollPane; |
||
16 | |||
17 | import org.gvsig.installer.lib.api.Dependencies; |
||
18 | import org.gvsig.installer.swing.api.SwingInstallerManager; |
||
19 | import org.gvsig.installer.swing.api.execution.JShowUnresolvedDependenciesAndAskContinuePanel; |
||
20 | |||
21 | 37598 | nfrancisco | public class DefaultJShowUnresolvedDependenciesAndAskContinuePanel extends |
22 | JShowUnresolvedDependenciesAndAskContinuePanel implements
|
||
23 | ActionListener {
|
||
24 | 37409 | fdiaz | |
25 | /**
|
||
26 | *
|
||
27 | */
|
||
28 | private static final long serialVersionUID = 2135985029410816305L; |
||
29 | private Dependencies dependencies;
|
||
30 | private boolean doCancel = true; |
||
31 | 37598 | nfrancisco | |
32 | public DefaultJShowUnresolvedDependenciesAndAskContinuePanel(
|
||
33 | SwingInstallerManager manager, Dependencies dependencies, |
||
34 | String message) {
|
||
35 | // this.buildPackageList(dependencies);
|
||
36 | 37409 | fdiaz | this.dependencies = dependencies;
|
37 | this.createUI(manager, message);
|
||
38 | } |
||
39 | |||
40 | 37598 | nfrancisco | // private void buildPackageList(Dependencies dependencies) {
|
41 | // this.dependencies = new ArrayList<String>();
|
||
42 | // for( int i=0 ; i<packages.size(); i++ ) {
|
||
43 | // PackageInfo pkg = packages.get(i);
|
||
44 | // this.packages.add(pkg.getName());
|
||
45 | // }
|
||
46 | // }
|
||
47 | 37409 | fdiaz | |
48 | 37598 | nfrancisco | private void createUI(SwingInstallerManager manager, String message) { |
49 | this.setLayout(new BorderLayout()); |
||
50 | 37409 | fdiaz | |
51 | 37598 | nfrancisco | JButton cancelButton = new JButton(manager.getText("_cancel")); |
52 | cancelButton.setActionCommand("cancel");
|
||
53 | cancelButton.addActionListener(this);
|
||
54 | //
|
||
55 | final JButton continueButton = new JButton(manager.getText("_continue")); |
||
56 | continueButton.setActionCommand("continue");
|
||
57 | continueButton.addActionListener(this);
|
||
58 | 37409 | fdiaz | |
59 | 37598 | nfrancisco | JList list = new JList(this.dependencies.toArray()); |
60 | 37409 | fdiaz | |
61 | 37598 | nfrancisco | JScrollPane listScroller = new JScrollPane(list); |
62 | listScroller.setPreferredSize(new Dimension(250, 80)); |
||
63 | listScroller.setAlignmentX(LEFT_ALIGNMENT); |
||
64 | |||
65 | JPanel listPane = new JPanel(); |
||
66 | listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); |
||
67 | JLabel label = new JLabel(message); |
||
68 | label.setLabelFor(list); |
||
69 | listPane.add(label); |
||
70 | listPane.add(Box.createRigidArea(new Dimension(0, 5))); |
||
71 | listPane.add(listScroller); |
||
72 | listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||
73 | |||
74 | JPanel buttonPane = new JPanel(); |
||
75 | buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); |
||
76 | buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); |
||
77 | buttonPane.add(Box.createHorizontalGlue());
|
||
78 | buttonPane.add(cancelButton); |
||
79 | buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); |
||
80 | buttonPane.add(continueButton); |
||
81 | |||
82 | this.add(listPane, BorderLayout.CENTER); |
||
83 | this.add(buttonPane, BorderLayout.PAGE_END); |
||
84 | 37409 | fdiaz | } |
85 | 37598 | nfrancisco | |
86 | 37599 | nfrancisco | @Override
|
87 | 37409 | fdiaz | public boolean cancelled() { |
88 | return doCancel;
|
||
89 | } |
||
90 | 37598 | nfrancisco | |
91 | 37599 | nfrancisco | @Override
|
92 | 37409 | fdiaz | public boolean needShow() { |
93 | 37598 | nfrancisco | return this.dependencies.size() > 0; |
94 | 37409 | fdiaz | } |
95 | |||
96 | public void actionPerformed(ActionEvent e) { |
||
97 | if ("cancel".equals(e.getActionCommand())) { |
||
98 | doCancel = true;
|
||
99 | } else {
|
||
100 | doCancel = false;
|
||
101 | } |
||
102 | this.setVisible(false); |
||
103 | } |
||
104 | } |