1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.plugin;
21
22 import java.awt.Component;
23 import java.awt.event.ActionEvent;
24
25 import javax.swing.AbstractAction;
26 import javax.swing.Action;
27
28 import org.xnap.XNap;
29 import org.xnap.gui.component.DefaultDialog;
30 import org.xnap.gui.component.XNapButton;
31 import org.xnap.gui.util.*;
32
33 public class PluginDialog extends DefaultDialog {
34
35
36
37
38
39 private static PluginDialog me = null;
40
41 private PluginPanel panel;
42 private Action updateListAction = new UpdateListAction();
43
44
45
46 private PluginDialog()
47 {
48 super(BUTTON_OKAY | BUTTON_CANCEL);
49
50 initialize();
51
52 pack();
53 setSize(550, 400);
54
55 panel.update();
56 }
57
58 public void initialize()
59 {
60 setTitle(XNap.tr("Plugins"));
61
62
63 panel = new PluginPanel(true);
64 setMainComponent(panel);
65
66
67
68 GUIHelper.bindEscapeKey(panel.getPluginTree(), null);
69
70
71 getButtonPanel().add(new XNapButton(updateListAction), 0);
72 }
73
74
75
76 public static void showDialog(Component c)
77 {
78 if (me == null) {
79 me = new PluginDialog();
80 }
81 me.show(c);
82 }
83
84 public boolean apply()
85 {
86 panel.apply();
87 return PluginInstallerDialog.commit(this);
88 }
89
90 public void close()
91 {
92 dispose();
93 me = null;
94 }
95
96
97
98 private class UpdateListAction extends AbstractAction {
99
100 public UpdateListAction()
101 {
102 putValue(Action.NAME, XNap.tr("Update List"));
103 putValue(Action.SHORT_DESCRIPTION,
104 XNap.tr("Updates the list packages from the internet."));
105 }
106
107 public void actionPerformed(ActionEvent event)
108 {
109 panel.updatePackageManager();
110 }
111
112 }
113
114 }