-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added information in the tool tip for undo and redo and disabled when… #1565
Conversation
Shouldn't this be queriable from the undo/redo action? So each action that can be made undo/redo should have an identifier describing its action. |
You mean basically move the Yes, that might be a better idea. However, I'm not really sure if one also needs to change the corresponding classes in the preamble editor and string dialog. (Nor, actually, how it works there now...) |
It can indeed be queried. However, the actual undo/redo classes are in BasePanel but the actions associated to menu and toolbar are defined in JabRefFrame, providing the undo/redo class instance. So, the undo/redo class have no idea about its tooltip. When I tried it out now, it appeared much more flaky, completely ignoring "change field" edits. No idea why this happens as it worked well earlier. This happens also in master so trying to figure out what might have changed... Most (all?) other types of edits can be undone, but "change field"... |
@JabRef/developers : I'm not opening a new issue, but can you please check to see if you can undo field changes in the current master? It seems like it stopped working sometime between creating this PR and now. From debugging I can tell that I've looked through the recent commits multiple times to try to figure out what have changed, but at no luck... |
@JabRef/developers: Just after posting, I think I found the issue... No emergency... |
I don't like that the UndoManager has to know about the frame. Thus I would propose to use "inversion of control" here. That is, the CountingUndoManager throws an event (using the new EventBus) whenever the last undoable action changes. In the frame you can then subscribe to this event and change the display accordingly. In the event you can store the undoable event (of type Using events in a similar manner, you can also move the |
OK, EventBus is introduced and I think the structure is clearly better. It would now be nice if there are more "advanced" |
There is a minor flaw which may not be so easy to solve (and is not that serious): if one makes an edit in the entry editor and directly selects a different tab, the undo/redo state is from the previous tab. Also, when trying to undo in the new tab, the state is not updated as an Exception is thrown and the code never gets to the place where the update is done. |
Rebased. Anything else here? |
package net.sf.jabref.logic.undo; | ||
|
||
|
||
public class UndoRedoEvent extends AddUndoEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My head is spinning by thinking about UndoRedoEvents, as undo and redo should cancel each other out, leaving only a event? Can you please document this? And the AddUndoEvent als well? What should be described in these events? When are they fired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, I also don't get why UndoRedo derives from AddUndo. I would prefer if only one event UndoableActionChangedEvent
would be needed, i.e. one event for adding a new undo action and the same event is fired when an action is "redoed".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just duplicate the code and do not introduce inheritance if it is semantically inadequate.
Maybe the meaning of "AddUndoEvent" gets clearer if it is named "AddUndoableActionEvent"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for code duplication in that case.
👍 for "AddUndoableActionEvent", but still, is this just not something that is happening automatically because of other events? So do we really need this event as such? To add an undoable item to the undo manager seems a little bit too low from a granularity point of view. We should add the event that a save was triggered, and this would then be also the "AddUndoableActionEvent" as it was a save event. Does this make sense?
👍 for "UndoOrRedoEvent"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create a common base event like Undo(Manager?)ChangedEvent
and let both events derive from this new class.
JabRef#1565) * Added information in the tool tip for undo and redo and disabled when no undo/redo is available
A tool tip text is shown describing the undo/redo action. Also, the undo/redo buttons are enabled/disabled when there are things to undo/redo.
Current problem is that it doesn't work on startup (both undo and redo is enabled as before), but as soon as one edit is done it works just fine.
… no undo/redo is available