-
Notifications
You must be signed in to change notification settings - Fork 848
Expand file tree
/
Copy pathregister_browser_preferences.py
More file actions
532 lines (489 loc) · 16.9 KB
/
register_browser_preferences.py
File metadata and controls
532 lines (489 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2026, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import sys
from flask_babel import gettext
from pgadmin.utils.constants import PREF_LABEL_DISPLAY,\
PREF_LABEL_KEYBOARD_SHORTCUTS, PREF_LABEL_TABS_SETTINGS, \
PREF_LABEL_OPTIONS, QT_DEFAULT_PLACEHOLDER, VW_EDT_DEFAULT_PLACEHOLDER, \
PREF_LABEL_BREADCRUMBS
from flask import current_app
import config
def register_browser_preferences(self):
self.show_system_objects = self.preference.register(
'display', 'show_system_objects',
gettext("Show system objects?"), 'boolean', False,
category_label=PREF_LABEL_DISPLAY
)
self.show_empty_coll_nodes = self.preference.register(
'display', 'show_empty_coll_nodes',
gettext("Show empty object collections?"), 'boolean', True,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'If turned off, then all object collections which are empty '
'will be hidden from browser tree.'
)
)
self.show_column_datatype = self.preference.register(
'display', 'show_column_datatype',
gettext("Show column data type?"), 'boolean', True,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'If turned off, then the data types of the columns '
'will not be displayed alongside their column names.'
)
)
self.show_user_defined_templates = self.preference.register(
'display', 'show_user_defined_templates',
gettext("Show template databases?"), 'boolean', False,
category_label=PREF_LABEL_DISPLAY
)
if config.SERVER_MODE:
self.hide_shared_server = self.preference.register(
'display', 'hide_shared_server',
gettext("Hide shared servers?"), 'boolean', False,
category_label=gettext('Display'),
help_str=gettext(
'If set to True, all shared servers will be '
'hidden from the browser tree.'
)
)
self.preference.register(
'display', 'browser_tree_state_save_interval',
gettext("Object explorer tree state saving interval"), 'integer',
30, category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Object explorer state saving interval in seconds. '
'Use -1 to disable the tree saving mechanism.'
)
)
self.preference.register(
'display', 'confirm_on_refresh_close',
gettext("Confirm on close or refresh?"), 'boolean',
True, category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Confirm that closure or refresh of the browser or browser tab '
'is intended before proceeding.'
)
)
self.preference.register(
'display', 'confirm_on_properties_close',
gettext("Confirm before Close/Reset in object properties dialog?"),
'boolean',
True, category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Confirm before closing or resetting the changes in the '
'properties dialog for an object if the changes are not saved.'
)
)
self.preference.register(
'display', 'auto_expand_sole_children',
gettext("Auto-expand sole children"), 'boolean', True,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'If a treeview node is expanded and has only a single '
'child, automatically expand the child node as well.'
)
)
self.preference.register(
'display', 'show_server_color_indicator',
gettext("Show server color indicator in panel tabs?"), 'boolean',
False,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'If enabled, a colored circle indicator will be shown in panel '
'tabs (Query Tool, ERD Tool, etc.) matching the server\'s custom '
'background color.'
)
)
self.table_row_count_threshold = self.preference.register(
'properties', 'table_row_count_threshold',
gettext("Count rows if estimated less than"), 'integer', 2000,
category_label=gettext('Properties')
)
self.pg_agent_row_threshold = self.preference.register(
'properties', 'pgagent_row_threshold',
gettext("Maximum job history rows"), 'integer', 250,
category_label=gettext('Properties'),
min_val=1, max_val=9999,
help_str=gettext(
'The maximum number of history rows to show on '
'the Statistics tab for pgAgent jobs.'
)
)
self.table_row_count_threshold = self.preference.register(
'processes', 'process_retain_days',
gettext("Process details/logs retention days"), 'integer', 5,
min_val=1,
category_label=gettext('Processes'),
help_str=gettext(
'After this many days, the process info and logs '
'will be automatically cleared.'
)
)
fields = [
{'name': 'key', 'type': 'keyCode', 'label': gettext('Key')},
{'name': 'shift', 'type': 'checkbox', 'label': gettext('Shift')},
{'name': 'control', 'type': 'checkbox', 'label': gettext('Ctrl')},
{'name': 'alt', 'type': 'checkbox', 'label': gettext('Alt/Option')}
]
self.preference.register(
'keyboard_shortcuts',
'browser_tree',
gettext('Object Explorer'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 66, 'char': 'b'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'tabbed_panel_backward',
gettext('Tabbed panel backward'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 91, 'char': '['}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'close_tab_panel',
gettext('Close tab panel'),
'keyboardshortcut',
{
'alt': False,
'shift': True,
'control': True,
'key': {'key_code': 87, 'char': 'w'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'tabbed_panel_forward',
gettext('Tabbed panel forward'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 93, 'char': ']'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
if not current_app.PGADMIN_RUNTIME:
self.preference.register(
'keyboard_shortcuts',
'main_menu_file',
gettext('File main menu'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 70, 'char': 'f'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'main_menu_object',
gettext('Object main menu'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 79, 'char': 'o'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'main_menu_tools',
gettext('Tools main menu'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 76, 'char': 'l'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'main_menu_help',
gettext('Help main menu'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 72, 'char': 'h'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_query_tool',
gettext('Open query tool'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 81, 'char': 'q'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_view_data',
gettext('View data'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 86, 'char': 'v'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_search_objects',
gettext('Search objects'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 83, 'char': 's'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_create',
gettext('Create object'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 78, 'char': 'n'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_properties',
gettext('Edit object properties'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 69, 'char': 'e'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_delete',
gettext('Drop object'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 68, 'char': 'd'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'direct_debugging',
gettext('Direct debugging'),
'keyboardshortcut',
{
'alt': True,
'shift': True,
'control': False,
'key': {'key_code': 71, 'char': 'g'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'sub_menu_refresh',
gettext('Refresh object explorer'),
'keyboardshortcut',
{
'alt': False,
'shift': False,
'control': False,
'key': {'key_code': 116, 'char': 'F5'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts',
'add_grid_row',
gettext('Add grid row'),
'keyboardshortcut',
{
'alt': False,
'shift': True,
'control': True,
'key': {'key_code': 65, 'char': 'a'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.preference.register(
'keyboard_shortcuts', 'open_quick_search',
gettext('Quick Search'), 'keyboardshortcut',
{
'alt': False,
'shift': True,
'control': True,
'key': {'key_code': 70, 'char': 'f'}
},
category_label=PREF_LABEL_KEYBOARD_SHORTCUTS,
fields=fields
)
self.dynamic_tab_title = self.preference.register(
'tab_settings', 'dynamic_tabs',
gettext("Dynamic tab size"), 'boolean', False,
category_label=PREF_LABEL_TABS_SETTINGS,
help_str=gettext(
'If set to True, the tabs will take full size as per the title. '
'This will also apply to already opened tabs.')
)
self.qt_tab_title = self.preference.register(
'tab_settings', 'qt_tab_title_placeholder',
gettext("Query tool tab title"),
'text', QT_DEFAULT_PLACEHOLDER,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Supported placeholders are %DATABASE%, %USERNAME%, and %SERVER%. '
'Users can provide any string with or without placeholders of'
' their choice. A blank title will revert to the default.'
)
)
self.ve_edt_tab_title = self.preference.register(
'tab_settings', 'vw_edt_tab_title_placeholder',
gettext("View/Edit data tab title"),
'text', VW_EDT_DEFAULT_PLACEHOLDER,
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Supported placeholders are %SCHEMA%, %TABLE%, %DATABASE%, '
'%USERNAME%, and %SERVER%. Users can provide any string with or '
'without placeholders of their choice. A blank title will revert '
'to the default.'
)
)
self.debugger_tab_title = self.preference.register(
'tab_settings', 'debugger_tab_title_placeholder',
gettext("Debugger tab title"),
'text', '%FUNCTION%(%ARGS%)',
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Supported placeholders are %FUNCTION%, %ARGS%, %SCHEMA%, and'
' %DATABASE%. Users can provide any string with or '
'without placeholders of their choice. A blank title will revert '
'to the default.'
)
)
open_new_tab_options = [
{'label': gettext('Query Tool'), 'value': 'qt'},
{'label': gettext('Debugger'), 'value': 'debugger'},
{'label': gettext('Schema Diff'), 'value': 'schema_diff'},
{'label': gettext('ERD Tool'), 'value': 'erd_tool'}]
# Allow psq tool to open in new browser tab if ENABLE_PSQL is set to True
if config.ENABLE_PSQL:
open_new_tab_options.append(
{'label': gettext('PSQL Tool'), 'value': 'psql_tool'})
self.open_in_new_tab = self.preference.register(
'tab_settings', 'new_browser_tab_open',
gettext("Open in new browser tab"), 'select', None,
category_label=PREF_LABEL_OPTIONS,
options=open_new_tab_options,
help_str=gettext(
'Select Query Tool, Debugger, Schema Diff, ERD Tool, '
'or PSQL Tool from the drop-down to open that module '
'in a new browser tab.'
),
control_props={
'multiple': True, 'allowClear': False,
'tags': True, 'first_empty': False,
'selectOnClose': False, 'emptyOptions': True,
'tokenSeparators': [','],
'placeholder': gettext('Select open new tab...')
}
)
# Set PSQL tool tab title if ENABLE_PSQL is set to True
if config.ENABLE_PSQL:
self.psql_tab_title = self.preference.register(
'tab_settings', 'psql_tab_title_placeholder',
gettext("PSQL tool tab title"),
'text', '%DATABASE%/%USERNAME%@%SERVER%',
category_label=PREF_LABEL_DISPLAY,
help_str=gettext(
'Supported placeholders are %DATABASE%, %USERNAME%, '
'and %SERVER%. Users can provide any string with or without'
' placeholders of their choice. A blank title will revert '
'to the default.'
)
)
self.preference.register(
'breadcrumbs', 'breadcrumbs_enable',
gettext("Enable object breadcrumbs?"),
'boolean',
True, category_label=PREF_LABEL_BREADCRUMBS,
help_str=gettext(
'Enable breadcrumbs to show the complete path of an object in the '
'object explorer. The breadcrumbs are displayed on object mouse '
'hover.'
)
)
self.preference.register(
'breadcrumbs', 'breadcrumbs_show_comment',
gettext("Show comment with object breadcrumbs?"),
'boolean',
True, category_label=PREF_LABEL_BREADCRUMBS,
help_str=gettext(
'Show object comment along with breadcrumbs.'
)
)