From 55023ceb79fb650e53b66a11dd115f5084e31ba2 Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Sat, 8 Aug 2015 20:02:15 -0500 Subject: [PATCH] Added cloning for user types --- .../ui/impl/GlobalEditorTabControllerImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/GlobalEditorTabControllerImpl.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/GlobalEditorTabControllerImpl.java index 1dbef10c..c70f3710 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/GlobalEditorTabControllerImpl.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ui/impl/GlobalEditorTabControllerImpl.java @@ -162,6 +162,22 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController { @Override protected void onDataTypeClonePressed(ActionEvent event) { + UserType source = dataTypeList.getSelectionModel().getSelectedItem(); + if (source == null) { + String message = "First select a data type and then press Clone"; + UIAction.alert(message); + } else { + try { + UserType newType = TransferHelper.cloneObject(source, UserType.class, "userType"); + newType.setName(source.getName() + " CLONE"); + Application.gameData.getGlobal().getUserTypes().getUserType().add(newType); + redrawGlobalDataTypes(); + UIAction.editUserType(newType); + } catch (JAXBException ex) { + Logger.getLogger(MapEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex); + UIAction.alert("Error occured when attempting clone operation:\n" + ex.getMessage()); + } + } } @Override