Source code: com/memoire/bu/BuGenericPreferencesPanel.java
1 /**
2 * @modification $Date: 2001/12/03 16:28:07 $
3 * @statut unstable
4 * @file BuGenericPreferencesPanel.java
5 * @version 0.36
6 * @author Guillaume Desnoix
7 * @email guillaume@desnoix.com
8 * @license GNU General Public License 2 (GPL2)
9 * @copyright 1998-2001 Guillaume Desnoix
10 */
11
12 package com.memoire.bu;
13
14 import com.memoire.bu.*;
15 import com.memoire.fu.*;
16
17 /**
18 * @creation 2001-03-06
19 * @modification 2001-03-06
20 * @statut unstable
21 */
22
23 import java.awt.*;
24 import java.awt.event.*;
25 import java.util.*;
26
27 import javax.swing.*;
28 import javax.swing.border.*;
29 import javax.swing.event.*;
30 import javax.swing.table.*;
31
32 /**
33 * A panel where the user can view/edit preferences.
34 * any
35 */
36 public class BuGenericPreferencesPanel
37 extends BuAbstractPreferencesPanel
38 {
39 private String title_;
40 private BuCommonInterface appli_;
41 private FuPreferences options_;
42 private boolean editable_,growable_;
43 private BuGenericPreferencesModel model_;
44
45 public String getTitle() { return title_; }
46
47 public BuGenericPreferencesPanel
48 (BuCommonInterface _appli, String _title, FuPreferences _options)
49 {
50 this(_appli,_title,_options,"",true,false);
51 }
52
53 public BuGenericPreferencesPanel
54 (BuCommonInterface _appli, String _title, FuPreferences _options,
55 String _mask, boolean _editable, boolean _growable)
56 {
57 super();
58 appli_ =_appli;
59 title_ =_title;
60 options_ =_options;
61 editable_=_editable;
62 growable_=_growable;
63 model_ =new BuGenericPreferencesModel
64 (options_,_mask,editable_,growable_);
65
66 BuBorderLayout lo=new BuBorderLayout();
67 lo.setVgap(5);
68 lo.setHgap(5);
69
70 BuPanel p=new BuPanel();
71 p.setBorder
72 (new CompoundBorder
73 (new TitledBorder(getTitle()),
74 new EmptyBorder(5,5,5,5)));
75 p.setLayout(lo);
76
77 BuTable table=new BuTable(model_);
78 //table.setFont(BuLib.deriveFont("Table",-2));
79 p.add(new BuScrollPane(table),BuBorderLayout.CENTER);
80
81 setLayout(new BuBorderLayout());
82 setBorder(new EmptyBorder(5,5,5,5));
83 add(p,BuBorderLayout.CENTER);
84 setPreferredSize(new Dimension(200,200));
85 }
86
87 public boolean isPreferencesValidable()
88 { return (editable_||growable_); }
89
90 public void validatePreferences()
91 {
92 options_.writeIniFile();
93 }
94
95 public boolean isPreferencesCancelable()
96 { return (editable_||growable_); }
97
98 public void cancelPreferences()
99 {
100 options_.readIniFile();
101 model_.fireTableChanged();
102 }
103 }