Skip to content

Commit

Permalink
Merge pull request #45 from dmk257/dependency_refactoring
Browse files Browse the repository at this point in the history
Moving transientRanks and most error dialogs to the views
  • Loading branch information
vdye authored Aug 3, 2024
2 parents f1e5c4c + a4ddc08 commit 5f1b081
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 313 deletions.
112 changes: 71 additions & 41 deletions src/main/java/org/bigredbands/mb/controllers/ControllerInterface.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.bigredbands.mb.controllers;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import org.bigredbands.mb.models.CommandPair;
import org.bigredbands.mb.models.Move;
import org.bigredbands.mb.models.RankPosition;

/**
Expand Down Expand Up @@ -59,12 +61,13 @@ public interface ControllerInterface {
public boolean isModified();

/**
* Adds a new rank to the models and update the view
* Adds a new rank to the models and update the view.
*
* @param name - the name of the new rank
* @param rankPosition - the position of the new rank
* @param name - The name of the new rank
* @param rankPosition - The position of the new rank
* @return - An error messsge iff adding a rank failed. An empty string otherwise.
*/
public void addRank(String name, RankPosition rankPosition);
public String addRank(String name, RankPosition rankPosition);

/**
* Adds a new move to the list of moves
Expand Down Expand Up @@ -107,22 +110,24 @@ public interface ControllerInterface {
public void changeMoves(int targetMove);

/**
* Assigns a command to the given rank in the current move. Displays an
* Assigns a command to the given rank in the current move. Returns an
* error message if it could not add a command to the rank.
*
* @param rankName
* - the rank to add a command to
* @param commandPair
* - the command and number of counts
* @param rankName - the rank to add a command to
* @param commandPair - the command and number of counts
* @return - An error messsge iff assigning the command failed. An empty string
* otherwise.
*/
public void assignCommand(String rankName, CommandPair commandPair);
public String assignCommand(String rankName, CommandPair commandPair);

/**
* Sets the selected rank to the specified rank
* Sets the selected rank to the specified rank and updates the view.
*
* @param rankName - the rank name of the new selected rank
* @return - An error messsge iff setting the selected rank failed. An empty
* string otherwise.
*/
public void addSelectedRank(String rankName, boolean reset);
public String addSelectedRank(String rankName, boolean reset);

/**
* Removes any current rank selection
Expand Down Expand Up @@ -158,11 +163,14 @@ public void setSongConstants(HashMap<Integer, Integer> tempoHashMap,
HashMap<Integer, Integer> countsHashMap, String songName);

/**
* Removes the selected commands from the selected rank for the current move
* Removes the selected commands from the selected rank for the current move and
* updates the display.
*
* @param commandIndices - the index of commands to be removed
* @return - An error messsge iff removing the command failed. An empty string
* otherwise.
*/
public void removeCommands(int[] commandIndices);
public String removeCommands(int[] commandIndices);

/**
* Gets the tempo changes throughout this song
Expand Down Expand Up @@ -212,45 +220,66 @@ public void setSongConstants(HashMap<Integer, Integer> tempoHashMap,
public HashMap<String, RankPosition> getPlaybackPositions();

/**
* Rename the specified command to a new name, but keep the same functionality
* Renames the specified command to a new name, but keep the same functionality.
* Updates the display afterwards.
*
* @param index - the index of the command to be renamed
* @param name - the new name of the command
* @param name - the new name of the command
* @return - An error messsge iff renaming the command failed. An empty string
* otherwise.
*/
public void renameCommand(int index, String name);
public String renameCommand(int index, String name);

/**
* Moves the specified commands up in the queue of commands
* Moves the specified commands up in the queue of commands. Updates the display
* afterwards.
*
* @param commandIndices - the indices of commands to be moved up
* @return - An error messsge iff moving the command failed. An empty string
* otherwise.
*/
public void moveCommandsUp(int[] commandIndices);
public String moveCommandsUp(int[] commandIndices);

/**
* Moves the specified commands down in the queue of commands
* Moves the specified commands down in the queue of commands. Updates the
* display afterwards.
*
* @param commandIndices - the indices of commands to be moved down
* @return - An error messsge iff moving the command failed. An empty string
* otherwise.
*/
public void moveCommandsDown(int[] commandIndices);
public String moveCommandsDown(int[] commandIndices);

/**
* Merges the specified commands if they are of the same type
* into one command of their combined length
* into one command of their combined length. Updates the
* display afterwards.
*
* @param commandIndices - the indices of commands to be merged
* @return - An error messsge iff merging the command failed. An empty string
* otherwise.
*/
public void mergeCommands(int[] commandIndices);
public String mergeCommands(int[] commandIndices);

/**
* Splits the specified command into two separate commands of the same type
* at the count specified
* Splits the specified command at the given index into two separate commands of
* the same type at the count specified. Updates the display afterwards.
*
* @param index - the index of command to be split
* @param count - the count at which the command will be split
* @return - An error message if one occurs
*/
public String splitCommand(int index, int count);

/**
* Returns an error string if the command at the given index cannot be split.
* Otherwise, returns an empty string.
*
* @param index - The index of the command to split.
* @return - An error string if the command at the given index cannot be split.
*/
public String canSplit(int index);

/**
* Exports the project to a PDF file
*
Expand All @@ -273,29 +302,30 @@ public void setSongConstants(HashMap<Integer, Integer> tempoHashMap,
public void setMoveComment(String comment);

/**
* Returns the number of the current move
*
* @return - the number of the current move
*/
public int getCurrentMove();

/**
* Returns additional indicators to be displayed to the user not stored as ranks
* Returns the number of the current move.
*
* @return - a hashmap mapping the name of the indicator to its position
* @return - the number of the current move.
*/
public HashMap<String, RankPosition> getTransientRanks();
public int getCurrentMoveNumber();

/**
* Adds a temporary indicator to show the user how the rank would look if drawn to
* the current position
*
* @param temporaryDrawingRank - the position of the indicator to be drawn
* Returns the current move.
*
* @return - the current move.
*/
public void addTemporaryDrawingRank(RankPosition temporaryDrawingRank);
public Move getCurrentMove();

public void updateInitialPosition(String rankName, RankPosition newPos);

void deleteMove(int moveNum);
public void deleteMove(int moveNum);

/**
* Gets the set of shared commands for the given rankNames and their commands.
*
* @param rankNames - The rankNames for which to fetch shared commands.
* @param commands - The commands for which to fetch shared commands.
* @return An ArrayList containing the shared commands.
*/
public ArrayList<CommandPair> getSharedCommands(HashSet<String> rankNames, HashMap<String, ArrayList<CommandPair>> commands);

}
Loading

0 comments on commit 5f1b081

Please sign in to comment.