Repository: arthurdeka/cedro-modern-dock Branch: main Commit: ccc216cf26f0 Files: 91 Total size: 335.3 KB Directory structure: gitextract_8_0nq8pf/ ├── .gitattributes ├── .github/ │ └── FUNDING.yml ├── .gitignore ├── .mvn/ │ └── wrapper/ │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src/ ├── main/ │ ├── java/ │ │ ├── com/ │ │ │ └── github/ │ │ │ └── arthurdeka/ │ │ │ └── cedromoderndock/ │ │ │ ├── App.java │ │ │ ├── application/ │ │ │ │ ├── AppServices.java │ │ │ │ ├── DockAppearanceService.java │ │ │ │ ├── DockItemActionService.java │ │ │ │ ├── DockPositioningService.java │ │ │ │ ├── DockService.java │ │ │ │ ├── DockTheme.java │ │ │ │ ├── LocalizationService.java │ │ │ │ ├── ProgramSelectionResolver.java │ │ │ │ ├── SupportedLanguage.java │ │ │ │ └── WindowPreviewService.java │ │ │ ├── controller/ │ │ │ │ ├── AcknowledgementsModalController.java │ │ │ │ ├── AddWindowsModulesModalController.java │ │ │ │ ├── DockController.java │ │ │ │ └── SettingsController.java │ │ │ ├── domain/ │ │ │ │ ├── DockRepository.java │ │ │ │ ├── FolderLauncher.java │ │ │ │ ├── IconGateway.java │ │ │ │ ├── ProgramLauncher.java │ │ │ │ ├── WindowQueryGateway.java │ │ │ │ └── WindowsModuleLauncher.java │ │ │ ├── infrastructure/ │ │ │ │ ├── persistence/ │ │ │ │ │ └── JsonDockRepository.java │ │ │ │ └── system/ │ │ │ │ ├── CachedWindowsIconGateway.java │ │ │ │ ├── DefaultFolderLauncher.java │ │ │ │ ├── DefaultProgramLauncher.java │ │ │ │ ├── DefaultWindowsModuleLauncher.java │ │ │ │ └── JnaWindowQueryGateway.java │ │ │ ├── model/ │ │ │ │ ├── DockFolderItemModel.java │ │ │ │ ├── DockHorizontalAnchor.java │ │ │ │ ├── DockItem.java │ │ │ │ ├── DockItemType.java │ │ │ │ ├── DockModel.java │ │ │ │ ├── DockPositioningMode.java │ │ │ │ ├── DockProgramItemModel.java │ │ │ │ ├── DockSettingsItemModel.java │ │ │ │ ├── DockVerticalAnchor.java │ │ │ │ └── DockWindowsModuleItemModel.java │ │ │ ├── util/ │ │ │ │ ├── ColorManipulation.java │ │ │ │ ├── Logger.java │ │ │ │ ├── NativeWindowUtils.java │ │ │ │ ├── SaveAndLoadDockSettings.java │ │ │ │ ├── SettingsWindowLauncher.java │ │ │ │ ├── SingleInstanceGuard.java │ │ │ │ ├── SystemTrayManager.java │ │ │ │ ├── UIUtils.java │ │ │ │ └── WindowsIconHandler.java │ │ │ └── view/ │ │ │ └── WindowPreviewPopup.java │ │ └── module-info.java │ └── resources/ │ └── com/ │ └── github/ │ └── arthurdeka/ │ └── cedromoderndock/ │ ├── css/ │ │ ├── dock.css │ │ └── dockSettings.css │ ├── fxml/ │ │ ├── AcknowledgementsModalView.fxml │ │ ├── AddWindowsModulesModalView.fxml │ │ ├── DockSettingsView.fxml │ │ └── DockView.fxml │ └── i18n/ │ ├── messages_ar_SA.properties │ ├── messages_bn_BD.properties │ ├── messages_de_DE.properties │ ├── messages_en_US.properties │ ├── messages_es_ES.properties │ ├── messages_fr_FR.properties │ ├── messages_hi_IN.properties │ ├── messages_id_ID.properties │ ├── messages_ja_JP.properties │ ├── messages_mr_IN.properties │ ├── messages_pcm_NG.properties │ ├── messages_pt_BR.properties │ ├── messages_ru_RU.properties │ ├── messages_ta_IN.properties │ ├── messages_te_IN.properties │ ├── messages_tr_TR.properties │ ├── messages_ur_PK.properties │ ├── messages_vi_VN.properties │ ├── messages_yue_HK.properties │ ├── messages_zh_CN.properties │ └── messages_zh_TW.properties └── test/ └── java/ └── com/ └── github/ └── arthurdeka/ └── cedromoderndock/ ├── application/ │ ├── DockItemActionServiceTest.java │ ├── DockServiceTest.java │ ├── LocalizationServiceTest.java │ └── ProgramSelectionResolverTest.java ├── infrastructure/ │ ├── persistence/ │ │ └── JsonDockRepositoryTest.java │ └── system/ │ └── DefaultProgramLauncherTest.java └── util/ └── SingleInstanceGuardTest.java ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [arthurdeka] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: arthurcodes tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: #['https://customlink.com/donate'] ================================================ FILE: .gitignore ================================================ config.json log.txt .superpowers target target/ # Build output and packages /target/ *.jar *.war *.ear # Logs *.log # IDE files .idea/ .project .classpath .settings/ *.iml *.iws # Operating system files .DS_Store Thumbs.db # Maven generated files .mvn/timing.properties # Package Files # *.jar *.war *.nar *.ear *.zip *.tar.gz *.rar # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* replay_pid* ================================================ FILE: .mvn/wrapper/maven-wrapper.properties ================================================ distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: README.md ================================================ ![GitHub contributors](https://img.shields.io/github/contributors/arthurdeka/cedro-modern-dock?style=for-the-badge) ![GitHub forks](https://img.shields.io/github/forks/arthurdeka/cedro-modern-dock?style=for-the-badge) ![GitHub Repo stars](https://img.shields.io/github/stars/arthurdeka/cedro-modern-dock?style=for-the-badge) ![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/arthurdeka/cedro-modern-dock?style=for-the-badge) ![GitHub License](https://img.shields.io/github/license/arthurdeka/cedro-modern-dock?style=for-the-badge) ![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/TeiuAlligator?style=for-the-badge) img1 img3 > Follow @TeiuAlligator on X to stay tuned for new features and updates! > ## How To Install > 1. Go to [Releases](https://github.com/arthurdeka/cedro-modern-dock/releases): > 2. Download the latest `CedroSetup.exe` file > 3. Execute and install
## Features - **Quick Launch Shortcuts:** Add your favorite `.exe` files to the dock for fast access. - **Folder Shortcuts:** Pin folders alongside apps and open them directly from the dock. - **Built-in Windows Modules:** Add native Windows shortcuts such as **This PC**, **Recycle Bin**, **Control Panel**, and **Settings**. - **Appearance Customization:** Adjust icon size, spacing, background color, transparency, and dock corner rounding. - **Flexible Positioning:** Choose between a static anchored layout with per-edge spacing or a dynamic draggable dock. - **Running App Indicators:** Program shortcuts show a live indicator when matching windows are currently open. - **Window Preview Popup:** Hovering a running app can show its open windows, and clicking a preview brings that window to the front. - **Desktop-Friendly Behavior:** Includes system tray integration for quick access to settings.
## Supported Languages - 🇺🇸 English - 🇧🇷 Portuguese (Brazil) - 🇪🇸 Spanish - 🇫🇷 French - 🇩🇪 German - 🇯🇵 Japanese - 🇨🇳 Chinese (Simplified) - 🇹🇼 Chinese (Traditional) - 🇮🇳 Hindi - 🇸🇦 Arabic - 🇧🇩 Bengali - 🇷🇺 Russian - 🇵🇰 Urdu - 🇮🇩 Indonesian - 🇳🇬 Nigerian Pidgin - 🇮🇳 Marathi - 🇮🇳 Telugu - 🇹🇷 Turkish - 🇮🇳 Tamil - 🇭🇰 Cantonese - 🇻🇳 Vietnamese
## Built With * ![JavaFX](https://img.shields.io/badge/javafx-%23FF0000.svg?style=for-the-badge&logo=javafx&logoColor=white)
## How To Contribute > Only for those who wish to contribute in the project's coding, none of this is required for you to do if you [just want to download it](https://github.com/arthurdeka/cedro-modern-dock/releases) ### Understand the project architecture: The project now follows a lightweight layered architecture: - `controller`: JavaFX controllers and UI event handling - `application`: dock use cases, appearance rules, item actions and preview orchestration - `domain`: ports/interfaces for persistence, icon resolution, program launch and native window queries - `infrastructure`: Jackson persistence and Windows-specific adapters - `model`: serializable dock data structures used by the application layer - `view` and `resources`: popup rendering, FXML, CSS and static assets `App.java` is responsible for composing these dependencies and injecting them into the JavaFX controllers. ### Prerequisites Before you begin, ensure you have the following installed on your system: (required only for development) - **An IDE** (IntelliJ IDEA recommended). - **JDK 21**. - **Apache Maven**. - **Git** for cloning the repository.
### How To Run Locally 1. Clone the repository 2. Before running, make sure to install all the dependencies 3. Run `App.java` to run the program 4. Make desired changes 5. Commit your changes 6. Open a pull request
### How To `COMPILE` Locally 1. Clone the repository 2. Install all dependencies 3. Run `mvn clean package` on the terminal 4. The `.exe` file will be available at `target\dist\Cedro Modern Dock`
================================================ FILE: mvnw ================================================ #!/bin/sh # ---------------------------------------------------------------------------- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- # Maven Start Up Batch script # # Required ENV vars: # ------------------ # JAVA_HOME - location of a JDK home dir # # Optional ENV vars # ----------------- # M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 # MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- if [ -z "$MAVEN_SKIP_RC" ] ; then if [ -f /usr/local/etc/mavenrc ] ; then . /usr/local/etc/mavenrc fi if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi if [ -f "$HOME/.mavenrc" ] ; then . "$HOME/.mavenrc" fi fi # OS specific support. $var _must_ be set to either true or false. cygwin=false; darwin=false; mingw=false case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then export JAVA_HOME="`/usr/libexec/java_home`" else export JAVA_HOME="/Library/Java/Home" fi fi ;; esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then JAVA_HOME=`java-config --jre-home` fi fi if [ -z "$M2_HOME" ] ; then ## resolve links - $0 may be a link to maven's home PRG="$0" # need this for relative symlinks while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG="`dirname "$PRG"`/$link" fi done saveddir=`pwd` M2_HOME=`dirname "$PRG"`/.. # make it fully qualified M2_HOME=`cd "$M2_HOME" && pwd` cd "$saveddir" # echo Using m2 at $M2_HOME fi # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then [ -n "$M2_HOME" ] && M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" fi if [ -z "$JAVA_HOME" ]; then javaExecutable="`which javac`" if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. readLink=`which readlink` if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then if $darwin ; then javaHome="`dirname \"$javaExecutable\"`" javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" else javaExecutable="`readlink -f \"$javaExecutable\"`" fi javaHome="`dirname \"$javaExecutable\"`" javaHome=`expr "$javaHome" : '\(.*\)/bin'` JAVA_HOME="$javaHome" export JAVA_HOME fi fi fi if [ -z "$JAVACMD" ] ; then if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi else JAVACMD="`\\unset -f command; \\command -v java`" fi fi if [ ! -x "$JAVACMD" ] ; then echo "Error: JAVA_HOME is not defined correctly." >&2 echo " We cannot execute $JAVACMD" >&2 exit 1 fi if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" return 1 fi basedir="$1" wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then wdir=`cd "$wdir/.."; pwd` fi # end of workaround done echo "${basedir}" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then echo "$(tr -s '\n' ' ' < "$1")" fi } BASE_DIR=`find_maven_basedir "$(pwd)"` if [ -z "$BASE_DIR" ]; then exit 1; fi ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found .mvn/wrapper/maven-wrapper.jar" fi else if [ "$MVNW_VERBOSE" = true ]; then echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi if [ -n "$MVNW_REPOURL" ]; then jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" else jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" if [ "$MVNW_VERBOSE" = true ]; then echo "Downloading from: $jarUrl" fi wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" if $cygwin; then wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` fi if command -v wget > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then curl -o "$wrapperJarPath" "$jarUrl" -f else curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f fi else if [ "$MVNW_VERBOSE" = true ]; then echo "Falling back to using Java to download" fi javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" # For Cygwin, switch paths to Windows format before running javac if $cygwin; then javaClass=`cygpath --path --windows "$javaClass"` fi if [ -e "$javaClass" ]; then if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then if [ "$MVNW_VERBOSE" = true ]; then echo " - Compiling MavenWrapperDownloader.java ..." fi # Compiling the Java class ("$JAVA_HOME/bin/javac" "$javaClass") fi if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then # Running the downloader if [ "$MVNW_VERBOSE" = true ]; then echo " - Running MavenWrapperDownloader.java ..." fi ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") fi fi fi fi ########################################################################################## # End of extension ########################################################################################## export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} if [ "$MVNW_VERBOSE" = true ]; then echo $MAVEN_PROJECTBASEDIR fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then [ -n "$M2_HOME" ] && M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$MAVEN_PROJECTBASEDIR" ] && MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ $MAVEN_OPTS \ $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" \ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" ================================================ FILE: mvnw.cmd ================================================ @REM ---------------------------------------------------------------------------- @REM Licensed to the Apache Software Foundation (ASF) under one @REM or more contributor license agreements. See the NOTICE file @REM distributed with this work for additional information @REM regarding copyright ownership. The ASF licenses this file @REM to you under the Apache License, Version 2.0 (the @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM @REM https://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @REM KIND, either express or implied. See the License for the @REM specific language governing permissions and limitations @REM under the License. @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- @REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @REM @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files @REM ---------------------------------------------------------------------------- @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off @REM set title of command window title %0 @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* :skipRcPre @setlocal set ERROR_CODE=0 @REM To isolate internal variables from possible post scripts, we use another setlocal @setlocal @REM ==== START VALIDATION ==== if not "%JAVA_HOME%" == "" goto OkJHome echo. echo Error: JAVA_HOME not found in your environment. >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 echo. goto error :OkJHome if exist "%JAVA_HOME%\bin\java.exe" goto init echo. echo Error: JAVA_HOME is set to an invalid directory. >&2 echo JAVA_HOME = "%JAVA_HOME%" >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 echo. goto error @REM ==== END VALIDATION ==== :init @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir set EXEC_DIR=%CD% set WDIR=%EXEC_DIR% :findBaseDir IF EXIST "%WDIR%"\.mvn goto baseDirFound cd .. IF "%WDIR%"=="%CD%" goto baseDirNotFound set WDIR=%CD% goto findBaseDir :baseDirFound set MAVEN_PROJECTBASEDIR=%WDIR% cd "%EXEC_DIR%" goto endDetectBaseDir :baseDirNotFound set MAVEN_PROJECTBASEDIR=%EXEC_DIR% cd "%EXEC_DIR%" :endDetectBaseDir IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig @setlocal EnableExtensions EnableDelayedExpansion for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B ) @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @REM This allows using the maven wrapper in projects that prohibit checking in binary data. if exist %WRAPPER_JAR% ( if "%MVNW_VERBOSE%" == "true" ( echo Found %WRAPPER_JAR% ) ) else ( if not "%MVNW_REPOURL%" == "" ( SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... echo Downloading from: %DOWNLOAD_URL% ) powershell -Command "&{"^ "$webclient = new-object System.Net.WebClient;"^ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ "}"^ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ "}" if "%MVNW_VERBOSE%" == "true" ( echo Finished downloading %WRAPPER_JAR% ) ) @REM End of extension @REM Provide a "standardized" way to retrieve the CLI args that will @REM work with both Windows and non-Windows executions. set MAVEN_CMD_LINE_ARGS=%* %MAVEN_JAVA_EXE% ^ %JVM_CONFIG_MAVEN_PROPS% ^ %MAVEN_OPTS% ^ %MAVEN_DEBUG_OPTS% ^ -classpath %WRAPPER_JAR% ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end :error set ERROR_CODE=1 :end @endlocal & set ERROR_CODE=%ERROR_CODE% if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost @REM check for post script, once with legacy .bat ending and once with .cmd ending if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" :skipRcPost @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' if "%MAVEN_BATCH_PAUSE%"=="on" pause if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% cmd /C exit /B %ERROR_CODE% ================================================ FILE: pom.xml ================================================ 4.0.0 com.github.arthurdeka cedro-modern-dock 1.0 Cedro Modern Dock UTF-8 5.10.2 org.openjfx javafx-controls 23.0.1 win org.openjfx javafx-fxml 23.0.1 win org.openjfx javafx-graphics 23.0.1 win org.openjfx javafx-base 23.0.1 win org.junit.jupiter junit-jupiter-api ${junit.version} test org.junit.jupiter junit-jupiter-engine ${junit.version} test net.java.dev.jna jna 5.13.0 net.java.dev.jna jna-platform 5.13.0 com.fasterxml.jackson.core jackson-databind 2.17.2 org.projectlombok lombok 1.18.38 provided org.apache.maven.plugins maven-compiler-plugin 3.13.0 21 21 org.projectlombok lombok 1.18.38 org.apache.maven.plugins maven-surefire-plugin 3.2.5 org.moditect moditect-maven-plugin 1.2.1.Final add-module-infos package add-module-info ${project.build.directory}/modified-mods net.java.dev.jna jna com.sun.jna net.java.dev.jna jna-platform module com.sun.jna.platform { // Declara a dependência CRÍTICA no módulo base requires transitive com.sun.jna; // Exporta os pacotes para que seu código possa usá-los exports com.sun.jna.platform.win32; } org.apache.maven.plugins maven-dependency-plugin 3.7.1 copy-dependencies package copy-dependencies ${project.build.directory}/mods runtime jna,jna-platform org.panteleyev jpackage-maven-plugin 1.6.0 Cedro Modern Dock target/dist com.github.arthurdeka.cedromoderndock/com.github.arthurdeka.cedromoderndock.App ${project.build.directory}/mods ${project.build.directory}/modified-mods ${project.build.directory}/${project.build.finalName}.jar APP_IMAGE ${project.version} com.github.arthurdeka Copyright (C) 2024 src/main/resources/com/github/arthurdeka/cedromoderndock/icons/cedro/logo_256_ICO.ico jpackage package jpackage ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/App.java ================================================ package com.github.arthurdeka.cedromoderndock; import com.github.arthurdeka.cedromoderndock.application.AppServices; import com.github.arthurdeka.cedromoderndock.application.DockAppearanceService; import com.github.arthurdeka.cedromoderndock.application.DockItemActionService; import com.github.arthurdeka.cedromoderndock.application.DockPositioningService; import com.github.arthurdeka.cedromoderndock.application.DockService; import com.github.arthurdeka.cedromoderndock.application.LocalizationService; import com.github.arthurdeka.cedromoderndock.application.SupportedLanguage; import com.github.arthurdeka.cedromoderndock.application.WindowPreviewService; import com.github.arthurdeka.cedromoderndock.controller.DockController; import com.github.arthurdeka.cedromoderndock.infrastructure.persistence.JsonDockRepository; import com.github.arthurdeka.cedromoderndock.infrastructure.system.CachedWindowsIconGateway; import com.github.arthurdeka.cedromoderndock.infrastructure.system.DefaultFolderLauncher; import com.github.arthurdeka.cedromoderndock.infrastructure.system.DefaultProgramLauncher; import com.github.arthurdeka.cedromoderndock.infrastructure.system.DefaultWindowsModuleLauncher; import com.github.arthurdeka.cedromoderndock.infrastructure.system.JnaWindowQueryGateway; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import com.github.arthurdeka.cedromoderndock.util.SettingsWindowLauncher; import com.github.arthurdeka.cedromoderndock.util.SingleInstanceGuard; import com.github.arthurdeka.cedromoderndock.util.SystemTrayManager; import javafx.application.Application; import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.stage.StageStyle; import javax.swing.JOptionPane; import java.io.IOException; import static com.github.arthurdeka.cedromoderndock.util.UIUtils.setStageIcon; public class App extends Application { private static SingleInstanceGuard singleInstanceGuard; private SystemTrayManager systemTrayManager; @Override public void start(Stage primaryStage) throws IOException { AppServices appServices = createServices(); // invisble primary stage to dont show the dock icon in the taskbar primaryStage.initStyle(StageStyle.UTILITY); primaryStage.setOpacity(0); primaryStage.show(); // creates a new stage for the dock Stage dockStage = new Stage(); // loading dock interface and controller. FXMLLoader loader = new FXMLLoader(App.class.getResource("fxml/DockView.fxml")); Scene scene = new Scene(loader.load()); // configuring dock stage. dockStage.setTitle("Cedro Modern Dock"); setStageIcon(dockStage); // defining the invisible window as the "owner" of the dock (this makes the dock invisible). dockStage.initOwner(primaryStage); dockStage.initStyle(StageStyle.TRANSPARENT); scene.setFill(Color.TRANSPARENT); dockStage.setScene(scene); DockController dockController = loader.getController(); dockController.setStage(dockStage); dockController.setAppServices(appServices); dockController.handleInitialization(); dockStage.iconifiedProperty().addListener((observable, wasIconified, isIconified) -> { if (!isIconified) { return; } Platform.runLater(() -> { dockStage.setIconified(false); if (!dockStage.isShowing()) { dockStage.show(); } }); }); Platform.setImplicitExit(false); dockStage.show(); appServices.positioningService().applyPosition(dockStage); systemTrayManager = new SystemTrayManager( () -> openSettingsWindow(appServices, dockController, dockStage), Platform::exit ); systemTrayManager.install(); } @Override public void stop() { if (systemTrayManager != null) { systemTrayManager.dispose(); systemTrayManager = null; } if (singleInstanceGuard != null) { singleInstanceGuard.close(); singleInstanceGuard = null; } } public static void main(String[] args) { singleInstanceGuard = new SingleInstanceGuard(); if (!singleInstanceGuard.tryAcquire()) { SupportedLanguage language = new JsonDockRepository().load().getLanguage(); JOptionPane.showMessageDialog( null, LocalizationService.bootstrapText(language, "dialog.singleInstance.message"), "Cedro Modern Dock", JOptionPane.WARNING_MESSAGE ); return; } try { launch(); } finally { if (singleInstanceGuard != null) { singleInstanceGuard.close(); singleInstanceGuard = null; } } } private AppServices createServices() { DockService dockService = new DockService(new JsonDockRepository()); DockAppearanceService appearanceService = new DockAppearanceService(dockService); DockPositioningService positioningService = new DockPositioningService(dockService); LocalizationService localizationService = new LocalizationService(dockService); DockItemActionService itemActionService = new DockItemActionService( new DefaultProgramLauncher(), new DefaultFolderLauncher(), new DefaultWindowsModuleLauncher() ); WindowPreviewService windowPreviewService = new WindowPreviewService(new JnaWindowQueryGateway()); return new AppServices( dockService, appearanceService, positioningService, itemActionService, windowPreviewService, new CachedWindowsIconGateway(), localizationService ); } private void openSettingsWindow(AppServices appServices, DockController dockController, Stage dockStage) { SettingsWindowLauncher.open( appServices, dockController::updateDockUI, positioningMode -> handlePositioningModeChange(appServices, dockStage, positioningMode) ); } private void handlePositioningModeChange( AppServices appServices, Stage dockStage, DockPositioningMode positioningMode ) { DockPositioningMode currentMode = appServices.positioningService().getPositioningMode(); if (currentMode == DockPositioningMode.STATIC && positioningMode == DockPositioningMode.DYNAMIC) { appServices.dockService().setDockPosition(dockStage.getX(), dockStage.getY()); } appServices.positioningService().setPositioningMode(positioningMode); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/AppServices.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.domain.IconGateway; public record AppServices( DockService dockService, DockAppearanceService appearanceService, DockPositioningService positioningService, DockItemActionService itemActionService, WindowPreviewService windowPreviewService, IconGateway iconGateway, LocalizationService localizationService ) { } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/DockAppearanceService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.model.DockModel; public class DockAppearanceService { private final DockService dockService; public DockAppearanceService(DockService dockService) { this.dockService = dockService; } public DockModel getDock() { return dockService.getDock(); } public int getIconsSize() { return getDock().getIconsSize(); } public void setIconsSize(int iconsSize) { getDock().setIconsSize(iconsSize); dockService.saveChanges(); } public int getSpacingBetweenIcons() { return getDock().getSpacingBetweenIcons(); } public void setSpacingBetweenIcons(int spacingValue) { getDock().setSpacingBetweenIcons(spacingValue); dockService.saveChanges(); } public int getDockTransparencyPercentage() { return (int) (getDock().getDockTransparency() * 100); } public void setDockTransparencyPercentage(int value) { getDock().setDockTransparency((double) value / 100); dockService.saveChanges(); } public int getDockBorderRounding() { return getDock().getDockBorderRounding(); } public void setDockBorderRounding(int value) { getDock().setDockBorderRounding(value); dockService.saveChanges(); } public String getDockColorRGB() { return getDock().getDockColorRGB(); } public void setDockColorRGB(String value) { getDock().setDockColorRGB(value); dockService.saveChanges(); } public DockTheme getDockTheme() { DockModel dock = getDock(); return new DockTheme(dock.getDockColorRGB(), dock.getDockTransparency(), dock.getDockBorderRounding()); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/DockItemActionService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.domain.FolderLauncher; import com.github.arthurdeka.cedromoderndock.domain.ProgramLauncher; import com.github.arthurdeka.cedromoderndock.domain.WindowsModuleLauncher; import com.github.arthurdeka.cedromoderndock.model.DockItem; import com.github.arthurdeka.cedromoderndock.model.DockItemType; import com.github.arthurdeka.cedromoderndock.model.DockFolderItemModel; import com.github.arthurdeka.cedromoderndock.model.DockProgramItemModel; import com.github.arthurdeka.cedromoderndock.model.DockWindowsModuleItemModel; public class DockItemActionService { private final FolderLauncher folderLauncher; private final ProgramLauncher programLauncher; private final WindowsModuleLauncher windowsModuleLauncher; public DockItemActionService( ProgramLauncher programLauncher, FolderLauncher folderLauncher, WindowsModuleLauncher windowsModuleLauncher ) { this.programLauncher = programLauncher; this.folderLauncher = folderLauncher; this.windowsModuleLauncher = windowsModuleLauncher; } public void execute(DockItem item, Runnable openSettingsAction) { if (item.getType() == DockItemType.PROGRAM && item instanceof DockProgramItemModel programItem) { programLauncher.launch(programItem.getExecutablePath(), programItem.getLabel()); return; } if (item.getType() == DockItemType.FOLDER && item instanceof DockFolderItemModel folderItem) { folderLauncher.launch(folderItem.getFolderPath(), folderItem.getLabel()); return; } if (item.getType() == DockItemType.WINDOWS_MODULE && item instanceof DockWindowsModuleItemModel windowsModuleItem) { windowsModuleLauncher.launch(windowsModuleItem.getModule(), windowsModuleItem.getLabel()); return; } if (item.getType() == DockItemType.SETTINGS) { openSettingsAction.run(); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/DockPositioningService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.model.DockHorizontalAnchor; import com.github.arthurdeka.cedromoderndock.model.DockModel; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import com.github.arthurdeka.cedromoderndock.model.DockVerticalAnchor; import javafx.geometry.Rectangle2D; import javafx.stage.Screen; import javafx.stage.Stage; public class DockPositioningService { private final DockService dockService; public DockPositioningService(DockService dockService) { this.dockService = dockService; } public DockPositioningMode getPositioningMode() { return dockService.getDock().getPositioningMode(); } public void setPositioningMode(DockPositioningMode positioningMode) { dockService.getDock().setPositioningMode(positioningMode); dockService.saveChanges(); } public DockVerticalAnchor getVerticalAnchor() { return dockService.getDock().getVerticalAnchor(); } public void setVerticalAnchor(DockVerticalAnchor verticalAnchor) { dockService.getDock().setVerticalAnchor(verticalAnchor); dockService.saveChanges(); } public DockHorizontalAnchor getHorizontalAnchor() { return dockService.getDock().getHorizontalAnchor(); } public void setHorizontalAnchor(DockHorizontalAnchor horizontalAnchor) { dockService.getDock().setHorizontalAnchor(horizontalAnchor); dockService.saveChanges(); } public int getScreenEdgeSpacing() { return dockService.getDock().getTopSpacing(); } public void setScreenEdgeSpacing(int spacing) { setTopSpacing(spacing); setLeftSpacing(spacing); setRightSpacing(spacing); setBottomSpacing(spacing); } public int getTopSpacing() { return dockService.getDock().getTopSpacing(); } public void setTopSpacing(int spacing) { dockService.getDock().setTopSpacing(Math.max(0, spacing)); dockService.saveChanges(); } public int getLeftSpacing() { return dockService.getDock().getLeftSpacing(); } public void setLeftSpacing(int spacing) { dockService.getDock().setLeftSpacing(Math.max(0, spacing)); dockService.saveChanges(); } public int getRightSpacing() { return dockService.getDock().getRightSpacing(); } public void setRightSpacing(int spacing) { dockService.getDock().setRightSpacing(Math.max(0, spacing)); dockService.saveChanges(); } public int getBottomSpacing() { return dockService.getDock().getBottomSpacing(); } public void setBottomSpacing(int spacing) { dockService.getDock().setBottomSpacing(Math.max(0, spacing)); dockService.saveChanges(); } public boolean isDynamicPositioning() { return getPositioningMode() == DockPositioningMode.DYNAMIC; } public void applyPosition(Stage stage) { if (stage == null) { return; } DockModel dock = dockService.getDock(); if (dock.getPositioningMode() == DockPositioningMode.DYNAMIC) { stage.setX(snapToPixel(dock.getDockPositionX())); stage.setY(snapToPixel(dock.getDockPositionY())); return; } Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); double stageWidth = stage.getWidth(); double stageHeight = stage.getHeight(); stage.setX(snapToPixel(resolveHorizontalPosition(bounds, stageWidth, dock))); stage.setY(snapToPixel(resolveVerticalPosition(bounds, stageHeight, dock))); } static double snapToPixel(double value) { return Math.round(value); } private double resolveHorizontalPosition( Rectangle2D bounds, double stageWidth, DockModel dock ) { return switch (dock.getHorizontalAnchor()) { case LEFT -> bounds.getMinX() + dock.getLeftSpacing(); case MIDDLE -> bounds.getMinX() + ((bounds.getWidth() - stageWidth) / 2); case RIGHT -> bounds.getMaxX() - stageWidth - dock.getRightSpacing(); }; } private double resolveVerticalPosition( Rectangle2D bounds, double stageHeight, DockModel dock ) { return switch (dock.getVerticalAnchor()) { case TOP -> bounds.getMinY() + dock.getTopSpacing(); case MIDDLE -> bounds.getMinY() + ((bounds.getHeight() - stageHeight) / 2); case DOWN -> bounds.getMaxY() - stageHeight - dock.getBottomSpacing(); }; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/DockService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.domain.DockRepository; import com.github.arthurdeka.cedromoderndock.model.DockItem; import com.github.arthurdeka.cedromoderndock.model.DockModel; import java.util.List; public class DockService { private final DockRepository repository; private final DockModel dock; public DockService(DockRepository repository) { this.repository = repository; this.dock = repository.load(); } public DockModel getDock() { return dock; } public List getItems() { return dock.getItems(); } public void addItem(DockItem item) { dock.addItem(item); saveChanges(); } public void removeItem(int index) { dock.removeItem(index); saveChanges(); } public void swapItems(int firstItemIdx, int secondItemIdx) { dock.swapItems(firstItemIdx, secondItemIdx); saveChanges(); } public void setDockPosition(double positionX, double positionY) { dock.setDockPosition( DockPositioningService.snapToPixel(positionX), DockPositioningService.snapToPixel(positionY) ); saveChanges(); } public void saveChanges() { repository.save(dock); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/DockTheme.java ================================================ package com.github.arthurdeka.cedromoderndock.application; public record DockTheme(String colorRgb, double transparency, int borderRounding) { } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/LocalizationService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.model.DockItem; import com.github.arthurdeka.cedromoderndock.model.DockItemType; import com.github.arthurdeka.cedromoderndock.model.DockSettingsItemModel; import com.github.arthurdeka.cedromoderndock.model.DockWindowsModuleItemModel; import java.text.MessageFormat; import java.util.List; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.concurrent.CopyOnWriteArrayList; public class LocalizationService { private static final String BUNDLE_BASE_NAME = "com.github.arthurdeka.cedromoderndock.i18n.messages"; private final DockService dockService; private final List listeners = new CopyOnWriteArrayList<>(); private ResourceBundle bundle; public LocalizationService(DockService dockService) { this.dockService = dockService; this.bundle = loadBundle(getCurrentLanguage()); } public SupportedLanguage getCurrentLanguage() { SupportedLanguage language = dockService.getDock().getLanguage(); return language == null ? SupportedLanguage.EN_US : language; } public void setLanguage(SupportedLanguage language) { SupportedLanguage resolvedLanguage = language == null ? SupportedLanguage.EN_US : language; if (resolvedLanguage == getCurrentLanguage()) { return; } dockService.getDock().setLanguage(resolvedLanguage); dockService.saveChanges(); bundle = loadBundle(resolvedLanguage); notifyListeners(); } public String text(String key, Object... arguments) { String pattern = bundle.containsKey(key) ? bundle.getString(key) : key; if (arguments == null || arguments.length == 0) { return pattern; } return MessageFormat.format(pattern, arguments); } public String languageDisplayName(SupportedLanguage language) { SupportedLanguage resolvedLanguage = language == null ? SupportedLanguage.EN_US : language; return resolvedLanguage.nativeDisplayName(); } public String dockItemLabel(DockItem item) { if (item == null) { return ""; } if (item.getType() == DockItemType.SETTINGS || item instanceof DockSettingsItemModel) { return text("dockItem.settings"); } if (item.getType() == DockItemType.WINDOWS_MODULE && item instanceof DockWindowsModuleItemModel windowsModuleItem) { return switch (windowsModuleItem.getModule()) { case "mypc" -> text("windowsModule.myComputer"); case "trash" -> text("windowsModule.recycleBin"); case "ctrlpnl" -> text("windowsModule.controlPanel"); case "pconfig" -> text("windowsModule.settings"); default -> item.getLabel(); }; } return item.getLabel(); } public void addListener(Runnable listener) { listeners.add(listener); } public void removeListener(Runnable listener) { listeners.remove(listener); } public static String bootstrapText(SupportedLanguage language, String key, Object... arguments) { try { ResourceBundle bundle = loadBundle(language == null ? SupportedLanguage.EN_US : language); String pattern = bundle.containsKey(key) ? bundle.getString(key) : key; if (arguments == null || arguments.length == 0) { return pattern; } return MessageFormat.format(pattern, arguments); } catch (MissingResourceException e) { return key; } } private void notifyListeners() { for (Runnable listener : listeners) { listener.run(); } } private static ResourceBundle loadBundle(SupportedLanguage language) { return ResourceBundle.getBundle(BUNDLE_BASE_NAME, language.locale()); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/ProgramSelectionResolver.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.stream.Stream; public final class ProgramSelectionResolver { private ProgramSelectionResolver() { } public static ResolvedProgramSelection resolve(Path selectedExecutable) { Path normalizedPath = selectedExecutable.toAbsolutePath().normalize(); Path resolvedExecutable = resolveSquirrelExecutable(normalizedPath); return new ResolvedProgramSelection( resolvedExecutable.toString(), stripExtension(resolvedExecutable.getFileName().toString()) ); } private static Path resolveSquirrelExecutable(Path selectedExecutable) { if (!isUpdaterExecutable(selectedExecutable)) { return selectedExecutable; } Path installDir = selectedExecutable.getParent(); if (installDir == null) { return selectedExecutable; } String installFolderName = installDir.getFileName() == null ? "" : installDir.getFileName().toString(); List appDirectories = listAppDirectories(installDir); for (Path appDirectory : appDirectories) { Path preferredExecutable = appDirectory.resolve(installFolderName + ".exe"); if (Files.isRegularFile(preferredExecutable)) { return preferredExecutable; } Path fallbackExecutable = findFirstExecutable(appDirectory); if (fallbackExecutable != null) { return fallbackExecutable; } } return selectedExecutable; } private static boolean isUpdaterExecutable(Path executablePath) { Path fileName = executablePath.getFileName(); return fileName != null && fileName.toString().equalsIgnoreCase("Update.exe"); } private static List listAppDirectories(Path installDir) { try (Stream paths = Files.list(installDir)) { return paths .filter(Files::isDirectory) .filter(path -> path.getFileName() != null) .filter(path -> path.getFileName().toString().toLowerCase(Locale.ROOT).startsWith("app-")) .sorted(Comparator.comparing(ProgramSelectionResolver::lastModifiedTime).reversed()) .toList(); } catch (IOException e) { return List.of(); } } private static long lastModifiedTime(Path path) { try { return Files.getLastModifiedTime(path).toMillis(); } catch (IOException e) { return Long.MIN_VALUE; } } private static Path findFirstExecutable(Path appDirectory) { try (Stream files = Files.list(appDirectory)) { return files .filter(Files::isRegularFile) .filter(path -> path.getFileName() != null) .filter(path -> path.getFileName().toString().toLowerCase(Locale.ROOT).endsWith(".exe")) .filter(path -> !path.getFileName().toString().equalsIgnoreCase("Update.exe")) .sorted(Comparator.comparing(path -> path.getFileName().toString())) .findFirst() .orElse(null); } catch (IOException e) { return null; } } private static String stripExtension(String fileName) { int lastDot = fileName.lastIndexOf('.'); return lastDot > 0 ? fileName.substring(0, lastDot) : fileName; } public record ResolvedProgramSelection(String executablePath, String label) { } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/SupportedLanguage.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import java.util.Locale; public enum SupportedLanguage { EN_US("en", "US", "English"), ZH_CN("zh", "CN", "\u7B80\u4F53\u4E2D\u6587"), ZH_TW("zh", "TW", "\u7E41\u9AD4\u4E2D\u6587"), HI_IN("hi", "IN", "\u0939\u093F\u0928\u094D\u0926\u0940"), ES_ES("es", "ES", "Espa\u00F1ol"), FR_FR("fr", "FR", "Fran\u00E7ais"), AR_SA("ar", "SA", "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"), BN_BD("bn", "BD", "\u09AC\u09BE\u0982\u09B2\u09BE"), PT_BR("pt", "BR", "Portugu\u00EAs (Brasil)"), RU_RU("ru", "RU", "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"), UR_PK("ur", "PK", "\u0627\u0631\u062F\u0648"), ID_ID("id", "ID", "Bahasa Indonesia"), DE_DE("de", "DE", "Deutsch"), JA_JP("ja", "JP", "\u65E5\u672C\u8A9E"), PCM_NG("pcm", "NG", "Naij\u00E1"), MR_IN("mr", "IN", "\u092E\u0930\u093E\u0920\u0940"), TE_IN("te", "IN", "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41"), TR_TR("tr", "TR", "T\u00FCrk\u00E7e"), TA_IN("ta", "IN", "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD"), YUE_HK("yue", "HK", "\u7CB5\u8A9E"), VI_VN("vi", "VN", "Ti\u1EBFng Vi\u1EC7t"); private final Locale locale; private final String nativeDisplayName; SupportedLanguage(String language, String country, String nativeDisplayName) { this.locale = Locale.of(language, country); this.nativeDisplayName = nativeDisplayName; } public Locale locale() { return locale; } public String nativeDisplayName() { return nativeDisplayName; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/application/WindowPreviewService.java ================================================ package com.github.arthurdeka.cedromoderndock.application; import com.github.arthurdeka.cedromoderndock.domain.WindowQueryGateway; import com.github.arthurdeka.cedromoderndock.model.DockProgramItemModel; import com.github.arthurdeka.cedromoderndock.util.NativeWindowUtils; import java.util.List; public class WindowPreviewService { private final WindowQueryGateway windowQueryGateway; public WindowPreviewService(WindowQueryGateway windowQueryGateway) { this.windowQueryGateway = windowQueryGateway; } public List loadPreview(DockProgramItemModel item) { return windowQueryGateway.findOpenWindows(item.getExecutablePath()); } public boolean hasOpenWindows(String executablePath) { return !windowQueryGateway.findOpenWindows(executablePath).isEmpty(); } public void activate(NativeWindowUtils.WindowInfo windowInfo) { windowQueryGateway.activate(windowInfo); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/controller/AcknowledgementsModalController.java ================================================ package com.github.arthurdeka.cedromoderndock.controller; import com.github.arthurdeka.cedromoderndock.application.AppServices; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.stage.Stage; import javafx.stage.WindowEvent; public class AcknowledgementsModalController { @FXML private Label titleLabel; @FXML private Label subtitleLabel; @FXML private Label sectionTitleLabel; private AppServices appServices; private final Runnable localizationListener = this::applyLocalizedTexts; private boolean localizationRegistered; private boolean cleanupRegistered; public void initialize() { titleLabel.sceneProperty().addListener((observableValue, oldScene, newScene) -> { if (newScene == null) { return; } newScene.windowProperty().addListener((windowObservable, oldWindow, newWindow) -> { if (newWindow == null) { return; } updateWindowTitle(); if (!cleanupRegistered) { cleanupRegistered = true; newWindow.addEventHandler(WindowEvent.WINDOW_HIDDEN, event -> unregisterLocalizationListener()); } }); }); } public void handleInitialization() { if (!localizationRegistered) { appServices.localizationService().addListener(localizationListener); localizationRegistered = true; } applyLocalizedTexts(); } public void setAppServices(AppServices appServices) { this.appServices = appServices; } private void applyLocalizedTexts() { if (appServices == null) { return; } titleLabel.setText(text("acknowledgements.title")); subtitleLabel.setText(text("acknowledgements.subtitle")); sectionTitleLabel.setText(text("acknowledgements.sectionTitle")); updateWindowTitle(); } private void updateWindowTitle() { if (titleLabel.getScene() != null && titleLabel.getScene().getWindow() instanceof Stage stage && appServices != null) { stage.setTitle(text("acknowledgements.window.title")); } } private void unregisterLocalizationListener() { if (appServices != null && localizationRegistered) { appServices.localizationService().removeListener(localizationListener); localizationRegistered = false; } } private String text(String key) { return appServices.localizationService().text(key); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/controller/AddWindowsModulesModalController.java ================================================ package com.github.arthurdeka.cedromoderndock.controller; import com.github.arthurdeka.cedromoderndock.App; import com.github.arthurdeka.cedromoderndock.application.AppServices; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import com.github.arthurdeka.cedromoderndock.model.DockWindowsModuleItemModel; import com.github.arthurdeka.cedromoderndock.util.Logger; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.stage.Stage; import javafx.stage.WindowEvent; import java.util.List; import java.util.function.Consumer; import static com.github.arthurdeka.cedromoderndock.util.UIUtils.setStageIcon; public class AddWindowsModulesModalController { private static final List MODULE_IDS = List.of("mypc", "trash", "ctrlpnl", "pconfig"); @FXML private Label titleLabel; @FXML private Label subtitleLabel; @FXML private Label availableModulesTitleLabel; @FXML private Label availableModulesHelperLabel; @FXML private ListView listView; @FXML private Button addSelectedModuleButton; private AppServices appServices; private Runnable dockRefreshAction = () -> {}; private Consumer positioningModeChangeAction = positioningMode -> {}; private final Runnable localizationListener = this::applyLocalizedTexts; private boolean localizationRegistered; private boolean cleanupRegistered; public void initialize() { Logger.info("[Initializing] AddWindowsModulesModalController"); listView.sceneProperty().addListener((observableValue, oldScene, newScene) -> { if (newScene == null) { return; } newScene.windowProperty().addListener((windowObservable, oldWindow, newWindow) -> { if (newWindow == null) { return; } updateWindowTitle(); if (!cleanupRegistered) { cleanupRegistered = true; newWindow.addEventHandler(WindowEvent.WINDOW_HIDDEN, event -> unregisterLocalizationListener()); } }); }); } public void handleInitialization() { if (!localizationRegistered) { appServices.localizationService().addListener(localizationListener); localizationRegistered = true; } applyLocalizedTexts(); } @FXML private void handleAddSelectedModule() { int selectedIdx = listView.getSelectionModel().getSelectedIndex(); if (selectedIdx < 0 || selectedIdx >= MODULE_IDS.size()) { return; } String moduleId = MODULE_IDS.get(selectedIdx); appServices.dockService().addItem(new DockWindowsModuleItemModel(defaultModuleLabel(moduleId), moduleId)); dockRefreshAction.run(); openSettingsWindow(); } private void openSettingsWindow() { try { Stage currentStage = (Stage) listView.getScene().getWindow(); FXMLLoader loader = new FXMLLoader(App.class.getResource("fxml/DockSettingsView.fxml")); Parent root = loader.load(); SettingsController settingsController = loader.getController(); settingsController.setAppServices(appServices); settingsController.setDockRefreshAction(dockRefreshAction); settingsController.setPositioningModeChangeAction(positioningModeChangeAction); settingsController.handleInitialization(); Stage stage = new Stage(); stage.setTitle(text("settings.window.title")); setStageIcon(stage); stage.setScene(new Scene(root)); stage.show(); stage.setMinHeight(stage.getHeight()); stage.setMaxHeight(stage.getHeight()); currentStage.close(); } catch (Exception e) { throw new RuntimeException(e); } } public void setAppServices(AppServices appServices) { this.appServices = appServices; } public void setDockRefreshAction(Runnable dockRefreshAction) { this.dockRefreshAction = dockRefreshAction; } public void setPositioningModeChangeAction(Consumer positioningModeChangeAction) { this.positioningModeChangeAction = positioningModeChangeAction; } private void applyLocalizedTexts() { if (appServices == null) { return; } titleLabel.setText(text("windowsModule.modal.title")); subtitleLabel.setText(text("windowsModule.modal.subtitle")); availableModulesTitleLabel.setText(text("windowsModule.modal.available.title")); availableModulesHelperLabel.setText(text("windowsModule.modal.available.helper")); addSelectedModuleButton.setText(text("windowsModule.modal.addSelected")); listView.getItems().setAll(MODULE_IDS.stream().map(this::resolveModuleLabel).toList()); updateWindowTitle(); } private String resolveModuleLabel(String moduleId) { return switch (moduleId) { case "mypc" -> text("windowsModule.myComputer"); case "trash" -> text("windowsModule.recycleBin"); case "ctrlpnl" -> text("windowsModule.controlPanel"); case "pconfig" -> text("windowsModule.settings"); default -> moduleId; }; } private String defaultModuleLabel(String moduleId) { return switch (moduleId) { case "mypc" -> "My Computer"; case "trash" -> "Recycle Bin"; case "ctrlpnl" -> "Control Panel"; case "pconfig" -> "Settings"; default -> moduleId; }; } private void updateWindowTitle() { if (listView.getScene() != null && listView.getScene().getWindow() instanceof Stage stage && appServices != null) { stage.setTitle(text("windowsModule.modal.title")); } } private void unregisterLocalizationListener() { if (appServices != null && localizationRegistered) { appServices.localizationService().removeListener(localizationListener); localizationRegistered = false; } } private String text(String key) { return appServices.localizationService().text(key); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/controller/DockController.java ================================================ package com.github.arthurdeka.cedromoderndock.controller; import com.github.arthurdeka.cedromoderndock.App; import com.github.arthurdeka.cedromoderndock.application.AppServices; import com.github.arthurdeka.cedromoderndock.application.DockTheme; import com.github.arthurdeka.cedromoderndock.model.DockItem; import com.github.arthurdeka.cedromoderndock.model.DockFolderItemModel; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import com.github.arthurdeka.cedromoderndock.model.DockProgramItemModel; import com.github.arthurdeka.cedromoderndock.model.DockSettingsItemModel; import com.github.arthurdeka.cedromoderndock.model.DockWindowsModuleItemModel; import com.github.arthurdeka.cedromoderndock.util.Logger; import javafx.application.Platform; import javafx.animation.PauseTransition; import javafx.concurrent.Task; import javafx.util.Duration; import com.github.arthurdeka.cedromoderndock.util.NativeWindowUtils; import com.github.arthurdeka.cedromoderndock.view.WindowPreviewPopup; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.geometry.Pos; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.github.arthurdeka.cedromoderndock.util.SettingsWindowLauncher; public class DockController { private static final double HOVER_SCALE = 1.3; @FXML private AnchorPane rootPane; @FXML private HBox hBoxContainer; private AppServices appServices; private Stage stage; // Runs native window queries off the FX thread; single daemon thread avoids unbounded thread creation. private final ExecutorService windowPreviewExecutor = Executors.newSingleThreadExecutor(r -> { Thread t = new Thread(r, "WindowPreviewFetcher"); t.setDaemon(true); return t; }); private WindowPreviewPopup windowPreviewPopup; private PauseTransition hideDebounce; private boolean isHoveringPopup = false; private Button currentHoverButton; private Button popupOwnerButton; private final ExecutorService openStateExecutor = Executors.newSingleThreadExecutor(r -> { Thread t = new Thread(r, "DockOpenStateWatcher"); t.setDaemon(true); return t; }); private final Map> programIndicators = new HashMap<>(); private final Rectangle dockClip = new Rectangle(); // Monotonic id to ignore stale async results from previous hover requests. private int hoverRequestId = 0; private final Runnable localizationListener = this::updateDockUI; // variables for the enableDrag function private double xOffset = 0; private double yOffset = 0; // Run when FXML is loaded public void handleInitialization() { appServices.localizationService().addListener(localizationListener); dockClip.widthProperty().bind(hBoxContainer.widthProperty()); dockClip.heightProperty().bind(hBoxContainer.heightProperty()); hBoxContainer.setClip(dockClip); // Popup that lists open windows for a program icon on hover. windowPreviewPopup = new WindowPreviewPopup(); windowPreviewPopup.getContainer().setOnMouseEntered(e -> { isHoveringPopup = true; hideDebounce.stop(); }); windowPreviewPopup.getContainer().setOnMouseExited(e -> { isHoveringPopup = false; scheduleHide(); }); // Small delay prevents flicker when moving between icon and popup. hideDebounce = new PauseTransition(Duration.millis(80)); hideDebounce.setOnFinished(e -> { if (shouldHidePreview()) { windowPreviewPopup.hide(); popupOwnerButton = null; } }); enableDrag(); updateDockUI(); startOpenStateWatcher(); } // enables dock drag effect private void enableDrag() { rootPane.setOnMousePressed(event -> { if (!appServices.positioningService().isDynamicPositioning()) { return; } xOffset = event.getSceneX(); yOffset = event.getSceneY(); }); rootPane.setOnMouseDragged(event -> { if (!appServices.positioningService().isDynamicPositioning()) { return; } stage.setX(event.getScreenX() - xOffset); stage.setY(event.getScreenY() - yOffset); }); // saves the dock position on the model rootPane.setOnMouseReleased(event -> { if (!appServices.positioningService().isDynamicPositioning()) { appServices.positioningService().applyPosition(stage); return; } appServices.dockService().setDockPosition(stage.getX(), stage.getY()); appServices.positioningService().applyPosition(stage); }); } public void addDockItem(DockItem item) { appServices.dockService().addItem(item); } public void removeDockItem(int index) { appServices.dockService().removeItem(index); } public List getDockItems() { return appServices.dockService().getItems(); } public void swapItems(int firstItemIdx, int secondItemIdx) { appServices.dockService().swapItems(firstItemIdx, secondItemIdx); updateDockUI(); } /* this method updates the DockView (actual rendered Dock) style and saves the changes */ public void updateDockUI() { var dock = appServices.dockService().getDock(); hBoxContainer.getChildren().clear(); synchronized (programIndicators) { programIndicators.clear(); } dockClip.setArcWidth(dock.getDockBorderRounding() * 2.0); dockClip.setArcHeight(dock.getDockBorderRounding() * 2.0); hBoxContainer.setSpacing(getDockIconsSpacing()); hBoxContainer.setStyle("-fx-background-color: rgba(" + dock.getDockColorRGB() + " " + dock.getDockTransparency() + ");" + "-fx-background-radius: " + dock.getDockBorderRounding() + ";"); for (DockItem item : dock.getItems()) { Button button = createButton(item); if (button != null) { hBoxContainer.getChildren().add(button); } } // resize DockView window to account for DockItem additions or removing stage.sizeToScene(); appServices.positioningService().applyPosition(stage); requestProgramIndicatorRefresh(); } private Button createButton(DockItem item) { String buttonLabel = appServices.localizationService().dockItemLabel(item); if (item instanceof DockSettingsItemModel) { Image icon = loadDockResourceImage(item.getPath()); ImageView imageView = createDockImageView(icon); Button button = new Button(buttonLabel); button.getStyleClass().add("dock-button"); button.setGraphic(imageView); button.setOnAction(e -> appServices.itemActionService().execute(item, this::openSettingsWindow)); return button; } else if (item instanceof DockWindowsModuleItemModel) { Image icon = loadDockResourceImage(item.getPath()); ImageView imageView = createDockImageView(icon); Button button = new Button(buttonLabel); button.getStyleClass().add("dock-button"); button.setGraphic(imageView); button.setOnAction(e -> appServices.itemActionService().execute(item, this::openSettingsWindow)); return button; } else if (item instanceof DockProgramItemModel programItem) { // Logic for DockProgramItemModel runs on a background thread. Path iconPath = appServices.iconGateway().resolveProgramIcon(programItem.getExecutablePath()); // if file does not exist if (iconPath == null || Files.notExists(iconPath)) { Logger.error("DockController - createButton - path for cached icon not found"); return null; } Image icon = loadDockFileImage(iconPath); ImageView imageView = createDockImageView(icon); Circle runningIndicator = createRunningIndicator(); VBox graphic = createProgramGraphic(imageView, runningIndicator); Button button = new Button(buttonLabel); button.getStyleClass().add("dock-button"); button.setGraphic(graphic); synchronized (programIndicators) { programIndicators .computeIfAbsent(programItem.getExecutablePath(), ignored -> new ArrayList<>()) .add(runningIndicator); } button.setOnAction(e -> appServices.itemActionService().execute(item, this::openSettingsWindow)); // Show a window list preview when hovering this program icon. setupHoverPreview(button, programItem, icon); return button; } else if (item instanceof DockFolderItemModel folderItem) { Path iconPath = appServices.iconGateway().resolveFolderIcon(folderItem.getFolderPath()); if (iconPath == null || Files.notExists(iconPath)) { appServices.iconGateway().cacheFolderIcon(folderItem.getFolderPath()); iconPath = appServices.iconGateway().resolveFolderIcon(folderItem.getFolderPath()); } Image icon; if (iconPath != null && Files.exists(iconPath)) { icon = loadDockFileImage(iconPath); } else { icon = loadDockResourceImage("/com/github/arthurdeka/cedromoderndock/icons/folder.png"); } ImageView imageView = createDockImageView(icon); Button button = new Button(buttonLabel); button.getStyleClass().add("dock-button"); button.setGraphic(imageView); button.setOnAction(e -> appServices.itemActionService().execute(item, this::openSettingsWindow)); return button; } else { return null; } } private VBox createProgramGraphic(ImageView imageView, Circle runningIndicator) { VBox graphic = new VBox(4, imageView, runningIndicator); graphic.setAlignment(Pos.CENTER); return graphic; } private Image loadDockResourceImage(String resourcePath) { return new Image( App.class.getResource(resourcePath).toExternalForm(), getRequestedIconSize(), getRequestedIconSize(), true, true, false ); } private Image loadDockFileImage(Path iconPath) { return new Image( iconPath.toUri().toString(), getRequestedIconSize(), getRequestedIconSize(), true, true, false ); } private ImageView createDockImageView(Image icon) { ImageView imageView = new ImageView(icon); imageView.setFitWidth(appServices.appearanceService().getIconsSize()); imageView.setFitHeight(appServices.appearanceService().getIconsSize()); imageView.setPreserveRatio(true); imageView.setSmooth(true); return imageView; } private int getRequestedIconSize() { return Math.max( appServices.appearanceService().getIconsSize(), (int) Math.ceil(appServices.appearanceService().getIconsSize() * HOVER_SCALE) ); } private Circle createRunningIndicator() { Circle runningIndicator = new Circle(1.5); runningIndicator.setFill(Color.WHITE); runningIndicator.setManaged(true); runningIndicator.setOpacity(0); runningIndicator.setMouseTransparent(true); return runningIndicator; } private void startOpenStateWatcher() { openStateExecutor.execute(() -> { while (!Thread.currentThread().isInterrupted()) { try { refreshProgramIndicatorsInBackground(); Thread.sleep(1200); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { Logger.error("Failed to refresh running program indicators: " + e.getMessage()); } } }); } private void requestProgramIndicatorRefresh() { openStateExecutor.execute(this::refreshProgramIndicatorsInBackground); } private void refreshProgramIndicatorsInBackground() { Map> indicatorSnapshot = snapshotProgramIndicators(); if (indicatorSnapshot.isEmpty()) { return; } Map openStateByExecutable = new HashMap<>(); for (String executablePath : indicatorSnapshot.keySet()) { openStateByExecutable.put(executablePath, appServices.windowPreviewService().hasOpenWindows(executablePath)); } Platform.runLater(() -> applyProgramIndicatorState(indicatorSnapshot, openStateByExecutable)); } private Map> snapshotProgramIndicators() { synchronized (programIndicators) { Map> snapshot = new HashMap<>(); for (Map.Entry> entry : programIndicators.entrySet()) { snapshot.put(entry.getKey(), new ArrayList<>(entry.getValue())); } return snapshot; } } private void applyProgramIndicatorState(Map> indicatorSnapshot, Map openStateByExecutable) { for (Map.Entry entry : openStateByExecutable.entrySet()) { List indicators = indicatorSnapshot.getOrDefault(entry.getKey(), List.of()); boolean isOpen = entry.getValue(); for (Circle indicator : indicators) { indicator.setOpacity(isOpen ? 1 : 0); } } } private void setupHoverPreview(Button button, DockProgramItemModel item, Image icon) { // Track hover state for the icon and popup to avoid flicker. button.setOnMouseEntered(e -> { currentHoverButton = button; hideDebounce.stop(); // If another icon owns the popup, close it before showing new content. if (windowPreviewPopup.isShowing() && popupOwnerButton != button) { windowPreviewPopup.hide(); popupOwnerButton = null; } showWindowPreview(button, item, icon); }); button.setOnMouseExited(e -> { if (currentHoverButton == button) { currentHoverButton = null; } // Hide with a short debounce to allow moving into the popup. scheduleHide(); }); } private void showWindowPreview(Button button, DockProgramItemModel item, Image icon) { int requestId = ++hoverRequestId; // Query native windows on a background thread. Task> task = new Task<>() { @Override protected List call() throws Exception { return appServices.windowPreviewService().loadPreview(item); } }; task.setOnSucceeded(e -> { // Ignore results from older hover requests. if (requestId != hoverRequestId) { return; } List windows = task.getValue(); // If the mouse left the icon, do nothing. if (currentHoverButton != button || !button.isHover()) { return; } // Only show popup when there is at least one window. if (!windows.isEmpty()) { DockTheme dockTheme = appServices.appearanceService().getDockTheme(); windowPreviewPopup.updateContent( windows, icon, item.getLabel(), dockTheme, appServices.windowPreviewService()::activate ); windowPreviewPopup.showAbove(button, hBoxContainer); popupOwnerButton = button; } else if (windowPreviewPopup.isShowing() && popupOwnerButton == button) { windowPreviewPopup.hide(); popupOwnerButton = null; } }); task.setOnFailed(e -> { Logger.error("Failed to fetch windows for " + item.getLabel() + ": " + task.getException().getMessage()); }); windowPreviewExecutor.execute(task); } private void scheduleHide() { hideDebounce.stop(); hideDebounce.playFromStart(); } private boolean shouldHidePreview() { if (isHoveringPopup) { return false; } if (currentHoverButton == null) { return true; } return !currentHoverButton.isHover(); } private void openSettingsWindow() { SettingsWindowLauncher.open( appServices, this::updateDockUI, this::handlePositioningModeChange ); } public void setDockIconsSize(int iconsSize) { appServices.appearanceService().setIconsSize(iconsSize); updateDockUI(); } public int getDockIconsSize() { return appServices.appearanceService().getIconsSize(); } public void setDockIconsSpacing(int spacingValue) { appServices.appearanceService().setSpacingBetweenIcons(spacingValue); updateDockUI(); } public int getDockIconsSpacing() { return appServices.appearanceService().getSpacingBetweenIcons(); } public int getDockTransparency() { return appServices.appearanceService().getDockTransparencyPercentage(); } public void setDockTransparency(int value) { appServices.appearanceService().setDockTransparencyPercentage(value); updateDockUI(); } public void setDockBorderRounding(int value) { appServices.appearanceService().setDockBorderRounding(value); updateDockUI(); } public int getDockBorderRounding() { return appServices.appearanceService().getDockBorderRounding(); } public void setStage(Stage stage) { this.stage = stage; this.stage.setOnHidden(event -> { appServices.localizationService().removeListener(localizationListener); windowPreviewExecutor.shutdownNow(); openStateExecutor.shutdownNow(); }); } public String getDockColorRGB() { return appServices.appearanceService().getDockColorRGB(); } public void setDockColorRGB(String value) { appServices.appearanceService().setDockColorRGB(value); updateDockUI(); } public void saveChanges() { appServices.dockService().saveChanges(); } public void setAppServices(AppServices appServices) { this.appServices = appServices; } private void handlePositioningModeChange(DockPositioningMode positioningMode) { DockPositioningMode currentMode = appServices.positioningService().getPositioningMode(); if (currentMode == DockPositioningMode.STATIC && positioningMode == DockPositioningMode.DYNAMIC) { appServices.dockService().setDockPosition(stage.getX(), stage.getY()); } appServices.positioningService().setPositioningMode(positioningMode); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/controller/SettingsController.java ================================================ package com.github.arthurdeka.cedromoderndock.controller; import com.github.arthurdeka.cedromoderndock.App; import com.github.arthurdeka.cedromoderndock.application.AppServices; import com.github.arthurdeka.cedromoderndock.application.ProgramSelectionResolver; import com.github.arthurdeka.cedromoderndock.application.SupportedLanguage; import com.github.arthurdeka.cedromoderndock.model.DockHorizontalAnchor; import com.github.arthurdeka.cedromoderndock.model.DockItem; import com.github.arthurdeka.cedromoderndock.model.DockFolderItemModel; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import com.github.arthurdeka.cedromoderndock.model.DockProgramItemModel; import com.github.arthurdeka.cedromoderndock.model.DockSettingsItemModel; import com.github.arthurdeka.cedromoderndock.model.DockVerticalAnchor; import com.github.arthurdeka.cedromoderndock.util.ColorManipulation; import com.github.arthurdeka.cedromoderndock.util.Logger; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ChoiceBox; import javafx.scene.control.ColorPicker; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.RadioButton; import javafx.scene.control.Slider; import javafx.scene.control.Tab; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.StringConverter; import java.io.File; import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.function.Consumer; import static com.github.arthurdeka.cedromoderndock.util.UIUtils.setStageIcon; public class SettingsController { private static final double LIST_VIEW_CELL_HEIGHT = 40; private static final double LIST_VIEW_MAX_HEIGHT = 200; @FXML private Label mainTitleLabel; @FXML private Label mainSubtitleLabel; @FXML private Label languageLabel; @FXML private ChoiceBox languageChoiceBox; @FXML private Tab iconsTab; @FXML private Tab iconsCustomizationTab; @FXML private Tab dockCustomizationTab; @FXML private Tab dockPositioningTab; @FXML private Tab generalTab; @FXML private ListView listView; @FXML private Label dockItemsTitleLabel; @FXML private Label dockItemsHelperLabel; @FXML private Label actionsTitleLabel; @FXML private Label actionsHelperLabel; @FXML private Button addProgramButton; @FXML private Button addFolderButton; @FXML private Button addWindowsModuleButton; @FXML private Button removeProgramButton; @FXML private Button moveItemUpButton; @FXML private Button moveItemDownButton; @FXML private Slider iconSizeSlider; @FXML private Slider spacingBetweenIconsSlider; @FXML private Label iconsSizeTitleLabel; @FXML private Label iconsSizeHelperLabel; @FXML private Label spacingTitleLabel; @FXML private Label spacingHelperLabel; @FXML private Slider dockTransparencySlider; @FXML private Slider dockBorderRoundingSlider; @FXML private ColorPicker dockColorPicker; @FXML private Label transparencyTitleLabel; @FXML private Label transparencyHelperLabel; @FXML private Label roundingTitleLabel; @FXML private Label roundingHelperLabel; @FXML private Label backgroundColorTitleLabel; @FXML private Label backgroundColorHelperLabel; @FXML private RadioButton staticPositioningRadio; @FXML private RadioButton dynamicPositioningRadio; @FXML private ChoiceBox verticalPositionChoiceBox; @FXML private ChoiceBox horizontalPositionChoiceBox; @FXML private Slider topSpacingSlider; @FXML private Slider leftSpacingSlider; @FXML private Slider rightSpacingSlider; @FXML private Slider bottomSpacingSlider; @FXML private VBox staticPositioningPane; @FXML private VBox dynamicPositioningPane; @FXML private Label positioningModeTitleLabel; @FXML private Label positioningModeHelperLabel; @FXML private Label alignmentTitleLabel; @FXML private Label verticalLabel; @FXML private Label horizontalLabel; @FXML private Label screenSpacingTitleLabel; @FXML private Label topSpacingLabel; @FXML private Label leftSpacingLabel; @FXML private Label rightSpacingLabel; @FXML private Label bottomSpacingLabel; @FXML private Label dynamicPositioningTitleLabel; @FXML private Label dynamicPositioningHelperLabel; @FXML private Label versionLabel; @FXML private Label repositoryLabel; @FXML private Label contactLabel; @FXML private Label openSourceLabel; @FXML private Button acknowledgementsButton; private final ObservableList listItems = FXCollections.observableArrayList(); private final Runnable localizationListener = this::handleLocalizationChanged; private boolean suppressionEnabled; private boolean localizationRegistered; private boolean cleanupRegistered; private AppServices appServices; private Runnable dockRefreshAction = () -> {}; private Consumer positioningModeChangeAction = positioningMode -> {}; public void initialize() { Logger.info("[Initializing] SettingsController"); javafx.scene.control.ToggleGroup positioningModeGroup = new javafx.scene.control.ToggleGroup(); staticPositioningRadio.setToggleGroup(positioningModeGroup); dynamicPositioningRadio.setToggleGroup(positioningModeGroup); listView.setFixedCellSize(LIST_VIEW_CELL_HEIGHT); listView.sceneProperty().addListener((observableValue, oldScene, newScene) -> { if (newScene == null) { return; } newScene.windowProperty().addListener((windowObservable, oldWindow, newWindow) -> { if (newWindow == null) { return; } updateWindowTitle(); if (!cleanupRegistered) { cleanupRegistered = true; newWindow.addEventHandler(WindowEvent.WINDOW_HIDDEN, event -> unregisterLocalizationListener()); } }); }); } public void handleInitialization() { registerLocalization(); configureLocalizationControls(); addDockItemsToListView(appServices.dockService().getItems()); listView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> handleListViewItemSelection()); iconSizeSlider.setValue(appServices.appearanceService().getIconsSize()); iconSizeSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> handleSetIconSizeSlider((int) iconSizeSlider.getValue())); spacingBetweenIconsSlider.setValue(appServices.appearanceService().getSpacingBetweenIcons()); spacingBetweenIconsSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> handleSetIconsSpacingSlider((int) spacingBetweenIconsSlider.getValue())); dockTransparencySlider.setValue(appServices.appearanceService().getDockTransparencyPercentage()); dockTransparencySlider.valueProperty().addListener((observableValue, oldValue, newValue) -> handleSetDockTransparencySlider((int) dockTransparencySlider.getValue())); dockBorderRoundingSlider.setValue(appServices.appearanceService().getDockBorderRounding()); dockBorderRoundingSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> handleSetDockBorderRoundingSlider((int) dockBorderRoundingSlider.getValue())); Color rgbaColor = ColorManipulation.fromRGBtoRGBA(appServices.appearanceService().getDockColorRGB()); dockColorPicker.setValue(rgbaColor); initializePositioningControls(); applyLocalizedTexts(); } private void registerLocalization() { if (!localizationRegistered) { appServices.localizationService().addListener(localizationListener); localizationRegistered = true; } } private void unregisterLocalizationListener() { if (appServices != null && localizationRegistered) { appServices.localizationService().removeListener(localizationListener); localizationRegistered = false; } } private void configureLocalizationControls() { languageChoiceBox.setConverter(new StringConverter<>() { @Override public String toString(SupportedLanguage language) { return language == null ? "" : appServices.localizationService().languageDisplayName(language); } @Override public SupportedLanguage fromString(String string) { return appServices.localizationService().getCurrentLanguage(); } }); verticalPositionChoiceBox.setConverter(new StringConverter<>() { @Override public String toString(DockVerticalAnchor anchor) { return anchor == null ? "" : verticalAnchorText(anchor); } @Override public DockVerticalAnchor fromString(String string) { return DockVerticalAnchor.TOP; } }); horizontalPositionChoiceBox.setConverter(new StringConverter<>() { @Override public String toString(DockHorizontalAnchor anchor) { return anchor == null ? "" : horizontalAnchorText(anchor); } @Override public DockHorizontalAnchor fromString(String string) { return DockHorizontalAnchor.LEFT; } }); languageChoiceBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { if (suppressionEnabled || newValue == null) { return; } appServices.localizationService().setLanguage(newValue); dockRefreshAction.run(); }); } private void initializePositioningControls() { DockPositioningMode positioningMode = appServices.positioningService().getPositioningMode(); if (positioningMode == DockPositioningMode.DYNAMIC) { dynamicPositioningRadio.setSelected(true); } else { staticPositioningRadio.setSelected(true); } verticalPositionChoiceBox.setValue(appServices.positioningService().getVerticalAnchor()); horizontalPositionChoiceBox.setValue(appServices.positioningService().getHorizontalAnchor()); topSpacingSlider.setValue(appServices.positioningService().getTopSpacing()); leftSpacingSlider.setValue(appServices.positioningService().getLeftSpacing()); rightSpacingSlider.setValue(appServices.positioningService().getRightSpacing()); bottomSpacingSlider.setValue(appServices.positioningService().getBottomSpacing()); verticalPositionChoiceBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { if (suppressionEnabled || newValue == null) { return; } appServices.positioningService().setVerticalAnchor(newValue); dockRefreshAction.run(); }); horizontalPositionChoiceBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { if (suppressionEnabled || newValue == null) { return; } appServices.positioningService().setHorizontalAnchor(newValue); dockRefreshAction.run(); }); topSpacingSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { appServices.positioningService().setTopSpacing((int) Math.round(newValue.doubleValue())); dockRefreshAction.run(); }); leftSpacingSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { appServices.positioningService().setLeftSpacing((int) Math.round(newValue.doubleValue())); dockRefreshAction.run(); }); rightSpacingSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { appServices.positioningService().setRightSpacing((int) Math.round(newValue.doubleValue())); dockRefreshAction.run(); }); bottomSpacingSlider.valueProperty().addListener((observableValue, oldValue, newValue) -> { appServices.positioningService().setBottomSpacing((int) Math.round(newValue.doubleValue())); dockRefreshAction.run(); }); updatePositioningModeUI(); } @FXML private void handlePositioningModeChange() { DockPositioningMode positioningMode = staticPositioningRadio.isSelected() ? DockPositioningMode.STATIC : DockPositioningMode.DYNAMIC; positioningModeChangeAction.accept(positioningMode); updatePositioningModeUI(); dockRefreshAction.run(); } private void updatePositioningModeUI() { boolean isStaticMode = staticPositioningRadio.isSelected(); staticPositioningPane.setVisible(isStaticMode); staticPositioningPane.setManaged(isStaticMode); dynamicPositioningPane.setVisible(!isStaticMode); dynamicPositioningPane.setManaged(!isStaticMode); } private void handleListViewItemSelection() { int selectedIdx = listView.getSelectionModel().getSelectedIndex(); if (selectedIdx < 0) { removeProgramButton.setDisable(true); moveItemUpButton.setDisable(true); moveItemDownButton.setDisable(true); return; } DockItem item = appServices.dockService().getItems().get(selectedIdx); removeProgramButton.setDisable(item instanceof DockSettingsItemModel); moveItemUpButton.setDisable(selectedIdx == 0); moveItemDownButton.setDisable(selectedIdx == listItems.size() - 1); } private void addDockItemsToListView(List dockItems) { listItems.clear(); for (DockItem item : dockItems) { String label = appServices.localizationService().dockItemLabel(item); listItems.add(label); Logger.info("[Initializing][listView] Adding item to ListView: " + label); } listView.setItems(listItems); updateListViewHeight(); } private void updateListViewHeight() { int visibleRows = Math.max(1, listItems.size()); double contentHeight = visibleRows * listView.getFixedCellSize() + 2; double boundedHeight = Math.min(contentHeight, LIST_VIEW_MAX_HEIGHT); listView.setMinHeight(boundedHeight); listView.setPrefHeight(boundedHeight); listView.setMaxHeight(LIST_VIEW_MAX_HEIGHT); } @FXML private void openAddWindowsModuleWindow() { try { Stage currentStage = (Stage) listView.getScene().getWindow(); FXMLLoader loader = new FXMLLoader(App.class.getResource("fxml/AddWindowsModulesModalView.fxml")); Parent root = loader.load(); AddWindowsModulesModalController addWindowsModulesModalController = loader.getController(); addWindowsModulesModalController.setAppServices(appServices); addWindowsModulesModalController.setDockRefreshAction(dockRefreshAction); addWindowsModulesModalController.setPositioningModeChangeAction(positioningModeChangeAction); addWindowsModulesModalController.handleInitialization(); Stage stage = new Stage(); stage.setTitle(text("windowsModule.modal.title")); setStageIcon(stage); stage.setScene(new Scene(root)); stage.show(); currentStage.close(); } catch (Exception e) { throw new RuntimeException(e); } } @FXML private void handleAddProgram() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(text("dialog.fileChooser.executableTitle")); fileChooser.getExtensionFilters().add( new FileChooser.ExtensionFilter(text("dialog.fileChooser.executableFilter"), "*.exe") ); File file = fileChooser.showOpenDialog(null); if (file != null) { ProgramSelectionResolver.ResolvedProgramSelection selection = ProgramSelectionResolver.resolve(Path.of(file.getAbsolutePath())); String selectedExePath = selection.executablePath(); String selectedExeName = selection.label(); appServices.iconGateway().cacheProgramIcon(selectedExePath); DockItem newItem = new DockProgramItemModel(selectedExeName, selectedExePath); appServices.dockService().addItem(newItem); Logger.info("[listView] Program added: " + selectedExeName); } addDockItemsToListView(appServices.dockService().getItems()); dockRefreshAction.run(); } @FXML private void handleAddFolder() { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(text("dialog.directoryChooser.title")); Stage owner = (Stage) listView.getScene().getWindow(); File selectedFolder = directoryChooser.showDialog(owner); if (selectedFolder == null || !selectedFolder.isDirectory()) { return; } String folderPath = selectedFolder.getAbsolutePath(); String folderName = selectedFolder.getName(); String label = (folderName == null || folderName.isBlank()) ? folderPath : folderName; appServices.iconGateway().cacheFolderIcon(folderPath); DockItem newItem = new DockFolderItemModel(label, folderPath); appServices.dockService().addItem(newItem); Logger.info("[listView] Folder added: " + label); addDockItemsToListView(appServices.dockService().getItems()); dockRefreshAction.run(); } @FXML private void handleRemoveProgram() { int selectedIdx = listView.getSelectionModel().getSelectedIndex(); Logger.info("[listView] Removing item on index: " + selectedIdx); appServices.dockService().removeItem(selectedIdx); addDockItemsToListView(appServices.dockService().getItems()); dockRefreshAction.run(); } @FXML private void handleMoveItem(ActionEvent event) { int selectedIdx = listView.getSelectionModel().getSelectedIndex(); if (selectedIdx < 0) { return; } int newSelectedIdx = selectedIdx; if (event.getSource() == moveItemUpButton) { if (selectedIdx == 0) { return; } Logger.info("[listView] moving item up"); Collections.swap(listItems, selectedIdx, selectedIdx - 1); appServices.dockService().swapItems(selectedIdx, selectedIdx - 1); newSelectedIdx = selectedIdx - 1; } else { if (selectedIdx >= listItems.size() - 1) { return; } Logger.info("[listView] moving item down"); Collections.swap(listItems, selectedIdx, selectedIdx + 1); appServices.dockService().swapItems(selectedIdx, selectedIdx + 1); newSelectedIdx = selectedIdx + 1; } addDockItemsToListView(appServices.dockService().getItems()); listView.getSelectionModel().select(newSelectedIdx); handleListViewItemSelection(); dockRefreshAction.run(); } private void handleSetIconSizeSlider(int value) { appServices.appearanceService().setIconsSize(value); dockRefreshAction.run(); } private void handleSetIconsSpacingSlider(int value) { appServices.appearanceService().setSpacingBetweenIcons(value); dockRefreshAction.run(); } private void handleSetDockTransparencySlider(int value) { appServices.appearanceService().setDockTransparencyPercentage(value); dockRefreshAction.run(); } private void handleSetDockBorderRoundingSlider(int value) { appServices.appearanceService().setDockBorderRounding(value); dockRefreshAction.run(); } @FXML private void handleSetDockColor() { String rgbaColor = String.valueOf(dockColorPicker.getValue()); String rgbColor = ColorManipulation.fromRGBAtoRGB(rgbaColor); appServices.appearanceService().setDockColorRGB(rgbColor); dockRefreshAction.run(); } public void setAppServices(AppServices appServices) { this.appServices = appServices; } public void setDockRefreshAction(Runnable dockRefreshAction) { this.dockRefreshAction = dockRefreshAction; } public void setPositioningModeChangeAction(Consumer positioningModeChangeAction) { this.positioningModeChangeAction = positioningModeChangeAction; } @FXML private void openAknowledgementsWindow() { try { FXMLLoader loader = new FXMLLoader(App.class.getResource("fxml/AcknowledgementsModalView.fxml")); Parent root = loader.load(); AcknowledgementsModalController controller = loader.getController(); controller.setAppServices(appServices); controller.handleInitialization(); Stage stage = new Stage(); stage.setTitle(text("acknowledgements.window.title")); setStageIcon(stage); stage.setScene(new Scene(root)); stage.show(); } catch (Exception e) { throw new RuntimeException(e); } } private void handleLocalizationChanged() { applyLocalizedTexts(); addDockItemsToListView(appServices.dockService().getItems()); handleListViewItemSelection(); } private void applyLocalizedTexts() { if (appServices == null) { return; } suppressionEnabled = true; languageChoiceBox.setItems(FXCollections.observableArrayList(SupportedLanguage.values())); languageChoiceBox.setValue(appServices.localizationService().getCurrentLanguage()); verticalPositionChoiceBox.setItems(FXCollections.observableArrayList(DockVerticalAnchor.values())); verticalPositionChoiceBox.setValue(appServices.positioningService().getVerticalAnchor()); horizontalPositionChoiceBox.setItems(FXCollections.observableArrayList(DockHorizontalAnchor.values())); horizontalPositionChoiceBox.setValue(appServices.positioningService().getHorizontalAnchor()); suppressionEnabled = false; mainTitleLabel.setText(text("settings.page.title")); mainSubtitleLabel.setText(text("settings.page.subtitle")); languageLabel.setText(text("settings.language.label")); iconsTab.setText(text("settings.tab.icons")); iconsCustomizationTab.setText(text("settings.tab.iconsCustomization")); dockCustomizationTab.setText(text("settings.tab.dockCustomization")); dockPositioningTab.setText(text("settings.tab.dockPositioning")); generalTab.setText(text("settings.tab.general")); dockItemsTitleLabel.setText(text("settings.icons.items.title")); dockItemsHelperLabel.setText(text("settings.icons.items.helper")); actionsTitleLabel.setText(text("settings.icons.actions.title")); actionsHelperLabel.setText(text("settings.icons.actions.helper")); moveItemUpButton.setText(text("settings.icons.moveUp")); moveItemDownButton.setText(text("settings.icons.moveDown")); addProgramButton.setText(text("settings.icons.addProgram")); addFolderButton.setText(text("settings.icons.addFolder")); addWindowsModuleButton.setText(text("settings.icons.addWindowsModule")); removeProgramButton.setText(text("settings.icons.removeSelected")); iconsSizeTitleLabel.setText(text("settings.iconsCustomization.size.title")); iconsSizeHelperLabel.setText(text("settings.iconsCustomization.size.helper")); spacingTitleLabel.setText(text("settings.iconsCustomization.spacing.title")); spacingHelperLabel.setText(text("settings.iconsCustomization.spacing.helper")); transparencyTitleLabel.setText(text("settings.dockCustomization.transparency.title")); transparencyHelperLabel.setText(text("settings.dockCustomization.transparency.helper")); roundingTitleLabel.setText(text("settings.dockCustomization.rounding.title")); roundingHelperLabel.setText(text("settings.dockCustomization.rounding.helper")); backgroundColorTitleLabel.setText(text("settings.dockCustomization.background.title")); backgroundColorHelperLabel.setText(text("settings.dockCustomization.background.helper")); positioningModeTitleLabel.setText(text("settings.positioning.mode.title")); positioningModeHelperLabel.setText(text("settings.positioning.mode.helper")); staticPositioningRadio.setText(text("settings.positioning.mode.static")); dynamicPositioningRadio.setText(text("settings.positioning.mode.dynamic")); alignmentTitleLabel.setText(text("settings.positioning.alignment.title")); verticalLabel.setText(text("settings.positioning.alignment.vertical")); horizontalLabel.setText(text("settings.positioning.alignment.horizontal")); screenSpacingTitleLabel.setText(text("settings.positioning.spacing.title")); topSpacingLabel.setText(text("settings.positioning.spacing.top")); leftSpacingLabel.setText(text("settings.positioning.spacing.left")); rightSpacingLabel.setText(text("settings.positioning.spacing.right")); bottomSpacingLabel.setText(text("settings.positioning.spacing.down")); dynamicPositioningTitleLabel.setText(text("settings.positioning.dynamic.title")); dynamicPositioningHelperLabel.setText(text("settings.positioning.dynamic.helper")); versionLabel.setText(text("settings.general.version")); repositoryLabel.setText(text("settings.general.repository")); contactLabel.setText(text("settings.general.contact")); openSourceLabel.setText(text("settings.general.openSource")); acknowledgementsButton.setText(text("settings.general.acknowledgements")); updateWindowTitle(); } private void updateWindowTitle() { if (listView.getScene() != null && listView.getScene().getWindow() instanceof Stage stage && appServices != null) { stage.setTitle(text("settings.window.title")); } } private String verticalAnchorText(DockVerticalAnchor verticalAnchor) { return switch (verticalAnchor) { case TOP -> text("settings.positioning.choice.top"); case MIDDLE -> text("settings.positioning.choice.middle"); case DOWN -> text("settings.positioning.choice.down"); }; } private String horizontalAnchorText(DockHorizontalAnchor horizontalAnchor) { return switch (horizontalAnchor) { case LEFT -> text("settings.positioning.choice.left"); case MIDDLE -> text("settings.positioning.choice.middle"); case RIGHT -> text("settings.positioning.choice.right"); }; } private String text(String key) { return appServices.localizationService().text(key); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/DockRepository.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; import com.github.arthurdeka.cedromoderndock.model.DockModel; public interface DockRepository { DockModel load(); void save(DockModel model); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/FolderLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; public interface FolderLauncher { void launch(String folderPath, String label); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/IconGateway.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; import java.nio.file.Path; public interface IconGateway { Path resolveProgramIcon(String executablePath); Path resolveFolderIcon(String folderPath); void cacheProgramIcon(String executablePath); void cacheFolderIcon(String folderPath); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/ProgramLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; public interface ProgramLauncher { void launch(String executablePath, String label); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/WindowQueryGateway.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; import com.github.arthurdeka.cedromoderndock.util.NativeWindowUtils; import java.util.List; public interface WindowQueryGateway { List findOpenWindows(String executablePath); void activate(NativeWindowUtils.WindowInfo windowInfo); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/domain/WindowsModuleLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.domain; public interface WindowsModuleLauncher { void launch(String module, String label); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/persistence/JsonDockRepository.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.persistence; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.github.arthurdeka.cedromoderndock.domain.DockRepository; import com.github.arthurdeka.cedromoderndock.model.DockModel; import com.github.arthurdeka.cedromoderndock.util.Logger; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; public final class JsonDockRepository implements DockRepository { private static final String CONFIG_FILE_NAME = "config.json"; private final Path configFilePath; private final ObjectMapper mapper; public JsonDockRepository() { this(getDefaultConfigPath()); } public JsonDockRepository(Path configFilePath) { this.configFilePath = configFilePath; this.mapper = createObjectMapper(); } private static Path getDefaultConfigPath() { String appDataPath = System.getenv("APPDATA"); if (appDataPath == null || appDataPath.isEmpty()) { appDataPath = System.getProperty("user.home"); } Path configDir = Paths.get(appDataPath, "CedroModernDock"); File dir = configDir.toFile(); if (!dir.exists()) { dir.mkdirs(); } return configDir.resolve(CONFIG_FILE_NAME); } private static ObjectMapper createObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); return objectMapper; } @Override public void save(DockModel model) { try { mapper.writeValue(configFilePath.toFile(), model); } catch (IOException e) { Logger.error("Error saving the DockModel: " + e.getMessage()); e.printStackTrace(); } } @Override public DockModel load() { File configFile = configFilePath.toFile(); if (configFile.exists() && configFile.length() > 0) { try { DockModel model = mapper.readValue(configFile, DockModel.class); Logger.info("[JsonDockRepository] Dock config.json loaded successfully from: " + configFilePath); return model; } catch (IOException e) { Logger.error("Error reading config.json, creating a new default config file: " + e.getMessage()); return createAndSaveDefault(); } } Logger.error("config.json not found or is empty. Creating a new default config file at: " + configFilePath); return createAndSaveDefault(); } private DockModel createAndSaveDefault() { DockModel model = new DockModel(); model.loadDefaultItems(); save(model); return model; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/system/CachedWindowsIconGateway.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.system; import com.github.arthurdeka.cedromoderndock.domain.IconGateway; import com.github.arthurdeka.cedromoderndock.util.WindowsIconHandler; import java.nio.file.Path; public class CachedWindowsIconGateway implements IconGateway { @Override public Path resolveProgramIcon(String executablePath) { return WindowsIconHandler.getCachedIconPath(executablePath); } @Override public Path resolveFolderIcon(String folderPath) { return WindowsIconHandler.getCachedFolderIconPath(folderPath); } @Override public void cacheProgramIcon(String executablePath) { WindowsIconHandler.extractAndCacheIcon(executablePath); } @Override public void cacheFolderIcon(String folderPath) { WindowsIconHandler.extractAndCacheFolderIcon(folderPath); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/system/DefaultFolderLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.system; import com.github.arthurdeka.cedromoderndock.domain.FolderLauncher; import com.github.arthurdeka.cedromoderndock.util.Logger; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; public class DefaultFolderLauncher implements FolderLauncher { @Override public void launch(String folderPath, String label) { Logger.info(label + " Clicked"); if (folderPath == null || folderPath.trim().isEmpty()) { Logger.error("Folder path not defined for: " + label); return; } Path path = Path.of(folderPath); if (!Files.isDirectory(path)) { Logger.error("Folder path is invalid: " + folderPath); return; } try { new ProcessBuilder("explorer.exe", folderPath).start(); Logger.info("Opening folder: " + label); } catch (IOException e) { Logger.error("Failed to open folder: " + label); Logger.error("Path: " + folderPath); Logger.error("Error: " + e.getMessage()); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/system/DefaultProgramLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.system; import com.github.arthurdeka.cedromoderndock.domain.ProgramLauncher; import com.github.arthurdeka.cedromoderndock.util.Logger; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Locale; public class DefaultProgramLauncher implements ProgramLauncher { @Override public void launch(String executablePath, String label) { Logger.info(label + " Clicked"); if (executablePath == null || executablePath.trim().isEmpty()) { Logger.error("Executable path not defined for: " + label); return; } try { executeAndHandleElevation(executablePath, label); } catch (IOException e) { Logger.error("Failed to open: " + label); Logger.error("Path: " + executablePath); Logger.error("Error: " + e.getMessage()); } catch (InterruptedException e) { Logger.error("Process interrupted: " + e.getMessage()); throw new RuntimeException(e); } } private void executeAndHandleElevation(String path, String label) throws IOException, InterruptedException { LaunchCommand launchCommand = resolveLaunchCommand(path); try { new ProcessBuilder(launchCommand.toCommandLine()).start(); Logger.info("Executing: " + label); } catch (IOException e) { if (e.getMessage() != null && e.getMessage().contains("error=740")) { Logger.info("Standard execution failed. Requesting elevation..."); String command = buildElevationCommand(launchCommand); new ProcessBuilder("powershell.exe", "-Command", command).start(); Logger.info("(Elevated) Executing: " + label); } else { Logger.error("Error trying to execute program"); throw e; } } } static LaunchCommand resolveLaunchCommand(String executablePath) { Path normalizedPath = Path.of(executablePath).toAbsolutePath().normalize(); if (isDiscordExecutable(normalizedPath)) { Path installDirectory = normalizedPath.getParent() == null ? null : normalizedPath.getParent().getParent(); if (installDirectory != null) { Path updateExecutable = installDirectory.resolve("Update.exe"); if (Files.isRegularFile(updateExecutable)) { return new LaunchCommand( updateExecutable.toString(), List.of("--processStart", normalizedPath.getFileName().toString()) ); } } } return new LaunchCommand(normalizedPath.toString(), List.of()); } private static boolean isDiscordExecutable(Path executablePath) { Path fileName = executablePath.getFileName(); Path versionDirectory = executablePath.getParent(); Path installDirectory = versionDirectory == null ? null : versionDirectory.getParent(); if (fileName == null || versionDirectory == null || installDirectory == null) { return false; } return fileName.toString().equalsIgnoreCase("Discord.exe") && versionDirectory.getFileName() != null && versionDirectory.getFileName().toString().toLowerCase(Locale.ROOT).startsWith("app-") && installDirectory.getFileName() != null && installDirectory.getFileName().toString().equalsIgnoreCase("Discord"); } private static String buildElevationCommand(LaunchCommand launchCommand) { String escapedFilePath = escapePowerShellArgument(launchCommand.executablePath()); if (launchCommand.arguments().isEmpty()) { return "Start-Process -FilePath '" + escapedFilePath + "' -Verb RunAs"; } String escapedArguments = launchCommand.arguments().stream() .map(DefaultProgramLauncher::escapePowerShellArgument) .map(argument -> "'" + argument + "'") .reduce((first, second) -> first + ", " + second) .orElse(""); return "Start-Process -FilePath '" + escapedFilePath + "' -ArgumentList " + escapedArguments + " -Verb RunAs"; } private static String escapePowerShellArgument(String argument) { return argument.replace("'", "''"); } record LaunchCommand(String executablePath, List arguments) { List toCommandLine() { if (arguments.isEmpty()) { return List.of(executablePath); } java.util.ArrayList command = new java.util.ArrayList<>(); command.add(executablePath); command.addAll(arguments); return command; } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/system/DefaultWindowsModuleLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.system; import com.github.arthurdeka.cedromoderndock.domain.WindowsModuleLauncher; import com.github.arthurdeka.cedromoderndock.util.Logger; import java.io.IOException; import java.util.Objects; public class DefaultWindowsModuleLauncher implements WindowsModuleLauncher { @Override public void launch(String module, String label) { try { if (Objects.equals(module, "mypc")) { new ProcessBuilder("explorer.exe", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}").start(); } else if (Objects.equals(module, "trash")) { new ProcessBuilder("explorer.exe", "::{645FF040-5081-101B-9F08-00AA002F954E}").start(); } else if (Objects.equals(module, "ctrlpnl")) { new ProcessBuilder("control.exe").start(); } else if (Objects.equals(module, "pconfig")) { new ProcessBuilder("cmd", "/c", "start", "ms-settings:").start(); } } catch (IOException e) { throw new RuntimeException(e); } Logger.info(label + " Clicked"); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/infrastructure/system/JnaWindowQueryGateway.java ================================================ package com.github.arthurdeka.cedromoderndock.infrastructure.system; import com.github.arthurdeka.cedromoderndock.domain.WindowQueryGateway; import com.github.arthurdeka.cedromoderndock.util.NativeWindowUtils; import java.util.List; public class JnaWindowQueryGateway implements WindowQueryGateway { @Override public List findOpenWindows(String executablePath) { return NativeWindowUtils.getOpenWindows(executablePath); } @Override public void activate(NativeWindowUtils.WindowInfo windowInfo) { NativeWindowUtils.activateWindow(windowInfo.hwnd()); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockFolderItemModel.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.NoArgsConstructor; @NoArgsConstructor public class DockFolderItemModel implements DockItem { private String label = ""; private String folderPath = ""; public DockFolderItemModel(String label, String folderPath) { this.label = label; this.folderPath = folderPath; } @Override public String getLabel() { return label; } @Override public String getPath() { return folderPath; } @JsonIgnore public String getFolderPath() { return folderPath; } @Override public DockItemType getType() { return DockItemType.FOLDER; } @Override public void setLabel(String label) { this.label = label; } @Override public void setPath(String path) { this.folderPath = path; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockHorizontalAnchor.java ================================================ package com.github.arthurdeka.cedromoderndock.model; public enum DockHorizontalAnchor { LEFT, MIDDLE, RIGHT } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockItem.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; /* * Those annotations are needed for the Serialization Library (Jackson) to work properly * */ @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type" ) @JsonSubTypes({ @JsonSubTypes.Type(value = DockProgramItemModel.class, name = "programItem"), @JsonSubTypes.Type(value = DockFolderItemModel.class, name = "folderItem"), @JsonSubTypes.Type(value = DockWindowsModuleItemModel.class, name = "windowsModuleItem"), @JsonSubTypes.Type(value = DockSettingsItemModel.class, name = "settingsItem") }) public interface DockItem { String getLabel(); String getPath(); @JsonIgnore DockItemType getType(); void setLabel(String label); void setPath(String path); } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockItemType.java ================================================ package com.github.arthurdeka.cedromoderndock.model; public enum DockItemType { PROGRAM, FOLDER, WINDOWS_MODULE, SETTINGS } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockModel.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import com.github.arthurdeka.cedromoderndock.application.SupportedLanguage; import lombok.Getter; import lombok.Setter; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class DockModel { @Getter private List items = new ArrayList<>(); private int iconsSize = 24; private int spacingBetweenIcons = 0; private double dockTransparency = 0.3; @Setter @Getter private int dockBorderRounding = 10; @Setter @Getter private String dockColorRGB = "0, 0, 0, "; @Getter private double dockPositionX; @Getter private double dockPositionY; @Getter @Setter private DockPositioningMode positioningMode = DockPositioningMode.STATIC; @Getter @Setter private DockVerticalAnchor verticalAnchor = DockVerticalAnchor.TOP; @Getter @Setter private DockHorizontalAnchor horizontalAnchor = DockHorizontalAnchor.MIDDLE; @Getter @Setter private int topSpacing = 20; @Getter @Setter private int leftSpacing = 20; @Getter @Setter private int rightSpacing = 20; @Getter @Setter private int bottomSpacing = 20; @Getter @Setter private SupportedLanguage language = SupportedLanguage.EN_US; public void addItem(DockItem item) { items.add(item); } public void removeItem(int index) { items.remove(index); } public void loadDefaultItems() { items.add(new DockSettingsItemModel()); } public void swapItems(int firstItemIdx, int secondItemIdx) { Collections.swap(items, firstItemIdx, secondItemIdx); } public Integer getIconsSize() { return iconsSize; } public void setIconsSize(Integer iconsSize) { this.iconsSize = iconsSize; } public Integer getSpacingBetweenIcons() { return spacingBetweenIcons; } public void setSpacingBetweenIcons(Integer spacingBetweenIcons) { this.spacingBetweenIcons = spacingBetweenIcons; } public Double getDockTransparency() { return dockTransparency; } public void setDockTransparency(Double dockTransparency) { this.dockTransparency = dockTransparency; } public void setDockPosition(Double PositionX, Double PositionY) { this.dockPositionX = PositionX; this.dockPositionY = PositionY; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockPositioningMode.java ================================================ package com.github.arthurdeka.cedromoderndock.model; public enum DockPositioningMode { STATIC, DYNAMIC } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockProgramItemModel.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.NoArgsConstructor; @NoArgsConstructor public class DockProgramItemModel implements DockItem { private String label = ""; private String exePath = ""; public DockProgramItemModel(String label, String exePath) { this.label = label; this.exePath = exePath; } @Override public String getLabel() { return label; } @Override public String getPath() { return exePath; } @JsonIgnore public String getExecutablePath() { return exePath; } @Override public DockItemType getType() { return DockItemType.PROGRAM; } @Override public void setLabel(String label) { this.label = label; } @Override public void setPath(String path) { this.exePath = path; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockSettingsItemModel.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import lombok.NoArgsConstructor; @NoArgsConstructor public class DockSettingsItemModel implements DockItem{ private String label = "Settings"; private String iconPath = "/com/github/arthurdeka/cedromoderndock/icons/settings.png"; @Override public String getLabel() { return label; } @Override public String getPath() { return iconPath; } @Override public DockItemType getType() { return DockItemType.SETTINGS; } @Override public void setLabel(String label) { this.label = label; } @Override public void setPath(String path) { this.iconPath = path; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockVerticalAnchor.java ================================================ package com.github.arthurdeka.cedromoderndock.model; public enum DockVerticalAnchor { TOP, MIDDLE, DOWN } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/model/DockWindowsModuleItemModel.java ================================================ package com.github.arthurdeka.cedromoderndock.model; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import java.util.Objects; @NoArgsConstructor public class DockWindowsModuleItemModel implements DockItem { private String label = ""; private String iconPath = ""; @Setter @Getter private String module = ""; public DockWindowsModuleItemModel(String label, String module) { if (Objects.equals(module, "mypc")) { this.iconPath = "/com/github/arthurdeka/cedromoderndock/icons/my_computer.png"; } else if (Objects.equals(module, "trash")) { this.iconPath = "/com/github/arthurdeka/cedromoderndock/icons/trash.png"; } else if (Objects.equals(module, "ctrlpnl")) { this.iconPath = "/com/github/arthurdeka/cedromoderndock/icons/control.png"; } else if (Objects.equals(module, "pconfig")) { this.iconPath = "/com/github/arthurdeka/cedromoderndock/icons/windows_settings.png"; } this.label = label; this.module = module; } @Override public String getLabel() { return label; } @Override public String getPath() { return iconPath; } @Override public DockItemType getType() { return DockItemType.WINDOWS_MODULE; } @Override public void setLabel(String label) { this.label = label; } @Override public void setPath(String path) { this.iconPath = path; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/ColorManipulation.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import javafx.scene.paint.Color; public class ColorManipulation { /* * This class exists to translate colors between the formats 0xAARRGGBB and RGB * Why? Because to apply the dock color, we use the RGB format * However, to get and set the color on the JavaFX ColorPicker, it will only accept 0xAARRGGBB * * if you know any better way to do this, I'm all ears * * */ public static String fromRGBAtoRGB(String RGBAColor) { Color color = Color.web(RGBAColor); int red = (int) (color.getRed() * 255); int green = (int) (color.getGreen() * 255); int blue = (int) (color.getBlue() * 255); String RGBcolor = red + ", " + green + ", " + blue + ", "; return RGBcolor; } public static Color fromRGBtoRGBA(String RGBColor) { // the expected format is String RGBColor = "255, 255, 255, " //removing , and extra spaces String[] rgbValues = RGBColor.trim().split(",\\s*"); int red = Integer.parseInt(rgbValues[0]); int green = Integer.parseInt(rgbValues[1]); int blue = Integer.parseInt(rgbValues[2]); // alpha is always 100% int alpha = 255; Color color = Color.rgb(red, green, blue); return color; } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/Logger.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; /** * Final utility class for application logging. * Provides static methods for informational and error logs. */ public final class Logger { private static final String LOG_FILE_NAME = "log.txt"; private static final Path LOG_FILE_PATH = getLogFilePath(); private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // Private constructor to prevent this utility class from being instantiated. private Logger() { } /** * Determines the absolute path for the log file in the user's * AppData/Roaming directory. * @return The absolute Path to the log file. */ private static Path getLogFilePath() { // Get the AppData\Roaming folder path (standard for user-specific data, same for config.json file) String appDataPath = System.getenv("APPDATA"); if (appDataPath == null || appDataPath.isEmpty()) { // Fallback to user home directory if APPDATA is not available appDataPath = System.getProperty("user.home"); } // Create a dedicated directory for our application to keep things clean Path configDir = Paths.get(appDataPath, "CedroModernDock"); // Ensure the directory exists File dir = configDir.toFile(); if (!dir.exists()) { dir.mkdirs(); } // Return the full path to our log file return configDir.resolve(LOG_FILE_NAME); } /** * Logs an informational message to the console. * The format includes the [INFO] log level. */ public static void info(String message) { System.out.println("[INFO] - " + message); } /** * Logs an error message to a log file (log.txt). * Messages are appended to the end of the file. */ public static void error(String message) { String timestamp = dtf.format(LocalDateTime.now()); String logMessage = String.format("[%s] [ERROR] %s", timestamp, message); // Prints a notification to the console that an error has been logged. System.err.println(logMessage + " | Check " + LOG_FILE_PATH + " for more details."); try (FileWriter fw = new FileWriter(LOG_FILE_PATH.toFile(), true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw)) { out.println(logMessage); out.println("----------------------------------------------------"); } catch (IOException e) { System.err.println("CRITICAL ERROR: Could not write to the log file."); e.printStackTrace(); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/NativeWindowUtils.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.ptr.IntByReference; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; public class NativeWindowUtils { // Minimal info required by the popup to activate and label a window. public record WindowInfo(HWND hwnd, String title) {} public static List getOpenWindows(String executablePath) { List windows = new ArrayList<>(); if (executablePath == null || executablePath.isEmpty()) { return windows; } // Normalize the target executable path so comparisons are stable. final Path targetPath = Paths.get(executablePath).toAbsolutePath().normalize(); User32.INSTANCE.EnumWindows((hWnd, arg1) -> { if (User32.INSTANCE.IsWindowVisible(hWnd)) { char[] buffer = new char[1024]; User32.INSTANCE.GetWindowText(hWnd, buffer, 1024); String title = new String(buffer).trim(); // Skip windows without title or hidden ones (some invisible windows report visible but have empty title/rect). if (title.isEmpty()) { return true; } // Keep only windows belonging to the executable path requested. if (isWindowFromExecutable(hWnd, targetPath)) { windows.add(new WindowInfo(hWnd, title)); } } return true; }, null); return windows; } private static boolean isWindowFromExecutable(HWND hWnd, Path targetPath) { IntByReference pidRef = new IntByReference(); User32.INSTANCE.GetWindowThreadProcessId(hWnd, pidRef); int pid = pidRef.getValue(); // Query the process image path to match it against the target executable. WinNT.HANDLE process = Kernel32.INSTANCE.OpenProcess( WinNT.PROCESS_QUERY_LIMITED_INFORMATION, false, pid ); if (process != null) { try { char[] pathBuffer = new char[1024]; IntByReference size = new IntByReference(pathBuffer.length); if (Kernel32.INSTANCE.QueryFullProcessImageName(process, 0, pathBuffer, size)) { String processPathStr = new String(pathBuffer, 0, size.getValue()); Path processPath = Paths.get(processPathStr).toAbsolutePath().normalize(); // Prefer full path match, but fall back to filename match for edge cases. if (isSameExecutable(processPath, targetPath)) { return true; } } } finally { Kernel32.INSTANCE.CloseHandle(process); } } return false; } private static boolean isSameExecutable(Path processPath, Path targetPath) { if (processPath == null || targetPath == null) { return false; } // Exact path match. if (processPath.equals(targetPath)) { return true; } // Case-insensitive path match (Windows path comparisons). String processStr = normalizePathString(processPath); String targetStr = normalizePathString(targetPath); if (processStr.equalsIgnoreCase(targetStr)) { return true; } // Fallback: match only the filename when the full path is not comparable. Path processFile = processPath.getFileName(); Path targetFile = targetPath.getFileName(); if (processFile != null && targetFile != null) { return processFile.toString().equalsIgnoreCase(targetFile.toString()); } return false; } private static String normalizePathString(Path path) { String value = path.toString(); // Strip Windows extended-length path prefix if present. if (value.startsWith("\\\\?\\")) { value = value.substring(4); } return value; } public static void activateWindow(HWND hwnd) { if (hwnd == null) return; // Restore window if minimized User32.INSTANCE.ShowWindow(hwnd, User32.SW_RESTORE); // Bring to front User32.INSTANCE.SetForegroundWindow(hwnd); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/SaveAndLoadDockSettings.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.github.arthurdeka.cedromoderndock.domain.DockRepository; import com.github.arthurdeka.cedromoderndock.infrastructure.persistence.JsonDockRepository; import com.github.arthurdeka.cedromoderndock.model.DockModel; /** * Utility class used to save and load the Dock's settings */ public final class SaveAndLoadDockSettings { private static final DockRepository REPOSITORY = new JsonDockRepository(); private SaveAndLoadDockSettings() {} /** * saves the DockModel object in the config file (config.json). * @param model DockModel object to be saved. */ public static void save(DockModel model) { REPOSITORY.save(model); } /** * This method loads the currennt config.json file and returns a DockModel. * If the file is corrupted or does not exist, a new one with only a DockSettings item is created and returned * * @return A DockModel instance, always valid (loaded or default). */ public static DockModel load() { return REPOSITORY.load(); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/SettingsWindowLauncher.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.github.arthurdeka.cedromoderndock.App; import com.github.arthurdeka.cedromoderndock.application.AppServices; import com.github.arthurdeka.cedromoderndock.controller.SettingsController; import com.github.arthurdeka.cedromoderndock.model.DockPositioningMode; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import java.util.function.Consumer; import static com.github.arthurdeka.cedromoderndock.util.UIUtils.setStageIcon; public final class SettingsWindowLauncher { private SettingsWindowLauncher() { } public static void open( AppServices appServices, Runnable dockRefreshAction, Consumer positioningModeChangeAction ) { try { FXMLLoader loader = new FXMLLoader(App.class.getResource("fxml/DockSettingsView.fxml")); Parent root = loader.load(); SettingsController settingsController = loader.getController(); settingsController.setAppServices(appServices); settingsController.setDockRefreshAction(dockRefreshAction); settingsController.setPositioningModeChangeAction(positioningModeChangeAction); settingsController.handleInitialization(); Stage stage = new Stage(); stage.setTitle(appServices.localizationService().text("settings.window.title")); setStageIcon(stage); stage.setScene(new Scene(root)); stage.show(); stage.setMinHeight(stage.getHeight()); stage.setMaxHeight(stage.getHeight()); } catch (Exception e) { throw new RuntimeException(e); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/SingleInstanceGuard.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public final class SingleInstanceGuard implements AutoCloseable { private static final String LOCK_FILE_NAME = "app.lock"; private final Path lockFilePath; private FileChannel channel; private FileLock lock; public SingleInstanceGuard() { this(getDefaultLockPath()); } public SingleInstanceGuard(Path lockFilePath) { this.lockFilePath = lockFilePath; } public boolean tryAcquire() { try { Path parent = lockFilePath.getParent(); if (parent != null) { Files.createDirectories(parent); } channel = FileChannel.open( lockFilePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE ); lock = channel.tryLock(); return lock != null; } catch (IOException e) { Logger.error("Failed to acquire single-instance lock: " + e.getMessage()); closeQuietly(); return false; } catch (OverlappingFileLockException e) { closeQuietly(); return false; } } @Override public void close() { closeQuietly(); } private void closeQuietly() { try { if (lock != null && lock.isValid()) { lock.release(); } } catch (IOException e) { Logger.error("Failed to release single-instance lock: " + e.getMessage()); } finally { lock = null; } try { if (channel != null && channel.isOpen()) { channel.close(); } } catch (IOException e) { Logger.error("Failed to close single-instance lock channel: " + e.getMessage()); } finally { channel = null; } } private static Path getDefaultLockPath() { String appDataPath = System.getenv("APPDATA"); if (appDataPath == null || appDataPath.isEmpty()) { appDataPath = System.getProperty("user.home"); } return Paths.get(appDataPath, "CedroModernDock", LOCK_FILE_NAME); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/SystemTrayManager.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.github.arthurdeka.cedromoderndock.App; import javafx.application.Platform; import javax.imageio.ImageIO; import java.awt.AWTException; import java.awt.EventQueue; import java.awt.Image; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.TrayIcon; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; import java.io.InputStream; public final class SystemTrayManager { private final Runnable openSettingsAction; private final Runnable exitAction; private TrayIcon trayIcon; public SystemTrayManager(Runnable openSettingsAction, Runnable exitAction) { this.openSettingsAction = openSettingsAction; this.exitAction = exitAction; } public void install() { if (!SystemTray.isSupported()) { Logger.info("System tray is not supported on this system."); return; } EventQueue.invokeLater(() -> { if (trayIcon != null) { return; } try { TrayIcon createdTrayIcon = createTrayIcon(); SystemTray.getSystemTray().add(createdTrayIcon); trayIcon = createdTrayIcon; Logger.info("System tray icon installed."); } catch (AWTException | IOException e) { Logger.error("Failed to install system tray icon: " + e.getMessage()); } }); } public void dispose() { EventQueue.invokeLater(() -> { if (trayIcon == null || !SystemTray.isSupported()) { return; } SystemTray.getSystemTray().remove(trayIcon); trayIcon = null; Logger.info("System tray icon removed."); }); } private TrayIcon createTrayIcon() throws IOException { PopupMenu popupMenu = new PopupMenu(); MenuItem openSettingsMenuItem = new MenuItem("Open Settings"); openSettingsMenuItem.addActionListener(event -> Platform.runLater(openSettingsAction)); popupMenu.add(openSettingsMenuItem); MenuItem exitMenuItem = new MenuItem("Exit"); exitMenuItem.addActionListener(event -> Platform.runLater(exitAction)); popupMenu.add(exitMenuItem); TrayIcon createdTrayIcon = new TrayIcon(loadTrayImage(), "Cedro Modern Dock", popupMenu); createdTrayIcon.setImageAutoSize(true); createdTrayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 1) { Platform.runLater(openSettingsAction); } } }); return createdTrayIcon; } private Image loadTrayImage() throws IOException { try (InputStream inputStream = App.class.getResourceAsStream( "/com/github/arthurdeka/cedromoderndock/icons/cedro/logo_32.png" )) { if (inputStream == null) { throw new IOException("Tray icon resource not found."); } return ImageIO.read(inputStream); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/UIUtils.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.github.arthurdeka.cedromoderndock.App; import javafx.scene.image.Image; import javafx.stage.Stage; /** * Utility class to UI related operations */ public final class UIUtils { // Construtor privado para impedir a instanciação. private UIUtils() {} /** * Defines a standard app icon to a stage. * @param stage The stage which the icon will be applied to */ public static void setStageIcon(Stage stage) { try { Image icon = new Image(App.class.getResourceAsStream("/com/github/arthurdeka/cedromoderndock/icons/cedro/logo_256.png")); stage.getIcons().add(icon); } catch (Exception e) { Logger.error("Failed to load application icon: " + e.getMessage()); } } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/util/WindowsIconHandler.java ================================================ package com.github.arthurdeka.cedromoderndock.util; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Structure; import com.sun.jna.platform.win32.GDI32; import com.sun.jna.platform.win32.Guid; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinDef.HBITMAP; import com.sun.jna.platform.win32.WinDef.HDC; import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinGDI; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.List; /** * Extracts the icon from executables (.exe) and saves it to a persistent cache folder in AppData. * The extraction uses Windows Shell API (JNA) to request a high-resolution icon. */ public final class WindowsIconHandler { private WindowsIconHandler() { } // static utility // Persistent cache directory in %APPDATA%/CedroModernDock/iconsCache private static final Path CACHE_DIR = getCacheDirectory(); // Target extraction size to capture the highest-quality icon available. private static final int ICON_SIZE = 256; private static final int SHGFI_ICON = 0x000000100; private static final int SHGFI_SYSICONINDEX = 0x000004000; private static final int FILE_ATTRIBUTE_DIRECTORY = 0x00000010; private static final int SHIL_JUMBO = 0x4; private static final int ILD_TRANSPARENT = 0x00000001; private interface User32Ex extends StdCallLibrary { User32Ex INSTANCE = Native.load("user32", User32Ex.class, W32APIOptions.DEFAULT_OPTIONS); int PrivateExtractIconsW(String szFileName, int nIconIndex, int cxIcon, int cyIcon, HICON[] phicon, int[] piconid, int nIcons, int flags); } private interface Shell32Ex extends StdCallLibrary { Shell32Ex INSTANCE = Native.load("shell32", Shell32Ex.class, W32APIOptions.DEFAULT_OPTIONS); long SHGetFileInfoW(String pszPath, int dwFileAttributes, SHFILEINFO psfi, int cbFileInfo, int uFlags); int SHGetImageList(int iImageList, Guid.IID riid, com.sun.jna.ptr.PointerByReference ppv); } private interface Comctl32Ex extends StdCallLibrary { Comctl32Ex INSTANCE = Native.load("comctl32", Comctl32Ex.class, W32APIOptions.DEFAULT_OPTIONS); HICON ImageList_GetIcon(com.sun.jna.Pointer himl, int i, int flags); } @Structure.FieldOrder({"hIcon", "iIcon", "dwAttributes", "szDisplayName", "szTypeName"}) public static class SHFILEINFO extends Structure { public HICON hIcon; public int iIcon; public int dwAttributes; public char[] szDisplayName = new char[260]; public char[] szTypeName = new char[80]; } /** * Get the cached icon path * * @param exePath complete path to the .exe. (take it from the value in the config.json file) * @return The path to the icon in the cache folder */ public static Path getCachedIconPath(String exePath) { return getCachedPath(exePath, "program"); } public static Path getCachedFolderIconPath(String folderPath) { return getCachedPath(folderPath, "folder_v3"); } private static Path getCachedPath(String inputPath, String kind) { try { String fileName = kind + "_" + getHashedFileName(inputPath) + ".png"; return CACHE_DIR.resolve(fileName); } catch (NoSuchAlgorithmException e) { Logger.error("getCachedIconPath - Failed to generate hashed file name for " + inputPath + e); return null; } } /** * Extracts the icon from executables * * @param exePath complete path to the .exe. * @return The path to the icon in the cache folder */ public static Path extractAndCacheIcon(String exePath) { return extractAndCacheProgramIcon(exePath); } public static Path extractAndCacheFolderIcon(String folderPath) { try { Path cachedIconPath = getCachedFolderIconPath(folderPath); if (cachedIconPath == null) { return null; } if (Files.exists(cachedIconPath)) { Logger.info("Icon for " + folderPath + " found in cache."); return cachedIconPath; } File folder = new File(folderPath); if (!folder.isDirectory()) { Logger.error("Folder icon extraction failed because folder is invalid: " + folderPath); return null; } BufferedImage image = extractFolderIconWithShellApi(folder); if (image == null) { return null; } ImageIO.write(image, "png", cachedIconPath.toFile()); return Files.exists(cachedIconPath) && Files.size(cachedIconPath) > 0 ? cachedIconPath : null; } catch (IOException e) { Logger.error("WindowsIconExtractor error on extractAndCacheFolderIcon: " + e.getMessage() + e); return null; } } private static Path extractAndCacheProgramIcon(String exePath) { try { Path cachedIconPath = getCachedIconPath(exePath); if (cachedIconPath == null) { return null; } // If the icon already exists, return its path immediately. if (Files.exists(cachedIconPath)) { Logger.info("Icon for " + exePath + " found in cache."); return cachedIconPath; } if (!extractIconWithShellApi(exePath, cachedIconPath)) { Logger.error("Failed to extract icon for " + exePath + " using Shell API."); Files.deleteIfExists(cachedIconPath); // Clean up empty or corrupted file return null; } Logger.info("[extractAndCacheIcon] Icon for " + exePath + " successfully extracted and cached at iconsCache"); return cachedIconPath; // Return the path of the newly saved icon. } catch (IOException e) { Logger.error("WindowsIconExtractor error on extractAndCacheIcon: " + e.getMessage() + e); return null; } } private static BufferedImage extractFolderIconWithShellApi(File folder) { SHFILEINFO shFileInfo = new SHFILEINFO(); long result = Shell32Ex.INSTANCE.SHGetFileInfoW( folder.getAbsolutePath(), FILE_ATTRIBUTE_DIRECTORY, shFileInfo, shFileInfo.size(), SHGFI_SYSICONINDEX ); if (result == 0) { return null; } com.sun.jna.ptr.PointerByReference imageListRef = new com.sun.jna.ptr.PointerByReference(); Guid.IID iImageListId = new Guid.IID("{46EB5926-582E-4017-9FDF-E8998DAA0950}"); int hr = Shell32Ex.INSTANCE.SHGetImageList(SHIL_JUMBO, iImageListId, imageListRef); if (hr != 0 || imageListRef.getValue() == null) { return null; } HICON hIcon = Comctl32Ex.INSTANCE.ImageList_GetIcon(imageListRef.getValue(), shFileInfo.iIcon, ILD_TRANSPARENT); if (hIcon == null) { return null; } try { return iconToBufferedImage(hIcon); } finally { User32.INSTANCE.DestroyIcon(hIcon); } } /** * Extracts the icon using the Windows Shell API and saves it as a PNG. */ private static boolean extractIconWithShellApi(String exePath, Path outputPath) throws IOException { HICON[] icons = new HICON[1]; int[] iconIds = new int[1]; int extracted = User32Ex.INSTANCE.PrivateExtractIconsW( exePath, 0, ICON_SIZE, ICON_SIZE, icons, iconIds, 1, 0 ); if (extracted <= 0 || icons[0] == null) { return false; } BufferedImage image; try { image = iconToBufferedImage(icons[0]); } finally { User32.INSTANCE.DestroyIcon(icons[0]); } if (image == null) { return false; } ImageIO.write(image, "png", outputPath.toFile()); return Files.exists(outputPath) && Files.size(outputPath) > 0; } /** * Converts a Windows HICON into a BufferedImage. */ private static BufferedImage iconToBufferedImage(HICON hIcon) { WinGDI.ICONINFO iconInfo = new WinGDI.ICONINFO(); if (!User32.INSTANCE.GetIconInfo(hIcon, iconInfo)) { return null; } try { HBITMAP hBitmap = iconInfo.hbmColor != null ? iconInfo.hbmColor : iconInfo.hbmMask; if (hBitmap == null) { return null; } WinGDI.BITMAP bitmap = new WinGDI.BITMAP(); GDI32.INSTANCE.GetObject(hBitmap, bitmap.size(), bitmap.getPointer()); bitmap.read(); int width = bitmap.bmWidth.intValue(); int height = bitmap.bmHeight.intValue(); if (width <= 0 || height <= 0) { return null; } WinGDI.BITMAPINFO bmi = new WinGDI.BITMAPINFO(); bmi.bmiHeader.biSize = bmi.bmiHeader.size(); bmi.bmiHeader.biWidth = width; // Negative height creates a top-down DIB (no vertical flip). bmi.bmiHeader.biHeight = -height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = WinGDI.BI_RGB; int bufferSize = width * height * 4; Memory buffer = new Memory(bufferSize); HDC hdc = GDI32.INSTANCE.CreateCompatibleDC(null); if (hdc == null) { return null; } WinNT.HANDLE oldBitmap = GDI32.INSTANCE.SelectObject(hdc, hBitmap); int lines = GDI32.INSTANCE.GetDIBits( hdc, hBitmap, 0, height, buffer, bmi, WinGDI.DIB_RGB_COLORS ); GDI32.INSTANCE.SelectObject(hdc, oldBitmap); GDI32.INSTANCE.DeleteDC(hdc); if (lines == 0) { return null; } byte[] data = buffer.getByteArray(0, bufferSize); int[] pixels = new int[width * height]; for (int i = 0, p = 0; i < pixels.length; i++) { int b = data[p++] & 0xFF; int g = data[p++] & 0xFF; int r = data[p++] & 0xFF; int a = data[p++] & 0xFF; pixels[i] = (a << 24) | (r << 16) | (g << 8) | b; } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); image.setRGB(0, 0, width, height, pixels, 0, width); return image; } finally { cleanupIconInfo(iconInfo); } } private static void cleanupIconInfo(WinGDI.ICONINFO iconInfo) { if (iconInfo.hbmColor != null) { GDI32.INSTANCE.DeleteObject(iconInfo.hbmColor); } if (iconInfo.hbmMask != null) { GDI32.INSTANCE.DeleteObject(iconInfo.hbmMask); } } /** * Returns the icons cache directory (creating AppData/CedroModernDock/iconsCache if it does not exist) */ private static Path getCacheDirectory() { try { String appData = System.getenv("APPDATA"); if (appData == null || appData.isEmpty()) { Logger.error("AppData Not found."); } Path cacheDir = Paths.get(appData, "CedroModernDock", "iconsCache"); Files.createDirectories(cacheDir); // Creates the folder structure if it doesn't exist return cacheDir; } catch (IOException e) { Logger.error("Failed to create icon cache directory." + e); throw new RuntimeException("Could not create cache directory.", e); } } /** * Generates a safe filename using a SHA-256 hash of the executable path. */ private static String getHashedFileName(String input) throws NoSuchAlgorithmException { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(input.getBytes(StandardCharsets.UTF_8)); return new BigInteger(1, hash).toString(16); } } ================================================ FILE: src/main/java/com/github/arthurdeka/cedromoderndock/view/WindowPreviewPopup.java ================================================ package com.github.arthurdeka.cedromoderndock.view; import com.github.arthurdeka.cedromoderndock.application.DockTheme; import com.github.arthurdeka.cedromoderndock.util.NativeWindowUtils; import javafx.beans.value.ChangeListener; import javafx.geometry.Bounds; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.geometry.Rectangle2D; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.stage.Popup; import javafx.stage.Screen; import java.util.List; import java.util.function.Consumer; public class WindowPreviewPopup extends Popup { private final VBox container; private Node currentTarget; private Node currentDock; // Reposition whenever popup size changes (content can grow/shrink). private final ChangeListener sizeListener = (obs, old, val) -> reposition(); public WindowPreviewPopup() { this.container = new VBox(); this.container.setPadding(new Insets(10)); this.container.setSpacing(5); this.container.setAlignment(Pos.CENTER_LEFT); // Prevent auto-hide when clicking inside the popup this.setAutoHide(false); this.getContent().add(container); widthProperty().addListener(sizeListener); heightProperty().addListener(sizeListener); } public void updateContent( List windows, Image appIcon, String appLabel, DockTheme dockTheme, Consumer activateWindowAction ) { container.getChildren().clear(); // Apply style from dock model so the popup matches the dock theme. String style = String.format( "-fx-background-color: rgba(%s %s); -fx-background-radius: %s;", dockTheme.colorRgb(), dockTheme.transparency(), dockTheme.borderRounding() ); container.setStyle(style); // Choose a readable text color based on dock background brightness. Color textColor = getTextColorForBackground(dockTheme.colorRgb()); for (NativeWindowUtils.WindowInfo window : windows) { HBox item = createWindowItem(window, appIcon, appLabel, textColor, activateWindowAction); container.getChildren().add(item); } } private Color getTextColorForBackground(String dockColorRGB) { try { // Remove commas and trim String cleanRGB = dockColorRGB.replace(",", " ").trim(); String[] parts = cleanRGB.split("\\s+"); if (parts.length >= 3) { int r = Integer.parseInt(parts[0]); int g = Integer.parseInt(parts[1]); int b = Integer.parseInt(parts[2]); // Calculate brightness to choose black/white contrast. double brightness = (r * 0.299 + g * 0.587 + b * 0.114); return brightness > 128 ? Color.BLACK : Color.WHITE; } } catch (NumberFormatException e) { // Ignore, default to white } return Color.WHITE; } private HBox createWindowItem( NativeWindowUtils.WindowInfo window, Image appIcon, String appLabel, Color textColor, Consumer activateWindowAction ) { HBox item = new HBox(); item.setSpacing(10); item.setPadding(new Insets(5, 10, 5, 10)); item.setAlignment(Pos.CENTER_LEFT); item.setStyle("-fx-background-color: transparent; -fx-background-radius: 5; -fx-cursor: hand;"); // Icon ImageView iconView = new ImageView(appIcon); iconView.setFitWidth(16); iconView.setFitHeight(16); iconView.setPreserveRatio(true); // Title Label titleLabel = new Label(formatWindowTitle(window.title(), appLabel)); titleLabel.setTextFill(textColor); titleLabel.setStyle("-fx-font-size: 12px;"); item.getChildren().addAll(iconView, titleLabel); // Hover effect for better visual feedback. item.setOnMouseEntered(e -> { item.setStyle("-fx-background-color: rgba(255, 255, 255, 0.2); -fx-background-radius: 5; -fx-cursor: hand;"); titleLabel.setTextFill(Color.WHITE); // Always white on hover for better contrast against hover bg }); item.setOnMouseExited(e -> { item.setStyle("-fx-background-color: transparent; -fx-background-radius: 5; -fx-cursor: hand;"); titleLabel.setTextFill(textColor); }); // Click action item.setOnMouseClicked(e -> { activateWindowAction.accept(window); this.hide(); }); return item; } private String formatWindowTitle(String windowTitle, String appLabel) { String sanitizedTitle = stripRedundantAppSuffix(windowTitle, appLabel); return truncateTitle(sanitizedTitle, 40); } private String stripRedundantAppSuffix(String windowTitle, String appLabel) { if (windowTitle == null) { return ""; } if (appLabel == null || appLabel.isBlank()) { return windowTitle; } String suffix = " - " + appLabel; if (windowTitle.regionMatches(true, Math.max(0, windowTitle.length() - suffix.length()), suffix, 0, suffix.length())) { String stripped = windowTitle.substring(0, windowTitle.length() - suffix.length()).trim(); if (!stripped.isEmpty()) { return stripped; } } return windowTitle; } private String truncateTitle(String title, int maxLength) { if (title == null) { return ""; } if (title.length() <= maxLength) { return title; } return title.substring(0, maxLength) + "..."; } public VBox getContainer() { return container; } public void showAbove(Node target, Node dockContainer) { this.currentTarget = target; this.currentDock = dockContainer; Bounds bounds = target.localToScreen(target.getBoundsInLocal()); // Initial show, then reposition to avoid flicker. if (!isShowing()) { this.show(target, bounds.getMinX(), bounds.getMinY()); } reposition(); } private void reposition() { if (currentTarget == null || !isShowing()) return; Bounds bounds = currentTarget.localToScreen(currentTarget.getBoundsInLocal()); if (bounds == null) return; double w = getWidth(); double h = getHeight(); double gap = 5; // Center horizontally over the target icon. setX(bounds.getMinX() + (bounds.getWidth() / 2) - (w / 2)); Rectangle2D screenBounds = getScreenBounds(bounds); Bounds dockBounds = getDockBounds(bounds); double yAbove = dockBounds.getMinY() - h - gap; double yBelow = dockBounds.getMaxY() + gap; // If there's no room above the dock, place below instead. if (yAbove < screenBounds.getMinY() + gap) { setY(yBelow); } else { setY(yAbove); } } private Rectangle2D getScreenBounds(Bounds bounds) { // Use the screen containing the target bounds. for (Screen screen : Screen.getScreensForRectangle( bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight() )) { return screen.getVisualBounds(); } return Screen.getPrimary().getVisualBounds(); } private Bounds getDockBounds(Bounds fallbackBounds) { if (currentDock == null) { return fallbackBounds; } Bounds dockBounds = currentDock.localToScreen(currentDock.getBoundsInLocal()); return dockBounds != null ? dockBounds : fallbackBounds; } } ================================================ FILE: src/main/java/module-info.java ================================================ module com.github.arthurdeka.cedromoderndock { requires javafx.controls; requires javafx.fxml; requires java.desktop; requires com.sun.jna; requires com.sun.jna.platform; requires com.fasterxml.jackson.databind; requires static lombok; opens com.github.arthurdeka.cedromoderndock.controller to javafx.fxml; opens com.github.arthurdeka.cedromoderndock to javafx.fxml; opens com.github.arthurdeka.cedromoderndock.fxml to javafx.fxml; opens com.github.arthurdeka.cedromoderndock.application to com.fasterxml.jackson.databind; opens com.github.arthurdeka.cedromoderndock.model to com.fasterxml.jackson.databind; opens com.github.arthurdeka.cedromoderndock.util to com.sun.jna; exports com.github.arthurdeka.cedromoderndock; exports com.github.arthurdeka.cedromoderndock.controller to javafx.fxml; } ================================================ FILE: src/main/resources/com/github/arthurdeka/cedromoderndock/css/dock.css ================================================ #myAnchorPane { -fx-background-color: transparent; } #MyHBox { -fx-background-color: black; } .dock-button { -fx-content-display: graphic-only; -fx-background-color: transparent; -fx-cursor: hand; transition-property: -fx-scale-x, -fx-scale-y; transition-duration: 0.3s; -fx-scale-x: 1.0; -fx-scale-y: 1.0; } .dock-button:hover { -fx-scale-x: 1.3; -fx-scale-y: 1.3; } ================================================ FILE: src/main/resources/com/github/arthurdeka/cedromoderndock/css/dockSettings.css ================================================ .root { -fx-font-family: "Segoe UI", Arial, sans-serif; -fx-background-color: #111315; -fx-base: #111315; -fx-accent: #007acc; -fx-focus-color: transparent; -fx-faint-focus-color: transparent; } .window-root { -fx-background-color: linear-gradient(to bottom, #15181c 0%, #111315 100%); } .settings-window { -fx-background-insets: 0; } .modal-root { -fx-background-color: #111315; } .label { -fx-text-fill: #e6edf3; -fx-font-size: 13px; } .page-header { -fx-padding: 0 0 4 0; } #mainTitle, .main-title { -fx-text-fill: #f5f7fa; -fx-font-size: 30px; -fx-font-weight: bold; } .modal-title { -fx-font-size: 26px; } .main-subtitle { -fx-text-fill: #8f9aa6; -fx-font-size: 13px; } .content-shell { -fx-background-color: transparent; } .tab-scroll-pane { -fx-background-color: transparent; -fx-background: transparent; -fx-border-color: transparent; -fx-fit-to-width: true; } .tab-scroll-pane > .viewport { -fx-background-color: transparent; } .tab-scroll-pane > .corner { -fx-background-color: transparent; } .section-card { -fx-background-color: #1a1d21; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-border-radius: 4px; -fx-background-radius: 4px; -fx-padding: 18px; } .action-panel { -fx-background-color: #171a1e; } .hero-card, .logo-card { -fx-background-color: #171a1e; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-border-radius: 4px; -fx-background-radius: 4px; -fx-padding: 18px; } .hero-image-wrap { -fx-background-color: #111315; -fx-border-color: #28313a; -fx-border-width: 1px; -fx-border-radius: 4px; -fx-background-radius: 4px; -fx-padding: 18px; } .section-title { -fx-text-fill: #007acc; -fx-font-size: 17px; -fx-font-weight: bold; } .section-helper { -fx-text-fill: #97a3b0; -fx-font-size: 12px; } .field-label { -fx-text-fill: #dce3ea; -fx-font-size: 12px; -fx-font-weight: bold; } .meta-card { -fx-min-width: 440px; } .meta-value { -fx-text-fill: #d7dee6; -fx-font-size: 13px; } .general-link { -fx-text-fill: #8fbfe8; } .footer-note { -fx-text-fill: #b9c3ce; -fx-font-weight: bold; } .ack-item { -fx-background-color: #13161a; -fx-border-color: #262d35; -fx-border-width: 1px; -fx-border-radius: 4px; -fx-background-radius: 4px; -fx-padding: 10px 12px; -fx-text-fill: #dde6ef; -fx-font-size: 13px; } .tab-pane { -fx-background-color: transparent; -fx-tab-min-height: 36px; -fx-tab-max-height: 36px; } .tab-pane .tab-header-area { -fx-padding: 0 0 8 0; } .tab-pane .tab-header-area .tab-header-background { -fx-background-color: transparent; } .tab-pane .headers-region { -fx-background-color: transparent; } .tab-pane .tab { -fx-background-color: #1a1d21; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-border-radius: 4px 4px 0 0; -fx-background-radius: 4px 4px 0 0; -fx-padding: 8 16 8 16; } .tab-pane .tab:hover { -fx-background-color: #20242a; } .tab-pane .tab:selected { -fx-background-color: #20242a; -fx-border-color: #007acc #2d333b #20242a #2d333b; -fx-border-width: 2px 1px 1px 1px; } .tab-pane .tab .tab-label { -fx-text-fill: #a9b4bf; -fx-font-size: 12px; -fx-font-weight: bold; } .tab-pane .tab:selected .tab-label { -fx-text-fill: #f5f7fa; } .tab-pane .tab-content-area { -fx-background-color: #14181c; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-background-radius: 0 4px 4px 4px; -fx-border-radius: 0 4px 4px 4px; } .button { -fx-background-color: #007acc; -fx-text-fill: white; -fx-font-size: 13px; -fx-font-weight: bold; -fx-padding: 11px 16px; -fx-background-radius: 4px; -fx-border-radius: 4px; -fx-border-width: 1px; -fx-border-color: #007acc; } .button:hover { -fx-background-color: #1387d7; -fx-border-color: #1387d7; -fx-cursor: hand; } .button:pressed { -fx-background-color: #0060a2; -fx-border-color: #0060a2; } .button:disabled { -fx-opacity: 0.48; } .secondary-button { -fx-background-color: #1a1d21; -fx-border-color: #2f3943; -fx-text-fill: #e6edf3; } .secondary-button:hover { -fx-background-color: #22272e; -fx-border-color: #3b4753; } .secondary-button:pressed { -fx-background-color: #171b1f; -fx-border-color: #2f3943; } .list-view { -fx-background-color: #111315; -fx-control-inner-background: #111315; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-background-radius: 4px; -fx-border-radius: 4px; -fx-padding: 4px; } .list-cell { -fx-background-color: transparent; -fx-text-fill: #dce3ea; -fx-font-size: 13px; -fx-padding: 10px 12px; } .list-cell:filled:hover { -fx-background-color: #1d2329; -fx-text-fill: #f5f7fa; } .list-cell:filled:selected, .list-cell:filled:selected:hover { -fx-background-color: #007acc; -fx-text-fill: #ffffff; } .scroll-bar:vertical, .scroll-bar:horizontal { -fx-background-color: transparent; } .scroll-bar .thumb { -fx-background-color: #2f3943; -fx-background-radius: 4px; } .scroll-bar .thumb:hover { -fx-background-color: #3d4956; } .slider .track { -fx-background-color: #2a3036; -fx-background-radius: 2px; -fx-pref-height: 4px; } .slider .thumb { -fx-background-color: #007acc; -fx-background-radius: 100px; -fx-padding: 8px; } .slider .axis { -fx-tick-label-fill: #8f9aa6; -fx-tick-length: 4px; } .slider .axis .tick-mark { -fx-stroke: #5f6a75; } .radio-button { -fx-text-fill: #dce3ea; -fx-font-size: 13px; -fx-font-weight: bold; } .radio-button .radio { -fx-background-color: #111315; -fx-border-color: #55616e; -fx-border-width: 1px; -fx-border-radius: 100px; -fx-background-radius: 100px; -fx-padding: 4px; } .radio-button:selected .radio { -fx-border-color: #007acc; } .radio-button:selected .dot { -fx-background-color: #007acc; -fx-background-insets: 0; } .choice-box, .color-picker { -fx-background-color: #111315; -fx-border-color: #2d333b; -fx-border-width: 1px; -fx-background-radius: 4px; -fx-border-radius: 4px; -fx-mark-color: #007acc; -fx-padding: 4px 8px; } .choice-box:hover, .color-picker:hover { -fx-background-color: #161a1f; -fx-border-color: #3a4652; } .choice-box > .label, .color-picker .label { -fx-text-fill: #e6edf3; -fx-font-size: 13px; -fx-font-weight: bold; } .choice-box .context-menu { -fx-background-color: #171b20; } .choice-box .menu-item:focused { -fx-background-color: #007acc; } .choice-box .menu-item > .label { -fx-text-fill: #e6edf3; -fx-font-size: 13px; } .choice-box .menu-item:focused > .label { -fx-text-fill: white; } #dockColorPicker .arrow { -fx-background-color: #007acc; } #dockColorPicker .color-picker-label { -fx-text-fill: #e6edf3; } #dockColorPicker .color-picker-grid .opacity-slider, #dockColorPicker .color-picker-grid .opacity-label { visibility: hidden; max-height: 0; padding: 0; } ================================================ FILE: src/main/resources/com/github/arthurdeka/cedromoderndock/fxml/AcknowledgementsModalView.fxml ================================================ ================================================ FILE: src/main/resources/com/github/arthurdeka/cedromoderndock/fxml/AddWindowsModulesModalView.fxml ================================================