Search in sources :

Example 1 with UpdateInfo

use of org.knime.core.eclipseUtil.UpdateChecker.UpdateInfo in project knime-core by knime.

the class NewReleaseMessageInjector method injectUpdateMessage.

private void injectUpdateMessage(final Document doc) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException {
    XPath xpath = m_xpathFactory.newXPath();
    Element updateNode = (Element) xpath.evaluate("//div[@id='update-inner']", doc.getDocumentElement(), XPathConstants.NODE);
    Element minorUpdatesAvailableSpan = (Element) xpath.evaluate("//span[@id='release-available']", updateNode, XPathConstants.NODE);
    // removes the "hidden" style and makes it visible
    minorUpdatesAvailableSpan.removeAttribute("style");
    Element updateList = (Element) xpath.evaluate(".//ul[@id='release-list']", updateNode, XPathConstants.NODE);
    // removes the "hidden" style and makes it visible
    updateList.removeAttribute("style");
    boolean updatePossible = true;
    for (UpdateInfo ui : m_newMinorVersions) {
        updatePossible &= ui.isUpdatePossible();
        Element li = doc.createElement("li");
        li.setTextContent(ui.getName());
        updateList.appendChild(li);
    }
    if (updatePossible) {
        Element updatePossibleNode = (Element) xpath.evaluate(".//span[@id='update-possible']", updateNode, XPathConstants.NODE);
        updatePossibleNode.removeAttribute("style");
    } else {
        Element updateNotPossibleNode = (Element) xpath.evaluate(".//span[@id='update-not-possible']", updateNode, XPathConstants.NODE);
        updateNotPossibleNode.removeAttribute("style");
    }
    if (m_prefs.getBoolean("org.knime.product.intro.update", true)) {
        // removes the "hidden" style
        updateNode.removeAttribute("style");
    }
}
Also used : XPath(javax.xml.xpath.XPath) Element(org.w3c.dom.Element) UpdateInfo(org.knime.core.eclipseUtil.UpdateChecker.UpdateInfo)

Example 2 with UpdateInfo

use of org.knime.core.eclipseUtil.UpdateChecker.UpdateInfo in project knime-core by knime.

the class NewReleaseMessageInjector method checkNewMinorVersion.

private List<UpdateInfo> checkNewMinorVersion() throws IOException, URISyntaxException {
    final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
    RepositoryTracker tracker = provUI.getRepositoryTracker();
    if (tracker == null) {
        // if run from the IDE there will be no tracker
        return Collections.emptyList();
    }
    List<UpdateInfo> updateList = new ArrayList<>();
    for (URI uri : tracker.getKnownRepositories(provUI.getSession())) {
        if (("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) && (uri.getHost().endsWith(".knime.org") || uri.getHost().endsWith(".knime.com"))) {
            UpdateInfo newRelease = UpdateChecker.checkForNewRelease(uri);
            if (newRelease != null) {
                updateList.add(newRelease);
            }
        }
    }
    return updateList;
}
Also used : ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) ArrayList(java.util.ArrayList) URI(java.net.URI) UpdateInfo(org.knime.core.eclipseUtil.UpdateChecker.UpdateInfo) RepositoryTracker(org.eclipse.equinox.p2.operations.RepositoryTracker)

Aggregations

UpdateInfo (org.knime.core.eclipseUtil.UpdateChecker.UpdateInfo)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 XPath (javax.xml.xpath.XPath)1 RepositoryTracker (org.eclipse.equinox.p2.operations.RepositoryTracker)1 ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)1 Element (org.w3c.dom.Element)1