01: /* This file is *not* under GPL or any other public license
02: * Copyright 2005 Ugo Taddei
03: */
04: package de.latlon.deejump.plugin.manager;
05:
06: import java.awt.Dimension;
07: import java.awt.event.ActionEvent;
08: import java.awt.event.ActionListener;
09:
10: import javax.swing.JCheckBox;
11: import javax.swing.JPanel;
12:
13: import com.vividsolutions.jump.util.StringUtil;
14:
15: public class ExtensionPanel extends JPanel {
16:
17: private ExtensionWrapper cataloguedExtension;
18: private JCheckBox installCheck;
19:
20: public ExtensionPanel(ExtensionWrapper catExtension) {
21: super ();
22: this .cataloguedExtension = catExtension;
23: initGUI();
24: final Dimension dim = new Dimension(300, 40);
25: setPreferredSize(dim);
26: setMinimumSize(dim);
27: setMaximumSize(dim);
28:
29: }
30:
31: private void initGUI() {
32:
33: final String label = StringUtil.limitLength(cataloguedExtension
34: .getTitle(), 30)
35: + " (" + cataloguedExtension.getCategory() + ") ";
36:
37: installCheck = new JCheckBox(label, cataloguedExtension
38: .isInstalled());
39: installCheck.addActionListener(new ActionListener() {
40:
41: public void actionPerformed(ActionEvent e) {
42: System.out.println("label: " + label);
43: cataloguedExtension.setInstalled(installCheck
44: .isSelected());
45: }
46:
47: });
48: final Dimension dim = new Dimension(286, 36);
49:
50: installCheck.setPreferredSize(dim);
51: installCheck.setMinimumSize(dim);
52:
53: installCheck.setAlignmentX(0.20f);
54: /*JLabel jLabel = new JLabel( label );
55:
56: JPanel panel = new JPanel();
57: panel.add( installCheck );
58: panel.add( jLabel );
59: */
60: add(installCheck);
61: }
62:
63: public String getExtensionText() {
64:
65: return this .cataloguedExtension.toString();
66: }
67:
68: public void setEnabled(boolean on) {
69: super .setEnabled(on);
70: for (int i = 0; i < getComponentCount(); i++) {
71: getComponent(i).setEnabled(on);
72: }
73: }
74:
75: /*public boolean isSelected() {
76: return this.installCheck.isSelected();
77: }
78: */
79: public void setSelected(boolean selected) {
80: this.installCheck.setSelected(selected);
81: cataloguedExtension.setInstalled(selected);
82: }
83:
84: }
|