*/
public void add(Collection<File> selectedFiles, boolean recursive) {
ProfileForm selectedProfile = droidContext.getSelectedProfile();
DefaultTreeModel treeModel = selectedProfile.getTreeModel();
ProfileInstance profile = selectedProfile.getProfile();
ProfileSpec profileSpec = profile.getProfileSpec();
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
for (File selectedFile : selectedFiles) {
AbstractProfileResource newResource;
// VERY basic shortcut detection:
boolean isShortcut = !selectedFile.toURI().getPath().endsWith("/");
if (selectedFile.isDirectory() && !isShortcut) {
newResource = new DirectoryProfileResource(selectedFile, recursive);
} else {
newResource = new FileProfileResource(selectedFile);
}
if (profile.addResource(newResource)) {
ProfileResourceNode primordialNode = new ProfileResourceNode(newResource.getUri());
final NodeMetaData metaData = primordialNode.getMetaData();
metaData.setName(newResource.getUri().getPath());
metaData.setNodeStatus(NodeStatus.NOT_DONE);
metaData.setResourceType(
newResource.isDirectory() ? ResourceType.FOLDER : ResourceType.FILE);
DefaultMutableTreeNode node = new DefaultMutableTreeNode(primordialNode, false);
int index = rootNode.getChildCount();
treeModel.insertNodeInto(node, rootNode, index);
}
}
profileManager.updateProfileSpec(profile.getUuid(), profileSpec);
// if (profile.isDirty()) {
// selectedProfile.onResourceChanged();
// }
}