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 226124 - UI for switching the project's target browser in the toolbar
Summary: UI for switching the project's target browser in the toolbar
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Extbrowser (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on: 227132
Blocks:
  Show dependency tree
 
Reported: 2013-02-14 14:24 UTC by Petr Jiricka
Modified: 2013-04-04 07:47 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
API patch (83.31 KB, patch)
2013-03-06 02:50 UTC, David Konecny
Details | Diff
implementation modules patch (105.54 KB, patch)
2013-03-06 02:50 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2013-02-14 14:24:50 UTC
For the next release, all (or most) web application-related project types will contain UI for switching the target browser in project properties:
- HTML5 Project
- Java Web Ant Project
- Java Web Maven Project
- PHP project

With the exception of HTML5 project, this UI is only in project properties, and is not easily discoverable. This makes it less convenient to test web applications with various browsers, and to use the JavaScript debugging features available with Chrome and Embedded WebKit browser.

To improve discoverability and allow convenient switching of browsers, it would be useful to present the UI for switching browsers in a more prominent location, e.g. in the IDE toolbar. At the same time, the UI should not take up too much screen estate. So I suggest the following UI:

- Icon button representing the browser + down arrow that activates the menu (similar to e.g. the Debug button)
- The menu will contain the list of registered browsers (icon + textual description)
- The UI will be project-sensitive, i.e. the selected browser will match the browser that's selected in the project properties of the activated project (similarly to the project configurations combo box)
- If the activated project does not support browser selection (e.g. Java SE project or C++ project), the browser selection button will be grayed out
- This toolbar button will not be present at all in NetBeans distributions that do not contain web development features (Java SE and C++)

As a follow-up step, we can consider deemphasizing or removing the concept of project configurations in HTML5 projects, as this UI would to a large extent replace the HTML5 project configurations concept (with the possible exception of PhoneGap build).
Comment 1 Petr Jiricka 2013-02-19 15:27:39 UTC
I just discussed this with Honza Becicka, cc'ing.

One point that Honza made is that in the future, for a few more browsers (besides Chrome) we may want to have two modes - with NetBeans integration (debug) and without NetBeans integration (non-debug). Namely, targets "Android Device", "Android Emulator", "iPhone Device" and "iPhone Simulator" may all have these two variants - which would make the list very long and harder to use. 

We were thinking how to get around this - one idea is to use the "Run" and "Debug" action distinction, i.e. Run action would launch the browser without NB integration, Debug action would launch it with NB integration. But this has disadvantages that:
- It makes NetBeans integration harder to discover, some people will always hit run and will not know that Debug will give them more features
- While this association makes some sense for JavaScript debugging, it does not really make sense for visual CSS styling: how would I know that I need to "Debug" if I want to use the visual style editor?
- For (Java, PHP) web projects, Debug action already has the semantics of "server-side debugging", so adding more meaning to this action could create more confusion. Also, we would face questions like what if I want to debug the server side, but not the client side, or vice versa?

So I would suggest the following solution instead: The drop-down menu associated with the browser selection button would have an extra checkbox (2-state item) called something like "NetBeans integration". Then each browser would appear in the menu only once, and depending on the state of the NetBeans integration item, the browser would be run in debug mode or not. So the menu would look e.g. like this:

[ ] NetBeans Integration
--------------------
Chrome
Safari
Firefox
External Browser (command line)
Android Device
Android Emulator
iPhone Simulator
--------------------
Customize...


The corresponding change would need to be made in project properties of all the relevant project types.
Comment 2 Petr Jiricka 2013-02-19 16:59:53 UTC
One other thing - the state of the NetBeans Integration checkbox could be communicated to the user in the toolbar icon via a badge - i.e. if NB integration is enabled, the browser icon in the toolbar would be badged with the NetBeans cube.

What do you think?
Comment 3 Tomas Mysik 2013-02-25 07:03:24 UTC
Sounds good to me. The only problem I see is that it seems that we have NB integration for all browsers in the list - or not? We should somehow tell user which browsers have NB integration.

Thanks.
Comment 4 David Konecny 2013-03-06 02:10:19 UTC
I'm going to attach two patches:
* one with API changes
* second with mainly implementation changes

The patches implement browser combo box requested by this issue and changes to Web Project and HTML5 project. Nothing was done for PHP project and it will need to be fixed before I can push this change - should be small change. Changes in HTML5 were drastic in area of org.netbeans.modules.web.clientproject.spi.platform package and handling of project configurations. I patched the cordova modules just so that they compile but they will require some work to be done to avoid regression in current functionality.

Tomas, Honza, could you review please? You should be able to apply the patches and build your modules and see how it works.

Honza, regarding "org.netbeans.modules.web.clientproject.spi.platform" package: I got rid of everything "project configuration" specific; I renamed existing classes to differentiate them from the old ones but new names are pretty long - ClientProjectEnhancedBrowserImplementation. Any suggestions are welcome. Before everything revolved around Project Configuration and now it is "WebBrowser" (see WebBrowser.getBrowserFamilyId). ClientProjectEnhancedBrowserImplementation.getProjectConfigurationProvider is the only addition and allows you to return different configurations per browser type. I tested it and it works quite well - configurations combo gets enabled/disabled as you change browsers depending on if they have configurations or not.

There is an small API change for openide.awt to show drop down button as a single button without that line separator between drop down arrow and button itself. I will file it separately once we agreed above patches are OK.

Thanks for any comments.
Comment 5 David Konecny 2013-03-06 02:50:30 UTC
Created attachment 132235 [details]
API patch
Comment 6 David Konecny 2013-03-06 02:50:59 UTC
Created attachment 132236 [details]
implementation modules patch
Comment 7 Tomas Mysik 2013-03-06 11:22:50 UTC
I am not able to apply the 2nd patch against the current trunk [1].

Thanks.
[1]
patching file cordova/src/org/netbeans/modules/cordova/project/ClientProjectConfigurationImpl.java
Hunk #1 FAILED at 49
Hunk #2 FAILED at 60
Hunk #3 FAILED at 70
Hunk #4 FAILED at 79
Hunk #5 FAILED at 131
Hunk #6 FAILED at 141
Hunk #7 FAILED at 155
Hunk #8 succeeded at 110 with fuzz 1 (offset -76 lines).
7 out of 8 hunks FAILED -- saving rejects to file cordova/src/org/netbeans/modules/cordova/project/ClientProjectConfigurationImpl.java.rej
Comment 8 Petr Jiricka 2013-03-06 14:45:04 UTC
> Nothing was done for PHP project and it will need to be fixed

Not sure if some changes will also need to be done for Maven project, cc'ing Martin J.
Comment 9 David Konecny 2013-03-07 03:08:20 UTC
I created branch browser_toolbar_selector and put the change there. Let's use it to finish this feature.
Comment 10 Jan Becicka 2013-03-07 14:14:14 UTC
(In reply to comment #9)
> I created branch browser_toolbar_selector and put the change there. Let's use
> it to finish this feature.

build failed in php.project module...
Comment 11 Petr Jiricka 2013-03-07 14:50:04 UTC
I think the hotfix is to add a second 'true' parameter in CustomizerBrowser:70:

        browserModel = WebBrowserSupport.createBrowserModel(uiProps.getBrowserId(), true);
Comment 12 David Konecny 2013-03-07 17:47:11 UTC
(In reply to comment #11)
> I think the hotfix is to add a second 'true' parameter in CustomizerBrowser:70:
> 
>         browserModel =
> WebBrowserSupport.createBrowserModel(uiProps.getBrowserId(), true);

Yes. Or build only javaee cluster as I do.
Comment 13 Jan Becicka 2013-03-08 08:45:53 UTC
If I understand it well, the phonegap module is required to provide ClientProjectEnhancedBrowserProvider, right?
How should phonegap module provide icons and display names for Android, iOS and PhoneGap browsers?
Thanks
Comment 14 David Konecny 2013-03-10 23:00:43 UTC
(In reply to comment #13)
> If I understand it well, the phonegap module is required to provide
> ClientProjectEnhancedBrowserProvider, right?

ClientProjectEnhancedBrowserProvider is a way to hook your browser into ClientSide project's ActionProvider, customizer, etc. In order to use ClientProjectEnhancedBrowserProvider you will first need to be able to create WebBrowser for your phonegap browsers.

> How should phonegap module provide icons and display names for Android, iOS and
> PhoneGap browsers?

Yeah, I knew this will need to be enhanced. Done in

changeset:   247723:754ce9ec9958
branch:      browser_toolbar_selector
tag:         tip
user:        David Konecny <dkonecny@netbeans.org>
date:        Mon Mar 11 11:52:16 2013 +1300
summary:     making browser icon and display name configurable via browser factory

Basically your browser factory must implement org.openide.awt.HtmlBrowser.Factory and org.netbeans.modules.web.browser.spi.EnhancedBrowserFactory.

Please let me know if something else is missing. Or if you would prefer to change some APIs completely. Or just change it yourself. Thanks.

I also fixed the PHP project:

changeset:   247722:c84097b69fe0
branch:      browser_toolbar_selector
parent:      247558:a909f51206a9
user:        David Konecny <dkonecny@netbeans.org>
date:        Mon Mar 11 11:49:53 2013 +1300
summary:     fixing broken build
Comment 15 Jan Becicka 2013-03-20 12:45:01 UTC
As we discussed offline, current impl is not yet sufficient. I created 2 dummy browsers to test API: Cordova browser and Android Browser. They did not do any real browsing, but I'm still not able to plug them correctly into the UI. David, I'd like to ask you to register these 2 for me.
Thanks

changeset:   248296:9e65f6c1c6dc
branch:      browser_toolbar_selector
tag:         tip
user:        Jan Becicka <jbecicka@netbeans.org>
date:        Wed Mar 20 13:39:17 2013 +0100
summary:     Dummy implementation of android and phonegap browser
Comment 16 David Konecny 2013-03-21 00:54:16 UTC
Done: 5495b2a0bd9f
Comment 17 Jan Becicka 2013-03-21 16:08:42 UTC
Thanks David,
I work on an implementation:
changeset   : 248641:b5f65da23253
branch      : browser_toolbar_selector
tags        : tip 
author      : Jan Becicka <jbecicka@netbeans.org>
date        : Thu Mar 21 16:56:19 CET 2013
summary     : Browser switcher - Android Rewrite

Now I have problem with multiple instances of android browser. I cannot select the first one in the UI.
The problem probably is, that there are 2 instances of WebBrowser with the very same "id". Both instances of WebBrowser returns "ANDROID" from getId().
Probably we need to introduce new method "getId" in EnhancedBrowserFactory ?

public interface EnhancedBrowserFactory {

    BrowserFamilyId getBrowserFamilyId();
    Image getIconImage();
    String getDisplayName();
+ String getId();    
}
Comment 18 David Konecny 2013-03-21 19:55:42 UTC
(In reply to comment #17)
> Both instances of WebBrowser returns "ANDROID" from getId().
> 
> public interface EnhancedBrowserFactory {
> + String getId();    
> }

Yeah, I left a comment in the code that this might be needed. Existing browsers get their ID because they are registered in default filesystem as a Settings file and ID is the filename. I considered the same approach for Services/MobileBrowsers but it too much "registration work" so I wanted to make it easier for you.

I will add getId() today.
Comment 19 David Konecny 2013-03-21 21:35:38 UTC
Done:
3cd5ffbd1d68
and
fcd96e9f71c5
Comment 20 Jan Becicka 2013-03-22 10:26:59 UTC
Now PhoneGap works - let say - the same way like before

changeset   : 248747:6c4eb4dd5cbd
branch      : browser_toolbar_selector
author      : Jan Becicka <jbecicka@netbeans.org>
date        : Fri Mar 22 11:17:34 CET 2013
summary     : Browser switcher - iOS and Android Rewrite

From my point of view I think, that this branch can be merged to trunk and continue there...
Comment 21 Petr Jiricka 2013-03-22 14:52:13 UTC
Thanks a lot Honza and David - most scenarios now work fine for me.

> I think, that this branch can be merged to trunk and continue there...

The remaining things that I am aware of are:
- PhoneGap application deployment to iOS Simulator does not work for me, but I am not sure if I am doing something wrong
- I just filed bug 227824 related to some remaining UI issues
- The browser switcher combo box is not integrated with Maven web projects
- Mobile browsers are not visible in the combo box for Java web/PHP projects (enhancement 225836)

Not sure how easy these will be to resolve. If they may require some substantial changes, then I think we should make these substantial changes on the branch. If not, then I agree we can merge to trunk and continue there.
Comment 22 Jan Becicka 2013-03-22 15:07:20 UTC
> The remaining things that I am aware of are:
> - PhoneGap application deployment to iOS Simulator does not work for me, but I
issue 227820?
if not please file a new one. Probably not related to this changes.

> - Mobile browsers are not visible in the combo box for Java web/PHP projects
> (enhancement 225836)

should be easily fixed. just need to do proper registration.
Comment 23 Petr Jiricka 2013-03-22 17:38:15 UTC
> > - PhoneGap application deployment to iOS Simulator does not work for me, but I
> issue 227820?
> if not please file a new one. Probably not related to this changes.

No, it was different (build succeeded, simulator was launched, but it only showed black screen), but after resetting the simulator everything works fine now.
Comment 24 Jan Becicka 2013-03-26 15:30:34 UTC
Branch merged to default
Comment 25 Vladimir Riha 2013-03-27 10:39:53 UTC
Browser switcher seems to be disabled for PHP projects (gray icon & unclickable). Is it supposed to work already with PHP?


Product Version: NetBeans IDE Dev (Build web-main-10182-on-20130327)
Comment 26 Petr Jiricka 2013-03-27 10:49:04 UTC
Same for me. I also thought this was supposed to work. Tomas, do you know what needs to be done?
Comment 27 Tomas Mysik 2013-03-27 12:09:29 UTC
No, I don't work on the branch at all.
Comment 28 Quality Engineering 2013-03-28 02:14:16 UTC
Integrated into 'main-golden', will be available in build *201303272300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4e2b6b6b3384
User: David Konecny <dkonecny@netbeans.org>
Log: #226124 - UI for switching the project's target browser in the toolbar
initial work to implement this feature; see the issue for more details
Comment 29 Vladimir Riha 2013-04-02 14:52:00 UTC
The issue with PHP project seems to be a bit random, restarting IDE sometimes helps. Also if you're creating new PHP file, you can see that browser icon changes for a second from e.g. Chrome with NB to the gray ("disabled") icon
Comment 30 David Konecny 2013-04-03 02:20:19 UTC
(In reply to comment #29)
> The issue with PHP project seems to be a bit random, restarting IDE sometimes
> helps. Also if you're creating new PHP file, you can see that browser icon
> changes for a second from e.g. Chrome with NB to the gray ("disabled") icon

Tomas, have a look at org.netbeans.modules.web.clientproject.browser.ActiveBrowserAction - the action is sensitive to content of lookup of selected node. The code was copied from MainProjectAction. Perhaps some nodes in PHP project are missing FO/DO in their lookup??
Comment 31 Tomas Mysik 2013-04-03 12:01:39 UTC
(In reply to comment #30)
> Perhaps some nodes in PHP project are missing FO/DO in their lookup??

Well, I am not expert in nodes but I think that in PHP, we use FileObject everywhere (I remember that there were performance problems with DataObjects so FileObjects should be used as much as possible). OTOH, why does ActiveBrowserAction use DataObjects at all? Just for finding project via its FileObject? I can be wrong, but it seems to me that FileObject should be enough...

Thanks.
Comment 32 David Konecny 2013-04-03 23:30:03 UTC
As I said the body of ActiveBrowserAction was mostly copied from the existing MainProject action assuming the action worked well in the past in the PHP context. Feel free to enhance the ActiveBrowserAction in any way you want.
Comment 33 Tomas Mysik 2013-04-04 07:16:38 UTC
(In reply to comment #32)
> As I said the body of ActiveBrowserAction was mostly copied from the existing
> MainProject action assuming the action worked well in the past in the PHP
> context.

Not exact - we have never used Main project functionality in PHP.

> Feel free to enhance the ActiveBrowserAction in any way you want.

I will do it.

Thanks.
Comment 34 Tomas Mysik 2013-04-04 07:47:43 UTC
(In reply to comment #32)
> Feel free to enhance the ActiveBrowserAction in any way you want.

http://hg.netbeans.org/web-main/rev/e167e619811b