Skip to content

Commit

Permalink
Version-6
Browse files Browse the repository at this point in the history
  • Loading branch information
xaverW committed Apr 23, 2021
1 parent 0cd8bb0 commit 93320d9
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 137 deletions.
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

<br />

**Release 6**

* Update-Dialog: Suche nach einem Programmupdate
* ...

<br />
<br />

**Release 5**

* Dark-Theme: Kann in den Einstellungen eingestellt werden
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/de/p2tools/fileRunner/FileRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public void losGehts() {
ProgStart.setOrgTitle(progData);

PDuration.onlyPing("Gui steht!");
new SearchProgramUpdate(primaryStage, progData).checkProgramUpdate();
Thread th = new Thread(() -> {
new SearchProgramUpdate(primaryStage, progData).searchUpdateProgStart();
});
th.setName("checkProgUpdate");
th.start();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package de.p2tools.fileRunner;

import de.p2tools.fileRunner.controller.ProgQuitt;
import de.p2tools.fileRunner.controller.SearchProgramUpdate;
import de.p2tools.fileRunner.controller.config.ProgData;
import de.p2tools.fileRunner.controller.data.Icons;
import de.p2tools.fileRunner.gui.GuiDirRunner;
Expand Down Expand Up @@ -84,18 +83,13 @@ private void init() {
final MenuItem miQuitt = new MenuItem("Beenden");
miQuitt.setOnAction(e -> new ProgQuitt().quitt(true));

final MenuItem miUpdate = new MenuItem("Gibt es ein Update?");
miUpdate.setOnAction(event -> new SearchProgramUpdate(progData.primaryStage, progData)
.checkVersion(false));

final MenuItem miAbout = new MenuItem("Über dieses Programm");
miAbout.setOnAction(event -> new AboutDialogController(progData));

menuButton.getStyleClass().add("btnFunctionWide");
menuButton.setText("");
menuButton.setGraphic(new Icons().FX_ICON_TOOLBAR_MENUE_TOP);
menuButton.getItems().addAll(miConfig,
new SeparatorMenuItem(), miAbout, miUpdate,
menuButton.getItems().addAll(miConfig, miAbout,
new SeparatorMenuItem(), miQuitt);

menuButton2.getStyleClass().add("btnFunctionWide");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package de.p2tools.fileRunner.controller;

import de.p2tools.fileRunner.controller.config.ProgConfig;
import de.p2tools.fileRunner.controller.config.ProgConst;
import de.p2tools.fileRunner.controller.config.ProgData;
import de.p2tools.p2Lib.checkForUpdates.SearchProgUpdate;
import de.p2tools.p2Lib.checkForUpdates.UpdateSearchData;
import de.p2tools.p2Lib.tools.ProgramTools;
import de.p2tools.p2Lib.tools.duration.PDuration;
import de.p2tools.p2Lib.tools.log.PLog;
Expand Down Expand Up @@ -45,71 +48,51 @@ public SearchProgramUpdate(Stage stage, ProgData progData) {
*
* @return
*/
public boolean checkVersion() {
return checkVersion(true, true, true);
public boolean searchUpdate() {
return checkVersion(true);
}

public boolean checkVersion(boolean showDailyUpdate) {
return checkVersion(showDailyUpdate, true, true);
}

private boolean checkVersion(boolean showDailyUpdate, boolean showError, boolean showProgramInformation) {
// prüft auf neue Version,
ProgConfig.SYSTEM_UPDATE_PROGRAM_VERSION.setValue(ProgramTools.getProgVersionInt());
ProgConfig.SYSTEM_UPDATE_DATE.setValue(FastDateFormat.getInstance("dd.MM.yyyy").format(new Date()));

if (showDailyUpdate) {
// todo
// return new SearchProgInfo(stage).checkUpdate(ProgConst.WEBSITE_PROG_UPDATE,
// ProgConfig.SYSTEM_UPDATE_PROGRAM_VERSION.get(),
// ProgConfig.SYSTEM_UPDATE_INFOS_NR,
// ProgConfig.SYSTEM_UPDATE_SEARCH_PROG_START,
// showProgramInformation, showError);
} else {
// return new SearchProgInfo(stage).checkUpdate(ProgConst.WEBSITE_PROG_UPDATE,
// ProgConfig.SYSTEM_UPDATE_PROGRAM_VERSION.get(),
// ProgConfig.SYSTEM_UPDATE_INFOS_NR,
// //ProgConfig.SYSTEM_UPDATE_SEARCH_PROG_START,
// showProgramInformation, showError);
}
return false;
}


/**
* check if program update is available and show the
* the result in the program title
*/
public void checkProgramUpdate() {
public void searchUpdateProgStart() {
PDuration.onlyPing("checkProgUpdate");

if (!ProgConfig.SYSTEM_UPDATE_SEARCH_PROG_START.get() ||
ProgConfig.SYSTEM_UPDATE_PROGRAM_VERSION.get() == ProgramTools.getProgVersionInt() /*Start mit neuer Version*/
&& ProgConfig.SYSTEM_UPDATE_DATE.get().equals(FastDateFormat.getInstance("dd.MM.yyyy").format(new Date()))) {

if (!ProgConfig.SYSTEM_UPDATE_SEARCH_PROG_START.get()) {
// will der User nicht --oder-- keine neue Version und heute schon gemacht
PLog.sysLog("Kein Update-Check");
return;
}

Thread th = new Thread(() -> {
try {
if (checkVersion(true, false, false)) {
// gab eine neue Version
Platform.runLater(() -> ProgStart.setUpdateTitle(progData));
} else {
Platform.runLater(() -> ProgStart.setNoUpdateTitle(progData));
}

sleep(10_000);
Platform.runLater(() -> ProgStart.setOrgTitle(progData));

} catch (final Exception ex) {
PLog.errorLog(794612801, ex);
Platform.runLater(() -> ProgStart.setOrgTitle(progData));
try {
if (checkVersion(false)) {
// gab eine neue Version
Platform.runLater(() -> ProgStart.setUpdateTitle(progData));
} else {
Platform.runLater(() -> ProgStart.setNoUpdateTitle(progData));
}
});
th.setName("checkProgUpdate");
th.start();
sleep(10_000);
} catch (final Exception ex) {
PLog.errorLog(794612801, ex);
}
Platform.runLater(() -> ProgStart.setOrgTitle(progData));
}

private boolean checkVersion(boolean showProgramInformation) {
// prüft auf neue Version,
// ProgConfig.SYSTEM_UPDATE_VERSION_SHOWN.setValue(ProgramTools.getProgVersionInt());
ProgConfig.SYSTEM_UPDATE_SEARCH_DATE.setValue(FastDateFormat.getInstance("dd.MM.yyyy").format(new Date()));

UpdateSearchData updateSearchData = new UpdateSearchData(ProgConst.WEBSITE_PROG_UPDATE,
ProgramTools.getProgVersionInt(),
ProgramTools.getBuildInt(),
ProgConfig.SYSTEM_UPDATE_VERSION_SHOWN,
null,
ProgConfig.SYSTEM_UPDATE_INFOS_NR_SHOWN,
ProgConfig.SYSTEM_UPDATE_SEARCH_PROG_START);

boolean ret = new SearchProgUpdate(stage).checkAllUpdates(updateSearchData, null, showProgramInformation);
return ret;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public class ProgConfig extends PDataProgConfig {
// Configdialog

// Programupdate
public static IntegerProperty SYSTEM_UPDATE_PROGRAM_VERSION = addInt("system-update-program-version", 0);
public static BooleanProperty SYSTEM_UPDATE_SEARCH_PROG_START = addBool("system-update-search-prog-update", true);
public static StringProperty SYSTEM_UPDATE_DATE = addStr("system-update-date");
public static IntegerProperty SYSTEM_UPDATE_INFOS_NR = addInt("system-update-info-nr", 0);
public static IntegerProperty SYSTEM_UPDATE_VERSION_SHOWN = addInt("system-update-version-shown", 0);
public static BooleanProperty SYSTEM_UPDATE_SEARCH_PROG_START = addBool("system-update-search-prog-start", true);
public static StringProperty SYSTEM_UPDATE_SEARCH_DATE = addStr("system-update-search-date");
public static IntegerProperty SYSTEM_UPDATE_INFOS_NR_SHOWN = addInt("system-update-info-nr-shown", 0);

private static ProgConfig instance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ProgConst {

public static final String WEBSITE_P2 = "https://www.p2tools.de";
public static final String WEBSITE_FILE_RUNNER = "https://www.p2tools.de/filerunner/";
public static final String WEBSITE_FILE_RUNNER_HELP = "https://www.p2tools.de/filerunner/manual.html";
public static final String WEBSITE_PROG_UPDATE = "https://www.p2tools.de/extra/filerunner-info.xml";

public static final String P2_ICON = "P2.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void makeConfig() {
//jetzt suchen
Button btnNow = new Button("Jetzt suchen");
btnNow.setMaxWidth(Double.MAX_VALUE);
btnNow.setOnAction(event -> new SearchProgramUpdate(stage, ProgData.getInstance()).checkVersion());
btnNow.setOnAction(event -> new SearchProgramUpdate(stage, ProgData.getInstance()).searchUpdate());

// Website
Hyperlink hyperlink = new Hyperlink(ProgConst.WEBSITE_FILE_RUNNER);
Expand Down
Loading

0 comments on commit 93320d9

Please sign in to comment.