Skip to content

Commit

Permalink
fixed a bug with the remove last game feature
Browse files Browse the repository at this point in the history
  • Loading branch information
stieglma committed Sep 11, 2015
1 parent b5001f3 commit 2f19b3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Binary file modified Schafkopfauswerter.jar
Binary file not shown.
14 changes: 11 additions & 3 deletions src/main/java/RemoveLastGame.aj
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

Expand All @@ -12,6 +13,7 @@ import me.stieglmaier.schafkopfAuswerter.view.GUI;
public privileged aspect RemoveLastGame {

private GUI gui;
private JButton buttonRemoveLastGame;

/**
* catch constructor call, so that we have the correct gui, to refer to everywhere
Expand All @@ -36,11 +38,16 @@ public privileged aspect RemoveLastGame {
return false;
}

after() : execution(* GameData.addData(*)) {
this.buttonRemoveLastGame.setEnabled(true);
}

/** add remove last game button */
after() returning(JPanel panel): call(JPanel GUI.createButtonPane()) {
JButton buttonRemoveLastGame = new JButton("letztes Spiel löschen");
buttonRemoveLastGame.addActionListener(new RemoveLastGameListener());
this.buttonRemoveLastGame = new JButton("letztes Spiel löschen");
this.buttonRemoveLastGame.addActionListener(new RemoveLastGameListener());
panel.add(buttonRemoveLastGame);
this.buttonRemoveLastGame.setEnabled(false);
}

/** catch execution of removelastgamelistener and remove the game + update ui */
Expand All @@ -50,8 +57,9 @@ public privileged aspect RemoveLastGame {
gui.table.updateUI();
gui.updateValues();
}

if(gui.model.getGameData().size() <= 1) {
gui.tabbedPane.setEnabledAt(1, false);
this.buttonRemoveLastGame.setEnabled(false);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/me/stieglmaier/schafkopfAuswerter/view/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ private JTabbedPane createTabbedPane() {
tabbedPane.addTab("Einstellungen", null, new ConfigPopup(this), null);
tabbedPane.addTab("Tabelle", null, scrollPane, null);

tabbedPane.setEnabledAt(1, false);

return tabbedPane;
}
}

0 comments on commit 2f19b3e

Please sign in to comment.