This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 248304 - Added an ability to convert a folder into a project
Summary: Added an ability to convert a folder into a project
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Projects UI (show other bugs)
Version: 8.1
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 246846
  Show dependency tree
 
Reported: 2014-10-31 10:38 UTC by Tomas Zezula
Modified: 2014-12-14 05:25 UTC (History)
3 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Diff file (54.94 KB, patch)
2014-10-31 10:45 UTC, Tomas Zezula
Details | Diff
Diff file (56.76 KB, patch)
2014-11-03 07:44 UTC, Tomas Zezula
Details | Diff
Diff file (72.56 KB, patch)
2014-11-03 14:32 UTC, Tomas Zezula
Details | Diff
Diff file (84.24 KB, patch)
2014-11-04 09:59 UTC, Tomas Zezula
Details | Diff
Patch for HTML5 project convertor (6.14 KB, patch)
2014-11-04 10:40 UTC, Tomas Mysik
Details | Diff
commit validation change (849 bytes, patch)
2014-11-25 12:11 UTC, Tomas Mysik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2014-10-31 10:38:28 UTC
For the folder accepted by the ProjectConvertor an artifical in memory project is created causing the folder looks like a regular Project in the UI. The folder is converted into a regular the Project when the artificial Project is opened.
Comment 1 Tomas Zezula 2014-10-31 10:45:04 UTC
Created attachment 150184 [details]
Diff file

The diff file contains the SPI, implementation, tests and an example of the ProjectConvertor for J2SE Ant based project. The J2SE Project convertor is only sample and will NOT be a part of final commit.
Comment 2 Tomas Zezula 2014-11-03 07:44:28 UTC
Created attachment 150222 [details]
Diff file

The optional convertor lookup is kept as a part of the artificial project lookup after real project creation. This allows a better control over the project services by convertor implementer who can decide which services will be removed and preserved himself.
Comment 3 Jaroslav Tulach 2014-11-03 09:37:09 UTC
Y01 Please design the registration to not load all providers on startup - e.g. consider adding @ProjectConvertor.Registration(requiredFile = { "build.xml" }, iconBase = "...") which would delay the instantiation of client code until at least one of the required files is found. I'd like to avoid initializing HTML5 project classes as soon as IDE is loaded.

Y02 What is the relation to ide.ergonomics? Should ergonomics be also aware of convertors?
Comment 4 Tomas Mysik 2014-11-03 09:39:35 UTC
Ad Y01: Tome, please allow to specify more file names. Thanks.
Comment 5 Tomas Zezula 2014-11-03 14:32:30 UTC
Created attachment 150241 [details]
Diff file

Split the default convertor services to non UI services (ProjectInformation) in projectui.base and UI services (LogicalView) in projectui. Added internal SPI for locating the services.
Comment 6 Tomas Zezula 2014-11-03 14:42:44 UTC
Y01 & TM01: The ProjectConvertor.isProject(FileObject) is stronger than the pattern based detection. However for most cases the pattern detection is OK.
So I will add the pattern detection using @Registration in addition to the ProjectConvertor.isProject(). In fact the @Registration processor will just generate a wrapping ProjectConvertor for you.

Y02: It depends. For the WebIDE it's not needed as the ergonomics is not present. But it would be nice if the ergonomics will work with convertors. It's probably not possible for ergonomics to work with generic ProjectConvertor but it's possible to work  with the pattern based convertor registered using the @Registration.
Comment 7 Tomas Mysik 2014-11-04 08:23:42 UTC
Y01 & TM01: Perhaps we could "skip" isProject() if filePattern will be present to save some resources. Is this what you meant?
Comment 8 Tomas Zezula 2014-11-04 08:44:45 UTC
TM02: Perhaps we could "skip" isProject() if filePattern will be present to save some resources.
No, it's not a good idea as for real word project convertors a content of file is important, eg. delete apisupport and click on the apisupport module with ergonomics.
Also you will lose the correct display name and possibly other services.
Comment 9 Tomas Zezula 2014-11-04 09:59:13 UTC
Created attachment 150260 [details]
Diff file

Patch with added @Registration annotation.
The ProjectConvertor is wrapped by an module private ProjectConvertorAcceptor. The ProjectConvertor.isProject is not called unless the pattern from @Registration matches the project file. When the pattern matches the PC.isProject is called to do additional verification (possibly read content of project file) and returns a Result.
Comment 10 Tomas Mysik 2014-11-04 10:40:49 UTC
Created attachment 150261 [details]
Patch for HTML5 project convertor

Attaching patch for HTML5 project convertor, seems to be working without any problem.
Comment 11 Tomas Zezula 2014-11-04 11:59:13 UTC
The patch for HTML5 project convertor seems good to me, it's nearly identical to J2SEProjectConvertor. So it should work OK.
Comment 12 Tomas Mysik 2014-11-05 09:04:32 UTC
(In reply to Tomas Zezula from comment #11)
> The patch for HTML5 project convertor seems good to me, it's nearly
> identical to J2SEProjectConvertor. So it should work OK.

I will try to improve it a bit then (to add detection of possible SiteRoot folder - searching for "public" or "www" folder could be OK I guess).

Thanks.
Comment 13 Tomas Mysik 2014-11-05 12:59:33 UTC
TM03: If a convertor needs to know some information from the user since the information is not present in the well-known file - is it possible to ask for it? Can I show some dialog in the Factory (that implements Callable<Project>)? Or it is a bad idea and there should not be anything like this done in any convertor.

Thanks.
Comment 14 Petr Jiricka 2014-11-05 13:43:26 UTC
I agree that asking the user would be the best option from the user's point of view.

> searching for "public" or "www" folder could be OK I guess

I would also add "app" - that's becoming increasingly more common, and e.g. Yeoman uses that (see 'yo webapp --help').
Comment 15 Tomas Zezula 2014-11-05 16:12:51 UTC
It's not guaranteed that it's called from the EDT.
It's not good to ask user during the convert, the convert should be lightway without user feedback. The feedback will be quite strange as you in fact opening project, if you need a wizard it has not much sense.
Have you seen a dialog during opening project?
What it you open 100 projects? Should be 100 dialogs opened?
Comment 16 Tomas Mysik 2014-11-06 07:09:30 UTC
(In reply to Tomas Zezula from comment #15)
> It's not guaranteed that it's called from the EDT.
> It's not good to ask user during the convert, the convert should be lightway
> without user feedback. The feedback will be quite strange as you in fact
> opening project, if you need a wizard it has not much sense.
> Have you seen a dialog during opening project?
> What it you open 100 projects? Should be 100 dialogs opened?

So, a bad idea I see :)
Comment 17 Tomas Zezula 2014-11-06 16:14:29 UTC
I suggest the following solution. Whenever you need some user data create a project without these additional data and add a ProjectProblem with appropriate severity (Severity.ERROR for broken project, Severity.WARNING for some non needed data).
Comment 18 Tomas Mysik 2014-11-07 06:29:48 UTC
(In reply to Tomas Zezula from comment #17)
> I suggest the following solution. Whenever you need some user data create a
> project without these additional data and add a ProjectProblem with
> appropriate severity (Severity.ERROR for broken project, Severity.WARNING
> for some non needed data).

I wanted to ask for e.g. SiteRoot - this is not a good case for a project problem (project does not need to have SiteRoot). But no problem, we will simply try to detect it and set it to project directory if the detection fails.

Thanks.
Comment 19 Petr Jiricka 2014-11-07 08:01:10 UTC
Maybe there can be a low-severity project problem called something like "Review and correct important project settings detected by the IDE".
Comment 20 Tomas Mysik 2014-11-07 08:21:32 UTC
Good idea, will try to do that.
Comment 21 Tomas Zezula 2014-11-07 09:44:56 UTC
>Maybe there can be a low-severity project problem 
Yes, there is a ProjectProblem.Severity.WARNING which does not mark project as broken. Just adds the item into project problems. Currently it's used by Maven.
Comment 22 Tomas Zezula 2014-11-07 10:10:30 UTC
I am going to integrate the change.
Comment 23 Tomas Zezula 2014-11-07 10:24:34 UTC
Fixed jet-main 226dbe7ee9d9
Comment 24 Quality Engineering 2014-11-21 03:50:34 UTC
Integrated into 'main-silver', will be available in build *201411210001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/226dbe7ee9d9
User: Tomas Zezula <tzezula@netbeans.org>
Log: #248304:Added an ability to convert a folder into a project
Comment 25 Tomas Mysik 2014-11-24 09:37:46 UTC
BTW used for HTML5 project now, works perfectly. Once such project is converted/created, a notification is shown on its first opening in the IDE (this notification is shown just once).

Thanks.

http://hg.netbeans.org/web-main/rev/b6077f92c20d
http://hg.netbeans.org/web-main/rev/ee23bc1edbe1
Comment 26 Tomas Mysik 2014-11-24 11:18:51 UTC
BTW adding position for the PRojectCOnvertor instance caused that the build is unstable, see [1]. One problem seems to be the "position" attribute; the other one seems to be related to the proper service instance [2].

Tome/Jardo, could you please have a look at it?

Thanks.
[1] http://deadlock.netbeans.org/job/web-main/1577/
[2] Some instances cannot be created
File Services/org-netbeans-modules-web-clientproject-ClientSideProjectConvertor.instance should declare instanceOf
Comment 27 Tomas Mysik 2014-11-25 12:11:16 UTC
So, removing position helps with the position attribute test (surprise :) but the other error [1] still remains (see [2]).

I will attach patch (updated commit validation test to ignore my ProjectConvertor, at least I hope so) - wouldn't it be better to put all ProjectConvertor instances into e.g. [Services/]ProjectConvertors and ignore/whitelist just this folder? It would mean that all future implementatitons would pass the commit validation without any problem.

Thanks.
[1] Some instances cannot be created
File Services/org-netbeans-modules-web-clientproject-ClientSideProjectConvertor.instance should declare instanceOf
[2] http://deadlock.netbeans.org/job/web-main/1580/
Comment 28 Tomas Mysik 2014-11-25 12:11:49 UTC
Created attachment 150689 [details]
commit validation change
Comment 29 Tomas Mysik 2014-11-25 19:01:32 UTC
(In reply to Tomas Mysik from comment #27)
> Some instances cannot be created
> File
> Services/org-netbeans-modules-web-clientproject-ClientSideProjectConvertor.
> instance should declare instanceOf

I tried to fix this issue [1]; Tome, please review my fix and feel free to improve it if needed.

Thanks!
[1] http://hg.netbeans.org/web-main/rev/02f698e2efb9
Comment 30 Tomas Mysik 2014-11-25 20:30:30 UTC
Since web-main is again stable now [1], the only problem that exists now is the "position" attribute.

Thanks.
[1] http://deadlock.netbeans.org/job/web-main/1585/
Comment 31 Quality Engineering 2014-11-26 04:23:16 UTC
Integrated into 'main-silver', will be available in build *201411260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/02f698e2efb9
User: Tomas Mysik <tmysik@netbeans.org>
Log: #248304 cont'd - Added an ability to convert a folder into a project

Generate instanceOf attribute as well.
Comment 32 Quality Engineering 2014-12-14 05:25:50 UTC
Integrated into 'main-silver', will be available in build *201412140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c14c5579baae
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #248304: Documenting and changing location of generated convertor registrations. Needed by my work on bug 248887