Skip to content

#1802 GUI State management implementation#1807

Open
laim2003 wants to merge 57 commits into
devonfw:mainfrom
laim2003:#1802-state-management-implementation
Open

#1802 GUI State management implementation#1807
laim2003 wants to merge 57 commits into
devonfw:mainfrom
laim2003:#1802-state-management-implementation

Conversation

@laim2003
Copy link
Copy Markdown
Contributor

@laim2003 laim2003 commented Apr 9, 2026

This PR fixes #1802

Implemented changes:

  • Implemented basic State Management for the IdeContext in the GUI
  • State management should be thread safe: Thread safe singleton implementation
  • Added custom adaption of JavaFXs alert class for IDEasy

Main points:

  • Basic state management
  • Start-context <-> context seperation
  • Ensure thread safety
  • Callback pattern for any dependent compontents

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

laim2003 added 13 commits March 27, 2026 17:52
- Added logging to IdeGuiStateManager.
- Added functionality, that selecting a different project now switches the IdeContext to the new project.
- Added logging to IdeGuiStateManager.
- Added functionality, that selecting a different project now switches the IdeContext to the new project.
- Added functionality, that selecting a different project now switches the IdeContext to the new project.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Apr 9, 2026
@laim2003 laim2003 self-assigned this Apr 9, 2026
@laim2003 laim2003 added GUI Graphical User Interface of IDEasy (aka dashboard) build with JavaFx bugfix PR that fixes a bug issue core FileAccess, ProcessUtil, IdeContext, etc. labels Apr 9, 2026
@laim2003 laim2003 moved this from 🆕 New to 🏗 In progress in IDEasy board Apr 9, 2026
- added DI for IdeGuiStateManager.switchContext
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 9, 2026

Coverage Report for CI Build 26781579041

Coverage decreased (-0.02%) to 71.076%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 26 coverage regressions across 4 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

26 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/ide/gui/App.java 13 0.0%
com/devonfw/ide/gui/MainController.java 11 62.96%
com/devonfw/ide/gui/AppLauncher.java 1 0.0%
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 1 78.33%

Coverage Stats

Coverage Status
Relevant Lines: 15862
Covered Lines: 11754
Line Coverage: 74.1%
Relevant Branches: 7050
Covered Branches: 4531
Branch Coverage: 64.27%
Branches in Coverage %: Yes
Coverage Strength: 3.13 hits per line

💛 - Coveralls

@laim2003 laim2003 added the internal Nothing to be added to CHANGELOG, only internal story label Apr 14, 2026
- not automatically select a workspace
- to seperate concerns of which functions update the workspace combobox and which the project combobox
…low new Select-Project-Then-Select-Workspace UI logic (previous commit)
@laim2003 laim2003 force-pushed the #1802-state-management-implementation branch from 459f762 to 6c44432 Compare April 28, 2026 17:28
@laim2003 laim2003 moved this from 🏗 In progress to Team Review in IDEasy board Apr 28, 2026
@laim2003 laim2003 marked this pull request as ready for review April 30, 2026 08:34
@laim2003 laim2003 moved this from Team Review to 👀 In review in IDEasy board May 2, 2026
Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@laim2003 thanks for your PR.
I like the general design and you added many valuable fixes and improvements for the GUI.
I still have some doubts about the singleton and static member access approach.
Typically this will sooner or later cause trouble.
Maybe we can avoid this where possible.

Please avoid this extensive copy&paste of pointless and confusing properties, plugin settings that are never used, etc.
The golden rule for ide-projects for test is to keep them as minimalistic as possible.
Every line from such file and every entire file that can be removed without the test failing should be removed.

Comment thread cli/pom.xml
Comment thread gui/src/main/java/com/devonfw/ide/gui/context/ProjectManager.java Outdated
Comment thread gui/src/main/java/com/devonfw/ide/gui/context/ProjectManager.java Outdated
Comment thread gui/src/test/resources/ide-projects/testProject/project-3/settings/ide.properties Outdated
@laim2003
Copy link
Copy Markdown
Contributor Author

@laim2003 thanks for your PR. I like the general design and you added many valuable fixes and improvements for the GUI. I still have some doubts about the singleton and static member access approach. Typically this will sooner or later cause trouble. Maybe we can avoid this where possible.

Please avoid this extensive copy&paste of pointless and confusing properties, plugin settings that are never used, etc. The golden rule for ide-projects for test is to keep them as minimalistic as possible. Every line from such file and every entire file that can be removed without the test failing should be removed.

regarding the singleton design, i created a new ticket to document this #1975

@laim2003 laim2003 requested a review from hohwille May 29, 2026 14:31
Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@laim2003 I now found the time to read and review the entire diff.
Thanks also for your rework. This PR is very nice progress and improvement. 👍
I left some further review remarks for improvement.
We should then finally merge this instead if dying in perfection.
There will be more rounds of changes in the GUI and we should stop blocking other stories that want to build on top of this...
However, I have always learned that we always need a solid foundation rather than a sandbank to build on top. So lets keep some pair of careful looking eyes on the GUI stuff that we are evolving...

.filter(Files::isDirectory)
.map(Path::getFileName)
.map(Path::toString)
.filter(name -> !name.startsWith("_") && Files.exists(ideRootDirectory.resolve(name).resolve("workspaces")))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should make this method reusable here:

We could even make it public if required.
BTW: The only forbidden or reserved project name is _ide and for that we have the constant IdeContext.FOLDER_UNDERSCORE_IDE.
I do not think users should do ide create _project - but I guess it is technically possible.

Copy link
Copy Markdown
Contributor Author

@laim2003 laim2003 Jun 2, 2026

Choose a reason for hiding this comment

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

Ahh yes, this was a remaining fragment from the original implementation from the first MVP. I guess, I will change this so only folders matching FOLDER_UNDERSCORE_IDE will be excuded.

@@ -0,0 +1 @@
this is the foo-bar workspace
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everywhere else we just use empty .gitkeep files to add a folder to git. Shouldn't we follow this pattern here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh ok, I will change this.

@@ -0,0 +1 @@
this is the foo-bar workspace
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does it make sense to create project-0,..., project-5 that are all identical and have the same workspaces?
Actually if all this should make sense it would be more reasonable to have some differences between the workspaces so your test can really check if the workspaces found for some project really fit to that project and are not from a different one...

projectManager = new ProjectManager(ideRoot);

assertThat(projectManager).isNotNull();
assertThat(projectManager.getProjectNames()).containsExactlyInAnyOrder("project-0", "project-1", "project-2", "project-3", "project-4", "project-5");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In cli we have added our test-infrastructure such that we can continuously add new code with new tests and potentially new test projects.
This will break as soon as we add a new test-project.
IMHO this does not really work out well for maintenance.
Maybe only assert that the project names contain these projects or filter the project names by a pattern project-[0-9] so other developers can later add foo and bar projects without breaking this test.

void testRefreshProjects() throws IOException {

projectManager = new ProjectManager(ideRoot);
assertThat(projectManager.getProjectNames()).containsExactlyInAnyOrder("project-0", "project-1", "project-2", "project-3", "project-4", "project-5");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also in JUnits we can consider reuse instead of copy&paste.
Consider adding List.of("project-0", "project-1", "project-2", "project-3", "project-4", "project-5") as a constant.
Then you can create a new list adding the constant + project-6.


// Verify that test-project-no-workspaces is not recognized
assertThat(projectManager.getProjectNames()).doesNotContain("test-project-no-workspaces");
assertThat(projectManager.getProjectNames()).containsExactlyInAnyOrder("project-0", "project-1", "project-2", "project-3", "project-4", "project-5");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use constant.


// Verify that _ide folder is not in the project names
assertThat(projectManager.getProjectNames()).doesNotContain("_ide");
assertThat(projectManager.getProjectNames()).containsExactlyInAnyOrder("project-0", "project-1", "project-2", "project-3", "project-4", "project-5");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use constant.

Comment on lines +40 to +42
for (String projectName : projectManager.getProjectNames()) {
assertThat(projectManager.getWorkspaceNames(projectName)).containsExactlyInAnyOrder("foo-test", "main");
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is what I was talking about. Then you could assert that project-1 has workspaces xyz and project-2 instead has abc (whatever).
And for test-data I have learned that it sooner or later hurts you if you use technical random instead of meaningful examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR that fixes a bug issue core FileAccess, ProcessUtil, IdeContext, etc. GUI Graphical User Interface of IDEasy (aka dashboard) build with JavaFx internal Nothing to be added to CHANGELOG, only internal story

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Enable state management for the IdeContext in the GUI.

3 participants