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

GUI: IndexOutOfBoundsException #575

Open
cdalexndr opened this issue Jul 9, 2020 · 10 comments
Open

GUI: IndexOutOfBoundsException #575

cdalexndr opened this issue Jul 9, 2020 · 10 comments
Assignees
Labels
Milestone

Comments

@cdalexndr
Copy link

java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 2
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:458)
	at pl.otros.vfs.browser.list.MutableListModel.getElementAt(MutableListModel.java:40)
	at pl.otros.vfs.browser.VfsBrowser$5.actionPerformed(VfsBrowser.java:439)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1020)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1064)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6397)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at pl.otros.logview.exceptionshandler.EventQueueProxy.dispatchEvent(EventQueueProxy.java:31)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
	at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
	at java.desktop/java.awt.Dialog.show(Dialog.java:1070)
	at java.desktop/java.awt.Component.show(Component.java:1716)
	at java.desktop/java.awt.Component.setVisible(Component.java:1663)
	at java.desktop/java.awt.Window.setVisible(Window.java:1031)
	at java.desktop/java.awt.Dialog.setVisible(Dialog.java:1005)
	at pl.otros.vfs.browser.JOtrosVfsBrowserDialog.showOpenDialog(JOtrosVfsBrowserDialog.java:99)
	at pl.otros.logview.gui.editor.LogPatternParserEditorBase.selectLogFileAndLoad(LogPatternParserEditorBase.java:266)
	at pl.otros.logview.gui.editor.LogPatternParserEditorBase.lambda$createActions$1(LogPatternParserEditorBase.java:189)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6397)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at pl.otros.logview.exceptionshandler.EventQueueProxy.dispatchEvent(EventQueueProxy.java:31)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

File select dialog.
Add favorite two times to create duplicate.
Right click -> delete one duplicate.

OtrosLogViewer 1.4.13

@svennissel
Copy link
Collaborator

I think this bug is fixed with #262. I cannot reproduce it

@svennissel svennissel added the bug label Apr 7, 2022
@benlazaro
Copy link
Contributor

Alright... I was finally able to reproduce this problem running the code from the master branch.
The steps to reproduce the issue are:

  1. Click on the "File" menu and then click on "Open log files".
  2. Add 1 or more favorites to the favorites list by clicking on the "Add favorite" icon (top right on the "open file" dialog window). It doesn't need to be more than one, so one should be enough.
  3. Now comes the important part, without left clicking on any of the favorite items in the favorites list (i.e. do not select any items from the list), right click over one of those favorite items, and the context menu for favorite items will display.
  4. Click on the "delete" menu item in the favorite's context menu and another dialog windows opens showing the IndexOutOfBoundsException

The problem here is when we try to delete an item from the favorites list without ever giving the focus to the favorites list. In other words, if we select one of the items from the list before we try to delete, this error never happens. Right after deleting that item, the first item in the list gets automatically selected, so if we right click over the last item on the list and select the delete option, the first item in the list is the one that gets deleted, because that's the one that was selected. This is misleading because when we right click over an item in the list and the context menu is displayed, it gives the impression that the menu is for the item the cursor was over when the right click was performed.

The are a few ways to fix this problem, but I'm only going to suggest the one that I like the most. When we right click on any of the items in the favorites list, the item under the cursor should be automatically selected (display highlighted) and then we can display the context menu for that item. Only then the user can proceed to delete the item. I've seen other apps work like this so I bet many users are used to that behavior, including @cdalexndr :p

@svennissel I can work on fixing this issue. Can you assign it to me?

@svennissel svennissel added this to the 1.4.17 milestone Apr 21, 2022
@svennissel
Copy link
Collaborator

This is a good way to fix it. Thank you.

I think the project is active again. Did you have an idear how we can discuss other things like next steps, releases an other thinks? Did we need something like a forum?

@svennissel
Copy link
Collaborator

[email protected]

@p91paul
Copy link

p91paul commented Apr 21, 2022

Github has a discussions feature you can enable on the project!

@benlazaro
Copy link
Contributor

@svennissel yeah, I like how we’re getting a lot of activity going on in this project. That’s awesome!
So I do have a few ideas a would like to discuss. If you can enable the discussions feature that @p91paul is suggesting, we can use it and have other people see the discussions and collaborate with us.

@benlazaro
Copy link
Contributor

@svennissel check this out: https://docs.github.com/en/discussions/quickstart
That is the github documentation for enabling discussions in the project. If you have access to do that, it would be very helpful for starting discussions regarding release versioning, unit tests in code collaborations, reproducing error before submitting a PR, Code quality, etc. I think that's going to send this project to the next level!

@svennissel
Copy link
Collaborator

Ahh thanks. But I have no permissions to change this. I will ask the otros owner.

benlazaro added a commit to benlazaro/otroslogviewer that referenced this issue Apr 23, 2022
… cell when it's selected | Updated the behavior of the right click on the list of Favorite locations so that the cell clicked over gets selected and then the popup menu is displayed
@svennissel svennissel modified the milestones: 1.4.17, 1.4.18 Apr 24, 2022
@svennissel
Copy link
Collaborator

@benlazaro I you are ready, please create a pull request?

@benlazaro
Copy link
Contributor

I'm not done with this yet. The code in the "open file" dialog class it's basically a God Class. I has so much code and there is not separation of concerns that I'm actually fixing the whole thing for maintainability purposes. I got a fix for the bug, but there are some other minor UI functionalities that I have to take care of as well, that's why I decided to improve the code maintainability so that we can easily make changes later.
I'll send you the pull request once I'm done with all these changes. Hopefully I will be done before we release version 1.4.18

@svennissel svennissel modified the milestones: 1.4.18, 1.4.19 Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants