zoyasiddiqui / NoteNinja

A note-taking app with python code snippets and AI helpers.
MIT License
3 stars 1 forks source link

RenameNote use case not working. #6

Closed mrdandelion6 closed 9 months ago

mrdandelion6 commented 10 months ago

Problem:

I have created a use case for naming/renaming notes while on the EditNoteView screen. You can find my attempt at implementing this feature in pull request #5. Everything is being called all the way up to propertyChange(evt) in EditNoteView, you can test this with System.out.println(). However, when propertyChange(evt) is called, nothing happens. The button does not get recreated as expected. In fact it becomes unclickable.

Suggestion:

I believe the issue is because propertyChange(evt) currently creates a new JButton each time it is called, so perhaps the buttons are overlapping. We must figure out a way for it to reset the text of the current button, or delete the current button and create a new one with the updated text. The text is already there for us to use in the propertyChange(evt) method, given to us by the following code:

EditNoteState editState = this.editViewModel.getState(); String noteTitle = editState.getNoteTitle();

All that is left to do is update the button properly.

mrdandelion6 commented 9 months ago

Solved the Issue!

public void propertyChange(PropertyChangeEvent evt) {
        // Handle property changes if needed
        System.out.println("*pChange EditView"); // for debugging, delete later
        noteTitleButton.setText(editViewModel.getState().getNoteTitle());

    }

This fix ensures that the button text reflects the most recent note title changes. We no longer recreate the whole button in propertyChange(PropertyChangeEvent evt), but rather just call setText on the button and set the current chosen title.

mrdandelion6 commented 9 months ago

Reopened issue to show as an issue temporarily (it is already resolved).