Skip to main content

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

What worked for us was extend NewJavaProjectWizardPageOne and override getCreateModuleInfoFile() like:

    @Override
    public boolean getCreateModuleInfoFile() {
        // Avoids the display of the Dialog to decide to create or not the module-info.java file.
        return false;
    }

but we use that extended page in another custom Wizard so maybe it is not directly useful for you.

On Tue, Feb 8, 2022 at 10:56 PM Alexander Kriegisch <alexander@xxxxxxxxxxxxxx> wrote:
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
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jdt-dev

Back to the top