-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ public interface UIDefaults { | |
|
||
int THUMBNAIL_SIZE = 240; | ||
int SCROLL_OFFSET = 120; | ||
|
||
int MAX_REFRESH_COUNT = 3; | ||
} |
30 changes: 0 additions & 30 deletions
30
vpin-studio-ui/src/main/java/de/mephisto/vpin/ui/tables/TableActions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
vpin-studio-ui/src/main/java/de/mephisto/vpin/ui/tables/VPSResetProgressModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package de.mephisto.vpin.ui.tables; | ||
|
||
import de.mephisto.vpin.commons.utils.WidgetFactory; | ||
import de.mephisto.vpin.connectors.vps.model.VPSChanges; | ||
import de.mephisto.vpin.restclient.games.GameRepresentation; | ||
import de.mephisto.vpin.ui.Studio; | ||
import de.mephisto.vpin.ui.events.EventManager; | ||
import de.mephisto.vpin.ui.util.ProgressModel; | ||
import de.mephisto.vpin.ui.util.ProgressResultModel; | ||
import javafx.application.Platform; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import static de.mephisto.vpin.commons.fx.pausemenu.UIDefaults.MAX_REFRESH_COUNT; | ||
import static de.mephisto.vpin.ui.Studio.client; | ||
|
||
public class VPSResetProgressModel extends ProgressModel<GameRepresentation> { | ||
private final static Logger LOG = LoggerFactory.getLogger(VPSResetProgressModel.class); | ||
private List<GameRepresentation> games; | ||
|
||
private final Iterator<GameRepresentation> gameIterator; | ||
|
||
public VPSResetProgressModel(List<GameRepresentation> games) { | ||
super("Resetting VPS Update Indicators"); | ||
this.games = games; | ||
this.gameIterator = games.iterator(); | ||
} | ||
|
||
@Override | ||
public boolean isShowSummary() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isIndeterminate() { | ||
return games.size() == 1; | ||
} | ||
|
||
@Override | ||
public int getMax() { | ||
return games.size(); | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return this.gameIterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public GameRepresentation getNext() { | ||
return gameIterator.next(); | ||
} | ||
|
||
@Override | ||
public String nextToString(GameRepresentation game) { | ||
return game.getGameDisplayName(); | ||
} | ||
|
||
@Override | ||
public void finalizeModel(ProgressResultModel progressResultModel) { | ||
super.finalizeModel(progressResultModel); | ||
|
||
if (games.size() > MAX_REFRESH_COUNT) { | ||
EventManager.getInstance().notifyTablesChanged(); | ||
} | ||
} | ||
|
||
@Override | ||
public void processNext(ProgressResultModel progressResultModel, GameRepresentation game) { | ||
try { | ||
game.setUpdates(new VPSChanges()); | ||
client.getGameService().saveGame(game); | ||
if (games.size() <= MAX_REFRESH_COUNT) { | ||
EventManager.getInstance().notifyTableChange(game.getId(), null); | ||
} | ||
} | ||
catch (Exception e) { | ||
LOG.error("Failed to reset VPS indicator: " + e.getMessage(), e); | ||
Platform.runLater(() -> { | ||
WidgetFactory.showAlert(Studio.stage, "Error", "Failed to reset VPS indicator: " + e.getMessage()); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters