use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.
the class ViewKifuActivity method onMoveSelectedEvent.
@EventHandler
public void onMoveSelectedEvent(final MoveSelectedEvent event) {
GWT.log("ViewKifuActivity handling MoveSelectedEvent");
eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree(), event.getMoveNumber()));
}
use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.
the class GameTreePanel method createContextMenu.
private PopupPanel createContextMenu() {
final PopupPanel contextMenu;
contextMenu = new PopupPanel(true);
MenuBar menuBar = new MenuBar(true);
deleteVariationMenu = new MenuItem("Delete Variation", () -> {
GWT.log("Delete variation");
Node node = (Node) tree.getSelectedItem().getUserObject();
boolean confirm = Window.confirm("Delete variation starting with " + tree.getSelectedItem().getText() + "? This can not be undone.");
if (confirm) {
node.removeFromParent();
eventBus.fireEvent(new GameTreeChangedEvent(gameNavigation.getGameTree()));
}
contextMenu.hide();
});
menuBar.addItem(deleteVariationMenu);
if (!readOnly) {
promoteVariationMenu = new MenuItem("Promote variation to main line", () -> {
GWT.log("Promote variation");
Node node = (Node) tree.getSelectedItem().getUserObject();
node.promoteVariation();
eventBus.fireEvent(new GameTreeChangedEvent(gameNavigation.getGameTree()));
contextMenu.hide();
});
menuBar.addItem(promoteVariationMenu);
rebaseMenu = new MenuItem("Start from here", () -> {
GWT.log("Rebase");
Node node = (Node) tree.getSelectedItem().getUserObject();
if (!(node.getMove() instanceof EditMove)) {
GWT.log("Not an edit move - aborting");
return;
}
boolean confirm = Window.confirm("Only keep the variations starting from this position?" + " This can not be undone.");
if (confirm) {
node.setParent(null);
node.setParentIndex(0);
GameTree gameTree = new GameTree(node);
eventBus.fireEvent(new GameTreeChangedEvent(gameTree));
}
contextMenu.hide();
});
menuBar.addItem(rebaseMenu);
}
contextMenu.add(menuBar);
contextMenu.hide();
return contextMenu;
}
use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.
the class ByoYomiActivity method getProblemRequestCallback.
private AsyncCallback<ProblemDetails> getProblemRequestCallback() {
return new AsyncCallback<ProblemDetails>() {
@Override
public void onSuccess(final ProblemDetails result) {
if (result == null) {
GWT.log("Got null usf from server for random problem request");
} else {
GWT.log("Got problem details for random problem request: " + result);
String resultUsf = result.getUsf();
GameRecord gameRecord = UsfFormat.INSTANCE.readSingle(resultUsf);
GWT.log("Updating game navigator...");
setTsumeId(result.getId());
eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
initProblemTimer();
initMoveTimer();
}
}
@Override
public void onFailure(final Throwable caught) {
GWT.log("Remote called failed for problem request");
}
};
}
use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.
the class KifuEditorActivity method onImportGameRecord.
@EventHandler
public void onImportGameRecord(final ImportGameRecordEvent gameRecordChangedEvent) {
GWT.log("problem editor Activity Handling ImportGameRecordEvent");
GameRecord gameRecord = gameRecordChangedEvent.getGameRecord();
eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
eventBus.fireEvent(new GameInformationChangedEvent(gameRecord.getGameInformation()));
}
use of com.playshogi.website.gwt.client.events.gametree.GameTreeChangedEvent in project playshogi by Tellmarch.
the class TsumeActivity method getProblemRequestCallback.
private AsyncCallback<ProblemDetails> getProblemRequestCallback(final String tsumeId) {
return new AsyncCallback<ProblemDetails>() {
@Override
public void onSuccess(final ProblemDetails result) {
if (result == null) {
GWT.log("Got null usf from server for problem request: " + tsumeId);
} else {
GWT.log("Got problem details problem request: " + tsumeId + " : " + result);
String resultUsf = result.getUsf();
GameRecord gameRecord = UsfFormat.INSTANCE.readSingle(resultUsf);
GWT.log("Updating game navigator...");
setTsumeId(result.getId());
History.newItem("Tsume:" + new TsumePlace.Tokenizer().getToken(getPlace()), false);
eventBus.fireEvent(new GameTreeChangedEvent(gameRecord.getGameTree()));
initTimer();
}
}
@Override
public void onFailure(final Throwable caught) {
GWT.log("Remote called failed for problem request: " + tsumeId);
}
};
}
Aggregations