Skip to content

Commit

Permalink
Mandate a package name in NewClassWizard when project is a module (#1335
Browse files Browse the repository at this point in the history
)

- fixes #1328
  • Loading branch information
jjohnstn committed Apr 18, 2024
1 parent 52791d3 commit 57767ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -112,6 +112,7 @@ private NewWizardMessages() {
public static String NewTypeWizardPage_enclosing_button;
public static String NewTypeWizardPage_error_InvalidPackageName;
public static String NewTypeWizardPage_error_ClashOutputLocation;
public static String NewTypeWizardPage_error_PackageNameEmptyForModule;
public static String NewTypeWizardPage_warning_DiscouragedPackageName;
public static String NewTypeWizardPage_warning_DefaultPackageDiscouraged;
public static String NewTypeWizardPage_warning_NotJDKCompliant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2022 IBM Corporation and others.
# Copyright (c) 2000, 2024 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -86,6 +86,7 @@ NewTypeWizardPage_enclosing_button=Bro&wse...

NewTypeWizardPage_error_InvalidPackageName=Package name is not valid. {0}
NewTypeWizardPage_error_ClashOutputLocation=Package clashes with project output folder.
NewTypeWizardPage_error_PackageNameEmptyForModule=A package name must be specified for a module.
NewTypeWizardPage_error_uri_location_unkown=Cannot locate resource {0}
NewTypeWizardPage_warning_DiscouragedPackageName=This package name is discouraged. {0}
NewTypeWizardPage_warning_DefaultPackageDiscouraged=The use of the default package is discouraged.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2023 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -1900,7 +1900,15 @@ protected IStatus packageChanged() {
// continue
}
} else {
status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
try {
if (project != null && project.getModuleDescription() != null) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameEmptyForModule);
} else {
status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
} catch (JavaModelException e) {
status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
}

if (project != null && root != null) {
Expand Down

0 comments on commit 57767ee

Please sign in to comment.