// Path: src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDevice.java
// public interface AndroidDevice {
// 
//     String executeCommand(String command);
// 
//     List<FileInfo> list(String path);
// 
//     void openUrl(String url);
// 
//     void pullFile(String remoteFrom, File localTo);
// 
//     void pushFile(File localFrom, String remoteTo);
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java
// @Singleton
// public final class FileInfo {
// 
//     public AndroidDeviceImpl device;
//     public String path;
//     public String attribs;
//     public boolean directory;
//     public String name;
// 
//     @Inject
//     public FileInfo() {
//     }
// 
//     public File downloadTemporary() {
//         try {
//             File tempFile = File.createTempFile("android", name);
//             device.pullFile(path + name, tempFile);
//             tempFile.deleteOnExit();
//             return tempFile;
//         } catch (IOException ex) {
//             throw new IORuntimeException(ex);
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/AndroidScreenCastRuntimeException.java
// public class AndroidScreenCastRuntimeException extends RuntimeException {
// 
//     private String additionalInformation;
// 
//     public AndroidScreenCastRuntimeException() {
//     }
// 
//     public AndroidScreenCastRuntimeException(String message) {
//         super(message);
//     }
// 
// 
//     public AndroidScreenCastRuntimeException(String message, String additionalInformation) {
//         super(message);
//         this.additionalInformation = additionalInformation;
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
//     public String getAdditionalInformation() {
//         return additionalInformation;
//     }
// }


import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.github.xsavikx.androidscreencast.api.AndroidDevice;
import com.github.xsavikx.androidscreencast.api.file.FileInfo;
import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException;
import javax.inject.Inject;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
                if (e.getClickCount() == 2) {
                    int index = jListFichiers.locationToIndex(e.getPoint());
                    ListModel<Object> dlm = jListFichiers.getModel();
                    FileInfo item = (FileInfo) dlm.getElementAt(index);
                    launchFile(item);
                }
            }
        });
    }

    private void displayFolder(String path) {
        List<FileInfo> fileInfos = cache.get(path);
        if (fileInfos == null)
            fileInfos = androidDevice.list(path);

        List<FileInfo> files = new ArrayList<>();
        for (FileInfo fi2 : fileInfos) {
            if (fi2.directory)
                continue;
            files.add(fi2);
        }
        jListFichiers.setListData(files.toArray());

    }

    private void launchFile(FileInfo node) {
        try {
            File tempFile = node.downloadTemporary();
            Desktop.getDesktop().open(tempFile);
        } catch (Exception ex) {
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDevice.java
// public interface AndroidDevice {
// 
//     String executeCommand(String command);
// 
//     List<FileInfo> list(String path);
// 
//     void openUrl(String url);
// 
//     void pullFile(String remoteFrom, File localTo);
// 
//     void pushFile(File localFrom, String remoteTo);
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java
// @Singleton
// public final class FileInfo {
// 
//     public AndroidDeviceImpl device;
//     public String path;
//     public String attribs;
//     public boolean directory;
//     public String name;
// 
//     @Inject
//     public FileInfo() {
//     }
// 
//     public File downloadTemporary() {
//         try {
//             File tempFile = File.createTempFile("android", name);
//             device.pullFile(path + name, tempFile);
//             tempFile.deleteOnExit();
//             return tempFile;
//         } catch (IOException ex) {
//             throw new IORuntimeException(ex);
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/AndroidScreenCastRuntimeException.java
// public class AndroidScreenCastRuntimeException extends RuntimeException {
// 
//     private String additionalInformation;
// 
//     public AndroidScreenCastRuntimeException() {
//     }
// 
//     public AndroidScreenCastRuntimeException(String message) {
//         super(message);
//     }
// 
// 
//     public AndroidScreenCastRuntimeException(String message, String additionalInformation) {
//         super(message);
//         this.additionalInformation = additionalInformation;
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(Throwable cause) {
//         super(cause);
//     }
// 
//     public AndroidScreenCastRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
//     public String getAdditionalInformation() {
//         return additionalInformation;
//     }
// }


// Path: src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/JFrameExplorer.java
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.github.xsavikx.androidscreencast.api.AndroidDevice;
import com.github.xsavikx.androidscreencast.api.file.FileInfo;
import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException;
import javax.inject.Inject;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;

                if (e.getClickCount() == 2) {
                    int index = jListFichiers.locationToIndex(e.getPoint());
                    ListModel<Object> dlm = jListFichiers.getModel();
                    FileInfo item = (FileInfo) dlm.getElementAt(index);
                    launchFile(item);
                }
            }
        });
    }

    private void displayFolder(String path) {
        List<FileInfo> fileInfos = cache.get(path);
        if (fileInfos == null)
            fileInfos = androidDevice.list(path);

        List<FileInfo> files = new ArrayList<>();
        for (FileInfo fi2 : fileInfos) {
            if (fi2.directory)
                continue;
            files.add(fi2);
        }
        jListFichiers.setListData(files.toArray());

    }

    private void launchFile(FileInfo node) {
        try {
            File tempFile = node.downloadTemporary();
            Desktop.getDesktop().open(tempFile);
        } catch (Exception ex) {
            throw new AndroidScreenCastRuntimeException(ex);