for (TreePath path : selectedTreePaths) {
MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();
MCTMutableTreeNode parentNode = (MCTMutableTreeNode) selectedNode.getParent();
AbstractComponent parentComponent = ((View) parentNode.getUserObject()).getManifestedComponent();
AbstractComponent selectedComponent = ((View) selectedNode.getUserObject()).getManifestedComponent();
if (selectedComponent == null) {
OptionBox.showMessageDialog(null, "Unable to create duplicate of this object!", "Error creating duplicate.", OptionBox.ERROR_MESSAGE);
return;
}
DuplicateObjectDialog dialog = new DuplicateObjectDialog(actionContext.getTargetHousing().getHostedFrame(),
selectedComponent.getDisplayName());
String name = dialog.getConfirmedTelemetryGroupName();
if (!StringUtil.isEmpty(name)) {
AbstractComponent duplicate = selectedComponent.clone();
ComponentInitializer ci = duplicate.getCapability(ComponentInitializer.class);
ci.setCreator(GlobalContext.getGlobalContext().getUser().getUserId());
ci.setOwner(GlobalContext.getGlobalContext().getUser().getUserId());
duplicate.setDisplayName(name);
duplicate.save();
parentComponent.addDelegateComponent(duplicate);
parentComponent.save();
}
}