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

Removed warning in Edit main page and InMemoryFlashcardSet.java #102

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ public void editTitleAndDescription(FlashcardSetDsRequestModel flashcardSet) {
@Override
public void saveFlashcardID(int flashcardSetId, int flashcardId) {
FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId);
String title = oldFlashcardSet.getTitle();
String description = oldFlashcardSet.getDescription();
boolean isPrivate = oldFlashcardSet.getIsPrivate();
List<Integer> flashcardIds = oldFlashcardSet.getFlashcardIds();
String owner = oldFlashcardSet.getOwnerUsername();

ArrayList<Integer> newFlashcardIds = new ArrayList<>(flashcardIds);
newFlashcardIds.add(flashcardId);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(
oldFlashcardSet.getTitle(),
oldFlashcardSet.getDescription(),
oldFlashcardSet.getIsPrivate(),
flashcardSetId,
oldFlashcardSet.getOwnerUsername(),
newFlashcardIds);

flashcardSets.put(flashcardSetId, newFlashcardSet);
}
Expand All @@ -77,15 +79,16 @@ public void saveFlashcardID(int flashcardSetId, int flashcardId) {
@Override
public void removeFlashcardId(int flashcardSetId, int flashcardId) {
FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId);
String title = oldFlashcardSet.getTitle();
String description = oldFlashcardSet.getDescription();
boolean isPrivate = oldFlashcardSet.getIsPrivate();
List<Integer> flashcardIds = oldFlashcardSet.getFlashcardIds();
String owner = oldFlashcardSet.getOwnerUsername();

ArrayList<Integer> newFlashcardIds = new ArrayList<>(flashcardIds);
newFlashcardIds.remove(flashcardId);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(
oldFlashcardSet.getTitle(),
oldFlashcardSet.getDescription(),
oldFlashcardSet.getIsPrivate(),
flashcardSetId,
oldFlashcardSet.getOwnerUsername(),
newFlashcardIds);

flashcardSets.put(flashcardSetId, newFlashcardSet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public ListOfFlashcardsDataPanel(DBGateway dbGateway, List<FlashcardDsRequestMod
int numCards = flashcardData.size();
if (numCards == 0){
JLabel label = new JLabel("You have no Flashcards in this FlashcardSet.");
//label.setHorizontalAlignment(SwingConstants.CENTER);
//label.setVerticalAlignment(SwingConstants.TOP);
JPanel labelPanel = new JPanel();
labelPanel.add(label);
flashcardPanels.add(labelPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;

/**
* The results screen where the user can
Expand Down Expand Up @@ -84,8 +85,10 @@ public SearchResultsScreen(SearchResponseModel responseModel, DBGateway gateway,
}
});
JButton edit = new JButton("Edit");
edit.addActionListener((e) -> new EditorMainScreen(responseModel.getResult_set().get(tempX)
.getFlashcardSetId()));
edit.addActionListener((e) -> {
EditorMainScreen editor = new EditorMainScreen(responseModel.getResult_set().get(tempX).getFlashcardSetId());
editor.addWindowListener(new WindowAdapter() {});
});
JButton delete = new JButton("Delete");
delete.addActionListener(e -> {
DeleteFlashcardSetOutputBoundary presenter = new DeleteFlashcardSetPresenter();
Expand Down