Skip to content

migrating Preferences and Messages to stand-alone version #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AhmedMagedC
Copy link

Resolves #1104

Changes

  • migrating Preferences to :app:utils module making it independent of app module by also moving the functionalities that depends on app to AppPreferences class
  • doing the same for the Messages class to be able to use it (for example in debugging) in different areas of Processing
  • moving Utils into :app:utils, because why keeping it in app it doesn't need any functionalities from there, and also can be used in :app:utils without the need to depend on app
  • now for the platform-dependent settings location, the previously mention approach in the issue made cyclic dependency problem, so i moved the getSettingsFolder() method for each platform from :app to :app:utils, without duplication the code i made app.Platform class to depend on SettingsResolver in :app:utils to get the correct location for each platform
  • loading the defaults.txt now by using JAR resource system instead of Platform.getContentFile() (which is also marked as deprecated in the codebase encouraging to migrate to JAR RS)

Todo

  • Adding callback events/listeners when a preference changes
  • Tests that will declare and test the functionality of Preferences
  • A Github Action that will run the Tests on all supported platforms

Tests

I tried to compile and run, as for now preferences are loaded and saved correctly

but for some reason some languages aren't displayed properly like: arabic , chinese, but languages like: english, japanese properly displayed.
I will look into it, but any help or suggestion of why that happens is very much appreciated

@AhmedMagedC
Copy link
Author

so for the language display issue, i suspect it happened when i renamed Preferences class to AppPreferences
the comment: # Preferences (Frame) in all PDE.properties automatically changed to # AppPreferences (Frame) leading to corruption of some files (idk why tho)

it's fixed now

@Stefterv Stefterv marked this pull request as draft June 17, 2025 07:15
@Stefterv
Copy link
Collaborator

Hi @AhmedMagedC Thank you for the PR! Sorry I got a little busy, hope to get to this soon!

Copy link
Collaborator

@Stefterv Stefterv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AhmedMagedC Thank you again for the work! It is heading very much in the right direction. I have added some comments as suggestions to help further improve

@@ -472,12 +471,12 @@ static public String getVersionName() {


public static void setCommandLine() {
commandLine = true;
System.setProperty("processing.cli", "true");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain why this needed to change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main motivation behind this change was to be able to know if Processing is launched via CLI or not without the need to depend on app module via using Base.isCommandLine()

as for example im using it in the utils.Messages.kt

*/
@JvmStatic
fun showMessage(title: String = "Message", message: String) {
if (Base.isCommandLine()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that the JOptionPane parts should stay and the println can be in the universal class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i understand you correctly, you wanna seperate the appearance of graphical messages via JOptionPane to be only used by app.Messages and a simple println only for the utils.Messages

but wouldn't that make an issue in utils module? as for example in processing.utils.settingslocation and processing.utils.Base
error messages via Messages.showError() wouldn't display a graphical message only just a console print. So is it accepctable? also bear in mind that i cannot use app.Messages for this purpose because i want the utils module along with the utils.preference class to be fully independent of app module

load(new FileInputStream(preferencesFile));

} catch (Exception ex) {
Messages.showError("Error reading preferences",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these could be transformed to normal errors and then catch and log them in the app classes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that. but that would depend on how we choose to implement utils.Messages

if we decided to keep the use of JOptionPane in utils.Messages then this delegation of catching and logging the errors in app rather than in utils wouldn't make much sense because we will use the same method but in different location

if we decided to remove JOptionPane and keep only the println then i can do that delegation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the build folder to the .gitignore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already did in this commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Making Preferences standalone
2 participants