49
49
public class GuiConfigDialog extends JDialog {
51
private static final String TITLE = "Configure look and feel";
52
private static final String WIDTH_TOOLTIP = "Width of a sticky note in px.";
53
private static final String HEIGHT_TOOLTIP = "Height of a sticky note in px.";
54
private static final String SYSTRAY_TOOLTIP = "Path to icon used in system tray (requires restart).";
55
private static final String SPACING_TOOLTIP = "Offset in px. between sticky notes when layed out on the screen.";
56
private static final String NOTE_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'note'.";
57
private static final String NOTE_TOP_TOOLTIP = "Top color used for sticky notes of type 'note'.";
58
private static final String PHONE_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'phone call'.";
59
private static final String PHONE_TOP_TOOLTIP = "Top color used for sticky notes of type 'phone call'.";
60
private static final String TASK_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'task'.";
61
private static final String TASK_TOP_TOOLTIP = "Top color used for sticky notes of type 'task'.";
62
private static final String DRAG_DELAY_TOOLTIP = "Threshold value to tweak the drag behaviour, higher values will delay the repaint events making it easier for slow graphic cards to keep up.";
63
private static final String DOUBLE_CLICK_DELAY_TOOLTIP = "Delay in ms between two clicks to register as a double click.";
65
private JSpinner widthSpinner;
66
private JSpinner spacingSpinner;
67
private JSpinner heightSpinner;
68
private ColorButton btnTopColorNotes;
69
private ColorButton btnTopColorTasks;
70
private ColorButton btnTopColorPhoneCalls;
71
private ColorButton btnBottomColorNotes;
72
private ColorButton btnBottomColorTasks;
73
private ColorButton btnBottomColorPhoneCalls;
74
private JSpinner dragDelaySpinner;
75
private JSpinner doubleClickDelaySpinner;
76
private JTextField trayIconField;
78
public GuiConfigDialog(JFrame parent) {
79
super(parent, TITLE, true);
80
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
83
JPanel actionPanel = new JPanel();
84
getContentPane().add(actionPanel, BorderLayout.SOUTH);
85
actionPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"),
86
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
87
FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
88
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
89
ColumnSpec.decode("max(40dlu;default)"), FormFactory.RELATED_GAP_COLSPEC,
90
ColumnSpec.decode("max(5dlu;default)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC,
91
FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(5dlu;default)"), }));
93
JButton btnCancel = new JButton("Cancel");
94
btnCancel.addActionListener(new ActionListener() {
96
public void actionPerformed(ActionEvent e) {
100
actionPanel.add(btnCancel, "7, 1, 2, 1");
102
JButton btnDefaults = new JButton("Load defaults");
103
btnDefaults.addActionListener(new ActionListener() {
105
public void actionPerformed(ActionEvent e) {
109
actionPanel.add(btnDefaults, "3, 1");
111
JButton btnOk = new JButton("OK");
112
btnOk.addActionListener(new ActionListener() {
114
public void actionPerformed(ActionEvent e) {
119
actionPanel.add(btnOk, "11, 1, 2, 1");
121
JPanel configPanel = new JPanel();
122
getContentPane().add(configPanel, BorderLayout.CENTER);
123
configPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("max(61dlu;min):grow"),
124
ColumnSpec.decode("max(40dlu;default):grow"), FormFactory.RELATED_GAP_COLSPEC,
125
ColumnSpec.decode("99px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(30dlu;default)"),
126
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
127
ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
128
FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
129
ColumnSpec.decode("max(30dlu;default)"), FormFactory.RELATED_GAP_COLSPEC,
130
ColumnSpec.decode("max(30dlu;default)"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC,
131
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
132
FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
133
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
134
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
135
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
136
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
137
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));
139
StringSeparator dimensionsSeparator = new StringSeparator("Dimensions");
140
configPanel.add(dimensionsSeparator, "1, 2, 18, 1");
142
JLabel lblWidth = new JLabel("Width");
143
configPanel.add(lblWidth, "4, 4, right, center");
145
widthSpinner = new JSpinner();
146
widthSpinner.setToolTipText(WIDTH_TOOLTIP);
147
configPanel.add(widthSpinner, "6, 4");
149
JLabel lblPx_1 = new JLabel("px");
150
configPanel.add(lblPx_1, "8, 4");
152
JLabel lblHeight = new JLabel("Height");
153
configPanel.add(lblHeight, "12, 4, 3, 1, right, center");
155
heightSpinner = new JSpinner();
156
heightSpinner.setToolTipText(HEIGHT_TOOLTIP);
157
configPanel.add(heightSpinner, "16, 4");
159
JLabel lblPx = new JLabel("px");
160
configPanel.add(lblPx, "18, 4");
162
JLabel lblSpacing = new JLabel("Spacing:");
163
configPanel.add(lblSpacing, "4, 5, right, center");
165
spacingSpinner = new JSpinner();
166
spacingSpinner.setToolTipText(SPACING_TOOLTIP);
167
configPanel.add(spacingSpinner, "6, 5");
169
JLabel lblPx_2 = new JLabel("px");
170
configPanel.add(lblPx_2, "8, 5");
172
StringSeparator colorsSeparator = new StringSeparator("Colors");
173
configPanel.add(colorsSeparator, "1, 6, 18, 1");
175
JLabel lblNotes = new JLabel("Notes");
176
configPanel.add(lblNotes, "2, 8, right, default");
178
JLabel lblTop = new JLabel("Top:");
179
configPanel.add(lblTop, "4, 8, right, center");
181
btnTopColorNotes = new ColorButton(InfologClientProperties.noteTopColor);
182
btnTopColorNotes.setToolTipText(NOTE_TOP_TOOLTIP);
183
configPanel.add(btnTopColorNotes, "6, 8, fill, fill");
185
JLabel lblBottom = new JLabel("Bottom:");
186
configPanel.add(lblBottom, "12, 8, 3, 1, right, center");
188
btnBottomColorNotes = new ColorButton(InfologClientProperties.noteBottomColor);
189
btnBottomColorNotes.setToolTipText(NOTE_BOTTOM_TOOLTIP);
190
configPanel.add(btnBottomColorNotes, "16, 8, fill, fill");
192
JLabel lblTasks = new JLabel("Tasks");
193
configPanel.add(lblTasks, "2, 10, right, default");
195
JLabel lblTop_1 = new JLabel("Top:");
196
configPanel.add(lblTop_1, "4, 10, right, center");
198
btnTopColorTasks = new ColorButton(InfologClientProperties.taskTopColor);
199
btnTopColorTasks.setToolTipText(TASK_TOP_TOOLTIP);
200
configPanel.add(btnTopColorTasks, "6, 10, fill, fill");
202
JLabel lblBottom_1 = new JLabel("Bottom:");
203
configPanel.add(lblBottom_1, "12, 10, 3, 1, right, center");
205
btnBottomColorTasks = new ColorButton(InfologClientProperties.taskBottomColor);
206
btnBottomColorTasks.setToolTipText(TASK_BOTTOM_TOOLTIP);
207
configPanel.add(btnBottomColorTasks, "16, 10, fill, fill");
209
JLabel lblPhoneCalls = new JLabel("Phone Calls");
210
configPanel.add(lblPhoneCalls, "2, 12, right, default");
212
JLabel lblTop_2 = new JLabel("Top:");
213
configPanel.add(lblTop_2, "4, 12, right, center");
215
btnTopColorPhoneCalls = new ColorButton(InfologClientProperties.phoneTopColor);
216
btnTopColorPhoneCalls.setToolTipText(PHONE_TOP_TOOLTIP);
217
configPanel.add(btnTopColorPhoneCalls, "6, 12, fill, fill");
219
JLabel lblBottom_2 = new JLabel("Bottom:");
220
configPanel.add(lblBottom_2, "12, 12, 3, 1, right, center");
222
btnBottomColorPhoneCalls = new ColorButton(InfologClientProperties.phoneBottomColor);
223
btnBottomColorPhoneCalls.setToolTipText(PHONE_BOTTOM_TOOLTIP);
224
configPanel.add(btnBottomColorPhoneCalls, "16, 12, fill, fill");
226
StringSeparator behaviourSeparator = new StringSeparator("Mouse behaviour");
227
configPanel.add(behaviourSeparator, "1, 14, 18, 1, fill, default");
229
JLabel lblDragDelay = new JLabel("Drag delay: ");
230
configPanel.add(lblDragDelay, "4, 16, right, center");
232
dragDelaySpinner = new JSpinner();
233
dragDelaySpinner.setToolTipText(DRAG_DELAY_TOOLTIP);
234
configPanel.add(dragDelaySpinner, "6, 16");
236
JLabel lblDoubleClickDelay = new JLabel("Double click delay:");
237
configPanel.add(lblDoubleClickDelay, "10, 16, 5, 1, right, center");
239
doubleClickDelaySpinner = new JSpinner();
240
doubleClickDelaySpinner.setToolTipText(DOUBLE_CLICK_DELAY_TOOLTIP);
241
configPanel.add(doubleClickDelaySpinner, "16, 16");
243
StringSeparator iconSeparator = new StringSeparator("System tray icon");
244
configPanel.add(iconSeparator, "1, 18, 18, 1");
246
trayIconField = new JTextField();
247
trayIconField.setToolTipText(SYSTRAY_TOOLTIP);
248
configPanel.add(trayIconField, "2, 20, 11, 1, fill, default");
250
JButton btnChooseIcon = new JButton("Choose file");
251
btnChooseIcon.addActionListener(new ActionListener() {
253
public void actionPerformed(ActionEvent e) {
254
JFileChooser fileChooser = new JFileChooser();
255
int returnVal = fileChooser.showOpenDialog(GuiConfigDialog.this);
256
if (returnVal == JFileChooser.APPROVE_OPTION) {
257
File file = fileChooser.getSelectedFile();
258
trayIconField.setText(file.getPath());
262
configPanel.add(btnChooseIcon, "14, 20, 3, 1, right, default");
269
private void loadConfiguration() {
270
widthSpinner.setValue(InfologClientProperties.width);
271
heightSpinner.setValue(InfologClientProperties.height);
272
spacingSpinner.setValue(InfologClientProperties.spacing);
273
dragDelaySpinner.setValue(InfologClientProperties.dragDelay);
274
doubleClickDelaySpinner.setValue(InfologClientProperties.doubleClickDelay);
275
trayIconField.setText(InfologClientProperties.trayIcon);
278
private void saveConfiguration() {
282
Properties properties = Properties.getInstance();
283
properties.setProperty("width", widthSpinner.getValue().toString());
284
properties.setProperty("spacing", spacingSpinner.getValue().toString());
285
properties.setProperty("height", heightSpinner.getValue().toString());
287
properties.setProperty("notetopcolor", btnTopColorNotes.getPropertiesValue());
288
properties.setProperty("notebottomcolor", btnBottomColorNotes.getPropertiesValue());
290
properties.setProperty("tasktopcolor", btnTopColorTasks.getPropertiesValue());
291
properties.setProperty("taskbottomcolor", btnBottomColorTasks.getPropertiesValue());
293
properties.setProperty("phonetopcolor", btnTopColorPhoneCalls.getPropertiesValue());
294
properties.setProperty("phonebottomcolor", btnBottomColorPhoneCalls.getPropertiesValue());
296
properties.setProperty("dragdelay", dragDelaySpinner.getValue().toString());
297
properties.setProperty("doubleclickdelay", doubleClickDelaySpinner.getValue().toString());
299
properties.setProperty("systrayicon", trayIconField.getText());
302
applyConfiguration();
308
private void applyConfiguration() {
309
InfologClientProperties.width = (Integer) widthSpinner.getValue();
310
InfologClientProperties.spacing = (Integer) spacingSpinner.getValue();
311
InfologClientProperties.height = (Integer) heightSpinner.getValue();
313
InfologClientProperties.noteTopColor = btnTopColorNotes.getColorValue();
314
InfologClientProperties.noteBottomColor = btnBottomColorNotes.getColorValue();
316
InfologClientProperties.taskTopColor = btnTopColorTasks.getColorValue();
317
InfologClientProperties.taskBottomColor = btnBottomColorTasks.getColorValue();
319
InfologClientProperties.phoneTopColor = btnTopColorPhoneCalls.getColorValue();
320
InfologClientProperties.phoneBottomColor = btnBottomColorPhoneCalls.getColorValue();
322
InfologClientProperties.dragDelay = (Integer) dragDelaySpinner.getValue();
323
InfologClientProperties.doubleClickDelay = (Integer) doubleClickDelaySpinner.getValue();
325
InfologClientProperties.trayIcon = trayIconField.getText();
327
StickyNoteIcon.colorsRefreshed();
330
private void setDefaults() {
331
widthSpinner.setValue(InfologClientProperties.DEFAULT_WIDTH);
332
spacingSpinner.setValue(InfologClientProperties.DEFAULT_SPACING);
333
heightSpinner.setValue(InfologClientProperties.DEFAULT_HEIGHT);
334
btnTopColorNotes.setColor(InfologClientProperties.DEFAULT_NOTE_TOP_COLOR);
335
btnBottomColorNotes.setColor(InfologClientProperties.DEFAULT_NOTE_BOTTOM_COLOR);
336
btnTopColorTasks.setColor(InfologClientProperties.DEFAULT_TASK_TOP_COLOR);
337
btnBottomColorTasks.setColor(InfologClientProperties.DEFAULT_TASK_BOTTOM_COLOR);
338
btnTopColorPhoneCalls.setColor(InfologClientProperties.DEFAULT_PHONE_TOP_COLOR);
339
btnBottomColorPhoneCalls.setColor(InfologClientProperties.DEFAULT_PHONE_BOTTOM_COLOR);
340
dragDelaySpinner.setValue(InfologClientProperties.DEFAULT_DRAG_DELAY);
341
doubleClickDelaySpinner.setValue(InfologClientProperties.DEFAULT_DOUBLE_CLICK_DELAY);
342
trayIconField.setText(InfologClientProperties.DEFAULT_TRAY_ICON);
345
private void setFocus(final JComponent component) {
346
SwingUtilities.invokeLater(new Runnable() {
349
component.requestFocusInWindow();
51
private static final String TITLE = "Configure look and feel";
52
private static final String WIDTH_TOOLTIP = "Width of a sticky note in px.";
53
private static final String HEIGHT_TOOLTIP = "Height of a sticky note in px.";
54
private static final String SYSTRAY_TOOLTIP = "Path to icon used in system tray (requires restart).";
55
private static final String SPACING_TOOLTIP = "Offset in px. between sticky notes when layed out on the screen.";
56
private static final String NOTE_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'note'.";
57
private static final String NOTE_TOP_TOOLTIP = "Top color used for sticky notes of type 'note'.";
58
private static final String PHONE_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'phone call'.";
59
private static final String PHONE_TOP_TOOLTIP = "Top color used for sticky notes of type 'phone call'.";
60
private static final String TASK_BOTTOM_TOOLTIP = "Bottom color used for sticky notes of type 'task'.";
61
private static final String TASK_TOP_TOOLTIP = "Top color used for sticky notes of type 'task'.";
62
private static final String DRAG_DELAY_TOOLTIP = "Threshold value to tweak the drag behaviour, higher values will delay the repaint events making it easier for slow graphic cards to keep up.";
63
private static final String DOUBLE_CLICK_DELAY_TOOLTIP = "Delay in ms between two clicks to register as a double click.";
65
private JSpinner widthSpinner;
66
private JSpinner spacingSpinner;
67
private JSpinner heightSpinner;
68
private ColorButton btnTopColorNotes;
69
private ColorButton btnTopColorTasks;
70
private ColorButton btnTopColorPhoneCalls;
71
private ColorButton btnBottomColorNotes;
72
private ColorButton btnBottomColorTasks;
73
private ColorButton btnBottomColorPhoneCalls;
74
private JSpinner dragDelaySpinner;
75
private JSpinner doubleClickDelaySpinner;
76
private JTextField trayIconField;
78
public GuiConfigDialog(JFrame parent) {
79
super(parent, TITLE, true);
80
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
83
JPanel actionPanel = new JPanel();
84
getContentPane().add(actionPanel, BorderLayout.SOUTH);
85
actionPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"),
86
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
87
FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
88
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
89
ColumnSpec.decode("max(40dlu;default)"), FormFactory.RELATED_GAP_COLSPEC,
90
ColumnSpec.decode("max(5dlu;default)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC,
91
FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(5dlu;default)"), }));
93
JButton btnCancel = new JButton("Cancel");
94
btnCancel.addActionListener(new ActionListener() {
96
public void actionPerformed(ActionEvent e) {
100
actionPanel.add(btnCancel, "7, 1, 2, 1");
102
JButton btnDefaults = new JButton("Load defaults");
103
btnDefaults.addActionListener(new ActionListener() {
105
public void actionPerformed(ActionEvent e) {
109
actionPanel.add(btnDefaults, "3, 1");
111
JButton btnOk = new JButton("OK");
112
btnOk.addActionListener(new ActionListener() {
114
public void actionPerformed(ActionEvent e) {
119
actionPanel.add(btnOk, "11, 1, 2, 1");
121
JPanel configPanel = new JPanel();
122
getContentPane().add(configPanel, BorderLayout.CENTER);
123
configPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("max(61dlu;min):grow"),
124
ColumnSpec.decode("max(40dlu;default):grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("99px:grow"),
125
FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(30dlu;default)"), FormFactory.RELATED_GAP_COLSPEC,
126
FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
127
FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
128
ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(30dlu;default)"),
129
FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(30dlu;default)"), }, new RowSpec[] {
130
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
131
FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
132
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
133
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
134
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
135
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
136
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
137
FormFactory.DEFAULT_ROWSPEC, }));
139
StringSeparator dimensionsSeparator = new StringSeparator("Dimensions");
140
configPanel.add(dimensionsSeparator, "1, 2, 18, 1");
142
JLabel lblWidth = new JLabel("Width");
143
configPanel.add(lblWidth, "4, 4, right, center");
145
widthSpinner = new JSpinner();
146
widthSpinner.setToolTipText(WIDTH_TOOLTIP);
147
configPanel.add(widthSpinner, "6, 4");
149
JLabel lblPx_1 = new JLabel("px");
150
configPanel.add(lblPx_1, "8, 4");
152
JLabel lblHeight = new JLabel("Height");
153
configPanel.add(lblHeight, "12, 4, 3, 1, right, center");
155
heightSpinner = new JSpinner();
156
heightSpinner.setToolTipText(HEIGHT_TOOLTIP);
157
configPanel.add(heightSpinner, "16, 4");
159
JLabel lblPx = new JLabel("px");
160
configPanel.add(lblPx, "18, 4");
162
JLabel lblSpacing = new JLabel("Spacing:");
163
configPanel.add(lblSpacing, "4, 5, right, center");
165
spacingSpinner = new JSpinner();
166
spacingSpinner.setToolTipText(SPACING_TOOLTIP);
167
configPanel.add(spacingSpinner, "6, 5");
169
JLabel lblPx_2 = new JLabel("px");
170
configPanel.add(lblPx_2, "8, 5");
172
StringSeparator colorsSeparator = new StringSeparator("Colors");
173
configPanel.add(colorsSeparator, "1, 6, 18, 1");
175
JLabel lblNotes = new JLabel("Notes");
176
configPanel.add(lblNotes, "2, 8, right, default");
178
JLabel lblTop = new JLabel("Top:");
179
configPanel.add(lblTop, "4, 8, right, center");
181
btnTopColorNotes = new ColorButton(InfologClientProperties.noteTopColor);
182
btnTopColorNotes.setToolTipText(NOTE_TOP_TOOLTIP);
183
configPanel.add(btnTopColorNotes, "6, 8, fill, fill");
185
JLabel lblBottom = new JLabel("Bottom:");
186
configPanel.add(lblBottom, "12, 8, 3, 1, right, center");
188
btnBottomColorNotes = new ColorButton(InfologClientProperties.noteBottomColor);
189
btnBottomColorNotes.setToolTipText(NOTE_BOTTOM_TOOLTIP);
190
configPanel.add(btnBottomColorNotes, "16, 8, fill, fill");
192
JLabel lblTasks = new JLabel("Tasks");
193
configPanel.add(lblTasks, "2, 10, right, default");
195
JLabel lblTop_1 = new JLabel("Top:");
196
configPanel.add(lblTop_1, "4, 10, right, center");
198
btnTopColorTasks = new ColorButton(InfologClientProperties.taskTopColor);
199
btnTopColorTasks.setToolTipText(TASK_TOP_TOOLTIP);
200
configPanel.add(btnTopColorTasks, "6, 10, fill, fill");
202
JLabel lblBottom_1 = new JLabel("Bottom:");
203
configPanel.add(lblBottom_1, "12, 10, 3, 1, right, center");
205
btnBottomColorTasks = new ColorButton(InfologClientProperties.taskBottomColor);
206
btnBottomColorTasks.setToolTipText(TASK_BOTTOM_TOOLTIP);
207
configPanel.add(btnBottomColorTasks, "16, 10, fill, fill");
209
JLabel lblPhoneCalls = new JLabel("Phone Calls");
210
configPanel.add(lblPhoneCalls, "2, 12, right, default");
212
JLabel lblTop_2 = new JLabel("Top:");
213
configPanel.add(lblTop_2, "4, 12, right, center");
215
btnTopColorPhoneCalls = new ColorButton(InfologClientProperties.phoneTopColor);
216
btnTopColorPhoneCalls.setToolTipText(PHONE_TOP_TOOLTIP);
217
configPanel.add(btnTopColorPhoneCalls, "6, 12, fill, fill");
219
JLabel lblBottom_2 = new JLabel("Bottom:");
220
configPanel.add(lblBottom_2, "12, 12, 3, 1, right, center");
222
btnBottomColorPhoneCalls = new ColorButton(InfologClientProperties.phoneBottomColor);
223
btnBottomColorPhoneCalls.setToolTipText(PHONE_BOTTOM_TOOLTIP);
224
configPanel.add(btnBottomColorPhoneCalls, "16, 12, fill, fill");
226
StringSeparator behaviourSeparator = new StringSeparator("Mouse behaviour");
227
configPanel.add(behaviourSeparator, "1, 14, 18, 1, fill, default");
229
JLabel lblDragDelay = new JLabel("Drag delay: ");
230
configPanel.add(lblDragDelay, "4, 16, right, center");
232
dragDelaySpinner = new JSpinner();
233
dragDelaySpinner.setToolTipText(DRAG_DELAY_TOOLTIP);
234
configPanel.add(dragDelaySpinner, "6, 16");
236
JLabel lblDoubleClickDelay = new JLabel("Double click delay:");
237
configPanel.add(lblDoubleClickDelay, "10, 16, 5, 1, right, center");
239
doubleClickDelaySpinner = new JSpinner();
240
doubleClickDelaySpinner.setToolTipText(DOUBLE_CLICK_DELAY_TOOLTIP);
241
configPanel.add(doubleClickDelaySpinner, "16, 16");
243
StringSeparator iconSeparator = new StringSeparator("System tray icon");
244
configPanel.add(iconSeparator, "1, 18, 18, 1");
246
trayIconField = new JTextField();
247
trayIconField.setToolTipText(SYSTRAY_TOOLTIP);
248
configPanel.add(trayIconField, "2, 20, 11, 1, fill, default");
250
JButton btnChooseIcon = new JButton("Choose file");
251
btnChooseIcon.addActionListener(new ActionListener() {
253
public void actionPerformed(ActionEvent e) {
254
JFileChooser fileChooser = new JFileChooser();
255
int returnVal = fileChooser.showOpenDialog(GuiConfigDialog.this);
256
if (returnVal == JFileChooser.APPROVE_OPTION) {
257
File file = fileChooser.getSelectedFile();
258
trayIconField.setText(file.getPath());
262
configPanel.add(btnChooseIcon, "14, 20, 3, 1, right, default");
269
private void loadConfiguration() {
270
widthSpinner.setValue(InfologClientProperties.width);
271
heightSpinner.setValue(InfologClientProperties.height);
272
spacingSpinner.setValue(InfologClientProperties.spacing);
273
dragDelaySpinner.setValue(InfologClientProperties.dragDelay);
274
doubleClickDelaySpinner.setValue(InfologClientProperties.doubleClickDelay);
275
trayIconField.setText(InfologClientProperties.trayIcon);
278
private void saveConfiguration() {
282
Properties properties = Properties.getInstance();
283
properties.setProperty("width", widthSpinner.getValue().toString());
284
properties.setProperty("spacing", spacingSpinner.getValue().toString());
285
properties.setProperty("height", heightSpinner.getValue().toString());
287
properties.setProperty("notetopcolor", btnTopColorNotes.getPropertiesValue());
288
properties.setProperty("notebottomcolor", btnBottomColorNotes.getPropertiesValue());
290
properties.setProperty("tasktopcolor", btnTopColorTasks.getPropertiesValue());
291
properties.setProperty("taskbottomcolor", btnBottomColorTasks.getPropertiesValue());
293
properties.setProperty("phonetopcolor", btnTopColorPhoneCalls.getPropertiesValue());
294
properties.setProperty("phonebottomcolor", btnBottomColorPhoneCalls.getPropertiesValue());
296
properties.setProperty("dragdelay", dragDelaySpinner.getValue().toString());
297
properties.setProperty("doubleclickdelay", doubleClickDelaySpinner.getValue().toString());
299
properties.setProperty("systrayicon", trayIconField.getText());
302
applyConfiguration();
308
private void applyConfiguration() {
309
InfologClientProperties.width = (Integer) widthSpinner.getValue();
310
InfologClientProperties.spacing = (Integer) spacingSpinner.getValue();
311
InfologClientProperties.height = (Integer) heightSpinner.getValue();
313
InfologClientProperties.noteTopColor = btnTopColorNotes.getColorValue();
314
InfologClientProperties.noteBottomColor = btnBottomColorNotes.getColorValue();
316
InfologClientProperties.taskTopColor = btnTopColorTasks.getColorValue();
317
InfologClientProperties.taskBottomColor = btnBottomColorTasks.getColorValue();
319
InfologClientProperties.phoneTopColor = btnTopColorPhoneCalls.getColorValue();
320
InfologClientProperties.phoneBottomColor = btnBottomColorPhoneCalls.getColorValue();
322
InfologClientProperties.dragDelay = (Integer) dragDelaySpinner.getValue();
323
InfologClientProperties.doubleClickDelay = (Integer) doubleClickDelaySpinner.getValue();
325
InfologClientProperties.trayIcon = trayIconField.getText();
327
StickyNoteIcon.colorsRefreshed();
330
private void setDefaults() {
331
widthSpinner.setValue(InfologClientProperties.DEFAULT_WIDTH);
332
spacingSpinner.setValue(InfologClientProperties.DEFAULT_SPACING);
333
heightSpinner.setValue(InfologClientProperties.DEFAULT_HEIGHT);
334
btnTopColorNotes.setColor(InfologClientProperties.DEFAULT_NOTE_TOP_COLOR);
335
btnBottomColorNotes.setColor(InfologClientProperties.DEFAULT_NOTE_BOTTOM_COLOR);
336
btnTopColorTasks.setColor(InfologClientProperties.DEFAULT_TASK_TOP_COLOR);
337
btnBottomColorTasks.setColor(InfologClientProperties.DEFAULT_TASK_BOTTOM_COLOR);
338
btnTopColorPhoneCalls.setColor(InfologClientProperties.DEFAULT_PHONE_TOP_COLOR);
339
btnBottomColorPhoneCalls.setColor(InfologClientProperties.DEFAULT_PHONE_BOTTOM_COLOR);
340
dragDelaySpinner.setValue(InfologClientProperties.DEFAULT_DRAG_DELAY);
341
doubleClickDelaySpinner.setValue(InfologClientProperties.DEFAULT_DOUBLE_CLICK_DELAY);
342
trayIconField.setText(InfologClientProperties.DEFAULT_TRAY_ICON);
345
private void setFocus(final JComponent component) {
346
SwingUtilities.invokeLater(new Runnable() {
349
component.requestFocusInWindow();