Beispiel #1
0
  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);
  }
Beispiel #2
0
  @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);
          }
        });
  }
Beispiel #3
0
 @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);
         }
       });
 }
Beispiel #4
0
 @Override
 public void checkFailed(final String message) {
   UpdateCore.logInfo("UpdateStatusControl.checkFailed()");
   asyncExec(
       new Runnable() {
         @Override
         public void run() {
           setStatus(message, regularFont);
           setActionEnabled(checkFordUpdatesAction);
         }
       });
 }
Beispiel #5
0
 @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);
         }
       });
 }
Beispiel #6
0
 /**
  * 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;
 }
Beispiel #7
0
 @Override
 public void run() {
   UpdateCore.getUpdateManager().scheduleDownload(latestAvailableRevision);
 }
Beispiel #8
0
 @Override
 public void run() {
   UpdateCore.getUpdateManager().scheduleInstall();
 }
Beispiel #9
0
 @Override
 public void widgetDisposed(DisposeEvent e) {
   UpdateCore.getUpdateManager().removeListener(this);
 }
Beispiel #10
0
 @Override
 public void run() {
   UpdateCore.getUpdateManager().scheduleUpdateCheck();
 }
Beispiel #11
0
 /**
  * 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);
 }
Beispiel #12
0
 /**
  * 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());
 }
Beispiel #13
0
 @Override
 public void updateAvailable(Revision revision) {
   if (UpdateCore.isAutoDownloadEnabled() && !model.isDownloadingUpdate()) {
     scheduleDownload(revision);
   }
 }