NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Update Center issue: How to hide/remove items from the Available Plugins tab

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
jhuber



Joined: 22 Jul 2011
Posts: 69

PostPosted: Wed Apr 13, 2016 4:07 pm    Post subject: Update Center issue: How to hide/remove items from the Available Plugins tab Reply with quote

Hello!

I have a Netbeans 8.0.1 platform suite/application App1 that has its own update center. I have another platform application App2 with its own modules that uses App1 as a library, but some of the modules from App1 are disabled. App2 also has its own separate update center.

The problem is that when I goto Tools->Plugins in App2, under the "Available Plugins" tab, it shows the modules that I have disabled in App1 as available for install. This is undesirable, since one of the reasons I created App2 is because I do not want the users to have access to those disabled App1 modules.

Is there some way to prevent those disabled App1 modules from showing up in the "Available Plugins" tab?

Thanks!
Back to top
Peter Hansson
Posted via mailing list.





PostPosted: Thu Apr 14, 2016 5:22 pm    Post subject: Update Center issue: How to hide/remove items from the Available Plugins tab Reply with quote

I'm not aware if this can be fixed with the standard UI component in the Platform.


However:

Are you aware that you are by no means forced to use the standard UI for Auto Update ?  (i.e. the one you find in Tools --> Plugins)

You can roll your own UI for that if you want. You just need to hook into the NetBeans Auto Update Services API (http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-autoupdate-services/org/netbeans/api/autoupdate/package-summary.html). In fact you can completely get rid of the UI if you want and do everything in the background if you don't want to leave your users any choice.

The API isn't the most intuitive to work with. It throws a lot of new terminology at you. Personally I learned a lot about how this works from "The Definitive Guide To NetBeans Platform 7" by Heiko Böck (chapter 36 and chapter 25). Try Google. The book is rather old but still the best source I know of for this particular subject.

If you are creating an NB application where you want to customize how the module install/update mechanism works, meaning you want full control, then especially chapter 25 has been an eye opener for me.


Enjoy.


Peter









On Wed, Apr 13, 2016 at 6:07 PM, jhuber <address-removed ([email]address-removed[/email])> wrote:
Quote:
Hello!

I have a Netbeans 8.0.1 platform suite/application App1 that has its own update center.  I have another platform application App2 with its own modules that uses App1 as a library, but some of the modules from App1 are disabled.  App2 also has its own separate update center.

The problem is that when I goto Tools->Plugins in App2, under the "Available Plugins" tab, it shows the modules that I have disabled in App1 as available for install.  This is undesirable, since one of the reasons I created App2 is because I do not want the users to have access to those disabled App1 modules.

Is there some way to prevent those disabled App1 modules from showing up in the "Available Plugins" tab?

Thanks!




Back to top
jhuber



Joined: 22 Jul 2011
Posts: 69

PostPosted: Thu Apr 14, 2016 9:56 pm    Post subject: Re: Update Center issue: How to hide/remove items from the Available Plugins tab Reply with quote

Peter Hansson wrote:
I'm not aware if this can be fixed with the standard UI component in the Platform.

However:

Are you aware that you are by no means forced to use the standard UI for Auto Update ?  (i.e. the one you find in Tools --> Plugins)

You can roll your own UI for that if you want. You just need to hook into the NetBeans Auto Update Services API (http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-autoupdate-services/org/netbeans/api/autoupdate/package-summary.html). In fact you can completely get rid of the UI if you want and do everything in the background if you don't want to leave your users any choice.

The API isn't the most intuitive to work with. It throws a lot of new terminology at you. Personally I learned a lot about how this works from "The Definitive Guide To NetBeans Platform 7" by Heiko Böck (chapter 36 and chapter 25). Try Google. The book is rather old but still the best source I know of for this particular subject.

If you are creating an NB application where you want to customize how the module install/update mechanism works, meaning you want full control, then especially chapter 25 has been an eye opener for me.

Enjoy.

Peter


Peter,

Thank you for the reference! I found it and took a look at chapter 25. I don't really need to roll my own complete new UI. It would be ideal if there was some way to hook into the standard UI after it has compiled the update and install lists, and remove the unwanted items before the UI is displayed. I'm not sure if this is possible. I searched a little bit today, but didn't find and example of how to do this.
Back to top
jhuber



Joined: 22 Jul 2011
Posts: 69

PostPosted: Thu Jul 07, 2016 8:01 pm    Post subject: Reply with quote

In case anyone is interested, I finally got back to this issue after being shuffled around between projects and came up with a solution.

This involves patching the Auto Update UI platform module. I'm working with NB platform 8.0.2.

In org.netbeans.modules.autoupdate.ui.api, which is a public package, I added a new class UpdateUnitListModifier, which very simply is

Code:
[...]
package org.netbeans.modules.autoupdate.ui.api;

import java.util.List;
import org.netbeans.api.autoupdate.UpdateUnit;

/** <code>UpdateUnitListModifier</code> modifies a list of {@link org.netbeans.api.autoupdate.UpdateUnit} items.
 * After {@link org.netbeans.modules.autoupdate.ui.PluginManagerUI} creates the list,
 * it looks for providers of this service registered in the global lookup, and calls them to modify the list.
 *
 * @author jhuber
 */
public interface UpdateUnitListModifier {
    public List<UpdateUnit> modifyList(List<UpdateUnit> uList);
}


Then, in org.netbeans.modules.autoupdate.ui, I modified PuginManagerUI.java by adding code noted below to initialize() after line 251:

Code:
[...]
private void initialize () {
        try {
            final List<UpdateUnit> uu = UpdateManager.getDefault().getUpdateUnits(Utilities.getUnitTypes());
//            List<UnitCategory> precompute1 = Utilities.makeUpdateCategories (uu, false);
            if (localTable != null) {
                final List<UpdateUnit> nbms = new ArrayList<UpdateUnit>(((LocallyDownloadedTableModel) localTable.getModel()).getLocalDownloadSupport().getUpdateUnits());
                List<UnitCategory> precompute2 = Utilities.makeUpdateCategories (nbms, true);
            }

//new code           
            Collection<?> col1 = Lookup.getDefault().lookupAll(UpdateUnitListModifier.class);
            if (!col1.isEmpty()) {
                for (Object k1 : col1) {
                    ((UpdateUnitListModifier)k1).modifyList(uu);
                }
            }           
//end new code
           
            // postpone later
            refreshUnitsInBackground(uu);
[...]


Finally in my application, I have an UpdateUnitListModifier service provider to manipulate the UpdateUnit list.

Code:
[...]
@ServiceProvider(service=UpdateUnitListModifier.class)
public class UpdateModifier implements UpdateUnitListModifier {

    @Override
    public List<UpdateUnit> modifyList(List<UpdateUnit> uList) {     
          Iterator<UpdateUnit> it1 = uList.iterator();
          while (it1.hasNext()) {
                UpdateUnit u1 = it1.next();           
                String s1 = "com.dont.show.this.in.update.tab";
                if ((u1.getInstalled() == null) && u1.getCodeName().contentEquals(s1)) {
                   System.out.println ("This module should be removed from the list: " + u1.getCodeName());           
                   it1.remove();               
            }
        }
        return uList;
    }   
}


When one selects Tools>Plugins, PluginManagerUI goes about figuring out what is installed, what needs to be updated, and creates an UpdateUnit list with these items. Per the above modification, after this list is created and before the default Plugins window is displayed, PluginManagerUI now looks for service providers to modify this list. The service provider(s) can go through the list and remove items from (or add items to) the list. PluginManagerUI then goes on to process the list normally and display it in the various tabs of the Plugins window.

I've done some limited testing, but it seems to work as planned. My next challenge is to figure out how to distribute the modified Auto Update UI platform module through my app's update center. Not much out there about how to do that.
Back to top
Neil C Smith
Posted via mailing list.





PostPosted: Fri Jul 08, 2016 8:51 am    Post subject: Update Center issue: How to hide/remove items from the Available Plugins tab Reply with quote

Hi Joe,

On 7 July 2016 at 21:01, jhuber <address-removed> wrote:
Quote:
In case anyone is interested, I finally got back to this issue after being shuffled around between projects and came up with a solution.

I may have missed an earlier email that explained what you're trying
to do, but is this any different to adding the following lines to the
manifest of the relevant modules

AutoUpdate-Essential-Module: true
AutoUpdate-Show-In-Client: false

??

Best wishes,

Neil

--
Neil C Smith
Artist : Technologist : Adviser
http://neilcsmith.net

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org
Digital Prisoners - interactive spaces and projections -
www.digitalprisoners.co.uk
Back to top
jhuber



Joined: 22 Jul 2011
Posts: 69

PostPosted: Fri Jul 08, 2016 12:10 pm    Post subject: Re: Update Center issue: How to hide/remove items from the Available Plugins tab Reply with quote

Neil C Smith wrote:
I may have missed an earlier email that explained what you're trying to do, but is this any different to adding the following lines to the manifest of the relevant modules

AutoUpdate-Essential-Module: true
AutoUpdate-Show-In-Client: false

??


This is an excerpt from my original post:
Quote:
I have a Netbeans 8.0.1 platform suite/application App1 that has its own update center. I have another platform application App2 with its own modules that uses App1 as a library, but some of the modules from App1 are disabled. App2 also has its own separate update center.

The problem is that when I goto Tools->Plugins in App2, under the "Available Plugins" tab, it shows the modules that I have disabled in App1 as available for install. This is undesirable, since one of the reasons I created App2 is because I do not want the users to have access to those disabled App1 modules.

Setting AutoUpdate-Show-In-Client: false would prevent the module from showing in all applications, but it should only not be shown in certain applications, while it should be shown in others.
Back to top
bruehlicke



Joined: 18 Sep 2009
Posts: 201
Location: Houston

PostPosted: Thu Mar 02, 2017 10:34 pm    Post subject: Reply with quote

I have a much simpler problem, you might have a quick answer for hence you now have been deeper in the Update Center code.

After upgrading my RCP app to Nb 8.2 (from 6.5!) I see that a few Update Centers are made available by default under "Settings" on the Plugin GUI. they are "Plugin Portal", "NetBeans Distribution" and "Certified Plugins".

I simply do not want those in the list of possible Update Centers ... any easy way to get them out ? I would expect to find such settings in some xml/settings file ?

B
Back to top
bruehlicke



Joined: 18 Sep 2009
Posts: 201
Location: Houston

PostPosted: Thu Mar 02, 2017 10:50 pm    Post subject: Reply with quote

OK, I was too fast on the trigger. Found it.

Important Files -> XML Layer -> <this layer in context> -> Services -> AutoupdateType

In here remove the 3 defaults listed.

Voila ... loooove NetBeans !
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo