Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 495680 - Improve "Type name must not be qualified" message in new Java class dialog
Summary: Improve "Type name must not be qualified" message in new Java class dialog
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.7 M2   Edit
Assignee: Noopur Gupta CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 426001 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-06-08 08:02 EDT by Lars Vogel CLA
Modified: 2016-09-08 09:20 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2016-06-08 08:02:43 EDT
In my training sessions with people new to the Eclipse IDE, I frequently see people typing the .java extension. The error message "Type name must not be qualified" seems not to help them. 

I suggest to improve this for them via one of the following alternatives:

1.) Allow that .java is specified and at a warning "Specifying the .java file extension is not necessary"
2.) Or change the "Type name must not be qualified" message to "The file extension %1 in the Name field must not be specified" and to repalce %1 with the specified file extension.
Comment 1 Dani Megert CLA 2016-06-08 10:53:29 EDT
In case it ends with ".java" I would issue an info message saying the ".java" should not be specified and will be ignored.
Comment 2 Noopur Gupta CLA 2016-06-16 07:21:39 EDT
*** Bug 426001 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2016-07-01 19:42:17 EDT
New Gerrit change created: https://git.eclipse.org/r/76459
Comment 4 Noopur Gupta CLA 2016-07-28 03:58:59 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/76459

The fix is not good as:

- NewTypeWizardPage.getTypeName() used to return the file name without any extension on Finish. With the patch, it returns the file name with extension. This causes problems at the clients like NewTestCaseWizard which add the extension .java explicitly to the returned file name.

- The extension checks should use String#endsWith instead of #contains and #replaceAll. Otherwise invalid extensions like ".java.java123" are also accepted.

- The added message should be an info instead of warning.

Also note that the fix has to go in NewTypeWizardPage which can be used for any Type that may have some other extension instead of .java. With this fix we will just be handling the .java case and for any other extension, we will still get the "Type name must not be qualified" message.

I will provide a patch for this.
Comment 6 Paul Benedict CLA 2016-08-08 15:05:16 EDT
Regarding the new message, I found the "should not be specified" part to be confusing. It begs the question why it shouldn't, why Eclipse allows it, and why it's being ignored. It creates a thinking moment. I recommend cutting out that part of the message.
Comment 7 Noopur Gupta CLA 2016-08-19 02:16:07 EDT
(In reply to Paul Benedict from comment #6)
> Regarding the new message, I found the "should not be specified" part to be
> confusing. It begs the question why it shouldn't, why Eclipse allows it, and
> why it's being ignored. It creates a thinking moment. I recommend cutting
> out that part of the message.

Fixed with:
http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=f653f9a350f14aa731798aeee4bb12a687d0c342
Comment 8 Lars Vogel CLA 2016-08-19 02:56:05 EDT
I think a better message would be something simular to: "Specifying .java is not nececcary."
Comment 9 Dani Megert CLA 2016-08-19 04:14:28 EDT
(In reply to Lars Vogel from comment #8)
> I think a better message would be something simular to: "Specifying .java is
> not nececcary."

That doesn't imply that we ignore it.
Comment 10 Lars Vogel CLA 2016-08-19 04:24:29 EDT
(In reply to Dani Megert from comment #9)
> (In reply to Lars Vogel from comment #8)
> > I think a better message would be something simular to: "Specifying .java is
> > not nececcary."
> 
> That doesn't imply that we ignore it.

I think the message that .java is ignored is misleading for the user. The resulting file has the extension .java. 

The current message shows implementation details to the user, which IMHO is not the best approach.
Comment 11 Paul Benedict CLA 2016-08-20 21:31:27 EDT
Thought Puzzle: If even the shortened message is confusing, then perhaps the fix started on the wrong assumption. My understanding regarding allowing ".java" was because it made it easy for users to paste in qualified names. So why not capture the paste event and automatically trim away the ".java" suffix? It will never be seen. That would be much better than changing the validation of the input box. No one should seriously be typing a file name extension; Eclipse should be helping the poor user (a certain newbie) from making that error. Let's separate out the typing vs. pasting? Restore the input validation error and trim away the suffix on a paste?
Comment 12 Dani Megert CLA 2016-09-08 06:06:07 EDT
(In reply to Paul Benedict from comment #11)
> Thought Puzzle: If even the shortened message is confusing, then perhaps the
> fix started on the wrong assumption. My understanding regarding allowing
> ".java" was because it made it easy for users to paste in qualified names.
> So why not capture the paste event and automatically trim away the ".java"
> suffix? It will never be seen. That would be much better than changing the
> validation of the input box. No one should seriously be typing a file name
> extension; Eclipse should be helping the poor user (a certain newbie) from
> making that error. Let's separate out the typing vs. pasting? Restore the
> input validation error and trim away the suffix on a paste?

The original bug was about typing. The paste case would be a new bug report.
Comment 13 Dani Megert CLA 2016-09-08 06:09:10 EDT
(In reply to Lars Vogel from comment #10)
> (In reply to Dani Megert from comment #9)
> > (In reply to Lars Vogel from comment #8)
> > > I think a better message would be something simular to: "Specifying .java is
> > > not nececcary."
> > 
> > That doesn't imply that we ignore it.
> 
> I think the message that .java is ignored is misleading for the user. The
> resulting file has the extension .java. 
> 
> The current message shows implementation details to the user, which IMHO is
> not the best approach.

It's not an implementation detail when the name is different than what's in the input field.

How about this:

File extension '.java' will be removed from the name.
Comment 14 Lars Vogel CLA 2016-09-08 06:16:47 EDT
(In reply to Dani Megert from comment #13) 
> How about this:
> 
> File extension '.java' will be removed from the name.

-2, this would be very misleading. I would read this as "The .java extension will be removed from the generated file" which is not what is happening.
Comment 15 Lars Vogel CLA 2016-09-08 06:18:59 EDT
IMHO the best solution possibilities are:

1.) Do not show a message, if the user types in .java
2.) Tell the user that this extension is not necessary, e.g. by saying: "Specifying the .java file extension is not necessary"
Comment 16 Dani Megert CLA 2016-09-08 06:38:11 EDT
(In reply to Lars Vogel from comment #14)
> (In reply to Dani Megert from comment #13) 
> > How about this:
> > 
> > File extension '.java' will be removed from the name.
> 
> -2, this would be very misleading. I would read this as "The .java extension
> will be removed from the generated file" which is not what is happening.

But on the other hand, you expect that it will be there in the file name when you don't even type it? That sounds strange.

How about

The file extension '.java' will not be part of the class name.
Comment 17 Lars Vogel CLA 2016-09-08 06:44:37 EDT
(In reply to Dani Megert from comment #16)
> The file extension '.java' will not be part of the class name.

+1 This is better than the current text. Maybe you can use a shorter form:

"The '.java' extension will not be part of the class name."
Comment 18 Noopur Gupta CLA 2016-09-08 09:20:42 EDT
Updated the message to:
The file extension '.java' will not be part of the type name.

Replaced "class" with "type" as this message is applicable to all the types.

Released with:
http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=286f3d7ce46ed43436f36af1a2e4e046a18d745c