Skip to content

Commit

Permalink
Action List Context Menu Deep Copy (#392)
Browse files Browse the repository at this point in the history
Make the context menu buttons for the action list do a deep copy instead of a shallow copy of the transferred actions. The `ActionsPaste` method now iterates the action list being transferred and deep copies each of the actions before adding them to the target's model. Also updated the comments of the other deep copy locations for clarity and fixed the indentation of a for loop which was ambiguous. Finally, update the copyright year to extend through 2018 and into 2019.
  • Loading branch information
RobertBColton authored Apr 14, 2019
1 parent 7114a6f commit 5014b7a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions org/lateralgm/components/ActionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ public boolean importData(TransferHandler.TransferSupport info)
LGM.showDefaultExceptionHandler(e);
return false;
}
//clone properly for drag-copy or clipboard paste
// deep copy for drag-copy or clipboard paste
if (!info.isDrop() || info.getDropAction() == COPY) a = a.copy();
if (info.isDrop() && info.getDropAction() == MOVE && indices != null)
{
Expand All @@ -967,9 +967,10 @@ public boolean importData(TransferHandler.TransferSupport info)
LGM.showDefaultExceptionHandler(e);
return false;
}
//clone properly for drag-copy or clipboard paste
if (!info.isDrop() || info.getDropAction() == COPY) for (int i = 0; i < a.size(); i++)
a.set(i,a.get(i).copy());
// deep copy for drag-copy or clipboard paste
if (!info.isDrop() || info.getDropAction() == COPY)
for (int i = 0; i < a.size(); i++)
a.set(i,a.get(i).copy());
if (info.isDrop() && info.getDropAction() == MOVE && indices != null)
{
addIndex = index;
Expand Down Expand Up @@ -1369,6 +1370,11 @@ public void ActionsPaste(JList<Action> list)
if (ind < 0) {
ind = alm.getSize();
}
// perform a deep copy of the actions so editing them
// does not change the original ones we transferred
for (int i = 0; i < actions.size(); i++)
actions.set(i,actions.get(i).copy());

alm.addAll(ind, (List<Action>) actions);
list.setSelectionInterval(ind,ind += actions.size() - 1);
}
Expand Down
2 changes: 1 addition & 1 deletion org/lateralgm/main/LGM.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

public final class LGM
{
public static final String version = "1.8.42"; //$NON-NLS-1$
public static final String version = "1.8.43"; //$NON-NLS-1$

// TODO: This list holds the class loader for any loaded plugins which should be
// cleaned up and closed when the application closes.
Expand Down
2 changes: 1 addition & 1 deletion org/lateralgm/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ DocumentUndoManager.UNDO=Undo
DocumentUndoManager.REDO=Redo

AboutBox.TITLE=About LateralGM
AboutBox.ABOUT=<h1 style="white-space: nowrap">Copyright &copy; 2006-2017</h1>\
AboutBox.ABOUT=<h1 style="white-space: nowrap">Copyright &copy; 2006-2019</h1>\
<p style="white-space: nowrap">Version: {0}<br><br>\
IsmAvatar \
&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;<br>\
Expand Down

0 comments on commit 5014b7a

Please sign in to comment.