Bug 244645 - "New Java Class" option should automatically create a Java Project
Summary: "New Java Class" option should automatically create a Java Project
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: IDE4EDU (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks: 300672
  Show dependency tree
 
Reported: 2008-08-19 22:18 EDT by Wayne Beaton CLA
Modified: 2014-01-09 15:38 EST (History)
3 users (show)

See Also:


Attachments
Add a page to the class wizard. (41.72 KB, patch)
2009-10-09 09:41 EDT, Nil Goyette CLA
no flags Details | Diff
Default MyAssignment project (8.18 KB, patch)
2009-10-09 17:58 EDT, Nil Goyette CLA
no flags Details | Diff
Default MyAssignment project, no src or bin folders created (4.08 KB, patch)
2010-01-17 11:16 EST, Miles Billsman CLA
no flags Details | Diff
Default MyAssignment project, no src or bin folders created, fixed (3.11 KB, patch)
2010-01-17 12:42 EST, Miles Billsman CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wayne Beaton CLA 2008-08-19 22:18:46 EDT
We should be able to create a default Java Project pretty easily.  If there are no Java Projects in the workspace, then create the default one. If there is only one Java Project in the workspace, we should assume that the user wants to create the class there. If the user has a Java Project selected (or one of it descendants), assume that the user wants to create the class there.

We may consider adding a hint to in the New Class wizard indicating that the class file can be dragged into an alternate location.
Comment 1 Nil Goyette CLA 2009-09-22 21:00:47 EDT
Maxime Caron and me are working on that.
Comment 2 Nil Goyette CLA 2009-10-09 09:41:04 EDT
Created attachment 149235 [details]
Add a page to the class wizard.

Add a page to the class wizard when there's 2 projects or more in the project explorer and none is selected. The new page show the list of project so the user can choose to which project he wants to add the new class.
Comment 3 Nil Goyette CLA 2009-10-09 09:54:38 EDT
Oh, sorry, the last attachment was more for https://bugs.eclipse.org/bugs/show_bug.cgi?id=246163

(I can't see an edit button to edit the post I wrote, is this normal?)
Comment 4 Wayne Beaton CLA 2009-10-09 11:03:06 EDT
Comment on attachment 149235 [details]
Add a page to the class wizard.

Marking attachment as obsolete.
Comment 5 Wayne Beaton CLA 2009-10-09 11:03:40 EDT
(In reply to comment #3)
> Oh, sorry, the last attachment was more for
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246163
> 
> (I can't see an edit button to edit the post I wrote, is this normal?)

Once you make a comment, it's here forever.
Comment 6 Nil Goyette CLA 2009-10-09 17:58:04 EDT
Created attachment 149284 [details]
Default MyAssignment project

Instead of a messagebox asking if the user want to create a java project, a default project is automaticaly created.
Comment 7 Brenda Sadoway CLA 2010-01-11 13:54:28 EST
I applied this patch to my workspace and it seems to work as I would expect.  However, Wayne mentioned the following in his first comment:

"We may consider adding a hint to in the New Class wizard indicating that the
class file can be dragged into an alternate location."

I actually wasn't able to drag a class to a new location, although I can when not in the Java Lite perspective.  If it's supposed to be possible to drag a class (maybe it is and it's a problem on my end?), I do like the idea of adding a hint to the New Class wizard though, so the student doesn't feel restricted to where the class was created by default.

It seems to me that this default MyAssignment project should also be created when the student tries to create a package in an empty workspace.  Is this something new that needs to be addressed?
Comment 8 Wayne Beaton CLA 2010-01-11 21:47:32 EST
(In reply to comment #7)
> I applied this patch to my workspace and it seems to work as I would expect. 
> However, Wayne mentioned the following in his first comment:
> 
> "We may consider adding a hint to in the New Class wizard indicating that the
> class file can be dragged into an alternate location."

I honestly don't know what I was thinking. Perhaps I meant that the wizard should indicate that the file can moved at some future point if necessary and that the student shouldn't worry about where it's being created. In retrospect, maybe it's just not worth saying.

Here's the lesson... capture your entire thought, not just some pithy sentence that inadequately reflects your thoughts...

> 
> I actually wasn't able to drag a class to a new location, although I can when
> not in the Java Lite perspective.  If it's supposed to be possible to drag a
> class (maybe it is and it's a problem on my end?), I do like the idea of adding
> a hint to the New Class wizard though, so the student doesn't feel restricted
> to where the class was created by default.

Part of what we're trying to do is avoid overloading the student with concerns. I'm inclined to have as little text/information as possible in these "simplified" wizards.

> It seems to me that this default MyAssignment project should also be created
> when the student tries to create a package in an empty workspace.  Is this
> something new that needs to be addressed?

Agreed.
Comment 9 Miles Billsman CLA 2010-01-17 11:04:24 EST
When the new project is automagically created, a src and bin folder is created by default. But when we create a new project explicitly the src and bin folders are not created. I prefer this behaviour since there will not be any need for src and bin folders when students are working on small beginner level assignments. One folder with their .java and .class files in it should be fine. 

I've worked on this and fixed it. I will attach a patch for this.
Comment 10 Miles Billsman CLA 2010-01-17 11:16:01 EST
Created attachment 156322 [details]
Default MyAssignment project, no src or bin folders created

This patch makes the patch from Oct. 9 obsolete. 

We simply need to change the preferences for new project creation before creating the MyAssignment project.
Comment 11 Miles Billsman CLA 2010-01-17 12:42:26 EST
Created attachment 156330 [details]
Default MyAssignment project, no src or bin folders created, fixed

Ooops! I haven't made a patch before. Lesson learned. Now I know, only create a patch when you don't have any other patches for other bugs applied.

This version works. Enjoy.
Comment 12 Wayne Beaton CLA 2010-01-20 17:21:15 EST
Let me apologise in advance. I apologise.

The solution we have here makes me feel icky. We're basically hacking the crap out of a wizard that we've liberated from the JDT project. I don't think that this is the right approach. For starters, all those compiler warnings are a good indication that we're doing it wrong.

I open Bug 299332 to address this, at least in part. With this bug, I would like to separate out the two different aspects of class creation. Bug 299332 addresses the Java project creation problem by introducing the notion of a "Java Project Constructor". I will open a new bug to create a "Java Class Constructor" object. All of the code that we need to build the suggested "constructor" object is contained in the JDT "New Java Class" wizard that we're currently hacking. Then, there's the actual GUI code. I believe that, with the "constructor" code extracted from the GUI, the GUI code will become _very_ simple. Right now, we're hiding stuff, and accessing fields that we're not displaying, etc. This is a recipe for disaster: when/if JDT changes the internal code that their wizard uses, our code will break. This is not good.

I'm inclined to close this bug as WONTFIX in favour of a new bug that proposes the creation of a replacement wizard.

I'm also interested in some out-of-the-box thinking about how we can change this wizard into something better/more useful.
Comment 13 Wayne Beaton CLA 2010-01-20 17:35:54 EST
I've opened Bug 300275 to create a "Java Class Constructor" class.
Comment 14 Wayne Beaton CLA 2010-01-29 16:59:28 EST
This bug has been FIXED as a result of work done on Bug 300275 and Bug 300672. Marking as FIXED.