MCPcopy Create free account
hub / github.com/BaseXdb/basex / checkVersion

Method checkVersion

basex-core/src/main/java/org/basex/gui/GUI.java:708–743  ·  view source on GitHub ↗

Checks for new versions. @param ask ask for automatic update checks

(final boolean ask)

Source from the content-addressed store, hash-verified

706 * @param ask ask for automatic update checks
707 */
708 void checkVersion(final boolean ask) {
709 // retrieve latest version
710 final Version version = new Version(gopts.get(GUIOptions.UPDATEVERSION));
711 Version latest = version;
712 try {
713 final Matcher matcher = VERSION_CHECK.matcher(new IOUrl(VERSION_URL).readString());
714 if(matcher.matches()) {
715 latest = new Version(matcher.group(2));
716 gopts.set(GUIOptions.UPDATEVERSION, latest.toString());
717 }
718 } catch(final IOException ex) {
719 Util.debug(ex);
720 }
721
722 final boolean check = gopts.get(GUIOptions.CHECKUPDATES);
723 boolean chk = check;
724 if(version.compareTo(latest) < 0) {
725 if(BaseXDialog.confirm(this, Util.info(H_VERSION_NEW_X_X, Prop.NAME, latest))) {
726 // new version found: open browser page
727 BaseXDialog.browse(this, UPDATE_URL);
728 } else if(ask) {
729 // if page is not opened, ask for automatic check
730 chk = BaseXDialog.confirm(this, H_VERSION_CHECK);
731 gopts.set(GUIOptions.CHECKUPDATES, chk);
732 }
733 saveOptions();
734 } else if(ask) {
735 // version is up-to-date: ask for automatic check
736 chk = BaseXDialog.confirm(this, Util.info(H_VERSION_LATEST_X, Prop.NAME) + '\n' +
737 H_VERSION_CHECK);
738 gopts.set(GUIOptions.CHECKUPDATES, chk);
739 }
740
741 // save changed options
742 if(!version.equals(latest) || check != chk) saveOptions();
743 }
744}

Callers 2

GUIMethod · 0.95
executeMethod · 0.45

Calls 14

toStringMethod · 0.95
debugMethod · 0.95
compareToMethod · 0.95
confirmMethod · 0.95
infoMethod · 0.95
browseMethod · 0.95
saveOptionsMethod · 0.95
equalsMethod · 0.95
getMethod · 0.65
setMethod · 0.65
matcherMethod · 0.45
readStringMethod · 0.45

Tested by

no test coverage detected