1 | /* |
2 | Copyright - 2017 2023 - wwwouaiebe - Contact: https://www.ouaie.be/ |
3 | |
4 | This program is free software; |
5 | you can redistribute it and/or modify it under the terms of the |
6 | GNU General Public License as published by the Free Software Foundation; |
7 | either version 3 of the License, or any later version. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | /* |
19 | Changes: |
20 | - v4.0.0: |
21 | - created from v3.6.0 |
22 | Doc reviewed 202208 |
23 | */ |
24 | |
25 | import OsmSearchDialog from '../dialogs/osmSearchDialog/OsmSearchDialog.js'; |
26 | import TravelPropertiesDialog from '../dialogs/travelPropertiesDialog/TravelPropertiesDialog.js'; |
27 | import TravelNotesDialog from '../dialogs/travelNotesDialog/TravelNotesDialog.js'; |
28 | import theConfig from '../data/Config.js'; |
29 | |
30 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
31 | /** |
32 | This class manages the dockable dialogs. |
33 | We cannot create the dockable dialogs as global objects because it's needed that the translations are loaded before |
34 | creating the dialogs. |
35 | */ |
36 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
37 | |
38 | class DockableDialogsManager { |
39 | |
40 | /** |
41 | The one and only one instance of OsmSearchDialog |
42 | @type {OsmSearchDialog} |
43 | */ |
44 | |
45 | #osmSearchDialog = null; |
46 | |
47 | /** |
48 | The one and only one instance of TravelPropertiesDialog |
49 | @type {TravelPropertiesDialog} |
50 | */ |
51 | |
52 | #travelPropertiesDialog = null; |
53 | |
54 | /** |
55 | The one and only one instance of TravelNotesDialog |
56 | @type {TravelPropertiesDialog} |
57 | */ |
58 | |
59 | #travelNotesDialog = null; |
60 | |
61 | /** |
62 | The constructor |
63 | */ |
64 | |
65 | constructor ( ) { |
66 | Object.freeze ( this ); |
67 | } |
68 | |
69 | /** |
70 | The one and only one instance of OsmSearchDialog |
71 | @type {OsmSearchDialog} |
72 | */ |
73 | |
74 | get osmSearchDialog ( ) { |
75 | if ( ! this.#osmSearchDialog ) { |
76 | this.#osmSearchDialog = new OsmSearchDialog ( |
77 | theConfig.osmSearchDialog.dialogX, |
78 | theConfig.osmSearchDialog.dialogY |
79 | ); |
80 | } |
81 | return this.#osmSearchDialog; |
82 | } |
83 | |
84 | /** |
85 | The one and only one instance of TravelPropertiesDialog |
86 | @type {TravelPropertiesDialog} |
87 | */ |
88 | |
89 | get travelPropertiesDialog ( ) { |
90 | if ( ! this.#travelPropertiesDialog ) { |
91 | this.#travelPropertiesDialog = new TravelPropertiesDialog ( |
92 | theConfig.travelPropertiesDialog.dialogX, |
93 | theConfig.travelPropertiesDialog.dialogY |
94 | ); |
95 | } |
96 | return this.#travelPropertiesDialog; |
97 | } |
98 | |
99 | /** |
100 | The one and only one instance of TravelPropertiesDialog |
101 | @type {TravelPropertiesDialog} |
102 | */ |
103 | |
104 | get travelNotesDialog ( ) { |
105 | if ( ! this.#travelNotesDialog ) { |
106 | this.#travelNotesDialog = new TravelNotesDialog ( |
107 | theConfig.travelNotesDialog.dialogX, |
108 | theConfig.travelNotesDialog.dialogY |
109 | ); |
110 | } |
111 | return this.#travelNotesDialog; |
112 | } |
113 | |
114 | /** |
115 | Show the travel properties dialog visible and centered on the screen |
116 | */ |
117 | |
118 | showTravelProperties ( ) { |
119 | this.travelPropertiesDialog.show ( ); |
120 | this.travelPropertiesDialog.mover.centerDialog ( ); |
121 | } |
122 | |
123 | } |
124 | |
125 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
126 | /** |
127 | The one and only one instance of DockableDialogsManager class |
128 | @type {DockableDialogsManager} |
129 | */ |
130 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
131 | |
132 | const theDockableDialogsManager = new DockableDialogsManager ( ); |
133 | |
134 | export default theDockableDialogsManager; |
135 | |
136 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
137 |