Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] How to programmatically uncheck "Create module-info.java" in NewJavaProjectWizardPageOne?

The "new Java project" wizard contains class
NewJavaProjectWizardPageOne. In commit [1], a new checkbox "Create
module-info.java" was added by Kalyan Prasad Tatavarthi. This causes
some trouble in an AspectJ UI test which basically creates a few
projects and verifies something. In doing so, it also sets a few field
values via reflection, because the necessary fields and methods are
private. This is ugly, but it works and is better than copy-pasting the
whole class in order to create a 95% duplicate with some accessible
members.

In our use case, we want to explicitly uncheck the checkbox, because we
do not want to create a modular project. We also want to avoid the
asynchronous pop-up dialogue asking for the module name. Even though
executing the reflective equivalent of

fFirstPage.fModuleGroup.fCreateModuleInfo.setSelection(false);

in the wizard extension used for our test before calling
'super.finishPressed()', the pop-up appears and makes the whole test
suite time out. I tried waiting for 1 up to 10 seconds both before and
after setting the value, which helps on my local Windows workstation but
still seems to be not enough in a GitHub workflow running the same test.
I also tried the reflective equivalent of

fFirstPage.fModuleGroup.fCreateModuleInfo.setSelection(false);
fFirstPage.fModuleGroup.savePreference = true;

to no avail. Actually, I am just trying to fix an old test which works
nicely on Linux and MacOS (maybe by chance). I have no experience
whatsoever with Eclipse UI programming (JFace, SWT) and would welcome
hints about how to reliably and without ugly wait loops uncheck that box
before clicking "Finish" right from wizard page 1.

[1] https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java?id=39b14df0a8be80c7fbc8f9cddab4bf1217626fda

-- 
Alexander Kriegisch
https://scrum-master.de


Back to the top