Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI issue105 clean up the tool bar #134

Merged
merged 7 commits into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ gradle-app.setting
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,java

**/.DS_Store
gradle/wrapper/gradle-wrapper.properties
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
39 changes: 20 additions & 19 deletions src/main/java/edu/rpi/legup/ui/LegupUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ private void setupMenu() {
{
GameBoardFacade.getInstance().getHistory().redo();
});

if(Objects.equals(os, "mac")) redo.setAccelerator(KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() + InputEvent.SHIFT_DOWN_MASK));
else redo.setAccelerator(KeyStroke.getKeyStroke('Z', InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));

Expand Down Expand Up @@ -377,10 +378,10 @@ private void setupToolBar() {
getToolBarButtons()[i].setHorizontalTextPosition(SwingConstants.CENTER);
}

toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle());
toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof());
toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo());
toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo());
// toolBarButtons[ToolbarName.OPEN_PUZZLE.ordinal()].addActionListener((ActionEvent e) -> promptPuzzle());
// toolBarButtons[ToolbarName.SAVE.ordinal()].addActionListener((ActionEvent e) -> saveProof());
// toolBarButtons[ToolbarName.UNDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().undo());
// toolBarButtons[ToolbarName.REDO.ordinal()].addActionListener((ActionEvent e) -> GameBoardFacade.getInstance().getHistory().redo());
toolBarButtons[ToolbarName.HINT.ordinal()].addActionListener((ActionEvent e) -> {
});
toolBarButtons[ToolbarName.CHECK.ordinal()].addActionListener((ActionEvent e) -> checkProof());
Expand All @@ -391,9 +392,9 @@ private void setupToolBar() {

toolBarButtons[ToolbarName.CHECK_ALL.ordinal()].addActionListener((ActionEvent e) -> checkProofAll());

toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false);
toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false);
toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);
toolBarButtons[ToolbarName.HINT.ordinal()].setEnabled(false);
toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(false);
toolBarButtons[ToolbarName.SUBMIT.ordinal()].setEnabled(false);
Expand Down Expand Up @@ -639,9 +640,9 @@ private void directions() {
}

private void showAll() {
getToolBarButtons()[ToolbarName.SAVE.ordinal()].setEnabled(true);
getToolBarButtons()[ToolbarName.UNDO.ordinal()].setEnabled(false);
getToolBarButtons()[ToolbarName.REDO.ordinal()].setEnabled(false);
// getToolBarButtons()[ToolbarName.SAVE.ordinal()].setEnabled(true);
// getToolBarButtons()[ToolbarName.UNDO.ordinal()].setEnabled(false);
// getToolBarButtons()[ToolbarName.REDO.ordinal()].setEnabled(false);
getToolBarButtons()[ToolbarName.HINT.ordinal()].setEnabled(true);
getToolBarButtons()[ToolbarName.CHECK.ordinal()].setEnabled(true);
getToolBarButtons()[ToolbarName.SUBMIT.ordinal()].setEnabled(true);
Expand Down Expand Up @@ -862,7 +863,7 @@ public void setPuzzleView(Puzzle puzzle) {
ruleFrame.getContradictionPanel().setRules(puzzle.getContradictionRules());

toolBarButtons[ToolbarName.CHECK.ordinal()].setEnabled(true);
toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true);
// toolBarButtons[ToolbarName.SAVE.ordinal()].setEnabled(true);

reloadGui();
}
Expand All @@ -888,9 +889,9 @@ public TreePanel getTreePanel() {
public void onPushChange(ICommand command) {
LOGGER.info("Pushing " + command.getClass().getSimpleName() + " to stack.");
undo.setEnabled(true);
toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true);
// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(true);
redo.setEnabled(false);
toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);

String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName();
File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName());
Expand All @@ -906,9 +907,9 @@ public void onPushChange(ICommand command) {
@Override
public void onUndo(boolean isBottom, boolean isTop) {
undo.setEnabled(!isBottom);
toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom);
// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom);
redo.setEnabled(!isTop);
toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop);
// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop);
String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName();
File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName());
if (isBottom) {
Expand All @@ -927,9 +928,9 @@ public void onUndo(boolean isBottom, boolean isTop) {
@Override
public void onRedo(boolean isBottom, boolean isTop) {
undo.setEnabled(!isBottom);
toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom);
// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(!isBottom);
redo.setEnabled(!isTop);
toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop);
// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(!isTop);
if (isBottom) {
String puzzleName = GameBoardFacade.getInstance().getPuzzleModule().getName();
File puzzleFile = new File(GameBoardFacade.getInstance().getCurFileName());
Expand All @@ -947,8 +948,8 @@ public void onRedo(boolean isBottom, boolean isTop) {
@Override
public void onClearHistory() {
undo.setEnabled(false);
toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.UNDO.ordinal()].setEnabled(false);
redo.setEnabled(false);
toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);
// toolBarButtons[ToolbarName.REDO.ordinal()].setEnabled(false);
}
}
2 changes: 1 addition & 1 deletion src/main/java/edu/rpi/legup/ui/ToolbarName.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.rpi.legup.ui;

public enum ToolbarName {
OPEN_PUZZLE, SAVE, UNDO, REDO, HINT, CHECK, SUBMIT, DIRECTIONS, CHECK_ALL;
HINT, CHECK, SUBMIT, DIRECTIONS, CHECK_ALL;

/**
* Gets the String representation of the ToolbarName enum
Expand Down