Bug 102996 - [type wizards] don't create main for inner types

- In new Class wizard page; add check if enclosing type is selected but
NOT static modifier, if so, the selection box for creating main method
is deselected and disabled

Change-Id: Ibdbf1d5bd0f448738751292455ff10fae08bf0c2
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/189716
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Kalyan Prasad Tatavarthi <kalyan_prasad@in.ibm.com>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewClassWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewClassWizardPage.java
index bd65217..817d717 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewClassWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewClassWizardPage.java
@@ -134,6 +134,13 @@
 	protected void handleFieldChanged(String fieldName) {
 		super.handleFieldChanged(fieldName);
 
+		// disable creation of main if enclosing type is selected but not static modifier, otherwise this creates compilation error
+		if (isEnclosingTypeSelected() && !((getModifiers() & F_STATIC) > 0)) {
+			fMethodStubsButtons.setSelection(0, false);
+			fMethodStubsButtons.enableSelectionButton(0, false);
+		} else {
+			fMethodStubsButtons.enableSelectionButton(0, true);
+		}
 		doStatusUpdate();
 	}