org.netbeans.api.autoupdate.UpdateElement Java Examples

The following examples show how to use org.netbeans.api.autoupdate.UpdateElement. 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: LicenseApprovalPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void cbPluginsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPluginsActionPerformed
	// This is designed on purpose to make the user feel that
	//  license do refresh when new plugin is selected
	taLicense.setText("");
	final int delay = 100;
	RequestProcessor.getDefault().post(new Runnable() {

                       @Override
		public void run() {
			SwingUtilities.invokeLater(new Runnable() {

                                       @Override
				public void run() {
					UpdateElement el = license4plugins.get(cbPlugins.getSelectedIndex());
					taLicense.setText(el.getLicence());
					taLicense.setCaretPosition(0);
				}
			});
		}
	}, delay);
}
 
Example #2
Source File: UpdateTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void logCurrentValues(CountsStruct pluginCounts) {
    log("");
    log("-----------------------------------------------------------");
    log("|  PLUGINS COUNTS IN DETAIL :                             |");
    log("-----------------------------------------------------------");
    log("NEW ELEMENTS:" + pluginCounts.getNewCount());
    log("INSTALLED ELEMENTS:" + pluginCounts.getInstalledCount());
    log("UPDATE ELEMENTS:" + pluginCounts.getUpdatesCount());
    log("FILTERED ELEMENTS:" + pluginCounts.getFilteredCount());
    log("PENDING ELEMENTS:" + pluginCounts.getPendingCount());
    log("-----------------------------------------------------------");

    log("-----------------------------------------------------------");
    log("|  PENDING PLUGINS :                                      |");
    log("-----------------------------------------------------------");
    for (UpdateElement updateElement : currentlyPendingUpdates) {
        log("[" + updateElement.getDisplayName() + "] " + updateElement.getCodeName());
    }
    log("-----------------------------------------------------------");

}
 
Example #3
Source File: OperationWizardModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addRequiredElements (Set<UpdateElement> elems) {
    OperationContainer baseContainer = getBaseContainer();
    OperationContainer customContainer = getCustomHandledContainer();
    OperationContainer installContainer = getInstallContainer();
    for (UpdateElement el : elems) {
        if (el == null || el.getUpdateUnit () == null) {
            Logger.getLogger (OperationWizardModel.class.getName ()).log (Level.INFO, "UpdateElement " + el + " cannot be null"
                    + (el == null ? "" : " or UpdateUnit " + el.getUpdateUnit () + " cannot be null"));
            continue;
        }
        if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == el.getUpdateUnit ().getType ()) {
            customContainer.add (el);
        } else if (baseContainer.canBeAdded(el.getUpdateUnit(), el)) {
            baseContainer.add (el);
        } else if (installContainer != null && installContainer.canBeAdded(el.getUpdateUnit(), el)) {
            installContainer.add(el);
        }
    }
}
 
Example #4
Source File: ProblemPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "# {0} - plugin_name",
    "write_taTitle_Text=You don''t have permission to install plugin <b>{0}</b> into the installation directory.",
    "write_taMessage_WarningText=To perform installation into the installation directory, you should run the application "
        + "as a user with administrative privilege, i.e. <i>Run as administrator</i> on Windows platform or "
        + "run as <i>sudo</i> command on Unix-like systems."})
private void initWriteProblem(UpdateElement culprit, String problemDescription) {
    problem = problemDescription == null ?
        write_taTitle_Text(culprit.getDisplayName()) : // NOI18N
        problemDescription;
    enhancedInitComponents();
    cbShowAgain.setVisible(false);
    taTitle.setText(problem);
    taTitle.setToolTipText (problem);
    tpMessage.setText(write_taMessage_WarningText()); // NOI18N
}
 
Example #5
Source File: FindComponentModules.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void findComponentModules () {
    Collection<UpdateUnit> units = UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.MODULE);
    problemDescription = null;
    
    // install missing modules
    Collection<UpdateElement> elementsForInstall = getMissingModules (units);
    forInstall = getAllForInstall (elementsForInstall);
    
    // install disabled modules
    Collection<UpdateElement> elementsForEnable = getDisabledModules (units);
    forEnable = getAllForEnable (elementsForEnable);
    
    if (problemDescription == null && elementsForInstall.isEmpty () && elementsForEnable.isEmpty ()) {
        problemDescription = NbBundle.getMessage (FindComponentModules.class, "FindComponentModules_Problem_PluginNotFound", codeNames);
    }
}
 
Example #6
Source File: AutoupdateCheckScheduler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void run () {
    if (SwingUtilities.isEventDispatchThread ()) {
        Installer.RP.post (doCheckAvailableUpdates);
        return ;
    }
    boolean hasUpdates = false;
    if (Utilities.shouldCheckAvailableUpdates ()) {
        Collection<UpdateElement> updates = new HashSet<UpdateElement> ();
        checkUpdateElements(OperationType.UPDATE, null, false, updates);
        hasUpdates = updates != null && ! updates.isEmpty ();
        LazyUnit.storeUpdateElements (OperationType.UPDATE, updates);
        Utilities.storeAcceptedLicenseIDs();
    }
    if (! hasUpdates && Utilities.shouldCheckAvailableNewPlugins ()) {
        LazyUnit.storeUpdateElements (OperationType.INSTALL, checkUpdateElements(OperationType.INSTALL, null, false, null));
    }
    Installer.RP.post (doCheckLazyUpdates, 500);
}
 
Example #7
Source File: ModulesInstaller.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static String presentUpdateElements (Collection<UpdateElement> elems) {
    StringBuilder sb = new StringBuilder();
    String sep = "";
    Set<String> used = new HashSet<String>();
    
    for (UpdateElement el : elems) {
        if (!used.add(el.getCategory())) {
            continue;
        }
        sb.append(sep);
        sb.append(el.getCategory());
        if (sb.length() > 30) {
            sb.append("..."); // NOI18N
            break;
        }
        sep = ", "; // NOI18N
    }
    return sb.toString();
}
 
Example #8
Source File: OperationPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setBody (final String msg, final Set<UpdateElement> updateElements) {
    final List<UpdateElement> elements = new ArrayList<UpdateElement> (updateElements);
    
    Collections.sort(elements, new Comparator<UpdateElement>() {

        @Override
            public int compare(UpdateElement o1, UpdateElement o2) {
                return Collator.getInstance().compare(o1.getDisplayName(), o2.getDisplayName());
            }
        });
    
    if (SwingUtilities.isEventDispatchThread ()) {
        setBodyInEQ (msg, elements);
    } else {
        SwingUtilities.invokeLater (new Runnable () {
            @Override
            public void run () {
                setBodyInEQ (msg, elements);
            }
        });
    }
}
 
Example #9
Source File: ValidateInstallTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void logCurrentValues() {
    log("");
    log("-----------------------------------------------------------");
    log("|  PLUGINS COUNTS IN DETAIL :                             |");
    log("-----------------------------------------------------------");
    log("NEW ELEMENTS:" + newPlugins.size());
    log("INSTALLED ELEMENTS:" + installedPlugins.size());
    log("UPDATE ELEMENTS:" + updatePlugins.size());
    log("-----------------------------------------------------------");
    log("-----------------------------------------------------------");
    log("|  NEW PLUGINS :                                          |");
    log("-----------------------------------------------------------");
    for (UpdateElement updateElement : newPlugins) {
        log("[" + updateElement.getDisplayName() + "] " + updateElement.getCodeName());
    }
    log("-----------------------------------------------------------");
}
 
Example #10
Source File: JUnitLibraryInstaller.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: UpdateUnitFactoryTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetUpdateUnitsInNbmFile () {
    UpdateProvider localFilesProvider = new LocalNBMsProvider ("test-local-file-provider", NBM_FILE);
    assertNotNull ("LocalNBMsProvider found for file " + NBM_FILE, localFilesProvider);
    Map<String, UpdateUnit> units = UpdateUnitFactory.getDefault().getUpdateUnits (localFilesProvider);
    assertNotNull ("UpdateUnit found in provider " + localFilesProvider.getDisplayName (), units);
    assertEquals ("Provider providers only once unit in provider" + localFilesProvider.getName (), 1, units.size ());
    String id = units.keySet ().iterator ().next ();
    assertNotNull (localFilesProvider.getName () + " gives UpdateUnit.", units.get (id));
    UpdateUnit u = units.get (id);
    assertNull ("Unit is not installed.", u.getInstalled ());
    assertNotNull ("Unit has update.", u.getAvailableUpdates ());
    assertFalse ("Unit.getAvailableUpdates() is not empty.", u.getAvailableUpdates ().isEmpty ());
    assertEquals ("Unit has only one update.", 1, u.getAvailableUpdates ().size ());
    UpdateElement el = u.getAvailableUpdates ().get (0);
    assertEquals ("org.yourorghere.depending", el.getCodeName ());
    assertEquals ("1.0", el.getSpecificationVersion ());
    assertEquals (0, el.getDownloadSize ());
}
 
Example #12
Source File: Unit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public int getCompleteSize () {
    if (size == -1) {
        size = 0;
        OperationContainer<OperationSupport> c = OperationContainer.createForDirectUpdate ();
        OperationInfo<OperationSupport> i = c.add (getRelevantElement ());
        Set<UpdateElement> elems = i.getRequiredElements ();
        for (UpdateElement el : elems) {
            size += el.getDownloadSize ();
        }
        size += getRelevantElement ().getDownloadSize ();
        c.removeAll ();
    }
    return size;
}
 
Example #13
Source File: NbmExternalTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #14
Source File: TargetClusterTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected File getTargetCluster (String target, Boolean global) throws IOException, OperationException {
    assertTrue (target + " cannot be empty.", target == null || target.length () > 0);
    String module = getCodeName (target, global);

    String catalog = generateCatalog (generateModuleElement (module, "1.1", global, target));
    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 (module + " found in parsed items.", updates.keySet ().contains (module + "_1.1"));

    UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog));
    UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true);

    UpdateUnit uu = UpdateManagerImpl.getInstance ().getUpdateUnit (module);
    assertNotNull (module + " - UpdateUnit found.", uu);
    assertFalse ("Available updates " + uu, uu.getAvailableUpdates ().isEmpty ());
    UpdateElement ue = uu.getAvailableUpdates ().get (0);
    ModuleUpdateElementImpl impl = (ModuleUpdateElementImpl) Trampoline.API.impl (ue);
    assertNotNull ("Impl " + ue + " found and is instanceof ModuleUpdateElementImpl.", impl);

    File targetDir = InstallManager.findTargetDirectory (getInstalledUpdateElement (), impl, global, false);
    assertNotNull ("Target cluster cannot be null for " + impl, targetDir);

    return targetDir;
}
 
Example #15
Source File: UpdateHandler.java    From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #16
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("null")
public static boolean isElementInstalled (UpdateElement el) {
    assert el != null : "Invalid call isElementInstalled with null parameter.";
    if (el == null) {
        return false;
    }
    return el.equals (el.getUpdateUnit ().getInstalled ());
}
 
Example #17
Source File: UpdateManagerImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public synchronized Set<UpdateElement> getInstalledEagers() {
    if (installedEagers == null) {
        createMaps ();
    }            
    assert installedEagers != null : "installedEagers initialized";
    return installedEagers;
}
 
Example #18
Source File: ModulesInstaller.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public static String presentUpdateElements (Collection<UpdateElement> elems) {
    String res = "";
    for (UpdateElement el : new LinkedList<UpdateElement> (elems)) {
        res += res.length () == 0 ? el.getDisplayName () : ", " + el.getDisplayName (); // NOI18N
    }
    return res;
}
 
Example #19
Source File: WakaTime.java    From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static String getPluginVersion() {
    for (UpdateUnit updateUnit : UpdateManager.getDefault().getUpdateUnits()) {
        UpdateElement updateElement = updateUnit.getInstalled();
        if (updateElement != null)
            if (WakaTime.CODENAME.equals(updateElement.getCodeName()))
                return updateElement.getSpecificationVersion();
    }
    return "Unknown";
}
 
Example #20
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static List<ModuleInfo> getModuleInfos (Collection<UpdateElement> elements) {
    List<ModuleInfo> infos = new ArrayList<ModuleInfo> (elements.size ());
    for (UpdateElement el : elements) {
        if (el.getUpdateUnit () != null && el.getUpdateUnit ().isPending ()) {
            // cannot depend of UpdateElement in pending state
            continue;
        }
        UpdateElementImpl impl = Trampoline.API.impl (el);
        infos.addAll (impl.getModuleInfos ());
    }
    return infos;
}
 
Example #21
Source File: OperationValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: OperationWizardModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SortedMap<String, Set<UpdateElement>> getBrokenDependency2Plugins () {
    if (dep2plugins != null) {
        return dep2plugins;
    }
    
    dep2plugins = new TreeMap<String, Set<UpdateElement>> ();

    for (OperationInfo<?> info : getBaseInfos ()) {
        Set<String> broken = info.getBrokenDependencies ();
        if (! broken.isEmpty()) {
            for (String brokenDep : broken) {
                // pay special attention to missing JDK
                if (brokenDep.toLowerCase ().startsWith ("package")) {
                    brokenDep = "package";
                }
                if (dep2plugins.get (brokenDep) == null) {
                    dep2plugins.put (brokenDep, new HashSet<UpdateElement> ());
                }
                dep2plugins.get (brokenDep).add (info.getUpdateElement ());
            }
            if (dep2plugins.keySet ().size () >= MAX_TO_REPORT) {
                dep2plugins.put (MORE_BROKEN_PLUGINS, null);
                break;
            }
        }
    }
    return dep2plugins;
}
 
Example #23
Source File: InstallCustomInstalledTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: NbmAdvancedTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected UpdateElement installUpdateUnit (UpdateUnit unit) {
    OperationContainer ic = OperationContainer.createForInstall ();
    assertNotNull (unit + " has available update.", unit.getAvailableUpdates ());
    ic.add (unit.getAvailableUpdates ().get (0));
    OperationInfo requiresInfo = (OperationInfo) ic.listAll ().iterator ().next ();
    assertNotNull (requiresInfo);
    ic.add (requiresInfo.getRequiredElements ());
    
    assertTrue ("Install operation on " + unit + " is valid.", ic.listInvalid ().isEmpty ());
    assertFalse ("Something will be installed for " + unit, ic.listAll ().isEmpty ());
    InstallSupport is = (InstallSupport) ic.getSupport ();
    try {
        
        InstallSupport.Validator v = is.doDownload (null, false);
        InstallSupport.Installer i = is.doValidate (v, null);
        is.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 ());
        }
    }
    
    // check if unit was installed
    assertNotNull (unit + " is installed.", unit.getInstalled ());
    
    return unit.getInstalled ();
}
 
Example #25
Source File: Unit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TreeSet<UpdateUnit> getUpdateUnits() {
    if (internalUpdates == null) {
        internalUpdates = new TreeSet<UpdateUnit>(new Comparator<UpdateUnit>() {
            @Override
            public int compare(UpdateUnit uu1, UpdateUnit uu2) {
                UpdateElement ue1 = uu1.getInstalled() != null ? uu1.getInstalled() : uu1.getAvailableUpdates().get(0);
                UpdateElement ue2 = uu2.getInstalled() != null ? uu2.getInstalled() : uu2.getAvailableUpdates().get(0);
                return ue1.getDisplayName().compareTo(ue2.getDisplayName());
            }
        });
    }
    return internalUpdates;
}
 
Example #26
Source File: FindComponentModules.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #27
Source File: OperationValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Set<String> getBrokenDependencies (OperationContainerImpl.OperationType type,
        UpdateElement updateElement,
        List<ModuleInfo> moduleInfos) {
        Set<String> broken = new HashSet<String> ();
        switch (type) {
        case ENABLE :
            broken = Utilities.getBrokenDependenciesInInstalledModules (updateElement);
            break;
        case INSTALL :
        case UPDATE :
        case INTERNAL_UPDATE:
            Set<UpdateElement> recommeded = new HashSet<UpdateElement>();
            getRequiredElements (type, updateElement, moduleInfos, broken, recommeded);
            if (! recommeded.isEmpty() && ! broken.isEmpty()) {
                broken = new HashSet<String> ();
                getRequiredElements(type, updateElement, moduleInfos, broken, recommeded);
            }
            break;
        case UNINSTALL :
        case DIRECT_UNINSTALL :
        case CUSTOM_UNINSTALL :
        case DISABLE :
        case DIRECT_DISABLE :
        case CUSTOM_INSTALL:
            broken = Utilities.getBrokenDependencies (updateElement, moduleInfos);
            break;
        default:
            assert false : "Unknown type of operation " + type;
        }
        return broken;
}
 
Example #28
Source File: IDEServicesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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 #29
Source File: ProblemPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ProblemPanel (OperationException ex, UpdateElement culprit, String problemDescription, boolean warning, JButton... buttons) {
    this.ex = ex;
    this.buttons = buttons;
    this.isWarning = warning;
    if (ex == null) {
        initProxyProblem(problemDescription);
    } else {
        switch (ex.getErrorType()) {
            case PROXY:
                initProxyProblem(problemDescription);
                break;
            case WRITE_PERMISSION:
                initWriteProblem(culprit, problemDescription);
                break;
            case INSTALL:
                initInstallProblem(ex);
                break;
            case MODIFIED:
                initModifiedProblem(ex, problemDescription);
                break;
            default:
                assert false : "Unknown type " + ex;
        }
    }
    for (JButton b : buttons) {
        b.getAccessibleContext ().setAccessibleDescription (b.getText ());
    }
}
 
Example #30
Source File: InstallStep.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}