01: package net.xoetrope.builder.editor.dialog;
02:
03: import java.util.Vector;
04:
05: import java.awt.Dimension;
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08: import javax.swing.JButton;
09: import javax.swing.JDialog;
10: import javax.swing.JFrame;
11: import javax.swing.border.EtchedBorder;
12:
13: import net.xoetrope.builder.editor.XuiDefaults;
14: import net.xoetrope.builder.editor.plugin.XPluginManager;
15: import net.xoetrope.swing.XButton;
16: import net.xoetrope.swing.XList;
17: import net.xoetrope.xui.XComponentFactory;
18: import net.xoetrope.xui.XPage;
19:
20: /**
21: * Display a list of plugins
22: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
23: * <p> $Revision: 1.5 $</p>
24: * <p> License: see License.txt</p>
25: */
26: public class XPluginListDialog extends JDialog implements
27: ActionListener {
28: protected JButton btnOK;
29: protected String selectedPage;
30: protected XList pluginList;
31:
32: public XPluginListDialog(JFrame frame, XPluginManager pm) {
33: setTitle("Choose the plugin");
34: getContentPane().setLayout(null);
35: setModal(true);
36:
37: setFont(XuiDefaults.defaultFont);
38:
39: XComponentFactory factory = new XComponentFactory(
40: XPage.XUI_SWING_PACKAGE);
41: factory.setParentComponent(getContentPane());
42:
43: pluginList = (XList) factory.addComponent(XPage.LIST, 10, 8,
44: 210, 150, null);
45: pluginList.setFont(XuiDefaults.defaultFont);
46: getContentPane().add(pluginList);
47:
48: int numPlugins = pm.getNumPlugins();
49: Vector plugins = new Vector(numPlugins);
50: for (int i = 0; i < numPlugins; i++)
51: plugins.add(pm.getPlugin(i).getName());
52: pluginList.setListData(plugins);
53: pluginList.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
54:
55: XButton okButton = (XButton) factory.addComponent(XPage.BUTTON,
56: 120, 170, 100, 20, "OK");
57: okButton.setFont(XuiDefaults.defaultFont);
58: okButton.addActionListener(this );
59:
60: XButton cancelButton = (XButton) factory.addComponent(
61: XPage.BUTTON, 10, 170, 100, 20, "Cancel");
62: cancelButton.setFont(XuiDefaults.defaultFont);
63: cancelButton.addActionListener(this );
64:
65: setSize(238, 232);
66: Dimension frameSize = frame.getSize();
67: setLocation((frameSize.width - 238) / 2,
68: (frameSize.height - 232) / 2);
69: setLocationRelativeTo(frame);
70: setModal(true);
71: }
72:
73: public int getSelection() {
74: return pluginList.getSelectedIndex();
75: }
76:
77: public void actionPerformed(ActionEvent e) {
78: hide();
79: }
80: }
|