public UpdateStatusControl( Composite parent, Color backgroundColor, Point margin, boolean isCentered) { this.backgroundColor = backgroundColor; this.margin = margin; this.isCentered = isCentered; createControl(parent); cacheFonts(); // pad the initial status message to ensure it's wide enough to display new version available // text setStatus( padToMatch( "Checking for updates...", bindRevision(NEW_VERSION_AVAILABLE_MSG + WHATS_NEW_LINK_TEXT, "000000")), italicFont); setActionDisabled(checkFordUpdatesAction); UpdateManager updateManager = UpdateCore.getUpdateManager(); updateManager.addListener(this); if (updateManager.isDownloadingUpdate()) { downloadStarted(); } else { updateManager.scheduleUpdateCheck(); } parent.addDisposeListener(this); }
@Override public void updateAvailable(final Revision revision) { this.latestAvailableRevision = revision; UpdateCore.logInfo("UpdateStatusControl.updateAvailable() => " + latestAvailableRevision); asyncExec( new Runnable() { @Override public void run() { String link = ""; try { URL url = revision.getUrl(); // sanity check in case a custom URL is being used if (url.getPath().contains("integration")) { link = WHATS_NEW_LINK_TEXT; } } catch (MalformedURLException e) { // bad URL means no link } setStatus( bindRevision(NEW_VERSION_AVAILABLE_MSG + link, latestAvailableRevision), regularFont); setActionEnabled(downloadUpdateAction); } }); }
@Override public void updateStaged() { UpdateCore.logInfo("UpdateStatusControl.updateStaged()"); asyncExec( new Runnable() { @Override public void run() { setStatus("An update is ready to install", regularFont); setActionEnabled(applyUpdateAction); } }); }
@Override public void checkFailed(final String message) { UpdateCore.logInfo("UpdateStatusControl.checkFailed()"); asyncExec( new Runnable() { @Override public void run() { setStatus(message, regularFont); setActionEnabled(checkFordUpdatesAction); } }); }
@Override public void checkComplete() { UpdateCore.logInfo("UpdateStatusControl.checkComplete()"); asyncExec( new Runnable() { @Override public void run() { setStatus("Dart Editor is up to date.", regularFont); setActionDisabled(checkFordUpdatesAction); } }); }
/** * Get the latest staged revision number. * * @return the latest staged revision */ public Revision getLatestStaged() { IPath updateDirPath = UpdateCore.getUpdateDirPath(); File dir = updateDirPath.toFile(); Revision latest = Revision.UNKNOWN; if (dir.exists() && dir.isDirectory()) { for (File file : dir.listFiles()) { Revision revision = Revision.forValue(file.getName().split(".zip")[0]); if (revision.isMoreCurrentThan(latest)) { latest = revision; } } } return latest; }
@Override public void run() { UpdateCore.getUpdateManager().scheduleDownload(latestAvailableRevision); }
@Override public void run() { UpdateCore.getUpdateManager().scheduleInstall(); }
@Override public void widgetDisposed(DisposeEvent e) { UpdateCore.getUpdateManager().removeListener(this); }
@Override public void run() { UpdateCore.getUpdateManager().scheduleUpdateCheck(); }
/** * Check to see if there is an update staged and ready to be applied. * * @return <code>true</code> if there is an update ready to be applied, <code>false</code> * otherwise */ public boolean isUpdateStaged() { Revision current = UpdateCore.getCurrentRevision(); Revision staged = getLatestStaged(); return staged.isMoreCurrentThan(current); }
/** * Get the latest revision number for update testing. * * @return the latest revision * @throws IOException if an error occurs accessing revision info */ public Revision getLatestRevision() throws IOException { return UpdateUtils.getLatestRevision(UpdateCore.getUpdateUrl()); }
@Override public void updateAvailable(Revision revision) { if (UpdateCore.isAutoDownloadEnabled() && !model.isDownloadingUpdate()) { scheduleDownload(revision); } }