org.netbeans.api.autoupdate.InstallSupport Java Examples
The following examples show how to use
org.netbeans.api.autoupdate.InstallSupport.
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: 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 #2
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 6 votes |
private static InstallationResult installUpdate(@NonNull final UpdateElement update) { final ProgressHandle installHandle = ProgressHandle.createHandle(NbBundle.getMessage( MissingModuleProblemsProvider.class, "TXT_InstallModule", update.getDisplayName())); installHandle.start(); try { final OperationContainer<InstallSupport> container = OperationContainer.createForInstall(); container.add(Collections.singleton(update)); final InstallSupport support = container.getSupport(); try { final InstallSupport.Validator v = support.doDownload(installHandle, true, true); final InstallSupport.Installer i = support.doValidate(v, installHandle); final Restarter r = support.doInstall(i, installHandle); return InstallationResult.success(support, r); } catch (OperationException ex) { Exceptions.printStackTrace(ex); } } finally { installHandle.finish(); } return InstallationResult.failure(); }
Example #3
Source File: PluginManager.java From netbeans with Apache License 2.0 | 6 votes |
/** Open standard dialog for installing set of modules. Shows it to the user, * asks for confirmation, license acceptance, etc. The whole operation requires * AWT dispatch thread access (to show the dialog) and blocks * (until the user clicks through), so either call from AWT dispatch thread * directly, or be sure you hold no locks and block no progress of other * threads to avoid deadlocks. * * @param container the container with list of modules for install * @param runInBackground if <code>true</code> then installation run in the background after license acceptance */ public static void openInstallWizard(OperationContainer<InstallSupport> container, boolean runInBackground) { if (container == null) { throw new IllegalArgumentException ("OperationContainer cannot be null."); // NOI18N } List<OperationContainer.OperationInfo<InstallSupport>> all = container.listAll (); if (all.isEmpty ()) { throw new IllegalArgumentException ("OperationContainer cannot be empty."); // NOI18N } List<OperationContainer.OperationInfo<InstallSupport>> invalid = container.listInvalid(); if (! invalid.isEmpty ()) { throw new IllegalArgumentException ("OperationContainer cannot contain invalid elements but " + invalid); // NOI18N } OperationInfo<InstallSupport> info = all.get (0); OperationType doOperation = info.getUpdateUnit ().getInstalled () == null ? OperationType.INSTALL : OperationType.UPDATE; new InstallUnitWizard ().invokeWizard (new InstallUnitWizardModel (doOperation, container), true, runInBackground); }
Example #4
Source File: InstallStep.java From netbeans with Apache License 2.0 | 6 votes |
private void presentInstallNeedsRestart(Restarter r, final InstallSupport support) { if (canceled) { log.fine("Quit presentInstallNeedsRestart() because an previous installation was canceled."); return ; } component.setHeadAndContent (getBundle (HEAD_RESTART), getBundle (CONTENT_RESTART)); model.modifyOptionsForDoClose (wd, true); restarter = r; panel.setRestartButtonsVisible (true); panel.setBody (getBundle ("InstallStep_InstallDone_Text"), model.getAllVisibleUpdateElements ()); panel.hideRunInBackground (); if (runInBackground ()) { resetLastCheckWhenUpdatingFirstClassModules (model.getAllUpdateElements ()); support.doRestartLater (restarter); try { model.doCleanup (false); } catch (OperationException x) { log.log (Level.INFO, x.getMessage (), x); } if (clearLazyUnits) { LazyUnit.storeLazyUnits (model.getOperation (), null); AutoupdateCheckScheduler.notifyAvailable (null, OperationType.UPDATE); } notifyInstallRestartNeeded (support, r); // NOI18N } }
Example #5
Source File: FindComponentModules.java From netbeans with Apache License 2.0 | 6 votes |
private Collection<UpdateElement> getAllForInstall (Collection<UpdateElement> elements) { Collection<UpdateElement> all = new HashSet<UpdateElement> (); for (UpdateElement el : elements) { OperationContainer<InstallSupport> ocForInstall = OperationContainer.createForInstall (); if (ocForInstall.canBeAdded (el.getUpdateUnit (), el)) { OperationContainer.OperationInfo<InstallSupport> info = ocForInstall.add (el); if (info == null) { continue; } Set<UpdateElement> reqs = info.getRequiredElements (); ocForInstall.add (reqs); // PENDING: broken dependencies may mean the feature contains a platform/java-specific // module, but could be used even without that one. Set<String> breaks = info.getBrokenDependencies (); if (breaks.isEmpty ()) { all.add (el); all.addAll (reqs); } } } return all; }
Example #6
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 #7
Source File: FindComponentModules.java From visualvm with GNU General Public License v2.0 | 6 votes |
private Collection<UpdateElement> getAllForInstall (Collection<UpdateElement> elements) { Collection<UpdateElement> all = new HashSet<UpdateElement> (); for (UpdateElement el : elements) { OperationContainer<InstallSupport> ocForInstall = OperationContainer.createForInstall (); if (ocForInstall.canBeAdded (el.getUpdateUnit (), el)) { OperationContainer.OperationInfo<InstallSupport> info = ocForInstall.add (el); if (info == null) { continue; } Set<UpdateElement> reqs = info.getRequiredElements (); ocForInstall.add (reqs); Set<String> breaks = info.getBrokenDependencies (); if (breaks.isEmpty ()) { all.add (el); all.addAll (reqs); } else { problemDescription = NbBundle.getMessage (FindComponentModules.class, "FindComponentModules_Problem_DependingPluginNotFound", codeNames, breaks); } } } return all; }
Example #8
Source File: NbmExternalTest.java From netbeans with Apache License 2.0 | 6 votes |
private void doInstall(OperationContainer<InstallSupport> installContainer) throws OperationException { InstallSupport support = installContainer.getSupport(); assertNotNull(support); InstallSupport.Validator v = support.doDownload(null, false); assertNotNull(v); InstallSupport.Installer i = support.doValidate(v, null); assertNotNull(i); Restarter r = null; try { r = support.doInstall(i, null); } catch (OperationException ex) { if (OperationException.ERROR_TYPE.INSTALL == ex.getErrorType()) { // can ingore // module system cannot load the module either } else { fail(ex.toString()); } } assertNull("Installing new element require restarting though it should not", r); }
Example #9
Source File: UpdateHandler.java From jeddict with Apache License 2.0 | 5 votes |
static boolean allLicensesApproved(OperationContainer<InstallSupport> container) { if (!container.listInvalid().isEmpty()) { return false; } for (OperationInfo<InstallSupport> info : container.listAll()) { String license = info.getUpdateElement().getLicence(); if (!isLicenseApproved(license)) { return false; } } return true; }
Example #10
Source File: UpdateHandler.java From jeddict with Apache License 2.0 | 5 votes |
static OperationContainer<InstallSupport> feedContainer(Collection<UpdateElement> updates, boolean update) { if (updates == null || updates.isEmpty()) { return null; } // create a container for update OperationContainer<InstallSupport> container; if (update) { container = OperationContainer.createForUpdate(); } else { container = OperationContainer.createForInstall(); } // loop all updates and add to container for update for (UpdateElement ue : updates) { if (container.canBeAdded(ue.getUpdateUnit(), ue) && JeddictInstaller.CATEGORY.equals(ue.getCategory())) { JeddictInstaller.info("Update to Jeddict plugin found: " + ue); OperationInfo<InstallSupport> operationInfo = container.add(ue); if (operationInfo == null) { continue; } container.add(operationInfo.getRequiredElements()); if (!operationInfo.getBrokenDependencies().isEmpty()) { // have a problem => cannot continue JeddictInstaller.info("There are broken dependencies => cannot continue, broken deps: " + operationInfo.getBrokenDependencies()); return null; } } } return container; }
Example #11
Source File: IDEServicesImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override @NbBundle.Messages({"LBL_Error=Error", "# {0} - pluginName", "MSG_CannotBeInstalled={0} plugin cannot be installed"}) public Plugin getPluginUpdates(String cnb, final String pluginName) { List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.MODULE); for (UpdateUnit u : units) { if(u.getCodeName().equals(cnb)) { List<UpdateElement> elements = u.getAvailableUpdates(); final boolean isInstalled = u.getInstalled() != null; if(elements != null) { for (final UpdateElement updateElement : elements) { // even if there is more UpdateElements (more plugins with different versions), // we will return the first one - it is given that it will have the highest version. return new Plugin() { @Override public String getDescription() { return updateElement.getDescription(); } @Override public boolean installOrUpdate() { OperationContainer<InstallSupport> oc = isInstalled ? OperationContainer.createForUpdate() : OperationContainer.createForInstall(); if (oc.canBeAdded(updateElement.getUpdateUnit(), updateElement)) { oc.add(updateElement); return PluginManager.openInstallWizard(oc); } else { notifyError(Bundle.LBL_Error(), Bundle.MSG_CannotBeInstalled(pluginName)); } return false; } }; } } else { return null; } } } return null; }
Example #12
Source File: Containers.java From netbeans with Apache License 2.0 | 5 votes |
public static OperationContainer<InstallSupport> forUpdate() { synchronized(Containers.class) { OperationContainer<InstallSupport> container = null; if (UPDATE != null) { container = UPDATE.get(); } if (container == null) { container = OperationContainer.createForUpdate(); UPDATE = new WeakReference<OperationContainer<InstallSupport>>(container); } return container; } }
Example #13
Source File: JUnitLibraryInstaller.java From netbeans with Apache License 2.0 | 5 votes |
private static void install(OperationContainer<InstallSupport> oc, UpdateElement jUnitElement, UpdateUnit jUnitLib, boolean useUserdirAsFallback) throws OperationException { // download LOG.log(Level.FINE, "Try to download {0}", jUnitElement); ProgressHandle downloadHandle = ProgressHandleFactory.createHandle (download_handle()); Validator validator = oc.getSupport().doDownload(downloadHandle, null, useUserdirAsFallback); // install ProgressHandle validateHandle = ProgressHandleFactory.createHandle (validate_handle()); Installer installer = oc.getSupport().doValidate(validator, validateHandle); LOG.log(Level.FINE, "Try to install {0}", jUnitElement); ProgressHandle installHandle = ProgressHandleFactory.createHandle (install_handle()); Restarter restarter = oc.getSupport().doInstall(installer, installHandle); assert restarter == null : "Not need to restart while installing " + jUnitLib; LOG.log(Level.FINE, "Done {0}", jUnitElement); }
Example #14
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static OperationContainer<InstallSupport> feedContainer(Collection<UpdateElement> updates, boolean update) { if (updates == null || updates.isEmpty()) { return null; } // create a container for update OperationContainer<InstallSupport> container; if (update) { container = OperationContainer.createForUpdate(); } else { container = OperationContainer.createForInstall(); } // loop all updates and add to container for update for (UpdateElement ue : updates) { if (container.canBeAdded(ue.getUpdateUnit(), ue) && ue.getCodeName().equals(WakaTime.CODENAME)) { WakaTime.info("Update to WakaTime plugin found: " + ue); OperationInfo<InstallSupport> operationInfo = container.add(ue); if (operationInfo == null) { continue; } container.add(operationInfo.getRequiredElements()); if (!operationInfo.getBrokenDependencies().isEmpty()) { // have a problem => cannot continue WakaTime.info("There are broken dependencies => cannot continue, broken deps: " + operationInfo.getBrokenDependencies()); return null; } } } return container; }
Example #15
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static boolean allLicensesApproved(OperationContainer<InstallSupport> container) { if (!container.listInvalid().isEmpty()) { return false; } for (OperationInfo<InstallSupport> info : container.listAll()) { String license = info.getUpdateElement().getLicence(); if (!isLicenseApproved(license)) { return false; } } return true; }
Example #16
Source File: InstallStep.java From netbeans with Apache License 2.0 | 5 votes |
private UpdateElement findCulprit(String codeName) { if (codeName == null || codeName.isEmpty()) { return null; } for (OperationInfo<InstallSupport> info : model.getInstallContainer().listAll()) { if (codeName.equals(info.getUpdateElement().getCodeName())) { return info.getUpdateElement(); } } return null; }
Example #17
Source File: InstallStep.java From netbeans with Apache License 2.0 | 5 votes |
private static void notifyInstallRestartNeeded (final InstallSupport support, final Restarter r) { final Runnable onMouseClick = new Runnable () { @Override public void run () { try { support.doRestart (r, null); } catch (OperationException x) { log.log (Level.INFO, x.getMessage (), x); } } }; notifyRestartNeeded (onMouseClick, getBundle ("InstallSupport_RestartNeeded")); }
Example #18
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Validator doDownload(InstallSupport support) throws OperationException { final String displayName = "Downloading new version of WakaTime plugin..."; ProgressHandle downloadHandle = ProgressHandleFactory.createHandle( displayName, new Cancellable () { @Override public boolean cancel () { return true; } } ); return support.doDownload(downloadHandle, true); }
Example #19
Source File: InstallStep.java From netbeans with Apache License 2.0 | 5 votes |
private Validator handleDownload(final InstallSupport support) { if (canceled) { log.fine("Quit handleDownload() because an previous installation was canceled."); return null; } validator = null; boolean finish = false; while (! finish) { finish = tryPerformDownload(support); } return validator; }
Example #20
Source File: OperationWizardModel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Determines if there are modules to install before the main enable operation * may be successful. * @return modules to install */ public boolean hasComponentsToInstall() { OperationContainer<InstallSupport> oc = getInstallContainer(); if (oc == null) { return false; } return !oc.listAll().isEmpty(); }
Example #21
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException { final String displayName = "Validating WakaTime plugin..."; ProgressHandle validateHandle = ProgressHandleFactory.createHandle( displayName, new Cancellable () { @Override public boolean cancel () { return true; } } ); Installer installer = support.doValidate(validator, validateHandle); return installer; }
Example #22
Source File: Containers.java From netbeans with Apache License 2.0 | 5 votes |
public static OperationContainer<InstallSupport> forInternalUpdate () { synchronized (Containers.class) { OperationContainer<InstallSupport> container = null; if (INTERNAL_UPDATE != null) { container = INTERNAL_UPDATE.get (); } if(container == null) { container = OperationContainer.createForInternalUpdate(); INTERNAL_UPDATE = new WeakReference<OperationContainer<InstallSupport>> (container); } return container; } }
Example #23
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Restarter doInstall(InstallSupport support, Installer installer) throws OperationException { final String displayName = "Installing WakaTime plugin..."; ProgressHandle installHandle = ProgressHandleFactory.createHandle( displayName, new Cancellable () { @Override public boolean cancel () { return true; } } ); return support.doInstall(installer, installHandle); }
Example #24
Source File: InstallFeatureWithDependentModulesTest.java From netbeans with Apache License 2.0 | 5 votes |
public UpdateElement installModule(UpdateUnit toInstall) throws Exception { assertNotNull ("I have to have something toInstall.", toInstall); assertNull ("... and no installed.", toInstall.getInstalled ()); assertNotNull ("... and some available updates.", toInstall.getAvailableUpdates ()); assertFalse ("... and some available updates are not empty.", toInstall.getAvailableUpdates ().isEmpty ()); UpdateElement toInstallElement = toInstall.getAvailableUpdates ().get (0); OperationContainer<InstallSupport> container = OperationContainer.createForInstall (); OperationInfo<InstallSupport> info = container.add (toInstallElement); assertNotNull ("OperationInfo for element " + toInstallElement, info); Set<UpdateElement> reqs = info.getRequiredElements (); assertNotNull ("getRequiredElements() cannot returns null.", reqs); assertFalse ("Something missing", reqs.isEmpty ()); return super.installModule(toInstall, toInstallElement); }
Example #25
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
private InstallationResult( final boolean success, final InstallSupport support, final Restarter restarter) { this.success = success; this.support = support; this.restarter = restarter; }
Example #26
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
Optional<Pair<InstallSupport,Restarter>> getRestarter() { if (!isSuccess()) { throw new IllegalStateException("Failed installation."); } return Optional.ofNullable(restarter) .map((r) -> Pair.of(support, r)); }
Example #27
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
private static void maybeRestart( @NonNull final InstallSupport is, @NonNull final Restarter r) { SwingUtilities.invokeLater(()-> { final Object option = DialogDisplayer.getDefault().notify(new DialogDescriptor.Message.Confirmation( NbBundle.getMessage(MissingModuleProblemsProvider.class, "TXT_RestartConfirm"), NbBundle.getMessage(MissingModuleProblemsProvider.class, "TITLE_Restart"), DialogDescriptor.YES_NO_OPTION)); if (option == DialogDescriptor.YES_OPTION) { final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage( MissingModuleProblemsProvider.class, "TXT_Restart")); handle.start(); try { try { is.doRestart(r, handle); } catch (OperationException e) { //Cancelled is.doRestartLater(r); } } finally { handle.finish(); } } else { is.doRestartLater(r); } }); }
Example #28
Source File: NbmExternalTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testNbmWithExternalFailMessageDigest() throws Exception { String moduleCNB = "org.netbeans.modules.mymodule2"; String moduleReleaseVersion = "1"; String moduleImplVersion = "2"; String moduleSpecVersion = "1.0"; // Override message digest with an invalid SHA-1 sum - this must prevent // the module from being installed prepareNBM(moduleCNB, moduleReleaseVersion, moduleImplVersion, moduleSpecVersion, false, null, null, "SHA-1 5a7d7df655ba40478fae80a6abafc6afc36f9b6a"); writeCatalog(); UpdateUnitProviderFactory.getDefault().refreshProviders(null, true); OperationContainer<InstallSupport> installContainer = OperationContainer.createForInstall(); UpdateUnit moduleUnit = getUpdateUnit(moduleCNB); assertNull("cannot be installed", moduleUnit.getInstalled()); UpdateElement moduleElement = getAvailableUpdate(moduleUnit, 0); assertEquals(moduleElement.getSpecificationVersion(), moduleSpecVersion); OperationInfo<InstallSupport> independentInfo = installContainer.add(moduleElement); assertNotNull(independentInfo); try { doInstall(installContainer); } catch (OperationException ex) { assertTrue(ex.getMessage().contains("Failed checks [Message Digest (SHA-1)]")); return; } fail("Expected operation exception was not raised."); }
Example #29
Source File: NbmExternalTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testNbmWithExternalFailCRC32() throws Exception { String moduleCNB = "org.netbeans.modules.mymodule3"; String moduleReleaseVersion = "1"; String moduleImplVersion = "2"; String moduleSpecVersion = "1.0"; // Override CRC32 with an invalid CRC32 check sum - this must prevent // the module from being installed prepareNBM(moduleCNB, moduleReleaseVersion, moduleImplVersion, moduleSpecVersion, false, null, 1L, null); writeCatalog(); UpdateUnitProviderFactory.getDefault().refreshProviders(null, true); OperationContainer<InstallSupport> installContainer = OperationContainer.createForInstall(); UpdateUnit moduleUnit = getUpdateUnit(moduleCNB); assertNull("cannot be installed", moduleUnit.getInstalled()); UpdateElement moduleElement = getAvailableUpdate(moduleUnit, 0); assertEquals(moduleElement.getSpecificationVersion(), moduleSpecVersion); OperationInfo<InstallSupport> independentInfo = installContainer.add(moduleElement); assertNotNull(independentInfo); try { doInstall(installContainer); } catch (OperationException ex) { assertTrue(ex.getMessage().contains("Failed checks [Checksum CRC32]")); return; } fail("Expected operation exception was not raised."); }
Example #30
Source File: Containers.java From netbeans with Apache License 2.0 | 5 votes |
public static OperationContainer<InstallSupport> forAvailable() { synchronized(Containers.class) { OperationContainer<InstallSupport> container = null; if (INSTALL != null) { container = INSTALL.get(); } if (container == null) { container = OperationContainer.createForInstall(); INSTALL = new WeakReference<OperationContainer<InstallSupport>>(container); } return container; } }