org.netbeans.api.autoupdate.UpdateUnit Java Examples
The following examples show how to use
org.netbeans.api.autoupdate.UpdateUnit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OperationsTestImpl.java From netbeans with Apache License 2.0 | 6 votes |
public UpdateElement installNativeComponent (UpdateUnit toInstall, UpdateElement installElement) throws Exception { installElement = (installElement != null) ? installElement : toInstall.getAvailableUpdates ().get (0); assertNotNull (toInstall); // XXX: assert same could be broken later assertSame (toInstall, Utilities.toUpdateUnit (toInstall.getCodeName ())); OperationContainer<OperationSupport> container = OperationContainer.createForCustomInstallComponent (); OperationContainer.OperationInfo<OperationSupport> info = container.add (installElement); assertNotNull (info); container.add (info.getRequiredElements ()); assertEquals (0,container.listInvalid ().size ()); OperationSupport support = container.getSupport (); assertNotNull (support); support.doOperation (null); return installElement; }
Example #2
Source File: InstallDisabledModuleTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails @Override public void testSelf() throws Throwable { LOG.info("testSelf starting"); UpdateUnit install = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest()); assertNotNull("There is an NBM to install", install); LOG.log(Level.INFO, "module install found: {0}", install); Throwable t = null; try { installModule(install, null);//fail("OK"); } catch (Throwable ex) { t = ex; } LOG.log(Level.INFO, "Info installModule over with {0}", t); File f = new File(new File(new File(new File(System.getProperty("netbeans.user")), "config"), "Modules"), "com-example-testmodule-cluster.xml"); LOG.log(Level.INFO, "Does {0} exists: {1}", new Object[]{f, f.exists()}); File m = new File(new File(new File(getWorkDir(), "test"), "modules"), "com-example-testmodule-cluster.jar"); LOG.log(Level.INFO, "Does {0} exists: {1}", new Object[]{m, m.exists()}); if (t != null) { throw t; } assertTrue("Config file created in userdirectory for install of new module: " + f, f.exists()); }
Example #3
Source File: LocalDownloadSupport.java From netbeans with Apache License 2.0 | 6 votes |
private UpdateUnit createUpdateUnitFromNBM (File nbm, boolean quiet) { UpdateUnitProviderFactory factory = UpdateUnitProviderFactory.getDefault (); UpdateUnitProvider provider = factory.create (nbm.getName (), new File[] {nbm}); List<UpdateUnit> units = Collections.emptyList (); try { units = provider.getUpdateUnits (UpdateManager.TYPE.MODULE); } catch (RuntimeException re) { if (!quiet) { err.log (Level.INFO, re.getMessage (), re); DialogDisplayer.getDefault ().notifyLater (new NotifyDescriptor.Exception (re, NbBundle.getMessage(LocalDownloadSupport.class, "LocalDownloadSupport_BrokenNBM_Exception", nbm.getName (), re.getLocalizedMessage ()))); fileList.removeFile (nbm); } } if (units == null || units.isEmpty()) { // skip to another one return null; } assert units.size () == 1 : "Only once UpdateUnit for " + nbm + " but " + units; return units.get (0); }
Example #4
Source File: UpdateDisabledModuleTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testSelf() throws Exception { File f = new File(new File(new File(ud, "config"), "Modules"), "com-example-testmodule-cluster.xml"); f.delete(); assertFalse("No Config file before: " + f, f.exists()); MockServices.setServices(UP.class); UpdateUnit update = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest()); assertNotNull("There is an NBM to update", update); OperationContainer<InstallSupport> oc = OperationContainer.createForUpdate(); oc.add(update, update.getAvailableUpdates().get(0)); final InstallSupport support = oc.getSupport(); Validator down = support.doDownload(null, true); Installer inst = support.doValidate(down, null); Restarter res = support.doInstall(inst, null); System.setProperty("netbeans.close.no.exit", "true"); support.doRestart(res, null); UpdaterInternal.update(null, null, null); assertFalse("No Config file created in for upgrade: " + f, f.exists()); }
Example #5
Source File: UpdateManagerImpl.java From netbeans with Apache License 2.0 | 6 votes |
private static List<UpdateUnit> filterUnitsByAskedTypes (Collection<UpdateUnit> units, List<UpdateManager.TYPE> types) { List<UpdateUnit> askedUnits = new ArrayList<UpdateUnit> (); //hotfix for #113193 - reevaluate and probably fix better List<UpdateManager.TYPE> tmpTypes = new ArrayList<UpdateManager.TYPE>(types); if (tmpTypes.contains (UpdateManager.TYPE.MODULE) && !tmpTypes.contains (UpdateManager.TYPE.KIT_MODULE)) { tmpTypes.add (UpdateManager.TYPE.KIT_MODULE); } for (UpdateUnit unit : units) { UpdateUnitImpl impl = Trampoline.API.impl (unit); if (tmpTypes.contains (impl.getType ())) { askedUnits.add (unit); } } return askedUnits; }
Example #6
Source File: InstallEagerModuleTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testAquireEargersFromManager () throws IOException { String eagerModule = "com.sun.testmodule.eager"; String regularModule1 = "org.yourorghere.independent"; String regularModule2 = "org.yourorghere.engine"; String catalog = generateCatalog ( generateModuleElement (eagerModule, "1.0", null, null, false, true, regularModule1, regularModule2), generateModuleElement (regularModule1, "1.0", null, null, false, false), generateModuleElement (regularModule2, "1.0", null, null, false, false, regularModule1) ); UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog)); UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true); Set<UpdateElement> eagerElements = UpdateManagerImpl.getInstance ().getAvailableEagers (); assertFalse ("Some available eagers are found.", eagerElements.isEmpty ()); UpdateUnit ea = UpdateManagerImpl.getInstance ().getUpdateUnit (eagerModule); UpdateElement foundEaEl = eagerElements.iterator ().next (); UpdateUnit foundEaU = foundEaEl.getUpdateUnit (); assertEquals ("Same eager UpdateUnit", ea, foundEaU); // assertFalse ("Some installed eagers are found.", UpdateManagerImpl.getInstance ().getInstalledEagers ().isEmpty ()); }
Example #7
Source File: Status.java From netbeans with Apache License 2.0 | 6 votes |
static String[] toArray(UpdateUnit uu) { if (uu.getInstalled() != null) { return new String[] { uu.getCodeName(), uu.getInstalled().getSpecificationVersion(), Status.installed(uu).toString() }; } else { List<UpdateElement> updates = uu.getAvailableUpdates(); if (updates.isEmpty()) { return new String[] { uu.getCodeName(), "N/A", "N/A" }; } UpdateElement first = updates.get(0); return new String[] { uu.getCodeName(), first.getSpecificationVersion(), Status.update(uu).toString() }; } }
Example #8
Source File: InstallTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails public void testSelf () throws Exception { File pf = getWorkDir (); File lastModified = new File (pf, ".lastModified"); // NOI18N lastModified.createNewFile (); assertTrue ("Check mark created", lastModified.exists ()); long before = lastModified.lastModified (); Thread.sleep (1000); UpdateUnit toInstall = UpdateManagerImpl.getInstance ().getUpdateUnit (moduleCodeNameBaseForTest ()); installModule (toInstall, null); if (before >= lastModified.lastModified ()) { fail ("The file shall have newer timestamp: " + lastModified.lastModified ()); } }
Example #9
Source File: FragmentDisabledNoRestartTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void testSelf() throws Exception { UpdateUnit hostUnit = UpdateManagerImpl.getInstance().getUpdateUnit("org.yourorghere.engine"); installModule(hostUnit, null); OperationContainer<OperationSupport> container = OperationContainer.createForDirectDisable (); container.add(hostUnit.getInstalled()); OperationSupport support = container.getSupport (); support.doOperation (null); UpdateUnit toInstall = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest()); AtomicReference<OperationSupport.Restarter> restarter = new AtomicReference<>(); installModuleWithRestart(toInstall, null, restarter); assertNull ("Module must not cause restart, host is disabled", restarter.get()); }
Example #10
Source File: Unit.java From netbeans with Apache License 2.0 | 6 votes |
public Installed (UpdateUnit unit, String categoryName) { super (categoryName); this.updateUnit = unit; if (unit.getInstalled () == null && unit.isPending ()) { this.installEl = unit.getAvailableUpdates ().get (0); assert installEl != null : "Pending UpdateUnit " + unit + " has UpdateElement for update."; } else { this.installEl = unit.getInstalled (); assert installEl != null : "Installed UpdateUnit " + unit + " has Installed UpdateElement."; } this.backupEl = unit.getBackup (); OperationContainer<OperationSupport> container; if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == updateUnit.getType ()) { container = Containers.forCustomUninstall (); } else { container = Containers.forUninstall (); } uninstallationAllowed = isOperationAllowed (this.updateUnit, installEl, container); deactivationAllowed = isOperationAllowed (this.updateUnit, installEl, Containers.forDisable()); activationAllowed = isOperationAllowed (this.updateUnit, installEl, Containers.forEnable()); initState(); }
Example #11
Source File: UpdateUnitFactory.java From netbeans with Apache License 2.0 | 6 votes |
public Map<String, UpdateUnit> getUpdateUnits (UpdateProvider provider) { //TODO: this call should be forced not to be called from AWT //assert !SwingUtilities.isEventDispatchThread(); resetRunTime ("Measuring UpdateUnitFactory.getUpdateUnits (" + provider.getDisplayName () + ")"); // NOI18N // append units from provider Map<String, UpdateUnit> temp = appendUpdateItems (new HashMap<String, UpdateUnit> (), provider); reportRunTime ("Get appendUpdateItems for " + provider.getDisplayName ()); Map<String, UpdateUnit> retval = new HashMap<String, UpdateUnit>(); for (UpdateUnit unit : temp.values ()) { retval.put (unit.getCodeName (), mergeInstalledUpdateUnit (unit)); } reportRunTime ("Get filltering by " + provider.getDisplayName ()); return temp; }
Example #12
Source File: UnitTab.java From netbeans with Apache License 2.0 | 6 votes |
final void updateTab(final Map<String, Boolean> state) { final Runnable addUpdates = new Runnable() { @Override public void run() { final LocallyDownloadedTableModel downloadedTableModel = ((LocallyDownloadedTableModel) model); List<UpdateUnit> empty = Collections.emptyList(); downloadedTableModel.setUnits(empty); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fireUpdataUnitChange(); UnitCategoryTableModel.restoreState(model.getUnits(), state, model.isMarkedAsDefault()); refreshState(); setWaitingState(false); } }); } }; setWaitingState(true); Utilities.startAsWorkerThread(addUpdates, 250); }
Example #13
Source File: JUnitLibraryInstaller.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({"writePermission=You don't have permission to install JUnit Library into the installation directory which is recommended.", "showDetails=Show details"}) private static void notifyWarning(final OperationContainer<InstallSupport> oc, final UpdateElement jUnitElement, final UpdateUnit jUnitLib) { // lack of privileges for writing ActionListener onMouseClickAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Runnable r = new Runnable() { @Override public void run() { try { install(oc, jUnitElement, jUnitLib, true); } catch (OperationException ex) { LOG.log(Level.INFO, "While installing " + jUnitLib + " thrown " + ex, ex); } } }; showWritePermissionDialog(r); } }; String title = writePermission(); String description = showDetails(); NotificationDisplayer.getDefault().notify(title, ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/pluginimporter/resources/warning.gif", false), // NOI18N description, onMouseClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.WARNING); }
Example #14
Source File: Unit.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void setMarked(boolean marked) { if (marked == isMarked()) { log.info("Not necessary mark " + this + " as " + marked + " if it'is marked as " + isMarked()); return ; } OperationContainer container = Containers.forUpdate(); for (UpdateUnit invisible : getUpdateUnits()) { if (marked) { if (container.canBeAdded(invisible, invisible.getAvailableUpdates().get(0))) { container.add(invisible, invisible.getAvailableUpdates().get(0)); } } else { container.remove(invisible.getAvailableUpdates().get(0)); } } if (! hasInternalsOnly()) { if (marked) { if (container.canBeAdded(updateUnit, getRelevantElement())) { container.add(updateUnit, getRelevantElement()); } } else { container.remove(getRelevantElement()); } } }
Example #15
Source File: Unit.java From netbeans with Apache License 2.0 | 5 votes |
public Update (UpdateUnit unit, boolean isNbms, String categoryName) { super (categoryName); this.isNbms = isNbms; this.updateUnit = unit; this.installEl = unit.getInstalled (); assert installEl != null : "Updateable UpdateUnit " + unit + " has Installed UpdateElement."; if(unit.getAvailableUpdates().size() > 0) { this.updateEl = unit.getAvailableUpdates ().get (0); assert updateEl != null : "Updateable UpdateUnit " + unit + " has UpdateElement for update."; } initState(); }
Example #16
Source File: OperationsTestImpl.java From netbeans with Apache License 2.0 | 5 votes |
void disableModule (UpdateUnit toDisable) throws Exception { FileObject fo = FileUtil.getConfigFile("Modules"); File f = new File (getWorkDir (), "config/Modules"); File f2 = new File (getWorkDir (), "modules"); assertTrue (f.listFiles () != null && f.listFiles ().length != 0); assertTrue (f2.listFiles () != null && f2.listFiles ().length != 0); assertFalse (fileChanges[0]); assertNotNull (getModuleInfos ().get (toDisable.getCodeName ())); assertNotNull (toDisable); /* Cf. installModuleImpl: assertSame (toDisable, Utilities.toUpdateUnit (toDisable.getCodeName ())); */ OperationContainer<OperationSupport> container = OperationContainer.createForDirectDisable (); assertNotNull (container.add (toDisable.getInstalled ())); OperationSupport support = container.getSupport (); assertNotNull (support); support.doOperation (null); assertNotNull (toDisable.getInstalled ()); assertTrue (f.listFiles () != null && f.listFiles ().length != 0); assertTrue (f2.listFiles () != null && f2.listFiles ().length != 0); assertEquals (1, fo.getChildren ().length); assertEquals (f.listFiles ()[0], FileUtil.toFile (fo.getChildren ()[0])); assertNotNull (getModuleInfos ().get (toDisable.getCodeName ())); ModuleInfo info = getModuleInfos ().get (toDisable.getCodeName ()); assertNotNull (info); assertFalse (info.isEnabled ()); assertNotNull (Utilities.toModule (toDisable.getCodeName (), null)); assertFalse (Utilities.toModule (toDisable.getCodeName (), null).isEnabled ()); }
Example #17
Source File: LocallyDownloadedTableModel.java From netbeans with Apache License 2.0 | 5 votes |
@Override public final void setUnits(final List<UpdateUnit> unused) { getLocalDownloadSupport ().removeInstalledUnit (); Collection<UpdateUnit> units = getLocalDownloadSupport().getUpdateUnits(); //do not compute if not necessary if (cachedUnits == null || !units.containsAll (cachedUnits) || !cachedUnits.containsAll (units)) { setData(makeCategories (new LinkedList<UpdateUnit> (units))); cachedUnits = new ArrayList<UpdateUnit>(units); } }
Example #18
Source File: OperationsTestImpl.java From netbeans with Apache License 2.0 | 5 votes |
void assertInstalledModule (UpdateUnit toInstallUnit) throws InterruptedException { ModuleInfo info = getModuleInfos ().get (toInstallUnit.getCodeName ()); assertNotNull (info); int timeout = 250; while (! info.isEnabled () && timeout-- > 0) { Thread.sleep (10); } assertTrue (info.getCodeNameBase (), info.isEnabled ()); assertNotNull (Utilities.toModule (toInstallUnit.getCodeName (), null)); assertTrue (Utilities.toModule (toInstallUnit.getCodeName (), null).isEnabled ()); }
Example #19
Source File: TargetClusterTestCase.java From netbeans with Apache License 2.0 | 5 votes |
protected UpdateElement installModule (String codeName) throws IOException, OperationException { String catalog = generateCatalog (generateModuleElement (codeName, "1.0", true, platformDir.getName ())); AutoupdateCatalogProvider p = createUpdateProvider (catalog); p.refresh (true); Map<String, UpdateItem> updates = p.getUpdateItems (); assertNotNull ("Some modules are installed.", updates); assertFalse ("Some modules are installed.", updates.isEmpty ()); // check being assertTrue (codeName + " found in parsed items.", updates.keySet ().contains (codeName + "_1.0")); UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog)); UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true); UpdateUnit uu = UpdateManagerImpl.getInstance ().getUpdateUnit (codeName); assertNotNull (codeName + " - UpdateUnit found.", uu); assertFalse ("Available updates " + uu, uu.getAvailableUpdates ().isEmpty ()); assertEquals (codeName + " goes into platformDir.", platformDir.getName (), InstallManager.findTargetDirectory (null, Trampoline.API.impl (uu.getAvailableUpdates ().get (0)), null, false).getName ()); UpdateElement installed = installUpdateUnit (uu); assertNotNull (codeName + " is installed.", installed); assertEquals (codeName + " is as same as installed in " + installed.getUpdateUnit (), installed.getUpdateUnit ().getInstalled (), installed); // XXX: workaround missing real NBM for codeName File modules = new File (new File (platformDir, "config"), "Modules"); modules.mkdirs (); new File (modules, installed.getCodeName ().replace ('.', '-') + ".xml").createNewFile (); return installed; }
Example #20
Source File: FindComponentModules.java From netbeans with Apache License 2.0 | 5 votes |
private static UpdateElement findUpdateElement (String codeName, boolean isInstalled) { UpdateElement res = null; for (UpdateUnit u : UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.MODULE)) { if (codeName.equals (u.getCodeName ())) { if (isInstalled && u.getInstalled () != null) { res = u.getInstalled (); } else if (! isInstalled && ! u.getAvailableUpdates ().isEmpty ()) { res = u.getAvailableUpdates ().get (0); } break; } } return res; }
Example #21
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Collection<UpdateElement> findUpdates() { // check updates Collection<UpdateElement> elements4update = new HashSet<UpdateElement>(); List<UpdateUnit> updateUnits = UpdateManager.getDefault().getUpdateUnits(); for (UpdateUnit unit : updateUnits) { if (unit.getInstalled() != null) { // means the plugin already installed if (unit.getCodeName().equals(WakaTime.CODENAME)) { // this is our current plugin if (!unit.getAvailableUpdates().isEmpty()) { // has updates elements4update.add(unit.getAvailableUpdates().get(0)); // add plugin with highest version } } } } return elements4update; }
Example #22
Source File: OperationValidator.java From netbeans with Apache License 2.0 | 5 votes |
@Override boolean isValidOperationImpl (UpdateUnit unit, UpdateElement uElement) { boolean res = false; UpdateElementImpl impl = Trampoline.API.impl (uElement); assert impl != null; if (impl != null && impl instanceof NativeComponentUpdateElementImpl) { NativeComponentUpdateElementImpl ni = (NativeComponentUpdateElementImpl) impl; if (ni.getInstallInfo ().getCustomInstaller () != null) { res = containsElement (uElement, unit); } } return res; }
Example #23
Source File: FragmentIEnabledRestartTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void testSelf() throws Exception { installModule(UpdateManagerImpl.getInstance().getUpdateUnit("org.yourorghere.engine"), null); UpdateUnit toInstall = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest()); AtomicReference<OperationSupport.Restarter> restarter = new AtomicReference<>(); installModuleWithRestart(toInstall, null, restarter); assertNotNull(restarter.get()); }
Example #24
Source File: InstallCustomInstalledTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testSelf () throws Exception { List<UpdateUnit> units = UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT); assertNotNull (units); assertFalse (units.isEmpty ()); UpdateUnit toInstall = UpdateManagerImpl.getInstance ().getUpdateUnit (moduleCodeNameBaseForTest ()); assertFalse (toInstall + " has available elements.", toInstall.getAvailableUpdates ().isEmpty ()); UpdateElement toInstallElement = toInstall.getAvailableUpdates ().get (0); installNativeComponent (toInstall, toInstallElement); assertTrue ("Custom installer was called.", installerCalled); }
Example #25
Source File: InstallationCompletenessTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testInstalledKits() throws Exception { String distro = System.getProperty(DISTRO_PROPERTY); assertNotNull("Distribution not set, please set by setting property:" + DISTRO_PROPERTY, distro); Set<String> kitsGolden = getModulesForDistro(distro, new File(getDataDir(), "kits.properties")); if(readExpectedParams()){ kitsGolden.addAll(expectedIncludes); kitsGolden.removeAll(expectedExcludes); listExpectedParams(); } Set<String> redundantKits = new HashSet<String>(); UpdateManager um = UpdateManager.getDefault(); List<UpdateUnit> l = um.getUpdateUnits(UpdateManager.TYPE.KIT_MODULE); for (UpdateUnit updateUnit : l) { String kitName = updateUnit.getCodeName(); if (kitsGolden.contains(kitName)) { kitsGolden.remove(kitName); System.out.println("OK - IDE contains:" + updateUnit.getCodeName()); } else { redundantKits.add(kitName); System.out.println("REDUNDANT - IDE contains:" + kitName); } } for (String missing : kitsGolden) { System.out.println("MISSING - IDE does not contain:" + missing); } assertTrue("Some modules are missing:\n" + setToString(kitsGolden), kitsGolden.isEmpty()); assertTrue("Some modules are redundant:\n" + setToString(redundantKits), redundantKits.isEmpty()); }
Example #26
Source File: JeddictInstaller.java From jeddict with Apache License 2.0 | 5 votes |
public static Set<String> getPluginVersion() { Set<String> versions = new HashSet<>(); for (UpdateUnit updateUnit : UpdateManager.getDefault().getUpdateUnits()) { UpdateElement updateElement = updateUnit.getInstalled(); if (updateElement != null) { if (JeddictInstaller.CATEGORY.equals(updateElement.getCategory())) { versions.add(updateElement.getSpecificationVersion()); } } } return versions; }
Example #27
Source File: LocalDownloadSupport.java From netbeans with Apache License 2.0 | 5 votes |
private String getDisplayNames (Collection<UpdateUnit> units) { SortedSet<String> names = new TreeSet<String> (); for (UpdateUnit uu : units) { if (uu.getInstalled () != null) { names.add (uu.getInstalled ().getDisplayName ()); } else { names.add (uu.getAvailableUpdates ().get (0).getDisplayName ()); } } String res = ""; for (String dn : names) { res += res.length () == 0 ? dn : ", " + dn; // NOI18N } return res; }
Example #28
Source File: LocalDownloadSupport.java From netbeans with Apache License 2.0 | 5 votes |
public boolean remove (UpdateUnit unit) { File f = getNbm (unit.getCodeName ()); if (f != null) { fileList.removeFile (f); synchronized (LocalDownloadSupport.class) { File nbm = getNbm (unit.getCodeName ()); getCodeName2Unit ().remove (unit.getCodeName ()); getNbm2CodeName ().remove (nbm); } } return f != null; }
Example #29
Source File: UpdateHandler.java From jeddict with Apache License 2.0 | 5 votes |
static Collection<UpdateElement> findNewModules() { // check updates Collection<UpdateElement> elements4install = new HashSet<>(); List<UpdateUnit> updateUnits = UpdateManager.getDefault().getUpdateUnits(); for (UpdateUnit unit : updateUnits) { if (unit.getInstalled() == null) { // means the plugin is not installed yet if (unit.getCodeName().equals(JeddictInstaller.CATEGORY)) { // this is our current plugin if (!unit.getAvailableUpdates().isEmpty()) { // is available elements4install.add(unit.getAvailableUpdates().get(0)); // add plugin with highest version } } } } return elements4install; }
Example #30
Source File: FindComponentModules.java From netbeans with Apache License 2.0 | 5 votes |
private void findComponentModules () { long start = System.currentTimeMillis(); Collection<UpdateUnit> units = null; Collection<UpdateElement> elementsForInstall = null; buildCodebaseIndex(); for (int[] refresh = { 2 }; refresh[0] > 0; ) { if (units != null) { List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true); for (UpdateUnitProvider p : providers) { try { p.refresh(null, true); } catch (IOException ex) { updateErrors.add(ex); Exceptions.attachSeverity(ex, Level.INFO).printStackTrace(); } } availUnits = null; } buildUpdateUnitIndex(); units = UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.MODULE); // install missing modules elementsForInstall = getMissingModules(units, refresh); } forInstall = getAllForInstall (elementsForInstall); // install disabled modules Collection<UpdateElement> elementsForEnable = getDisabledModules (units); forEnable = getAllForEnable (elementsForEnable, units); }