ActionList fixes for stable branch. #264

Merged
merged 4 commits into from Apr 12, 2016

Conversation

Projects
None yet
1 participant
@RobertBColton
Collaborator

RobertBColton commented Apr 9, 2016

This ticket attempts to address several issues and various exceptions with the lgm16b4 action list. I have tested this as extensively as I could and I believe that this corrects all of the inconsistencies with the transfer handler and fully resolves #170 for the stable branch.

  • *.log is added to .gitignore because those are error logs output by the JVM and I almost committed them by accident
  • In 16b4 an exception occurs when dragging more than one action over the project tree or over other controls with transfer handlers. The reason for this is because ActionListTransferable was accidentally constructing its flavor array with a null flavor, because of what seems to be a simple typo. The code there conditionally builds an ArrayList of data flavors and then converts it to an array, so obviously it should construct the array with the size of that ArrayList. The fix is the single change on line 430 of ActionList.java
  • getSelectedValues() is a deprecated method and getSelectedValuesList() should be used instead. Important to note that the new method was introduced in Java 7, so that may fail in older JVMs. This is addressed by the changes on lines 603-605 or what is now lines 613-615
    • NOTE: We decided against this for now and will later break compatibility with older JVMs when we have more reasons to do so.
  • The reason for changing the less than operator on line 487 to less-than-or-equal is to address an issue with discontinuous multiple selections. This is something not accounted for in the official Java Swing examples. What happens in 16b4 if you add 3 actions, select the first and last with CTRL, and then drag and drop them at index 0 is that the third action will come first followed by what was the first and then finally what was the second. Also if you select the first and the second and then try to drag and drop them at the index between each other the first action will become a duplicate of the second one.
  • The changes on lines 527-528 correct the behavior of the paste action. When you pasted actions before it always appended them to the end of the list. Now it will append them to just before the action you have selected, or at the end if the list has no current selection. Which we also discussed and agreed upon in #170
  • Finally, the changes that check if indices is null fixes an issue regarding dragging and dropping between two different action lists. This is also an issue the official Java drag and drop example does not account for. The issue can be reproduced in 16b4 by creating two objects, adding two actions to the create event of one of the objects, selecting both actions and dragging them to the second object and then back. What happens is that addIndex is set the first time the second object imports data, but is not cleared because exportDone is never called on it since it came from the first object list. Because it is never cleared it causes it to misbehave when you drag back to the original object. addIndex and addCount are only useful when dragging and dropping in the same list, to account for the old actions being removed.

RobertBColton added some commits Apr 9, 2016

Add type information
But Josh said to not go crazy. This still leaves a warning on the first
line though because the cast of JComponent to JList<Action> is unchecked.
Revert changes about deprecated method
Me and Josh have decided against breaking compatibility with older JVMs at
this point because we do not have sufficient justification for doing so. I
will keep a list of reasons for breaking compatibility in the stable topic
on the forum. When there are sufficient reasons, Josh can decide whether
to go ahead and break compatibility.
Helper method
Extract helper method to stash the import range for export done.

@RobertBColton RobertBColton merged commit 96a9352 into IsmAvatar:stable Apr 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment