Source code: com/memoire/bu/BuDesktopPreferencesPanel.java
1 /**
2 * @modification $Date: 2002/12/16 18:56:24 $
3 * @statut unstable
4 * @file BuDesktopPreferencesPanel.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 import java.awt.event.*;
18 import java.awt.*;
19 import java.util.*;
20
21 import javax.swing.*;
22 import javax.swing.border.*;
23
24 /**
25 * A panel where the user can choose which elements to
26 * put on his desktop.
27 */
28
29 /*
30 * see below.
31 */
32
33 public class BuDesktopPreferencesPanel
34 extends BuAbstractPreferencesPanel
35 {
36 private static final int NBL=18;
37
38 private static final String[] CODES=new String[]
39 {
40 "leftcolumn.visible",
41 "specificbar.visible",
42 "rightcolumn.visible",
43 "statusbar.visible",
44 "columns.swapped",
45 "assistant.visible",
46 "button.icon",
47 "tool.icon",
48 "button.text",
49 "tool.text",
50 "toolbar.floatable",
51 "splashscreen.visible",
52 "toolbar.rollover",
53 "desktop.tabbed",
54 "desktop.grid",
55 "desktop.snap",
56 "desktop.dots",
57 "antialias.all",
58 };
59
60 private static final boolean[] DEFAUTS=new boolean[]
61 {
62 true,
63 true,
64 true,
65 true,
66 true,
67 true,
68 false,
69 true,
70 true,
71 true,
72 true,
73 true,
74 true,
75 true,
76 false,
77 false,
78 false,
79 false,
80 false,
81 };
82
83 private static final String[] INTITULES=new String[]
84 {
85 "Colonne gauche",
86 "Outils spécifiques",
87 "Colonne droite",
88 "Barre d'état",
89 "Colonnes inversées",
90 "Assistant",
91 "Icône de bouton",
92 "Icône d'outil",
93 "Texte de bouton",
94 "Texte d'outil",
95 "Détachement des barres",
96 "Ecran d'accueil",
97 "Survol des barres",
98 "Bureau à onglets",
99 "Grille",
100 "Magnétisme",
101 "Points",
102 "Antialiassage",
103 };
104
105 BuCommonInterface appli_;
106 BuPreferences options_;
107 BuCheckBox[] cbEtats_;
108
109 public String getTitle()
110 { return BuResource.BU.getString("Bureau"); }
111
112 // Constructeur
113
114 public BuDesktopPreferencesPanel(BuCommonInterface _appli)
115 {
116 super();
117 appli_ =_appli;
118 options_ =BuPreferences.BU;
119
120 BuPanel q=new BuPanel();
121 q.setLayout(new BuGridLayout(2,5,2));
122 q.setBorder(new EmptyBorder(0,5,0,5));
123
124 cbEtats_=new BuCheckBox[NBL];
125 for(int i=0;i<NBL;i++)
126 {
127 cbEtats_[i]=new BuCheckBox(BuResource.BU.getString(INTITULES[i]));
128 cbEtats_[i].setName("cb"+CODES[i].replace('.','_').toUpperCase());
129 cbEtats_[i].setActionCommand(CODES[i].replace('.','_').toUpperCase());
130 q.add(cbEtats_[i]);
131 }
132
133 BuPanel p=new BuPanel();
134 p.setBorder
135 (new CompoundBorder
136 (new TitledBorder(getTitle()),
137 new EmptyBorder(5,5,5,5)));
138 p.setLayout(new BuBorderLayout());
139 p.add(new BuScrollPane(q),BuBorderLayout.CENTER);
140
141 setLayout(new BuBorderLayout());
142 setBorder(new EmptyBorder(5,5,5,5));
143 setPreferredSize(new Dimension(200,200));
144 add(p,BuBorderLayout.CENTER);
145
146 for(int i=0;i<NBL;i++)
147 cbEtats_[i].setSelected(DEFAUTS[i]);
148
149 updateComponents();
150 }
151
152 // Methodes publiques
153
154 public boolean isPreferencesValidable()
155 { return true; }
156
157 public void validatePreferences()
158 {
159 fillTable();
160 options_.writeIniFile();
161 }
162
163 /*
164 public boolean isPreferencesApplyable()
165 { return true; }
166
167 public void applyPreferences()
168 {
169 fillTable();
170 options_.applyOn(appli_);
171 }
172 */
173
174 public boolean isPreferencesCancelable()
175 { return true; }
176
177 public void cancelPreferences()
178 {
179 options_.readIniFile();
180 updateComponents();
181 }
182
183 // Methodes privees
184
185 private void fillTable()
186 {
187 for(int i=0;i<NBL;i++)
188 options_.putBooleanProperty(CODES[i],cbEtats_[i].isSelected());
189 }
190
191 private void updateComponents()
192 {
193 for(int i=0;i<NBL;i++)
194 cbEtats_[i].setSelected
195 (options_.getBooleanProperty(CODES[i],DEFAUTS[i]));
196 }
197 }
198